ntdll: Move mapping of the user shared data to the Unix library.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
cd0c598802
commit
4ffe39573b
|
@ -4392,7 +4392,6 @@ void __wine_process_init(void)
|
|||
FILE_umask = umask(0777);
|
||||
umask( FILE_umask );
|
||||
|
||||
map_user_shared_data();
|
||||
load_global_options();
|
||||
version_init();
|
||||
|
||||
|
|
|
@ -176,7 +176,6 @@ extern NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_S
|
|||
extern void virtual_fill_image_information( const pe_image_info_t *pe_info,
|
||||
SECTION_IMAGE_INFORMATION *info ) DECLSPEC_HIDDEN;
|
||||
extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN;
|
||||
extern void map_user_shared_data(void) DECLSPEC_HIDDEN;
|
||||
|
||||
/* completion */
|
||||
extern NTSTATUS NTDLL_AddCompletion( HANDLE hFile, ULONG_PTR CompletionValue,
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
WINE_DEFAULT_DEBUG_CHANNEL(thread);
|
||||
WINE_DECLARE_DEBUG_CHANNEL(relay);
|
||||
|
||||
struct _KUSER_SHARED_DATA *user_shared_data = NULL;
|
||||
struct _KUSER_SHARED_DATA *user_shared_data = (void *)0x7ffe0000;
|
||||
|
||||
void (WINAPI *kernel32_start_process)(LPTHREAD_START_ROUTINE,void*) = NULL;
|
||||
|
||||
|
@ -173,33 +173,6 @@ int __cdecl __wine_dbg_output( const char *str )
|
|||
return unix_funcs->dbg_output( str );
|
||||
}
|
||||
|
||||
void map_user_shared_data(void)
|
||||
{
|
||||
static const WCHAR wine_usdW[] = {'\\','K','e','r','n','e','l','O','b','j','e','c','t','s',
|
||||
'\\','_','_','w','i','n','e','_','u','s','e','r','_','s','h','a','r','e','d','_','d','a','t','a',0};
|
||||
OBJECT_ATTRIBUTES attr = {sizeof(attr)};
|
||||
UNICODE_STRING wine_usd_str;
|
||||
NTSTATUS status;
|
||||
HANDLE section;
|
||||
int res, fd, needs_close;
|
||||
|
||||
RtlInitUnicodeString( &wine_usd_str, wine_usdW );
|
||||
InitializeObjectAttributes( &attr, &wine_usd_str, OBJ_OPENIF, NULL, NULL );
|
||||
if ((status = NtOpenSection( §ion, SECTION_ALL_ACCESS, &attr )))
|
||||
{
|
||||
MESSAGE( "wine: failed to open the USD section: %08x\n", status );
|
||||
exit(1);
|
||||
}
|
||||
if ((res = unix_funcs->server_get_unix_fd( section, 0, &fd, &needs_close, NULL, NULL )) ||
|
||||
(user_shared_data != mmap( user_shared_data, sizeof(*user_shared_data),
|
||||
PROT_READ, MAP_SHARED | MAP_FIXED, fd, 0 )))
|
||||
{
|
||||
MESSAGE( "wine: failed to remap the process USD: %d\n", res );
|
||||
exit(1);
|
||||
}
|
||||
if (needs_close) close( fd );
|
||||
NtClose( section );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* thread_init
|
||||
|
@ -211,27 +184,9 @@ void map_user_shared_data(void)
|
|||
TEB *thread_init( SIZE_T *info_size, BOOL *suspend )
|
||||
{
|
||||
TEB *teb;
|
||||
void *addr;
|
||||
SIZE_T size;
|
||||
NTSTATUS status;
|
||||
|
||||
virtual_init();
|
||||
|
||||
/* reserve space for shared user data */
|
||||
|
||||
addr = (void *)0x7ffe0000;
|
||||
size = 0x1000;
|
||||
status = NtAllocateVirtualMemory( NtCurrentProcess(), &addr, 0, &size,
|
||||
MEM_RESERVE|MEM_COMMIT, PAGE_READONLY );
|
||||
if (status)
|
||||
{
|
||||
MESSAGE( "wine: failed to map the shared user data: %08x\n", status );
|
||||
exit(1);
|
||||
}
|
||||
user_shared_data = addr;
|
||||
|
||||
/* allocate and initialize the PEB and initial TEB */
|
||||
|
||||
teb = unix_funcs->init_threading( &nb_threads, &__wine_ldt_copy, info_size, suspend, &server_cpus,
|
||||
&is_wow64, &server_start_time );
|
||||
|
||||
|
|
|
@ -107,6 +107,8 @@ TEB * CDECL init_threading( int *nb_threads_ptr, struct ldt_copy **ldt_copy, SIZ
|
|||
dbg_init();
|
||||
server_init_process();
|
||||
info_size = server_init_thread( teb->Peb, suspend );
|
||||
virtual_map_user_shared_data();
|
||||
|
||||
if (size) *size = info_size;
|
||||
if (cpus) *cpus = server_cpus;
|
||||
if (wow64) *wow64 = is_wow64;
|
||||
|
|
|
@ -134,6 +134,7 @@ extern void virtual_init(void) DECLSPEC_HIDDEN;
|
|||
extern TEB *virtual_alloc_first_teb(void) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS virtual_alloc_teb( TEB **ret_teb ) DECLSPEC_HIDDEN;
|
||||
extern void virtual_free_teb( TEB *teb ) DECLSPEC_HIDDEN;
|
||||
extern void virtual_map_user_shared_data(void) DECLSPEC_HIDDEN;
|
||||
|
||||
extern void signal_init_threading(void) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS signal_alloc_thread( TEB *teb ) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -161,6 +161,8 @@ static void *user_space_limit = (void *)0x7fff0000;
|
|||
static void *working_set_limit = (void *)0x7fff0000;
|
||||
#endif
|
||||
|
||||
static struct _KUSER_SHARED_DATA *user_shared_data = (void *)0x7ffe0000;
|
||||
|
||||
SIZE_T signal_stack_size = 0;
|
||||
SIZE_T signal_stack_mask = 0;
|
||||
static SIZE_T signal_stack_align;
|
||||
|
@ -2543,10 +2545,21 @@ TEB *virtual_alloc_first_teb(void)
|
|||
{
|
||||
TEB *teb;
|
||||
PEB *peb;
|
||||
NTSTATUS status;
|
||||
SIZE_T data_size = page_size;
|
||||
SIZE_T peb_size = page_size;
|
||||
SIZE_T teb_size = signal_stack_mask + 1;
|
||||
SIZE_T total = 32 * teb_size;
|
||||
|
||||
/* reserve space for shared user data */
|
||||
status = NtAllocateVirtualMemory( NtCurrentProcess(), (void **)&user_shared_data, 0, &data_size,
|
||||
MEM_RESERVE | MEM_COMMIT, PAGE_READONLY );
|
||||
if (status)
|
||||
{
|
||||
ERR( "wine: failed to map the shared user data: %08x\n", status );
|
||||
exit(1);
|
||||
}
|
||||
|
||||
NtAllocateVirtualMemory( NtCurrentProcess(), (void **)&teb_block, 0, &total,
|
||||
MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE );
|
||||
teb_block_pos = 30;
|
||||
|
@ -2733,6 +2746,37 @@ void virtual_clear_thread_stack( void *stack_end )
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* virtual_map_user_shared_data
|
||||
*/
|
||||
void virtual_map_user_shared_data(void)
|
||||
{
|
||||
static const WCHAR wine_usdW[] = {'\\','K','e','r','n','e','l','O','b','j','e','c','t','s',
|
||||
'\\','_','_','w','i','n','e','_','u','s','e','r','_','s','h','a','r','e','d','_','d','a','t','a',0};
|
||||
OBJECT_ATTRIBUTES attr = {sizeof(attr)};
|
||||
UNICODE_STRING wine_usd_str;
|
||||
NTSTATUS status;
|
||||
HANDLE section;
|
||||
int res, fd, needs_close;
|
||||
|
||||
RtlInitUnicodeString( &wine_usd_str, wine_usdW );
|
||||
InitializeObjectAttributes( &attr, &wine_usd_str, OBJ_OPENIF, NULL, NULL );
|
||||
if ((status = NtOpenSection( §ion, SECTION_ALL_ACCESS, &attr )))
|
||||
{
|
||||
ERR( "failed to open the USD section: %08x\n", status );
|
||||
exit(1);
|
||||
}
|
||||
if ((res = server_get_unix_fd( section, 0, &fd, &needs_close, NULL, NULL )) ||
|
||||
(user_shared_data != mmap( user_shared_data, page_size, PROT_READ, MAP_SHARED|MAP_FIXED, fd, 0 )))
|
||||
{
|
||||
ERR( "failed to remap the process USD: %d\n", res );
|
||||
exit(1);
|
||||
}
|
||||
if (needs_close) close( fd );
|
||||
NtClose( section );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* virtual_handle_fault
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue