bool ProcessLister::isWindows64() { #ifdef _WIN64 //compiled 64bit application return true; #else //32bit exe, check wow64 BOOL bIsWow64 = FALSE; //not available in all windows operating systems //Minimum supported client: Windows Vista, Windows XP with SP2 //Minimum supported server: Windows Server 2008, Windows Server 2003 with SP1 if (_IsWow64Process) { _IsWow64Process(GetCurrentProcess(), &bIsWow64); if (bIsWow64 != FALSE) { return true; } else { return false; } } else { return false; } #endif }
ProcessType ProcessLister::checkIsProcess64(HANDLE hProcess) { BOOL bIsWow64 = FALSE; if (!hProcess) { return PROCESS_MISSING_RIGHTS; } if (!isWindows64()) { //32bit win can only run 32bit process return PROCESS_32; } _IsWow64Process(hProcess, &bIsWow64); if (bIsWow64 == FALSE) { //process not running under wow return PROCESS_64; } else { //process running under wow -> 32bit return PROCESS_32; } }
bool IsRunningInWow64() { #ifndef _WIN64 typedef BOOL (WINAPI *IsWow64ProcessProc)(HANDLE, PBOOL); IsWow64ProcessProc _IsWow64Process = (IsWow64ProcessProc)LoadDllFunc(L"kernel32.dll", "IsWow64Process"); BOOL isWow = FALSE; if (_IsWow64Process) _IsWow64Process(GetCurrentProcess(), &isWow); return isWow; #else return false; #endif }