DBG : Added option to save/load command line arguments into the database.
GUI : Symbols tab, when searching a module and getting no result, function widget gets cleared.
This commit is contained in:
parent
84d1feeb33
commit
bd4d4c5370
|
|
@ -66,6 +66,7 @@ BRIDGE_IMPEXP int BridgeGetDbgVersion();
|
|||
#define MAX_ERROR_SIZE 512
|
||||
#define RIGHTS_STRING_SIZE (sizeof("ERWCG") + 1)
|
||||
#define MAX_SECTION_SIZE 10
|
||||
#define MAX_COMMAND_LINE_SIZE 256
|
||||
|
||||
#define TYPE_VALUE 1
|
||||
#define TYPE_MEMORY 2
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include "bookmark.h"
|
||||
#include "function.h"
|
||||
#include "loop.h"
|
||||
#include "commandline.h"
|
||||
|
||||
/**
|
||||
\brief Directory where program databases are stored (usually in \db). UTF-8 encoding.
|
||||
|
|
@ -24,26 +25,44 @@ char dbbasepath[deflen];
|
|||
*/
|
||||
char dbpath[deflen];
|
||||
|
||||
void DBSave()
|
||||
enum LOAD_SAVE_DB_TYPE
|
||||
{
|
||||
COMMAND_LINE_ONLY,
|
||||
ALL_BUT_COMMAND_LINE,
|
||||
ALL
|
||||
};
|
||||
|
||||
void DBSave(LOAD_SAVE_DB_TYPE saveType)
|
||||
{
|
||||
dprintf("Saving database...");
|
||||
DWORD ticks = GetTickCount();
|
||||
JSON root = json_object();
|
||||
CommentCacheSave(root);
|
||||
LabelCacheSave(root);
|
||||
BookmarkCacheSave(root);
|
||||
FunctionCacheSave(root);
|
||||
LoopCacheSave(root);
|
||||
BpCacheSave(root);
|
||||
//save notes
|
||||
char* text = nullptr;
|
||||
GuiGetDebuggeeNotes(&text);
|
||||
if (text)
|
||||
|
||||
// Save only command line
|
||||
if (saveType == COMMAND_LINE_ONLY || saveType == ALL)
|
||||
{
|
||||
json_object_set_new(root, "notes", json_string(text));
|
||||
BridgeFree(text);
|
||||
CmdLineCacheSave(root);
|
||||
}
|
||||
|
||||
if (saveType == ALL_BUT_COMMAND_LINE || saveType == ALL)
|
||||
{
|
||||
CommentCacheSave(root);
|
||||
LabelCacheSave(root);
|
||||
BookmarkCacheSave(root);
|
||||
FunctionCacheSave(root);
|
||||
LoopCacheSave(root);
|
||||
BpCacheSave(root);
|
||||
|
||||
//save notes
|
||||
char* text = nullptr;
|
||||
GuiGetDebuggeeNotes(&text);
|
||||
if (text)
|
||||
{
|
||||
json_object_set_new(root, "notes", json_string(text));
|
||||
BridgeFree(text);
|
||||
}
|
||||
GuiSetDebuggeeNotes("");
|
||||
}
|
||||
GuiSetDebuggeeNotes("");
|
||||
|
||||
WString wdbpath = StringUtils::Utf8ToUtf16(dbpath);
|
||||
if (json_object_size(root))
|
||||
|
|
@ -76,7 +95,7 @@ void DBSave()
|
|||
json_decref(root); //free root
|
||||
}
|
||||
|
||||
void DBLoad()
|
||||
void DBLoad(LOAD_SAVE_DB_TYPE loadType)
|
||||
{
|
||||
// If the file doesn't exist, there is no DB to load
|
||||
if (!FileExists(dbpath))
|
||||
|
|
@ -139,17 +158,26 @@ void DBLoad()
|
|||
return;
|
||||
}
|
||||
|
||||
// Finally load all structures
|
||||
CommentCacheLoad(root);
|
||||
LabelCacheLoad(root);
|
||||
BookmarkCacheLoad(root);
|
||||
FunctionCacheLoad(root);
|
||||
LoopCacheLoad(root);
|
||||
BpCacheLoad(root);
|
||||
// Load only command line
|
||||
if (loadType == COMMAND_LINE_ONLY || loadType == ALL)
|
||||
{
|
||||
CmdLineCacheLoad(root);
|
||||
}
|
||||
|
||||
// Load notes
|
||||
const char* text = json_string_value(json_object_get(root, "notes"));
|
||||
GuiSetDebuggeeNotes(text);
|
||||
if (loadType == ALL_BUT_COMMAND_LINE || loadType == ALL)
|
||||
{
|
||||
// Finally load all structures
|
||||
CommentCacheLoad(root);
|
||||
LabelCacheLoad(root);
|
||||
BookmarkCacheLoad(root);
|
||||
FunctionCacheLoad(root);
|
||||
LoopCacheLoad(root);
|
||||
BpCacheLoad(root);
|
||||
|
||||
// Load notes
|
||||
const char* text = json_string_value(json_object_get(root, "notes"));
|
||||
GuiSetDebuggeeNotes(text);
|
||||
}
|
||||
|
||||
// Free root
|
||||
json_decref(root);
|
||||
|
|
@ -158,7 +186,7 @@ void DBLoad()
|
|||
|
||||
void DBClose()
|
||||
{
|
||||
DBSave();
|
||||
DBSave(ALL);
|
||||
CommentClear();
|
||||
LabelClear();
|
||||
BookmarkClear();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,14 @@
|
|||
|
||||
#include "_global.h"
|
||||
|
||||
void DBSave();
|
||||
void DBLoad();
|
||||
enum LOAD_SAVE_DB_TYPE
|
||||
{
|
||||
COMMAND_LINE_ONLY,
|
||||
ALL_BUT_COMMAND_LINE,
|
||||
ALL
|
||||
};
|
||||
|
||||
void DBSave(LOAD_SAVE_DB_TYPE saveType);
|
||||
void DBLoad(LOAD_SAVE_DB_TYPE loadType);
|
||||
void DBClose();
|
||||
void DBSetPath(const char *Directory, const char *ModulePath);
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
#include "exception.h"
|
||||
#include "error.h"
|
||||
#include "module.h"
|
||||
#include "commandline.h"
|
||||
|
||||
static PROCESS_INFORMATION g_pi = {0, 0, 0, 0};
|
||||
static char szBaseFileName[MAX_PATH] = "";
|
||||
|
|
@ -632,7 +633,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo)
|
|||
|
||||
// Init program database
|
||||
DBSetPath(nullptr, szFileName);
|
||||
DBLoad();
|
||||
DBLoad(ALL_BUT_COMMAND_LINE);
|
||||
|
||||
SafeSymSetOptions(SYMOPT_DEBUG | SYMOPT_LOAD_LINES | SYMOPT_ALLOW_ABSOLUTE_SYMBOLS | SYMOPT_FAVOR_COMPRESSED | SYMOPT_IGNORE_NT_SYMPATH);
|
||||
GuiSymbolLogClear();
|
||||
|
|
@ -1120,6 +1121,21 @@ DWORD WINAPI threadDebugLoop(void* lpParameter)
|
|||
bFileIsDll = IsFileDLLW(StringUtils::Utf8ToUtf16(init->exe).c_str(), 0);
|
||||
pDebuggedEntry = GetPE32DataW(StringUtils::Utf8ToUtf16(init->exe).c_str(), 0, UE_OEP);
|
||||
strcpy_s(szFileName, init->exe);
|
||||
|
||||
// Load command line if it exists in DB
|
||||
DBSetPath(nullptr, szFileName);
|
||||
DBLoad(COMMAND_LINE_ONLY);
|
||||
|
||||
if (!isCmdLineEmpty())
|
||||
{
|
||||
char* commandLineArguments = NULL;
|
||||
commandLineArguments = getCommandLineArgs();
|
||||
|
||||
if (commandLineArguments)
|
||||
init->commandline = commandLineArguments;
|
||||
}
|
||||
|
||||
|
||||
if(bFileIsDll)
|
||||
fdProcessInfo = (PROCESS_INFORMATION*)InitDLLDebugW(StringUtils::Utf8ToUtf16(init->exe).c_str(), false, StringUtils::Utf8ToUtf16(init->commandline).c_str(), StringUtils::Utf8ToUtf16(init->currentfolder).c_str(), 0);
|
||||
else
|
||||
|
|
@ -1596,7 +1612,7 @@ static bool fixgetcommandlinesbase(duint new_command_line_unicode, duint new_com
|
|||
{
|
||||
duint getcommandline;
|
||||
|
||||
if(!valfromstring("kernelbase:GetCommandLineA", &getcommandline))
|
||||
if(!valfromstring("kernelBase:GetCommandLineA", &getcommandline))
|
||||
{
|
||||
if(!valfromstring("kernel32:GetCommandLineA", &getcommandline))
|
||||
{
|
||||
|
|
@ -1682,6 +1698,9 @@ bool dbgsetcmdline(const char* cmd_line, cmdline_error_t* cmd_line_error)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Copy command line
|
||||
copyCommandLine(cmd_line);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1723,6 +1742,7 @@ bool dbggetcmdline(char** cmd_line, cmdline_error_t* cmd_line_error)
|
|||
cmd_line_error->type = CMDL_ERR_CONVERTUNICODE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -416,14 +416,14 @@ CMDRESULT cbInstrBookmarkDel(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbInstrLoaddb(int argc, char* argv[])
|
||||
{
|
||||
DBLoad();
|
||||
DBLoad(ALL);
|
||||
GuiUpdateAllViews();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
CMDRESULT cbInstrSavedb(int argc, char* argv[])
|
||||
{
|
||||
DBSave();
|
||||
DBSave(ALL);
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ enum SectionLock
|
|||
LockPluginCommandList,
|
||||
LockPluginMenuList,
|
||||
LockLast,
|
||||
LockCmdLine
|
||||
};
|
||||
|
||||
class SectionLockerGlobal
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
<ClCompile Include="breakpoint.cpp" />
|
||||
<ClCompile Include="CodeFollowPass.cpp" />
|
||||
<ClCompile Include="command.cpp" />
|
||||
<ClCompile Include="commandline.cpp" />
|
||||
<ClCompile Include="commandparser.cpp" />
|
||||
<ClCompile Include="comment.cpp" />
|
||||
<ClCompile Include="console.cpp" />
|
||||
|
|
@ -106,6 +107,7 @@
|
|||
<ClInclude Include="capstone\xcore.h" />
|
||||
<ClInclude Include="CodeFollowPass.h" />
|
||||
<ClInclude Include="command.h" />
|
||||
<ClInclude Include="commandline.h" />
|
||||
<ClInclude Include="commandparser.h" />
|
||||
<ClInclude Include="comment.h" />
|
||||
<ClInclude Include="console.h" />
|
||||
|
|
|
|||
|
|
@ -278,6 +278,9 @@
|
|||
<ClCompile Include="jit.cpp">
|
||||
<Filter>Source Files\Debugger Core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="commandline.cpp">
|
||||
<Filter>Source Files\Information</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="x64_dbg.h">
|
||||
|
|
@ -646,5 +649,8 @@
|
|||
<ClInclude Include="yara\yara\stream.h">
|
||||
<Filter>Header Files\Third Party\yara\yara</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="commandline.h">
|
||||
<Filter>Header Files\Information</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -168,6 +168,10 @@ void SearchListView::searchTextChanged(const QString & arg1)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(rows == 0)
|
||||
emit emptySearchResult();
|
||||
|
||||
if(ui->checkBoxRegex->checkState() != Qt::Checked) //do not highlight with regex
|
||||
mSearchList->highlightText = arg1;
|
||||
mSearchList->reloadData();
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ private slots:
|
|||
signals:
|
||||
void enterPressedSignal();
|
||||
void listContextMenuSignal(QMenu* wMenu);
|
||||
void emptySearchResult();
|
||||
|
||||
private:
|
||||
Ui::SearchListView* ui;
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ SymbolView::SymbolView(QWidget* parent) : QWidget(parent), ui(new Ui::SymbolView
|
|||
connect(Bridge::getBridge(), SIGNAL(clearSymbolLog()), this, SLOT(clearSymbolLogSlot()));
|
||||
connect(mModuleList->mList, SIGNAL(selectionChangedSignal(int)), this, SLOT(moduleSelectionChanged(int)));
|
||||
connect(mModuleList->mSearchList, SIGNAL(selectionChangedSignal(int)), this, SLOT(moduleSelectionChanged(int)));
|
||||
connect(mModuleList, SIGNAL(emptySearchResult()), this, SLOT(emptySearchResultSlot()));
|
||||
connect(mModuleList, SIGNAL(listContextMenuSignal(QMenu*)), this, SLOT(moduleContextMenu(QMenu*)));
|
||||
connect(mModuleList, SIGNAL(enterPressedSignal()), this, SLOT(moduleFollow()));
|
||||
connect(Bridge::getBridge(), SIGNAL(updateSymbolList(int, SYMBOLMODULEINFO*)), this, SLOT(updateSymbolList(int, SYMBOLMODULEINFO*)));
|
||||
|
|
@ -395,3 +396,9 @@ void SymbolView::moduleEntropy()
|
|||
entropyDialog.exec();
|
||||
}
|
||||
}
|
||||
|
||||
void SymbolView::emptySearchResultSlot()
|
||||
{
|
||||
// No result after search
|
||||
mSearchListView->mCurList->setRowCount(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ private slots:
|
|||
void toggleBookmark();
|
||||
void refreshShortcutsSlot();
|
||||
void moduleEntropy();
|
||||
void emptySearchResultSlot();
|
||||
|
||||
signals:
|
||||
void showCpu();
|
||||
|
|
|
|||
Loading…
Reference in New Issue