Commit 064c7bdb authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

ntdll: Fix trace pointer returned from RtlGetUnloadEventTraceEx().

parent 4820290a
...@@ -197,6 +197,7 @@ typedef struct _RTL_UNLOAD_EVENT_TRACE ...@@ -197,6 +197,7 @@ typedef struct _RTL_UNLOAD_EVENT_TRACE
} RTL_UNLOAD_EVENT_TRACE, *PRTL_UNLOAD_EVENT_TRACE; } RTL_UNLOAD_EVENT_TRACE, *PRTL_UNLOAD_EVENT_TRACE;
static RTL_UNLOAD_EVENT_TRACE unload_traces[RTL_UNLOAD_EVENT_TRACE_NUMBER]; static RTL_UNLOAD_EVENT_TRACE unload_traces[RTL_UNLOAD_EVENT_TRACE_NUMBER];
static RTL_UNLOAD_EVENT_TRACE *unload_trace_ptr;
static unsigned int unload_trace_seq; static unsigned int unload_trace_seq;
static void module_push_unload_trace( const LDR_MODULE *ldr ) static void module_push_unload_trace( const LDR_MODULE *ldr )
...@@ -213,6 +214,7 @@ static void module_push_unload_trace( const LDR_MODULE *ldr ) ...@@ -213,6 +214,7 @@ static void module_push_unload_trace( const LDR_MODULE *ldr )
ptr->ImageName[len / sizeof(*ptr->ImageName)] = 0; ptr->ImageName[len / sizeof(*ptr->ImageName)] = 0;
unload_trace_seq = (unload_trace_seq + 1) % ARRAY_SIZE(unload_traces); unload_trace_seq = (unload_trace_seq + 1) % ARRAY_SIZE(unload_traces);
unload_trace_ptr = unload_traces;
} }
/********************************************************************* /*********************************************************************
...@@ -233,7 +235,7 @@ void WINAPI RtlGetUnloadEventTraceEx(ULONG **size, ULONG **count, void **trace) ...@@ -233,7 +235,7 @@ void WINAPI RtlGetUnloadEventTraceEx(ULONG **size, ULONG **count, void **trace)
*size = &element_size; *size = &element_size;
*count = &element_count; *count = &element_count;
*trace = unload_traces; *trace = &unload_trace_ptr;
} }
/************************************************************************* /*************************************************************************
......
...@@ -3410,21 +3410,20 @@ static void test_suspend_process(void) ...@@ -3410,21 +3410,20 @@ static void test_suspend_process(void)
static void test_unload_trace(void) static void test_unload_trace(void)
{ {
static const WCHAR imageW[] = {'m','s','x','m','l','3','.','d','l','l',0}; static const WCHAR imageW[] = {'m','s','x','m','l','3','.','d','l','l',0};
RTL_UNLOAD_EVENT_TRACE *unload_trace, *ptr; RTL_UNLOAD_EVENT_TRACE *unload_trace, **unload_trace_ex = NULL, *ptr;
ULONG *element_size, *element_count, size; ULONG *element_size, *element_count, size;
BOOL found = FALSE;
HMODULE hmod; HMODULE hmod;
BOOL found;
unload_trace = pRtlGetUnloadEventTrace(); unload_trace = pRtlGetUnloadEventTrace();
ok(unload_trace != NULL, "Failed to get unload events pointer.\n"); ok(unload_trace != NULL, "Failed to get unload events pointer.\n");
if (pRtlGetUnloadEventTraceEx) if (pRtlGetUnloadEventTraceEx)
{ {
ptr = NULL; pRtlGetUnloadEventTraceEx(&element_size, &element_count, (void **)&unload_trace_ex);
pRtlGetUnloadEventTraceEx(&element_size, &element_count, (void **)&ptr);
ok(*element_size >= sizeof(*ptr), "Unexpected element size.\n"); 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(*element_count == RTL_UNLOAD_EVENT_TRACE_NUMBER, "Unexpected trace element count %u.\n", *element_count);
ok(ptr != NULL, "Unexpected pointer %p.\n", ptr); ok(unload_trace_ex != NULL, "Unexpected pointer %p.\n", unload_trace_ex);
size = *element_size; size = *element_size;
} }
else else
...@@ -3434,6 +3433,7 @@ static void test_unload_trace(void) ...@@ -3434,6 +3433,7 @@ static void test_unload_trace(void)
ok(hmod != NULL, "Failed to load library.\n"); ok(hmod != NULL, "Failed to load library.\n");
FreeLibrary(hmod); FreeLibrary(hmod);
found = FALSE;
ptr = unload_trace; ptr = unload_trace;
while (ptr->BaseAddress != NULL) while (ptr->BaseAddress != NULL)
{ {
...@@ -3445,6 +3445,22 @@ static void test_unload_trace(void) ...@@ -3445,6 +3445,22 @@ static void test_unload_trace(void)
ptr = (RTL_UNLOAD_EVENT_TRACE *)((char *)ptr + size); ptr = (RTL_UNLOAD_EVENT_TRACE *)((char *)ptr + size);
} }
ok(found, "Unloaded module wasn't found.\n"); ok(found, "Unloaded module wasn't found.\n");
if (unload_trace_ex)
{
found = FALSE;
ptr = *unload_trace_ex;
while (ptr->BaseAddress != NULL)
{
if (!lstrcmpW(imageW, ptr->ImageName))
{
found = TRUE;
break;
}
ptr = (RTL_UNLOAD_EVENT_TRACE *)((char *)ptr + size);
}
ok(found, "Unloaded module wasn't found.\n");
}
} }
START_TEST(exception) START_TEST(exception)
......
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