Some symbols (e.g., RtlPcToFileHeader) are exported by both kernel32 and ntdll. In this case, prefer ntdll's export over kernel32's one.
-- v2: ntdll/tests: Import RtlPcToFileHeader statically. ntdll/tests: Import from ntdll before other DLLs.
From: Jinoh Kang jinoh.kang.kr@gmail.com
Some symbols (e.g., RtlPcToFileHeader) are exported by both kernel32 and ntdll. In this case, prefer ntdll's export over kernel32's one. --- dlls/ntdll/tests/Makefile.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/tests/Makefile.in b/dlls/ntdll/tests/Makefile.in index 3742968c415..944e2cdb894 100644 --- a/dlls/ntdll/tests/Makefile.in +++ b/dlls/ntdll/tests/Makefile.in @@ -1,5 +1,8 @@ TESTDLL = ntdll.dll -IMPORTS = user32 advapi32 +# Resolve from ntdll before others. Since ntdll is also a default importlib, +# ntdll appears twice in linker arguments; this is intentional and needed for +# winecrt0. +IMPORTS = ntdll user32 advapi32
SOURCES = \ atom.c \
From: Jinoh Kang jinoh.kang.kr@gmail.com
--- dlls/ntdll/tests/exception.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 67b02cbd8b6..9278aaa6b08 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -65,7 +65,6 @@ static void * (WINAPI *pRtlLocateExtendedFeature)(CONTEXT_EX *context_ex, ULO static void * (WINAPI *pRtlLocateLegacyContext)(CONTEXT_EX *context_ex, ULONG *length); static void (WINAPI *pRtlSetExtendedFeaturesMask)(CONTEXT_EX *context_ex, ULONG64 feature_mask); static ULONG64 (WINAPI *pRtlGetExtendedFeaturesMask)(CONTEXT_EX *context_ex); -static void * (WINAPI *pRtlPcToFileHeader)(PVOID pc, PVOID *address); static void (WINAPI *pRtlGetCallersAddress)(void**,void**); static NTSTATUS (WINAPI *pNtRaiseException)(EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance); static NTSTATUS (WINAPI *pNtReadVirtualMemory)(HANDLE, const void*, void*, SIZE_T, SIZE_T*); @@ -2138,11 +2137,11 @@ static void CDECL hook_KiUserCallbackDispatcher( void *eip, ULONG id, ULONG *arg ok( (char *)esp - ((char *)args + len) < 0x10, "wrong esp offset %p / %p\n", esp, args ); }
- if (eip && pRtlPcToFileHeader) + if (eip) { void *mod, *win32u = GetModuleHandleA("win32u.dll");
- pRtlPcToFileHeader( eip, &mod ); + RtlPcToFileHeader( eip, &mod ); if (win32u) ok( mod == win32u, "ret address %p not in win32u %p\n", eip, win32u ); else trace( "ret address %p in %p\n", eip, mod ); } @@ -4930,11 +4929,11 @@ static void WINAPI hook_KiUserCallbackDispatcher(void *rsp) ok( (BYTE *)stack->frame.rsp - &stack->args_data[stack->len] <= 16, "wrong rsp %p / %p\n", (void *)stack->frame.rsp, &stack->args_data[stack->len] );
- if (stack->frame.rip && pRtlPcToFileHeader) + if (stack->frame.rip) { void *mod, *win32u = GetModuleHandleA("win32u.dll");
- pRtlPcToFileHeader( (void *)stack->frame.rip, &mod ); + RtlPcToFileHeader( (void *)stack->frame.rip, &mod ); if (win32u) ok( mod == win32u, "ret address %Ix not in win32u %p\n", stack->frame.rip, win32u ); else trace( "ret address %Ix in %p\n", stack->frame.rip, mod ); } @@ -5921,11 +5920,10 @@ static void WINAPI hook_KiUserCallbackDispatcher(void *sp) ok( redzone >= 8 && redzone <= 16, "wrong sp %p / %p (%Iu)\n", (void *)stack->sp, stack->args_data, redzone );
- if (pRtlPcToFileHeader) { void *mod, *win32u = GetModuleHandleA("win32u.dll");
- pRtlPcToFileHeader( (void *)stack->pc, &mod ); + RtlPcToFileHeader( (void *)stack->pc, &mod ); ok( mod == win32u, "pc %lx not in win32u %p\n", stack->pc, win32u ); } NtCallbackReturn( NULL, 0, func( stack->args, stack->len )); @@ -7208,11 +7206,10 @@ static void WINAPI hook_KiUserCallbackDispatcher(void *sp) ok( redzone >= 16 && redzone <= 32, "wrong sp %p / %p (%Iu)\n", (void *)stack->sp, stack->args_data, redzone );
- if (pRtlPcToFileHeader) { void *mod, *win32u = GetModuleHandleA("win32u.dll");
- pRtlPcToFileHeader( (void *)stack->pc, &mod ); + RtlPcToFileHeader( (void *)stack->pc, &mod ); ok( mod == win32u, "pc %Ix not in win32u %p\n", stack->pc, win32u ); } NtCallbackReturn( NULL, 0, func( stack->args, stack->len )); @@ -10831,11 +10828,11 @@ static void test_backtrace(void) ok( count > 0, "got %u entries\n", count ); for (i = hash_expect = 0; i < count; i++) hash_expect += (ULONG_PTR)buffer[i]; ok( hash == hash_expect, "hash mismatch %lx / %lx\n", hash, hash_expect ); - pRtlPcToFileHeader( buffer[0], &module ); + RtlPcToFileHeader( buffer[0], &module ); if (is_arm64ec && module == hntdll) /* Windows arm64ec has an extra frame for the entry thunk */ { ok( count > 1, "wrong count %u\n", count ); - pRtlPcToFileHeader( buffer[1], &module ); + RtlPcToFileHeader( buffer[1], &module ); } GetModuleFileNameW( module, name, ARRAY_SIZE(name) ); ok( module == GetModuleHandleA(0), "wrong module %p %s / %p for %p\n", @@ -10855,7 +10852,7 @@ static void test_backtrace(void)
if (count && !buffer[count - 1]) count--; /* win11 32-bit */ if (count <= 1) return; - pRtlPcToFileHeader( buffer[count - 1], &module ); + RtlPcToFileHeader( buffer[count - 1], &module ); GetModuleFileNameW( module, name, ARRAY_SIZE(name) ); ok( module == hntdll, "wrong module %p %s for frame %u %p\n", module, debugstr_w(name), count - 1, buffer[count - 1] ); @@ -10912,7 +10909,6 @@ START_TEST(exception) X(RtlLocateLegacyContext); X(RtlSetExtendedFeaturesMask); X(RtlGetExtendedFeaturesMask); - X(RtlPcToFileHeader); X(RtlGetCallersAddress); X(RtlCopyContext); X(RtlCopyExtendedContext);
A possibly more elgant approach to solve this is with --start-group/-( and --end-group/-), but it seems like an overkill to change makedep just for this. Also it's not clear if those flags are portable (e.g., works with LINK.EXE).
This merge request was closed by Jinoh Kang.