microsoft / Detours

Detours is a software package for monitoring and instrumenting API calls on Windows. It is distributed in source code form.
MIT License
5.01k stars 979 forks source link

Improve failure mode if `DetourCreateProcessWithDllEx` is supplied with a DLL of wrong bitness #224

Open criemen opened 2 years ago

criemen commented 2 years ago

Describe the bug When using DetourCreateProcessWithDllEx from a 32-bit process to create a new process, while pointing lpDllName at a 64-bit DLL, strange failures occur.

I assumed that, because DetourCreateProcessWithDllEx auto-chooses the correct bitness for injection, I'd be safe to always pass the 64-bit DLL name into it. However, that's not true (and a close read of the documentation confirms this). Still, it would be great to either warn in the documentation about this, and/or improve the handling of this in DetourCreateProcessWithDllEx - either also auto-choose the correct bitness if parent-bitness==child-bitness, or return an error.

Detours version https://github.com/microsoft/Detours/commit/66d6f2d34aba564d373083621cacf66ec51199b2