How to get the Address of a ntdll function when it's loaded twice?

1.2k views Asked by At

I intend to hook into a ntdll function ZwTerminateProcess, but am having a problem with x64, because if a x86 app is running in a windows x64 , it is loaded with two ntdlls: One from System32 path and the other one from SysWOW64.

Until here I have no problems, except: the first ntdll(system32) don't show up when I list dlls using CreateToolhelp32Snapshot() or EnumProcessModules() and when I use GetModuleHandle() the return is the hModule from the second ntdll(SysWOW64).

I was thinking that maybe the first dll was loaded with LOAD_LIBRARY_AS_DATAFILE flag but if it were the case the app would not be able to use the function from the first ntdll(System32). I have tried to hook the ZwTerminateProcess() in the second ntdll but it doesn't work. Does anyone have some idea of how to help me?

Please let me know if more clarification is required.

Thank you, Douglas.

0

There are 0 answers