1
0
Fork 0

DBG+GUI+BRIDGE+PROJECT: updated AStyle and formatting

This commit is contained in:
mrexodia 2017-03-16 03:32:09 +01:00
parent 033a495925
commit d5e578ee6a
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
62 changed files with 264 additions and 289 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,30 +1,5 @@
# hooks # hooks
This contains two binaries `AStyleWhore.exe` and `AStyle.dll` to format any code before you commit. They are signed with GPG. This contains two binaries `AStyleWhore.exe` and `AStyle.dll` to format any code before you commit. They are signed with the serial number `37 ba b6 0f 84 53 0e 5e e5 76 ba d2 6d 45 4b 58`.
To verify: If you are unsure about the integrity of the files, don't hesitate to contact me (mrexodia). The source code is available at [BitBucket](https://bitbucket.org/mrexodia/astylewhore). The version of `AStyle.dll` is compiled from `AStyle_2.06_windows.zip` which came from [Sourceforge](https://sourceforge.net/projects/astyle/files/astyle/astyle%202.06/AStyle_2.06_windows.zip/download).
```
gpg --verify AStyle.dll.sig AStyle.dll
gpg: Signature made 07/08/16 06:01:39 W. Europe Daylight Time using RSA key ID AA0073B4
gpg: Good signature from "Duncan Ogilvie <mr.exodia.tpodt@gmail.com>" [ultimate]
gpg --verify AStyleWhore.exe.sig AStyleWhore.exe
gpg: Signature made 07/08/16 06:01:42 W. Europe Daylight Time using RSA key ID AA0073B4
gpg: Good signature from "Duncan Ogilvie <mr.exodia.tpodt@gmail.com>" [ultimate]
```
The *key ID* should match the last 8 characters of the signature of [this commit](https://github.com/x64dbg/x64dbg/commit/c855c15fd79870312ea5b4a1fbf3cb0dd8ae6240).
Git hashes are:
```
git ls-files -s
100644 6ef20910c6ab4e94cc2270e289a5b73d712c9c50 0 AStyle.dll
100644 5ea8a5daf0580e030406cedb83fb73ca9c187138 0 AStyle.dll.sig
100644 10dd63522b059eb3a43c01b35b807a9d50b5034d 0 AStyleWhore.exe
100644 d910d7ff178703b1452bc717491e5c24b9db1945 0 AStyleWhore.exe.sig
100644 0706138f1ec594c0b5d41978900b9d45cd2d99d7 0 pre-commit
```
If you are unsure about the integrity of the files, don't hesitate to contact me (mrexodia). The source code is available at [BitBucket](https://bitbucket.org/mrexodia/astylewhore). The version of `AStyle.dll` is compiled from `AStyle_2.04_windows.zip` which came from [Sourceforge](https://sourceforge.net/projects/astyle/files/astyle/astyle%202.04/AStyle_2.04_windows.zip/download).

View File

@ -54,7 +54,7 @@ public:
*/ */
int Count() const int Count() const
{ {
if(_listInfo.size != _listInfo.count * sizeof(Type)) //make sure the user is using the correct type. if(_listInfo.size != _listInfo.count * sizeof(Type)) //make sure the user is using the correct type.
__debugbreak(); __debugbreak();
return _listInfo.count; return _listInfo.count;
} }
@ -88,7 +88,7 @@ public:
*/ */
Type & operator[](size_t index) const Type & operator[](size_t index) const
{ {
if(index >= size_t(Count())) //make sure the out-of-bounds access is caught as soon as possible. if(index >= size_t(Count())) //make sure the out-of-bounds access is caught as soon as possible.
__debugbreak(); __debugbreak();
return Data()[index]; return Data()[index];
} }

View File

@ -234,7 +234,7 @@ BRIDGE_IMPEXP bool BridgeSettingRead(int* errorLine)
} }
CloseHandle(hFile); CloseHandle(hFile);
} }
if(success) //if we failed to read the file, the current settings are better than none at all if(success) //if we failed to read the file, the current settings are better than none at all
{ {
EnterCriticalSection(&csIni); EnterCriticalSection(&csIni);
int errline = 0; int errline = 0;

@ -1 +1 @@
Subproject commit c1bf5682a05836e5f54319db92248116a4a9ccc6 Subproject commit 05adc360018b6810cb0a6bbaa247de6522bdf9c5

View File

@ -202,11 +202,11 @@ static bool getLabel(duint addr, char* label, bool noFuncOffset)
strncat_s(label, MAX_LABEL_SIZE, temp, _TRUNCATE); strncat_s(label, MAX_LABEL_SIZE, temp, _TRUNCATE);
} }
} }
if(!retval) //search for CALL <jmp.&user32.MessageBoxA> if(!retval) //search for CALL <jmp.&user32.MessageBoxA>
{ {
BASIC_INSTRUCTION_INFO basicinfo; BASIC_INSTRUCTION_INFO basicinfo;
memset(&basicinfo, 0, sizeof(BASIC_INSTRUCTION_INFO)); memset(&basicinfo, 0, sizeof(BASIC_INSTRUCTION_INFO));
if(disasmfast(addr, &basicinfo, true) && basicinfo.branch && !basicinfo.call && basicinfo.memory.value) //thing is a JMP if(disasmfast(addr, &basicinfo, true) && basicinfo.branch && !basicinfo.call && basicinfo.memory.value) //thing is a JMP
{ {
duint val = 0; duint val = 0;
if(MemRead(basicinfo.memory.value, &val, sizeof(val), nullptr, true)) if(MemRead(basicinfo.memory.value, &val, sizeof(val), nullptr, true))
@ -229,7 +229,7 @@ static bool getLabel(duint addr, char* label, bool noFuncOffset)
} }
} }
} }
if(!retval) //search for module entry if(!retval) //search for module entry
{ {
if(addr != 0 && ModEntryFromAddr(addr) == addr) if(addr != 0 && ModEntryFromAddr(addr) == addr)
{ {
@ -825,7 +825,7 @@ extern "C" DLL_EXPORT duint _dbg_sendmessage(DBGMSG type, void* param1, void* pa
{ {
if(dbgisstopped()) if(dbgisstopped())
{ {
switch(type) //ignore win events switch(type) //ignore win events
{ {
//these functions are safe to call when we did not initialize yet //these functions are safe to call when we did not initialize yet
case DBG_DEINITIALIZE_LOCKS: case DBG_DEINITIALIZE_LOCKS:

View File

@ -125,7 +125,7 @@ PLUG_IMPEXP void _plugin_startscript(CBPLUGINSCRIPT cbScript)
PLUG_IMPEXP bool _plugin_waituntilpaused() PLUG_IMPEXP bool _plugin_waituntilpaused()
{ {
while(DbgIsDebugging() && dbgisrunning()) //wait until the debugger paused while(DbgIsDebugging() && dbgisrunning()) //wait until the debugger paused
{ {
Sleep(1); Sleep(1);
GuiProcessEvents(); //workaround for scripts being executed on the GUI thread GuiProcessEvents(); //workaround for scripts being executed on the GUI thread

View File

@ -85,7 +85,7 @@ void AdvancedAnalysis::analyzeFunction(duint entryPoint, bool writedata)
{ {
auto start = queue.front(); auto start = queue.front();
queue.pop(); queue.pop();
if(visited.count(start) || !inRange(start)) //already visited or out of range if(visited.count(start) || !inRange(start)) //already visited or out of range
continue; continue;
visited.insert(start); visited.insert(start);
@ -106,11 +106,11 @@ void AdvancedAnalysis::analyzeFunction(duint entryPoint, bool writedata)
for(int i = 1; i < mCp.Size(); i++) for(int i = 1; i < mCp.Size(); i++)
mEncMap[node.end - mBase + i] = (byte)enc_middle; mEncMap[node.end - mBase + i] = (byte)enc_middle;
} }
if(mCp.InGroup(CS_GRP_JUMP) || mCp.IsLoop()) //jump if(mCp.InGroup(CS_GRP_JUMP) || mCp.IsLoop()) //jump
{ {
//set the branch destinations //set the branch destinations
node.brtrue = mCp.BranchDestination(); node.brtrue = mCp.BranchDestination();
if(mCp.GetId() != X86_INS_JMP) //unconditional jumps dont have a brfalse if(mCp.GetId() != X86_INS_JMP) //unconditional jumps dont have a brfalse
node.brfalse = node.end + mCp.Size(); node.brfalse = node.end + mCp.Size();
//add node to the function graph //add node to the function graph
@ -124,14 +124,14 @@ void AdvancedAnalysis::analyzeFunction(duint entryPoint, bool writedata)
break; break;
} }
if(mCp.InGroup(CS_GRP_CALL)) //call if(mCp.InGroup(CS_GRP_CALL)) //call
{ {
//TODO: handle no return //TODO: handle no return
duint target = mCp.BranchDestination(); duint target = mCp.BranchDestination();
if(inRange(target) && mEntryPoints.find(target) == mEntryPoints.end()) if(inRange(target) && mEntryPoints.find(target) == mEntryPoints.end())
mCandidateEPs.insert(target); mCandidateEPs.insert(target);
} }
if(mCp.InGroup(CS_GRP_RET)) //return if(mCp.InGroup(CS_GRP_RET)) //return
{ {
node.terminal = true; node.terminal = true;
graph.AddNode(node); graph.AddNode(node);

View File

@ -154,14 +154,14 @@ void ControlFlowAnalysis::BasicBlockStarts()
{ {
bSkipFilling = true; //skip INT3/NOP/whatever filling bytes (those are not part of the control flow) bSkipFilling = true; //skip INT3/NOP/whatever filling bytes (those are not part of the control flow)
} }
else if(mCp.InGroup(CS_GRP_JUMP) || mCp.IsLoop()) //branches else if(mCp.InGroup(CS_GRP_JUMP) || mCp.IsLoop()) //branches
{ {
auto dest1 = getReferenceOperand(); auto dest1 = getReferenceOperand();
duint dest2 = 0; duint dest2 = 0;
if(mCp.GetId() != X86_INS_JMP) //conditional jump if(mCp.GetId() != X86_INS_JMP) //conditional jump
dest2 = addr + mCp.Size(); dest2 = addr + mCp.Size();
if(!dest1 && !dest2) //TODO: better code for this (make sure absolutely no filling is inserted) if(!dest1 && !dest2) //TODO: better code for this (make sure absolutely no filling is inserted)
bSkipFilling = true; bSkipFilling = true;
if(dest1) if(dest1)
mBlockStarts.insert(dest1); mBlockStarts.insert(dest1);
@ -224,7 +224,7 @@ void ControlFlowAnalysis::BasicBlocks()
} }
else else
addr++; addr++;
if(addr == nextStart) //special case handling overlapping blocks if(addr == nextStart) //special case handling overlapping blocks
{ {
insertBlock(BasicBlock(start, prevaddr, 0, nextStart)); insertBlock(BasicBlock(start, prevaddr, 0, nextStart));
insertParent(nextStart, start); insertParent(nextStart, start);
@ -263,7 +263,7 @@ void ControlFlowAnalysis::Functions()
auto parents = findParents(block->start); auto parents = findParents(block->start);
if(!block->function) if(!block->function)
{ {
if(!parents || mFunctionStarts.count(block->start)) //no parents = function start if(!parents || mFunctionStarts.count(block->start)) //no parents = function start
{ {
auto functionStart = block->start; auto functionStart = block->start;
block->function = functionStart; block->function = functionStart;
@ -274,7 +274,7 @@ void ControlFlowAnalysis::Functions()
else //in function else //in function
{ {
auto function = findFunctionStart(block, parents); auto function = findFunctionStart(block, parents);
if(!function) //this happens with loops / unreferenced blocks sometimes if(!function) //this happens with loops / unreferenced blocks sometimes
delayedBlocks.push_back(DelayedBlock(block, parents)); delayedBlocks.push_back(DelayedBlock(block, parents));
else else
block->function = function; block->function = function;
@ -315,7 +315,7 @@ void ControlFlowAnalysis::Functions()
for(const auto & block : mBlocks) for(const auto & block : mBlocks)
{ {
auto found = mFunctions.find(block.second.function); auto found = mFunctions.find(block.second.function);
if(found == mFunctions.end()) //unreferenced block if(found == mFunctions.end()) //unreferenced block
{ {
unreferencedCount++; unreferencedCount++;
continue; continue;
@ -425,7 +425,7 @@ duint ControlFlowAnalysis::getReferenceOperand() const
else if(op.type == X86_OP_MEM) else if(op.type == X86_OP_MEM)
{ {
auto dest = duint(op.mem.disp); auto dest = duint(op.mem.disp);
if(op.mem.base == X86_REG_RIP) //rip-relative if(op.mem.base == X86_REG_RIP) //rip-relative
dest += mCp.Address() + mCp.Size(); dest += mCp.Address() + mCp.Size();
if(inRange(dest)) if(inRange(dest))
return dest; return dest;

View File

@ -62,7 +62,7 @@ void LinearAnalysis::analyseFunctions()
for(size_t i = 0; i < mFunctions.size(); i++) for(size_t i = 0; i < mFunctions.size(); i++)
{ {
auto & function = mFunctions[i]; auto & function = mFunctions[i];
if(function.end) //skip already-analysed functions if(function.end) //skip already-analysed functions
continue; continue;
auto maxaddr = mBase + mSize; auto maxaddr = mBase + mSize;
if(i < mFunctions.size() - 1) if(i < mFunctions.size() - 1)
@ -96,19 +96,19 @@ duint LinearAnalysis::findFunctionEnd(duint start, duint maxaddr)
{ {
if(mCp.Disassemble(addr, translateAddr(addr), MAX_DISASM_BUFFER)) if(mCp.Disassemble(addr, translateAddr(addr), MAX_DISASM_BUFFER))
{ {
if(addr + mCp.Size() > maxaddr) //we went past the maximum allowed address if(addr + mCp.Size() > maxaddr) //we went past the maximum allowed address
break; break;
const auto & op = mCp.x86().operands[0]; const auto & op = mCp.x86().operands[0];
if((mCp.InGroup(CS_GRP_JUMP) || mCp.IsLoop()) && op.type == X86_OP_IMM) //jump if((mCp.InGroup(CS_GRP_JUMP) || mCp.IsLoop()) && op.type == X86_OP_IMM) //jump
{ {
auto dest = duint(op.imm); auto dest = duint(op.imm);
if(dest >= maxaddr) //jump across function boundaries if(dest >= maxaddr) //jump across function boundaries
{ {
//currently unused //currently unused
} }
else if(dest > addr && dest > fardest) //save the farthest JXX destination forward else if(dest > addr && dest > fardest) //save the farthest JXX destination forward
{ {
fardest = dest; fardest = dest;
} }
@ -117,10 +117,10 @@ duint LinearAnalysis::findFunctionEnd(duint start, duint maxaddr)
jumpback = addr; jumpback = addr;
} }
} }
else if(mCp.InGroup(CS_GRP_RET)) //possible function end? else if(mCp.InGroup(CS_GRP_RET)) //possible function end?
{ {
end = addr; end = addr;
if(fardest < addr) //we stop if the farthest JXX destination forward is before this RET if(fardest < addr) //we stop if the farthest JXX destination forward is before this RET
break; break;
} }
@ -137,9 +137,9 @@ duint LinearAnalysis::getReferenceOperand() const
for(auto i = 0; i < mCp.OpCount(); i++) for(auto i = 0; i < mCp.OpCount(); i++)
{ {
const auto & op = mCp.x86().operands[i]; const auto & op = mCp.x86().operands[i];
if(mCp.InGroup(CS_GRP_JUMP) || mCp.IsLoop()) //skip jumps/loops if(mCp.InGroup(CS_GRP_JUMP) || mCp.IsLoop()) //skip jumps/loops
continue; continue;
if(op.type == X86_OP_IMM) //we are looking for immediate references if(op.type == X86_OP_IMM) //we are looking for immediate references
{ {
auto dest = duint(op.imm); auto dest = duint(op.imm);
if(inRange(dest)) if(inRange(dest))

View File

@ -120,7 +120,7 @@ void RecursiveAnalysis::analyzeFunction(duint entryPoint)
{ {
//set the branch destinations //set the branch destinations
node.brtrue = mCp.BranchDestination(); node.brtrue = mCp.BranchDestination();
if(mCp.GetId() != X86_INS_JMP && mCp.GetId() != X86_INS_LJMP) //unconditional jumps dont have a brfalse if(mCp.GetId() != X86_INS_JMP && mCp.GetId() != X86_INS_LJMP) //unconditional jumps dont have a brfalse
node.brfalse = node.end + mCp.Size(); node.brfalse = node.end + mCp.Size();
//consider register/memory branches as terminal nodes //consider register/memory branches as terminal nodes

View File

@ -17,7 +17,7 @@ std::map<BreakpointKey, BREAKPOINT> breakpoints;
static void setBpActive(BREAKPOINT & bp) static void setBpActive(BREAKPOINT & bp)
{ {
if(bp.type == BPHARDWARE) //TODO: properly implement this (check debug registers) if(bp.type == BPHARDWARE) //TODO: properly implement this (check debug registers)
bp.active = true; bp.active = true;
else if(bp.type == BPDLL || bp.type == BPEXCEPTION) else if(bp.type == BPDLL || bp.type == BPEXCEPTION)
bp.active = true; bp.active = true;
@ -478,7 +478,7 @@ bool BpEnumAll(BPENUMCALLBACK EnumCallback, const char* Module, duint base)
BREAKPOINT bpInfo = j->second; BREAKPOINT bpInfo = j->second;
if(bpInfo.type != BPDLL && bpInfo.type != BPEXCEPTION) if(bpInfo.type != BPDLL && bpInfo.type != BPEXCEPTION)
{ {
if(base) //workaround for some Windows bullshit with compatibility mode if(base) //workaround for some Windows bullshit with compatibility mode
bpInfo.addr += base; bpInfo.addr += base;
else else
bpInfo.addr += ModBaseFromName(bpInfo.mod); bpInfo.addr += ModBaseFromName(bpInfo.mod);

@ -1 +1 @@
Subproject commit 90eed9913a12ef5afec007b4d91f77301b66cc76 Subproject commit d5034cf6d647e98cb01e9e1fc4efa5086f8fc6a5

View File

@ -155,12 +155,12 @@ bool cbDebugDownloadSymbol(int argc, char* argv[])
dputs(QT_TRANSLATE_NOOP("DBG", "This may take very long, depending on your network connection and data in the debug directory...")); dputs(QT_TRANSLATE_NOOP("DBG", "This may take very long, depending on your network connection and data in the debug directory..."));
Memory<char*> szDefaultStore(MAX_SETTING_SIZE + 1); Memory<char*> szDefaultStore(MAX_SETTING_SIZE + 1);
const char* szSymbolStore = szDefaultStore(); const char* szSymbolStore = szDefaultStore();
if(!BridgeSettingGet("Symbols", "DefaultStore", szDefaultStore())) //get default symbol store from settings if(!BridgeSettingGet("Symbols", "DefaultStore", szDefaultStore())) //get default symbol store from settings
{ {
strcpy_s(szDefaultStore(), MAX_SETTING_SIZE, "https://msdl.microsoft.com/download/symbols"); strcpy_s(szDefaultStore(), MAX_SETTING_SIZE, "https://msdl.microsoft.com/download/symbols");
BridgeSettingSet("Symbols", "DefaultStore", szDefaultStore()); BridgeSettingSet("Symbols", "DefaultStore", szDefaultStore());
} }
if(argc < 2) //no arguments if(argc < 2) //no arguments
{ {
SymDownloadAllSymbols(szSymbolStore); //download symbols for all modules SymDownloadAllSymbols(szSymbolStore); //download symbols for all modules
GuiSymbolRefreshCurrent(); GuiSymbolRefreshCurrent();
@ -181,7 +181,7 @@ bool cbDebugDownloadSymbol(int argc, char* argv[])
return false; return false;
} }
wchar_t szOldSearchPath[MAX_PATH] = L""; wchar_t szOldSearchPath[MAX_PATH] = L"";
if(!SafeSymGetSearchPathW(fdProcessInfo->hProcess, szOldSearchPath, MAX_PATH)) //backup current search path if(!SafeSymGetSearchPathW(fdProcessInfo->hProcess, szOldSearchPath, MAX_PATH)) //backup current search path
{ {
dputs(QT_TRANSLATE_NOOP("DBG", "SymGetSearchPath failed!")); dputs(QT_TRANSLATE_NOOP("DBG", "SymGetSearchPath failed!"));
return false; return false;
@ -190,12 +190,12 @@ bool cbDebugDownloadSymbol(int argc, char* argv[])
if(argc > 2) if(argc > 2)
szSymbolStore = argv[2]; szSymbolStore = argv[2];
sprintf_s(szServerSearchPath, "SRV*%s*%s", szSymbolCachePath, szSymbolStore); sprintf_s(szServerSearchPath, "SRV*%s*%s", szSymbolCachePath, szSymbolStore);
if(!SafeSymSetSearchPathW(fdProcessInfo->hProcess, StringUtils::Utf8ToUtf16(szServerSearchPath).c_str())) //set new search path if(!SafeSymSetSearchPathW(fdProcessInfo->hProcess, StringUtils::Utf8ToUtf16(szServerSearchPath).c_str())) //set new search path
{ {
dputs(QT_TRANSLATE_NOOP("DBG", "SymSetSearchPath (1) failed!")); dputs(QT_TRANSLATE_NOOP("DBG", "SymSetSearchPath (1) failed!"));
return false; return false;
} }
if(!SafeSymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)modbase)) //unload module if(!SafeSymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)modbase)) //unload module
{ {
SafeSymSetSearchPathW(fdProcessInfo->hProcess, szOldSearchPath); SafeSymSetSearchPathW(fdProcessInfo->hProcess, szOldSearchPath);
dputs(QT_TRANSLATE_NOOP("DBG", "SymUnloadModule64 failed!")); dputs(QT_TRANSLATE_NOOP("DBG", "SymUnloadModule64 failed!"));
@ -203,7 +203,7 @@ bool cbDebugDownloadSymbol(int argc, char* argv[])
} }
auto symOptions = SafeSymGetOptions(); auto symOptions = SafeSymGetOptions();
SafeSymSetOptions(symOptions & ~SYMOPT_IGNORE_CVREC); SafeSymSetOptions(symOptions & ~SYMOPT_IGNORE_CVREC);
if(!SymLoadModuleExW(fdProcessInfo->hProcess, 0, wszModulePath, 0, (DWORD64)modbase, 0, 0, 0)) //load module if(!SymLoadModuleExW(fdProcessInfo->hProcess, 0, wszModulePath, 0, (DWORD64)modbase, 0, 0, 0)) //load module
{ {
dputs(QT_TRANSLATE_NOOP("DBG", "SymLoadModuleEx failed!")); dputs(QT_TRANSLATE_NOOP("DBG", "SymLoadModuleEx failed!"));
SafeSymSetOptions(symOptions); SafeSymSetOptions(symOptions);
@ -405,7 +405,7 @@ bool cbInstrExinfo(int argc, char* argv[])
dputs_untranslated("EXCEPTION_DEBUG_INFO:"); dputs_untranslated("EXCEPTION_DEBUG_INFO:");
dprintf_untranslated(" dwFirstChance: %X\n", info.dwFirstChance); dprintf_untranslated(" dwFirstChance: %X\n", info.dwFirstChance);
auto exceptionName = ExceptionCodeToName(record.ExceptionCode); auto exceptionName = ExceptionCodeToName(record.ExceptionCode);
if(!exceptionName.size()) //if no exception was found, try the error codes (RPC_S_*) if(!exceptionName.size()) //if no exception was found, try the error codes (RPC_S_*)
exceptionName = ErrorCodeToName(record.ExceptionCode); exceptionName = ErrorCodeToName(record.ExceptionCode);
if(exceptionName.size()) if(exceptionName.size())
dprintf_untranslated(" ExceptionCode: %08X (%s)\n", record.ExceptionCode, exceptionName.c_str()); dprintf_untranslated(" ExceptionCode: %08X (%s)\n", record.ExceptionCode, exceptionName.c_str());

View File

@ -142,14 +142,14 @@ bool cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]]
bool cbDebugDeleteBPX(int argc, char* argv[]) bool cbDebugDeleteBPX(int argc, char* argv[])
{ {
if(argc < 2) //delete all breakpoints if(argc < 2) //delete all breakpoints
{ {
if(!BpGetCount(BPNORMAL)) if(!BpGetCount(BPNORMAL))
{ {
dputs(QT_TRANSLATE_NOOP("DBG", "No breakpoints to delete!")); dputs(QT_TRANSLATE_NOOP("DBG", "No breakpoints to delete!"));
return true; return true;
} }
if(!BpEnumAll(cbDeleteAllBreakpoints)) //at least one deletion failed if(!BpEnumAll(cbDeleteAllBreakpoints)) //at least one deletion failed
{ {
GuiUpdateAllViews(); GuiUpdateAllViews();
return false; return false;
@ -159,7 +159,7 @@ bool cbDebugDeleteBPX(int argc, char* argv[])
return true; return true;
} }
BREAKPOINT found; BREAKPOINT found;
if(BpGet(0, BPNORMAL, argv[1], &found)) //found a breakpoint with name if(BpGet(0, BPNORMAL, argv[1], &found)) //found a breakpoint with name
{ {
if(!BpDelete(found.addr, BPNORMAL)) if(!BpDelete(found.addr, BPNORMAL))
{ {
@ -177,7 +177,7 @@ bool cbDebugDeleteBPX(int argc, char* argv[])
return true; return true;
} }
duint addr = 0; duint addr = 0;
if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "No such breakpoint \"%s\"\n"), argv[1]); dprintf(QT_TRANSLATE_NOOP("DBG", "No such breakpoint \"%s\"\n"), argv[1]);
return false; return false;
@ -202,21 +202,21 @@ bool cbDebugDeleteBPX(int argc, char* argv[])
bool cbDebugEnableBPX(int argc, char* argv[]) bool cbDebugEnableBPX(int argc, char* argv[])
{ {
if(argc < 2) //enable all breakpoints if(argc < 2) //enable all breakpoints
{ {
if(!BpGetCount(BPNORMAL)) if(!BpGetCount(BPNORMAL))
{ {
dputs(QT_TRANSLATE_NOOP("DBG", "No breakpoints to enable!")); dputs(QT_TRANSLATE_NOOP("DBG", "No breakpoints to enable!"));
return true; return true;
} }
if(!BpEnumAll(cbEnableAllBreakpoints)) //at least one enable failed if(!BpEnumAll(cbEnableAllBreakpoints)) //at least one enable failed
return false; return false;
dputs(QT_TRANSLATE_NOOP("DBG", "All breakpoints enabled!")); dputs(QT_TRANSLATE_NOOP("DBG", "All breakpoints enabled!"));
GuiUpdateAllViews(); GuiUpdateAllViews();
return true; return true;
} }
BREAKPOINT found; BREAKPOINT found;
if(BpGet(0, BPNORMAL, argv[1], &found)) //found a breakpoint with name if(BpGet(0, BPNORMAL, argv[1], &found)) //found a breakpoint with name
{ {
if(!SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint)) if(!SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint))
{ {
@ -232,7 +232,7 @@ bool cbDebugEnableBPX(int argc, char* argv[])
return true; return true;
} }
duint addr = 0; duint addr = 0;
if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "No such breakpoint \"%s\"\n"), argv[1]); dprintf(QT_TRANSLATE_NOOP("DBG", "No such breakpoint \"%s\"\n"), argv[1]);
return false; return false;
@ -260,21 +260,21 @@ bool cbDebugEnableBPX(int argc, char* argv[])
bool cbDebugDisableBPX(int argc, char* argv[]) bool cbDebugDisableBPX(int argc, char* argv[])
{ {
if(argc < 2) //delete all breakpoints if(argc < 2) //delete all breakpoints
{ {
if(!BpGetCount(BPNORMAL)) if(!BpGetCount(BPNORMAL))
{ {
dputs(QT_TRANSLATE_NOOP("DBG", "No breakpoints to disable!")); dputs(QT_TRANSLATE_NOOP("DBG", "No breakpoints to disable!"));
return true; return true;
} }
if(!BpEnumAll(cbDisableAllBreakpoints)) //at least one deletion failed if(!BpEnumAll(cbDisableAllBreakpoints)) //at least one deletion failed
return false; return false;
dputs(QT_TRANSLATE_NOOP("DBG", "All breakpoints disabled!")); dputs(QT_TRANSLATE_NOOP("DBG", "All breakpoints disabled!"));
GuiUpdateAllViews(); GuiUpdateAllViews();
return true; return true;
} }
BREAKPOINT found; BREAKPOINT found;
if(BpGet(0, BPNORMAL, argv[1], &found)) //found a breakpoint with name if(BpGet(0, BPNORMAL, argv[1], &found)) //found a breakpoint with name
{ {
if(!BpEnable(found.addr, BPNORMAL, false)) if(!BpEnable(found.addr, BPNORMAL, false))
{ {
@ -293,7 +293,7 @@ bool cbDebugDisableBPX(int argc, char* argv[])
return true; return true;
} }
duint addr = 0; duint addr = 0;
if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "No such breakpoint \"%s\"\n"), argv[1]); dprintf(QT_TRANSLATE_NOOP("DBG", "No such breakpoint \"%s\"\n"), argv[1]);
return false; return false;
@ -475,21 +475,21 @@ bool cbDebugSetHardwareBreakpoint(int argc, char* argv[])
bool cbDebugDeleteHardwareBreakpoint(int argc, char* argv[]) bool cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
{ {
if(argc < 2) //delete all breakpoints if(argc < 2) //delete all breakpoints
{ {
if(!BpGetCount(BPHARDWARE)) if(!BpGetCount(BPHARDWARE))
{ {
dputs(QT_TRANSLATE_NOOP("DBG", "No hardware breakpoints to delete!")); dputs(QT_TRANSLATE_NOOP("DBG", "No hardware breakpoints to delete!"));
return true; return true;
} }
if(!BpEnumAll(cbDeleteAllHardwareBreakpoints)) //at least one deletion failed if(!BpEnumAll(cbDeleteAllHardwareBreakpoints)) //at least one deletion failed
return false; return false;
dputs(QT_TRANSLATE_NOOP("DBG", "All hardware breakpoints deleted!")); dputs(QT_TRANSLATE_NOOP("DBG", "All hardware breakpoints deleted!"));
GuiUpdateAllViews(); GuiUpdateAllViews();
return true; return true;
} }
BREAKPOINT found; BREAKPOINT found;
if(BpGet(0, BPHARDWARE, argv[1], &found)) //found a breakpoint with name if(BpGet(0, BPHARDWARE, argv[1], &found)) //found a breakpoint with name
{ {
if(!BpDelete(found.addr, BPHARDWARE)) if(!BpDelete(found.addr, BPHARDWARE))
{ {
@ -504,7 +504,7 @@ bool cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
return true; return true;
} }
duint addr = 0; duint addr = 0;
if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPHARDWARE, 0, &found)) //invalid breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPHARDWARE, 0, &found)) //invalid breakpoint
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "No such hardware breakpoint \"%s\"\n"), argv[1]); dprintf(QT_TRANSLATE_NOOP("DBG", "No such hardware breakpoint \"%s\"\n"), argv[1]);
return false; return false;
@ -532,14 +532,14 @@ bool cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
dputs(QT_TRANSLATE_NOOP("DBG", "You can only set 4 hardware breakpoints")); dputs(QT_TRANSLATE_NOOP("DBG", "You can only set 4 hardware breakpoints"));
return false; return false;
} }
if(argc < 2) //enable all hardware breakpoints if(argc < 2) //enable all hardware breakpoints
{ {
if(!BpGetCount(BPHARDWARE)) if(!BpGetCount(BPHARDWARE))
{ {
dputs(QT_TRANSLATE_NOOP("DBG", "No hardware breakpoints to enable!")); dputs(QT_TRANSLATE_NOOP("DBG", "No hardware breakpoints to enable!"));
return true; return true;
} }
if(!BpEnumAll(cbEnableAllHardwareBreakpoints)) //at least one enable failed if(!BpEnumAll(cbEnableAllHardwareBreakpoints)) //at least one enable failed
return false; return false;
dputs(QT_TRANSLATE_NOOP("DBG", "All hardware breakpoints enabled!")); dputs(QT_TRANSLATE_NOOP("DBG", "All hardware breakpoints enabled!"));
GuiUpdateAllViews(); GuiUpdateAllViews();
@ -547,7 +547,7 @@ bool cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
} }
BREAKPOINT found; BREAKPOINT found;
duint addr = 0; duint addr = 0;
if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "No such hardware breakpoint \"%s\"\n"), argv[1]); dprintf(QT_TRANSLATE_NOOP("DBG", "No such hardware breakpoint \"%s\"\n"), argv[1]);
return false; return false;
@ -577,14 +577,14 @@ bool cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
bool cbDebugDisableHardwareBreakpoint(int argc, char* argv[]) bool cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
{ {
if(argc < 2) //delete all hardware breakpoints if(argc < 2) //delete all hardware breakpoints
{ {
if(!BpGetCount(BPHARDWARE)) if(!BpGetCount(BPHARDWARE))
{ {
dputs(QT_TRANSLATE_NOOP("DBG", "No hardware breakpoints to disable!")); dputs(QT_TRANSLATE_NOOP("DBG", "No hardware breakpoints to disable!"));
return true; return true;
} }
if(!BpEnumAll(cbDisableAllHardwareBreakpoints)) //at least one deletion failed if(!BpEnumAll(cbDisableAllHardwareBreakpoints)) //at least one deletion failed
return false; return false;
dputs(QT_TRANSLATE_NOOP("DBG", "All hardware breakpoints disabled!")); dputs(QT_TRANSLATE_NOOP("DBG", "All hardware breakpoints disabled!"));
GuiUpdateAllViews(); GuiUpdateAllViews();
@ -592,7 +592,7 @@ bool cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
} }
BREAKPOINT found; BREAKPOINT found;
duint addr = 0; duint addr = 0;
if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "No such hardware breakpoint \"%s\"\n"), argv[1]); dprintf(QT_TRANSLATE_NOOP("DBG", "No such hardware breakpoint \"%s\"\n"), argv[1]);
return false; return false;
@ -744,21 +744,21 @@ bool cbDebugSetMemoryBpx(int argc, char* argv[])
bool cbDebugDeleteMemoryBreakpoint(int argc, char* argv[]) bool cbDebugDeleteMemoryBreakpoint(int argc, char* argv[])
{ {
if(argc < 2) //delete all breakpoints if(argc < 2) //delete all breakpoints
{ {
if(!BpGetCount(BPMEMORY)) if(!BpGetCount(BPMEMORY))
{ {
dputs(QT_TRANSLATE_NOOP("DBG", "No memory breakpoints to delete!")); dputs(QT_TRANSLATE_NOOP("DBG", "No memory breakpoints to delete!"));
return true; return true;
} }
if(!BpEnumAll(cbDeleteAllMemoryBreakpoints)) //at least one deletion failed if(!BpEnumAll(cbDeleteAllMemoryBreakpoints)) //at least one deletion failed
return false; return false;
dputs(QT_TRANSLATE_NOOP("DBG", "All memory breakpoints deleted!")); dputs(QT_TRANSLATE_NOOP("DBG", "All memory breakpoints deleted!"));
GuiUpdateAllViews(); GuiUpdateAllViews();
return true; return true;
} }
BREAKPOINT found; BREAKPOINT found;
if(BpGet(0, BPMEMORY, argv[1], &found)) //found a breakpoint with name if(BpGet(0, BPMEMORY, argv[1], &found)) //found a breakpoint with name
{ {
duint size; duint size;
MemFindBaseAddr(found.addr, &size); MemFindBaseAddr(found.addr, &size);
@ -775,7 +775,7 @@ bool cbDebugDeleteMemoryBreakpoint(int argc, char* argv[])
return true; return true;
} }
duint addr = 0; duint addr = 0;
if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPMEMORY, 0, &found)) //invalid breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPMEMORY, 0, &found)) //invalid breakpoint
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "No such memory breakpoint \"%s\"\n"), argv[1]); dprintf(QT_TRANSLATE_NOOP("DBG", "No such memory breakpoint \"%s\"\n"), argv[1]);
return false; return false;
@ -799,14 +799,14 @@ bool cbDebugDeleteMemoryBreakpoint(int argc, char* argv[])
bool cbDebugEnableMemoryBreakpoint(int argc, char* argv[]) bool cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
{ {
if(argc < 2) //enable all memory breakpoints if(argc < 2) //enable all memory breakpoints
{ {
if(!BpGetCount(BPMEMORY)) if(!BpGetCount(BPMEMORY))
{ {
dputs(QT_TRANSLATE_NOOP("DBG", "No memory breakpoints to enable!")); dputs(QT_TRANSLATE_NOOP("DBG", "No memory breakpoints to enable!"));
return true; return true;
} }
if(!BpEnumAll(cbEnableAllMemoryBreakpoints)) //at least one enable failed if(!BpEnumAll(cbEnableAllMemoryBreakpoints)) //at least one enable failed
return false; return false;
dputs(QT_TRANSLATE_NOOP("DBG", "All memory breakpoints enabled!")); dputs(QT_TRANSLATE_NOOP("DBG", "All memory breakpoints enabled!"));
GuiUpdateAllViews(); GuiUpdateAllViews();
@ -814,7 +814,7 @@ bool cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
} }
BREAKPOINT found; BREAKPOINT found;
duint addr = 0; duint addr = 0;
if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "No such memory breakpoint \"%s\"\n"), argv[1]); dprintf(QT_TRANSLATE_NOOP("DBG", "No such memory breakpoint \"%s\"\n"), argv[1]);
return false; return false;
@ -844,14 +844,14 @@ bool cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
bool cbDebugDisableMemoryBreakpoint(int argc, char* argv[]) bool cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
{ {
if(argc < 2) //disable all memory breakpoints if(argc < 2) //disable all memory breakpoints
{ {
if(!BpGetCount(BPMEMORY)) if(!BpGetCount(BPMEMORY))
{ {
dputs(QT_TRANSLATE_NOOP("DBG", "No memory breakpoints to disable!")); dputs(QT_TRANSLATE_NOOP("DBG", "No memory breakpoints to disable!"));
return true; return true;
} }
if(!BpEnumAll(cbDisableAllMemoryBreakpoints)) //at least one deletion failed if(!BpEnumAll(cbDisableAllMemoryBreakpoints)) //at least one deletion failed
return false; return false;
dputs(QT_TRANSLATE_NOOP("DBG", "All memory breakpoints disabled!")); dputs(QT_TRANSLATE_NOOP("DBG", "All memory breakpoints disabled!"));
GuiUpdateAllViews(); GuiUpdateAllViews();
@ -859,7 +859,7 @@ bool cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
} }
BREAKPOINT found; BREAKPOINT found;
duint addr = 0; duint addr = 0;
if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "No such memory breakpoint \"%s\"\n"), argv[1]); dprintf(QT_TRANSLATE_NOOP("DBG", "No such memory breakpoint \"%s\"\n"), argv[1]);
return false; return false;
@ -984,7 +984,7 @@ bool cbDebugBcDll(int argc, char* argv[])
dputs(QT_TRANSLATE_NOOP("DBG", "No DLL breakpoints to delete!")); dputs(QT_TRANSLATE_NOOP("DBG", "No DLL breakpoints to delete!"));
return true; return true;
} }
if(!BpEnumAll(cbDeleteAllDllBreakpoints)) //at least one deletion failed if(!BpEnumAll(cbDeleteAllDllBreakpoints)) //at least one deletion failed
return false; return false;
dputs(QT_TRANSLATE_NOOP("DBG", "All DLL breakpoints deleted!")); dputs(QT_TRANSLATE_NOOP("DBG", "All DLL breakpoints deleted!"));
DebugUpdateBreakpointsViewAsync(); DebugUpdateBreakpointsViewAsync();
@ -1010,14 +1010,14 @@ bool cbDebugBcDll(int argc, char* argv[])
bool cbDebugBpDllEnable(int argc, char* argv[]) bool cbDebugBpDllEnable(int argc, char* argv[])
{ {
if(argc < 2) //disable all DLL breakpoints if(argc < 2) //disable all DLL breakpoints
{ {
if(!BpGetCount(BPDLL)) if(!BpGetCount(BPDLL))
{ {
dputs(QT_TRANSLATE_NOOP("DBG", "No DLL breakpoints to enable!")); dputs(QT_TRANSLATE_NOOP("DBG", "No DLL breakpoints to enable!"));
return true; return true;
} }
if(!BpEnumAll(cbEnableAllDllBreakpoints)) //at least one deletion failed if(!BpEnumAll(cbEnableAllDllBreakpoints)) //at least one deletion failed
return false; return false;
dputs(QT_TRANSLATE_NOOP("DBG", "All DLL breakpoints enabled!")); dputs(QT_TRANSLATE_NOOP("DBG", "All DLL breakpoints enabled!"));
GuiUpdateAllViews(); GuiUpdateAllViews();
@ -1025,7 +1025,7 @@ bool cbDebugBpDllEnable(int argc, char* argv[])
} }
BREAKPOINT found; BREAKPOINT found;
duint addr = 0; duint addr = 0;
if(!BpGetAny(BPDLL, argv[1], &found)) //invalid DLL breakpoint if(!BpGetAny(BPDLL, argv[1], &found)) //invalid DLL breakpoint
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "No such DLL breakpoint \"%s\"\n"), argv[1]); dprintf(QT_TRANSLATE_NOOP("DBG", "No such DLL breakpoint \"%s\"\n"), argv[1]);
return false; return false;
@ -1051,14 +1051,14 @@ bool cbDebugBpDllEnable(int argc, char* argv[])
bool cbDebugBpDllDisable(int argc, char* argv[]) bool cbDebugBpDllDisable(int argc, char* argv[])
{ {
if(argc < 2) //disable all DLL breakpoints if(argc < 2) //disable all DLL breakpoints
{ {
if(!BpGetCount(BPDLL)) if(!BpGetCount(BPDLL))
{ {
dputs(QT_TRANSLATE_NOOP("DBG", "No DLL breakpoints to disable!")); dputs(QT_TRANSLATE_NOOP("DBG", "No DLL breakpoints to disable!"));
return true; return true;
} }
if(!BpEnumAll(cbDisableAllDllBreakpoints)) //at least one deletion failed if(!BpEnumAll(cbDisableAllDllBreakpoints)) //at least one deletion failed
return false; return false;
dputs(QT_TRANSLATE_NOOP("DBG", "All DLL breakpoints disabled!")); dputs(QT_TRANSLATE_NOOP("DBG", "All DLL breakpoints disabled!"));
GuiUpdateAllViews(); GuiUpdateAllViews();
@ -1066,7 +1066,7 @@ bool cbDebugBpDllDisable(int argc, char* argv[])
} }
BREAKPOINT found; BREAKPOINT found;
duint addr = 0; duint addr = 0;
if(!BpGetAny(BPDLL, argv[1], &found)) //invalid DLL breakpoint if(!BpGetAny(BPDLL, argv[1], &found)) //invalid DLL breakpoint
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "No such DLL breakpoint \"%s\"\n"), argv[1]); dprintf(QT_TRANSLATE_NOOP("DBG", "No such DLL breakpoint \"%s\"\n"), argv[1]);
return false; return false;
@ -1183,14 +1183,14 @@ bool cbDebugDeleteExceptionBPX(int argc, char* argv[])
dputs(QT_TRANSLATE_NOOP("DBG", "No exception breakpoints to delete!")); dputs(QT_TRANSLATE_NOOP("DBG", "No exception breakpoints to delete!"));
return true; return true;
} }
if(!BpEnumAll(cbDeleteAllExceptionBreakpoints)) //at least one enable failed if(!BpEnumAll(cbDeleteAllExceptionBreakpoints)) //at least one enable failed
return false; return false;
dputs(QT_TRANSLATE_NOOP("DBG", "All exception breakpoints deleted!")); dputs(QT_TRANSLATE_NOOP("DBG", "All exception breakpoints deleted!"));
DebugUpdateBreakpointsViewAsync(); DebugUpdateBreakpointsViewAsync();
return true; return true;
} }
BREAKPOINT found; BREAKPOINT found;
if(BpGet(0, BPEXCEPTION, argv[1], &found)) //found a breakpoint with name if(BpGet(0, BPEXCEPTION, argv[1], &found)) //found a breakpoint with name
{ {
if(!BpDelete(found.addr, BPEXCEPTION)) if(!BpDelete(found.addr, BPEXCEPTION))
{ {
@ -1200,7 +1200,7 @@ bool cbDebugDeleteExceptionBPX(int argc, char* argv[])
return true; return true;
} }
duint addr = 0; duint addr = 0;
if((!ExceptionNameToCode(argv[1], reinterpret_cast<unsigned int*>(&addr)) && !valfromstring(argv[1], &addr)) || !BpGet(addr, BPEXCEPTION, 0, &found)) //invalid breakpoint if((!ExceptionNameToCode(argv[1], reinterpret_cast<unsigned int*>(&addr)) && !valfromstring(argv[1], &addr)) || !BpGet(addr, BPEXCEPTION, 0, &found)) //invalid breakpoint
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "No such exception breakpoint \"%s\"\n"), argv[1]); dprintf(QT_TRANSLATE_NOOP("DBG", "No such exception breakpoint \"%s\"\n"), argv[1]);
return false; return false;
@ -1217,21 +1217,21 @@ bool cbDebugDeleteExceptionBPX(int argc, char* argv[])
bool cbDebugEnableExceptionBPX(int argc, char* argv[]) bool cbDebugEnableExceptionBPX(int argc, char* argv[])
{ {
if(argc < 2) //enable all breakpoints if(argc < 2) //enable all breakpoints
{ {
if(!BpGetCount(BPEXCEPTION)) if(!BpGetCount(BPEXCEPTION))
{ {
dputs(QT_TRANSLATE_NOOP("DBG", "No exception breakpoints to enable!")); dputs(QT_TRANSLATE_NOOP("DBG", "No exception breakpoints to enable!"));
return true; return true;
} }
if(!BpEnumAll(cbEnableAllExceptionBreakpoints)) //at least one enable failed if(!BpEnumAll(cbEnableAllExceptionBreakpoints)) //at least one enable failed
return false; return false;
dputs(QT_TRANSLATE_NOOP("DBG", "All exception breakpoints enabled!")); dputs(QT_TRANSLATE_NOOP("DBG", "All exception breakpoints enabled!"));
DebugUpdateBreakpointsViewAsync(); DebugUpdateBreakpointsViewAsync();
return true; return true;
} }
BREAKPOINT found; BREAKPOINT found;
if(BpGet(0, BPEXCEPTION, argv[1], &found)) //found a breakpoint with name if(BpGet(0, BPEXCEPTION, argv[1], &found)) //found a breakpoint with name
{ {
if(!BpEnable(found.addr, BPEXCEPTION, true)) if(!BpEnable(found.addr, BPEXCEPTION, true))
{ {
@ -1242,7 +1242,7 @@ bool cbDebugEnableExceptionBPX(int argc, char* argv[])
return true; return true;
} }
duint addr = 0; duint addr = 0;
if((!ExceptionNameToCode(argv[1], reinterpret_cast<unsigned int*>(&addr)) && !valfromstring(argv[1], &addr)) || !BpGet(addr, BPEXCEPTION, 0, &found)) //invalid breakpoint if((!ExceptionNameToCode(argv[1], reinterpret_cast<unsigned int*>(&addr)) && !valfromstring(argv[1], &addr)) || !BpGet(addr, BPEXCEPTION, 0, &found)) //invalid breakpoint
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "No such exception breakpoint \"%s\"\n"), argv[1]); dprintf(QT_TRANSLATE_NOOP("DBG", "No such exception breakpoint \"%s\"\n"), argv[1]);
return false; return false;
@ -1265,21 +1265,21 @@ bool cbDebugEnableExceptionBPX(int argc, char* argv[])
bool cbDebugDisableExceptionBPX(int argc, char* argv[]) bool cbDebugDisableExceptionBPX(int argc, char* argv[])
{ {
if(argc < 2) //disable all breakpoints if(argc < 2) //disable all breakpoints
{ {
if(!BpGetCount(BPEXCEPTION)) if(!BpGetCount(BPEXCEPTION))
{ {
dputs(QT_TRANSLATE_NOOP("DBG", "No exception breakpoints to disable!")); dputs(QT_TRANSLATE_NOOP("DBG", "No exception breakpoints to disable!"));
return true; return true;
} }
if(!BpEnumAll(cbDisableAllExceptionBreakpoints)) //at least one deletion failed if(!BpEnumAll(cbDisableAllExceptionBreakpoints)) //at least one deletion failed
return false; return false;
dputs(QT_TRANSLATE_NOOP("DBG", "All exception breakpoints disabled!")); dputs(QT_TRANSLATE_NOOP("DBG", "All exception breakpoints disabled!"));
GuiUpdateAllViews(); GuiUpdateAllViews();
return true; return true;
} }
BREAKPOINT found; BREAKPOINT found;
if(BpGet(0, BPEXCEPTION, argv[1], &found)) //found a breakpoint with name if(BpGet(0, BPEXCEPTION, argv[1], &found)) //found a breakpoint with name
{ {
if(!BpEnable(found.addr, BPEXCEPTION, false)) if(!BpEnable(found.addr, BPEXCEPTION, false))
{ {
@ -1290,7 +1290,7 @@ bool cbDebugDisableExceptionBPX(int argc, char* argv[])
return true; return true;
} }
duint addr = 0; duint addr = 0;
if((!ExceptionNameToCode(argv[1], reinterpret_cast<unsigned int*>(&addr)) && !valfromstring(argv[1], &addr)) || !BpGet(addr, BPEXCEPTION, 0, &found)) //invalid breakpoint if((!ExceptionNameToCode(argv[1], reinterpret_cast<unsigned int*>(&addr)) && !valfromstring(argv[1], &addr)) || !BpGet(addr, BPEXCEPTION, 0, &found)) //invalid breakpoint
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "No such exception breakpoint \"%s\"\n"), argv[1]); dprintf(QT_TRANSLATE_NOOP("DBG", "No such exception breakpoint \"%s\"\n"), argv[1]);
return false; return false;

View File

@ -134,7 +134,7 @@ bool cbDebugStop(int argc, char* argv[])
//history //history
HistoryClear(); HistoryClear();
DWORD BeginTick = GetTickCount(); DWORD BeginTick = GetTickCount();
while(waitislocked(WAITID_STOP)) //custom waiting while(waitislocked(WAITID_STOP)) //custom waiting
{ {
unlock(WAITID_RUN); unlock(WAITID_RUN);
Sleep(100); Sleep(100);

View File

@ -26,7 +26,7 @@ static bool ReadWriteVariable(const char* varname, const std::function<bool(duin
if(!isvar || !valtostring(varname, set_value, true)) if(!isvar || !valtostring(varname, set_value, true))
{ {
duint value; duint value;
if(valfromstring(varname, &value)) //if the var is a value already it's an invalid destination if(valfromstring(varname, &value)) //if the var is a value already it's an invalid destination
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid variable \"%s\"\n"), varname); dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid variable \"%s\"\n"), varname);
return false; return false;
@ -288,7 +288,7 @@ bool cbInstrCmp(int argc, char* argv[])
ezflag = 1; ezflag = 1;
else else
ezflag = 0; ezflag = 0;
if(valuesignedcalc()) //signed comparision if(valuesignedcalc()) //signed comparision
{ {
if((dsint)arg1 < (dsint)arg2) if((dsint)arg1 < (dsint)arg2)
bsflag = 0; bsflag = 0;
@ -313,7 +313,7 @@ bool cbInstrMov(int argc, char* argv[])
if(IsArgumentsLessThan(argc, 3)) if(IsArgumentsLessThan(argc, 3))
return false; return false;
String srcText = argv[2]; String srcText = argv[2];
if(srcText[0] == '#' && srcText[srcText.length() - 1] == '#') //handle mov addr, #DATA# if(srcText[0] == '#' && srcText[srcText.length() - 1] == '#') //handle mov addr, #DATA#
{ {
//do some checks on the data //do some checks on the data
String dataText = srcText.substr(1, srcText.length() - 2); String dataText = srcText.substr(1, srcText.length() - 2);
@ -355,7 +355,7 @@ bool cbInstrMov(int argc, char* argv[])
if(!isvar || !valtostring(argv[1], set_value, true)) if(!isvar || !valtostring(argv[1], set_value, true))
{ {
duint value; duint value;
if(valfromstring(argv[1], &value)) //if the var is a value already it's an invalid destination if(valfromstring(argv[1], &value)) //if the var is a value already it's an invalid destination
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid dest \"%s\"\n"), argv[1]); dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid dest \"%s\"\n"), argv[1]);
return false; return false;

View File

@ -37,12 +37,12 @@ bool cbInstrLog(int argc, char* argv[])
dputs_untranslated(msg); dputs_untranslated(msg);
scriptlog(msg); scriptlog(msg);
}; };
if(argc == 1) //just log newline if(argc == 1) //just log newline
{ {
logputs(""); logputs("");
return true; return true;
} }
if(argc == 2) //inline logging: log "format {rax}" if(argc == 2) //inline logging: log "format {rax}"
{ {
logputs(stringformatinline(argv[1]).c_str()); logputs(stringformatinline(argv[1]).c_str());
} }

View File

@ -284,7 +284,7 @@ bool cbInstrFindAllMem(int argc, char* argv[])
static bool cbFindAsm(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo) static bool cbFindAsm(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
{ {
if(!disasm || !basicinfo) //initialize if(!disasm || !basicinfo) //initialize
{ {
GuiReferenceInitialize(refinfo->name); GuiReferenceInitialize(refinfo->name);
GuiReferenceAddColumn(2 * sizeof(duint), GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Address"))); GuiReferenceAddColumn(2 * sizeof(duint), GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Address")));
@ -372,7 +372,7 @@ struct VALUERANGE
static bool cbRefFind(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo) static bool cbRefFind(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
{ {
if(!disasm || !basicinfo) //initialize if(!disasm || !basicinfo) //initialize
{ {
GuiReferenceInitialize(refinfo->name); GuiReferenceInitialize(refinfo->name);
GuiReferenceAddColumn(sizeof(duint) * 2, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Address"))); GuiReferenceAddColumn(sizeof(duint) * 2, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Address")));
@ -454,7 +454,7 @@ bool cbInstrRefFindRange(int argc, char* argv[])
static bool cbRefStr(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo) static bool cbRefStr(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
{ {
if(!disasm || !basicinfo) //initialize if(!disasm || !basicinfo) //initialize
{ {
GuiReferenceInitialize(refinfo->name); GuiReferenceInitialize(refinfo->name);
GuiReferenceAddColumn(2 * sizeof(duint), GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Address"))); GuiReferenceAddColumn(2 * sizeof(duint), GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Address")));
@ -467,7 +467,7 @@ static bool cbRefStr(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINF
} }
bool found = false; bool found = false;
char string[MAX_STRING_SIZE] = ""; char string[MAX_STRING_SIZE] = "";
if(basicinfo->branch) //branches have no strings (jmp dword [401000]) if(basicinfo->branch) //branches have no strings (jmp dword [401000])
return false; return false;
auto addRef = [&]() auto addRef = [&]()
{ {
@ -524,7 +524,7 @@ bool cbInstrRefStr(int argc, char* argv[])
static bool cbModCallFind(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo) static bool cbModCallFind(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
{ {
if(!disasm || !basicinfo) //initialize if(!disasm || !basicinfo) //initialize
{ {
GuiReferenceInitialize(refinfo->name); GuiReferenceInitialize(refinfo->name);
GuiReferenceAddColumn(2 * sizeof(duint), GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Address"))); GuiReferenceAddColumn(2 * sizeof(duint), GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Address")));
@ -537,7 +537,7 @@ static bool cbModCallFind(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, R
bool found = false; bool found = false;
char label[MAX_LABEL_SIZE] = ""; char label[MAX_LABEL_SIZE] = "";
char module[MAX_MODULE_SIZE] = ""; char module[MAX_MODULE_SIZE] = "";
if(basicinfo->call) //we are looking for calls if(basicinfo->call) //we are looking for calls
{ {
duint ptr = basicinfo->addr > 0 ? basicinfo->addr : basicinfo->memory.value; duint ptr = basicinfo->addr > 0 ? basicinfo->addr : basicinfo->memory.value;
found = DbgGetLabelAt(ptr, SEG_DEFAULT, label) && !LabelGet(ptr, label) && !strstr(label, "sub_") && DbgGetModuleAt(ptr, module); //a non-user label found = DbgGetLabelAt(ptr, SEG_DEFAULT, label) && !LabelGet(ptr, label) && !strstr(label, "sub_") && DbgGetModuleAt(ptr, module); //a non-user label
@ -674,7 +674,7 @@ struct GUIDRefInfo
static bool cbGUIDFind(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo) static bool cbGUIDFind(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
{ {
if(!disasm || !basicinfo) //initialize if(!disasm || !basicinfo) //initialize
{ {
GuiReferenceInitialize(refinfo->name); GuiReferenceInitialize(refinfo->name);
GuiReferenceAddColumn(2 * sizeof(duint), GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Address"))); GuiReferenceAddColumn(2 * sizeof(duint), GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Address")));
@ -942,7 +942,7 @@ static int yaraScanCallback(int message, void* message_data, void* user_data)
pattern = yara_print_string(match->data, match->match_length); pattern = yara_print_string(match->data, match->match_length);
auto offset = duint(match->base + match->offset); auto offset = duint(match->base + match->offset);
duint addr; duint addr;
if(scanInfo->rawFile) //convert raw offset to virtual offset if(scanInfo->rawFile) //convert raw offset to virtual offset
addr = valfileoffsettova(scanInfo->modname, offset); addr = valfileoffsettova(scanInfo->modname, offset);
else else
addr = base + offset; addr = base + offset;
@ -1019,7 +1019,7 @@ bool cbInstrYara(int argc, char* argv[])
base = addr; base = addr;
} }
std::vector<unsigned char> rawFileData; std::vector<unsigned char> rawFileData;
if(rawFile) //read the file from disk if(rawFile) //read the file from disk
{ {
char modPath[MAX_PATH] = ""; char modPath[MAX_PATH] = "";
if(!ModPathFromAddr(base, modPath, MAX_PATH)) if(!ModPathFromAddr(base, modPath, MAX_PATH))
@ -1055,7 +1055,7 @@ bool cbInstrYara(int argc, char* argv[])
if(yr_compiler_create(&yrCompiler) == ERROR_SUCCESS) if(yr_compiler_create(&yrCompiler) == ERROR_SUCCESS)
{ {
yr_compiler_set_callback(yrCompiler, yaraCompilerCallback, 0); yr_compiler_set_callback(yrCompiler, yaraCompilerCallback, 0);
if(yr_compiler_add_string(yrCompiler, rulesContent.c_str(), nullptr) == 0) //no errors found if(yr_compiler_add_string(yrCompiler, rulesContent.c_str(), nullptr) == 0) //no errors found
{ {
YR_RULES* yrRules; YR_RULES* yrRules;
if(yr_compiler_get_rules(yrCompiler, &yrRules) == ERROR_SUCCESS) if(yr_compiler_get_rules(yrCompiler, &yrRules) == ERROR_SUCCESS)

View File

@ -50,7 +50,7 @@ bool cbDebugSwitchthread(int argc, char* argv[])
if(argc > 1) if(argc > 1)
if(!valfromstring(argv[1], &threadid, false)) if(!valfromstring(argv[1], &threadid, false))
return false; return false;
if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), DWORD(threadid)); dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), DWORD(threadid));
return false; return false;
@ -72,7 +72,7 @@ bool cbDebugSuspendthread(int argc, char* argv[])
if(argc > 1) if(argc > 1)
if(!valfromstring(argv[1], &threadid, false)) if(!valfromstring(argv[1], &threadid, false))
return false; return false;
if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), DWORD(threadid)); dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), DWORD(threadid));
return false; return false;
@ -94,7 +94,7 @@ bool cbDebugResumethread(int argc, char* argv[])
if(argc > 1) if(argc > 1)
if(!valfromstring(argv[1], &threadid, false)) if(!valfromstring(argv[1], &threadid, false))
return false; return false;
if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), DWORD(threadid)); dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), DWORD(threadid));
return false; return false;
@ -120,7 +120,7 @@ bool cbDebugKillthread(int argc, char* argv[])
if(argc > 2) if(argc > 2)
if(!valfromstring(argv[2], &exitcode, false)) if(!valfromstring(argv[2], &exitcode, false))
return false; return false;
if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), DWORD(threadid)); dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), DWORD(threadid));
return false; return false;
@ -184,7 +184,7 @@ bool cbDebugSetPriority(int argc, char* argv[])
} }
else else
{ {
switch((int)priority) //check if the priority value is valid switch((int)priority) //check if the priority value is valid
{ {
case THREAD_PRIORITY_NORMAL: case THREAD_PRIORITY_NORMAL:
case THREAD_PRIORITY_ABOVE_NORMAL: case THREAD_PRIORITY_ABOVE_NORMAL:
@ -199,7 +199,7 @@ bool cbDebugSetPriority(int argc, char* argv[])
return false; return false;
} }
} }
if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), DWORD(threadid)); dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), DWORD(threadid));
return false; return false;

View File

@ -19,7 +19,7 @@ bool cbBadCmd(int argc, char* argv[])
int valsize = 0; int valsize = 0;
bool isvar = false; bool isvar = false;
bool hexonly = false; bool hexonly = false;
if(valfromstring(*argv, &value, false, false, &valsize, &isvar, &hexonly, true)) //dump variable/value/register/etc if(valfromstring(*argv, &value, false, false, &valsize, &isvar, &hexonly, true)) //dump variable/value/register/etc
{ {
varset("$ans", value, true); varset("$ans", value, true);
if(valsize) if(valsize)
@ -30,11 +30,11 @@ bool cbBadCmd(int argc, char* argv[])
auto symbolic = SymGetSymbolicName(value); auto symbolic = SymGetSymbolicName(value);
if(symbolic.length()) if(symbolic.length())
symbolic = " " + symbolic; symbolic = " " + symbolic;
if(isvar) // and *cmd!='.' and *cmd!='x') //prevent stupid 0=0 stuff if(isvar) // and *cmd!='.' and *cmd!='x') //prevent stupid 0=0 stuff
{ {
if(value > 9 && !hexonly) if(value > 9 && !hexonly)
{ {
if(!valuesignedcalc()) //signed numbers if(!valuesignedcalc()) //signed numbers
#ifdef _WIN64 #ifdef _WIN64
sprintf_s(format_str, "%%s=%%.%dllX (%%llud)%%s\n", valsize); // TODO: This and the following statements use "%llX" for a "int"-typed variable. Maybe we can use "%X" everywhere? sprintf_s(format_str, "%%s=%%.%dllX (%%llud)%%s\n", valsize); // TODO: This and the following statements use "%llX" for a "int"-typed variable. Maybe we can use "%X" everywhere?
#else //x86 #else //x86
@ -58,7 +58,7 @@ bool cbBadCmd(int argc, char* argv[])
{ {
if(value > 9 && !hexonly) if(value > 9 && !hexonly)
{ {
if(!valuesignedcalc()) //signed numbers if(!valuesignedcalc()) //signed numbers
#ifdef _WIN64 #ifdef _WIN64
sprintf_s(format_str, "%%s=%%.%dllX (%%llud)%%s\n", valsize); sprintf_s(format_str, "%%s=%%.%dllX (%%llud)%%s\n", valsize);
#else //x86 #else //x86
@ -354,31 +354,31 @@ bool cbInstrVisualize(int argc, char* argv[])
const unsigned char* curData = (addr >= _base && addr < _base + _size) ? _data() + (addr - _base) : nullptr; const unsigned char* curData = (addr >= _base && addr < _base + _size) ? _data() + (addr - _base) : nullptr;
if(_cp.Disassemble(addr, curData, MAX_DISASM_BUFFER)) if(_cp.Disassemble(addr, curData, MAX_DISASM_BUFFER))
{ {
if(addr + _cp.Size() > maxaddr) //we went past the maximum allowed address if(addr + _cp.Size() > maxaddr) //we went past the maximum allowed address
break; break;
const cs_x86_op & operand = _cp.x86().operands[0]; const cs_x86_op & operand = _cp.x86().operands[0];
if((_cp.InGroup(CS_GRP_JUMP) || _cp.IsLoop()) && operand.type == X86_OP_IMM) //jump if((_cp.InGroup(CS_GRP_JUMP) || _cp.IsLoop()) && operand.type == X86_OP_IMM) //jump
{ {
duint dest = (duint)operand.imm; duint dest = (duint)operand.imm;
if(dest >= maxaddr) //jump across function boundaries if(dest >= maxaddr) //jump across function boundaries
{ {
//currently unused //currently unused
} }
else if(dest > addr && dest > fardest) //save the farthest JXX destination forward else if(dest > addr && dest > fardest) //save the farthest JXX destination forward
{ {
fardest = dest; fardest = dest;
} }
else if(end && dest < end && _cp.GetId() == X86_INS_JMP) //save the last JMP backwards else if(end && dest < end && _cp.GetId() == X86_INS_JMP) //save the last JMP backwards
{ {
jumpback = addr; jumpback = addr;
} }
} }
else if(_cp.InGroup(CS_GRP_RET)) //possible function end? else if(_cp.InGroup(CS_GRP_RET)) //possible function end?
{ {
end = addr; end = addr;
if(fardest < addr) //we stop if the farthest JXX destination forward is before this RET if(fardest < addr) //we stop if the farthest JXX destination forward is before this RET
break; break;
} }

View File

@ -641,7 +641,7 @@ static void printSoftBpInfo(const BREAKPOINT & bp)
static void printHwBpInfo(const BREAKPOINT & bp) static void printHwBpInfo(const BREAKPOINT & bp)
{ {
const char* bpsize = ""; const char* bpsize = "";
switch(TITANGETSIZE(bp.titantype)) //size switch(TITANGETSIZE(bp.titantype)) //size
{ {
case UE_HARDWARE_SIZE_1: case UE_HARDWARE_SIZE_1:
bpsize = "byte, "; bpsize = "byte, ";
@ -659,7 +659,7 @@ static void printHwBpInfo(const BREAKPOINT & bp)
#endif //_WIN64 #endif //_WIN64
} }
char* bptype; char* bptype;
switch(TITANGETTYPE(bp.titantype)) //type switch(TITANGETTYPE(bp.titantype)) //type
{ {
case UE_HARDWARE_EXECUTE: case UE_HARDWARE_EXECUTE:
bptype = _strdup(GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "execute"))); bptype = _strdup(GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "execute")));
@ -765,9 +765,9 @@ static void printExceptionBpInfo(const BREAKPOINT & bp, duint CIP)
static bool getConditionValue(const char* expression) static bool getConditionValue(const char* expression)
{ {
auto word = *(uint16*)expression; auto word = *(uint16*)expression;
if(word == '0') // short circuit for condition "0\0" if(word == '0') // short circuit for condition "0\0"
return false; return false;
if(word == '1') //short circuit for condition "1\0" if(word == '1') //short circuit for condition "1\0"
return true; return true;
duint value; duint value;
if(valfromstring(expression, &value)) if(valfromstring(expression, &value))
@ -862,7 +862,7 @@ static void cbGenericBreakpoint(BP_TYPE bptype, void* ExceptionAddress = nullptr
default: default:
break; break;
} }
if(!(bpPtr && bpPtr->enabled)) //invalid / disabled breakpoint hit (most likely a bug) if(!(bpPtr && bpPtr->enabled)) //invalid / disabled breakpoint hit (most likely a bug)
{ {
if(bptype != BPDLL || !BpUpdateDllPath(reinterpret_cast<const char*>(ExceptionAddress), &bpPtr)) if(bptype != BPDLL || !BpUpdateDllPath(reinterpret_cast<const char*>(ExceptionAddress), &bpPtr))
{ {
@ -899,7 +899,7 @@ static void cbGenericBreakpoint(BP_TYPE bptype, void* ExceptionAddress = nullptr
breakCondition = getConditionValue(bp.breakCondition); breakCondition = getConditionValue(bp.breakCondition);
else else
breakCondition = true; //break if no condition is set breakCondition = true; //break if no condition is set
if(bp.fastResume && !breakCondition) // fast resume: ignore GUI/Script/Plugin/Other if the debugger would not break if(bp.fastResume && !breakCondition) // fast resume: ignore GUI/Script/Plugin/Other if the debugger would not break
return; return;
if(*bp.logCondition) if(*bp.logCondition)
logCondition = getConditionValue(bp.logCondition); logCondition = getConditionValue(bp.logCondition);
@ -929,11 +929,11 @@ static void cbGenericBreakpoint(BP_TYPE bptype, void* ExceptionAddress = nullptr
// Update breakpoint view // Update breakpoint view
DebugUpdateBreakpointsViewAsync(); DebugUpdateBreakpointsViewAsync();
if(*bp.logText && logCondition) //log if(*bp.logText && logCondition) //log
{ {
dprintf_untranslated("%s\n", stringformatinline(bp.logText).c_str()); dprintf_untranslated("%s\n", stringformatinline(bp.logText).c_str());
} }
if(*bp.commandText && commandCondition) //command if(*bp.commandText && commandCondition) //command
{ {
//TODO: commands like run/step etc will fuck up your shit //TODO: commands like run/step etc will fuck up your shit
varset("$breakpointcondition", breakCondition ? 1 : 0, false); varset("$breakpointcondition", breakCondition ? 1 : 0, false);
@ -951,7 +951,7 @@ static void cbGenericBreakpoint(BP_TYPE bptype, void* ExceptionAddress = nullptr
breakCondition = false; breakCondition = false;
} }
} }
if(breakCondition) //break the debugger if(breakCondition) //break the debugger
{ {
dbgsetforeground(); dbgsetforeground();
dbgsetskipexceptions(false); dbgsetskipexceptions(false);
@ -1860,7 +1860,7 @@ static void cbOutputDebugString(OUTPUT_DEBUG_STRING_INFO* DebugString)
if(MemRead((duint)DebugString->lpDebugStringData, DebugText(), DebugString->nDebugStringLength)) if(MemRead((duint)DebugString->lpDebugStringData, DebugText(), DebugString->nDebugStringLength))
{ {
String str = String(DebugText()); String str = String(DebugText());
if(str != lastDebugText) //fix for every string being printed twice if(str != lastDebugText) //fix for every string being printed twice
{ {
if(str != "\n") if(str != "\n")
dprintf(QT_TRANSLATE_NOOP("DBG", "DebugString: \"%s\"\n"), StringUtils::Escape(str).c_str()); dprintf(QT_TRANSLATE_NOOP("DBG", "DebugString: \"%s\"\n"), StringUtils::Escape(str).c_str());
@ -1977,7 +1977,7 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData)
if(bVerboseExceptionLogging) if(bVerboseExceptionLogging)
DbgCmdExecDirect("exinfo"); //show extended exception information DbgCmdExecDirect("exinfo"); //show extended exception information
auto exceptionName = ExceptionCodeToName(ExceptionCode); auto exceptionName = ExceptionCodeToName(ExceptionCode);
if(!exceptionName.size()) //if no exception was found, try the error codes (RPC_S_*) if(!exceptionName.size()) //if no exception was found, try the error codes (RPC_S_*)
exceptionName = ErrorCodeToName(ExceptionCode); exceptionName = ErrorCodeToName(ExceptionCode);
if(ExceptionData->dwFirstChance) //first chance exception if(ExceptionData->dwFirstChance) //first chance exception
{ {
@ -2134,9 +2134,9 @@ bool dbglistprocesses(std::vector<PROCESSENTRY32>* infoList, std::vector<std::st
char* nextSlash = strchr(exeNameInCmdTmp, '\\') ? strchr(exeNameInCmdTmp, '\\') : char* nextSlash = strchr(exeNameInCmdTmp, '\\') ? strchr(exeNameInCmdTmp, '\\') :
strchr(exeNameInCmdTmp, '/') ? strchr(exeNameInCmdTmp, '/') : NULL; strchr(exeNameInCmdTmp, '/') ? strchr(exeNameInCmdTmp, '/') : NULL;
if(nextSlash && posEnum.posEnum == NO_QOUTES) //if there NO_QOUTES, then the path to PE in cmdline can't contain spaces if(nextSlash && posEnum.posEnum == NO_QOUTES) //if there NO_QOUTES, then the path to PE in cmdline can't contain spaces
{ {
if(strchr(exeNameInCmdTmp, ' ') < nextSlash) //slash is in arguments if(strchr(exeNameInCmdTmp, ' ') < nextSlash) //slash is in arguments
{ {
peNameInCmd = exeNameInCmdTmp; peNameInCmd = exeNameInCmdTmp;
break; break;
@ -2146,7 +2146,7 @@ bool dbglistprocesses(std::vector<PROCESSENTRY32>* infoList, std::vector<std::st
} }
else if(nextSlash && posEnum.posEnum == QOUTES_AROUND_EXE) else if(nextSlash && posEnum.posEnum == QOUTES_AROUND_EXE)
{ {
if((cmdline + posEnum.secondPos) < nextSlash) //slash is in arguments if((cmdline + posEnum.secondPos) < nextSlash) //slash is in arguments
{ {
peNameInCmd = exeNameInCmdTmp; peNameInCmd = exeNameInCmdTmp;
break; break;
@ -2181,9 +2181,9 @@ bool dbglistprocesses(std::vector<PROCESSENTRY32>* infoList, std::vector<std::st
char* nextSlash = strchr(basicNameInCmdTmp, '\\') ? strchr(basicNameInCmdTmp, '\\') : char* nextSlash = strchr(basicNameInCmdTmp, '\\') ? strchr(basicNameInCmdTmp, '\\') :
strchr(basicNameInCmdTmp, '/') ? strchr(basicNameInCmdTmp, '/') : NULL; strchr(basicNameInCmdTmp, '/') ? strchr(basicNameInCmdTmp, '/') : NULL;
if(nextSlash && posEnum.posEnum == NO_QOUTES) //if there NO_QOUTES, then the path to PE in cmdline can't contain spaces if(nextSlash && posEnum.posEnum == NO_QOUTES) //if there NO_QOUTES, then the path to PE in cmdline can't contain spaces
{ {
if(strchr(basicNameInCmdTmp, ' ') < nextSlash) //slash is in arguments if(strchr(basicNameInCmdTmp, ' ') < nextSlash) //slash is in arguments
{ {
peNameInCmd = basicNameInCmdTmp; peNameInCmd = basicNameInCmdTmp;
break; break;
@ -2193,7 +2193,7 @@ bool dbglistprocesses(std::vector<PROCESSENTRY32>* infoList, std::vector<std::st
} }
else if(nextSlash && posEnum.posEnum == QOUTES_AROUND_EXE) else if(nextSlash && posEnum.posEnum == QOUTES_AROUND_EXE)
{ {
if((cmdline + posEnum.secondPos) < nextSlash) //slash is in arguments if((cmdline + posEnum.secondPos) < nextSlash) //slash is in arguments
{ {
peNameInCmd = basicNameInCmdTmp; peNameInCmd = basicNameInCmdTmp;
break; break;

View File

@ -72,7 +72,7 @@ void fillbasicinfo(Capstone* cp, BASIC_INSTRUCTION_INFO* basicinfo, bool instrTe
if(instrText) if(instrText)
strcpy_s(basicinfo->memory.mnemonic, cp->OperandText(i).c_str()); strcpy_s(basicinfo->memory.mnemonic, cp->OperandText(i).c_str());
basicinfo->memory.size = MEMORY_SIZE(op.size); basicinfo->memory.size = MEMORY_SIZE(op.size);
if(op.mem.base == X86_REG_RIP) //rip-relative if(op.mem.base == X86_REG_RIP) //rip-relative
{ {
basicinfo->memory.value = ULONG_PTR(cp->Address() + op.mem.disp + basicinfo->size); basicinfo->memory.value = ULONG_PTR(cp->Address() + op.mem.disp + basicinfo->size);
basicinfo->type |= TYPE_MEMORY; basicinfo->type |= TYPE_MEMORY;

View File

@ -64,7 +64,7 @@ bool ExHandlerGetSEH(std::vector<duint> & Entries)
while(addr_ExRegRecord != 0xFFFFFFFF && MAX_DEPTH) while(addr_ExRegRecord != 0xFFFFFFFF && MAX_DEPTH)
{ {
Entries.push_back(addr_ExRegRecord); Entries.push_back(addr_ExRegRecord);
if(!MemRead(addr_ExRegRecord , &sehr, sizeof(EXCEPTION_REGISTRATION_RECORD))) if(!MemRead(addr_ExRegRecord, &sehr, sizeof(EXCEPTION_REGISTRATION_RECORD)))
break; break;
addr_ExRegRecord = (duint)sehr.Next; addr_ExRegRecord = (duint)sehr.Next;
MAX_DEPTH--; MAX_DEPTH--;

View File

@ -395,7 +395,7 @@ void ExpressionParser::shuntingYard()
case Token::Type::Comma: case Token::Type::Comma:
while(true) while(true)
{ {
if(stack.empty()) //empty stack = problems if(stack.empty()) //empty stack = problems
{ {
mIsValidExpression = false; mIsValidExpression = false;
return; return;
@ -414,14 +414,14 @@ void ExpressionParser::shuntingYard()
{ {
while(true) while(true)
{ {
if(stack.empty()) //empty stack = bracket mismatch if(stack.empty()) //empty stack = bracket mismatch
{ {
mIsValidExpression = false; mIsValidExpression = false;
return; return;
} }
auto curToken = stack[stack.size() - 1]; auto curToken = stack[stack.size() - 1];
stack.pop_back(); stack.pop_back();
if(curToken.type() == Token::Type::OpenBracket) //the bracket is already popped here if(curToken.type() == Token::Type::OpenBracket) //the bracket is already popped here
break; break;
queue.push_back(curToken); queue.push_back(curToken);
} }
@ -456,7 +456,7 @@ void ExpressionParser::shuntingYard()
while(!stack.empty()) while(!stack.empty())
{ {
const auto & curToken = stack[stack.size() - 1]; const auto & curToken = stack[stack.size() - 1];
if(curToken.type() == Token::Type::OpenBracket || curToken.type() == Token::Type::CloseBracket) //brackets on the stack means invalid expression if(curToken.type() == Token::Type::OpenBracket || curToken.type() == Token::Type::CloseBracket) //brackets on the stack means invalid expression
{ {
mIsValidExpression = false; mIsValidExpression = false;
return; return;

View File

@ -84,7 +84,7 @@ void MemUpdateMap()
else else
{ {
// Otherwise append the page to the last created entry // Otherwise append the page to the last created entry
if(pageVector.size()) //make sure to not dereference an invalid pointer if(pageVector.size()) //make sure to not dereference an invalid pointer
pageVector.back().mbi.RegionSize += mbi.RegionSize; pageVector.back().mbi.RegionSize += mbi.RegionSize;
} }
} }
@ -106,7 +106,7 @@ void MemUpdateMap()
for(int i = pagecount - 1; i > -1; i--) for(int i = pagecount - 1; i > -1; i--)
{ {
auto & currentPage = pageVector.at(i); auto & currentPage = pageVector.at(i);
if(!currentPage.info[0] || (scmp(curMod, currentPage.info) && !bListAllPages)) //there is a module if(!currentPage.info[0] || (scmp(curMod, currentPage.info) && !bListAllPages)) //there is a module
continue; //skip non-modules continue; //skip non-modules
strcpy(curMod, pageVector.at(i).info); strcpy(curMod, pageVector.at(i).info);
if(!ModBaseFromName(currentPage.info)) if(!ModBaseFromName(currentPage.info))
@ -116,9 +116,9 @@ void MemUpdateMap()
if(!ModSectionsFromAddr(base, &sections)) if(!ModSectionsFromAddr(base, &sections))
continue; continue;
int SectionNumber = (int)sections.size(); int SectionNumber = (int)sections.size();
if(!SectionNumber) //no sections = skip if(!SectionNumber) //no sections = skip
continue; continue;
if(!bListAllPages) //normal view if(!bListAllPages) //normal view
{ {
MEMPAGE newPage; MEMPAGE newPage;
//remove the current module page (page = size of module at this point) and insert the module sections //remove the current module page (page = size of module at this point) and insert the module sections
@ -129,7 +129,7 @@ void MemUpdateMap()
memset(&newPage, 0, sizeof(MEMPAGE)); memset(&newPage, 0, sizeof(MEMPAGE));
VirtualQueryEx(fdProcessInfo->hProcess, (LPCVOID)currentSection.addr, &newPage.mbi, sizeof(MEMORY_BASIC_INFORMATION)); VirtualQueryEx(fdProcessInfo->hProcess, (LPCVOID)currentSection.addr, &newPage.mbi, sizeof(MEMORY_BASIC_INFORMATION));
duint SectionSize = currentSection.size; duint SectionSize = currentSection.size;
if(SectionSize % PAGE_SIZE) //unaligned page size if(SectionSize % PAGE_SIZE) //unaligned page size
SectionSize += PAGE_SIZE - (SectionSize % PAGE_SIZE); //fix this SectionSize += PAGE_SIZE - (SectionSize % PAGE_SIZE); //fix this
if(SectionSize) if(SectionSize)
newPage.mbi.RegionSize = SectionSize; newPage.mbi.RegionSize = SectionSize;
@ -151,16 +151,16 @@ void MemUpdateMap()
const auto & currentSection = sections.at(j); const auto & currentSection = sections.at(j);
duint secStart = currentSection.addr; duint secStart = currentSection.addr;
duint SectionSize = currentSection.size; duint SectionSize = currentSection.size;
if(SectionSize % PAGE_SIZE) //unaligned page size if(SectionSize % PAGE_SIZE) //unaligned page size
SectionSize += PAGE_SIZE - (SectionSize % PAGE_SIZE); //fix this SectionSize += PAGE_SIZE - (SectionSize % PAGE_SIZE); //fix this
duint secEnd = secStart + SectionSize; duint secEnd = secStart + SectionSize;
if(secStart >= start && secEnd <= end) //section is inside the memory page if(secStart >= start && secEnd <= end) //section is inside the memory page
{ {
if(k) if(k)
k += sprintf_s(currentPage.info + k, MAX_MODULE_SIZE - k, ","); k += sprintf_s(currentPage.info + k, MAX_MODULE_SIZE - k, ",");
k += sprintf_s(currentPage.info + k, MAX_MODULE_SIZE - k, " \"%s\"", currentSection.name); k += sprintf_s(currentPage.info + k, MAX_MODULE_SIZE - k, " \"%s\"", currentSection.name);
} }
else if(start >= secStart && end <= secEnd) //memory page is inside the section else if(start >= secStart && end <= secEnd) //memory page is inside the section
{ {
if(k) if(k)
k += sprintf_s(currentPage.info + k, MAX_MODULE_SIZE - k, ","); k += sprintf_s(currentPage.info + k, MAX_MODULE_SIZE - k, ",");
@ -523,7 +523,7 @@ bool MemGetPageRights(duint Address, char* Rights)
bool MemPageRightsToString(DWORD Protect, char* Rights) bool MemPageRightsToString(DWORD Protect, char* Rights)
{ {
if(!Protect) //reserved pages don't have a protection (https://goo.gl/Izkk0c) if(!Protect) //reserved pages don't have a protection (https://goo.gl/Izkk0c)
{ {
*Rights = '\0'; *Rights = '\0';
return true; return true;

View File

@ -62,19 +62,19 @@ String MnemonicHelp::getUniversalMnemonic(const String & mnem)
}; };
if(mnemLower == "jmp") if(mnemLower == "jmp")
return mnemLower; return mnemLower;
if(mnemLower == "loop") //LOOP if(mnemLower == "loop") //LOOP
return mnemLower; return mnemLower;
if(startsWith("int")) //INT n if(startsWith("int")) //INT n
return "int n"; return "int n";
if(startsWith("cmov")) //CMOVcc if(startsWith("cmov")) //CMOVcc
return "cmovcc"; return "cmovcc";
if(startsWith("fcmov")) //FCMOVcc if(startsWith("fcmov")) //FCMOVcc
return "fcmovcc"; return "fcmovcc";
if(startsWith("j")) //Jcc if(startsWith("j")) //Jcc
return "jcc"; return "jcc";
if(startsWith("loop")) //LOOPcc if(startsWith("loop")) //LOOPcc
return "loopcc"; return "loopcc";
if(startsWith("set")) //SETcc if(startsWith("set")) //SETcc
return "setcc"; return "setcc";
return mnemLower; return mnemLower;
} }
@ -90,7 +90,7 @@ String MnemonicHelp::getDescription(const char* mnem, int depth)
auto found = MnemonicMap.find(mnemuni); auto found = MnemonicMap.find(mnemuni);
if(found == MnemonicMap.end()) if(found == MnemonicMap.end())
{ {
if(mnemuni[0] == 'v') //v/vm if(mnemuni[0] == 'v') //v/vm
{ {
found = MnemonicMap.find(mnemuni.c_str() + 1); found = MnemonicMap.find(mnemuni.c_str() + 1);
if(found == MnemonicMap.end()) if(found == MnemonicMap.end())
@ -100,7 +100,7 @@ String MnemonicHelp::getDescription(const char* mnem, int depth)
return ""; return "";
} }
const auto & description = found->second; const auto & description = found->second;
if(StringUtils::StartsWith(description, "-R:")) //redirect if(StringUtils::StartsWith(description, "-R:")) //redirect
return getDescription(description.c_str() + 3, depth + 1); return getDescription(description.c_str() + 3, depth + 1);
return description; return description;
} }
@ -116,12 +116,12 @@ String MnemonicHelp::getBriefDescription(const char* mnem)
auto found = MnemonicBriefMap.find(mnemLower); auto found = MnemonicBriefMap.find(mnemLower);
if(found == MnemonicBriefMap.end()) if(found == MnemonicBriefMap.end())
{ {
if(mnemLower[0] == 'v') //v/vm if(mnemLower[0] == 'v') //v/vm
{ {
found = MnemonicBriefMap.find(mnemLower.c_str() + 1); found = MnemonicBriefMap.find(mnemLower.c_str() + 1);
if(found != MnemonicBriefMap.end()) if(found != MnemonicBriefMap.end())
{ {
if(mnemLower.length() > 1 && mnemLower[1] == 'm') //vm if(mnemLower.length() > 1 && mnemLower[1] == 'm') //vm
return "vm " + found->second; return "vm " + found->second;
return "vector " + found->second; return "vector " + found->second;
} }

View File

@ -151,15 +151,15 @@ bool patternsnr(unsigned char* data, size_t datasize, const char* searchpattern,
size_t patternfind(const unsigned char* data, size_t datasize, const std::vector<PatternByte> & pattern) size_t patternfind(const unsigned char* data, size_t datasize, const std::vector<PatternByte> & pattern)
{ {
size_t searchpatternsize = pattern.size(); size_t searchpatternsize = pattern.size();
for(size_t i = 0, pos = 0; i < datasize; i++) //search for the pattern for(size_t i = 0, pos = 0; i < datasize; i++) //search for the pattern
{ {
if(patternmatchbyte(data[i], pattern.at(pos))) //check if our pattern matches the current byte if(patternmatchbyte(data[i], pattern.at(pos))) //check if our pattern matches the current byte
{ {
pos++; pos++;
if(pos == searchpatternsize) //everything matched if(pos == searchpatternsize) //everything matched
return i - searchpatternsize + 1; return i - searchpatternsize + 1;
} }
else if(pos > 0) //fix by Computer_Angel else if(pos > 0) //fix by Computer_Angel
{ {
i -= pos; i -= pos;
pos = 0; //reset current pattern position pos = 0; //reset current pattern position

View File

@ -144,7 +144,7 @@ bool pluginload(const char* pluginName, bool loadall)
SetCurrentDirectoryW(currentDir); SetCurrentDirectoryW(currentDir);
return false; return false;
} }
if(pluginData.initStruct.sdkVersion < PLUG_SDKVERSION) //the plugin SDK is not compatible if(pluginData.initStruct.sdkVersion < PLUG_SDKVERSION) //the plugin SDK is not compatible
{ {
dprintf(QT_TRANSLATE_NOOP("DBG", "[PLUGIN] %s is incompatible with this SDK version\n"), pluginData.initStruct.pluginName); dprintf(QT_TRANSLATE_NOOP("DBG", "[PLUGIN] %s is incompatible with this SDK version\n"), pluginData.initStruct.pluginName);
for(int i = CB_INITDEBUG; i < CB_LAST; i++) for(int i = CB_INITDEBUG; i < CB_LAST; i++)

View File

@ -117,7 +117,7 @@ int RefFind(duint Address, duint Size, CBREF Callback, void* UserData, bool Sile
GuiReferenceSetProgress(percent); GuiReferenceSetProgress(percent);
}, disasmText); }, disasmText);
} }
else if(type == ALL_MODULES) // Search in all Modules else if(type == ALL_MODULES) // Search in all Modules
{ {
bool initCallBack = true; bool initCallBack = true;
std::vector<MODINFO> modList; std::vector<MODINFO> modList;

View File

@ -391,7 +391,7 @@ struct AddrInfoHashMap : SerializableModuleHashMap<TLock, TValue, TSerializer>
{ {
this->DeleteRangeWhere(start, end, [manual](duint start, duint end, const TValue & value) this->DeleteRangeWhere(start, end, [manual](duint start, duint end, const TValue & value)
{ {
if(manual ? !value.manual : value.manual) //ignore non-matching entries if(manual ? !value.manual : value.manual) //ignore non-matching entries
return false; return false;
return value.addr >= start && value.addr < end; return value.addr >= start && value.addr < end;
}); });

View File

@ -175,7 +175,7 @@ static bool scriptcreatelinemap(const char* filename)
{ {
cur.type = lineempty; cur.type = lineempty;
} }
else if(!strncmp(cur.raw, "//", 2) || *cur.raw == ';') //comment else if(!strncmp(cur.raw, "//", 2) || *cur.raw == ';') //comment
{ {
cur.type = linecomment; cur.type = linecomment;
strcpy_s(cur.u.comment, cur.raw); strcpy_s(cur.u.comment, cur.raw);
@ -234,7 +234,7 @@ static bool scriptcreatelinemap(const char* filename)
for(int i = 0; i < linemapsize; i++) for(int i = 0; i < linemapsize; i++)
{ {
auto & currentLine = linemap.at(i); auto & currentLine = linemap.at(i);
if(currentLine.type == linebranch) //invalid branch label if(currentLine.type == linebranch) //invalid branch label
{ {
int labelline = scriptlabelfind(currentLine.u.branch.branchlabel); int labelline = scriptlabelfind(currentLine.u.branch.branchlabel);
if(!labelline) //invalid branch label if(!labelline) //invalid branch label

View File

@ -261,12 +261,12 @@ String stringformatinline(String format)
continue; continue;
} }
//handle actual formatting //handle actual formatting
if(format[i] == '{' && !inFormatter) //opening bracket if(format[i] == '{' && !inFormatter) //opening bracket
{ {
inFormatter = true; inFormatter = true;
formatString.clear(); formatString.clear();
} }
else if(format[i] == '}' && inFormatter) //closing bracket else if(format[i] == '}' && inFormatter) //closing bracket
{ {
inFormatter = false; inFormatter = false;
if(formatString.length()) if(formatString.length())
@ -275,7 +275,7 @@ String stringformatinline(String format)
formatString.clear(); formatString.clear();
} }
} }
else if(inFormatter) //inside brackets else if(inFormatter) //inside brackets
formatString += format[i]; formatString += format[i];
else //outside brackets else //outside brackets
output += format[i]; output += format[i];

View File

@ -53,7 +53,7 @@ String StringUtils::Escape(unsigned char ch)
case '\"': case '\"':
return "\\\""; return "\\\"";
default: default:
if(!isprint(ch)) //unknown unprintable character if(!isprint(ch)) //unknown unprintable character
sprintf_s(buf, "\\x%02X", ch); sprintf_s(buf, "\\x%02X", ch);
else else
*buf = ch; *buf = ch;
@ -143,7 +143,7 @@ String StringUtils::Escape(const String & s)
memcpy(buf, s.c_str() + i, UTF8CharSize); memcpy(buf, s.c_str() + i, UTF8CharSize);
i += UTF8CharSize - 1; i += UTF8CharSize - 1;
} }
else if(!isprint(ch)) //unknown unprintable character else if(!isprint(ch)) //unknown unprintable character
sprintf_s(buf, "\\x%02X", ch); sprintf_s(buf, "\\x%02X", ch);
else else
*buf = ch; *buf = ch;
@ -181,7 +181,7 @@ bool StringUtils::Unescape(const String & s, String & result, bool quoted)
} }
if(mLastChar == '\r' || mLastChar == '\n') if(mLastChar == '\r' || mLastChar == '\n')
return false; //unexpected newline in string literal (1) return false; //unexpected newline in string literal (1)
if(quoted && mLastChar == '\"') //end of quoted string literal if(quoted && mLastChar == '\"') //end of quoted string literal
break; break;
if(mLastChar == '\\') //escape sequence if(mLastChar == '\\') //escape sequence
{ {
@ -208,7 +208,7 @@ bool StringUtils::Unescape(const String & s, String & result, bool quoted)
mLastChar = '\v'; mLastChar = '\v';
else if(mLastChar == '0') else if(mLastChar == '0')
mLastChar = '\0'; mLastChar = '\0';
else if(mLastChar == 'x') //\xHH else if(mLastChar == 'x') //\xHH
{ {
auto ch1 = nextChar(); auto ch1 = nextChar();
auto ch2 = nextChar(); auto ch2 = nextChar();

View File

@ -64,7 +64,7 @@ template<class S1, class S2> struct concat;
template<unsigned... I1, unsigned... I2> template<unsigned... I1, unsigned... I2>
struct concat<seq<I1...>, seq<I2...>> struct concat<seq<I1...>, seq<I2...>>
: seq < I1..., (sizeof...(I1) + I2)... > {}; : seq < I1..., (sizeof...(I1) + I2)... > {};
template<class S1, class S2> using Concat = Invoke<concat<S1, S2>>; template<class S1, class S2> using Concat = Invoke<concat<S1, S2>>;

View File

@ -85,7 +85,7 @@ bool TypeManager::AddMember(const std::string & parent, const std::string & type
m.type = type; m.type = type;
m.offset = offset; m.offset = offset;
if(offset >= 0) //user-defined offset if(offset >= 0) //user-defined offset
{ {
if(offset < s.size) if(offset < s.size)
return false; return false;
@ -363,7 +363,7 @@ bool TypeManager::visitMember(const Member & root, Visitor & visitor) const
{ {
if(!isDefined(t.pointto)) if(!isDefined(t.pointto))
return false; return false;
if(visitor.visitPtr(root, t)) //allow the visitor to bail out if(visitor.visitPtr(root, t)) //allow the visitor to bail out
{ {
if(!Visit(t.pointto, "*" + root.name, visitor)) if(!Visit(t.pointto, "*" + root.name, visitor))
return false; return false;

View File

@ -1607,7 +1607,7 @@ bool valfromstring_noexpr(const char* string, duint* value, bool silent, bool ba
int read_size = sizeof(duint); int read_size = sizeof(duint);
int prefix_size = 1; int prefix_size = 1;
size_t seg_offset = 0; size_t seg_offset = 0;
if(string[1] == ':') //n:[ (number of bytes to read) if(string[1] == ':') //n:[ (number of bytes to read)
{ {
prefix_size = 3; prefix_size = 3;
int new_size = string[0] - '0'; int new_size = string[0] - '0';
@ -1617,7 +1617,7 @@ bool valfromstring_noexpr(const char* string, duint* value, bool silent, bool ba
else if(string[1] == 's' && string[2] == ':') else if(string[1] == 's' && string[2] == ':')
{ {
prefix_size = 4; prefix_size = 4;
if(string[0] == 'f') // fs:[...] if(string[0] == 'f') // fs:[...]
{ {
// TODO: get real segment offset instead of assuming them // TODO: get real segment offset instead of assuming them
#ifdef _WIN64 #ifdef _WIN64
@ -1626,7 +1626,7 @@ bool valfromstring_noexpr(const char* string, duint* value, bool silent, bool ba
seg_offset = (size_t)GetTEBLocation(hActiveThread); seg_offset = (size_t)GetTEBLocation(hActiveThread);
#endif //_WIN64 #endif //_WIN64
} }
else if(string[0] == 'g') // gs:[...] else if(string[0] == 'g') // gs:[...]
{ {
#ifdef _WIN64 #ifdef _WIN64
seg_offset = (size_t)GetTEBLocation(hActiveThread); seg_offset = (size_t)GetTEBLocation(hActiveThread);
@ -1670,13 +1670,13 @@ bool valfromstring_noexpr(const char* string, duint* value, bool silent, bool ba
*isvar = true; *isvar = true;
return true; return true;
} }
else if(varget(string, value, value_size, 0)) //then come variables else if(varget(string, value, value_size, 0)) //then come variables
{ {
if(isvar) if(isvar)
*isvar = true; *isvar = true;
return true; return true;
} }
else if(isregister(string)) //register else if(isregister(string)) //register
{ {
if(!DbgIsDebugging()) if(!DbgIsDebugging())
{ {
@ -1694,7 +1694,7 @@ bool valfromstring_noexpr(const char* string, duint* value, bool silent, bool ba
*isvar = true; *isvar = true;
return true; return true;
} }
else if(*string == '_' && isflag(string + 1)) //flag else if(*string == '_' && isflag(string + 1)) //flag
{ {
if(!DbgIsDebugging()) if(!DbgIsDebugging())
{ {
@ -1718,7 +1718,7 @@ bool valfromstring_noexpr(const char* string, duint* value, bool silent, bool ba
*isvar = true; *isvar = true;
return true; return true;
} }
else if(isdecnumber(string)) //decimal numbers come 'first' else if(isdecnumber(string)) //decimal numbers come 'first'
{ {
if(value_size) if(value_size)
*value_size = 0; *value_size = 0;
@ -1726,7 +1726,7 @@ bool valfromstring_noexpr(const char* string, duint* value, bool silent, bool ba
*isvar = false; *isvar = false;
return convertNumber(string + 1, *value, 10); return convertNumber(string + 1, *value, 10);
} }
else if(ishexnumber(string)) //then hex numbers else if(ishexnumber(string)) //then hex numbers
{ {
if(value_size) if(value_size)
*value_size = 0; *value_size = 0;
@ -1763,13 +1763,13 @@ bool valfromstring_noexpr(const char* string, duint* value, bool silent, bool ba
if(baseonly) if(baseonly)
return false; return false;
if(valapifromstring(string, value, value_size, true, silent, hexonly)) //then come APIs if(valapifromstring(string, value, value_size, true, silent, hexonly)) //then come APIs
return true; return true;
else if(LabelFromString(string, value)) //then come labels else if(LabelFromString(string, value)) //then come labels
return true; return true;
else if(SymAddrFromName(string, value)) //then come symbols else if(SymAddrFromName(string, value)) //then come symbols
return true; return true;
else if(strstr(string, "sub_") == string) //then come sub_ functions else if(strstr(string, "sub_") == string) //then come sub_ functions
{ {
#ifdef _WIN64 #ifdef _WIN64
bool result = sscanf(string, "sub_%llX", value) == 1; bool result = sscanf(string, "sub_%llX", value) == 1;
@ -2329,7 +2329,7 @@ bool valtostring(const char* string, duint value, bool silent)
GuiUpdateAllViews(); //repaint gui GuiUpdateAllViews(); //repaint gui
return ok; return ok;
} }
else if(*string == '_' && isflag(string + 1)) //flag else if(*string == '_' && isflag(string + 1)) //flag
{ {
if(!DbgIsDebugging()) if(!DbgIsDebugging())
{ {

View File

@ -43,7 +43,7 @@ bool varset(const char* Name, VAR_VALUE* Value, bool ReadOnly)
name_ = "$"; name_ = "$";
name_ += Name; name_ += Name;
auto found = variables.find(name_); auto found = variables.find(name_);
if(found == variables.end()) //not found if(found == variables.end()) //not found
return false; return false;
if(found->second.alias.length()) if(found->second.alias.length())
return varset(found->second.alias.c_str(), Value, ReadOnly); return varset(found->second.alias.c_str(), Value, ReadOnly);

View File

@ -711,11 +711,11 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
wchar_t** argv = CommandLineToArgvW(GetCommandLineW(), &argc); wchar_t** argv = CommandLineToArgvW(GetCommandLineW(), &argc);
if(argc == 2) //1 argument (init filename) if(argc == 2) //1 argument (init filename)
DbgCmdExec(StringUtils::Utf16ToUtf8(StringUtils::sprintf(L"init \"%s\"", argv[1])).c_str()); DbgCmdExec(StringUtils::Utf16ToUtf8(StringUtils::sprintf(L"init \"%s\"", argv[1])).c_str());
else if(argc == 3) //2 arguments (init filename, cmdline) else if(argc == 3) //2 arguments (init filename, cmdline)
DbgCmdExec(StringUtils::Utf16ToUtf8(StringUtils::sprintf(L"init \"%s\", \"%s\"", argv[1], argv[2])).c_str()); DbgCmdExec(StringUtils::Utf16ToUtf8(StringUtils::sprintf(L"init \"%s\", \"%s\"", argv[1], argv[2])).c_str());
else if(argc == 4) //3 arguments (init filename, cmdline, currentdir) else if(argc == 4) //3 arguments (init filename, cmdline, currentdir)
DbgCmdExec(StringUtils::Utf16ToUtf8(StringUtils::sprintf(L"init \"%s\", \"%s\", \"%s\"", argv[1], argv[2], argv[3])).c_str()); DbgCmdExec(StringUtils::Utf16ToUtf8(StringUtils::sprintf(L"init \"%s\", \"%s\", \"%s\"", argv[1], argv[2], argv[3])).c_str());
else if(argc == 5 && !_wcsicmp(argv[1], L"-a") && !_wcsicmp(argv[3], L"-e")) //4 arguments (JIT) else if(argc == 5 && !_wcsicmp(argv[1], L"-a") && !_wcsicmp(argv[3], L"-e")) //4 arguments (JIT)
DbgCmdExec(StringUtils::Utf16ToUtf8(StringUtils::sprintf(L"attach .%s, .%s", argv[2], argv[4])).c_str()); //attach pid, event DbgCmdExec(StringUtils::Utf16ToUtf8(StringUtils::sprintf(L"attach .%s, .%s", argv[2], argv[4])).c_str()); //attach pid, event
LocalFree(argv); LocalFree(argv);

View File

@ -124,7 +124,7 @@ typedef struct _YR_COMPILER
compiler->last_error_extra_info, \ compiler->last_error_extra_info, \
info, \ info, \
sizeof(compiler->last_error_extra_info)); \ sizeof(compiler->last_error_extra_info)); \
#define yr_compiler_set_error_extra_info_fmt(compiler, fmt, ...) \ #define yr_compiler_set_error_extra_info_fmt(compiler, fmt, ...) \
snprintf( \ snprintf( \

View File

@ -295,7 +295,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
for (block = iterator->first(iterator); \ for (block = iterator->first(iterator); \
block != NULL; \ block != NULL; \
block = iterator->next(iterator)) \ block = iterator->next(iterator)) \
#define first_memory_block(context) \ #define first_memory_block(context) \
(context)->iterator->first((context)->iterator) (context)->iterator->first((context)->iterator)

View File

@ -389,7 +389,7 @@ QString Disassembly::paintContent(QPainter* painter, dsint rowBase, int rowOffse
} }
} }
} }
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, addrText); painter->drawText(QRect(x + 4, y, w - 4, h), Qt::AlignVCenter | Qt::AlignLeft, addrText);
} }
break; break;
@ -443,7 +443,7 @@ QString Disassembly::paintContent(QPainter* painter, dsint rowBase, int rowOffse
} }
int charwidth = getCharWidth(); int charwidth = getCharWidth();
painter->drawText(QRect(x + funcsize, y , charwidth , h), Qt::AlignVCenter | Qt::AlignLeft, indicator); painter->drawText(QRect(x + funcsize, y, charwidth, h), Qt::AlignVCenter | Qt::AlignLeft, indicator);
funcsize += charwidth; funcsize += charwidth;
//draw jump arrows //draw jump arrows
@ -621,7 +621,7 @@ QString Disassembly::paintContent(QPainter* painter, dsint rowBase, int rowOffse
width = w; width = w;
if(width) if(width)
painter->fillRect(QRect(x + argsize, y, width, h), QBrush(backgroundColor)); //fill comment color painter->fillRect(QRect(x + argsize, y, width, h), QBrush(backgroundColor)); //fill comment color
painter->drawText(QRect(x + argsize, y , width , h), Qt::AlignVCenter | Qt::AlignLeft, comment); painter->drawText(QRect(x + argsize, y, width, h), Qt::AlignVCenter | Qt::AlignLeft, comment);
argsize += width + 3; argsize += width + 3;
} }
else if(DbgGetLabelAt(cur_addr, SEG_DEFAULT, label)) // label but no comment else if(DbgGetLabelAt(cur_addr, SEG_DEFAULT, label)) // label but no comment
@ -659,7 +659,7 @@ QString Disassembly::paintContent(QPainter* painter, dsint rowBase, int rowOffse
width = w; width = w;
if(width) if(width)
painter->fillRect(QRect(x + argsize, y, width, h), QBrush(mMnemonicBriefBackgroundColor)); //mnemonic brief background color painter->fillRect(QRect(x + argsize, y, width, h), QBrush(mMnemonicBriefBackgroundColor)); //mnemonic brief background color
painter->drawText(QRect(x + argsize, y , width, h), Qt::AlignVCenter | Qt::AlignLeft, mnemBrief); painter->drawText(QRect(x + argsize, y, width, h), Qt::AlignVCenter | Qt::AlignLeft, mnemBrief);
} }
break; break;
} }
@ -1130,7 +1130,7 @@ int Disassembly::paintJumpsGraphic(QPainter* painter, int x, int y, dsint addr,
{ {
QPoint wPoints[] = QPoint wPoints[] =
{ {
QPoint(x , y + halfRow + 1), QPoint(x, y + halfRow + 1),
QPoint(x + 2, y + halfRow - 1), QPoint(x + 2, y + halfRow - 1),
QPoint(x + 4, y + halfRow + 1), QPoint(x + 4, y + halfRow + 1),
}; };
@ -1141,7 +1141,7 @@ int Disassembly::paintJumpsGraphic(QPainter* painter, int x, int y, dsint addr,
{ {
QPoint wPoints[] = QPoint wPoints[] =
{ {
QPoint(x , y + halfRow - 1), QPoint(x, y + halfRow - 1),
QPoint(x + 2, y + halfRow + 1), QPoint(x + 2, y + halfRow + 1),
QPoint(x + 4, y + halfRow - 1), QPoint(x + 4, y + halfRow - 1),
}; };
@ -1363,7 +1363,7 @@ dsint Disassembly::getPreviousInstructionRVA(dsint rva, duint count)
mMemPage->read(wBuffer.data(), wBottomByteRealRVA, wBuffer.size()); mMemPage->read(wBuffer.data(), wBottomByteRealRVA, wBuffer.size());
dsint addr = mDisasm->DisassembleBack((byte_t*)wBuffer.data(), rvaToVa(wBottomByteRealRVA), wBuffer.size(), wVirtualRVA , count); dsint addr = mDisasm->DisassembleBack((byte_t*)wBuffer.data(), rvaToVa(wBottomByteRealRVA), wBuffer.size(), wVirtualRVA, count);
addr += rva - wVirtualRVA; addr += rva - wVirtualRVA;

View File

@ -263,7 +263,7 @@ QString SearchListViewTable::paintContent(QPainter* painter, dsint rowBase, int
} }
} }
} }
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, text); painter->drawText(QRect(x + 4, y, w - 4, h), Qt::AlignVCenter | Qt::AlignLeft, text);
text = ""; text = "";
} }
else if(highlightText.length() && text.contains(highlightText, Qt::CaseInsensitive)) else if(highlightText.length() && text.contains(highlightText, Qt::CaseInsensitive))

View File

@ -343,11 +343,11 @@ QString CapstoneTokenizer::printValue(const TokenValue & value, bool expandModul
moduleText += "."; moduleText += ".";
QString addrText = ToHexString(addr); QString addrText = ToHexString(addr);
QString finalText; QString finalText;
if(bHasLabel && bHasModule) //<module.label> if(bHasLabel && bHasModule) //<module.label>
finalText = QString("<%1%2>").arg(moduleText).arg(labelText); finalText = QString("<%1%2>").arg(moduleText).arg(labelText);
else if(bHasModule) //module.addr else if(bHasModule) //module.addr
finalText = QString("%1%2").arg(moduleText).arg(addrText); finalText = QString("%1%2").arg(moduleText).arg(addrText);
else if(bHasLabel) //<label> else if(bHasLabel) //<label>
finalText = QString("<%1>").arg(labelText); finalText = QString("<%1>").arg(labelText);
else else
finalText = addrText; finalText = addrText;
@ -554,7 +554,7 @@ bool CapstoneTokenizer::tokenizeMemOperand(const cs_x86_op & op)
addToken(bracketsType, "["); addToken(bracketsType, "[");
//stuff inside the brackets //stuff inside the brackets
if(mem.base == X86_REG_RIP) //rip-relative (#replacement) if(mem.base == X86_REG_RIP) //rip-relative (#replacement)
{ {
duint addr = _cp.Address() + duint(mem.disp) + _cp.Size(); duint addr = _cp.Address() + duint(mem.disp) + _cp.Size();
TokenValue value = TokenValue(op.size, addr); TokenValue value = TokenValue(op.size, addr);
@ -564,12 +564,12 @@ bool CapstoneTokenizer::tokenizeMemOperand(const cs_x86_op & op)
else //#base + #index * #scale + #displacement else //#base + #index * #scale + #displacement
{ {
bool prependPlus = false; bool prependPlus = false;
if(mem.base != X86_REG_INVALID) //base register if(mem.base != X86_REG_INVALID) //base register
{ {
addToken(TokenType::MemoryBaseRegister, _cp.RegName(mem.base)); addToken(TokenType::MemoryBaseRegister, _cp.RegName(mem.base));
prependPlus = true; prependPlus = true;
} }
if(mem.index != X86_REG_INVALID) //index register if(mem.index != X86_REG_INVALID) //index register
{ {
if(prependPlus) if(prependPlus)
addMemoryOperator('+'); addMemoryOperator('+');

View File

@ -41,7 +41,7 @@ QString BreakpointsViewTable::paintContent(QPainter* painter, dsint rowBase, int
{ {
painter->fillRect(QRect(x, y, w, h), QBrush(mCipBackgroundColor)); painter->fillRect(QRect(x, y, w, h), QBrush(mCipBackgroundColor));
painter->setPen(QPen(mCipColor)); painter->setPen(QPen(mCipColor));
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, bpAddrStr); painter->drawText(QRect(x + 4, y, w - 4, h), Qt::AlignVCenter | Qt::AlignLeft, bpAddrStr);
ret = ""; ret = "";
} }
} }

View File

@ -117,9 +117,9 @@ void CPUDisassembly::mouseDoubleClickEvent(QMouseEvent* event)
void CPUDisassembly::addFollowReferenceMenuItem(QString name, dsint value, QMenu* menu, bool isReferences, bool isFollowInCPU) void CPUDisassembly::addFollowReferenceMenuItem(QString name, dsint value, QMenu* menu, bool isReferences, bool isFollowInCPU)
{ {
foreach(QAction * action, menu->actions()) //check for duplicate action foreach(QAction* action, menu->actions()) //check for duplicate action
if(action->text() == name) if(action->text() == name)
return; return;
QAction* newAction = new QAction(name, this); QAction* newAction = new QAction(name, this);
newAction->setFont(QFont("Courier New", 8)); newAction->setFont(QFont("Courier New", 8));
menu->addAction(newAction); menu->addAction(newAction);
@ -488,7 +488,7 @@ void CPUDisassembly::setupRightClickContextMenu()
}; };
ENCODETYPE enctypeTable[] = {enc_code, enc_byte, enc_word, enc_dword, enc_fword, enc_qword, enc_tbyte, enc_oword, enc_middle, ENCODETYPE enctypeTable[] = {enc_code, enc_byte, enc_word, enc_dword, enc_fword, enc_qword, enc_tbyte, enc_oword, enc_middle,
enc_real4, enc_real8, enc_real10 , enc_middle, enc_real4, enc_real8, enc_real10, enc_middle,
enc_ascii, enc_unicode, enc_middle, enc_ascii, enc_unicode, enc_middle,
enc_mmword, enc_xmmword, enc_ymmword enc_mmword, enc_xmmword, enc_ymmword
}; };

View File

@ -329,7 +329,7 @@ QString CPUDump::paintContent(QPainter* painter, dsint rowBase, int rowOffset, i
} }
if(background.alpha()) if(background.alpha())
painter->fillRect(QRect(x, y, w, h), QBrush(background)); //fill background color painter->fillRect(QRect(x, y, w, h), QBrush(background)); //fill background color
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, makeAddrText(cur_addr)); painter->drawText(QRect(x + 4, y, w - 4, h), Qt::AlignVCenter | Qt::AlignLeft, makeAddrText(cur_addr));
return ""; return "";
} }
return HexDump::paintContent(painter, rowBase, rowOffset, col, x, y, w, h); return HexDump::paintContent(painter, rowBase, rowOffset, col, x, y, w, h);

View File

@ -324,9 +324,9 @@ void CPUInfoBox::followActionSlot()
*/ */
void CPUInfoBox::addFollowMenuItem(QMenu* menu, QString name, duint value) void CPUInfoBox::addFollowMenuItem(QMenu* menu, QString name, duint value)
{ {
foreach(QAction * action, menu->actions()) //check for duplicate action foreach(QAction* action, menu->actions()) //check for duplicate action
if(action->text() == name) if(action->text() == name)
return; return;
QAction* newAction = new QAction(name, menu); QAction* newAction = new QAction(name, menu);
newAction->setFont(QFont("Courier New", 8)); newAction->setFont(QFont("Courier New", 8));
menu->addAction(newAction); menu->addAction(newAction);
@ -389,9 +389,9 @@ void CPUInfoBox::setupFollowMenu(QMenu* menu, duint wVA)
*/ */
void CPUInfoBox::addWatchMenuItem(QMenu* menu, QString name, duint value) void CPUInfoBox::addWatchMenuItem(QMenu* menu, QString name, duint value)
{ {
foreach(QAction * action, menu->actions()) //check for duplicate action foreach(QAction* action, menu->actions()) //check for duplicate action
if(action->text() == name) if(action->text() == name)
return; return;
QAction* newAction = new QAction(name, menu); QAction* newAction = new QAction(name, menu);
newAction->setFont(QFont("Courier New", 8)); newAction->setFont(QFont("Courier New", 8));
menu->addAction(newAction); menu->addAction(newAction);

View File

@ -432,7 +432,7 @@ QString CPUStack::paintContent(QPainter* painter, dsint rowBase, int rowOffset,
} }
if(background.alpha()) if(background.alpha())
painter->fillRect(QRect(x, y, w, h), QBrush(background)); //fill background when defined painter->fillRect(QRect(x, y, w, h), QBrush(background)); //fill background when defined
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, makeAddrText(wVa)); painter->drawText(QRect(x + 4, y, w - 4, h), Qt::AlignVCenter | Qt::AlignLeft, makeAddrText(wVa));
return QString(); return QString();
} }
else if(col == 1) // paint stack data else if(col == 1) // paint stack data

View File

@ -89,7 +89,7 @@ void CalculatorDialog::expressionChanged(bool validExpression, bool validPointer
else else
ui->txtAscii->setText("???"); ui->txtAscii->setText("???");
ui->txtAscii->setCursorPosition(1); ui->txtAscii->setCursorPosition(1);
if((value == (value & 0xFFF))) //UNICODE? if((value == (value & 0xFFF))) //UNICODE?
{ {
QChar c = QChar((ushort)value); QChar c = QChar((ushort)value);
if(c.isPrint()) if(c.isPrint())

View File

@ -186,7 +186,7 @@ void DisassemblerGraphView::paintNormal(QPainter & p, QRect & viewportRect, int
} }
//Ignore blocks that are not in view //Ignore blocks that are not in view
if(viewportRect.intersects(QRect(block.x + this->charWidth , block.y + this->charWidth, if(viewportRect.intersects(QRect(block.x + this->charWidth, block.y + this->charWidth,
block.width - (2 * this->charWidth), block.height - (2 * this->charWidth)))) block.width - (2 * this->charWidth), block.height - (2 * this->charWidth))))
{ {
//Render shadow //Render shadow
@ -1405,7 +1405,7 @@ void DisassemblerGraphView::show_cur_instr(bool force)
QRect viewportRect = this->viewport()->rect(); QRect viewportRect = this->viewport()->rect();
QPoint translation(this->renderXOfs - xofs, this->renderYOfs - yofs); QPoint translation(this->renderXOfs - xofs, this->renderYOfs - yofs);
viewportRect.translate(-translation.x(), -translation.y()); viewportRect.translate(-translation.x(), -translation.y());
if(force || !viewportRect.contains(QRect(block.x + this->charWidth , block.y + this->charWidth, if(force || !viewportRect.contains(QRect(block.x + this->charWidth, block.y + this->charWidth,
block.width - (2 * this->charWidth), block.height - (2 * this->charWidth)))) block.width - (2 * this->charWidth), block.height - (2 * this->charWidth))))
{ {
auto x = block.x + int(block.width / 2); auto x = block.x + int(block.width / 2);

View File

@ -57,9 +57,9 @@ void RegistersView::InitMappings()
offset++; offset++;
mRegisterMapping.insert(R8, "R8"); mRegisterMapping.insert(R8, "R8");
mRegisterPlaces.insert(R8 , Register_Position(offset++, 0, 6, sizeof(duint) * 2)); mRegisterPlaces.insert(R8, Register_Position(offset++, 0, 6, sizeof(duint) * 2));
mRegisterMapping.insert(R9, "R9"); mRegisterMapping.insert(R9, "R9");
mRegisterPlaces.insert(R9 , Register_Position(offset++, 0, 6, sizeof(duint) * 2)); mRegisterPlaces.insert(R9, Register_Position(offset++, 0, 6, sizeof(duint) * 2));
mRegisterMapping.insert(R10, "R10"); mRegisterMapping.insert(R10, "R10");
mRegisterPlaces.insert(R10, Register_Position(offset++, 0, 6, sizeof(duint) * 2)); mRegisterPlaces.insert(R10, Register_Position(offset++, 0, 6, sizeof(duint) * 2));
mRegisterMapping.insert(R11, "R11"); mRegisterMapping.insert(R11, "R11");
@ -1702,7 +1702,7 @@ void RegistersView::mouseDoubleClickEvent(QMouseEvent* event)
// is current register general purposes register or FPU register? // is current register general purposes register or FPU register?
else if(mMODIFYDISPLAY.contains(mSelected)) else if(mMODIFYDISPLAY.contains(mSelected))
wCM_Modify->trigger(); wCM_Modify->trigger();
else if(mBOOLDISPLAY.contains(mSelected)) // is flag ? else if(mBOOLDISPLAY.contains(mSelected)) // is flag ?
wCM_ToggleValue->trigger(); wCM_ToggleValue->trigger();
else if(mCANSTOREADDRESS.contains(mSelected)) else if(mCANSTOREADDRESS.contains(mSelected))
wCM_FollowInDisassembly->trigger(); wCM_FollowInDisassembly->trigger();
@ -1746,7 +1746,7 @@ void RegistersView::keyPressEvent(QKeyEvent* event)
QSize RegistersView::sizeHint() const QSize RegistersView::sizeHint() const
{ {
// 32 character width // 32 character width
return QSize(32 * mCharWidth , this->viewport()->height()); return QSize(32 * mCharWidth, this->viewport()->height());
} }
void* RegistersView::operator new(size_t size) void* RegistersView::operator new(size_t size)
@ -1806,7 +1806,7 @@ QString RegistersView::getRegisterLabel(REGISTER_NAME register_selected)
isCharacter = IsCharacterRegister(register_selected); isCharacter = IsCharacterRegister(register_selected);
} }
} }
else if(register_value == (register_value & 0xFFF)) //UNICODE? else if(register_value == (register_value & 0xFFF)) //UNICODE?
{ {
QChar c = QChar((wchar_t)register_value); QChar c = QChar((wchar_t)register_value);
if(c.isPrint()) if(c.isPrint())
@ -2681,7 +2681,7 @@ void RegistersView::onPushAction()
duint regVal = 0; duint regVal = 0;
regVal = * ((duint*) registerValue(&wRegDumpStruct, mSelected)); regVal = * ((duint*) registerValue(&wRegDumpStruct, mSelected));
setRegister(CSP, csp); setRegister(CSP, csp);
DbgMemWrite(csp, (const unsigned char*)&regVal , sizeof(void*)); DbgMemWrite(csp, (const unsigned char*)&regVal, sizeof(void*));
} }
void RegistersView::onPopAction() void RegistersView::onPopAction()

View File

@ -191,7 +191,7 @@ protected slots:
QString getRegisterLabel(REGISTER_NAME); QString getRegisterLabel(REGISTER_NAME);
int CompareRegisters(const REGISTER_NAME reg_name, REGDUMP* regdump1, REGDUMP* regdump2); int CompareRegisters(const REGISTER_NAME reg_name, REGDUMP* regdump1, REGDUMP* regdump2);
SIZE_T GetSizeRegister(const REGISTER_NAME reg_name); SIZE_T GetSizeRegister(const REGISTER_NAME reg_name);
QString GetRegStringValueFromValue(REGISTER_NAME reg , const char* value); QString GetRegStringValueFromValue(REGISTER_NAME reg, const char* value);
QString GetTagWordStateString(unsigned short); QString GetTagWordStateString(unsigned short);
//unsigned int GetTagWordValueFromString(const char* string); //unsigned int GetTagWordValueFromString(const char* string);
QString GetControlWordPCStateString(unsigned short); QString GetControlWordPCStateString(unsigned short);

View File

@ -109,7 +109,7 @@ QString ScriptView::paintContent(QPainter* painter, dsint rowBase, int rowOffset
if(background.alpha()) if(background.alpha())
painter->fillRect(QRect(x, y, w, h), QBrush(background)); //fill background painter->fillRect(QRect(x, y, w, h), QBrush(background)); //fill background
} }
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, returnString); painter->drawText(QRect(x + 4, y, w - 4, h), Qt::AlignVCenter | Qt::AlignLeft, returnString);
returnString = ""; returnString = "";
} }
break; break;

View File

@ -50,7 +50,7 @@ void ThreadView::setupContextMenu()
QAction* mSetPriorityNormal = makeCommandAction(new QAction(tr("Normal"), this), "setprioritythread $, Normal"); QAction* mSetPriorityNormal = makeCommandAction(new QAction(tr("Normal"), this), "setprioritythread $, Normal");
QAction* mSetPriorityTimeCritical = makeCommandAction(new QAction(tr("Time Critical"), this), "setprioritythread $, TimeCritical"); QAction* mSetPriorityTimeCritical = makeCommandAction(new QAction(tr("Time Critical"), this), "setprioritythread $, TimeCritical");
MenuBuilder* mSetPriority = new MenuBuilder(this, [this, mSetPriorityIdle, mSetPriorityAboveNormal, mSetPriorityBelowNormal, MenuBuilder* mSetPriority = new MenuBuilder(this, [this, mSetPriorityIdle, mSetPriorityAboveNormal, mSetPriorityBelowNormal,
mSetPriorityHighest, mSetPriorityLowest, mSetPriorityNormal, mSetPriorityTimeCritical](QMenu*) mSetPriorityHighest, mSetPriorityLowest, mSetPriorityNormal, mSetPriorityTimeCritical](QMenu*)
{ {
QString priority = getCellContent(getInitialSelection(), 6); QString priority = getCellContent(getInitialSelection(), 6);
QAction* selectedaction = nullptr; QAction* selectedaction = nullptr;
@ -366,7 +366,7 @@ QString ThreadView::paintContent(QPainter* painter, dsint rowBase, int rowOffset
{ {
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("ThreadCurrentBackgroundColor"))); painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("ThreadCurrentBackgroundColor")));
painter->setPen(QPen(ConfigColor("ThreadCurrentColor"))); //white text painter->setPen(QPen(ConfigColor("ThreadCurrentColor"))); //white text
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, ret); painter->drawText(QRect(x + 4, y, w - 4, h), Qt::AlignVCenter | Qt::AlignLeft, ret);
ret = ""; ret = "";
} }
return ret; return ret;

View File

@ -178,7 +178,7 @@ QString WatchView::paintContent(QPainter* painter, dsint rowBase, int rowOffset,
{ {
painter->fillRect(QRect(x, y, w, h), mWatchTriggeredBackgroundColor); painter->fillRect(QRect(x, y, w, h), mWatchTriggeredBackgroundColor);
painter->setPen(mWatchTriggeredColor); //white text painter->setPen(mWatchTriggeredColor); //white text
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, ret); painter->drawText(QRect(x + 4, y, w - 4, h), Qt::AlignVCenter | Qt::AlignLeft, ret);
return ""; return "";
} }
else else

View File

@ -126,7 +126,7 @@ namespace
dd_real("0.0263157894736842105263157894736842105"), // 1/38 dd_real("0.0263157894736842105263157894736842105"), // 1/38
dd_real("0.0256410256410256410256410256410256410"), // 1/39 dd_real("0.0256410256410256410256410256410256410"), // 1/39
dd_real("0.025"), // 1/40 dd_real("0.025"), // 1/40
dd_real("0.0243902439024390243902439024390243902") // 1/41 dd_real("0.0243902439024390243902439024390243902") // 1/41
}; };
dd_real const inv_fact[] = dd_real const inv_fact[] =
@ -872,11 +872,11 @@ recompute:
int ilog = std::ilogb(a) + 1; // 0.5 <= frac < 1.0 int ilog = std::ilogb(a) + 1; // 0.5 <= frac < 1.0
if(ilog < -std::numeric_limits<dd_real>::digits / 2) // |a| <= 2^-54 - error O( 2^-108) if(ilog < -std::numeric_limits<dd_real>::digits / 2) // |a| <= 2^-54 - error O( 2^-108)
return a; return a;
if(ilog < -std::numeric_limits<dd_real>::digits / 3) // |a| <= 2^-36 - error O( 2^-108) if(ilog < -std::numeric_limits<dd_real>::digits / 3) // |a| <= 2^-36 - error O( 2^-108)
return a * std::Fma(a, -0.5, 1.0); return a * std::Fma(a, -0.5, 1.0);
if(ilog < -std::numeric_limits<dd_real>::digits / 4) // |a| <= 2^-27 - error O( 2^-108) if(ilog < -std::numeric_limits<dd_real>::digits / 4) // |a| <= 2^-27 - error O( 2^-108)
return a * std::Fma(a, -std::Fma(a, -_third, 0.5), 1.0); return a * std::Fma(a, -std::Fma(a, -_third, 0.5), 1.0);
dd_real f_minus = a; dd_real f_minus = a;
@ -1324,7 +1324,7 @@ std::string dd_real::to_string(std::streamsize precision, std::streamsize width,
{ {
// fix the string if it's been computed incorrectly // fix the string if it's been computed incorrectly
// round here in the decimal string if required // round here in the decimal string if required
round_string(t, d + 1 , &off); round_string(t, d + 1, &off);
if(off > 0) if(off > 0)
{ {
@ -2155,7 +2155,7 @@ namespace std
// align exponents of x, y and subtract // align exponents of x, y and subtract
// //
auto ys = scalbn(y, ix - iy); auto ys = scalbn(y, ix - iy);
if(x < ys) // if mantissa( y ) > mantissa( x ), if(x < ys) // if mantissa( y ) > mantissa( x ),
scalbn(ys, -1); // divide by 2 scalbn(ys, -1); // divide by 2
double z[3]; double z[3];
@ -2748,7 +2748,7 @@ namespace std
return signbit(a) ? -1.0 : a; return signbit(a) ? -1.0 : a;
// exp( a ) > 2.0; no destructive cancelation is possible // exp( a ) > 2.0; no destructive cancelation is possible
if(std::abs(a) > _ln2) // exp( a ) < 0.5; no destructive cancellation is possible if(std::abs(a) > _ln2) // exp( a ) < 0.5; no destructive cancellation is possible
{ {
return exp(a) - 1.0; return exp(a) - 1.0;
} }
@ -2809,7 +2809,7 @@ namespace std
return a; return a;
if((a >= 2.0) || (a <= -0.5)) // a >= 2.0 - no loss of significant bits - use log() if((a >= 2.0) || (a <= -0.5)) // a >= 2.0 - no loss of significant bits - use log()
return _log(1.0 + a); return _log(1.0 + a);
// at this point, -1.0 < a < 2.0 // at this point, -1.0 < a < 2.0

View File

@ -408,7 +408,7 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
defaultShortcuts.insert("OptionsAppearance", Shortcut(tr("Options -> Appearance"), "", true)); defaultShortcuts.insert("OptionsAppearance", Shortcut(tr("Options -> Appearance"), "", true));
defaultShortcuts.insert("OptionsShortcuts", Shortcut(tr("Options -> Shortcuts"), "", true)); defaultShortcuts.insert("OptionsShortcuts", Shortcut(tr("Options -> Shortcuts"), "", true));
defaultShortcuts.insert("OptionsTopmost", Shortcut(tr("Options -> Topmost"), "Ctrl+F5", true)); defaultShortcuts.insert("OptionsTopmost", Shortcut(tr("Options -> Topmost"), "Ctrl+F5", true));
defaultShortcuts.insert("OptionsReloadStylesheet", Shortcut(tr("Options -> Reload style.css") , "", true)); defaultShortcuts.insert("OptionsReloadStylesheet", Shortcut(tr("Options -> Reload style.css"), "", true));
defaultShortcuts.insert("HelpAbout", Shortcut(tr("Help -> About"), "", true)); defaultShortcuts.insert("HelpAbout", Shortcut(tr("Help -> About"), "", true));
defaultShortcuts.insert("HelpBlog", Shortcut(tr("Help -> Blog"), "", true)); defaultShortcuts.insert("HelpBlog", Shortcut(tr("Help -> Blog"), "", true));

View File

@ -404,7 +404,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
//Handle command line //Handle command line
auto argc = 0; auto argc = 0;
auto argv = CommandLineToArgvW(GetCommandLineW(), &argc); auto argv = CommandLineToArgvW(GetCommandLineW(), &argc);
if(argc <= 1) //no arguments -> set configuration if(argc <= 1) //no arguments -> set configuration
{ {
if(!FileExists(sz32Path) && BrowseFileOpen(nullptr, TEXT("x32dbg.exe\0x32dbg.exe\0\0"), nullptr, sz32Path, MAX_PATH, szCurrentDir)) if(!FileExists(sz32Path) && BrowseFileOpen(nullptr, TEXT("x32dbg.exe\0x32dbg.exe\0\0"), nullptr, sz32Path, MAX_PATH, szCurrentDir))
{ {
@ -439,7 +439,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
if(bDoneSomething) if(bDoneSomething)
MessageBox(nullptr, LoadResString(IDS_NEWCFGWRITTEN), LoadResString(IDS_DONE), MB_ICONINFORMATION); MessageBox(nullptr, LoadResString(IDS_NEWCFGWRITTEN), LoadResString(IDS_DONE), MB_ICONINFORMATION);
} }
else if(argc >= 2) //one or more arguments -> execute debugger else if(argc >= 2) //one or more arguments -> execute debugger
{ {
BOOL canDisableRedirect = FALSE; BOOL canDisableRedirect = FALSE;
RedirectWow rWow; RedirectWow rWow;
@ -453,19 +453,19 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
} }
TCHAR szPath[MAX_PATH] = TEXT(""); TCHAR szPath[MAX_PATH] = TEXT("");
if(PathIsRelative(argv[1])) //resolve the full path if a relative path is specified if(PathIsRelative(argv[1])) //resolve the full path if a relative path is specified
{ {
GetCurrentDirectory(_countof(szPath), szPath); GetCurrentDirectory(_countof(szPath), szPath);
PathAppend(szPath, argv[1]); PathAppend(szPath, argv[1]);
} }
else if(!ResolveShortcut(nullptr, argv[1], szPath, _countof(szPath))) //attempt to resolve the shortcut path else if(!ResolveShortcut(nullptr, argv[1], szPath, _countof(szPath))) //attempt to resolve the shortcut path
_tcscpy_s(szPath, argv[1]); //fall back to the origin full path _tcscpy_s(szPath, argv[1]); //fall back to the origin full path
std::wstring cmdLine; std::wstring cmdLine;
cmdLine.push_back(L'\"'); cmdLine.push_back(L'\"');
cmdLine += szPath; cmdLine += szPath;
cmdLine.push_back(L'\"'); cmdLine.push_back(L'\"');
if(argc > 2) //forward any commandline parameters if(argc > 2) //forward any commandline parameters
{ {
cmdLine += L" \""; cmdLine += L" \"";
for(auto i = 2; i < argc; i++) for(auto i = 2; i < argc; i++)