ntdll: Catch page faults in NtQueryPerformanceCounter.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
00475e1dfd
commit
b60b50ba35
|
@ -26,6 +26,7 @@
|
|||
|
||||
static VOID (WINAPI *pRtlTimeToTimeFields)( const LARGE_INTEGER *liTime, PTIME_FIELDS TimeFields) ;
|
||||
static VOID (WINAPI *pRtlTimeFieldsToTime)( PTIME_FIELDS TimeFields, PLARGE_INTEGER Time) ;
|
||||
static NTSTATUS (WINAPI *pNtQueryPerformanceCounter)( LARGE_INTEGER *counter, LARGE_INTEGER *frequency );
|
||||
|
||||
static const int MonthLengths[2][12] =
|
||||
{
|
||||
|
@ -94,13 +95,35 @@ static void test_pRtlTimeToTimeFields(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void test_NtQueryPerformanceCounter(void)
|
||||
{
|
||||
LARGE_INTEGER counter, frequency;
|
||||
NTSTATUS status;
|
||||
|
||||
status = pNtQueryPerformanceCounter(NULL, NULL);
|
||||
ok(status == STATUS_ACCESS_VIOLATION, "expected STATUS_ACCESS_VIOLATION, got %08x\n", status);
|
||||
status = pNtQueryPerformanceCounter(NULL, &frequency);
|
||||
ok(status == STATUS_ACCESS_VIOLATION, "expected STATUS_ACCESS_VIOLATION, got %08x\n", status);
|
||||
status = pNtQueryPerformanceCounter(&counter, (void *)0xdeadbee0);
|
||||
ok(status == STATUS_ACCESS_VIOLATION, "expected STATUS_ACCESS_VIOLATION, got %08x\n", status);
|
||||
status = pNtQueryPerformanceCounter((void *)0xdeadbee0, &frequency);
|
||||
ok(status == STATUS_ACCESS_VIOLATION, "expected STATUS_ACCESS_VIOLATION, got %08x\n", status);
|
||||
|
||||
status = pNtQueryPerformanceCounter(&counter, NULL);
|
||||
ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
|
||||
status = pNtQueryPerformanceCounter(&counter, &frequency);
|
||||
ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
|
||||
}
|
||||
|
||||
START_TEST(time)
|
||||
{
|
||||
HMODULE mod = GetModuleHandleA("ntdll.dll");
|
||||
pRtlTimeToTimeFields = (void *)GetProcAddress(mod,"RtlTimeToTimeFields");
|
||||
pRtlTimeFieldsToTime = (void *)GetProcAddress(mod,"RtlTimeFieldsToTime");
|
||||
pNtQueryPerformanceCounter = (void *)GetProcAddress(mod, "NtQueryPerformanceCounter");
|
||||
if (pRtlTimeToTimeFields && pRtlTimeFieldsToTime)
|
||||
test_pRtlTimeToTimeFields();
|
||||
else
|
||||
win_skip("Required time conversion functions are not available\n");
|
||||
test_NtQueryPerformanceCounter();
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#define WIN32_NO_STATUS
|
||||
#include "windef.h"
|
||||
#include "winternl.h"
|
||||
#include "wine/exception.h"
|
||||
#include "wine/unicode.h"
|
||||
#include "wine/debug.h"
|
||||
#include "ntdll_misc.h"
|
||||
|
@ -472,10 +473,17 @@ NTSTATUS WINAPI NtQuerySystemTime( PLARGE_INTEGER Time )
|
|||
*/
|
||||
NTSTATUS WINAPI NtQueryPerformanceCounter( LARGE_INTEGER *counter, LARGE_INTEGER *frequency )
|
||||
{
|
||||
if (!counter) return STATUS_ACCESS_VIOLATION;
|
||||
__TRY
|
||||
{
|
||||
counter->QuadPart = monotonic_counter();
|
||||
if (frequency) frequency->QuadPart = TICKSPERSEC;
|
||||
}
|
||||
__EXCEPT_PAGE_FAULT
|
||||
{
|
||||
return STATUS_ACCESS_VIOLATION;
|
||||
}
|
||||
__ENDTRY
|
||||
|
||||
counter->QuadPart = monotonic_counter();
|
||||
if (frequency) frequency->QuadPart = TICKSPERSEC;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue