Store module names in Unicode in the server.
This commit is contained in:
parent
a613de2a22
commit
c30cefb2d5
|
@ -101,8 +101,6 @@ PDB current_process;
|
|||
static RTL_USER_PROCESS_PARAMETERS process_pmts;
|
||||
static PEB_LDR_DATA process_ldr;
|
||||
|
||||
static char main_exe_name[MAX_PATH];
|
||||
static char *main_exe_name_ptr = main_exe_name;
|
||||
static HANDLE main_exe_file;
|
||||
static DWORD shutdown_flags = 0;
|
||||
static DWORD shutdown_priority = 0x280;
|
||||
|
@ -121,11 +119,9 @@ int main_create_flags = 0;
|
|||
#define PDB32_WIN32S_PROC 0x8000 /* Win32s process */
|
||||
|
||||
/* dlls/ntdll/env.c */
|
||||
extern BOOL init_user_process_pmts( size_t, char*, size_t );
|
||||
extern BOOL init_user_process_pmts( size_t );
|
||||
extern BOOL build_command_line( char **argv );
|
||||
|
||||
extern WINE_MODREF *MODULE_AllocModRef( HMODULE hModule, LPCSTR filename ); /* FIXME */
|
||||
|
||||
extern void RELAY_InitDebugLists(void);
|
||||
extern void SHELL_LoadRegistry(void);
|
||||
extern void VERSION_Init( const char *appname );
|
||||
|
@ -407,8 +403,7 @@ static BOOL process_init( char *argv[] )
|
|||
}
|
||||
|
||||
/* Copy the parent environment */
|
||||
if (!init_user_process_pmts( info_size, main_exe_name, sizeof(main_exe_name) ))
|
||||
return FALSE;
|
||||
if (!init_user_process_pmts( info_size )) return FALSE;
|
||||
|
||||
/* Parse command line arguments */
|
||||
OPTIONS_ParseOptions( !info_size ? argv : NULL );
|
||||
|
@ -458,12 +453,12 @@ static void start_process( void *arg )
|
|||
LPTHREAD_START_ROUTINE entry;
|
||||
HANDLE main_file = main_exe_file;
|
||||
IMAGE_NT_HEADERS *nt;
|
||||
WINE_MODREF *wm;
|
||||
PEB *peb = NtCurrentTeb()->Peb;
|
||||
UNICODE_STRING *main_exe_name = &peb->ProcessParameters->ImagePathName;
|
||||
|
||||
if (main_file)
|
||||
{
|
||||
UINT drive_type = GetDriveTypeA( main_exe_name );
|
||||
UINT drive_type = GetDriveTypeW( main_exe_name->Buffer );
|
||||
/* don't keep the file handle open on removable media */
|
||||
if (drive_type == DRIVE_REMOVABLE || drive_type == DRIVE_CDROM) main_file = 0;
|
||||
}
|
||||
|
@ -488,17 +483,16 @@ static void start_process( void *arg )
|
|||
req->module_size = nt->OptionalHeader.SizeOfImage;
|
||||
req->entry = entry;
|
||||
/* API requires a double indirection */
|
||||
req->name = &main_exe_name_ptr;
|
||||
req->name = &main_exe_name->Buffer;
|
||||
req->exe_file = main_file;
|
||||
req->gui = (nt->OptionalHeader.Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CUI);
|
||||
wine_server_add_data( req, main_exe_name, strlen(main_exe_name) );
|
||||
wine_server_add_data( req, main_exe_name->Buffer, main_exe_name->Length );
|
||||
wine_server_call( req );
|
||||
peb->BeingDebugged = reply->debugged;
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
|
||||
/* create the main modref and load dependencies */
|
||||
if (!(wm = MODULE_AllocModRef( peb->ImageBaseAddress, main_exe_name ))) goto error;
|
||||
if (main_exe_file) CloseHandle( main_exe_file ); /* we no longer need it */
|
||||
if (MODULE_DllProcessAttach( NULL, (LPVOID)1 ) != STATUS_SUCCESS)
|
||||
{
|
||||
|
@ -508,7 +502,7 @@ static void start_process( void *arg )
|
|||
|
||||
if (TRACE_ON(relay))
|
||||
DPRINTF( "%04lx:Starting process %s (entryproc=%p)\n",
|
||||
GetCurrentThreadId(), main_exe_name, entry );
|
||||
GetCurrentThreadId(), debugstr_w(main_exe_name->Buffer), entry );
|
||||
if (peb->BeingDebugged) DbgBreakPoint();
|
||||
SetLastError(0); /* clear error code */
|
||||
ExitThread( entry( NtCurrentTeb()->Peb ) );
|
||||
|
@ -531,6 +525,7 @@ static void start_process( void *arg )
|
|||
*/
|
||||
void __wine_process_init( int argc, char *argv[] )
|
||||
{
|
||||
char main_exe_name[MAX_PATH];
|
||||
char error[1024], *p;
|
||||
DWORD stack_size = 0;
|
||||
int file_exists;
|
||||
|
@ -540,10 +535,12 @@ void __wine_process_init( int argc, char *argv[] )
|
|||
|
||||
argv++; /* remove argv[0] (wine itself) */
|
||||
|
||||
TRACE( "starting process name=%s file=%p argv[0]=%s\n",
|
||||
debugstr_a(main_exe_name), main_exe_file, debugstr_a(argv[0]) );
|
||||
|
||||
if (!main_exe_name[0])
|
||||
if (process_pmts.ImagePathName.Buffer)
|
||||
{
|
||||
WideCharToMultiByte( CP_ACP, 0, process_pmts.ImagePathName.Buffer, -1,
|
||||
main_exe_name, sizeof(main_exe_name), NULL, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!argv[0]) OPTIONS_Usage();
|
||||
|
||||
|
@ -557,8 +554,13 @@ void __wine_process_init( int argc, char *argv[] )
|
|||
MESSAGE( "%s: cannot open '%s'\n", argv0, main_exe_name );
|
||||
ExitProcess(1);
|
||||
}
|
||||
RtlCreateUnicodeStringFromAsciiz( &NtCurrentTeb()->Peb->ProcessParameters->ImagePathName,
|
||||
main_exe_name );
|
||||
}
|
||||
|
||||
TRACE( "starting process name=%s file=%p argv[0]=%s\n",
|
||||
debugstr_a(main_exe_name), main_exe_file, debugstr_a(argv[0]) );
|
||||
|
||||
if (!main_exe_file) /* no file handle -> Winelib app */
|
||||
{
|
||||
TRACE( "starting Winelib app %s\n", debugstr_a(main_exe_name) );
|
||||
|
|
|
@ -300,6 +300,8 @@ BOOL WINAPI Thread32Next(HANDLE hSnapshot, LPTHREADENTRY32 lpte)
|
|||
static BOOL TOOLHELP_Process32Next( HANDLE handle, LPPROCESSENTRY32 lppe, BOOL first )
|
||||
{
|
||||
BOOL ret;
|
||||
WCHAR exe[MAX_PATH];
|
||||
DWORD len;
|
||||
|
||||
if (lppe->dwSize < sizeof(PROCESSENTRY32))
|
||||
{
|
||||
|
@ -311,18 +313,20 @@ static BOOL TOOLHELP_Process32Next( HANDLE handle, LPPROCESSENTRY32 lppe, BOOL f
|
|||
{
|
||||
req->handle = handle;
|
||||
req->reset = first;
|
||||
wine_server_set_reply( req, lppe->szExeFile, sizeof(lppe->szExeFile)-1 );
|
||||
wine_server_set_reply( req, exe, sizeof(exe) );
|
||||
if ((ret = !wine_server_call_err( req )))
|
||||
{
|
||||
lppe->cntUsage = reply->count;
|
||||
lppe->th32ProcessID = (DWORD)reply->pid;
|
||||
lppe->th32ProcessID = reply->pid;
|
||||
lppe->th32DefaultHeapID = (DWORD)reply->heap;
|
||||
lppe->th32ModuleID = (DWORD)reply->module;
|
||||
lppe->cntThreads = reply->threads;
|
||||
lppe->th32ParentProcessID = (DWORD)reply->ppid;
|
||||
lppe->th32ParentProcessID = reply->ppid;
|
||||
lppe->pcPriClassBase = reply->priority;
|
||||
lppe->dwFlags = -1; /* FIXME */
|
||||
lppe->szExeFile[wine_server_reply_size(reply)] = 0;
|
||||
len = WideCharToMultiByte( CP_ACP, 0, exe, wine_server_reply_size(reply) / sizeof(WCHAR),
|
||||
lppe->szExeFile, sizeof(lppe->szExeFile), NULL, NULL );
|
||||
lppe->szExeFile[len] = 0;
|
||||
}
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
|
@ -359,6 +363,8 @@ BOOL WINAPI Process32Next(HANDLE hSnapshot, LPPROCESSENTRY32 lppe)
|
|||
static BOOL TOOLHELP_Module32Next( HANDLE handle, LPMODULEENTRY32 lpme, BOOL first )
|
||||
{
|
||||
BOOL ret;
|
||||
WCHAR exe[MAX_PATH];
|
||||
DWORD len;
|
||||
|
||||
if (lpme->dwSize < sizeof (MODULEENTRY32))
|
||||
{
|
||||
|
@ -370,18 +376,20 @@ static BOOL TOOLHELP_Module32Next( HANDLE handle, LPMODULEENTRY32 lpme, BOOL fir
|
|||
{
|
||||
req->handle = handle;
|
||||
req->reset = first;
|
||||
wine_server_set_reply( req, lpme->szExePath, sizeof(lpme->szExePath)-1 );
|
||||
wine_server_set_reply( req, exe, sizeof(exe) );
|
||||
if ((ret = !wine_server_call_err( req )))
|
||||
{
|
||||
lpme->th32ModuleID = 0; /* toolhelp internal id, never used */
|
||||
lpme->th32ProcessID = (DWORD)reply->pid;
|
||||
lpme->th32ProcessID = reply->pid;
|
||||
lpme->GlblcntUsage = 0; /* FIXME */
|
||||
lpme->ProccntUsage = 0; /* FIXME */
|
||||
lpme->modBaseAddr = reply->base;
|
||||
lpme->modBaseSize = reply->size;
|
||||
lpme->hModule = (HMODULE)reply->base;
|
||||
lpme->hModule = reply->base;
|
||||
lpme->szModule[0] = 0; /* FIXME */
|
||||
lpme->szExePath[wine_server_reply_size(reply)] = 0;
|
||||
len = WideCharToMultiByte( CP_ACP, 0, exe, wine_server_reply_size(reply) / sizeof(WCHAR),
|
||||
lpme->szExePath, sizeof(lpme->szExePath), NULL, NULL );
|
||||
lpme->szExePath[len] = 0;
|
||||
}
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
|
|
|
@ -399,7 +399,7 @@ static void init_unicode( UNICODE_STRING* us, const char** src, size_t len)
|
|||
*
|
||||
* Fill the RTL_USER_PROCESS_PARAMETERS structure from the server.
|
||||
*/
|
||||
BOOL init_user_process_pmts( size_t info_size, char *main_exe_name, size_t main_exe_size )
|
||||
BOOL init_user_process_pmts( size_t info_size )
|
||||
{
|
||||
startup_info_t info;
|
||||
void *data;
|
||||
|
@ -436,11 +436,6 @@ BOOL init_user_process_pmts( size_t info_size, char *main_exe_name, size_t main_
|
|||
info_size -= info.desktop_len;
|
||||
if (info.title_len > info_size) info.title_len = info_size;
|
||||
|
||||
/* store the filename */
|
||||
len = min( info.filename_len, main_exe_size-1 );
|
||||
memcpy( main_exe_name, src, len );
|
||||
main_exe_name[len] = 0;
|
||||
|
||||
rupp = NtCurrentTeb()->Peb->ProcessParameters;
|
||||
|
||||
init_unicode( &rupp->ImagePathName, &src, info.filename_len );
|
||||
|
|
|
@ -68,12 +68,9 @@ static const WCHAR dllW[] = {'.','d','l','l',0};
|
|||
/* internal representation of 32bit modules. per process. */
|
||||
struct _wine_modref
|
||||
{
|
||||
void *dlhandle; /* handle returned by dlopen() */
|
||||
LDR_MODULE ldr;
|
||||
int nDeps;
|
||||
struct _wine_modref **deps;
|
||||
char *filename;
|
||||
char data[1]; /* space for storing filename and modname */
|
||||
};
|
||||
|
||||
static UINT tls_module_count; /* number of modules with TLS directory */
|
||||
|
@ -459,12 +456,8 @@ static WINE_MODREF *alloc_module( HMODULE hModule, LPCWSTR filename )
|
|||
if (!(wm = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*wm) + len )))
|
||||
return NULL;
|
||||
|
||||
wm->dlhandle = NULL;
|
||||
wm->nDeps = 0;
|
||||
wm->deps = NULL;
|
||||
wm->filename = (char *)(wm + 1);
|
||||
RtlUnicodeToMultiByteN( wm->filename, len, NULL,
|
||||
filename, (strlenW(filename) + 1) * sizeof(WCHAR) );
|
||||
|
||||
wm->ldr.BaseAddress = hModule;
|
||||
wm->ldr.EntryPoint = (nt->OptionalHeader.AddressOfEntryPoint) ?
|
||||
|
@ -523,26 +516,6 @@ static WINE_MODREF *alloc_module( HMODULE hModule, LPCWSTR filename )
|
|||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* MODULE_AllocModRef
|
||||
*
|
||||
* Allocate a WINE_MODREF structure and add it to the process list
|
||||
* The loader_section must be locked while calling this function.
|
||||
*
|
||||
* FIXME: should be removed.
|
||||
*/
|
||||
WINE_MODREF *MODULE_AllocModRef( HMODULE hModule, LPCSTR filename )
|
||||
{
|
||||
WINE_MODREF *wm;
|
||||
UNICODE_STRING strW;
|
||||
|
||||
RtlCreateUnicodeStringFromAsciiz( &strW, filename );
|
||||
wm = alloc_module( hModule, strW.Buffer );
|
||||
RtlFreeUnicodeString( &strW );
|
||||
return wm;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* alloc_process_tls
|
||||
*
|
||||
|
@ -739,12 +712,13 @@ NTSTATUS MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
|
|||
|
||||
if (!wm)
|
||||
{
|
||||
PLIST_ENTRY mark;
|
||||
|
||||
mark = &NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList;
|
||||
wm = CONTAINING_RECORD(CONTAINING_RECORD(mark->Flink,
|
||||
LDR_MODULE, InLoadOrderModuleList),
|
||||
WINE_MODREF, ldr);
|
||||
/* allocate the modref for the main exe */
|
||||
if (!(wm = alloc_module( NtCurrentTeb()->Peb->ImageBaseAddress,
|
||||
NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer )))
|
||||
{
|
||||
status = STATUS_NO_MEMORY;
|
||||
goto done;
|
||||
}
|
||||
wm->ldr.LoadCount = -1; /* can't unload main exe */
|
||||
if ((status = fixup_imports( wm )) != STATUS_SUCCESS) goto done;
|
||||
if ((status = alloc_process_tls()) != STATUS_SUCCESS) goto done;
|
||||
|
@ -1124,8 +1098,8 @@ static void load_builtin_callback( void *module, const char *filename )
|
|||
req->size = nt->OptionalHeader.SizeOfImage;
|
||||
req->dbg_offset = nt->FileHeader.PointerToSymbolTable;
|
||||
req->dbg_size = nt->FileHeader.NumberOfSymbols;
|
||||
req->name = &wm->filename;
|
||||
wine_server_add_data( req, wm->filename, strlen(wm->filename) );
|
||||
req->name = &wm->ldr.FullDllName.Buffer;
|
||||
wine_server_add_data( req, wm->ldr.FullDllName.Buffer, wm->ldr.FullDllName.Length );
|
||||
wine_server_call( req );
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
|
@ -1251,10 +1225,10 @@ static NTSTATUS load_native_dll( LPCWSTR name, DWORD flags, WINE_MODREF** pwm )
|
|||
req->size = nt->OptionalHeader.SizeOfImage;
|
||||
req->dbg_offset = nt->FileHeader.PointerToSymbolTable;
|
||||
req->dbg_size = nt->FileHeader.NumberOfSymbols;
|
||||
req->name = &wm->filename;
|
||||
req->name = &wm->ldr.FullDllName.Buffer;
|
||||
/* don't keep the file handle open on removable media */
|
||||
if (drive_type == DRIVE_REMOVABLE || drive_type == DRIVE_CDROM) req->handle = 0;
|
||||
wine_server_add_data( req, wm->filename, strlen(wm->filename) );
|
||||
wine_server_add_data( req, wm->ldr.FullDllName.Buffer, wm->ldr.FullDllName.Length );
|
||||
wine_server_call( req );
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
|
@ -1381,7 +1355,7 @@ static NTSTATUS load_builtin_dll( LPCWSTR path, DWORD flags, WINE_MODREF** pwm )
|
|||
/* wine_dll_unload( handle );*/
|
||||
return STATUS_INVALID_IMAGE_FORMAT;
|
||||
}
|
||||
wm->dlhandle = handle;
|
||||
wm->ldr.SectionHandle = handle;
|
||||
*pwm = wm;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -1714,7 +1688,7 @@ static void MODULE_FlushModrefs(void)
|
|||
if (!TRACE_ON(module))
|
||||
TRACE_(loaddll)("Unloaded module %s : %s\n",
|
||||
debugstr_w(mod->FullDllName.Buffer),
|
||||
wm->dlhandle ? "builtin" : "native" );
|
||||
(wm->ldr.Flags & LDR_WINE_INTERNAL) ? "builtin" : "native" );
|
||||
|
||||
SERVER_START_REQ( unload_dll )
|
||||
{
|
||||
|
@ -1723,7 +1697,7 @@ static void MODULE_FlushModrefs(void)
|
|||
}
|
||||
SERVER_END_REQ;
|
||||
|
||||
if (wm->dlhandle) wine_dll_unload( wm->dlhandle );
|
||||
if (wm->ldr.Flags & LDR_WINE_INTERNAL) wine_dll_unload( wm->ldr.SectionHandle );
|
||||
else NtUnmapViewOfSection( GetCurrentProcess(), mod->BaseAddress );
|
||||
if (cached_modref == wm) cached_modref = NULL;
|
||||
RtlFreeUnicodeString( &mod->FullDllName );
|
||||
|
|
|
@ -511,8 +511,8 @@ NTSTATUS WINAPI NtQuerySystemInformation(
|
|||
SYSTEM_PROCESS_INFORMATION* spi = (SYSTEM_PROCESS_INFORMATION*)SystemInformation;
|
||||
SYSTEM_PROCESS_INFORMATION* last = NULL;
|
||||
HANDLE hSnap = 0;
|
||||
char procname[1024];
|
||||
DWORD wlen;
|
||||
WCHAR procname[1024];
|
||||
DWORD wlen = 0;
|
||||
|
||||
SERVER_START_REQ( create_snapshot )
|
||||
{
|
||||
|
@ -529,10 +529,10 @@ NTSTATUS WINAPI NtQuerySystemInformation(
|
|||
{
|
||||
req->handle = hSnap;
|
||||
req->reset = (len == 0);
|
||||
wine_server_set_reply( req, procname, sizeof(procname)-1 );
|
||||
wine_server_set_reply( req, procname, sizeof(procname) );
|
||||
if (!(ret = wine_server_call( req )))
|
||||
{
|
||||
procname[wine_server_reply_size(reply)] = 0;
|
||||
wlen = wine_server_reply_size(reply) + sizeof(WCHAR);
|
||||
if (Length >= len + sizeof(*spi))
|
||||
{
|
||||
memset(spi, 0, sizeof(*spi));
|
||||
|
@ -568,7 +568,6 @@ NTSTATUS WINAPI NtQuerySystemInformation(
|
|||
if (ret == STATUS_NO_MORE_FILES) ret = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
RtlMultiByteToUnicodeN(NULL, 0, &wlen, procname, strlen(procname) + 1);
|
||||
if (Length >= len + wlen + spi->dwThreadCount * sizeof(THREAD_INFO))
|
||||
{
|
||||
int i, j;
|
||||
|
@ -605,7 +604,8 @@ NTSTATUS WINAPI NtQuerySystemInformation(
|
|||
|
||||
/* now append process name */
|
||||
spi->pszProcessName = (WCHAR*)((char*)spi + spi->dwOffset);
|
||||
RtlMultiByteToUnicodeN( spi->pszProcessName, wlen, NULL, procname, strlen(procname) + 1);
|
||||
memcpy( spi->pszProcessName, procname, wlen - sizeof(WCHAR) );
|
||||
spi->pszProcessName[wlen / sizeof(WCHAR)] = 0;
|
||||
len += wlen;
|
||||
spi->dwOffset += wlen;
|
||||
|
||||
|
|
|
@ -94,7 +94,6 @@ BOOL WINAPI EnumProcesses(DWORD *lpidProcess, DWORD cb, DWORD *lpcbNeeded)
|
|||
{
|
||||
req->handle = hSnapshot;
|
||||
req->reset = (count == 0);
|
||||
wine_server_set_reply( req, NULL, 0);
|
||||
if ((ret = !wine_server_call_err( req )))
|
||||
pid = reply->pid;
|
||||
}
|
||||
|
@ -174,7 +173,6 @@ BOOL WINAPI EnumProcessModules(HANDLE hProcess, HMODULE *lphModule,
|
|||
{
|
||||
req->handle = hSnapshot;
|
||||
req->reset = (count == 0);
|
||||
wine_server_set_reply( req, NULL, 0 );
|
||||
if ((ret = !wine_server_call_err( req )))
|
||||
{
|
||||
hModule = (HMODULE)reply->base;
|
||||
|
@ -342,7 +340,7 @@ DWORD WINAPI GetModuleBaseNameW(HANDLE hProcess, HMODULE hModule,
|
|||
DWORD WINAPI GetModuleFileNameExA(HANDLE hProcess, HMODULE hModule,
|
||||
LPSTR lpFileName, DWORD nSize)
|
||||
{
|
||||
DWORD len = 0;
|
||||
WCHAR *ptr;
|
||||
|
||||
TRACE("(hProcess=%p, hModule=%p, %p, %ld)\n",
|
||||
hProcess, hModule, lpFileName, nSize);
|
||||
|
@ -352,24 +350,20 @@ DWORD WINAPI GetModuleFileNameExA(HANDLE hProcess, HMODULE hModule,
|
|||
if ( hProcess == GetCurrentProcess() )
|
||||
return GetModuleFileNameA( hModule, lpFileName, nSize );
|
||||
|
||||
lpFileName[0] = 0;
|
||||
if (!(ptr = HeapAlloc(GetProcessHeap(), 0, nSize * sizeof(WCHAR)))) return 0;
|
||||
|
||||
SERVER_START_REQ( get_dll_info )
|
||||
if (!GetModuleFileNameExW(hProcess, hModule, ptr, nSize))
|
||||
{
|
||||
req->handle = hProcess;
|
||||
req->base_address = (void*)hModule;
|
||||
wine_server_set_reply( req, lpFileName, nSize - 1);
|
||||
if (!wine_server_call_err( req ))
|
||||
{
|
||||
len = wine_server_reply_size(reply);
|
||||
lpFileName[len] = 0;
|
||||
}
|
||||
lpFileName[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!WideCharToMultiByte( CP_ACP, 0, ptr, -1, lpFileName, nSize, NULL, NULL ))
|
||||
lpFileName[nSize - 1] = 0;
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
|
||||
TRACE("return %s (%lu)\n", lpFileName, len);
|
||||
|
||||
return len;
|
||||
HeapFree(GetProcessHeap(), 0, ptr);
|
||||
return strlen(lpFileName);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -378,10 +372,9 @@ DWORD WINAPI GetModuleFileNameExA(HANDLE hProcess, HMODULE hModule,
|
|||
DWORD WINAPI GetModuleFileNameExW(HANDLE hProcess, HMODULE hModule,
|
||||
LPWSTR lpFileName, DWORD nSize)
|
||||
{
|
||||
char* ptr;
|
||||
DWORD len;
|
||||
DWORD len = 0;
|
||||
|
||||
TRACE("(hProcess=%p,hModule=%p, %p, %ld)\n",
|
||||
TRACE("(hProcess=%p, hModule=%p, %p, %ld)\n",
|
||||
hProcess, hModule, lpFileName, nSize);
|
||||
|
||||
if (!lpFileName || !nSize) return 0;
|
||||
|
@ -389,21 +382,23 @@ DWORD WINAPI GetModuleFileNameExW(HANDLE hProcess, HMODULE hModule,
|
|||
if ( hProcess == GetCurrentProcess() )
|
||||
return GetModuleFileNameW( hModule, lpFileName, nSize );
|
||||
|
||||
ptr = HeapAlloc(GetProcessHeap(), 0, nSize / 2);
|
||||
if (!ptr) return 0;
|
||||
lpFileName[0] = 0;
|
||||
|
||||
len = GetModuleFileNameExA(hProcess, hModule, ptr, nSize / 2);
|
||||
if (len == 0)
|
||||
SERVER_START_REQ( get_dll_info )
|
||||
{
|
||||
lpFileName[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!MultiByteToWideChar( CP_ACP, 0, ptr, -1, lpFileName, nSize / 2 ))
|
||||
lpFileName[nSize / 2 - 1] = 0;
|
||||
req->handle = hProcess;
|
||||
req->base_address = hModule;
|
||||
wine_server_set_reply( req, lpFileName, (nSize - 1) * sizeof(WCHAR) );
|
||||
if (!wine_server_call_err( req ))
|
||||
{
|
||||
len = wine_server_reply_size(reply) / sizeof(WCHAR);
|
||||
lpFileName[len] = 0;
|
||||
}
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
|
||||
TRACE("return %s (%lu)\n", debugstr_w(lpFileName), len);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, ptr);
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
|
@ -296,7 +296,7 @@ struct init_process_done_request
|
|||
void* name;
|
||||
obj_handle_t exe_file;
|
||||
int gui;
|
||||
/* VARARG(filename,string); */
|
||||
/* VARARG(filename,unicode_str); */
|
||||
};
|
||||
struct init_process_done_reply
|
||||
{
|
||||
|
@ -440,7 +440,7 @@ struct get_dll_info_reply
|
|||
struct reply_header __header;
|
||||
size_t size;
|
||||
void* entry_point;
|
||||
/* VARARG(filename,string); */
|
||||
/* VARARG(filename,unicode_str); */
|
||||
};
|
||||
|
||||
|
||||
|
@ -480,7 +480,7 @@ struct load_dll_request
|
|||
int dbg_offset;
|
||||
int dbg_size;
|
||||
void* name;
|
||||
/* VARARG(filename,string); */
|
||||
/* VARARG(filename,unicode_str); */
|
||||
};
|
||||
struct load_dll_reply
|
||||
{
|
||||
|
@ -1593,7 +1593,7 @@ struct next_process_reply
|
|||
int threads;
|
||||
int priority;
|
||||
int handles;
|
||||
/* VARARG(filename,string); */
|
||||
/* VARARG(filename,unicode_str); */
|
||||
};
|
||||
|
||||
|
||||
|
@ -1628,7 +1628,7 @@ struct next_module_reply
|
|||
process_id_t pid;
|
||||
void* base;
|
||||
size_t size;
|
||||
/* VARARG(filename,string); */
|
||||
/* VARARG(filename,unicode_str); */
|
||||
};
|
||||
|
||||
|
||||
|
@ -3665,6 +3665,6 @@ union generic_reply
|
|||
struct open_token_reply open_token_reply;
|
||||
};
|
||||
|
||||
#define SERVER_PROTOCOL_VERSION 121
|
||||
#define SERVER_PROTOCOL_VERSION 122
|
||||
|
||||
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
|
||||
|
|
|
@ -539,7 +539,7 @@ extern DBG_THREAD* DEBUG_AddThread(DBG_PROCESS* p, DWORD tid, HANDLE h, LPVOID s
|
|||
extern DBG_THREAD* DEBUG_GetThread(DBG_PROCESS* p, DWORD tid);
|
||||
extern void DEBUG_DelThread(DBG_THREAD* t);
|
||||
extern BOOL DEBUG_ProcessGetString(char* buffer, int size, HANDLE hp, LPSTR addr);
|
||||
extern BOOL DEBUG_ProcessGetStringIndirect(char* buffer, int size, HANDLE hp, LPVOID addr);
|
||||
extern BOOL DEBUG_ProcessGetStringIndirect(char* buffer, int size, HANDLE hp, LPVOID addr, BOOL unicode);
|
||||
extern void DEBUG_WaitNextException(DWORD cont, int count, int mode);
|
||||
extern BOOL DEBUG_InterruptDebuggee(void);
|
||||
extern int curr_frame;
|
||||
|
|
|
@ -593,7 +593,8 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
|
|||
case CREATE_PROCESS_DEBUG_EVENT:
|
||||
DEBUG_ProcessGetStringIndirect(buffer, sizeof(buffer),
|
||||
de->u.CreateProcessInfo.hProcess,
|
||||
de->u.CreateProcessInfo.lpImageName);
|
||||
de->u.CreateProcessInfo.lpImageName,
|
||||
de->u.CreateProcessInfo.fUnicode);
|
||||
|
||||
/* FIXME unicode ? de->u.CreateProcessInfo.fUnicode */
|
||||
if (gdbctx->trace & GDBPXY_TRC_WIN32_EVENT)
|
||||
|
@ -648,7 +649,8 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
|
|||
assert(DEBUG_CurrThread);
|
||||
DEBUG_ProcessGetStringIndirect(buffer, sizeof(buffer),
|
||||
gdbctx->process->handle,
|
||||
de->u.LoadDll.lpImageName);
|
||||
de->u.LoadDll.lpImageName,
|
||||
de->u.LoadDll.fUnicode);
|
||||
|
||||
/* FIXME unicode: de->u.LoadDll.fUnicode */
|
||||
if (gdbctx->trace & GDBPXY_TRC_WIN32_EVENT)
|
||||
|
|
|
@ -252,17 +252,23 @@ BOOL DEBUG_ProcessGetString(char* buffer, int size, HANDLE hp, LPSTR addr)
|
|||
return (addr && ReadProcessMemory(hp, addr, buffer, size, &sz));
|
||||
}
|
||||
|
||||
BOOL DEBUG_ProcessGetStringIndirect(char* buffer, int size, HANDLE hp, LPVOID addr)
|
||||
BOOL DEBUG_ProcessGetStringIndirect(char* buffer, int size, HANDLE hp, LPVOID addr, BOOL unicode)
|
||||
{
|
||||
LPVOID ad;
|
||||
DWORD sz;
|
||||
|
||||
if ( addr
|
||||
&& ReadProcessMemory(hp, addr, &ad, sizeof(ad), &sz)
|
||||
&& sz == sizeof(ad)
|
||||
&& ad
|
||||
&& ReadProcessMemory(hp, ad, buffer, size, &sz))
|
||||
if (addr && ReadProcessMemory(hp, addr, &ad, sizeof(ad), &sz) && sz == sizeof(ad) && ad)
|
||||
{
|
||||
if (!unicode) ReadProcessMemory(hp, ad, buffer, size, &sz);
|
||||
else
|
||||
{
|
||||
WCHAR *buffW = DBG_alloc( size * sizeof(WCHAR) );
|
||||
ReadProcessMemory(hp, ad, buffW, size*sizeof(WCHAR), &sz);
|
||||
WideCharToMultiByte( CP_ACP, 0, buffW, sz/sizeof(WCHAR), buffer, size, NULL, NULL );
|
||||
DBG_free(buffW);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
*(WCHAR*)buffer = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -742,9 +748,9 @@ static BOOL DEBUG_HandleDebugEvent(DEBUG_EVENT* de)
|
|||
case CREATE_PROCESS_DEBUG_EVENT:
|
||||
DEBUG_ProcessGetStringIndirect(buffer, sizeof(buffer),
|
||||
de->u.CreateProcessInfo.hProcess,
|
||||
de->u.CreateProcessInfo.lpImageName);
|
||||
de->u.CreateProcessInfo.lpImageName,
|
||||
de->u.CreateProcessInfo.fUnicode);
|
||||
|
||||
/* FIXME unicode ? de->u.CreateProcessInfo.fUnicode */
|
||||
DEBUG_Printf(DBG_CHN_TRACE, "%08lx:%08lx: create process '%s'/%p @%08lx (%ld<%ld>)\n",
|
||||
de->dwProcessId, de->dwThreadId,
|
||||
buffer, de->u.CreateProcessInfo.lpImageName,
|
||||
|
@ -834,9 +840,9 @@ static BOOL DEBUG_HandleDebugEvent(DEBUG_EVENT* de)
|
|||
}
|
||||
DEBUG_ProcessGetStringIndirect(buffer, sizeof(buffer),
|
||||
DEBUG_CurrThread->process->handle,
|
||||
de->u.LoadDll.lpImageName);
|
||||
de->u.LoadDll.lpImageName,
|
||||
de->u.LoadDll.fUnicode);
|
||||
|
||||
/* FIXME unicode: de->u.LoadDll.fUnicode */
|
||||
DEBUG_Printf(DBG_CHN_TRACE, "%08lx:%08lx: loads DLL %s @%08lx (%ld<%ld>)\n",
|
||||
de->dwProcessId, de->dwThreadId,
|
||||
buffer, (unsigned long)de->u.LoadDll.lpBaseOfDll,
|
||||
|
|
|
@ -152,7 +152,7 @@ static int fill_create_process_event( struct debug_event *event, void *arg )
|
|||
event->data.info.create_process.dbg_offset = process->exe.dbg_offset;
|
||||
event->data.info.create_process.dbg_size = process->exe.dbg_size;
|
||||
event->data.info.create_process.name = process->exe.name;
|
||||
event->data.info.create_process.unicode = 0;
|
||||
event->data.info.create_process.unicode = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ static int fill_load_dll_event( struct debug_event *event, void *arg )
|
|||
event->data.info.load_dll.dbg_offset = dll->dbg_offset;
|
||||
event->data.info.load_dll.dbg_size = dll->dbg_size;
|
||||
event->data.info.load_dll.name = dll->name;
|
||||
event->data.info.load_dll.unicode = 0;
|
||||
event->data.info.load_dll.unicode = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -493,7 +493,7 @@ struct process *get_process_from_handle( obj_handle_t handle, unsigned int acces
|
|||
|
||||
/* add a dll to a process list */
|
||||
static struct process_dll *process_load_dll( struct process *process, struct file *file,
|
||||
void *base, const char *filename, size_t name_len )
|
||||
void *base, const WCHAR *filename, size_t name_len )
|
||||
{
|
||||
struct process_dll *dll;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ struct process_dll
|
|||
int dbg_offset; /* debug info offset */
|
||||
int dbg_size; /* debug info size */
|
||||
size_t namelen; /* length of dll file name */
|
||||
char *filename; /* dll file name */
|
||||
WCHAR *filename; /* dll file name */
|
||||
};
|
||||
|
||||
struct process
|
||||
|
@ -94,7 +94,7 @@ struct module_snapshot
|
|||
void *base; /* module base addr */
|
||||
size_t size; /* module size */
|
||||
size_t namelen; /* length of file name */
|
||||
char *filename; /* module file name */
|
||||
WCHAR *filename; /* module file name */
|
||||
};
|
||||
|
||||
/* process functions */
|
||||
|
|
|
@ -279,7 +279,7 @@ typedef struct
|
|||
void* name; /* ptr to ptr to name (in process addr space) */
|
||||
obj_handle_t exe_file; /* file handle for main exe */
|
||||
int gui; /* is it a GUI process? */
|
||||
VARARG(filename,string); /* file name of main exe */
|
||||
VARARG(filename,unicode_str); /* file name of main exe */
|
||||
@REPLY
|
||||
int debugged; /* being debugged? */
|
||||
@END
|
||||
|
@ -378,7 +378,7 @@ typedef struct
|
|||
@REPLY
|
||||
size_t size; /* module size */
|
||||
void* entry_point;
|
||||
VARARG(filename,string); /* file name of module */
|
||||
VARARG(filename,unicode_str); /* file name of module */
|
||||
@END
|
||||
|
||||
|
||||
|
@ -406,7 +406,7 @@ typedef struct
|
|||
int dbg_offset; /* debug info offset */
|
||||
int dbg_size; /* debug info size */
|
||||
void* name; /* ptr to ptr to name (in process addr space) */
|
||||
VARARG(filename,string); /* file name of dll */
|
||||
VARARG(filename,unicode_str); /* file name of dll */
|
||||
@END
|
||||
|
||||
|
||||
|
@ -1176,7 +1176,7 @@ enum char_info_mode
|
|||
int threads; /* number of threads */
|
||||
int priority; /* process priority */
|
||||
int handles; /* number of handles */
|
||||
VARARG(filename,string); /* file name of main exe */
|
||||
VARARG(filename,unicode_str); /* file name of main exe */
|
||||
@END
|
||||
|
||||
|
||||
|
@ -1201,7 +1201,7 @@ enum char_info_mode
|
|||
process_id_t pid; /* process id */
|
||||
void* base; /* module base address */
|
||||
size_t size; /* module size */
|
||||
VARARG(filename,string); /* file name of module */
|
||||
VARARG(filename,unicode_str); /* file name of module */
|
||||
@END
|
||||
|
||||
|
||||
|
|
|
@ -456,7 +456,7 @@ static void dump_init_process_done_request( const struct init_process_done_reque
|
|||
fprintf( stderr, " exe_file=%p,", req->exe_file );
|
||||
fprintf( stderr, " gui=%d,", req->gui );
|
||||
fprintf( stderr, " filename=" );
|
||||
dump_varargs_string( cur_size );
|
||||
dump_varargs_unicode_str( cur_size );
|
||||
}
|
||||
|
||||
static void dump_init_process_done_reply( const struct init_process_done_reply *req )
|
||||
|
@ -565,7 +565,7 @@ static void dump_get_dll_info_reply( const struct get_dll_info_reply *req )
|
|||
fprintf( stderr, " size=%d,", req->size );
|
||||
fprintf( stderr, " entry_point=%p,", req->entry_point );
|
||||
fprintf( stderr, " filename=" );
|
||||
dump_varargs_string( cur_size );
|
||||
dump_varargs_unicode_str( cur_size );
|
||||
}
|
||||
|
||||
static void dump_suspend_thread_request( const struct suspend_thread_request *req )
|
||||
|
@ -597,7 +597,7 @@ static void dump_load_dll_request( const struct load_dll_request *req )
|
|||
fprintf( stderr, " dbg_size=%d,", req->dbg_size );
|
||||
fprintf( stderr, " name=%p,", req->name );
|
||||
fprintf( stderr, " filename=" );
|
||||
dump_varargs_string( cur_size );
|
||||
dump_varargs_unicode_str( cur_size );
|
||||
}
|
||||
|
||||
static void dump_unload_dll_request( const struct unload_dll_request *req )
|
||||
|
@ -1374,7 +1374,7 @@ static void dump_next_process_reply( const struct next_process_reply *req )
|
|||
fprintf( stderr, " priority=%d,", req->priority );
|
||||
fprintf( stderr, " handles=%d,", req->handles );
|
||||
fprintf( stderr, " filename=" );
|
||||
dump_varargs_string( cur_size );
|
||||
dump_varargs_unicode_str( cur_size );
|
||||
}
|
||||
|
||||
static void dump_next_thread_request( const struct next_thread_request *req )
|
||||
|
@ -1404,7 +1404,7 @@ static void dump_next_module_reply( const struct next_module_reply *req )
|
|||
fprintf( stderr, " base=%p,", req->base );
|
||||
fprintf( stderr, " size=%d,", req->size );
|
||||
fprintf( stderr, " filename=" );
|
||||
dump_varargs_string( cur_size );
|
||||
dump_varargs_unicode_str( cur_size );
|
||||
}
|
||||
|
||||
static void dump_wait_debug_event_request( const struct wait_debug_event_request *req )
|
||||
|
|
Loading…
Reference in New Issue