DBG+GUI: code improvements
This commit is contained in:
parent
cc6cff939e
commit
8739e8ae52
|
@ -19,7 +19,7 @@ TraceRecordManager::~TraceRecordManager()
|
|||
void TraceRecordManager::clear()
|
||||
{
|
||||
EXCLUSIVE_ACQUIRE(LockTraceRecord);
|
||||
for(auto i = TraceRecord.begin(); i != TraceRecord.end(); i++)
|
||||
for(auto i = TraceRecord.begin(); i != TraceRecord.end(); ++i)
|
||||
efree(i->second.rawPtr, "TraceRecordManager");
|
||||
TraceRecord.clear();
|
||||
ModuleNames.clear();
|
||||
|
@ -354,7 +354,7 @@ void TraceRecordManager::loadFromDb(JSON root)
|
|||
}
|
||||
}
|
||||
|
||||
unsigned int TraceRecordManager::getModuleIndex(std::string moduleName)
|
||||
unsigned int TraceRecordManager::getModuleIndex(const String & moduleName)
|
||||
{
|
||||
auto iterator = std::find(ModuleNames.begin(), ModuleNames.end(), moduleName);
|
||||
if(iterator != ModuleNames.end())
|
||||
|
|
|
@ -78,7 +78,7 @@ private:
|
|||
//Key := page base, value := trace record raw data
|
||||
std::unordered_map<duint, TraceRecordPage> TraceRecord;
|
||||
std::vector<std::string> ModuleNames;
|
||||
unsigned int getModuleIndex(std::string moduleName);
|
||||
unsigned int getModuleIndex(const String & moduleName);
|
||||
unsigned int instructionCounter;
|
||||
};
|
||||
|
||||
|
|
|
@ -124,7 +124,6 @@ void json_free(void* ptr)
|
|||
#else
|
||||
return efree(ptr);
|
||||
#endif
|
||||
efree(ptr, "json:ptr");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -165,9 +164,7 @@ void setalloctrace(const char* file)
|
|||
*/
|
||||
bool scmp(const char* a, const char* b)
|
||||
{
|
||||
if(_stricmp(a, b))
|
||||
return false;
|
||||
return true;
|
||||
return !_stricmp(a, b);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -240,7 +237,7 @@ bool GetFileNameFromHandle(HANDLE hFile, char* szFileName)
|
|||
bool GetFileNameFromProcessHandle(HANDLE hProcess, char* szFileName)
|
||||
{
|
||||
wchar_t wszDosFileName[MAX_PATH] = L"";
|
||||
if(!GetProcessImageFileNameW(hProcess, wszDosFileName, sizeof(wszDosFileName)))
|
||||
if(!GetProcessImageFileNameW(hProcess, wszDosFileName, _countof(wszDosFileName)))
|
||||
return false;
|
||||
|
||||
wchar_t wszFileName[MAX_PATH] = L"";
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "module.h"
|
||||
|
||||
///api functions
|
||||
bool apienumexports(duint base, EXPORTENUMCALLBACK cbEnum)
|
||||
bool apienumexports(duint base, const EXPORTENUMCALLBACK & cbEnum)
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
VirtualQueryEx(fdProcessInfo->hProcess, (const void*)base, &mbi, sizeof(mbi));
|
||||
|
@ -81,7 +81,7 @@ bool apienumexports(duint base, EXPORTENUMCALLBACK cbEnum)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool apienumimports(duint base, IMPORTENUMCALLBACK cbEnum)
|
||||
bool apienumimports(duint base, const IMPORTENUMCALLBACK & cbEnum)
|
||||
{
|
||||
// Variables
|
||||
bool readSuccess;
|
||||
|
|
|
@ -59,7 +59,7 @@ struct DepthModuleRangeCompare
|
|||
typedef std::function<void (duint base, const char* mod, const char* name, duint addr)> EXPORTENUMCALLBACK;
|
||||
typedef std::function<void (duint base, duint addr, char* name, char* moduleName)> IMPORTENUMCALLBACK;
|
||||
|
||||
bool apienumexports(duint base, EXPORTENUMCALLBACK cbEnum);
|
||||
bool apienumimports(duint base, IMPORTENUMCALLBACK cbEnum);
|
||||
bool apienumexports(duint base, const EXPORTENUMCALLBACK & cbEnum);
|
||||
bool apienumimports(duint base, const IMPORTENUMCALLBACK & cbEnum);
|
||||
|
||||
#endif // _ADDRINFO_H
|
||||
|
|
|
@ -411,7 +411,7 @@ bool FunctionPass::ResolveFunctionEnd(FunctionDef* Function, BasicBlock* LastBlo
|
|||
}
|
||||
|
||||
#ifdef _WIN64
|
||||
void FunctionPass::EnumerateFunctionRuntimeEntries64(std::function<bool (PRUNTIME_FUNCTION)> Callback)
|
||||
void FunctionPass::EnumerateFunctionRuntimeEntries64(const std::function<bool(PRUNTIME_FUNCTION)> & Callback)
|
||||
{
|
||||
if(!m_FunctionInfo)
|
||||
return;
|
||||
|
|
|
@ -27,6 +27,6 @@ private:
|
|||
bool ResolveFunctionEnd(FunctionDef* Function, BasicBlock* LastBlock);
|
||||
|
||||
#ifdef _WIN64
|
||||
void EnumerateFunctionRuntimeEntries64(std::function<bool(PRUNTIME_FUNCTION)> Callback);
|
||||
void EnumerateFunctionRuntimeEntries64(const std::function<bool(PRUNTIME_FUNCTION)> & Callback);
|
||||
#endif // _WIN64
|
||||
};
|
|
@ -140,7 +140,6 @@ protected:
|
|||
byte* mEncMap;
|
||||
private:
|
||||
|
||||
duint mMaxDepth;
|
||||
bool mDump;
|
||||
void linearXrefPass();
|
||||
void findInvalidXrefs();
|
||||
|
|
|
@ -345,7 +345,7 @@ void ControlFlowAnalysis::FunctionRanges()
|
|||
}
|
||||
}
|
||||
|
||||
void ControlFlowAnalysis::insertBlock(BasicBlock block)
|
||||
void ControlFlowAnalysis::insertBlock(const BasicBlock & block)
|
||||
{
|
||||
if(mBlocks.find(block.start) != mBlocks.end())
|
||||
DebugBreak();
|
||||
|
@ -435,7 +435,7 @@ duint ControlFlowAnalysis::getReferenceOperand() const
|
|||
}
|
||||
|
||||
#ifdef _WIN64
|
||||
void ControlFlowAnalysis::enumerateFunctionRuntimeEntries64(std::function<bool(PRUNTIME_FUNCTION)> Callback) const
|
||||
void ControlFlowAnalysis::enumerateFunctionRuntimeEntries64(const std::function<bool(PRUNTIME_FUNCTION)> & Callback) const
|
||||
{
|
||||
if(!mFunctionInfoData)
|
||||
return;
|
||||
|
|
|
@ -60,7 +60,7 @@ private:
|
|||
void BasicBlocks();
|
||||
void Functions();
|
||||
void FunctionRanges();
|
||||
void insertBlock(BasicBlock block);
|
||||
void insertBlock(const BasicBlock & block);
|
||||
const BasicBlock* findBlock(duint start) const;
|
||||
void insertParent(duint child, duint parent);
|
||||
const UintSet* findParents(duint child) const;
|
||||
|
@ -69,7 +69,7 @@ private:
|
|||
duint getReferenceOperand() const;
|
||||
|
||||
#ifdef _WIN64
|
||||
void enumerateFunctionRuntimeEntries64(std::function<bool(PRUNTIME_FUNCTION)> Callback) const;
|
||||
void enumerateFunctionRuntimeEntries64(const std::function<bool(PRUNTIME_FUNCTION)> & Callback) const;
|
||||
#endif // _WIN64
|
||||
};
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ void ExceptionDirectoryAnalysis::SetMarkers()
|
|||
}
|
||||
|
||||
#ifdef _WIN64
|
||||
void ExceptionDirectoryAnalysis::EnumerateFunctionRuntimeEntries64(std::function<bool(PRUNTIME_FUNCTION)> Callback) const
|
||||
void ExceptionDirectoryAnalysis::EnumerateFunctionRuntimeEntries64(const std::function<bool(PRUNTIME_FUNCTION)> & Callback) const
|
||||
{
|
||||
if(!mFunctionInfoData)
|
||||
return;
|
||||
|
|
|
@ -19,7 +19,7 @@ private:
|
|||
std::vector<std::pair<duint, duint>> mFunctions;
|
||||
|
||||
#ifdef _WIN64
|
||||
void EnumerateFunctionRuntimeEntries64(std::function<bool(PRUNTIME_FUNCTION)> Callback) const;
|
||||
void EnumerateFunctionRuntimeEntries64(const std::function<bool(PRUNTIME_FUNCTION)> & Callback) const;
|
||||
#endif // _WIN64
|
||||
};
|
||||
|
||||
|
|
|
@ -535,7 +535,7 @@ uint32 BpGetHitCount(duint Address, BP_TYPE Type)
|
|||
BREAKPOINT* bpInfo = BpInfoFromAddr(Type, Address);
|
||||
|
||||
if(!bpInfo)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
return bpInfo->hitcount;
|
||||
}
|
||||
|
|
|
@ -224,14 +224,13 @@ CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[])
|
|||
CMDRESULT cbInstrImageinfo(int argc, char* argv[])
|
||||
{
|
||||
duint mod;
|
||||
if(argc < 2 || !valfromstring(argv[1], &mod) || !ModBaseFromAddr(mod))
|
||||
SHARED_ACQUIRE(LockModules);
|
||||
MODINFO* info;
|
||||
if(argc < 2 || !valfromstring(argv[1], &mod) || !((info = ModInfoFromAddr(mod))))
|
||||
{
|
||||
dputs(QT_TRANSLATE_NOOP("DBG", "invalid argument"));
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
SHARED_ACQUIRE(LockModules);
|
||||
auto info = ModInfoFromAddr(mod);
|
||||
auto c = GetPE32DataFromMappedFile(info->fileMapVA, 0, UE_CHARACTERISTICS);
|
||||
auto dllc = GetPE32DataFromMappedFile(info->fileMapVA, 0, UE_DLLCHARACTERISTICS);
|
||||
SHARED_RELEASE();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "variable.h"
|
||||
#include "value.h"
|
||||
|
||||
static CMDRESULT cbDebugSetBPXTextCommon(BP_TYPE Type, int argc, char* argv[], const String & description, std::function<bool(duint, BP_TYPE, const char*)> setFunction)
|
||||
static CMDRESULT cbDebugSetBPXTextCommon(BP_TYPE Type, int argc, char* argv[], const String & description, const std::function<bool(duint, BP_TYPE, const char*)> & setFunction)
|
||||
{
|
||||
BREAKPOINT bp;
|
||||
if(IsArgumentsLessThan(argc, 2))
|
||||
|
@ -21,7 +21,7 @@ static CMDRESULT cbDebugSetBPXTextCommon(BP_TYPE Type, int argc, char* argv[], c
|
|||
}
|
||||
if(!setFunction(bp.addr, Type, value))
|
||||
{
|
||||
dprintf(QT_TRANSLATE_NOOP("DBG", "Can't set %s on breakpoint \"%s\"\n"), description, argv[1]);
|
||||
dprintf(QT_TRANSLATE_NOOP("DBG", "Can't set %s on breakpoint \"%s\"\n"), description.c_str(), argv[1]);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
DebugUpdateBreakpointsViewAsync();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "_scriptapi_stack.h"
|
||||
#include "debugger.h"
|
||||
|
||||
static CMDRESULT ReadWriteVariable(const char* varname, std::function<CMDRESULT(duint*, int)> callback)
|
||||
static CMDRESULT ReadWriteVariable(const char* varname, const std::function<CMDRESULT(duint*, int)> & callback)
|
||||
{
|
||||
duint set_value = 0;
|
||||
bool isvar;
|
||||
|
@ -118,9 +118,7 @@ CMDRESULT cbInstrBswap(int argc, char* argv[])
|
|||
return STATUS_ERROR;
|
||||
return ReadWriteVariable(argv[1], [argv](duint * value, int size)
|
||||
{
|
||||
if(size == 1)
|
||||
*value = *value;
|
||||
else if(size == 2)
|
||||
if(size == 2)
|
||||
*value = _byteswap_ushort((uint16) * value);
|
||||
else if(size == 4)
|
||||
*value = _byteswap_ulong((uint32) * value);
|
||||
|
@ -128,7 +126,7 @@ CMDRESULT cbInstrBswap(int argc, char* argv[])
|
|||
else if(size == 8)
|
||||
*value = _byteswap_uint64(*value);
|
||||
#endif //_WIN64
|
||||
else
|
||||
else if(size != 1)
|
||||
{
|
||||
dputs(QT_TRANSLATE_NOOP("DBG", "Variable size not supported."));
|
||||
return STATUS_ERROR;
|
||||
|
|
|
@ -243,13 +243,14 @@ CMDRESULT cbDebugSetJIT(int argc, char* argv[])
|
|||
}
|
||||
else if(!_strcmpi(argv[1], "oldsave"))
|
||||
{
|
||||
char path[JIT_ENTRY_DEF_SIZE];
|
||||
dbggetdefjit(path);
|
||||
char get_entry[JIT_ENTRY_MAX_SIZE] = "";
|
||||
bool get_last_jit = true;
|
||||
|
||||
if(!dbggetjit(get_entry, notfound, &actual_arch, NULL))
|
||||
{
|
||||
get_last_jit = false;
|
||||
}
|
||||
else
|
||||
strcpy_s(oldjit, get_entry);
|
||||
|
||||
|
@ -355,7 +356,7 @@ CMDRESULT cbDebugGetJIT(int argc, char* argv[])
|
|||
char oldjit[MAX_SETTING_SIZE] = "";
|
||||
if(_strcmpi(argv[1], "OLD") == 0)
|
||||
{
|
||||
if(!BridgeSettingGet("JIT", "Old", (char*)& oldjit))
|
||||
if(!BridgeSettingGet("JIT", "Old", oldjit))
|
||||
{
|
||||
dputs(QT_TRANSLATE_NOOP("DBG", "Error: there is not an OLD JIT entry stored yet."));
|
||||
return STATUS_ERROR;
|
||||
|
|
|
@ -240,7 +240,7 @@ CMDRESULT cbDebugSetthreadname(int argc, char* argv[])
|
|||
dprintf(QT_TRANSLATE_NOOP("DBG", "Failed to change the name for thread %X\n"), threadid);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
if(!info.threadName)
|
||||
if(!*info.threadName)
|
||||
dprintf(QT_TRANSLATE_NOOP("DBG", "Thread name set to \"%s\"!\n"), newname);
|
||||
else
|
||||
dprintf(QT_TRANSLATE_NOOP("DBG", "Thread name changed from \"%s\" to \"%s\"!\n"), info.threadName, newname);
|
||||
|
|
|
@ -151,7 +151,7 @@ CMDRESULT cbCheckWatchdog(int argc, char* argv[])
|
|||
{
|
||||
EXCLUSIVE_ACQUIRE(LockWatch);
|
||||
bool watchdogTriggered = false;
|
||||
for(auto j = watchexpr.begin(); j != watchexpr.end(); j++)
|
||||
for(auto j = watchexpr.begin(); j != watchexpr.end(); ++j)
|
||||
{
|
||||
std::pair<unsigned int, WatchExpr*> i = *j;
|
||||
i.second->watchdogTriggered = false;
|
||||
|
|
|
@ -120,7 +120,7 @@ struct DataInstruction
|
|||
bool parsedatainstruction(const char* instruction, DataInstruction & di)
|
||||
{
|
||||
di.type = enc_unknown;
|
||||
di.operand = "";
|
||||
di.operand.clear();
|
||||
String instStr = StringUtils::Trim(String(instruction));
|
||||
size_t pos = instStr.find_first_of(" \t");
|
||||
String opcode = instStr.substr(0, pos);
|
||||
|
@ -148,7 +148,7 @@ bool tryassembledata(duint addr, unsigned char* dest, int destsize, int* size, c
|
|||
DataInstruction di;
|
||||
if(!parsedatainstruction(instruction, di))
|
||||
{
|
||||
if(di.operand == "")
|
||||
if(di.operand.empty())
|
||||
strcpy_s(error, MAX_ERROR_SIZE, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "missing operand")));
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ static void dbgClearRtuBreakpoints()
|
|||
RunToUserCodeBreakpoints.clear();
|
||||
}
|
||||
|
||||
bool dbgsettracecondition(String expression, duint maxSteps)
|
||||
bool dbgsettracecondition(const String & expression, duint maxSteps)
|
||||
{
|
||||
if(dbgtraceactive())
|
||||
return false;
|
||||
|
@ -1080,8 +1080,7 @@ void cbRtrStep()
|
|||
unsigned char data[MAX_DISASM_BUFFER];
|
||||
memset(data, 0, sizeof(data));
|
||||
MemRead(cip, data, MAX_DISASM_BUFFER);
|
||||
cp.Disassemble(cip, data);
|
||||
if(cp.GetId() == X86_INS_RET)
|
||||
if(cp.Disassemble(cip, data) && cp.GetId() == X86_INS_RET)
|
||||
cbRtrFinalStep();
|
||||
else
|
||||
StepOver((void*)cbRtrStep);
|
||||
|
@ -1509,9 +1508,9 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll)
|
|||
if(MemIsValidReadPtr(callbackVA))
|
||||
{
|
||||
if(bIsDebuggingThis)
|
||||
sprintf_s(command, "bp %p,\"%s %d\",ss", callbackVA, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "TLS Callback")), i + 1);
|
||||
sprintf_s(command, "bp %p,\"%s %u\",ss", callbackVA, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "TLS Callback")), i + 1);
|
||||
else
|
||||
sprintf_s(command, "bp %p,\"%s %d (%s)\",ss", callbackVA, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "TLS Callback")), i + 1, modname);
|
||||
sprintf_s(command, "bp %p,\"%s %u (%s)\",ss", callbackVA, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "TLS Callback")), i + 1, modname);
|
||||
cmddirectexec(command);
|
||||
}
|
||||
else
|
||||
|
@ -1685,8 +1684,7 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData)
|
|||
callbackInfo.Exception = ExceptionData;
|
||||
unsigned int ExceptionCode = ExceptionData->ExceptionRecord.ExceptionCode;
|
||||
GuiSetLastException(ExceptionCode);
|
||||
if(ExceptionData)
|
||||
lastExceptionInfo = *ExceptionData;
|
||||
lastExceptionInfo = *ExceptionData;
|
||||
|
||||
duint addr = (duint)ExceptionData->ExceptionRecord.ExceptionAddress;
|
||||
{
|
||||
|
@ -1828,14 +1826,16 @@ cmdline_qoutes_placement_t getqoutesplacement(const char* cmdline)
|
|||
cmdline_qoutes_placement_t quotesPos;
|
||||
quotesPos.firstPos = quotesPos.secondPos = 0;
|
||||
|
||||
auto len = strlen(cmdline);
|
||||
|
||||
char quoteSymb = cmdline[0];
|
||||
if(quoteSymb == '"' || quoteSymb == '\'')
|
||||
{
|
||||
for(size_t i = 1; i < strlen(cmdline); i++)
|
||||
for(size_t i = 1; i < len; i++)
|
||||
{
|
||||
if(cmdline[i] == quoteSymb)
|
||||
{
|
||||
quotesPos.posEnum = i == strlen(cmdline) - 1 ? QOUTES_AT_BEGIN_AND_END : QOUTES_AROUND_EXE;
|
||||
quotesPos.posEnum = i == len - 1 ? QOUTES_AT_BEGIN_AND_END : QOUTES_AROUND_EXE;
|
||||
quotesPos.secondPos = i;
|
||||
break;
|
||||
}
|
||||
|
@ -1847,7 +1847,7 @@ cmdline_qoutes_placement_t getqoutesplacement(const char* cmdline)
|
|||
{
|
||||
quotesPos.posEnum = NO_QOUTES;
|
||||
//try to locate first quote
|
||||
for(size_t i = 1; i < strlen(cmdline); i++)
|
||||
for(size_t i = 1; i < len; i++)
|
||||
if(cmdline[i] == '"' || cmdline[i] == '\'')
|
||||
quotesPos.secondPos = i;
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ cmdline_qoutes_placement_t getqoutesplacement(const char* cmdline);
|
|||
void dbgstartscriptthread(CBPLUGINSCRIPT cbScript);
|
||||
duint dbggetdebuggedbase();
|
||||
duint dbggetdbgevents();
|
||||
bool dbgsettracecondition(String expression, duint maxCount);
|
||||
bool dbgsettracecondition(const String & expression, duint maxCount);
|
||||
bool dbgtraceactive();
|
||||
void dbgsetdebuggeeinitscript(const char* fileName);
|
||||
const char* dbggetdebuggeeinitscript();
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
return (T)memset(m_Ptr, 0, m_Size);
|
||||
}
|
||||
|
||||
size_t size()
|
||||
size_t size() const
|
||||
{
|
||||
return m_Size;
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ void ExpressionFunctions::Init()
|
|||
RegisterEasy("ReadPtr,ReadPointer,ptr,Pointer,pointer", readptr);
|
||||
}
|
||||
|
||||
bool ExpressionFunctions::Register(const String & name, int argc, CBEXPRESSIONFUNCTION cbFunction, void* userdata)
|
||||
bool ExpressionFunctions::Register(const String & name, int argc, const CBEXPRESSIONFUNCTION & cbFunction, void* userdata)
|
||||
{
|
||||
if(!isValidName(name))
|
||||
return false;
|
||||
|
|
|
@ -8,7 +8,7 @@ public:
|
|||
using CBEXPRESSIONFUNCTION = std::function<duint(int argc, duint* argv, void* userdata)>;
|
||||
|
||||
static void Init();
|
||||
static bool Register(const String & name, int argc, CBEXPRESSIONFUNCTION cbFunction, void* userdata = nullptr);
|
||||
static bool Register(const String & name, int argc, const CBEXPRESSIONFUNCTION & cbFunction, void* userdata = nullptr);
|
||||
static bool RegisterAlias(const String & name, const String & alias);
|
||||
static bool Unregister(const String & name);
|
||||
static bool Call(const String & name, std::vector<duint> & argv, duint & result);
|
||||
|
|
|
@ -15,7 +15,7 @@ json_t* json_hex(unsigned json_int_t value)
|
|||
static JSON_INLINE
|
||||
unsigned json_int_t json_hex_value(const json_t* hex)
|
||||
{
|
||||
unsigned json_int_t ret;
|
||||
unsigned json_int_t ret = 0;
|
||||
const char* hexvalue;
|
||||
hexvalue = json_string_value(hex);
|
||||
if(!hexvalue)
|
||||
|
|
|
@ -478,7 +478,7 @@ duint MemAllocRemote(duint Address, duint Size, DWORD Type, DWORD Protect)
|
|||
|
||||
bool MemFreeRemote(duint Address)
|
||||
{
|
||||
return VirtualFreeEx(fdProcessInfo->hProcess, (LPVOID)Address, 0, MEM_RELEASE) == TRUE;
|
||||
return !!VirtualFreeEx(fdProcessInfo->hProcess, (LPVOID)Address, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
bool MemGetPageInfo(duint Address, MEMPAGE* PageInfo, bool Refresh)
|
||||
|
@ -513,7 +513,7 @@ bool MemSetPageRights(duint Address, const char* Rights)
|
|||
return false;
|
||||
|
||||
DWORD oldProtect;
|
||||
return VirtualProtectEx(fdProcessInfo->hProcess, (void*)Address, PAGE_SIZE, protect, &oldProtect) == TRUE;
|
||||
return !!VirtualProtectEx(fdProcessInfo->hProcess, (void*)Address, PAGE_SIZE, protect, &oldProtect);
|
||||
}
|
||||
|
||||
bool MemGetPageRights(duint Address, char* Rights)
|
||||
|
@ -607,7 +607,7 @@ bool MemPageRightsFromString(DWORD* Protect, const char* Rights)
|
|||
return (*Protect != 0);
|
||||
}
|
||||
|
||||
bool MemFindInPage(SimplePage page, duint startoffset, const std::vector<PatternByte> & pattern, std::vector<duint> & results, duint maxresults)
|
||||
bool MemFindInPage(const SimplePage & page, duint startoffset, const std::vector<PatternByte> & pattern, std::vector<duint> & results, duint maxresults)
|
||||
{
|
||||
if(startoffset >= page.size || results.size() >= maxresults)
|
||||
return false;
|
||||
|
|
|
@ -39,7 +39,7 @@ bool MemSetPageRights(duint Address, const char* Rights);
|
|||
bool MemGetPageRights(duint Address, char* Rights);
|
||||
bool MemPageRightsToString(DWORD Protect, char* Rights);
|
||||
bool MemPageRightsFromString(DWORD* Protect, const char* Rights);
|
||||
bool MemFindInPage(SimplePage page, duint startoffset, const std::vector<PatternByte> & pattern, std::vector<duint> & results, duint maxresults);
|
||||
bool MemFindInPage(const SimplePage & page, duint startoffset, const std::vector<PatternByte> & pattern, std::vector<duint> & results, duint maxresults);
|
||||
bool MemFindInMap(const std::vector<SimplePage> & pages, const std::vector<PatternByte> & pattern, std::vector<duint> & results, duint maxresults, bool progress = true);
|
||||
bool MemDecodePointer(duint* Pointer, bool vistaPlus);
|
||||
|
||||
|
|
|
@ -54,9 +54,9 @@ void pluginloadall(const char* pluginDir)
|
|||
{
|
||||
//load new plugins
|
||||
wchar_t currentDir[deflen] = L"";
|
||||
pluginDirectory = StringUtils::Utf8ToUtf16(pluginDir).c_str();
|
||||
pluginDirectory = StringUtils::Utf8ToUtf16(pluginDir);
|
||||
GetCurrentDirectoryW(deflen, currentDir);
|
||||
SetCurrentDirectoryW(StringUtils::Utf8ToUtf16(pluginDir).c_str());
|
||||
SetCurrentDirectoryW(pluginDirectory.c_str());
|
||||
char searchName[deflen] = "";
|
||||
#ifdef _WIN64
|
||||
sprintf(searchName, "%s\\*.dp64", pluginDir);
|
||||
|
@ -356,7 +356,7 @@ bool pluginload(const char* pluginName)
|
|||
return false;
|
||||
|
||||
char name[260] = "";
|
||||
strncpy(name, pluginName, MAX_PATH);
|
||||
strncpy_s(name, pluginName, _TRUNCATE);
|
||||
PLUG_DATA pluginData;
|
||||
|
||||
#ifdef _WIN64
|
||||
|
@ -630,7 +630,7 @@ bool pluginunload(const char* pluginName)
|
|||
PLUGSTOP stop = nullptr;
|
||||
PLUG_DATA currentPlugin;
|
||||
char name[MAX_PATH] = "";
|
||||
strncpy(name, pluginName, MAX_PATH);
|
||||
strncpy_s(name, pluginName, _TRUNCATE);
|
||||
|
||||
#ifdef _WIN64
|
||||
strcat(name, ".dp64");
|
||||
|
@ -776,14 +776,8 @@ void plugincbcall(CBTYPE cbType, void* callbackInfo)
|
|||
auto callbackList = pluginCallbackList; //copy for thread-safety reasons
|
||||
SHARED_RELEASE();
|
||||
for(const auto & currentCallback : callbackList)
|
||||
{
|
||||
if(currentCallback.cbType == cbType)
|
||||
{
|
||||
CBPLUGIN cbPlugin = currentCallback.cbPlugin;
|
||||
if(!IsBadReadPtr((const void*)cbPlugin, sizeof(duint)))
|
||||
cbPlugin(cbType, callbackInfo);
|
||||
}
|
||||
}
|
||||
currentCallback.cbPlugin(cbType, callbackInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -160,7 +160,7 @@ int RefFind(duint Address, duint Size, CBREF Callback, void* UserData, bool Sile
|
|||
return refInfo.refcount;
|
||||
}
|
||||
|
||||
int RefFindInRange(duint scanStart, duint scanSize, CBREF Callback, void* UserData, bool Silent, REFINFO & refInfo, Capstone & cp, bool initCallBack, CBPROGRESS cbUpdateProgress, bool disasmText)
|
||||
int RefFindInRange(duint scanStart, duint scanSize, CBREF Callback, void* UserData, bool Silent, REFINFO & refInfo, Capstone & cp, bool initCallBack, const CBPROGRESS & cbUpdateProgress, bool disasmText)
|
||||
{
|
||||
// Allocate and read a buffer from the remote process
|
||||
Memory<unsigned char*> data(scanSize, "reffind:data");
|
||||
|
|
|
@ -24,6 +24,6 @@ typedef bool (*CBREF)(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFIN
|
|||
typedef std::function<void(int)> CBPROGRESS;
|
||||
|
||||
int RefFind(duint Address, duint Size, CBREF Callback, void* UserData, bool Silent, const char* Name, REFFINDTYPE type, bool disasmText);
|
||||
int RefFindInRange(duint scanStart, duint scanSize, CBREF Callback, void* UserData, bool Silent, REFINFO & refInfo, Capstone & cp, bool initCallBack, CBPROGRESS cbUpdateProgress, bool disasmText);
|
||||
int RefFindInRange(duint scanStart, duint scanSize, CBREF Callback, void* UserData, bool Silent, REFINFO & refInfo, Capstone & cp, bool initCallBack, const CBPROGRESS & cbUpdateProgress, bool disasmText);
|
||||
|
||||
#endif // _REFERENCE_H
|
|
@ -73,7 +73,7 @@ String StringUtils::Escape(const String & s)
|
|||
|
||||
bool StringUtils::Unescape(const String & s, String & result, bool quoted)
|
||||
{
|
||||
int mLastChar;
|
||||
int mLastChar = EOF;
|
||||
size_t i = 0;
|
||||
auto nextChar = [&]()
|
||||
{
|
||||
|
@ -155,18 +155,18 @@ bool StringUtils::Unescape(const String & s, String & result, bool quoted)
|
|||
//Trim functions taken from: http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring/16743707#16743707
|
||||
const String StringUtils::WHITESPACE = " \n\r\t";
|
||||
|
||||
String StringUtils::Trim(const String & s, String delim)
|
||||
String StringUtils::Trim(const String & s, const String & delim)
|
||||
{
|
||||
return TrimRight(TrimLeft(s));
|
||||
}
|
||||
|
||||
String StringUtils::TrimLeft(const String & s, String delim)
|
||||
String StringUtils::TrimLeft(const String & s, const String & delim)
|
||||
{
|
||||
size_t startpos = s.find_first_not_of(delim);
|
||||
return (startpos == String::npos) ? "" : s.substr(startpos);
|
||||
}
|
||||
|
||||
String StringUtils::TrimRight(const String & s, String delim)
|
||||
String StringUtils::TrimRight(const String & s, const String & delim)
|
||||
{
|
||||
size_t endpos = s.find_last_not_of(delim);
|
||||
return (endpos == String::npos) ? "" : s.substr(0, endpos + 1);
|
||||
|
|
|
@ -18,9 +18,9 @@ public:
|
|||
static StringList Split(const String & s, char delim);
|
||||
static String Escape(const String & s);
|
||||
static bool Unescape(const String & s, String & result, bool quoted = true);
|
||||
static String Trim(const String & s, String delim = StringUtils::WHITESPACE);
|
||||
static String TrimLeft(const String & s, String delim = StringUtils::WHITESPACE);
|
||||
static String TrimRight(const String & s, String delim = StringUtils::WHITESPACE);
|
||||
static String Trim(const String & s, const String & delim = StringUtils::WHITESPACE);
|
||||
static String TrimLeft(const String & s, const String & delim = StringUtils::WHITESPACE);
|
||||
static String TrimRight(const String & s, const String & delim = StringUtils::WHITESPACE);
|
||||
static String PadLeft(const String & s, size_t minLength, char ch);
|
||||
static String Utf16ToUtf8(const WString & wstr);
|
||||
static String Utf16ToUtf8(const wchar_t* wstr);
|
||||
|
|
|
@ -116,11 +116,11 @@ bool TcpEnumConnections(duint pid, std::vector<TCPCONNECTIONINFO> & connections)
|
|||
strcpy_s(info.StateText, TcpStateToString(info.State));
|
||||
|
||||
InetNtopW(AF_INET6, &entry.LocalAddr, AddrBuffer, TCP_ADDR_SIZE);
|
||||
sprintf_s(info.LocalAddress, "[%s]", StringUtils::Utf16ToUtf8(AddrBuffer));
|
||||
sprintf_s(info.LocalAddress, "[%s]", StringUtils::Utf16ToUtf8(AddrBuffer).c_str());
|
||||
info.LocalPort = ntohs(u_short(entry.dwLocalPort));
|
||||
|
||||
InetNtopW(AF_INET6, &entry.RemoteAddr, AddrBuffer, TCP_ADDR_SIZE);
|
||||
sprintf_s(info.RemoteAddress, "[%s]", StringUtils::Utf16ToUtf8(AddrBuffer));
|
||||
sprintf_s(info.RemoteAddress, "[%s]", StringUtils::Utf16ToUtf8(AddrBuffer).c_str());
|
||||
info.RemotePort = ntohs(u_short(entry.dwRemotePort));
|
||||
|
||||
connections.push_back(info);
|
||||
|
|
|
@ -8,7 +8,13 @@
|
|||
std::map<unsigned int, WatchExpr*> watchexpr;
|
||||
unsigned int idCounter = 1;
|
||||
|
||||
WatchExpr::WatchExpr(const char* name, const char* expression, WATCHVARTYPE type) : expr(expression), varType(type), currValue(0), haveCurrValue(false), watchdogTriggered(false), watchWindow(0)
|
||||
WatchExpr::WatchExpr(const char* name, const char* expression, WATCHVARTYPE type) :
|
||||
expr(expression),
|
||||
haveCurrValue(false),
|
||||
varType(type), currValue(0),
|
||||
watchdogTriggered(false),
|
||||
watchWindow(0),
|
||||
watchdogMode(MODE_DISABLED)
|
||||
{
|
||||
if(!expr.IsValidExpression())
|
||||
varType = WATCHVARTYPE::TYPE_INVALID;
|
||||
|
|
|
@ -556,8 +556,10 @@ static DWORD WINAPI loadDbThread(LPVOID)
|
|||
dputs(QT_TRANSLATE_NOOP("DBG", "Reading notes file..."));
|
||||
notesFile = String(szProgramDir) + "\\notes.txt";
|
||||
String text;
|
||||
FileHelper::ReadAllText(notesFile, text);
|
||||
GuiSetGlobalNotes(text.c_str());
|
||||
if(!FileHelper::ReadAllText(notesFile, text))
|
||||
GuiSetGlobalNotes(text.c_str());
|
||||
else
|
||||
dputs(QT_TRANSLATE_NOOP("DBG", "Reading notes failed..."));
|
||||
|
||||
dputs(QT_TRANSLATE_NOOP("DBG", "File read thread finished!"));
|
||||
|
||||
|
|
|
@ -58,8 +58,8 @@ public:
|
|||
|
||||
typedef struct _DataDescriptor_t
|
||||
{
|
||||
DataSize_e itemSize; // Items size
|
||||
union // View mode
|
||||
DataSize_e itemSize; // Items size
|
||||
union // View mode
|
||||
{
|
||||
ByteViewMode_e byteMode;
|
||||
WordViewMode_e wordMode;
|
||||
|
@ -71,9 +71,9 @@ public:
|
|||
|
||||
struct ColumnDescriptor_t
|
||||
{
|
||||
bool isData;
|
||||
int itemCount;
|
||||
int separator;
|
||||
bool isData = true;
|
||||
int itemCount = 16;
|
||||
int separator = 0;
|
||||
QTextCodec* textCodec; //name of the text codec (leave empty if you want to keep your sanity)
|
||||
DataDescriptor_t data;
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#include "LabeledSplitterDetachedWindow.h"
|
||||
|
||||
|
||||
LabeledSplitterDetachedWindow::LabeledSplitterDetachedWindow(QWidget* parent, LabeledSplitter* splitterwidget) : QMainWindow(parent)
|
||||
LabeledSplitterDetachedWindow::LabeledSplitterDetachedWindow(QWidget* parent, LabeledSplitter* splitterwidget)
|
||||
: QMainWindow(parent),
|
||||
index(0)
|
||||
{
|
||||
m_SplitterWidget = splitterwidget;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ protected slots:
|
|||
protected:
|
||||
int getIndex();
|
||||
int charHeight;
|
||||
int originalIndex;
|
||||
LabeledSplitter* getParent() const;
|
||||
};
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
SearchListViewTable::SearchListViewTable(StdTable* parent)
|
||||
: StdTable(parent),
|
||||
bCipBase(false)
|
||||
bCipBase(false),
|
||||
mCip(0)
|
||||
{
|
||||
highlightText = "";
|
||||
updateColors();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "CodeFolding.h"
|
||||
|
||||
QBeaEngine::QBeaEngine(int maxModuleSize)
|
||||
: _tokenizer(maxModuleSize), mCodeFoldingManager(nullptr)
|
||||
: _tokenizer(maxModuleSize), mCodeFoldingManager(nullptr), _bLongDataInst(false)
|
||||
{
|
||||
CapstoneTokenizer::UpdateColors();
|
||||
UpdateDataInstructionMap();
|
||||
|
|
|
@ -290,7 +290,6 @@ void DataCopyDialog::printData(DataType type)
|
|||
InetNtopW(AF_INET6, const_cast<byte_t*>(mData->constData() + i * 16), buffer, 56);
|
||||
data += QString::fromWCharArray(buffer);
|
||||
}
|
||||
FreeLibrary(hWinsock);
|
||||
}
|
||||
else //fallback for Windows XP
|
||||
{
|
||||
|
@ -309,7 +308,7 @@ void DataCopyDialog::printData(DataType type)
|
|||
data += temp;
|
||||
}
|
||||
}
|
||||
|
||||
FreeLibrary(hWinsock);
|
||||
}
|
||||
}
|
||||
ui->editCode->setPlainText(data);
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
#include "Configuration.h"
|
||||
|
||||
SourceView::SourceView(QString path, int line, StdTable* parent)
|
||||
: ReferenceView(true, parent)
|
||||
: ReferenceView(true, parent),
|
||||
mIpLine(0)
|
||||
{
|
||||
mSourcePath = path;
|
||||
mList->enableColumnSorting(false);
|
||||
|
|
|
@ -10,6 +10,7 @@ XrefBrowseDialog::XrefBrowseDialog(QWidget* parent, duint address) :
|
|||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint | Qt::MSWindowsFixedSizeDialogHint);
|
||||
setWindowIcon(DIcon("xrefs.png"));
|
||||
mAddress = address;
|
||||
mPrevSelectionSize = 0;
|
||||
if(DbgXrefGet(address, &mXrefInfo))
|
||||
{
|
||||
char disasm[GUI_MAX_DISASSEMBLY_SIZE] = "";
|
||||
|
@ -21,7 +22,6 @@ XrefBrowseDialog::XrefBrowseDialog(QWidget* parent, duint address) :
|
|||
else
|
||||
ui->listWidget->addItem("???");
|
||||
}
|
||||
mPrevSelectionSize = 0;
|
||||
ui->listWidget->setCurrentRow(0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue