Commit 7406583e authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Store the unixlib handle at ntdll load time.

parent 157be051
......@@ -4120,8 +4120,6 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
NtQueryVirtualMemory( GetCurrentProcess(), LdrInitializeThunk, MemoryBasicInformation,
&meminfo, sizeof(meminfo), NULL );
NtQueryVirtualMemory( GetCurrentProcess(), meminfo.AllocationBase, MemoryWineUnixFuncs,
&__wine_unixlib_handle, sizeof(__wine_unixlib_handle), NULL );
peb->LdrData = &ldr;
peb->FastPebLock = &peb_lock;
......
......@@ -1698,6 +1698,7 @@
@ stdcall __wine_ctrl_routine(ptr)
@ extern -private __wine_syscall_dispatcher
@ extern -private __wine_unix_call_dispatcher
@ extern -private __wine_unixlib_handle
@ extern -arch=arm64 __wine_current_teb
# Debugging
......
......@@ -117,7 +117,6 @@ void (WINAPI *p__wine_ctrl_routine)(void*);
SYSTEM_DLL_INIT_BLOCK *pLdrSystemDllInitBlock = NULL;
static void *p__wine_syscall_dispatcher;
static void **p__wine_unix_call_dispatcher;
static void * const syscalls[] =
{
......@@ -398,7 +397,6 @@ const char **dll_paths = NULL;
const char **system_dll_paths = NULL;
const char *user_name = NULL;
SECTION_IMAGE_INFORMATION main_image_info = { NULL };
HMODULE ntdll_module = 0;
static const IMAGE_EXPORT_DIRECTORY *ntdll_exports;
/* adjust an array of pointers to make them into RVAs */
......@@ -1037,6 +1035,9 @@ static const void *get_module_data_dir( HMODULE module, ULONG dir, ULONG *size )
static void load_ntdll_functions( HMODULE module )
{
void **p__wine_unix_call_dispatcher;
unixlib_handle_t *p__wine_unixlib_handle;
ntdll_exports = get_module_data_dir( module, IMAGE_FILE_EXPORT_DIRECTORY, NULL );
assert( ntdll_exports );
......@@ -1055,6 +1056,9 @@ static void load_ntdll_functions( HMODULE module )
GET_FUNC( __wine_ctrl_routine );
GET_FUNC( __wine_syscall_dispatcher );
GET_FUNC( __wine_unix_call_dispatcher );
GET_FUNC( __wine_unixlib_handle );
*p__wine_unix_call_dispatcher = __wine_unix_call_dispatcher;
*p__wine_unixlib_handle = (UINT_PTR)__wine_unix_call_funcs;
#ifdef __aarch64__
{
void **p__wine_current_teb;
......@@ -1087,6 +1091,14 @@ static void load_ntdll_wow64_functions( HMODULE module )
p__wine_ctrl_routine = (void *)find_named_export( module, exports, "__wine_ctrl_routine" );
#ifdef _WIN64
{
unixlib_handle_t *p__wine_unixlib_handle = (void *)find_named_export( module, exports,
"__wine_unixlib_handle" );
*p__wine_unixlib_handle = (UINT_PTR)__wine_unix_call_wow64_funcs;
}
#endif
/* also set the 32-bit LdrSystemDllInitBlock */
memcpy( (void *)(ULONG_PTR)pLdrSystemDllInitBlock->pLdrSystemDllInitBlock,
pLdrSystemDllInitBlock, sizeof(*pLdrSystemDllInitBlock) );
......@@ -1905,7 +1917,6 @@ static void load_ntdll(void)
else if (status) fatal_error( "failed to load %s error %x\n", name, status );
free( name );
load_ntdll_functions( module );
ntdll_module = module;
}
......@@ -2099,7 +2110,6 @@ static void start_main_thread(void)
if (main_image_info.Machine != current_machine) load_wow64_ntdll( main_image_info.Machine );
load_apiset_dll();
ntdll_init_syscalls( 0, &syscall_table, p__wine_syscall_dispatcher );
*p__wine_unix_call_dispatcher = __wine_unix_call_dispatcher;
server_init_process_done();
}
......
......@@ -41,7 +41,6 @@ static const WORD current_machine = IMAGE_FILE_MACHINE_ARMNT;
static const WORD current_machine = IMAGE_FILE_MACHINE_ARM64;
#endif
extern WORD native_machine DECLSPEC_HIDDEN;
extern HMODULE ntdll_module DECLSPEC_HIDDEN;
extern const unixlib_entry_t __wine_unix_call_funcs[] DECLSPEC_HIDDEN;
extern const unixlib_entry_t __wine_unix_call_wow64_funcs[] DECLSPEC_HIDDEN;
......
......@@ -640,35 +640,15 @@ void *get_builtin_so_handle( void *module )
*/
static NTSTATUS get_builtin_unix_funcs( void *module, BOOL wow, const void **funcs )
{
const char *p, *ptr_name = wow ? "__wine_unix_call_wow64_funcs" : "__wine_unix_call_funcs";
const char *ptr_name = wow ? "__wine_unix_call_wow64_funcs" : "__wine_unix_call_funcs";
sigset_t sigset;
NTSTATUS status = STATUS_DLL_NOT_FOUND;
struct builtin_module *builtin;
if (module == ntdll_module)
{
#ifdef _WIN64
*funcs = wow ? __wine_unix_call_wow64_funcs : __wine_unix_call_funcs;
#else
*funcs = __wine_unix_call_funcs;
#endif
return STATUS_SUCCESS;
}
server_enter_uninterrupted_section( &virtual_mutex, &sigset );
LIST_FOR_EACH_ENTRY( builtin, &builtin_modules, struct builtin_module, entry )
{
if (builtin->module != module) continue;
if (builtin->unix_path && (p = strrchr( builtin->unix_path, '/' )) && !strcmp( p, "/ntdll.so" ))
{
#ifdef _WIN64
*funcs = wow ? __wine_unix_call_wow64_funcs : __wine_unix_call_funcs;
#else
*funcs = __wine_unix_call_funcs;
#endif
status = STATUS_SUCCESS;
break;
}
if (builtin->unix_path && !builtin->unix_handle)
builtin->unix_handle = dlopen( builtin->unix_path, RTLD_NOW );
if (builtin->unix_handle)
......
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