forked from Mirrors/wine-wine
ntdll: Move the image address initialization to the Unix library.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>feature/deterministic
parent
2e6a2cf9c6
commit
a0b7fb9bb2
|
@ -25,15 +25,6 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_TIMES_H
|
|
||||||
#include <sys/times.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_SYSCALL_H
|
|
||||||
#include <sys/syscall.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define NONAMELESSUNION
|
#define NONAMELESSUNION
|
||||||
#include "ntstatus.h"
|
#include "ntstatus.h"
|
||||||
|
@ -67,72 +58,6 @@ static RTL_CRITICAL_SECTION_DEBUG critsect_debug =
|
||||||
};
|
};
|
||||||
static RTL_CRITICAL_SECTION peb_lock = { &critsect_debug, -1, 0, 0, 0, 0 };
|
static RTL_CRITICAL_SECTION peb_lock = { &critsect_debug, -1, 0, 0, 0, 0 };
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
|
|
||||||
#ifdef HAVE_ELF_H
|
|
||||||
# include <elf.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_LINK_H
|
|
||||||
# include <link.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_AUXV_H
|
|
||||||
# include <sys/auxv.h>
|
|
||||||
#endif
|
|
||||||
#ifndef HAVE_GETAUXVAL
|
|
||||||
static unsigned long getauxval( unsigned long id )
|
|
||||||
{
|
|
||||||
extern char **__wine_main_environ;
|
|
||||||
char **ptr = __wine_main_environ;
|
|
||||||
ElfW(auxv_t) *auxv;
|
|
||||||
|
|
||||||
while (*ptr) ptr++;
|
|
||||||
while (!*ptr) ptr++;
|
|
||||||
for (auxv = (ElfW(auxv_t) *)ptr; auxv->a_type; auxv++)
|
|
||||||
if (auxv->a_type == id) return auxv->a_un.a_val;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static ULONG_PTR get_image_addr(void)
|
|
||||||
{
|
|
||||||
ULONG_PTR size, num, phdr_addr = getauxval( AT_PHDR );
|
|
||||||
ElfW(Phdr) *phdr;
|
|
||||||
|
|
||||||
if (!phdr_addr) return 0;
|
|
||||||
phdr = (ElfW(Phdr) *)phdr_addr;
|
|
||||||
size = getauxval( AT_PHENT );
|
|
||||||
num = getauxval( AT_PHNUM );
|
|
||||||
while (num--)
|
|
||||||
{
|
|
||||||
if (phdr->p_type == PT_PHDR) return phdr_addr - phdr->p_offset;
|
|
||||||
phdr = (ElfW(Phdr) *)((char *)phdr + size);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
#include <mach/mach.h>
|
|
||||||
#include <mach/mach_error.h>
|
|
||||||
|
|
||||||
static ULONG_PTR get_image_addr(void)
|
|
||||||
{
|
|
||||||
ULONG_PTR ret = 0;
|
|
||||||
#ifdef TASK_DYLD_INFO
|
|
||||||
struct task_dyld_info dyld_info;
|
|
||||||
mach_msg_type_number_t size = TASK_DYLD_INFO_COUNT;
|
|
||||||
if (task_info(mach_task_self(), TASK_DYLD_INFO, (task_info_t)&dyld_info, &size) == KERN_SUCCESS)
|
|
||||||
ret = dyld_info.all_image_info_addr;
|
|
||||||
#endif
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
static ULONG_PTR get_image_addr(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* __wine_dbg_get_channel_flags (NTDLL.@)
|
* __wine_dbg_get_channel_flags (NTDLL.@)
|
||||||
|
@ -204,7 +129,6 @@ TEB *thread_init( SIZE_T *info_size, BOOL *suspend )
|
||||||
InitializeListHead( &ldr.InLoadOrderModuleList );
|
InitializeListHead( &ldr.InLoadOrderModuleList );
|
||||||
InitializeListHead( &ldr.InMemoryOrderModuleList );
|
InitializeListHead( &ldr.InMemoryOrderModuleList );
|
||||||
InitializeListHead( &ldr.InInitializationOrderModuleList );
|
InitializeListHead( &ldr.InInitializationOrderModuleList );
|
||||||
*(ULONG_PTR *)peb->Reserved = get_image_addr();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Starting with Vista, the first user to log on has session id 1.
|
* Starting with Vista, the first user to log on has session id 1.
|
||||||
|
|
|
@ -33,6 +33,15 @@
|
||||||
#ifdef HAVE_PWD_H
|
#ifdef HAVE_PWD_H
|
||||||
# include <pwd.h>
|
# include <pwd.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_ELF_H
|
||||||
|
# include <elf.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_LINK_H
|
||||||
|
# include <link.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_AUXV_H
|
||||||
|
# include <sys/auxv.h>
|
||||||
|
#endif
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_SYS_MMAN_H
|
||||||
# include <sys/mman.h>
|
# include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -53,6 +62,8 @@
|
||||||
# undef LoadResource
|
# undef LoadResource
|
||||||
# undef GetCurrentThread
|
# undef GetCurrentThread
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
|
# include <mach/mach.h>
|
||||||
|
# include <mach/mach_error.h>
|
||||||
# include <mach-o/getsect.h>
|
# include <mach-o/getsect.h>
|
||||||
# include <crt_externs.h>
|
# include <crt_externs.h>
|
||||||
# include <spawn.h>
|
# include <spawn.h>
|
||||||
|
@ -829,6 +840,35 @@ static HMODULE load_ntdll(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* get_image_address
|
||||||
|
*/
|
||||||
|
ULONG_PTR get_image_address(void)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_GETAUXVAL
|
||||||
|
ULONG_PTR size, num, phdr_addr = getauxval( AT_PHDR );
|
||||||
|
ElfW(Phdr) *phdr;
|
||||||
|
|
||||||
|
if (!phdr_addr) return 0;
|
||||||
|
phdr = (ElfW(Phdr) *)phdr_addr;
|
||||||
|
size = getauxval( AT_PHENT );
|
||||||
|
num = getauxval( AT_PHNUM );
|
||||||
|
while (num--)
|
||||||
|
{
|
||||||
|
if (phdr->p_type == PT_PHDR) return phdr_addr - phdr->p_offset;
|
||||||
|
phdr = (ElfW(Phdr) *)((char *)phdr + size);
|
||||||
|
}
|
||||||
|
#elif defined(__APPLE__) && defined(TASK_DYLD_INFO)
|
||||||
|
struct task_dyld_info dyld_info;
|
||||||
|
mach_msg_type_number_t size = TASK_DYLD_INFO_COUNT;
|
||||||
|
|
||||||
|
if (task_info(mach_task_self(), TASK_DYLD_INFO, (task_info_t)&dyld_info, &size) == KERN_SUCCESS)
|
||||||
|
return dyld_info.all_image_info_addr;
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* unix_funcs
|
* unix_funcs
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -142,11 +142,12 @@ extern int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dst
|
||||||
extern char **build_envp( const WCHAR *envW ) DECLSPEC_HIDDEN;
|
extern char **build_envp( const WCHAR *envW ) DECLSPEC_HIDDEN;
|
||||||
extern NTSTATUS exec_wineloader( char **argv, int socketfd, int is_child_64bit,
|
extern NTSTATUS exec_wineloader( char **argv, int socketfd, int is_child_64bit,
|
||||||
ULONGLONG res_start, ULONGLONG res_end ) DECLSPEC_HIDDEN;
|
ULONGLONG res_start, ULONGLONG res_end ) DECLSPEC_HIDDEN;
|
||||||
|
extern void start_server( BOOL debug ) DECLSPEC_HIDDEN;
|
||||||
|
extern ULONG_PTR get_image_address(void) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
extern unsigned int server_call_unlocked( void *req_ptr ) DECLSPEC_HIDDEN;
|
extern unsigned int server_call_unlocked( void *req_ptr ) DECLSPEC_HIDDEN;
|
||||||
extern void server_enter_uninterrupted_section( RTL_CRITICAL_SECTION *cs, sigset_t *sigset ) DECLSPEC_HIDDEN;
|
extern void server_enter_uninterrupted_section( RTL_CRITICAL_SECTION *cs, sigset_t *sigset ) DECLSPEC_HIDDEN;
|
||||||
extern void server_leave_uninterrupted_section( RTL_CRITICAL_SECTION *cs, sigset_t *sigset ) DECLSPEC_HIDDEN;
|
extern void server_leave_uninterrupted_section( RTL_CRITICAL_SECTION *cs, sigset_t *sigset ) DECLSPEC_HIDDEN;
|
||||||
extern void start_server( BOOL debug ) DECLSPEC_HIDDEN;
|
|
||||||
extern unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT flags,
|
extern unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT flags,
|
||||||
timeout_t abs_timeout, CONTEXT *context, RTL_CRITICAL_SECTION *cs,
|
timeout_t abs_timeout, CONTEXT *context, RTL_CRITICAL_SECTION *cs,
|
||||||
user_apc_t *user_apc ) DECLSPEC_HIDDEN;
|
user_apc_t *user_apc ) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -2587,6 +2587,7 @@ TEB *virtual_alloc_first_teb(void)
|
||||||
NtAllocateVirtualMemory( NtCurrentProcess(), (void **)&teb, 0, &teb_size, MEM_COMMIT, PAGE_READWRITE );
|
NtAllocateVirtualMemory( NtCurrentProcess(), (void **)&teb, 0, &teb_size, MEM_COMMIT, PAGE_READWRITE );
|
||||||
NtAllocateVirtualMemory( NtCurrentProcess(), (void **)&peb, 0, &peb_size, MEM_COMMIT, PAGE_READWRITE );
|
NtAllocateVirtualMemory( NtCurrentProcess(), (void **)&peb, 0, &peb_size, MEM_COMMIT, PAGE_READWRITE );
|
||||||
init_teb( teb, peb );
|
init_teb( teb, peb );
|
||||||
|
*(ULONG_PTR *)peb->Reserved = get_image_address();
|
||||||
use_locks = TRUE;
|
use_locks = TRUE;
|
||||||
return teb;
|
return teb;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue