mirror of
https://github.com/reactos/reactos.git
synced 2025-01-04 05:20:54 +00:00
[WINESYNC] dbghelp: Determine the wine loader name from the target process's architecture.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> wine commit id a981edf0bc7c828e6b55fdc73b51a2f457043c4a by Zebediah Figura <zfigura@codeweavers.com>
This commit is contained in:
parent
3346544802
commit
f69be6c561
8 changed files with 112 additions and 88 deletions
|
@ -394,3 +394,9 @@ const char *wine_dbgstr_wn( const WCHAR *str, int n )
|
|||
*dst++ = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
BOOL __IsWow64Process(HANDLE Process, BOOL* is_wow64)
|
||||
{
|
||||
*is_wow64 = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -422,6 +422,8 @@ typedef struct _EXCEPTION_REGISTRATION_RECORD
|
|||
#define GetCurrentDirectoryW(x, y) 0
|
||||
#define GetFileSizeEx __GetFileSizeEx
|
||||
#define ReadProcessMemory(a,b,c,d,e) 0
|
||||
#define GetCurrentProcess() (HANDLE)1
|
||||
#define IsWow64Process __IsWow64Process
|
||||
|
||||
void* __HeapAlloc(int heap, int flags, size_t size);
|
||||
void* __HeapReAlloc(int heap, DWORD d2, void *slab, SIZE_T newsize);
|
||||
|
@ -432,6 +434,7 @@ void* __MapViewOfFile(HANDLE file,DWORD d1,DWORD d2,DWORD d3,SIZE_T s);
|
|||
BOOL __UnmapViewOfFile(const void*);
|
||||
LPSTR __lstrcpynA(LPSTR,LPCSTR,int);
|
||||
BOOL __GetFileSizeEx(HANDLE,PLARGE_INTEGER);
|
||||
BOOL WINAPI __IsWow64Process(HANDLE,BOOL*);
|
||||
#define OPEN_EXISTING 3
|
||||
#define FILE_MAP_READ SECTION_MAP_READ
|
||||
typedef struct _LDT_ENTRY {
|
||||
|
|
|
@ -309,6 +309,7 @@ static BOOL check_live_target(struct process* pcs)
|
|||
BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeProcess)
|
||||
{
|
||||
struct process* pcs;
|
||||
BOOL wow64, child_wow64;
|
||||
|
||||
TRACE("(%p %s %u)\n", hProcess, debugstr_w(UserSearchPath), fInvadeProcess);
|
||||
|
||||
|
@ -326,6 +327,12 @@ BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeP
|
|||
|
||||
pcs->handle = hProcess;
|
||||
|
||||
IsWow64Process(GetCurrentProcess(), &wow64);
|
||||
|
||||
if (!IsWow64Process(hProcess, &child_wow64))
|
||||
return FALSE;
|
||||
pcs->is_64bit = (sizeof(void *) == 8 || wow64) && !child_wow64;
|
||||
|
||||
if (UserSearchPath)
|
||||
{
|
||||
pcs->search_path = lstrcpyW(HeapAlloc(GetProcessHeap(), 0,
|
||||
|
|
|
@ -433,6 +433,8 @@ struct process
|
|||
|
||||
unsigned buffer_size;
|
||||
void* buffer;
|
||||
|
||||
BOOL is_64bit;
|
||||
};
|
||||
|
||||
struct line_info
|
||||
|
@ -639,7 +641,9 @@ extern void module_reset_debug_info(struct module* module) DECLSPEC_HIDD
|
|||
extern BOOL module_remove(struct process* pcs,
|
||||
struct module* module) DECLSPEC_HIDDEN;
|
||||
extern void module_set_module(struct module* module, const WCHAR* name) DECLSPEC_HIDDEN;
|
||||
extern const WCHAR *get_wine_loader_name(void) DECLSPEC_HIDDEN;
|
||||
#ifndef __REACTOS__
|
||||
extern WCHAR * get_wine_loader_name(struct process *pcs) DECLSPEC_HIDDEN;
|
||||
#endif
|
||||
|
||||
/* msc.c */
|
||||
extern BOOL pe_load_debug_directory(const struct process* pcs,
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
|
||||
#include "wine/library.h"
|
||||
#include "wine/debug.h"
|
||||
#include "wine/heap.h"
|
||||
|
||||
#ifdef __ELF__
|
||||
|
||||
|
@ -1568,13 +1569,17 @@ static BOOL elf_enum_modules_internal(const struct process* pcs,
|
|||
*/
|
||||
static BOOL elf_search_loader(struct process* pcs, struct elf_info* elf_info)
|
||||
{
|
||||
WCHAR *loader = get_wine_loader_name(pcs);
|
||||
PROCESS_BASIC_INFORMATION pbi;
|
||||
ULONG_PTR base = 0;
|
||||
BOOL ret;
|
||||
|
||||
if (!NtQueryInformationProcess( pcs->handle, ProcessBasicInformation, &pbi, sizeof(pbi), NULL ))
|
||||
ReadProcessMemory( pcs->handle, &pbi.PebBaseAddress->Reserved[0], &base, sizeof(base), NULL );
|
||||
|
||||
return elf_search_and_load_file(pcs, get_wine_loader_name(), base, 0, elf_info);
|
||||
ret = elf_search_and_load_file(pcs, loader, base, 0, elf_info);
|
||||
heap_free(loader);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
|
|
|
@ -1703,6 +1703,7 @@ BOOL macho_synchronize_module_list(struct process* pcs)
|
|||
*/
|
||||
static BOOL macho_search_loader(struct process* pcs, struct macho_info* macho_info)
|
||||
{
|
||||
WCHAR *loader = get_wine_loader_name(pcs);
|
||||
BOOL ret = FALSE;
|
||||
ULONG_PTR dyld_image_info_address;
|
||||
struct dyld_all_image_infos image_infos;
|
||||
|
@ -1757,7 +1758,8 @@ static BOOL macho_search_loader(struct process* pcs, struct macho_info* macho_in
|
|||
}
|
||||
|
||||
if (!ret)
|
||||
ret = macho_search_and_load_file(pcs, get_wine_loader_name(), 0, macho_info);
|
||||
ret = macho_search_and_load_file(pcs, loader, 0, macho_info);
|
||||
heap_free(loader);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -149,44 +149,41 @@ void module_set_module(struct module* module, const WCHAR* name)
|
|||
module_fill_module(name, module->modulename, sizeof(module->modulename) / sizeof(module->modulename[0]));
|
||||
}
|
||||
|
||||
const WCHAR *get_wine_loader_name(void)
|
||||
#ifndef __REACTOS__
|
||||
/* Returned string must be freed by caller */
|
||||
WCHAR *get_wine_loader_name(struct process *pcs)
|
||||
{
|
||||
static const BOOL is_win64 = sizeof(void *) > sizeof(int); /* FIXME: should depend on target process */
|
||||
static const WCHAR wineW[] = {'w','i','n','e',0};
|
||||
static const WCHAR suffixW[] = {'6','4',0};
|
||||
static const WCHAR *loader;
|
||||
WCHAR *buffer, *p;
|
||||
const char *env;
|
||||
|
||||
if (!loader)
|
||||
/* All binaries are loaded with WINELOADER (if run from tree) or by the
|
||||
* main executable
|
||||
*/
|
||||
if ((env = getenv("WINELOADER")))
|
||||
{
|
||||
WCHAR *p, *buffer;
|
||||
const char *ptr;
|
||||
|
||||
/* All binaries are loaded with WINELOADER (if run from tree) or by the
|
||||
* main executable
|
||||
*/
|
||||
if ((ptr = getenv("WINELOADER")))
|
||||
{
|
||||
DWORD len = 2 + MultiByteToWideChar( CP_UNIXCP, 0, ptr, -1, NULL, 0 );
|
||||
buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
||||
MultiByteToWideChar( CP_UNIXCP, 0, ptr, -1, buffer, len );
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = HeapAlloc( GetProcessHeap(), 0, sizeof(wineW) + 2 * sizeof(WCHAR) );
|
||||
strcpyW( buffer, wineW );
|
||||
}
|
||||
p = buffer + strlenW( buffer ) - strlenW( suffixW );
|
||||
if (p > buffer && !strcmpW( p, suffixW ))
|
||||
{
|
||||
if (!is_win64) *p = 0;
|
||||
}
|
||||
else if (is_win64) strcatW( buffer, suffixW );
|
||||
|
||||
TRACE( "returning %s\n", debugstr_w(buffer) );
|
||||
loader = buffer;
|
||||
DWORD len = 2 + MultiByteToWideChar( CP_UNIXCP, 0, env, -1, NULL, 0 );
|
||||
buffer = heap_alloc( len * sizeof(WCHAR) );
|
||||
MultiByteToWideChar( CP_UNIXCP, 0, env, -1, buffer, len );
|
||||
}
|
||||
return loader;
|
||||
else
|
||||
{
|
||||
buffer = heap_alloc( sizeof(wineW) + 2 * sizeof(WCHAR) );
|
||||
strcpyW( buffer, wineW );
|
||||
}
|
||||
|
||||
p = buffer + strlenW( buffer ) - strlenW( suffixW );
|
||||
if (p > buffer && !strcmpW( p, suffixW ))
|
||||
*p = 0;
|
||||
|
||||
if (pcs->is_64bit)
|
||||
strcatW(buffer, suffixW);
|
||||
|
||||
TRACE( "returning %s\n", debugstr_w(buffer) );
|
||||
return buffer;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char* get_module_type(enum module_type type, BOOL virtual)
|
||||
{
|
||||
|
|
|
@ -3,4 +3,4 @@ directories:
|
|||
files:
|
||||
include/dbghelp.h: sdk/include/psdk/dbghelp.h
|
||||
tags:
|
||||
wine: 9b973eee9e06a3dca7a6c5739741446bf46e27f5
|
||||
wine: a981edf0bc7c828e6b55fdc73b51a2f457043c4a
|
||||
|
|
Loading…
Reference in a new issue