Skip to content

WindowsProcess: unable to detect closure of program #15

@massimilianodelliubaldini

Description

Hello again! Thanks for your fix to #13! I'm making more progress on using PME because of it. Unfortunately I'm back to report another problem. On Windows, it seems that the __closed property of a WindowsProcess is not set to True correctly when I close out of a program (hitting the X on the window).

This leaves my code in a state where I can still read_process_memory on the closed process. Naturally, this returns all 0's. But my use case is a 1/10th of a second polling function just to check that process is still alive, and show the user a message if it crashes/dies. Even if I was checking the value of __closed rather than reading memory, it still holds False.

Here's a shell window showing me creating an OpenProcess instance of a running program, closing the program, and then reading its memory.

>>> gk = OpenProcess(process_name="gk.exe")
>>> gk
<PyMemoryEditor.win32.process.WindowsProcess object at 0x00000293B1CB1BE0>

...
I close the app here.
...

>>> gk.pid
4224
>>> gk.read_process_memory(0, bytes, 1)
b'\x00'
>>> gk.read_process_memory(0, bytes, 100)
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions