DBG: correctly handle executables with entry points inside the MZ header
closes #1994
This commit is contained in:
parent
f1fbfd98b3
commit
cc15cdec9f
|
@ -42,6 +42,7 @@ static PROCESS_INFORMATION g_pi = {0, 0, 0, 0};
|
||||||
static char szBaseFileName[MAX_PATH] = "";
|
static char szBaseFileName[MAX_PATH] = "";
|
||||||
static TraceState traceState;
|
static TraceState traceState;
|
||||||
static bool bFileIsDll = false;
|
static bool bFileIsDll = false;
|
||||||
|
static bool bEntryIsInMzHeader = false;
|
||||||
static duint pDebuggedBase = 0;
|
static duint pDebuggedBase = 0;
|
||||||
static duint pCreateProcessBase = 0;
|
static duint pCreateProcessBase = 0;
|
||||||
static duint pDebuggedEntry = 0;
|
static duint pDebuggedEntry = 0;
|
||||||
|
@ -1382,7 +1383,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo)
|
||||||
dprintf(QT_TRANSLATE_NOOP("DBG", "%d invalid TLS callback addresses...\n"), invalidCount);
|
dprintf(QT_TRANSLATE_NOOP("DBG", "%d invalid TLS callback addresses...\n"), invalidCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(settingboolget("Events", "EntryBreakpoint"))
|
if(settingboolget("Events", "EntryBreakpoint") && !bEntryIsInMzHeader)
|
||||||
{
|
{
|
||||||
sprintf_s(command, "bp %p,\"%s\",ss", pDebuggedBase + pDebuggedEntry, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "entry breakpoint")));
|
sprintf_s(command, "bp %p,\"%s\",ss", pDebuggedBase + pDebuggedEntry, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "entry breakpoint")));
|
||||||
cmddirectexec(command);
|
cmddirectexec(command);
|
||||||
|
@ -1597,7 +1598,13 @@ static void cbSystemBreakpoint(void* ExceptionData) // TODO: System breakpoint e
|
||||||
plugincbcall(CB_SYSTEMBREAKPOINT, &callbackInfo);
|
plugincbcall(CB_SYSTEMBREAKPOINT, &callbackInfo);
|
||||||
|
|
||||||
lock(WAITID_RUN); // Allow the user to run a script file now
|
lock(WAITID_RUN); // Allow the user to run a script file now
|
||||||
if(bIsAttached ? settingboolget("Events", "AttachBreakpoint") : settingboolget("Events", "SystemBreakpoint"))
|
bool systemBreakpoint = settingboolget("Events", "SystemBreakpoint");
|
||||||
|
if(!systemBreakpoint && bEntryIsInMzHeader)
|
||||||
|
{
|
||||||
|
dputs(QT_TRANSLATE_NOOP("DBG", "It has been detected that the debuggee entry point is in the MZ header of the executable. This will cause strange behavior, so the system breakpoint has been enabled regardless of your setting. Be careful!"));
|
||||||
|
systemBreakpoint = true;
|
||||||
|
}
|
||||||
|
if(bIsAttached ? settingboolget("Events", "AttachBreakpoint") : systemBreakpoint)
|
||||||
{
|
{
|
||||||
//lock
|
//lock
|
||||||
GuiSetDebugStateAsync(paused);
|
GuiSetDebugStateAsync(paused);
|
||||||
|
@ -2548,10 +2555,12 @@ static void debugLoopFunction(void* lpParameter, bool attach)
|
||||||
{
|
{
|
||||||
init = (INIT_STRUCT*)lpParameter;
|
init = (INIT_STRUCT*)lpParameter;
|
||||||
gInitExe = StringUtils::Utf8ToUtf16(init->exe);
|
gInitExe = StringUtils::Utf8ToUtf16(init->exe);
|
||||||
pDebuggedEntry = GetPE32DataW(gInitExe.c_str(), 0, UE_OEP);
|
|
||||||
strcpy_s(szFileName, init->exe);
|
strcpy_s(szFileName, init->exe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pDebuggedEntry = GetPE32DataW(gInitExe.c_str(), 0, UE_OEP);
|
||||||
|
bEntryIsInMzHeader = pDebuggedEntry == 0 || pDebuggedEntry == 1;
|
||||||
|
|
||||||
bFileIsDll = IsFileDLLW(StringUtils::Utf8ToUtf16(szFileName).c_str(), 0);
|
bFileIsDll = IsFileDLLW(StringUtils::Utf8ToUtf16(szFileName).c_str(), 0);
|
||||||
DbSetPath(nullptr, szFileName);
|
DbSetPath(nullptr, szFileName);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue