Commit cbcfaab5 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

ntdll: Use position independent syscall thunk for NtQueryInformationProcess on i386.

Fixes a regression introduced by commit efd03f40. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55967
parent 7a8c039a
...@@ -73,6 +73,30 @@ extern DWORD EXC_CallHandler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_R ...@@ -73,6 +73,30 @@ extern DWORD EXC_CallHandler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_R
PEXCEPTION_HANDLER handler, PEXCEPTION_HANDLER nested_handler ); PEXCEPTION_HANDLER handler, PEXCEPTION_HANDLER nested_handler );
#ifdef __WINE_PE_BUILD
enum syscall_ids
{
#define SYSCALL_ENTRY(id,name,args) __id_##name = id,
ALL_SYSCALLS32
#undef SYSCALL_ENTRY
};
/*******************************************************************
* NtQueryInformationProcess
*/
void NtQueryInformationProcess_wrapper(void)
{
asm( ".globl " __ASM_STDCALL("NtQueryInformationProcess", 20) "\n"
__ASM_STDCALL("NtQueryInformationProcess", 20) ":\n\t"
"movl %0,%%eax\n\t"
"call *%%fs:0xc0\n\t"
"ret $20" :: "i" (__id_NtQueryInformationProcess) );
}
#define NtQueryInformationProcess syscall_NtQueryInformationProcess
#endif /* __WINE_PE_BUILD */
/******************************************************************* /*******************************************************************
* syscalls * syscalls
*/ */
......
...@@ -2119,13 +2119,13 @@ static void test_syscalls(void) ...@@ -2119,13 +2119,13 @@ static void test_syscalls(void)
ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 ); ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 );
ok( ptr != NULL, "MapViewOfFile failed err %lu\n", GetLastError() ); ok( ptr != NULL, "MapViewOfFile failed err %lu\n", GetLastError() );
CloseHandle( mapping ); CloseHandle( mapping );
CloseHandle( file );
delta = (char *)ptr - (char *)module; delta = (char *)ptr - (char *)module;
if (memcmp( ptr, module, 0x1000 )) if (memcmp( ptr, module, 0x1000 ))
{ {
skip( "modules are not identical (non-PE build?)\n" ); skip( "modules are not identical (non-PE build?)\n" );
UnmapViewOfFile( ptr ); UnmapViewOfFile( ptr );
CloseHandle( file );
return; return;
} }
perform_relocations( ptr, delta ); perform_relocations( ptr, delta );
...@@ -2152,12 +2152,40 @@ static void test_syscalls(void) ...@@ -2152,12 +2152,40 @@ static void test_syscalls(void)
} }
else else
{ {
#ifdef __x86_64__ #ifdef __i386__
NTSTATUS (WINAPI *pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, void *, ULONG, ULONG *);
PROCESS_BASIC_INFORMATION pbi;
void *exec_mem, *va_ptr;
ULONG size;
BOOL ret;
exec_mem = VirtualAlloc( NULL, 4096, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE );
ok( !!exec_mem, "got NULL.\n" );
/* NtQueryInformationProcess is special. */
pNtQueryInformationProcess = (void *)GetProcAddress( module, "NtQueryInformationProcess" );
va_ptr = RtlImageRvaToVa( RtlImageNtHeader(module), module,
(char *)pNtQueryInformationProcess - (char *)module, NULL );
ok( !!va_ptr, "offset not found %p / %p\n", pNtQueryInformationProcess, module );
ret = SetFilePointer( file, (char *)va_ptr - (char *)module, NULL, FILE_BEGIN );
ok( ret, "got %d, err %lu.\n", ret, GetLastError() );
ret = ReadFile( file, exec_mem, 32, NULL, NULL );
ok( ret, "got %d, err %lu.\n", ret, GetLastError() );
pNtQueryInformationProcess = exec_mem;
/* The thunk still works without relocation. */
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), &size );
ok( !status, "got %#lx.\n", status );
ok( size == sizeof(pbi), "got %lu.\n", size );
ok( pbi.PebBaseAddress == NtCurrentTeb()->Peb, "got %p, %p.\n", pbi.PebBaseAddress, NtCurrentTeb()->Peb );
VirtualFree( exec_mem, 0, MEM_RELEASE );
#elif defined __x86_64__
ok( 0, "syscall thunk relocated\n" ); ok( 0, "syscall thunk relocated\n" );
#else #else
skip( "syscall thunk relocated\n" ); skip( "syscall thunk relocated\n" );
#endif #endif
} }
CloseHandle( file );
UnmapViewOfFile( ptr ); UnmapViewOfFile( ptr );
} }
......
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