How to Resolve ERROR_NOACCESS (0x3E6) When Injecting Assembly Code into a PE File Using CreateThread
I encountered an issue when injecting my assembly program asm.txt into a portable executable file to run a keylogger using
CreateThread
. CreateThread
was failing with the error code 0x3E6 (ERROR_NOACCESS)
.
I've been suspecting it could be stack issues, memory protection issue, or me passing the wrong parameters to CreateThread
, but I haven't been able to pinpoint the exact cause.
Where is the error in my assembly code? How can I resolve the ERROR_NOACCESS
error and successfully create the thread to run my keylogger in the injected PE file?5 Replies
@Marvee Amasi The
ERROR_NOACCESS (0x3E6)
error in your CreateThread
call is likely due to memory access
or parameter issues. Ensure the memory
where your injected code
resides has proper permissions
using VirtualProtect
(PAGE_EXECUTE_READWRITE
). Also, verify that the stack
is 16-byte
aligned before calling CreateThread
, and re-check
that the parameters you're passing are correct. If you're injecting code into another process, make sure it allows execution of injected threads, and consider security features like DEP and ASLR that may need to be addressed.I guess I am even complicating things the more . I need to calm down, and take my time to verify , altho I am under pressure doing this task
Yea coding might be more tasking at times and even cause severe headaches, that's y u never 4get ur coffee ☕
So after further debugging, I found that I hadn't correctly initialized the stack. Once I added the following initialization to the code, the keylogger started working correctly:
With this fix, the keylogger now works perfectly. Thanks for the help @Renuel Roberts