Pymem
Pymem copied to clipboard
Python interpreter injection
Describe the bug Whenever injecting the python interpreter into any process theres a good 50/50 chance it'll crash the program, been dealing with this ever since 3.11 came out because i didnt wanna reinstall 3.10 specifically for pymem
Your Environment
- python version - happens in both 3.11.5 and 3.12.0
- os version - Windows 11 10.0.22621 Build 2261
- pymem version - 1.12.0 and 1.13.0 although version of pymem shouldnt matter
Expected behavior The python interpreter sucessfully injects without crashing the program
Traceback The only traceback that happens is
raise RuntimeError('Could not allocate memory for shellcode') RuntimeError: Could not allocate memory for shellcode
ctypes.getlasterror returns 5 (access denied) because the python interpreter crashed the program so its trying to write to a non existent process
theirs no traceback when injecting the python interpreter
I've done some debugging on this and was able to reproduce the crashes with 3.12 but not 3.11; from what I've gathered from debugging the process we're injecting into it seems that the global object allocator is not being set for some reason
it should be getting set by our initialize call which I've confirmed is being called
Is there any fix to this. I don't want to use any other lib for python as of now and injecting the interpreter seems to me as the only reason to use pymem.
It's because it's wayyy too good, but it doesn't work unfortunately.