From 78c772e9d802d13522855fa3c8e2257c4933214a Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 21 Jul 2020 15:51:38 +0200 Subject: [PATCH] ntdll: Use a syscall thunk for NtQueryPerformanceCounter(). Signed-off-by: Alexandre Julliard --- dlls/ntdll/ntdll.spec | 4 ++-- dlls/ntdll/time.c | 21 +-------------------- dlls/ntdll/unix/loader.c | 1 - dlls/ntdll/unix/sync.c | 13 +++++++++++-- dlls/ntdll/unixlib.h | 3 +-- 5 files changed, 15 insertions(+), 27 deletions(-) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index ff1433be40d..aea91740689 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -307,7 +307,7 @@ @ stdcall -syscall NtQueryMutant(long long ptr long ptr) @ stdcall -syscall NtQueryObject(long long ptr long ptr) @ stub NtQueryOpenSubKeys -@ stdcall NtQueryPerformanceCounter(ptr ptr) +@ stdcall -syscall NtQueryPerformanceCounter(ptr ptr) # @ stub NtQueryPortInformationProcess # @ stub NtQueryQuotaInformationFile @ stdcall -syscall NtQuerySection(long long ptr long ptr) @@ -1295,7 +1295,7 @@ @ stdcall -private -syscall ZwQueryMutant(long long ptr long ptr) NtQueryMutant @ stdcall -private -syscall ZwQueryObject(long long ptr long ptr) NtQueryObject @ stub ZwQueryOpenSubKeys -@ stdcall -private ZwQueryPerformanceCounter(ptr ptr) NtQueryPerformanceCounter +@ stdcall -private -syscall ZwQueryPerformanceCounter(ptr ptr) NtQueryPerformanceCounter # @ stub ZwQueryPortInformationProcess # @ stub ZwQueryQuotaInformationFile @ stdcall -private -syscall ZwQuerySection(long long ptr long ptr) NtQuerySection diff --git a/dlls/ntdll/time.c b/dlls/ntdll/time.c index 15d100d10e7..f92443500d8 100644 --- a/dlls/ntdll/time.c +++ b/dlls/ntdll/time.c @@ -375,31 +375,12 @@ LONGLONG WINAPI RtlGetSystemTimePrecise( void ) return unix_funcs->RtlGetSystemTimePrecise(); } -/****************************************************************************** - * NtQueryPerformanceCounter [NTDLL.@] - */ -NTSTATUS WINAPI NtQueryPerformanceCounter( LARGE_INTEGER *counter, LARGE_INTEGER *frequency ) -{ - NTSTATUS status; - - __TRY - { - status = unix_funcs->NtQueryPerformanceCounter( counter, frequency ); - } - __EXCEPT_PAGE_FAULT - { - return STATUS_ACCESS_VIOLATION; - } - __ENDTRY - return status; -} - /****************************************************************************** * RtlQueryPerformanceCounter [NTDLL.@] */ BOOL WINAPI DECLSPEC_HOTPATCH RtlQueryPerformanceCounter( LARGE_INTEGER *counter ) { - unix_funcs->NtQueryPerformanceCounter( counter, NULL ); + NtQueryPerformanceCounter( counter, NULL ); return TRUE; } diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 99c70b400a2..3f3a10155d2 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1362,7 +1362,6 @@ static struct unix_funcs unix_funcs = { NtCurrentTeb, NtGetContextThread, - NtQueryPerformanceCounter, DbgUiIssueRemoteBreakin, RtlGetSystemTimePrecise, RtlWaitOnAddress, diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c index b7b9fa3443a..2dc1a7c2aa0 100644 --- a/dlls/ntdll/unix/sync.c +++ b/dlls/ntdll/unix/sync.c @@ -69,6 +69,7 @@ #include "winternl.h" #include "ddk/wdm.h" #include "wine/server.h" +#include "wine/exception.h" #include "wine/debug.h" #include "unix_private.h" @@ -1361,8 +1362,16 @@ NTSTATUS WINAPI NtDelayExecution( BOOLEAN alertable, const LARGE_INTEGER *timeou */ NTSTATUS WINAPI NtQueryPerformanceCounter( LARGE_INTEGER *counter, LARGE_INTEGER *frequency ) { - counter->QuadPart = monotonic_counter(); - if (frequency) frequency->QuadPart = TICKSPERSEC; + __TRY + { + counter->QuadPart = monotonic_counter(); + if (frequency) frequency->QuadPart = TICKSPERSEC; + } + __EXCEPT_PAGE_FAULT + { + return STATUS_ACCESS_VIOLATION; + } + __ENDTRY return STATUS_SUCCESS; } diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h index d7487feafcd..84e1a27977a 100644 --- a/dlls/ntdll/unixlib.h +++ b/dlls/ntdll/unixlib.h @@ -28,14 +28,13 @@ struct msghdr; struct _DISPATCHER_CONTEXT; /* increment this when you change the function table */ -#define NTDLL_UNIXLIB_VERSION 89 +#define NTDLL_UNIXLIB_VERSION 90 struct unix_funcs { /* Nt* functions */ TEB * (WINAPI *NtCurrentTeb)(void); NTSTATUS (WINAPI *NtGetContextThread)( HANDLE handle, CONTEXT *context ); - NTSTATUS (WINAPI *NtQueryPerformanceCounter)( LARGE_INTEGER *counter, LARGE_INTEGER *frequency ); /* other Win32 API functions */ NTSTATUS (WINAPI *DbgUiIssueRemoteBreakin)( HANDLE process );