Commit 841f8986 authored by Alexandre Julliard's avatar Alexandre Julliard

Converted process creation to Unicode.

parent f0d96a26
......@@ -482,130 +482,6 @@ void WINAPI RtlDestroyProcessParameters( RTL_USER_PROCESS_PARAMETERS *params )
/***********************************************************************
* build_environment
*
* Build the Win32 environment from the Unix environment
*/
static NTSTATUS build_initial_environment(void)
{
extern char **environ;
LPSTR* e, te;
LPWSTR p;
ULONG size;
NTSTATUS nts;
int len;
/* Compute the total size of the Unix environment */
size = sizeof(BYTE);
for (e = environ; *e; e++)
{
if (!memcmp(*e, "PATH=", 5)) continue;
size += strlen(*e) + 1;
}
size *= sizeof(WCHAR);
/* Now allocate the environment */
nts = NtAllocateVirtualMemory(NtCurrentProcess(), (void**)&p, 0, &size,
MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
if (nts != STATUS_SUCCESS) return nts;
ntdll_get_process_pmts()->Environment = p;
/* And fill it with the Unix environment */
for (e = environ; *e; e++)
{
/* skip Unix PATH and store WINEPATH as PATH */
if (!memcmp(*e, "PATH=", 5)) continue;
if (!memcmp(*e, "WINEPATH=", 9 )) te = *e + 4; else te = *e;
len = strlen(te);
RtlMultiByteToUnicodeN(p, len * sizeof(WCHAR), NULL, te, len);
p[len] = 0;
p += len + 1;
}
*p = 0;
return STATUS_SUCCESS;
}
static void init_unicode( UNICODE_STRING* us, const char** src, size_t len)
{
if (len)
{
STRING ansi;
ansi.Buffer = (char*)*src;
ansi.Length = len;
ansi.MaximumLength = len;
/* FIXME: should check value returned */
RtlAnsiStringToUnicodeString( us, &ansi, TRUE );
*src += len;
}
}
/***********************************************************************
* init_user_process_pmts
*
* Fill the RTL_USER_PROCESS_PARAMETERS structure from the server.
*/
BOOL init_user_process_pmts( size_t info_size )
{
startup_info_t info;
void *data;
const char *src;
size_t len;
RTL_USER_PROCESS_PARAMETERS *rupp;
if (build_initial_environment() != STATUS_SUCCESS) return FALSE;
if (!info_size) return TRUE;
if (!(data = RtlAllocateHeap( ntdll_get_process_heap(), 0, info_size )))
return FALSE;
SERVER_START_REQ( get_startup_info )
{
wine_server_set_reply( req, data, info_size );
wine_server_call( req );
info_size = wine_server_reply_size( reply );
}
SERVER_END_REQ;
if (info_size < sizeof(info.size)) goto done;
len = min( info_size, ((startup_info_t *)data)->size );
memset( &info, 0, sizeof(info) );
memcpy( &info, data, len );
src = (char *)data + len;
info_size -= len;
/* fixup the lengths */
if (info.filename_len > info_size) info.filename_len = info_size;
info_size -= info.filename_len;
if (info.cmdline_len > info_size) info.cmdline_len = info_size;
info_size -= info.cmdline_len;
if (info.desktop_len > info_size) info.desktop_len = info_size;
info_size -= info.desktop_len;
if (info.title_len > info_size) info.title_len = info_size;
rupp = NtCurrentTeb()->Peb->ProcessParameters;
init_unicode( &rupp->ImagePathName, &src, info.filename_len );
init_unicode( &rupp->CommandLine, &src, info.cmdline_len );
init_unicode( &rupp->Desktop, &src, info.desktop_len );
init_unicode( &rupp->WindowTitle, &src, info.title_len );
rupp->dwX = info.x;
rupp->dwY = info.y;
rupp->dwXSize = info.cx;
rupp->dwYSize = info.cy;
rupp->dwXCountChars = info.x_chars;
rupp->dwYCountChars = info.y_chars;
rupp->dwFillAttribute = info.attribute;
rupp->wShowWindow = info.cmd_show;
rupp->dwFlags = info.flags;
done:
RtlFreeHeap( ntdll_get_process_heap(), 0, data );
return TRUE;
}
/***********************************************************************
* set_library_argv
*
* Set the Wine library argc/argv global variables.
......
......@@ -32,8 +32,6 @@
#include "winerror.h"
#include "winreg.h"
#include "winternl.h"
#include "file.h"
#include "module.h"
#include "ntdll_misc.h"
#include "wine/debug.h"
......@@ -479,62 +477,6 @@ static BOOL get_registry_value( HKEY hkey, const WCHAR *module, enum loadorder_t
/***************************************************************************
* MODULE_GetBuiltinPath
*
* Get the path of a builtin module when the native file does not exist.
*/
BOOL MODULE_GetBuiltinPath( const char *libname, const char *ext, char *filename, UINT size )
{
char *p;
BOOL ret = FALSE;
UINT len = GetSystemDirectoryA( filename, size );
if (FILE_contains_path( libname ))
{
char *tmp;
/* if the library name contains a path and can not be found,
* return an error.
* exception: if the path is the system directory, proceed,
* so that modules which are not PE modules can be loaded.
* If the library name does not contain a path and can not
* be found, assume the system directory is meant */
if (strlen(libname) >= size) return FALSE; /* too long */
if (strchr( libname, '/' )) /* need to convert slashes */
{
if (!(tmp = RtlAllocateHeap( GetProcessHeap(), 0, strlen(libname)+1 ))) return FALSE;
strcpy( tmp, libname );
for (p = tmp; *p; p++) if (*p == '/') *p = '\\';
}
else tmp = (char *)libname;
if (!FILE_strncasecmp( filename, tmp, len ) && tmp[len] == '\\')
{
strcpy( filename, tmp );
ret = TRUE;
}
if (tmp != libname) RtlFreeHeap( GetProcessHeap(), 0, tmp );
if (!ret) return FALSE;
}
else
{
if (strlen(libname) >= size - len - 1) return FALSE;
filename[len] = '\\';
strcpy( filename+len+1, libname );
}
/* if the filename doesn't have an extension, append the default */
if (!(p = strrchr( filename, '.')) || strchr( p, '/' ) || strchr( p, '\\'))
{
if (strlen(filename) + strlen(ext) >= size) return FALSE;
strcat( filename, ext );
}
return TRUE;
}
/***************************************************************************
* MODULE_GetLoadOrderW (internal)
*
* Locate the loadorder of a module.
......
......@@ -248,7 +248,7 @@ static BOOL parse_win_version( HKEY hkey )
/**********************************************************************
* VERSION_Init
*/
void VERSION_Init( const char *appname )
void VERSION_Init( const WCHAR *appname )
{
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
......@@ -275,18 +275,15 @@ void VERSION_Init( const char *appname )
/* open AppDefaults\\appname\\Version key */
if (appname && *appname)
{
const char *p;
DWORD len;
const WCHAR *p;
WCHAR appversion[MAX_PATH+20];
BOOL got_win_ver = FALSE;
if ((p = strrchr( appname, '/' ))) appname = p + 1;
if ((p = strrchr( appname, '\\' ))) appname = p + 1;
if ((p = strrchrW( appname, '/' ))) appname = p + 1;
if ((p = strrchrW( appname, '\\' ))) appname = p + 1;
strcpyW( appversion, appdefaultsW );
len = strlenW(appversion);
RtlMultiByteToUnicodeN( appversion + len, sizeof(appversion) - len*sizeof(WCHAR),
&len, appname, strlen(appname)+1 );
strcatW( appversion, appname );
strcatW( appversion, versionW );
TRACE( "getting version from %s\n", debugstr_w(appversion) );
RtlInitUnicodeString( &nameW, appversion );
......
......@@ -1449,27 +1449,26 @@ static UINT DRIVE_GetCurrentDirectory( UINT buflen, LPWSTR buf )
* Build the environment array containing the drives' current directories.
* Resulting pointer must be freed with HeapFree.
*/
char *DRIVE_BuildEnv(void)
WCHAR *DRIVE_BuildEnv(void)
{
int i, length = 0;
LPCWSTR cwd[MAX_DOS_DRIVES];
char *env, *p;
WCHAR *env, *p;
for (i = 0; i < MAX_DOS_DRIVES; i++)
{
if ((cwd[i] = DRIVE_GetDosCwd(i)) && cwd[i][0])
length += WideCharToMultiByte(DRIVE_GetCodepage(i), 0,
cwd[i], -1, NULL, 0, NULL, NULL) + 7;
length += strlenW(cwd[i]) + 8;
}
if (!(env = HeapAlloc( GetProcessHeap(), 0, length+1 ))) return NULL;
if (!(env = HeapAlloc( GetProcessHeap(), 0, (length+1) * sizeof(WCHAR) ))) return NULL;
for (i = 0, p = env; i < MAX_DOS_DRIVES; i++)
{
if (cwd[i] && cwd[i][0])
{
*p++ = '='; *p++ = 'A' + i; *p++ = ':';
*p++ = '='; *p++ = 'A' + i; *p++ = ':'; *p++ = '\\';
WideCharToMultiByte(DRIVE_GetCodepage(i), 0, cwd[i], -1, p, 0x7fffffff, NULL, NULL);
p += strlen(p) + 1;
strcpyW( p, cwd[i] );
p += strlenW(p) + 1;
}
}
*p = 0;
......
......@@ -54,6 +54,6 @@ extern int DRIVE_Disable( int drive );
extern int DRIVE_Enable( int drive );
extern int DRIVE_SetLogicalMapping ( int existing_drive, int new_drive );
extern int DRIVE_OpenDevice( int drive, int flags );
extern char *DRIVE_BuildEnv(void);
extern WCHAR *DRIVE_BuildEnv(void);
#endif /* __WINE_DRIVE_H */
......@@ -65,12 +65,6 @@ inline static char FILE_toupper( char c )
return c;
}
inline static int FILE_contains_path (LPCSTR name)
{
return ((*name && (name[1] == ':')) ||
strchr (name, '/') || strchr (name, '\\'));
}
/* files/file.c */
extern mode_t FILE_umask;
extern int FILE_strcasecmp( const char *str1, const char *str2 );
......
......@@ -202,7 +202,6 @@ extern HRSRC PE_FindResourceW(HMODULE,LPCWSTR,LPCWSTR);
extern HRSRC PE_FindResourceExW(HMODULE,LPCWSTR,LPCWSTR,WORD);
/* loader/loadorder.c */
extern BOOL MODULE_GetBuiltinPath( const char *libname, const char *ext, char *filename, UINT size );
extern void MODULE_GetLoadOrderW( enum loadorder_type plo[], const WCHAR *app_name,
const WCHAR *path, BOOL win32 );
extern void MODULE_GetLoadOrderA( enum loadorder_type plo[], const WCHAR *app_name,
......
......@@ -134,29 +134,6 @@ struct wake_up_reply
typedef struct
{
size_t size;
size_t filename_len;
size_t cmdline_len;
size_t desktop_len;
size_t title_len;
int x;
int y;
int cx;
int cy;
int x_chars;
int y_chars;
int attribute;
int cmd_show;
unsigned int flags;
} startup_info_t;
typedef struct
{
int sec;
int usec;
} abs_time_t;
......@@ -3665,6 +3642,6 @@ union generic_reply
struct open_token_reply open_token_reply;
};
#define SERVER_PROTOCOL_VERSION 122
#define SERVER_PROTOCOL_VERSION 123
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
......@@ -95,7 +95,7 @@ struct startup_info
struct process *process; /* created process */
struct thread *thread; /* created thread */
size_t data_size; /* size of startup data */
startup_info_t *data; /* data for startup info */
void *data; /* data for startup info */
};
static void startup_info_dump( struct object *obj, int verbose );
......@@ -900,8 +900,7 @@ DECL_HANDLER(new_process)
!(info->exe_file = get_file_obj( current->process, req->exe_file, GENERIC_READ )))
goto done;
if (!(info->data = mem_alloc( info->data_size ))) goto done;
memcpy( info->data, get_req_data(), info->data_size );
if (!(info->data = memdup( get_req_data(), info->data_size ))) goto done;
reply->info = alloc_handle( current->process, info, SYNCHRONIZE, FALSE );
done:
......
......@@ -147,29 +147,6 @@ struct wake_up_reply
int signaled; /* wait result */
};
/* structure for process startup info */
typedef struct
{
size_t size; /* size of this structure */
size_t filename_len; /* length of filename */
size_t cmdline_len; /* length of cmd line */
size_t desktop_len; /* length of desktop name */
size_t title_len; /* length of title */
int x; /* window position */
int y;
int cx; /* window size */
int cy;
int x_chars; /* console size */
int y_chars;
int attribute; /* console attributes */
int cmd_show; /* main window show mode */
unsigned int flags; /* info flags */
/* char filename[...]; */
/* char cmdline[...]; */
/* char desktop[...]; */
/* char title[...]; */
} startup_info_t;
/* structure for absolute timeouts */
typedef struct
{
......
......@@ -30,10 +30,11 @@
#include <sys/uio.h>
#endif
#include "windef.h"
#include "winbase.h"
#include "wincon.h"
#include "winreg.h"
#include "winternl.h"
#include "request.h"
#include "unicode.h"
......@@ -294,41 +295,68 @@ static void dump_varargs_debug_event( size_t size )
remove_data( size );
}
/* dump a unicode string contained in a buffer; helper for dump_varargs_startup_info */
static void dump_inline_unicode_string( const UNICODE_STRING *str, const void *data, size_t size )
{
size_t length = str->Length / sizeof(WCHAR);
size_t offset = (size_t)str->Buffer;
if (offset >= size) return;
if (offset + length > size) length = size - offset;
dump_strW( (const WCHAR *)data + offset/sizeof(WCHAR), length, stderr, "\"\"" );
}
static void dump_varargs_startup_info( size_t size )
{
const startup_info_t *ptr = cur_data;
startup_info_t info;
const RTL_USER_PROCESS_PARAMETERS *ptr = cur_data;
RTL_USER_PROCESS_PARAMETERS params;
if (size < sizeof(info.size))
if (size < sizeof(params.Size))
{
fprintf( stderr, "{}" );
return;
}
if (size > ptr->size) size = ptr->size;
memset( &info, 0, sizeof(info) );
memcpy( &info, ptr, min( size, sizeof(info) ));
fprintf( stderr, "{size=%d", info.size );
fprintf( stderr, ",x=%d", info.x );
fprintf( stderr, ",y=%d", info.y );
fprintf( stderr, ",cx=%d", info.cx );
fprintf( stderr, ",cy=%d", info.cy );
fprintf( stderr, ",x_chars=%d", info.x_chars );
fprintf( stderr, ",y_chars=%d", info.y_chars );
fprintf( stderr, ",attr=%d", info.attribute );
fprintf( stderr, ",cmd_show=%d", info.cmd_show );
fprintf( stderr, ",flags=%x", info.flags );
if (size > ptr->Size) size = ptr->Size;
memset( &params, 0, sizeof(params) );
memcpy( &params, ptr, min( size, sizeof(params) ));
fprintf( stderr, "{AllocationSize=%lx,", params.AllocationSize );
fprintf( stderr, "Size=%lx,", params.Size );
fprintf( stderr, "Flags=%lx,", params.Flags );
fprintf( stderr, "DebugFlags=%lx,", params.DebugFlags );
fprintf( stderr, "Console=%p,", params.hConsole );
fprintf( stderr, "ProcessGroup=%lx,", params.ProcessGroup );
fprintf( stderr, "hStdInput=%p,", params.hStdInput );
fprintf( stderr, "hStdOutput=%p,", params.hStdOutput );
fprintf( stderr, "hStdError=%p,", params.hStdError );
fprintf( stderr, "CurrentDirectoryHandle=%p,", params.CurrentDirectoryHandle );
fprintf( stderr, "dwX=%ld,", params.dwX );
fprintf( stderr, "dwY=%ld,", params.dwY );
fprintf( stderr, "dwXSize=%ld,", params.dwXSize );
fprintf( stderr, "dwYSize=%ld,", params.dwYSize );
fprintf( stderr, "dwXCountChars=%ld,", params.dwXCountChars );
fprintf( stderr, "dwYCountChars=%ld,", params.dwYCountChars );
fprintf( stderr, "dwFillAttribute=%lx,", params.dwFillAttribute );
fprintf( stderr, "dwFlags=%lx,", params.dwFlags );
fprintf( stderr, "wShowWindow=%lx,", params.wShowWindow );
fprintf( stderr, "CurrentDirectoryName=L\"" );
dump_inline_unicode_string( &params.CurrentDirectoryName, cur_data, size );
fprintf( stderr, "\",DllPath=L\"" );
dump_inline_unicode_string( &params.DllPath, cur_data, size );
fprintf( stderr, "\",ImagePathName=L\"" );
dump_inline_unicode_string( &params.ImagePathName, cur_data, size );
fprintf( stderr, "\",CommandLine=L\"" );
dump_inline_unicode_string( &params.CommandLine, cur_data, size );
fprintf( stderr, "\",WindowTitle=L\"" );
dump_inline_unicode_string( &params.WindowTitle, cur_data, size );
fprintf( stderr, "\",Desktop=L\"" );
dump_inline_unicode_string( &params.Desktop, cur_data, size );
fprintf( stderr, "\",ShellInfo=L\"" );
dump_inline_unicode_string( &params.ShellInfo, cur_data, size );
fprintf( stderr, "\",RuntimeInfo=L\"" );
dump_inline_unicode_string( &params.RuntimeInfo, cur_data, size );
fprintf( stderr, "\"}" );
remove_data( size );
fprintf( stderr, ",filename=" );
/* FIXME: these should be unicode */
dump_varargs_string( min(cur_size,info.filename_len) );
fprintf( stderr, ",cmdline=" );
dump_varargs_string( min(cur_size,info.cmdline_len) );
fprintf( stderr, ",desktop=" );
dump_varargs_string( min(cur_size,info.desktop_len) );
fprintf( stderr, ",title=" );
dump_varargs_string( min(cur_size,info.title_len) );
fputc( '}', stderr );
}
static void dump_varargs_input_records( size_t size )
......
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