Skip to content

Fix incorrect thread with main_thread property #163

Open
SilicDev wants to merge 1 commit into
srounet:masterfrom
SilicDev:fix-main_thread
Open

Fix incorrect thread with main_thread property #163
SilicDev wants to merge 1 commit into
srounet:masterfrom
SilicDev:fix-main_thread

Conversation

@SilicDev

Copy link
Copy Markdown

Fixes the issue that main_thread would return an incorrect thread object
Inherently the issue is that the generator enum_process_thread acts in place so when sorted tries to create the array to sort, the generator returns the same reference pointer, with changed values after every call, resulting in n copies of the last entry in the thread32 list. This is not even guaranteed to be a thread to be owned by the source process, hence why the query_teb of the ThreadEntry32 fails as the targeted memory is not owned by the source process. Can confirm with this fix I can obtain the SMALL_TEB as seen https://github.com/SilicDev/Archipelago/blob/yohane-deepblue/worlds/yohane_deepblue/client.py#L253

This fix might not be ideal, but it fixes the issue blocking the teb feature.

@StarrFox

Copy link
Copy Markdown
Collaborator

can you try this branch and see if the issue persists

https://github.com/srounet/Pymem/tree/enum_process_thread_realloc

@SilicDev

Copy link
Copy Markdown
Author

This indeed seems to fix the issue
I suppose the issue ended up being the byref instead of the generator itself then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants