Commit 91763843 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

ntdll/tests: Add some tests for unloaded modules traces.

parent 13243a28
...@@ -56,6 +56,21 @@ static NTSTATUS (WINAPI *pNtClose)(HANDLE); ...@@ -56,6 +56,21 @@ static NTSTATUS (WINAPI *pNtClose)(HANDLE);
static NTSTATUS (WINAPI *pNtSuspendProcess)(HANDLE process); static NTSTATUS (WINAPI *pNtSuspendProcess)(HANDLE process);
static NTSTATUS (WINAPI *pNtResumeProcess)(HANDLE process); static NTSTATUS (WINAPI *pNtResumeProcess)(HANDLE process);
#define RTL_UNLOAD_EVENT_TRACE_NUMBER 64
typedef struct _RTL_UNLOAD_EVENT_TRACE
{
void *BaseAddress;
SIZE_T SizeOfImage;
ULONG Sequence;
ULONG TimeDateStamp;
ULONG CheckSum;
WCHAR ImageName[32];
} RTL_UNLOAD_EVENT_TRACE, *PRTL_UNLOAD_EVENT_TRACE;
static RTL_UNLOAD_EVENT_TRACE *(WINAPI *pRtlGetUnloadEventTrace)(void);
static void (WINAPI *pRtlGetUnloadEventTraceEx)(ULONG **element_size, ULONG **element_count, void **event_trace);
#if defined(__x86_64__) #if defined(__x86_64__)
typedef struct typedef struct
{ {
...@@ -3325,6 +3340,53 @@ static void test_suspend_process(void) ...@@ -3325,6 +3340,53 @@ static void test_suspend_process(void)
CloseHandle(event2); CloseHandle(event2);
} }
static void test_unload_trace(void)
{
static const WCHAR imageW[] = {'m','s','x','m','l','3','.','d','l','l',0};
RTL_UNLOAD_EVENT_TRACE *unload_trace, *ptr;
ULONG *element_size, *element_count, size;
BOOL found = FALSE;
HMODULE hmod;
unload_trace = pRtlGetUnloadEventTrace();
todo_wine
ok(unload_trace != NULL, "Failed to get unload events pointer.\n");
if (pRtlGetUnloadEventTraceEx)
{
ptr = NULL;
pRtlGetUnloadEventTraceEx(&element_size, &element_count, (void **)&ptr);
todo_wine {
ok(*element_size >= sizeof(*ptr), "Unexpected element size.\n");
ok(*element_count == RTL_UNLOAD_EVENT_TRACE_NUMBER, "Unexpected trace element count %u.\n", *element_count);
ok(ptr != NULL, "Unexpected pointer %p.\n", ptr);
}
size = *element_size;
}
else
size = sizeof(*unload_trace);
hmod = LoadLibraryA("msxml3.dll");
ok(hmod != NULL, "Failed to load library.\n");
FreeLibrary(hmod);
if (unload_trace)
{
ptr = unload_trace;
while (ptr->BaseAddress != NULL)
{
if (!lstrcmpW(imageW, ptr->ImageName))
{
found = TRUE;
break;
}
ptr = (RTL_UNLOAD_EVENT_TRACE *)((char *)ptr + size);
}
}
todo_wine
ok(found, "Unloaded module wasn't found.\n");
}
START_TEST(exception) START_TEST(exception)
{ {
HMODULE hntdll = GetModuleHandleA("ntdll.dll"); HMODULE hntdll = GetModuleHandleA("ntdll.dll");
...@@ -3346,29 +3408,28 @@ START_TEST(exception) ...@@ -3346,29 +3408,28 @@ START_TEST(exception)
return; return;
} }
pNtGetContextThread = (void *)GetProcAddress( hntdll, "NtGetContextThread" ); #define X(f) p##f = (void*)GetProcAddress(hntdll, #f)
pNtSetContextThread = (void *)GetProcAddress( hntdll, "NtSetContextThread" ); X(NtGetContextThread);
pNtReadVirtualMemory = (void *)GetProcAddress( hntdll, "NtReadVirtualMemory" ); X(NtSetContextThread);
pNtClose = (void *)GetProcAddress( hntdll, "NtClose" ); X(NtReadVirtualMemory);
pRtlUnwind = (void *)GetProcAddress( hntdll, "RtlUnwind" ); X(NtClose);
pRtlRaiseException = (void *)GetProcAddress( hntdll, "RtlRaiseException" ); X(RtlUnwind);
pRtlCaptureContext = (void *)GetProcAddress( hntdll, "RtlCaptureContext" ); X(RtlRaiseException);
pNtTerminateProcess = (void *)GetProcAddress( hntdll, "NtTerminateProcess" ); X(RtlCaptureContext);
pRtlAddVectoredExceptionHandler = (void *)GetProcAddress( hntdll, X(NtTerminateProcess);
"RtlAddVectoredExceptionHandler" ); X(RtlAddVectoredExceptionHandler);
pRtlRemoveVectoredExceptionHandler = (void *)GetProcAddress( hntdll, X(RtlRemoveVectoredExceptionHandler);
"RtlRemoveVectoredExceptionHandler" ); X(RtlAddVectoredContinueHandler);
pRtlAddVectoredContinueHandler = (void *)GetProcAddress( hntdll, X(RtlRemoveVectoredContinueHandler);
"RtlAddVectoredContinueHandler" ); X(NtQueryInformationProcess);
pRtlRemoveVectoredContinueHandler = (void *)GetProcAddress( hntdll, X(NtSetInformationProcess);
"RtlRemoveVectoredContinueHandler" ); X(NtSuspendProcess);
pNtQueryInformationProcess = (void*)GetProcAddress( hntdll, X(NtResumeProcess);
"NtQueryInformationProcess" ); X(RtlGetUnloadEventTrace);
pNtSetInformationProcess = (void*)GetProcAddress( hntdll, X(RtlGetUnloadEventTraceEx);
"NtSetInformationProcess" ); #undef X
pIsWow64Process = (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsWow64Process"); pIsWow64Process = (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsWow64Process");
pNtSuspendProcess = (void *)GetProcAddress( hntdll, "NtSuspendProcess" );
pNtResumeProcess = (void *)GetProcAddress( hntdll, "NtResumeProcess" );
#ifdef __i386__ #ifdef __i386__
if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE; if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE;
...@@ -3455,31 +3516,26 @@ START_TEST(exception) ...@@ -3455,31 +3516,26 @@ START_TEST(exception)
test_thread_context(); test_thread_context();
test_suspend_thread(); test_suspend_thread();
test_suspend_process(); test_suspend_process();
test_unload_trace();
#elif defined(__x86_64__) #elif defined(__x86_64__)
pRtlAddFunctionTable = (void *)GetProcAddress( hntdll,
"RtlAddFunctionTable" ); #define X(f) p##f = (void*)GetProcAddress(hntdll, #f)
pRtlDeleteFunctionTable = (void *)GetProcAddress( hntdll, X(RtlAddFunctionTable);
"RtlDeleteFunctionTable" ); X(RtlDeleteFunctionTable);
pRtlInstallFunctionTableCallback = (void *)GetProcAddress( hntdll, X(RtlInstallFunctionTableCallback);
"RtlInstallFunctionTableCallback" ); X(RtlLookupFunctionEntry);
pRtlLookupFunctionEntry = (void *)GetProcAddress( hntdll, X(RtlAddGrowableFunctionTable);
"RtlLookupFunctionEntry" ); X(RtlGrowFunctionTable);
pRtlAddGrowableFunctionTable = (void *)GetProcAddress( hntdll, "RtlAddGrowableFunctionTable" ); X(RtlDeleteGrowableFunctionTable);
pRtlGrowFunctionTable = (void *)GetProcAddress( hntdll, "RtlGrowFunctionTable" ); X(__C_specific_handler);
pRtlDeleteGrowableFunctionTable = (void *)GetProcAddress( hntdll, "RtlDeleteGrowableFunctionTable" ); X(RtlCaptureContext);
p__C_specific_handler = (void *)GetProcAddress( hntdll, X(RtlRestoreContext);
"__C_specific_handler" ); X(RtlUnwindEx);
pRtlCaptureContext = (void *)GetProcAddress( hntdll, X(RtlWow64GetThreadContext);
"RtlCaptureContext" ); X(RtlWow64SetThreadContext);
pRtlRestoreContext = (void *)GetProcAddress( hntdll, #undef X
"RtlRestoreContext" );
pRtlUnwindEx = (void *)GetProcAddress( hntdll,
"RtlUnwindEx" );
pRtlWow64GetThreadContext = (void *)GetProcAddress( hntdll,
"RtlWow64GetThreadContext" );
pRtlWow64SetThreadContext = (void *)GetProcAddress( hntdll,
"RtlWow64SetThreadContext" );
p_setjmp = (void *)GetProcAddress( hmsvcrt, p_setjmp = (void *)GetProcAddress( hmsvcrt,
"_setjmp" ); "_setjmp" );
...@@ -3498,6 +3554,7 @@ START_TEST(exception) ...@@ -3498,6 +3554,7 @@ START_TEST(exception)
test_wow64_context(); test_wow64_context();
test_suspend_thread(); test_suspend_thread();
test_suspend_process(); test_suspend_process();
test_unload_trace();
if (pRtlAddFunctionTable && pRtlDeleteFunctionTable && pRtlInstallFunctionTableCallback && pRtlLookupFunctionEntry) if (pRtlAddFunctionTable && pRtlDeleteFunctionTable && pRtlInstallFunctionTableCallback && pRtlLookupFunctionEntry)
test_dynamic_unwind(); test_dynamic_unwind();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment