Alexandre Julliard : ntdll: Implement RtlWow64GetProcessMachines().
Alexandre Julliard
julliard at winehq.org
Thu Apr 29 16:38:30 CDT 2021
Module: wine
Branch: master
Commit: f2c1470c7c4799c620cdbc5195a8823fdd51ae16
URL: https://source.winehq.org/git/wine.git/?a=commit;h=f2c1470c7c4799c620cdbc5195a8823fdd51ae16
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Apr 29 16:18:30 2021 +0200
ntdll: Implement RtlWow64GetProcessMachines().
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/ntdll.spec | 1 +
dlls/ntdll/process.c | 25 +++++++++++++++++++++++++
dlls/ntdll/tests/info.c | 14 ++++++++++++++
include/winternl.h | 1 +
4 files changed, 41 insertions(+)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index cade83da4b1..198a7287302 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -1068,6 +1068,7 @@
@ stdcall RtlWalkHeap(long ptr)
@ stdcall RtlWow64EnableFsRedirection(long)
@ stdcall RtlWow64EnableFsRedirectionEx(long ptr)
+@ stdcall RtlWow64GetProcessMachines(long ptr ptr)
@ stdcall -arch=x86_64 RtlWow64GetThreadContext(long ptr)
@ stdcall -arch=x86_64 RtlWow64SetThreadContext(long ptr)
@ stub RtlWriteMemoryStream
diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c
index a86eb80e0cc..8621d4f4123 100644
--- a/dlls/ntdll/process.c
+++ b/dlls/ntdll/process.c
@@ -49,6 +49,31 @@ PEB * WINAPI RtlGetCurrentPeb(void)
}
+/**********************************************************************
+ * RtlWow64GetProcessMachines (NTDLL.@)
+ */
+NTSTATUS WINAPI RtlWow64GetProcessMachines( HANDLE process, USHORT *current_ret, USHORT *native_ret )
+{
+ ULONG i, machines[8];
+ USHORT current = 0, native = 0;
+ NTSTATUS status;
+
+ status = NtQuerySystemInformationEx( SystemSupportedProcessorArchitectures, &process, sizeof(process),
+ machines, sizeof(machines), NULL );
+ if (status) return status;
+ for (i = 0; machines[i]; i++)
+ {
+ USHORT flags = HIWORD(machines[i]);
+ USHORT machine = LOWORD(machines[i]);
+ if (flags & 4 /* native machine */) native = machine;
+ else if (flags & 8 /* current machine */) current = machine;
+ }
+ if (current_ret) *current_ret = current;
+ if (native_ret) *native_ret = native;
+ return status;
+}
+
+
/**********************************************************************
* RtlCreateUserProcess (NTDLL.@)
*/
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index f12b2862a99..1b20937de50 100644
--- a/dlls/ntdll/tests/info.c
+++ b/dlls/ntdll/tests/info.c
@@ -25,6 +25,7 @@
static NTSTATUS (WINAPI * pNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG);
static NTSTATUS (WINAPI * pNtSetSystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG);
static NTSTATUS (WINAPI * pRtlGetNativeSystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG);
+static NTSTATUS (WINAPI * pRtlWow64GetProcessMachines)(HANDLE,WORD*,WORD*);
static NTSTATUS (WINAPI * pNtQuerySystemInformationEx)(SYSTEM_INFORMATION_CLASS, void*, ULONG, void*, ULONG, ULONG*);
static NTSTATUS (WINAPI * pNtPowerInformation)(POWER_INFORMATION_LEVEL, PVOID, ULONG, PVOID, ULONG);
static NTSTATUS (WINAPI * pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
@@ -82,6 +83,7 @@ static BOOL InitFunctionPtrs(void)
NTDLL_GET_PROC(NtQuerySystemInformation);
NTDLL_GET_PROC(NtSetSystemInformation);
NTDLL_GET_PROC(RtlGetNativeSystemInformation);
+ NTDLL_GET_PROC(RtlWow64GetProcessMachines);
NTDLL_GET_PROC(NtPowerInformation);
NTDLL_GET_PROC(NtQueryInformationProcess);
NTDLL_GET_PROC(NtQueryInformationThread);
@@ -2920,6 +2922,18 @@ static void test_process_architecture( HANDLE process, USHORT expect_machine, US
&buffer, len, &len );
ok( status == STATUS_BUFFER_TOO_SMALL, "failed %x\n", status );
ok( len == (i + 1) * sizeof(DWORD), "wrong len %u\n", len );
+
+ if (pRtlWow64GetProcessMachines)
+ {
+ USHORT current = 0xdead, native = 0xbeef;
+ status = pRtlWow64GetProcessMachines( process, ¤t, &native );
+ ok( !status, "failed %x\n", status );
+ if (expect_machine == expect_native)
+ ok( current == 0, "wrong current machine %x / %x\n", current, expect_machine );
+ else
+ ok( current == expect_machine, "wrong current machine %x / %x\n", current, expect_machine );
+ ok( native == expect_native, "wrong native machine %x / %x\n", native, expect_native );
+ }
}
static void test_query_architectures(void)
diff --git a/include/winternl.h b/include/winternl.h
index dd2bdbbebbe..fece32a6f5c 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -4252,6 +4252,7 @@ NTSYSAPI void WINAPI RtlWakeConditionVariable(RTL_CONDITION_VARIABLE *);
NTSYSAPI NTSTATUS WINAPI RtlWalkHeap(HANDLE,PVOID);
NTSYSAPI NTSTATUS WINAPI RtlWow64EnableFsRedirection(BOOLEAN);
NTSYSAPI NTSTATUS WINAPI RtlWow64EnableFsRedirectionEx(ULONG,ULONG*);
+NTSYSAPI NTSTATUS WINAPI RtlWow64GetProcessMachines(HANDLE,USHORT*,USHORT*);
#ifdef __x86_64__
NTSYSAPI NTSTATUS WINAPI RtlWow64GetThreadContext(HANDLE, WOW64_CONTEXT *);
NTSYSAPI NTSTATUS WINAPI RtlWow64SetThreadContext(HANDLE, const WOW64_CONTEXT *);
More information about the wine-cvs
mailing list