diff --git a/src/creatwth.cpp b/src/creatwth.cpp index f1fdeb4f..071fc8fc 100644 --- a/src/creatwth.cpp +++ b/src/creatwth.cpp @@ -718,10 +718,17 @@ BOOL WINAPI DetourUpdateProcessWithDllEx(_In_ HANDLE hProcess, return FALSE; } #elif defined(DETOURS_64BIT) - if (bIs32BitProcess || bIs32BitExe) { - if (!UpdateImports32(hProcess, hModule, rlpDlls, nDlls)) { + if (bIs32BitProcess) { + if(bIs32BitExe) { + if (!UpdateImports32(hProcess, hModule, rlpDlls, nDlls)) { + return FALSE; + } + } + else { + // Can't detour a 32-bit process with 64-bit code. + SetLastError(ERROR_INVALID_HANDLE); return FALSE; - } + } } else { // 64-bit native or 64-bit managed process on any platform.