ReactOS 0.4.17-dev-540-g8f54750
wow64.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS runtime library (RTL)
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: Implementation of RtlWow64GetProcessMachines
5 * COPYRIGHT: Copyright 2026 Timo Kreuzer <timo.kreuzer@reactos.org>
6 */
7
8/* INCLUDES *****************************************************************/
9
10#include <rtl.h>
11
12#define NDEBUG
13#include <debug.h>
14
19 _Out_ PUSHORT ProcessMachine,
20 _Out_opt_ PUSHORT NativeMachine)
21{
23 ULONG_PTR Wow64Info;
24
25 /* Check if the caller wants the current process */
27 {
28 /* Easy: process machine is current architecture */
29 *ProcessMachine = IMAGE_FILE_MACHINE_NATIVE;
30 }
31 else if (SharedUserData->ImageNumberLow == IMAGE_FILE_MACHINE_AMD64)
32 {
33 /* Kernel architecture is AMD64, query whether the process is WOW64 */
36 &Wow64Info,
37 sizeof(Wow64Info),
38 NULL);
39 if (!NT_SUCCESS(Status))
40 {
41 return Status;
42 }
43
44 *ProcessMachine = Wow64Info ? IMAGE_FILE_MACHINE_I386 : IMAGE_FILE_MACHINE_AMD64;
45 }
46 else
47 {
48 /* kernel is something else, assume no WOW64 */
49 *ProcessMachine = IMAGE_FILE_MACHINE_NATIVE;
50 }
51
52 if (NativeMachine != NULL)
53 {
54 /* The kernel stores it's native architecture in this field */
55 *NativeMachine = SharedUserData->ImageNumberLow;
56 }
57
58 return STATUS_SUCCESS;
59}
LONG NTSTATUS
Definition: precomp.h:26
@ ProcessWow64Information
Definition: cicbase.cpp:65
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:24
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:407
#define _Out_opt_
Definition: no_sal2.h:214
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define NtCurrentProcess()
Definition: nt_native.h:1660
#define IMAGE_FILE_MACHINE_AMD64
Definition: ntimage.h:17
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_writes_bytes_to_opt_(ProcessInformationLength, *ReturnLength) PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:211
#define IMAGE_FILE_MACHINE_I386
Definition: pedump.c:174
#define SharedUserData
#define STATUS_SUCCESS
Definition: shellext.h:65
#define NTAPI
Definition: typedefs.h:36
uint16_t * PUSHORT
Definition: typedefs.h:56
uint32_t ULONG_PTR
Definition: typedefs.h:65
NTSYSAPI NTSTATUS WINAPI RtlWow64GetProcessMachines(HANDLE, USHORT *, USHORT *)