Created
October 19, 2021 07:29
-
-
Save wjx0912/8e349c093e5960e7e615b40a86035e14 to your computer and use it in GitHub Desktop.
isDifferentArch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* XXX: Mixed architecture don't quite work. See also | |
* http://www.corsix.org/content/dll-injection-and-wow64 | |
*/ | |
static BOOL | |
isDifferentArch(HANDLE hProcess) | |
{ | |
typedef BOOL (WINAPI *PFNISWOW64PROCESS)(HANDLE, PBOOL); | |
PFNISWOW64PROCESS pfnIsWow64Process; | |
pfnIsWow64Process = (PFNISWOW64PROCESS) | |
GetProcAddress(GetModuleHandleA("kernel32"), "IsWow64Process"); | |
if (!pfnIsWow64Process) { | |
return FALSE; | |
} | |
// NOTE: IsWow64Process will return false on 32-bits Windows | |
BOOL isThisWow64; | |
BOOL isOtherWow64; | |
if (!pfnIsWow64Process(GetCurrentProcess(), &isThisWow64) || | |
!pfnIsWow64Process(hProcess, &isOtherWow64)) { | |
logLastError("IsWow64Process failed"); | |
return FALSE; | |
} | |
return bool(isThisWow64) != bool(isOtherWow64); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment