mirror of
https://github.com/reactos/wine.git
synced 2024-11-24 20:30:01 +00:00
Moved initialization of the default user process parameters to ntdll.
This commit is contained in:
parent
3aefc4e4a4
commit
3be8cb8b02
@ -743,6 +743,7 @@ static BOOL init_user_process_params( RTL_USER_PROCESS_PARAMETERS *params )
|
||||
HANDLE hstdin, hstdout, hstderr;
|
||||
|
||||
size = info_size = params->AllocationSize;
|
||||
if (!size) return TRUE; /* no parameters received from parent */
|
||||
|
||||
SERVER_START_REQ( get_startup_info )
|
||||
{
|
||||
@ -933,7 +934,6 @@ static BOOL process_init(void)
|
||||
{
|
||||
static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2',0};
|
||||
PEB *peb = NtCurrentTeb()->Peb;
|
||||
RTL_USER_PROCESS_PARAMETERS *params = peb->ProcessParameters;
|
||||
extern void __wine_dbg_kernel32_init(void);
|
||||
|
||||
PTHREAD_Init();
|
||||
@ -944,27 +944,13 @@ static BOOL process_init(void)
|
||||
setbuf(stderr,NULL);
|
||||
setlocale(LC_CTYPE,"");
|
||||
|
||||
if (!params->AllocationSize)
|
||||
{
|
||||
/* This is wine specific: we have no parent (we're started from unix)
|
||||
* so, create a simple console with bare handles to unix stdio
|
||||
* input & output streams (aka simple console)
|
||||
*/
|
||||
wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, TRUE, ¶ms->hStdInput );
|
||||
wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, TRUE, ¶ms->hStdOutput );
|
||||
wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, TRUE, ¶ms->hStdError );
|
||||
|
||||
params->CurrentDirectory.DosPath.Length = 0;
|
||||
params->CurrentDirectory.DosPath.MaximumLength = RtlGetLongestNtPathLength() * sizeof(WCHAR);
|
||||
params->CurrentDirectory.DosPath.Buffer = RtlAllocateHeap( GetProcessHeap(), 0, params->CurrentDirectory.DosPath.MaximumLength);
|
||||
}
|
||||
else if (!init_user_process_params( params )) return FALSE;
|
||||
if (!init_user_process_params( peb->ProcessParameters )) return FALSE;
|
||||
|
||||
kernel32_handle = GetModuleHandleW(kernel32W);
|
||||
|
||||
LOCALE_Init();
|
||||
|
||||
if (!params->AllocationSize)
|
||||
if (!peb->ProcessParameters->Environment)
|
||||
{
|
||||
/* Copy the parent environment */
|
||||
if (!build_initial_environment( __wine_main_environ )) return FALSE;
|
||||
@ -976,7 +962,7 @@ static BOOL process_init(void)
|
||||
}
|
||||
|
||||
init_windows_dirs();
|
||||
init_current_directory( ¶ms->CurrentDirectory );
|
||||
init_current_directory( &peb->ProcessParameters->CurrentDirectory );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -2126,22 +2126,9 @@ void __wine_process_init( int argc, char *argv[] )
|
||||
NTSTATUS status;
|
||||
ANSI_STRING func_name;
|
||||
void (* DECLSPEC_NORETURN init_func)();
|
||||
ULONG info_size;
|
||||
extern mode_t FILE_umask;
|
||||
|
||||
info_size = thread_init();
|
||||
|
||||
if (info_size)
|
||||
{
|
||||
RTL_USER_PROCESS_PARAMETERS *params = NULL;
|
||||
|
||||
if (NtAllocateVirtualMemory( NtCurrentProcess(), (void **)¶ms, 0, &info_size,
|
||||
MEM_COMMIT, PAGE_READWRITE ) == STATUS_SUCCESS)
|
||||
{
|
||||
params->AllocationSize = info_size;
|
||||
NtCurrentTeb()->Peb->ProcessParameters = params;
|
||||
}
|
||||
}
|
||||
thread_init();
|
||||
|
||||
/* retrieve current umask */
|
||||
FILE_umask = umask(0777);
|
||||
|
@ -34,6 +34,8 @@
|
||||
#define SIGNAL_STACK_SIZE 0 /* we don't need a signal stack on non-i386 */
|
||||
#endif
|
||||
|
||||
#define MAX_NT_PATH_LENGTH 277
|
||||
|
||||
extern void WINAPI __regs_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT );
|
||||
|
||||
/* debug helper */
|
||||
@ -48,7 +50,7 @@ extern NTSTATUS NTDLL_wait_for_multiple_objects( UINT count, const HANDLE *handl
|
||||
/* init routines */
|
||||
extern BOOL SIGNAL_Init(void);
|
||||
extern void debug_init(void);
|
||||
extern ULONG thread_init(void);
|
||||
extern void thread_init(void);
|
||||
extern void virtual_init(void);
|
||||
|
||||
/* server support */
|
||||
|
@ -783,7 +783,7 @@ DWORD WINAPI RtlGetFullPathName_U(const WCHAR* name, ULONG size, WCHAR* buffer,
|
||||
*/
|
||||
DWORD WINAPI RtlGetLongestNtPathLength(void)
|
||||
{
|
||||
return 277;
|
||||
return MAX_NT_PATH_LENGTH;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
|
@ -48,6 +48,7 @@ struct startup_info
|
||||
static PEB peb;
|
||||
static PEB_LDR_DATA ldr;
|
||||
static RTL_USER_PROCESS_PARAMETERS params; /* default parameters if no parent */
|
||||
static WCHAR current_dir[MAX_NT_PATH_LENGTH];
|
||||
static RTL_BITMAP tls_bitmap;
|
||||
static RTL_BITMAP tls_expansion_bitmap;
|
||||
static LIST_ENTRY tls_links;
|
||||
@ -102,7 +103,7 @@ static inline void free_teb( TEB *teb )
|
||||
*
|
||||
* NOTES: The first allocated TEB on NT is at 0x7ffde000.
|
||||
*/
|
||||
ULONG thread_init(void)
|
||||
void thread_init(void)
|
||||
{
|
||||
TEB *teb;
|
||||
void *addr;
|
||||
@ -116,6 +117,8 @@ ULONG thread_init(void)
|
||||
peb.TlsBitmap = &tls_bitmap;
|
||||
peb.TlsExpansionBitmap = &tls_expansion_bitmap;
|
||||
peb.LdrData = &ldr;
|
||||
params.CurrentDirectory.DosPath.Buffer = current_dir;
|
||||
params.CurrentDirectory.DosPath.MaximumLength = sizeof(current_dir);
|
||||
RtlInitializeBitMap( &tls_bitmap, peb.TlsBitmapBits, sizeof(peb.TlsBitmapBits) * 8 );
|
||||
RtlInitializeBitMap( &tls_expansion_bitmap, peb.TlsExpansionBitmapBits,
|
||||
sizeof(peb.TlsExpansionBitmapBits) * 8 );
|
||||
@ -161,7 +164,28 @@ ULONG thread_init(void)
|
||||
MESSAGE( "wine: failed to create the process heap\n" );
|
||||
exit(1);
|
||||
}
|
||||
return info_size;
|
||||
|
||||
/* allocate user parameters */
|
||||
if (info_size)
|
||||
{
|
||||
RTL_USER_PROCESS_PARAMETERS *params = NULL;
|
||||
|
||||
if (NtAllocateVirtualMemory( NtCurrentProcess(), (void **)¶ms, 0, &info_size,
|
||||
MEM_COMMIT, PAGE_READWRITE ) == STATUS_SUCCESS)
|
||||
{
|
||||
params->AllocationSize = info_size;
|
||||
NtCurrentTeb()->Peb->ProcessParameters = params;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is wine specific: we have no parent (we're started from unix)
|
||||
* so, create a simple console with bare handles to unix stdio
|
||||
*/
|
||||
wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, TRUE, ¶ms.hStdInput );
|
||||
wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, TRUE, ¶ms.hStdOutput );
|
||||
wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, TRUE, ¶ms.hStdError );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user