dll-syringe icon indicating copy to clipboard operation
dll-syringe copied to clipboard

Why is it not supported for 32-bit programs to call 64-bit target processes.

Open edsky opened this issue 3 years ago • 6 comments
trafficstars

Is there any difficulty here?

edsky avatar Jun 22 '22 05:06 edsky

It should be possible to do it, as there are also some other injectors that support it, but i have not looked into how they do it.

To extend the current implementation as is, there are some problems:

  • EnumProcessModulesEx does not support iterating x64 modules from an x32 (wow64) process. (Currently used to get addresses of win32 API functions in target process and to confirm that the injection succeeded)
  • CreateRemoteThread will truncate arguments and return value when doing x32->x64.
  • maybe others

OpenByteDev avatar Jun 22 '22 22:06 OpenByteDev

You can refer to the implementation of yapi, which supports injection of 32-bit processes into 64-bit processes under C++.

Confirm whether the injection is successful can be determined by remote LoadLibrary,

  • EnumProcessModulesEx the yapi method can call this function under 32 bits.
  • CreateRemoteThread the parameter problem can be done in assembly form. The assembly parameters under 64-bit are very fixed, and you only need to write the registers as they are.

edsky avatar Jun 23 '22 10:06 edsky

EnumProcessModulesEx can be called but will not return x64 modules (see the remarks section). I dont follow with what you are suggesting for CreateRemoteThread.

OpenByteDev avatar Jun 23 '22 10:06 OpenByteDev

This problem of EnumProcessModulesEx can be easily solved.

One way is to call NtQueryInformationProcess through wow64, and the other way is to directly call NtWow64QueryInformationProcess64.

For related codes, please refer to https://www.52pojie.cn/forum.php?mod=viewthread&tid=872501 and https://stackoverflow.com/questions/3801517/how-to-enum-modules-in-a-64bit -process-from-a-32bit-wow-process?answertab=trending#tab-top

edsky avatar Jun 24 '22 01:06 edsky

I just want to mention that while I may implement this, I will not work on it in the near future.

OpenByteDev avatar Jun 28 '22 01:06 OpenByteDev

I rewrote listing processes and modules using ntdll in https://github.com/OpenByteDev/processes/commit/31435c769fbf2856a45c2c4a1426bf67b4dd4139 but without using the WoW64 methods.

OpenByteDev avatar Apr 02 '23 00:04 OpenByteDev