PROJECT: better method of calling functions inside the DBG + show error message on assembling
This commit is contained in:
parent
0b64b56395
commit
a7c5ca87bd
|
@ -709,6 +709,11 @@ BRIDGE_IMPEXP bool DbgGetStringAt(duint addr, char* text)
|
|||
return false;
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP const DBGFUNCTIONS* DbgFunctions()
|
||||
{
|
||||
return (const DBGFUNCTIONS*)_dbg_sendmessage(DBG_GET_FUNCTIONS, 0, 0);
|
||||
}
|
||||
|
||||
//GUI
|
||||
BRIDGE_IMPEXP void GuiDisasmAt(duint addr, duint cip)
|
||||
{
|
||||
|
|
|
@ -156,7 +156,8 @@ enum DBGMSG
|
|||
DBG_DELETE_AUTO_BOOKMARK_RANGE, // param1=duint start, param2=duint end
|
||||
DBG_SET_AUTO_FUNCTION_AT, // param1=duint addr, param2=const char* text
|
||||
DBG_DELETE_AUTO_FUNCTION_RANGE, // param1=duint start, param2=duint end
|
||||
DBG_GET_STRING_AT // param1=duint addr, param2=unused
|
||||
DBG_GET_STRING_AT, // param1=duint addr, param2=unused
|
||||
DBG_GET_FUNCTIONS // param1=unused, param2=unused
|
||||
};
|
||||
|
||||
enum SCRIPTLINETYPE
|
||||
|
@ -265,6 +266,7 @@ enum MEMORY_SIZE
|
|||
//Debugger typedefs
|
||||
typedef MEMORY_SIZE VALUE_SIZE;
|
||||
struct SYMBOLINFO;
|
||||
struct DBGFUNCTIONS;
|
||||
|
||||
typedef void (*CBSYMBOLENUM)(SYMBOLINFO* symbol, void* user);
|
||||
|
||||
|
@ -552,6 +554,7 @@ BRIDGE_IMPEXP void DbgClearAutoBookmarkRange(duint start, duint end);
|
|||
BRIDGE_IMPEXP bool DbgSetAutoFunctionAt(duint start, duint end);
|
||||
BRIDGE_IMPEXP void DbgClearAutoFunctionRange(duint start, duint end);
|
||||
BRIDGE_IMPEXP bool DbgGetStringAt(duint addr, char* text);
|
||||
BRIDGE_IMPEXP const DBGFUNCTIONS* DbgFunctions();
|
||||
|
||||
//Gui defines
|
||||
#define GUI_PLUGIN_MENU 0
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#include "_global.h"
|
||||
#include "_dbgfunctions.h"
|
||||
#include "assemble.h"
|
||||
|
||||
static DBGFUNCTIONS _dbgfunctions;
|
||||
|
||||
const DBGFUNCTIONS* dbgfunctionsget()
|
||||
{
|
||||
return &_dbgfunctions;
|
||||
}
|
||||
|
||||
void dbgfunctionsinit()
|
||||
{
|
||||
_dbgfunctions.DbgAssembleAtEx=assembleat;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef _DBGFUNCTIONS_H
|
||||
#define _DBGFUNCTIONS_H
|
||||
|
||||
typedef bool (*DBGASSEMBLEATEX)(duint addr, const char* instruction, char* error, bool fillnop);
|
||||
|
||||
struct DBGFUNCTIONS
|
||||
{
|
||||
DBGASSEMBLEATEX DbgAssembleAtEx;
|
||||
};
|
||||
|
||||
#ifdef BUILD_DBG
|
||||
|
||||
const DBGFUNCTIONS* dbgfunctionsget();
|
||||
void dbgfunctionsinit();
|
||||
|
||||
#endif //BUILD_DBG
|
||||
|
||||
#endif //_DBGFUNCTIONS_H
|
|
@ -14,6 +14,7 @@
|
|||
#include "thread.h"
|
||||
#include "disasm_fast.h"
|
||||
#include "plugin_loader.h"
|
||||
#include "_dbgfunctions.h"
|
||||
|
||||
extern "C" DLL_EXPORT duint _dbg_memfindbaseaddr(duint addr, duint* size)
|
||||
{
|
||||
|
@ -767,7 +768,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
|
|||
|
||||
case DBG_ASSEMBLE_AT:
|
||||
{
|
||||
return assembleat((duint)param1, (const char*)param2, 0);
|
||||
return assembleat((duint)param1, (const char*)param2, 0, false);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1014,6 +1015,12 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
|
|||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case DBG_GET_FUNCTIONS:
|
||||
{
|
||||
return (uint)dbgfunctionsget();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ static bool cbUnknown(const char* text, ULONGLONG* value)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool assembleat(uint addr, const char* instruction, char* error)
|
||||
bool assembleat(uint addr, const char* instruction, char* error, bool fillnop)
|
||||
{
|
||||
if(strlen(instruction)>=XEDPARSE_MAXBUFSIZE)
|
||||
return false;
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
|
||||
#include "_global.h"
|
||||
|
||||
bool assembleat(uint addr, const char* instruction, char* error);
|
||||
bool assembleat(uint addr, const char* instruction, char* error, bool fillnop);
|
||||
|
||||
#endif // _ASSEMBLE_H
|
||||
|
|
|
@ -369,8 +369,11 @@ CMDRESULT cbAssemble(int argc, char* argv[])
|
|||
dprintf("invalid address: "fhex"!\n", addr);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
bool fillnop=false;
|
||||
if(argc>3)
|
||||
fillnop=true;
|
||||
char error[256]="";
|
||||
if(!assembleat(addr, argv[2], error))
|
||||
if(!assembleat(addr, argv[2], error, fillnop))
|
||||
{
|
||||
dprintf("failed to assemble \"%s\" (%s)\n", argv[2], error);
|
||||
return STATUS_ERROR;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "threading.h"
|
||||
#include "plugin_loader.h"
|
||||
#include "assemble.h"
|
||||
#include "_dbgfunctions.h"
|
||||
|
||||
static MESSAGE_STACK* gMsgStack=0;
|
||||
static COMMAND* command_list=0;
|
||||
|
@ -222,6 +223,7 @@ static void efree_json(void* ptr)
|
|||
|
||||
extern "C" DLL_EXPORT const char* _dbg_dbginit()
|
||||
{
|
||||
dbgfunctionsinit();
|
||||
json_set_alloc_funcs(emalloc_json, efree_json);
|
||||
char dir[deflen]="";
|
||||
if(!GetModuleFileNameA(hInst, dir, deflen))
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
<ClCompile Include="variable.cpp" />
|
||||
<ClCompile Include="x64_dbg.cpp" />
|
||||
<ClCompile Include="_exports.cpp" />
|
||||
<ClCompile Include="_dbgfunctions.cpp" />
|
||||
<ClCompile Include="_global.cpp" />
|
||||
<ClCompile Include="_plugins.cpp" />
|
||||
</ItemGroup>
|
||||
|
@ -81,6 +82,7 @@
|
|||
<ClInclude Include="x64_dbg.h" />
|
||||
<ClInclude Include="XEDParse\XEDParse.h" />
|
||||
<ClInclude Include="_exports.h" />
|
||||
<ClInclude Include="_dbgfunctions.h" />
|
||||
<ClInclude Include="_global.h" />
|
||||
<ClInclude Include="_plugins.h" />
|
||||
<ClInclude Include="_plugin_types.h" />
|
||||
|
|
|
@ -120,6 +120,9 @@
|
|||
<ClCompile Include="murmurhash.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="_dbgfunctions.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="_exports.h">
|
||||
|
@ -251,5 +254,8 @@
|
|||
<ClInclude Include="lz4\lz4hc.h">
|
||||
<Filter>Header Files\lz4</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="_dbgfunctions.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -654,9 +654,10 @@ void CPUDisassembly::assembleAt()
|
|||
if(mLineEdit.exec()!=QDialog::Accepted)
|
||||
return;
|
||||
|
||||
if(!DbgAssembleAt(wVA, mLineEdit.editText.toUtf8().constData()))
|
||||
char error[256]="";
|
||||
if(!DbgFunctions()->DbgAssembleAtEx(wVA, mLineEdit.editText.toUtf8().constData(), error, true))
|
||||
{
|
||||
QMessageBox msg(QMessageBox::Critical, "Error!", "Failed to assemble instruction \"" + mLineEdit.editText + QString("\""));
|
||||
QMessageBox msg(QMessageBox::Critical, "Error!", "Failed to assemble instruction \"" + mLineEdit.editText + "\" (" + error + ")");
|
||||
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
|
||||
msg.setParent(this, Qt::Dialog);
|
||||
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
#define IMPORTS_H
|
||||
|
||||
#include "..\..\..\x64_dbg_bridge\bridgemain.h"
|
||||
#include "..\..\..\x64_dbg_dbg\_dbgfunctions.h"
|
||||
|
||||
#endif // IMPORTS_H
|
||||
|
|
Loading…
Reference in New Issue