Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use IsWow64Process API #206

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions src/shared/WindowsVersion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "WindowsVersion.h"

#include <windows.h>
#include <wow64apiset.h>
#include <stdint.h>

#include <memory>
Expand Down Expand Up @@ -184,8 +185,6 @@ bool isAtLeastWindows8() {
#define WINPTY_ARCH WINPTY_X64
#endif

typedef BOOL WINAPI IsWow64Process_t(HANDLE hProcess, PBOOL Wow64Process);

void dumpWindowsVersion() {
if (!isTracingEnabled()) {
return;
Expand All @@ -206,20 +205,14 @@ void dumpWindowsVersion() {
b << ' ';
#if WINPTY_ARCH == WINPTY_IA32
b << "IA32";
OsModule kernel32(L"kernel32.dll");
IsWow64Process_t *pIsWow64Process =
reinterpret_cast<IsWow64Process_t*>(
kernel32.proc("IsWow64Process"));
if (pIsWow64Process != nullptr) {
BOOL result = false;
const BOOL success = pIsWow64Process(GetCurrentProcess(), &result);
if (!success) {
b << " WOW64:error";
} else if (success && result) {
BOOL result = false;
auto success = IsWow64Process(GetCurrentProcess(), &result);
if (success) {
if (result) {
b << " WOW64";
}
} else {
b << " WOW64:missingapi";
} else {
b << " WOW64:error";
}
#elif WINPTY_ARCH == WINPTY_X64
b << "X64";
Expand Down