mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-30 10:18:30 +00:00
ntdll: Use position independent syscall thunk for NtQueryInformationProcess on i386.
Fixes a regression introduced by commit
efd03f40e6
.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55967
This commit is contained in:
parent
7a8c039a5c
commit
cbcfaab519
|
@ -73,6 +73,30 @@ extern DWORD EXC_CallHandler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_R
|
|||
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
|
||||
*/
|
||||
|
|
|
@ -2119,13 +2119,13 @@ static void test_syscalls(void)
|
|||
ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 );
|
||||
ok( ptr != NULL, "MapViewOfFile failed err %lu\n", GetLastError() );
|
||||
CloseHandle( mapping );
|
||||
CloseHandle( file );
|
||||
delta = (char *)ptr - (char *)module;
|
||||
|
||||
if (memcmp( ptr, module, 0x1000 ))
|
||||
{
|
||||
skip( "modules are not identical (non-PE build?)\n" );
|
||||
UnmapViewOfFile( ptr );
|
||||
CloseHandle( file );
|
||||
return;
|
||||
}
|
||||
perform_relocations( ptr, delta );
|
||||
|
@ -2152,12 +2152,40 @@ static void test_syscalls(void)
|
|||
}
|
||||
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" );
|
||||
#else
|
||||
skip( "syscall thunk relocated\n" );
|
||||
#endif
|
||||
}
|
||||
CloseHandle( file );
|
||||
UnmapViewOfFile( ptr );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue