From 291fa66f9d22ebc4d6f31068d275b60d3d5e8a99 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 8 Jun 2000 05:02:19 +0000 Subject: [PATCH] Removed the .xcnlnk section hack, and replaced it by another hack in the debugger CREATE_PROCESS event handling. --- debugger/msc.c | 19 ++----------------- debugger/winedbg.c | 28 ++++++++++++++++++++++++++-- relay32/builtin32.c | 28 +--------------------------- 3 files changed, 29 insertions(+), 46 deletions(-) diff --git a/debugger/msc.c b/debugger/msc.c index 45dd2af99da..152d4895b15 100644 --- a/debugger/msc.c +++ b/debugger/msc.c @@ -1715,8 +1715,8 @@ int DEBUG_RegisterStabsDebugInfo(DBG_MODULE* module, HANDLE hFile, void* _nth, { IMAGE_SECTION_HEADER pe_seg; unsigned long pe_seg_ofs; - int i, stabsize = 0, stabstrsize = 0, xcnlnksize = 0; - unsigned int stabs = 0, stabstr = 0, xcnlnk = 0; + int i, stabsize = 0, stabstrsize = 0; + unsigned int stabs = 0, stabstr = 0; PIMAGE_NT_HEADERS nth = (PIMAGE_NT_HEADERS)_nth; pe_seg_ofs = nth_ofs + OFFSET_OF(IMAGE_NT_HEADERS, OptionalHeader) + @@ -1733,9 +1733,6 @@ int DEBUG_RegisterStabsDebugInfo(DBG_MODULE* module, HANDLE hFile, void* _nth, } else if (!strncasecmp(pe_seg.Name, ".stabstr", 8)) { stabstr = pe_seg.VirtualAddress; stabstrsize = pe_seg.SizeOfRawData; - } else if (!strncasecmp(pe_seg.Name, ".xcnlnk", 7)) { - xcnlnk = pe_seg.VirtualAddress; - xcnlnksize = pe_seg.SizeOfRawData; } } @@ -1756,18 +1753,6 @@ int DEBUG_RegisterStabsDebugInfo(DBG_MODULE* module, HANDLE hFile, void* _nth, stabsize + stabstrsize); } } - if (xcnlnksize) { - DWORD addr; - char bufstr[256]; - - if (DEBUG_READ_MEM_VERBOSE((char*)module->load_addr + xcnlnk, &addr, - sizeof(addr)) && - DEBUG_READ_MEM_VERBOSE((char*)addr, bufstr, sizeof(bufstr))) { - bufstr[sizeof(bufstr) - 1] = 0; - DEBUG_Printf(DBG_CHN_TRACE, "Got xcnlnk: argv0 '%s'\n", bufstr); - DEBUG_ReadExecutableDbgInfo(bufstr); - } - } return TRUE; } diff --git a/debugger/winedbg.c b/debugger/winedbg.c index 10db639508b..e459456e191 100644 --- a/debugger/winedbg.c +++ b/debugger/winedbg.c @@ -12,6 +12,7 @@ #include "thread.h" #include "process.h" +#include "file.h" #include "wincon.h" #include "wingdi.h" #include "winuser.h" @@ -479,9 +480,32 @@ static BOOL DEBUG_HandleDebugEvent(DEBUG_EVENT* de, LPDWORD cont) DEBUG_InitCurrProcess(); DEBUG_InitCurrThread(); - /* so far, process name is not set */ - DEBUG_LoadModule32("", de->u.CreateProcessInfo.hFile, + + DEBUG_ProcessGetStringIndirect(buffer, sizeof(buffer), + DEBUG_CurrThread->process->handle, + de->u.CreateProcessInfo.lpImageName); + DEBUG_LoadModule32(buffer[0] ? buffer : "", + de->u.CreateProcessInfo.hFile, (DWORD)de->u.CreateProcessInfo.lpBaseOfImage); + + if (buffer[0]) /* we got a process name */ + { + DWORD type; + if (!GetBinaryTypeA( buffer, &type )) + { + /* not a Windows binary, assume it's a Unix executable then */ + DOS_FULL_NAME fullname; + /* HACK!! should fix DEBUG_ReadExecutableDbgInfo to accept DOS filenames */ + if (DOSFS_GetFullName( buffer, TRUE, &fullname )) + { + DEBUG_ReadExecutableDbgInfo( fullname.long_name ); + break; + } + } + } + /* if it is a Windows binary, or an invalid or missing file name, + * we use wine itself as the main executable */ + DEBUG_ReadExecutableDbgInfo( "wine" ); break; case EXIT_THREAD_DEBUG_EVENT: diff --git a/relay32/builtin32.c b/relay32/builtin32.c index 042bdbacf96..e91c52de95d 100644 --- a/relay32/builtin32.c +++ b/relay32/builtin32.c @@ -33,7 +33,6 @@ #include "winerror.h" #include "server.h" #include "debugtools.h" -#include "options.h" /* for argv0 */ DEFAULT_DEBUG_CHANNEL(module); DECLARE_DEBUG_CHANNEL(relay); @@ -146,23 +145,16 @@ static HMODULE BUILTIN32_DoLoadImage( const BUILTIN32_DESCRIPTOR *descr ) IMAGE_EXPORT_DIRECTORY *exports = descr->exports; INT i, size, nb_sections; BYTE *addr, *code_start, *data_start; - BYTE* xcnlnk; - DWORD xcnsize = 0; int page_size = VIRTUAL_GetPageSize(); /* Allocate the module */ nb_sections = 2; /* code + data */ - if (!strcmp(descr->filename, "kernel32.dll")) { - nb_sections++; - xcnsize = sizeof(DWORD); - } size = (sizeof(IMAGE_DOS_HEADER) + sizeof(IMAGE_NT_HEADERS) + nb_sections * sizeof(IMAGE_SECTION_HEADER) - + (descr->nb_imports+1) * sizeof(IMAGE_IMPORT_DESCRIPTOR) - + xcnsize); + + (descr->nb_imports+1) * sizeof(IMAGE_IMPORT_DESCRIPTOR)); assert( size <= page_size ); @@ -184,7 +176,6 @@ static HMODULE BUILTIN32_DoLoadImage( const BUILTIN32_DESCRIPTOR *descr ) nt = (IMAGE_NT_HEADERS *)(dos + 1); sec = (IMAGE_SECTION_HEADER *)(nt + 1); imp = (IMAGE_IMPORT_DESCRIPTOR *)(sec + nb_sections); - xcnlnk = (char *)(imp + descr->nb_imports + 1); code_start = addr + page_size; /* HACK! */ @@ -258,23 +249,6 @@ static HMODULE BUILTIN32_DoLoadImage( const BUILTIN32_DESCRIPTOR *descr ) } } - /* Build Wine's .so link section. Those sections are used by the wine debugger to - * link a builtin PE header with the corresponding ELF module (from either a - * shared library, or the main executable - wine emulator or any winelib program - */ - if (xcnsize) - { - strcpy( sec->Name, ".xcnlnk" ); - sec->Misc.VirtualSize = xcnsize; - sec->VirtualAddress = (BYTE *)xcnlnk - addr; - sec->SizeOfRawData = sec->Misc.VirtualSize; - sec->PointerToRawData = (BYTE *)xcnlnk - addr; - sec->Characteristics = (IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ); - sec++; - - *(const char**)xcnlnk = argv0; - } - /* Build the resource directory */ if (descr->rsrc) -- 2.11.4.GIT