I recetly wanted to run winedbg with --gdb option to remote debug with radare2, but when I use the --gdb option, winegdb exit with no error :
Code: Select all
$ winedbg --gdb test.exe
0088:0089: create process ''/0x1131c0 @0x4012d0 (33792<558>)
0088:0089: create thread I @0x4012d0
$
Code: Select all
static BOOL CALLBACK mod_loader_cb(PCSTR mod_name, DWORD64 base, PVOID ctx)
{
struct mod_loader_info* mli = ctx;
if (!strcmp(mod_name, "<wine-loader>"))
{
if (SymGetModuleInfo64(mli->handle, base, mli->imh_mod))
return FALSE; /* stop enum */
}
return TRUE;
}
BOOL dbg_get_debuggee_info(HANDLE hProcess, IMAGEHLP_MODULE64* imh_mod)
{
struct mod_loader_info mli;
BOOL opt;
/* this will resynchronize builtin dbghelp's internal ELF module list */
SymLoadModule(hProcess, 0, 0, 0, 0, 0);
mli.handle = hProcess;
mli.imh_mod = imh_mod;
imh_mod->SizeOfStruct = sizeof(*imh_mod);
imh_mod->BaseOfImage = 0;
/* this is a wine specific options to return also ELF modules in the
* enumeration
*/
opt = SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE);
SymEnumerateModules64(hProcess, mod_loader_cb, &mli);
SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt);
return imh_mod->BaseOfImage != 0;
}
Code: Select all
kernelbase
kernel32
ntdll
test
I went deeper in the code and found that the purpose of this function is to get the full path of the program being debugged to give it to gdb.
In my case the the full path is something like /full/path/test.exe and the module name associated is "test", so the code above must be searching for "test" and not "<wine-loader>".
To verify my assumptions I replaced it directly in the code, and it worked. Then I tried to find why winedbg is searching for "<wine-loader>", but there is no occurrence of this string in the code and there is no module named "<wine-loader>", there is nowhere in the code where the name of the currently debugged module is overwrite with "<wine-loader>" , so it cannot work !
If someone can help me understand from where the "<wine-loader>" module comes from, then I could fix this bug.