1
0
Fork 0

Support x64dbg:command#xxx and x64dbg:address#xxx links

This commit is contained in:
Duncan Ogilvie 2022-09-02 13:45:40 +02:00
parent 9f32b844f4
commit 0db522082e
9 changed files with 38 additions and 15 deletions

View File

@ -43,7 +43,7 @@ PLUG_IMPEXP void _plugin_logprintf(const char* format, ...)
PLUG_IMPEXP void _plugin_lograw_html(const char* text)
{
dputs_untranslated_html(text);
dprint_untranslated_html(text);
}
PLUG_IMPEXP void _plugin_logputs(const char* text)

View File

@ -336,4 +336,5 @@ bool cbGotoTrace(int argc, char* argv[])
GuiGotoTrace(index);
GuiShowTrace();
return true;
}

View File

@ -40,19 +40,14 @@ bool cbScriptCmd(int argc, char* argv[])
return scriptcmdexec(scriptcmd);
}
bool cbInstrLog(int argc, char* argv[])
static bool cbGenericLog(int argc, char* argv[], void(*logputs)(const char* msg))
{
auto logputs = [](const char* msg)
{
dputs_untranslated(msg);
scriptlog(msg);
};
if(argc == 1) //just log newline
if(argc == 1) //just log newline
{
logputs("");
return true;
}
if(argc == 2) //inline logging: log "format {rax}"
if(argc == 2) //inline logging: log "format {rax}"
{
logputs(stringformatinline(argv[1]).c_str());
}
@ -66,6 +61,24 @@ bool cbInstrLog(int argc, char* argv[])
return true;
}
bool cbInstrLog(int argc, char* argv[])
{
return cbGenericLog(argc, argv, [](const char* msg)
{
dputs_untranslated(msg);
scriptlog(msg);
});
}
bool cbInstrHtmlLog(int argc, char* argv[])
{
return cbGenericLog(argc, argv, [](const char* msg)
{
dprint_untranslated_html(msg);
dprint_untranslated_html("\n");
});
}
bool cbInstrPrintStack(int argc, char* argv[])
{
duint csp = GetContextDataEx(hActiveThread, UE_CSP);
@ -87,4 +100,4 @@ bool cbInstrPrintStack(int argc, char* argv[])
dprintf_untranslated("%p %s\n", i.addr, i.comment);
}
return true;
}
}

View File

@ -7,4 +7,5 @@ bool cbScriptMsg(int argc, char* argv[]);
bool cbScriptMsgyn(int argc, char* argv[]);
bool cbScriptCmd(int argc, char* argv[]);
bool cbInstrLog(int argc, char* argv[]);
bool cbInstrHtmlLog(int argc, char* argv[]);
bool cbInstrPrintStack(int argc, char* argv[]);

View File

@ -115,7 +115,7 @@ void dprintf_args_untranslated(_In_z_ _Printf_format_string_ const char* Format,
\brief Print a html string to the console.
\param Text The message to use.
*/
void dputs_untranslated_html(_In_z_ _Printf_format_string_ const char* Text)
void dprint_untranslated_html(_In_z_ _Printf_format_string_ const char* Text)
{
GuiAddLogMessageHtmlAsync(Text);
}

View File

@ -9,6 +9,6 @@ void dprintf_args(_In_z_ _Printf_format_string_ const char* Format, va_list Args
void dputs_untranslated(_In_z_ const char* Text);
void dprintf_untranslated(_In_z_ _Printf_format_string_ const char* Format, ...);
void dprintf_args_untranslated(_In_z_ _Printf_format_string_ const char* Format, va_list Args);
void dputs_untranslated_html(_In_z_ _Printf_format_string_ const char* Text);
void dprint_untranslated_html(_In_z_ _Printf_format_string_ const char* Text);
#endif // _CONSOLE_H

View File

@ -616,7 +616,7 @@ namespace Exprfunc
assert(argv[0].type == ValueTypeString);
assert(argv[1].type == ValueTypeString);
*result = ValueNumber(::stricmp(argv[0].string.ptr, argv[1].string.ptr) == 0);
*result = ValueNumber(::_stricmp(argv[0].string.ptr, argv[1].string.ptr) == 0);
return true;
}

View File

@ -382,6 +382,7 @@ static void registercommands()
dbgcmdnew("msg", cbScriptMsg, false);
dbgcmdnew("msgyn", cbScriptMsgyn, false);
dbgcmdnew("log", cbInstrLog, false); //log command with superawesome hax
dbgcmdnew("htmllog", cbInstrHtmlLog, false); //command for testing
dbgcmdnew("scriptdll,dllscript", cbScriptDll, false); //execute a script DLL
dbgcmdnew("scriptcmd", cbScriptCmd, false); // execute a script command TODO: undocumented

View File

@ -331,12 +331,15 @@ void LogView::onAnchorClicked(const QUrl & link)
{
if(link.scheme() == "x64dbg")
{
if(link.path() == "/address32" || link.path() == "/address64")
// x64dbg:path#fragment
auto path = link.path();
auto fragment = link.fragment(QUrl::FullyDecoded);
if(path == "address" || path == "/address32" || path == "/address64")
{
if(DbgIsDebugging())
{
bool ok = false;
auto address = duint(link.fragment(QUrl::DecodeReserved).toULongLong(&ok, 16));
auto address = duint(fragment.toULongLong(&ok, 16));
if(ok && DbgMemIsValidReadPtr(address))
{
if(DbgFunctions()->MemIsCodePage(address, true))
@ -351,6 +354,10 @@ void LogView::onAnchorClicked(const QUrl & link)
SimpleErrorBox(this, tr("Invalid address!"), tr("The address %1 is not a valid memory location...").arg(ToPtrString(address)));
}
}
else if(path == "command")
{
DbgCmdExec(fragment.toUtf8().constData());
}
else
SimpleErrorBox(this, tr("Url is not valid!"), tr("The Url %1 is not supported").arg(link.toString()));
}