Commit 2cf868c0 authored by Alexandre Julliard's avatar Alexandre Julliard

server: Move ldt_copy to the init_process_done request and make it a client_ptr_t.

parent 1d2d0d56
...@@ -994,6 +994,9 @@ NTSTATUS server_init_process_done(void) ...@@ -994,6 +994,9 @@ NTSTATUS server_init_process_done(void)
SERVER_START_REQ( init_process_done ) SERVER_START_REQ( init_process_done )
{ {
req->module = wine_server_client_ptr( peb->ImageBaseAddress ); req->module = wine_server_client_ptr( peb->ImageBaseAddress );
#ifdef __i386__
req->ldt_copy = wine_server_client_ptr( &wine_ldt_copy );
#endif
req->entry = (char *)peb->ImageBaseAddress + nt->OptionalHeader.AddressOfEntryPoint; req->entry = (char *)peb->ImageBaseAddress + nt->OptionalHeader.AddressOfEntryPoint;
req->gui = (nt->OptionalHeader.Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CUI); req->gui = (nt->OptionalHeader.Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CUI);
status = wine_server_call( req ); status = wine_server_call( req );
...@@ -1048,7 +1051,6 @@ size_t server_init_thread( int unix_pid, int unix_tid, void *entry_point ) ...@@ -1048,7 +1051,6 @@ size_t server_init_thread( int unix_pid, int unix_tid, void *entry_point )
req->teb = NtCurrentTeb(); req->teb = NtCurrentTeb();
req->peb = NtCurrentTeb()->Peb; req->peb = NtCurrentTeb()->Peb;
req->entry = entry_point; req->entry = entry_point;
req->ldt_copy = &wine_ldt_copy;
req->reply_fd = reply_pipe[1]; req->reply_fd = reply_pipe[1];
req->wait_fd = ntdll_get_thread_data()->wait_fd[1]; req->wait_fd = ntdll_get_thread_data()->wait_fd[1];
req->debug_level = (TRACE_ON(server) != 0); req->debug_level = (TRACE_ON(server) != 0);
......
...@@ -542,6 +542,7 @@ struct init_process_done_request ...@@ -542,6 +542,7 @@ struct init_process_done_request
struct request_header __header; struct request_header __header;
int gui; int gui;
mod_handle_t module; mod_handle_t module;
client_ptr_t ldt_copy;
void* entry; void* entry;
}; };
struct init_process_done_reply struct init_process_done_reply
...@@ -560,7 +561,7 @@ struct init_thread_request ...@@ -560,7 +561,7 @@ struct init_thread_request
void* teb; void* teb;
void* peb; void* peb;
void* entry; void* entry;
void* ldt_copy; int unused;
int reply_fd; int reply_fd;
int wait_fd; int wait_fd;
}; };
...@@ -5061,6 +5062,6 @@ union generic_reply ...@@ -5061,6 +5062,6 @@ union generic_reply
struct set_window_layered_info_reply set_window_layered_info_reply; struct set_window_layered_info_reply set_window_layered_info_reply;
}; };
#define SERVER_PROTOCOL_VERSION 373 #define SERVER_PROTOCOL_VERSION 374
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */ #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
...@@ -446,9 +446,8 @@ void get_selector_entry( struct thread *thread, int entry, unsigned int *base, ...@@ -446,9 +446,8 @@ void get_selector_entry( struct thread *thread, int entry, unsigned int *base,
if ((ret = task_suspend( process_port )) == KERN_SUCCESS) if ((ret = task_suspend( process_port )) == KERN_SUCCESS)
{ {
void *ptr = process->ldt_copy; vm_offset_t offset = process->ldt_copy % page_size;
vm_offset_t offset = (unsigned long)ptr % page_size; vm_address_t aligned_address = (vm_address_t)(process->ldt_copy - offset);
vm_address_t aligned_address = (vm_address_t)((char *)ptr - offset);
vm_size_t aligned_size = (total_size + offset + page_size - 1) / page_size * page_size; vm_size_t aligned_size = (total_size + offset + page_size - 1) / page_size * page_size;
ret = vm_read( process_port, aligned_address, aligned_size, &data, &bytes_read ); ret = vm_read( process_port, aligned_address, aligned_size, &data, &bytes_read );
......
...@@ -332,7 +332,7 @@ struct thread *create_process( int fd, struct thread *parent_thread, int inherit ...@@ -332,7 +332,7 @@ struct thread *create_process( int fd, struct thread *parent_thread, int inherit
process->idle_event = NULL; process->idle_event = NULL;
process->queue = NULL; process->queue = NULL;
process->peb = NULL; process->peb = NULL;
process->ldt_copy = NULL; process->ldt_copy = 0;
process->winstation = 0; process->winstation = 0;
process->desktop = 0; process->desktop = 0;
process->token = NULL; process->token = NULL;
...@@ -1018,6 +1018,8 @@ DECL_HANDLER(init_process_done) ...@@ -1018,6 +1018,8 @@ DECL_HANDLER(init_process_done)
list_remove( &dll->entry ); list_remove( &dll->entry );
list_add_head( &process->dlls, &dll->entry ); list_add_head( &process->dlls, &dll->entry );
process->ldt_copy = req->ldt_copy;
generate_startup_debug_events( process, req->entry ); generate_startup_debug_events( process, req->entry );
set_process_startup_state( process, STARTUP_DONE ); set_process_startup_state( process, STARTUP_DONE );
......
...@@ -80,7 +80,7 @@ struct process ...@@ -80,7 +80,7 @@ struct process
struct token *token; /* security token associated with this process */ struct token *token; /* security token associated with this process */
struct list dlls; /* list of loaded dlls */ struct list dlls; /* list of loaded dlls */
void *peb; /* PEB address in client address space */ void *peb; /* PEB address in client address space */
void *ldt_copy; /* pointer to LDT copy in client addr space */ client_ptr_t ldt_copy; /* pointer to LDT copy in client addr space */
unsigned int trace_data; /* opaque data used by the process tracing mechanism */ unsigned int trace_data; /* opaque data used by the process tracing mechanism */
}; };
......
...@@ -174,10 +174,15 @@ void get_selector_entry( struct thread *thread, int entry, unsigned int *base, ...@@ -174,10 +174,15 @@ void get_selector_entry( struct thread *thread, int entry, unsigned int *base,
unsigned int *limit, unsigned char *flags ) unsigned int *limit, unsigned char *flags )
{ {
ssize_t ret; ssize_t ret;
off_t pos = (off_t)thread->process->ldt_copy; off_t pos = thread->process->ldt_copy;
int fd = open_proc_as( thread->process, O_RDONLY ); int fd;
if (fd == -1) return; if (!pos)
{
set_error( STATUS_ACCESS_DENIED );
return 0;
}
if ((fd = open_proc_as( thread->process, O_RDONLY )) == -1) return;
ret = pread( fd, base, sizeof(*base), pos + entry*sizeof(int) ); ret = pread( fd, base, sizeof(*base), pos + entry*sizeof(int) );
if (ret != sizeof(*base)) goto error; if (ret != sizeof(*base)) goto error;
......
...@@ -536,6 +536,7 @@ typedef union ...@@ -536,6 +536,7 @@ typedef union
@REQ(init_process_done) @REQ(init_process_done)
int gui; /* is it a GUI process? */ int gui; /* is it a GUI process? */
mod_handle_t module; /* main module base address */ mod_handle_t module; /* main module base address */
client_ptr_t ldt_copy; /* address of LDT copy (in thread address space) */
void* entry; /* process entry point */ void* entry; /* process entry point */
@END @END
...@@ -548,7 +549,7 @@ typedef union ...@@ -548,7 +549,7 @@ typedef union
void* teb; /* TEB of new thread (in thread address space) */ void* teb; /* TEB of new thread (in thread address space) */
void* peb; /* address of PEB (in thread address space) */ void* peb; /* address of PEB (in thread address space) */
void* entry; /* thread entry point (in thread address space) */ void* entry; /* thread entry point (in thread address space) */
void* ldt_copy; /* address of LDT copy (in thread address space) */ int unused; /* was: ldt_copy */
int reply_fd; /* fd for reply pipe */ int reply_fd; /* fd for reply pipe */
int wait_fd; /* fd for blocking calls pipe */ int wait_fd; /* fd for blocking calls pipe */
@REPLY @REPLY
......
...@@ -505,10 +505,10 @@ void get_selector_entry( struct thread *thread, int entry, unsigned int *base, ...@@ -505,10 +505,10 @@ void get_selector_entry( struct thread *thread, int entry, unsigned int *base,
if (suspend_for_ptrace( thread )) if (suspend_for_ptrace( thread ))
{ {
unsigned char flags_buf[4]; unsigned char flags_buf[4];
int *addr = (int *)thread->process->ldt_copy + entry; int *addr = (int *)(unsigned long)thread->process->ldt_copy + entry;
if (read_thread_int( thread, addr, (int *)base ) == -1) goto done; if (read_thread_int( thread, addr, (int *)base ) == -1) goto done;
if (read_thread_int( thread, addr + 8192, (int *)limit ) == -1) goto done; if (read_thread_int( thread, addr + 8192, (int *)limit ) == -1) goto done;
addr = (int *)thread->process->ldt_copy + 2*8192 + (entry >> 2); addr = (int *)(unsigned long)thread->process->ldt_copy + 2*8192 + (entry >> 2);
if (read_thread_int( thread, addr, (int *)flags_buf ) == -1) goto done; if (read_thread_int( thread, addr, (int *)flags_buf ) == -1) goto done;
*flags = flags_buf[entry & 3]; *flags = flags_buf[entry & 3];
done: done:
......
...@@ -1032,7 +1032,7 @@ DECL_HANDLER(init_thread) ...@@ -1032,7 +1032,7 @@ DECL_HANDLER(init_thread)
if (!(current->wait_fd = create_anonymous_fd( &thread_fd_ops, wait_fd, &current->obj, 0 ))) if (!(current->wait_fd = create_anonymous_fd( &thread_fd_ops, wait_fd, &current->obj, 0 )))
return; return;
if (!is_valid_address(req->teb) || !is_valid_address(req->peb) || !is_valid_address(req->ldt_copy)) if (!is_valid_address(req->teb) || !is_valid_address(req->peb))
{ {
set_error( STATUS_INVALID_PARAMETER ); set_error( STATUS_INVALID_PARAMETER );
return; return;
...@@ -1046,7 +1046,6 @@ DECL_HANDLER(init_thread) ...@@ -1046,7 +1046,6 @@ DECL_HANDLER(init_thread)
{ {
process->unix_pid = current->unix_pid; process->unix_pid = current->unix_pid;
process->peb = req->peb; process->peb = req->peb;
process->ldt_copy = req->ldt_copy;
reply->info_size = init_process( current ); reply->info_size = init_process( current );
} }
else else
......
...@@ -971,6 +971,9 @@ static void dump_init_process_done_request( const struct init_process_done_reque ...@@ -971,6 +971,9 @@ static void dump_init_process_done_request( const struct init_process_done_reque
fprintf( stderr, " module=" ); fprintf( stderr, " module=" );
dump_uint64( &req->module ); dump_uint64( &req->module );
fprintf( stderr, "," ); fprintf( stderr, "," );
fprintf( stderr, " ldt_copy=" );
dump_uint64( &req->ldt_copy );
fprintf( stderr, "," );
fprintf( stderr, " entry=%p", req->entry ); fprintf( stderr, " entry=%p", req->entry );
} }
...@@ -982,7 +985,7 @@ static void dump_init_thread_request( const struct init_thread_request *req ) ...@@ -982,7 +985,7 @@ static void dump_init_thread_request( const struct init_thread_request *req )
fprintf( stderr, " teb=%p,", req->teb ); fprintf( stderr, " teb=%p,", req->teb );
fprintf( stderr, " peb=%p,", req->peb ); fprintf( stderr, " peb=%p,", req->peb );
fprintf( stderr, " entry=%p,", req->entry ); fprintf( stderr, " entry=%p,", req->entry );
fprintf( stderr, " ldt_copy=%p,", req->ldt_copy ); fprintf( stderr, " unused=%d,", req->unused );
fprintf( stderr, " reply_fd=%d,", req->reply_fd ); fprintf( stderr, " reply_fd=%d,", req->reply_fd );
fprintf( stderr, " wait_fd=%d", req->wait_fd ); fprintf( stderr, " wait_fd=%d", req->wait_fd );
} }
......
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