1
0
Fork 0

Merge branch 'development' into patch000000a7

This commit is contained in:
torusrxxx 2020-11-14 17:51:32 +08:00
commit 4475af2513
No known key found for this signature in database
GPG Key ID: A795C73A0F1CFADD
47 changed files with 2085 additions and 486 deletions

View File

@ -26,8 +26,8 @@ QToolTip {
QWidget {
color: #e0e0e0;
background-color: #212121;
selection-background-color: #414141;
selection-color: #e0e0e0;
selection-background-color: #89a2f6;
selection-color: #000000;
background-clip: border;
border-image: none;
border: 0px transparent black;
@ -573,7 +573,8 @@ QPushButton:pressed {
}
QComboBox {
selection-background-color: #414141;
selection-background-color: #89a2f6;
selection-color: #000000;
border-style: solid;
border: 1px solid #212121;
border-radius: 2px;

2
deps

@ -1 +1 @@
Subproject commit 612f8b44905b1fb8076b0b2700982145ac8e5527
Subproject commit 87d4a5fb0380bae7b9406e342ac713bf21a8d4e6

View File

@ -354,7 +354,8 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, BRID
Zydis cp;
auto getregs = !bOnlyCipAutoComments || addr == lastContext.cip;
disasmget(cp, addr, &instr, getregs);
if(!cp.IsNop())
// Some nop variants have 'operands' that should be ignored
if(cp.Success() && !cp.IsNop())
{
//Ignore register values when not on CIP and OnlyCipAutoComments is enabled: https://github.com/x64dbg/x64dbg/issues/1383
if(!getregs)
@ -363,6 +364,21 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, BRID
instr.arg[i].value = instr.arg[i].constant;
}
if(addr == lastContext.cip && (cp.GetId() == ZYDIS_MNEMONIC_SYSCALL || (cp.GetId() == ZYDIS_MNEMONIC_INT && cp[0].imm.value.u == 0x2e)))
{
auto syscallName = SyscallToName(lastContext.cax);
if(!syscallName.empty())
{
if(!comment.empty())
{
comment.push_back(',');
comment.push_back(' ');
}
comment.append(syscallName);
retval = true;
}
}
for(int i = 0; i < instr.argcount; i++)
{
memset(&newinfo, 0, sizeof(BRIDGE_ADDRINFO));
@ -1494,10 +1510,6 @@ extern "C" DLL_EXPORT duint _dbg_sendmessage(DBGMSG type, void* param1, void* pa
duint setting = DebugEngineTitanEngine;
if(!BridgeSettingGetUint("Engine", "DebugEngine", &setting))
{
auto msg = String(GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "GleeBug is now available for beta testing, would you like to enable it? Some bugs can be expected, but generally things are looking stable!\n\nYou can change this setting in the Settings dialog.")));
auto title = String(GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "New debug engine available!")));
if(MessageBoxW(GuiGetWindowHandle(), StringUtils::Utf8ToUtf16(msg).c_str(), StringUtils::Utf8ToUtf16(title).c_str(), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) == IDYES)
setting = DebugEngineGleeBug;
BridgeSettingSetUint("Engine", "DebugEngine", setting);
}
return (DEBUG_ENGINE)setting;

View File

@ -90,6 +90,25 @@ bool cbInstrAnalrecur(int argc, char* argv[])
duint entry;
if(!valfromstring(argv[1], &entry, false))
return false;
#ifdef _WIN64
// find the closest function
{
SHARED_ACQUIRE(LockModules);
auto info = ModInfoFromAddr(entry);
if(info)
{
DWORD rva = DWORD(entry - info->base);
auto runtimeFunction = info->findRuntimeFunction(rva);
if(runtimeFunction)
{
if(runtimeFunction->BeginAddress < rva)
{
entry = info->base + runtimeFunction->BeginAddress;
}
}
}
}
#endif // _WIN64
duint size;
auto base = MemFindBaseAddr(entry, &size);
if(!base)

View File

@ -263,12 +263,32 @@ bool cbDebugAttach(int argc, char* argv[])
return true;
}
static bool dbgdetachDisableAllBreakpoints(const BREAKPOINT* bp)
{
if(bp->enabled)
{
if(bp->type == BPNORMAL)
DeleteBPX(bp->addr);
else if(bp->type == BPMEMORY)
RemoveMemoryBPX(bp->addr, 0);
else if(bp->type == BPHARDWARE && TITANDRXVALID(bp->titantype))
DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype));
}
return true;
}
bool cbDebugDetach(int argc, char* argv[])
{
unlock(WAITID_RUN); //run
dbgsetisdetachedbyuser(true); //detach when paused
StepInto((void*)cbDetach);
DebugBreakProcess(fdProcessInfo->hProcess);
PLUG_CB_DETACH detachInfo;
detachInfo.fdProcessInfo = fdProcessInfo;
plugincbcall(CB_DETACH, &detachInfo);
BpEnumAll(dbgdetachDisableAllBreakpoints); // Disable all software breakpoints before detaching.
if(!DetachDebuggerEx(fdProcessInfo->dwProcessId))
dputs(QT_TRANSLATE_NOOP("DBG", "DetachDebuggerEx failed..."));
else
dputs(QT_TRANSLATE_NOOP("DBG", "Detached!"));
_dbg_animatestop(); // Stop animating
unlock(WAITID_RUN); // run to resume the debug loop if necessary
return true;
}

View File

@ -534,3 +534,54 @@ bool cbInstrDebugFlags(int argc, char* argv[])
dprintf_untranslated("DebugFlags = 0x%08X\n", debugFlags);
return true;
}
bool cbInstrLabelRuntimeFunctions(int argc, char* argv[])
{
#ifdef _WIN64
if(argc < 2)
{
dputs_untranslated("Usage: LabelRuntimeFunctions modaddr");
return false;
}
auto modaddr = DbgValFromString(argv[1]);
SHARED_ACQUIRE(LockModules);
auto info = ModInfoFromAddr(modaddr);
if(info)
{
std::vector<COMMENTSINFO> comments;
CommentGetList(comments);
for(const auto & comment : comments)
{
if(comment.modhash == info->hash)
{
if(!comment.manual && comment.text.find("RUNTIME_FUNCTION") == 0)
{
CommentDelete(comment.addr + info->base);
}
}
}
for(const auto & runtimeFunction : info->runtimeFunctions)
{
auto setComment = [info](duint addr, const char* prefix)
{
char comment[MAX_COMMENT_SIZE] = "";
if(!CommentGet(addr, comment))
strncpy_s(comment, "RUNTIME_FUNCTION", _TRUNCATE);
strncat_s(comment, " ", _TRUNCATE);
strncat_s(comment, prefix, _TRUNCATE);
CommentSet(addr, comment, false);
};
setComment(info->base + runtimeFunction.BeginAddress, "BeginAddress");
setComment(info->base + runtimeFunction.EndAddress, "EndAddress");
}
GuiUpdateAllViews();
}
else
{
dprintf_untranslated("No module found at %p\n", modaddr);
}
return true;
#else
return false;
#endif // _WIN64
}

View File

@ -15,4 +15,5 @@ bool cbInstrFocusinfo(int argc, char* argv[]);
bool cbInstrFlushlog(int argc, char* argv[]);
bool cbInstrAnimateWait(int argc, char* argv[]);
bool cbInstrDbdecompress(int argc, char* argv[]);
bool cbInstrDebugFlags(int argc, char* argv[]);
bool cbInstrDebugFlags(int argc, char* argv[]);
bool cbInstrLabelRuntimeFunctions(int argc, char* argv[]);

View File

@ -87,6 +87,40 @@ bool cbSetWatchdog(int argc, char* argv[])
return true;
}
bool cbSetWatchType(int argc, char* argv[])
{
if(argc < 3)
{
dputs(QT_TRANSLATE_NOOP("DBG", "No enough arguments for SetWatchType\n"));
return false;
}
duint id;
bool ok = valfromstring(argv[1], &id);
if(!ok)
{
dputs(QT_TRANSLATE_NOOP("DBG", "Error expression in argument 1.\n"));
return false;
}
WATCHVARTYPE newtype;
if(_stricmp(argv[2], "uint") == 0)
newtype = WATCHVARTYPE::TYPE_UINT;
else if(_stricmp(argv[2], "int") == 0)
newtype = WATCHVARTYPE::TYPE_INT;
else if(_stricmp(argv[2], "float") == 0)
newtype = WATCHVARTYPE::TYPE_FLOAT;
else if(_stricmp(argv[2], "ascii") == 0)
newtype = WATCHVARTYPE::TYPE_ASCII;
else if(_stricmp(argv[2], "unicode") == 0)
newtype = WATCHVARTYPE::TYPE_UNICODE;
else
{
dputs(QT_TRANSLATE_NOOP("DBG", "Unknown watch type.\n"));
return false;
}
WatchSetType((unsigned int)id, newtype);
return true;
}
bool cbSetWatchExpression(int argc, char* argv[])
{
if(argc < 3)

View File

@ -7,4 +7,5 @@ bool cbDelWatch(int argc, char* argv[]);
bool cbSetWatchdog(int argc, char* argv[]);
bool cbSetWatchExpression(int argc, char* argv[]);
bool cbSetWatchName(int argc, char* argv[]);
bool cbSetWatchType(int argc, char* argv[]);
bool cbCheckWatchdog(int argc, char* argv[]);

View File

@ -48,7 +48,6 @@ static duint pCreateProcessBase = 0;
static duint pDebuggedEntry = 0;
static bool bRepeatIn = false;
static duint stepRepeat = 0;
static bool isDetachedByUser = false;
static bool bIsAttached = false;
static bool bSkipExceptions = false;
static duint skipExceptionCount = 0;
@ -327,11 +326,6 @@ void dbgsetsteprepeat(bool steppingIn, duint repeat)
stepRepeat = repeat;
}
void dbgsetisdetachedbyuser(bool b)
{
isDetachedByUser = b;
}
void dbgsetfreezestack(bool freeze)
{
bFreezeStack = freeze;
@ -865,7 +859,7 @@ static void cbGenericBreakpoint(BP_TYPE bptype, void* ExceptionAddress = nullptr
EXCLUSIVE_RELEASE();
if(bptype != BPDLL && bptype != BPEXCEPTION)
bp.addr += ModBaseFromAddr(CIP);
bp.addr += ModBaseFromName(bp.mod);
bp.active = true; //a breakpoint that has been hit is active
varset("$breakpointcounter", bp.hitcount, true); //save the breakpoint counter as a variable
@ -944,16 +938,19 @@ static void cbGenericBreakpoint(BP_TYPE bptype, void* ExceptionAddress = nullptr
void cbUserBreakpoint()
{
lastExceptionInfo = ((DEBUG_EVENT*)GetDebugData())->u.Exception;
cbGenericBreakpoint(BPNORMAL);
}
void cbHardwareBreakpoint(void* ExceptionAddress)
{
lastExceptionInfo = ((DEBUG_EVENT*)GetDebugData())->u.Exception;
cbGenericBreakpoint(BPHARDWARE, ExceptionAddress);
}
void cbMemoryBreakpoint(void* ExceptionAddress)
{
lastExceptionInfo = ((DEBUG_EVENT*)GetDebugData())->u.Exception;
cbGenericBreakpoint(BPMEMORY, ExceptionAddress);
}
@ -1463,6 +1460,8 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo)
threadInfo.lpStartAddress = CreateProcessInfo->lpStartAddress;
threadInfo.lpThreadLocalBase = CreateProcessInfo->lpThreadLocalBase;
ThreadCreate(&threadInfo);
hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId);
}
static void cbExitProcess(EXIT_PROCESS_DEBUG_INFO* ExitProcess)
@ -1621,10 +1620,7 @@ static void cbSystemBreakpoint(void* ExceptionData) // TODO: System breakpoint e
GuiUpdateAllViews();
//log message
if(bIsAttached)
dputs(QT_TRANSLATE_NOOP("DBG", "Attach breakpoint reached!"));
else
dputs(QT_TRANSLATE_NOOP("DBG", "System breakpoint reached!"));
dputs(QT_TRANSLATE_NOOP("DBG", "System breakpoint reached!"));
dbgsetskipexceptions(false); //we are not skipping first-chance exceptions
//plugin callbacks
@ -1639,7 +1635,7 @@ static void cbSystemBreakpoint(void* ExceptionData) // TODO: System breakpoint e
dputs(QT_TRANSLATE_NOOP("DBG", "It has been detected that the debuggee entry point is in the MZ header of the executable. This will cause strange behavior, so the system breakpoint has been enabled regardless of your setting. Be careful!"));
systemBreakpoint = true;
}
if(bIsAttached ? settingboolget("Events", "AttachBreakpoint") : systemBreakpoint)
if(systemBreakpoint)
{
//lock
GuiSetDebugStateAsync(paused);
@ -1695,7 +1691,9 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll)
}
DebugUpdateBreakpointsViewAsync();
if(settingboolget("Events", "TlsCallbacks"))
int party = ModGetParty(duint(base));
if(settingboolget("Events", "TlsCallbacks") && party != mod_system || settingboolget("Events", "TlsCallbacksSystem") && party == mod_system)
{
SHARED_ACQUIRE(LockModules);
auto modInfo = ModInfoFromAddr(duint(base));
@ -1720,7 +1718,7 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll)
auto breakOnDll = dbghandledllbreakpoint(modname, true);
if((breakOnDll || settingboolget("Events", "DllEntry")) && !bAlreadySetEntry)
if((breakOnDll || (settingboolget("Events", "DllEntry") && party != mod_system || settingboolget("Events", "DllEntrySystem") && party == mod_system)) && !bAlreadySetEntry)
{
auto entry = ModEntryFromAddr(duint(base));
if(entry)
@ -1736,7 +1734,8 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll)
cookie.HandleNtdllLoad(bIsAttached);
if(settingboolget("Misc", "TransparentExceptionStepping"))
exceptionDispatchAddr = DbgValFromString("ntdll:KiUserExceptionDispatcher");
if(settingboolget("Events", "NtTerminateProcess")) // Break on NtTerminateProcess
cmddirectexec("bp ntdll.NtTerminateProcess, ss");
//set debug flags
if(dwDebugFlags != 0)
{
@ -1804,7 +1803,7 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll)
{
cbGenericBreakpoint(BPDLL, DLLDebugFileName);
}
else if(settingboolget("Events", "DllLoad"))
else if(settingboolget("Events", "DllLoad") && party != mod_system || settingboolget("Events", "DllLoadSystem") && party == mod_system)
{
//update GUI
DebugUpdateGuiSetStateAsync(GetContextDataEx(hActiveThread, UE_CIP), true);
@ -1830,6 +1829,7 @@ static void cbUnloadDll(UNLOAD_DLL_DEBUG_INFO* UnloadDll)
char modname[256] = "???";
if(ModNameFromAddr((duint)base, modname, true))
BpEnumAll(cbRemoveModuleBreakpoints, modname, duint(base));
int party = ModGetParty(duint(base));
DebugUpdateBreakpointsViewAsync();
dprintf(QT_TRANSLATE_NOOP("DBG", "DLL Unloaded: %p %s\n"), base, modname);
@ -1837,7 +1837,7 @@ static void cbUnloadDll(UNLOAD_DLL_DEBUG_INFO* UnloadDll)
{
cbGenericBreakpoint(BPDLL, modname);
}
else if(settingboolget("Events", "DllUnload"))
else if(settingboolget("Events", "DllUnload") && party != mod_system || settingboolget("Events", "DllUnloadSystem") && party == mod_system)
{
//update GUI
DebugUpdateGuiSetStateAsync(GetContextDataEx(hActiveThread, UE_CIP), true);
@ -1934,24 +1934,7 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData)
return;
}
}
if(ExceptionData->ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT)
{
if(isDetachedByUser)
{
PLUG_CB_DETACH detachInfo;
detachInfo.fdProcessInfo = fdProcessInfo;
plugincbcall(CB_DETACH, &detachInfo);
BpEnumAll(dbgdetachDisableAllBreakpoints); // Disable all software breakpoints before detaching.
if(!DetachDebuggerEx(fdProcessInfo->dwProcessId))
dputs(QT_TRANSLATE_NOOP("DBG", "DetachDebuggerEx failed..."));
else
dputs(QT_TRANSLATE_NOOP("DBG", "Detached!"));
isDetachedByUser = false;
_dbg_animatestop(); // Stop animating
return;
}
}
else if(ExceptionData->ExceptionRecord.ExceptionCode == MS_VC_EXCEPTION) //SetThreadName exception
if(ExceptionData->ExceptionRecord.ExceptionCode == MS_VC_EXCEPTION) //SetThreadName exception
{
THREADNAME_INFO nameInfo; //has no valid local pointers
memcpy(&nameInfo, ExceptionData->ExceptionRecord.ExceptionInformation, sizeof(THREADNAME_INFO));
@ -2028,21 +2011,20 @@ static void cbAttachDebugger()
tidToResume = 0;
}
varset("$pid", fdProcessInfo->dwProcessId, true);
}
void cbDetach()
{
if(!isDetachedByUser)
return;
PLUG_CB_DETACH detachInfo;
detachInfo.fdProcessInfo = fdProcessInfo;
plugincbcall(CB_DETACH, &detachInfo);
BpEnumAll(dbgdetachDisableAllBreakpoints); // Disable all software breakpoints before detaching.
if(!DetachDebuggerEx(fdProcessInfo->dwProcessId))
dputs(QT_TRANSLATE_NOOP("DBG", "DetachDebuggerEx failed..."));
else
dputs(QT_TRANSLATE_NOOP("DBG", "Detached!"));
return;
//Get on top of things
SetForegroundWindow(GuiGetWindowHandle());
// Update GUI (this should be the first triggered event)
duint cip = GetContextDataEx(hActiveThread, UE_CIP);
GuiDumpAt(MemFindBaseAddr(cip, 0, true)); //dump somewhere
DebugUpdateGuiSetStateAsync(cip, true, running);
MemInitRemoteProcessCookie(cookie.cookie);
GuiUpdateAllViews();
dputs(QT_TRANSLATE_NOOP("DBG", "Attached to process!"));
dbgsetskipexceptions(false); //we are not skipping first-chance exceptions
}
cmdline_qoutes_placement_t getqoutesplacement(const char* cmdline)
@ -2849,7 +2831,6 @@ static void debugLoopFunction(void* lpParameter, bool attach)
pDebuggedEntry = 0;
pDebuggedBase = 0;
pCreateProcessBase = 0;
isDetachedByUser = false;
hActiveThread = nullptr;
if(!gDllLoader.empty()) //Delete the DLL loader (#1496)
{

View File

@ -54,7 +54,6 @@ void DebugSetBreakpoints();
void GuiSetDebugStateAsync(DBGSTATE state);
void dbgsetskipexceptions(bool skip);
void dbgsetsteprepeat(bool steppingIn, duint repeat);
void dbgsetisdetachedbyuser(bool b);
void dbgsetfreezestack(bool freeze);
void dbgclearignoredexceptions();
void dbgaddignoredexception(ExceptionRange range);
@ -100,7 +99,6 @@ void cbTraceIntoIntoTraceRecordStep();
void cbTraceOverIntoTraceRecordStep();
void cbRunToUserCodeBreakpoint(void* ExceptionAddress);
DWORD WINAPI threadAttachLoop(void* lpParameter);
void cbDetach();
bool cbSetModuleBreakpoints(const BREAKPOINT* bp);
EXCEPTION_DEBUG_INFO & getLastExceptionInfo();
bool dbgrestartadmin();

View File

@ -4,11 +4,15 @@
#include "filehelper.h"
#include "value.h"
#include "console.h"
#include "threading.h"
#include "module.h"
#include "syscalls.h"
static std::unordered_map<unsigned int, String> ExceptionNames;
static std::unordered_map<unsigned int, String> NtStatusNames;
static std::unordered_map<unsigned int, String> ErrorNames;
static std::unordered_map<String, unsigned int> Constants;
static std::unordered_map<unsigned int, String> SyscallIndices;
static bool UniversalCodeInit(const String & file, std::unordered_map<unsigned int, String> & names, unsigned char radix)
{
@ -181,3 +185,78 @@ std::vector<CONSTANTINFO> ErrorCodeList()
});
return result;
}
bool SyscallInit()
{
auto retrieveSyscalls = [](const char* moduleName)
{
auto moduleHandle = GetModuleHandleA(moduleName);
if(!moduleHandle)
return false;
char szModulePath[MAX_PATH];
if(!GetModuleFileNameA(moduleHandle, szModulePath, _countof(szModulePath)))
return false;
if(!ModLoad((duint)moduleHandle, 1, szModulePath, false))
return false;
auto info = ModInfoFromAddr((duint)moduleHandle);
if(info)
{
for(const MODEXPORT & exportEntry : info->exports)
{
if(strncmp(exportEntry.name.c_str(), "Nt", 2) != 0)
continue;
auto exportData = (const unsigned char*)ModRvaToOffset(info->fileMapVA, info->headers, exportEntry.rva);
if(!exportData)
continue;
// https://github.com/mrexodia/TitanHide/blob/1c6ba9796e320f399f998b23fba2729122597e87/TitanHide/ntdll.cpp#L75
DWORD index = -1;
for(int i = 0; i < 32; i++)
{
if(exportData[i] == 0xC2 || exportData[i] == 0xC3) //RET
{
break;
}
if(exportData[i] == 0xB8) //mov eax,X
{
index = *(DWORD*)(exportData + i + 1);
break;
}
}
if(index != -1)
SyscallIndices.emplace(index, exportEntry.name);
}
}
else
{
return false;
}
return true;
};
// See: https://github.com/x64dbg/ScyllaHide/blob/6817d32581b7a420322f34e36b1a1c8c3e4b434c/Scylla/Win32kSyscalls.h
auto result = retrieveSyscalls("ntdll.dll");
OSVERSIONINFOW versionInfo = { sizeof(OSVERSIONINFOW) };
GetVersionExW(&versionInfo);
if(versionInfo.dwBuildNumber >= 14393)
{
result = result && retrieveSyscalls("win32u.dll");
}
else
{
for(auto & syscall : Win32kSyscalls)
{
auto index = syscall.GetSyscallIndex(versionInfo.dwBuildNumber, ArchValue(true, false));
if(index != -1)
SyscallIndices.insert({ index, syscall.Name });
}
}
ModClear(false);
return result;
}
const String & SyscallToName(unsigned int index)
{
auto found = SyscallIndices.find(index);
return found != SyscallIndices.end() ? found->second : emptyString;
}

View File

@ -19,5 +19,8 @@ bool ExceptionNameToCode(const char* Name, unsigned int* ErrorCode);
bool ConstantCodeInit(const String & constantFile);
bool ConstantFromName(const String & name, duint & value);
std::vector<CONSTANTINFO> ConstantList();
// To use this function, use EXCLUSIVE_ACQUIRE(LockModules)
bool SyscallInit();
const String & SyscallToName(unsigned int index);
#endif // _EXCEPTION_H

View File

@ -60,7 +60,7 @@ static NTSTATUS ImageNtHeaders(duint base, duint size, PIMAGE_NT_HEADERS* outHea
}
// Use only with SEC_COMMIT mappings, not SEC_IMAGE! (in that case, just do VA = base + rva...)
static ULONG64 RvaToVa(ULONG64 base, PIMAGE_NT_HEADERS ntHeaders, ULONG64 rva)
ULONG64 ModRvaToOffset(ULONG64 base, PIMAGE_NT_HEADERS ntHeaders, ULONG64 rva)
{
PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(ntHeaders);
for(WORD i = 0; i < ntHeaders->FileHeader.NumberOfSections; ++i)
@ -96,7 +96,7 @@ static void ReadExportDirectory(MODINFO & Info, ULONG_PTR FileMapVA)
auto rva2offset = [&Info](ULONG64 rva)
{
return RvaToVa(0, Info.headers, rva);
return ModRvaToOffset(0, Info.headers, rva);
};
auto addressOfFunctionsOffset = rva2offset(exportDir->AddressOfFunctions);
@ -138,7 +138,7 @@ static void ReadExportDirectory(MODINFO & Info, ULONG_PTR FileMapVA)
auto & entry = Info.exports.back();
entry.ordinal = i + exportDir->Base;
entry.rva = addressOfFunctions[i];
const auto entryVa = RvaToVa(FileMapVA, Info.headers, entry.rva);
const auto entryVa = ModRvaToOffset(FileMapVA, Info.headers, entry.rva);
entry.forwarded = entryVa >= (ULONG64)exportDir && entryVa < (ULONG64)exportDir + exportDirSize;
if(entry.forwarded)
{
@ -232,7 +232,7 @@ static void ReadImportDirectory(MODINFO & Info, ULONG_PTR FileMapVA)
const ULONG64 ordinalFlag = IMAGE64(Info.headers) ? IMAGE_ORDINAL_FLAG64 : IMAGE_ORDINAL_FLAG32;
auto rva2offset = [&Info](ULONG64 rva)
{
return RvaToVa(0, Info.headers, rva);
return ModRvaToOffset(0, Info.headers, rva);
};
for(size_t moduleIndex = 0; importDescriptor->Name != 0; ++importDescriptor, ++moduleIndex)
@ -326,7 +326,7 @@ static void ReadTlsCallbacks(MODINFO & Info, ULONG_PTR FileMapVA)
return;
auto imageBase = HEADER_FIELD(Info.headers, ImageBase);
auto tlsArrayOffset = RvaToVa(0, Info.headers, tlsDir->AddressOfCallBacks - imageBase);
auto tlsArrayOffset = ModRvaToOffset(0, Info.headers, tlsDir->AddressOfCallBacks - imageBase);
if(!tlsArrayOffset)
return;
@ -463,7 +463,7 @@ static void ReadDebugDirectory(MODINFO & Info, ULONG_PTR FileMapVA)
const auto supported = [&Info](PIMAGE_DEBUG_DIRECTORY entry)
{
// Check for valid RVA
const auto offset = RvaToVa(0, Info.headers, entry->AddressOfRawData);
const auto offset = ModRvaToOffset(0, Info.headers, entry->AddressOfRawData);
if(!offset)
return false;
@ -556,7 +556,7 @@ static void ReadDebugDirectory(MODINFO & Info, ULONG_PTR FileMapVA)
}
// At this point we know the entry is a valid CV one
auto cvData = (unsigned char*)(FileMapVA + RvaToVa(0, Info.headers, entry->AddressOfRawData));
auto cvData = (unsigned char*)(FileMapVA + ModRvaToOffset(0, Info.headers, entry->AddressOfRawData));
auto signature = *(DWORD*)cvData;
if(signature == '01BN')
{
@ -757,7 +757,7 @@ void GetModuleInfo(MODINFO & Info, ULONG_PTR FileMapVA)
#undef GetUnsafeModuleInfo
}
bool ModLoad(duint Base, duint Size, const char* FullPath)
bool ModLoad(duint Base, duint Size, const char* FullPath, bool loadSymbols)
{
// Handle a new module being loaded
if(!Base || !Size || !FullPath)
@ -863,11 +863,14 @@ bool ModLoad(duint Base, duint Size, const char* FullPath)
}
info.symbols = &EmptySymbolSource; // empty symbol source per default
// TODO: setting to auto load symbols
for(const auto & pdbPath : info.pdbPaths)
if(loadSymbols)
{
if(info.loadSymbols(pdbPath, bForceLoadSymbols))
break;
for(const auto & pdbPath : info.pdbPaths)
{
if(info.loadSymbols(pdbPath, bForceLoadSymbols))
break;
}
}
// Add module to list
@ -910,7 +913,7 @@ bool ModUnload(duint Base)
return true;
}
void ModClear()
void ModClear(bool updateGui)
{
{
// Clean up all the modules
@ -925,7 +928,8 @@ void ModClear()
}
// Tell the symbol updater
GuiSymbolUpdateModuleList(0, nullptr);
if(updateGui)
GuiSymbolUpdateModuleList(0, nullptr);
}
MODINFO* ModInfoFromAddr(duint Address)
@ -1227,6 +1231,21 @@ bool ModRelocationsInRange(duint Address, duint Size, std::vector<MODRELOCATIONI
return !Relocations.empty();
}
#if _WIN64
const RUNTIME_FUNCTION* MODINFO::findRuntimeFunction(DWORD rva) const
{
const auto found = std::lower_bound(runtimeFunctions.cbegin(), runtimeFunctions.cend(), rva, [](const RUNTIME_FUNCTION & a, const DWORD & rva)
{
return a.EndAddress <= rva;
});
if(found != runtimeFunctions.cend() && rva >= found->BeginAddress)
return &*found;
return nullptr;
}
#endif
bool MODINFO::loadSymbols(const String & pdbPath, bool forceLoad)
{
unloadSymbols();

View File

@ -92,6 +92,8 @@ struct MODINFO
std::vector<duint> tlsCallbacks;
#if _WIN64
std::vector<RUNTIME_FUNCTION> runtimeFunctions; //sorted by (begin, end)
const RUNTIME_FUNCTION* findRuntimeFunction(DWORD rva) const;
#endif // _WIN64
MODEXPORT entrySymbol;
@ -138,9 +140,10 @@ struct MODINFO
const MODEXPORT* findExport(duint rva) const;
};
bool ModLoad(duint Base, duint Size, const char* FullPath);
ULONG64 ModRvaToOffset(ULONG64 base, PIMAGE_NT_HEADERS ntHeaders, ULONG64 rva);
bool ModLoad(duint Base, duint Size, const char* FullPath, bool loadSymbols = true);
bool ModUnload(duint Base);
void ModClear();
void ModClear(bool updateGui = true);
MODINFO* ModInfoFromAddr(duint Address);
bool ModNameFromAddr(duint Address, char* Name, bool Extension);
duint ModBaseFromAddr(duint Address);

View File

@ -158,20 +158,17 @@ static PVOID CALLBACK StackSymFunctionTableAccess64(HANDLE hProcess, DWORD64 Add
#ifdef _WIN64
// https://github.com/dotnet/coreclr/blob/master/src/unwinder/amd64/dbs_stack_x64.cpp
MODINFO* info = ModInfoFromAddr(AddrBase);
if(!info)
return nullptr;
DWORD rva = DWORD(AddrBase - info->base);
auto found = std::lower_bound(info->runtimeFunctions.begin(), info->runtimeFunctions.end(), rva, [](const RUNTIME_FUNCTION & a, const DWORD & rva)
if(info)
{
return a.EndAddress <= rva;
});
if(found != info->runtimeFunctions.end() && rva >= found->BeginAddress)
return &found->BeginAddress;
#endif // _WIN64
return (PVOID)info->findRuntimeFunction(DWORD(AddrBase - info->base));
}
else
{
return nullptr;
}
#else
return SymFunctionTableAccess64(hProcess, AddrBase);
#endif // _WIN64
}
static DWORD64 CALLBACK StackGetModuleBaseProc64(HANDLE hProcess, DWORD64 Address)
@ -309,7 +306,7 @@ void stackgetcallstack(duint csp, std::vector<CALLSTACKENTRY> & callstackVector,
DWORD machineType = IMAGE_FILE_MACHINE_AMD64;
frame.AddrPC.Offset = context.Rip;
frame.AddrPC.Mode = AddrModeFlat;
frame.AddrFrame.Offset = context.Rsp;
frame.AddrFrame.Offset = context.Rbp;
frame.AddrFrame.Mode = AddrModeFlat;
frame.AddrStack.Offset = csp;
frame.AddrStack.Mode = AddrModeFlat;
@ -383,4 +380,4 @@ void stackupdatesettings()
std::vector<CALLSTACKENTRY> dummy;
if(hActiveThread)
stackgetcallstack(GetContextDataEx(hActiveThread, UE_CSP), dummy, false);
}
}

1254
src/dbg/syscalls.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -623,11 +623,11 @@ bool setflag(const char* string, bool set)
flag = 0x100000;
else if(scmp(string, "id"))
flag = 0x200000;
if(eflags & flag && !set)
xorval = flag;
else if(set)
xorval = flag;
return SetContextDataEx(hActiveThread, UE_CFLAGS, eflags ^ xorval);
if(set)
eflags |= flag;
else
eflags &= ~flag;
return SetContextDataEx(hActiveThread, UE_CFLAGS, eflags);
}
/**

View File

@ -241,6 +241,21 @@ WATCHVARTYPE WatchGetType(unsigned int id)
return WATCHVARTYPE::TYPE_INVALID;
}
void WatchSetTypeUnlocked(unsigned int id, WATCHVARTYPE type)
{
auto obj = watchexpr.find(id);
if(obj != watchexpr.end())
obj->second->setType(type);
}
void WatchSetType(unsigned int id, WATCHVARTYPE type)
{
EXCLUSIVE_ACQUIRE(LockWatch);
WatchSetTypeUnlocked(id, type);
EXCLUSIVE_RELEASE();
GuiUpdateWatchViewAsync();
}
unsigned int WatchGetWindow(unsigned int id)
{
SHARED_ACQUIRE(LockWatch);

View File

@ -48,11 +48,15 @@ public:
inline const String & getExpr()
{
return expr.GetExpression();
}
};
inline const bool HaveCurrentValue()
{
return haveCurrValue;
};
inline void setType(WATCHVARTYPE type)
{
varType = type;
};
};
extern std::map<unsigned int, WatchExpr*> watchexpr;
@ -69,6 +73,7 @@ WATCHDOGMODE WatchGetWatchdogMode(unsigned int id);
WATCHDOGMODE WatchGetWatchdogEnabled(unsigned int id);
duint WatchGetUnsignedValue(unsigned int id);
WATCHVARTYPE WatchGetType(unsigned int id);
void WatchSetType(unsigned int id, WATCHVARTYPE type);
std::vector<WATCHINFO> WatchGetList();
void WatchCacheSave(JSON root); // Save watch data to database

View File

@ -258,8 +258,10 @@ static void registercommands()
dbgcmdnew("SetWatchdog", cbSetWatchdog, true); // Setup watchdog
dbgcmdnew("SetWatchExpression", cbSetWatchExpression, true); // Set watch expression
dbgcmdnew("SetWatchName", cbSetWatchName, true); // Set watch name
dbgcmdnew("SetWatchType", cbSetWatchType, true); // Set watch type
dbgcmdnew("CheckWatchdog", cbCheckWatchdog, true); // Watchdog
//variables
dbgcmdnew("varnew,var", cbInstrVar, false); //make a variable arg1:name,[arg2:value]
dbgcmdnew("vardel", cbInstrVarDel, false); //delete a variable, arg1:variable name
@ -445,6 +447,7 @@ static void registercommands()
dbgcmdnew("AnimateWait", cbInstrAnimateWait, true); //Wait for the debuggee to pause.
dbgcmdnew("dbdecompress", cbInstrDbdecompress, false); //Decompress a database.
dbgcmdnew("DebugFlags", cbInstrDebugFlags, false); //Set ntdll LdrpDebugFlags
dbgcmdnew("LabelRuntimeFunctions", cbInstrLabelRuntimeFunctions, true); //Label exception directory entries
};
bool cbCommandProvider(char* cmd, int maxlen)
@ -571,8 +574,23 @@ static bool DbgScriptDllExec(const char* dll)
return true;
}
static DWORD WINAPI loadDbThread(LPVOID)
static DWORD WINAPI loadDbThread(LPVOID hEvent)
{
{
// Take exclusive ownership over the modules to prevent a race condition with cbCreateProcess
EXCLUSIVE_ACQUIRE(LockModules);
// Signal the startup thread that we have the lock
SetEvent(hEvent);
// Load syscall indices
dputs(QT_TRANSLATE_NOOP("DBG", "Retrieving syscall indices..."));
if(SyscallInit())
dputs(QT_TRANSLATE_NOOP("DBG", "Syscall indices loaded!"));
else
dputs(QT_TRANSLATE_NOOP("DBG", "Failed to load syscall indices..."));
}
// Load error codes
if(ErrorCodeInit(StringUtils::sprintf("%s\\..\\errordb.txt", szProgramDir)))
dputs(QT_TRANSLATE_NOOP("DBG", "Error codes database loaded!"));
@ -703,7 +721,13 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
initDataInstMap();
dputs(QT_TRANSLATE_NOOP("DBG", "Start file read thread..."));
CloseHandle(CreateThread(nullptr, 0, loadDbThread, nullptr, 0, nullptr));
{
auto hEvent = CreateEventW(nullptr, false, FALSE, nullptr);
CloseHandle(CreateThread(nullptr, 0, loadDbThread, hEvent, 0, nullptr));
// Wait until the loadDbThread signals it's finished
WaitForSingleObject(hEvent, INFINITE);
CloseHandle(hEvent);
}
// Create database directory in the local debugger folder
DbSetPath(StringUtils::sprintf("%s\\db", szProgramDir).c_str(), nullptr);

View File

@ -240,6 +240,7 @@
<ClInclude Include="symbolsourcedia.h" />
<ClInclude Include="symbolundecorator.h" />
<ClInclude Include="symcache.h" />
<ClInclude Include="syscalls.h" />
<ClInclude Include="taskthread.h" />
<ClInclude Include="tcpconnections.h" />
<ClInclude Include="TraceRecord.h" />

View File

@ -895,5 +895,8 @@
<ClInclude Include="symbolundecorator.h">
<Filter>Header Files\Symbols</Filter>
</ClInclude>
<ClInclude Include="syscalls.h">
<Filter>Header Files\Information</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -13,7 +13,7 @@ ReferenceView::ReferenceView(bool sourceView, QWidget* parent) : StdSearchListVi
mSearchStartCol = 1;
// Widget container for progress
QWidget* progressWidget = new QWidget();
QWidget* progressWidget = new QWidget(this);
// Create the layout for the progress bars
QHBoxLayout* layoutProgress = new QHBoxLayout();

View File

@ -33,7 +33,7 @@ SearchListView::SearchListView(QWidget* parent, AbstractSearchList* abstractSear
listLayout->addWidget(abstractSearchList->searchList());
// Add list placeholder
QWidget* listPlaceholder = new QWidget();
QWidget* listPlaceholder = new QWidget(this);
listPlaceholder->setLayout(listLayout);
barSplitter->addWidget(listPlaceholder);
@ -68,7 +68,7 @@ SearchListView::SearchListView(QWidget* parent, AbstractSearchList* abstractSear
horzLayout->addWidget(mRegexCheckbox);
// Add searchbar placeholder
QWidget* horzPlaceholder = new QWidget();
QWidget* horzPlaceholder = new QWidget(this);
horzPlaceholder->setLayout(horzLayout);
barSplitter->addWidget(horzPlaceholder);

View File

@ -65,6 +65,10 @@ QString StdIconTable::paintContent(QPainter* painter, dsint rowBase, int rowOffs
{
if(col == mIconColumn)
{
// Draw the selection first, so that transparent icons are drawn properly
if(isSelected(rowBase, rowOffset))
painter->fillRect(QRect(x, y, w, h), QBrush(mSelectionColor));
mIcon.at(rowBase + rowOffset).paint(painter, x, y, h, h);
QString wStr = StdTable::paintContent(painter, rowBase, rowOffset, col, x + h, y, w, h);

View File

@ -418,31 +418,40 @@ void AppearanceDialog::colorInfoListInit()
//clear list
colorInfoIndex = 0;
colorInfoList.clear();
//list entries
// Guide lines for entry order:
// 1. Most visual and common first
// So mostly that'll be "Background" (most visual)
// followed by "Selection" and "Text" (most common)
// 2. others are sorted by read direction (Top to down / left to right)
// Example: "Header Text", "Addresses", "Text",...
//
colorInfoListAppend(tr("General Tables:"), "", "");
colorInfoListAppend(tr("Text"), "AbstractTableViewTextColor", "");
colorInfoListAppend(tr("Header Text"), "AbstractTableViewHeaderTextColor", "");
colorInfoListAppend(tr("Background"), "AbstractTableViewBackgroundColor", "");
colorInfoListAppend(tr("Selection"), "AbstractTableViewSelectionColor", "");
colorInfoListAppend(tr("Header Text"), "AbstractTableViewHeaderTextColor", "");
colorInfoListAppend(tr("Text"), "AbstractTableViewTextColor", "");
colorInfoListAppend(tr("Separators"), "AbstractTableViewSeparatorColor", "");
colorInfoListAppend(tr("Disassembly:"), "", "");
colorInfoListAppend(tr("Background"), "DisassemblyBackgroundColor", "");
colorInfoListAppend(tr("Selection"), "DisassemblySelectionColor", "");
colorInfoListAppend(ArchValue(tr("EIP"), tr("RIP")), "DisassemblyCipColor", "DisassemblyCipBackgroundColor");
colorInfoListAppend(tr("Addresses"), "DisassemblyAddressColor", "DisassemblyAddressBackgroundColor");
colorInfoListAppend(tr("Selected Addresses"), "DisassemblySelectedAddressColor", "DisassemblySelectedAddressBackgroundColor");
colorInfoListAppend(tr("Breakpoints"), "DisassemblyBreakpointColor", "DisassemblyBreakpointBackgroundColor");
colorInfoListAppend(tr("Hardware Breakpoints"), "DisassemblyHardwareBreakpointColor", "DisassemblyHardwareBreakpointBackgroundColor");
colorInfoListAppend(tr("Labels"), "DisassemblyLabelColor", "DisassemblyLabelBackgroundColor");
colorInfoListAppend(tr("Bytes"), "DisassemblyBytesColor", "DisassemblyBytesBackgroundColor");
colorInfoListAppend(tr("Modified Bytes"), "DisassemblyModifiedBytesColor", "DisassemblyModifiedBytesBackgroundColor");
colorInfoListAppend(tr("Restored Bytes"), "DisassemblyRestoredBytesColor", "DisassemblyRestoredBytesBackgroundColor");
colorInfoListAppend(tr("Relocation underline"), "DisassemblyRelocationUnderlineColor", "");
colorInfoListAppend(ArchValue(tr("EIP"), tr("RIP")), "DisassemblyCipColor", "DisassemblyCipBackgroundColor");
colorInfoListAppend(tr("Breakpoints"), "DisassemblyBreakpointColor", "DisassemblyBreakpointBackgroundColor");
colorInfoListAppend(tr("Hardware Breakpoints"), "DisassemblyHardwareBreakpointColor", "DisassemblyHardwareBreakpointBackgroundColor");
colorInfoListAppend(tr("Bookmarks"), "DisassemblyBookmarkColor", "DisassemblyBookmarkBackgroundColor");
colorInfoListAppend(tr("Comments"), "DisassemblyCommentColor", "DisassemblyCommentBackgroundColor");
colorInfoListAppend(tr("Automatic Comments"), "DisassemblyAutoCommentColor", "DisassemblyAutoCommentBackgroundColor");
colorInfoListAppend(tr("Mnemonic Brief Comments"), "DisassemblyMnemonicBriefColor", "DisassemblyMnemonicBriefBackgroundColor");
colorInfoListAppend(tr("Labels"), "DisassemblyLabelColor", "DisassemblyLabelBackgroundColor");
colorInfoListAppend(tr("Addresses"), "DisassemblyAddressColor", "DisassemblyAddressBackgroundColor");
colorInfoListAppend(tr("Selected Addresses"), "DisassemblySelectedAddressColor", "DisassemblySelectedAddressBackgroundColor");
colorInfoListAppend(tr("Relocation underline"), "DisassemblyRelocationUnderlineColor", "");
colorInfoListAppend(tr("Conditional Jump Lines (jump)"), "DisassemblyConditionalJumpLineTrueColor", "");
colorInfoListAppend(tr("Conditional Jump Lines (no jump)"), "DisassemblyConditionalJumpLineFalseColor", "");
colorInfoListAppend(tr("Unconditional Jump Lines"), "DisassemblyUnconditionalJumpLineColor", "");
@ -450,42 +459,39 @@ void AppearanceDialog::colorInfoListInit()
colorInfoListAppend(tr("Function Lines"), "DisassemblyFunctionColor", "");
colorInfoListAppend(tr("Loop Lines"), "DisassemblyLoopColor", "");
colorInfoListAppend(tr("SideBar:"), "", "");
colorInfoListAppend(tr("Background"), "SideBarBackgroundColor", "");
colorInfoListAppend(tr("Register Labels"), "SideBarCipLabelColor", "SideBarCipLabelBackgroundColor");
colorInfoListAppend(tr("Conditional Jump Lines (jump)"), "SideBarConditionalJumpLineTrueColor", "");
colorInfoListAppend(tr("Conditional Jump Backwards Lines (jump)"), "SideBarConditionalJumpLineTrueBackwardsColor", "");
colorInfoListAppend(tr("Conditional Jump Lines (no jump)"), "SideBarConditionalJumpLineFalseColor", "");
colorInfoListAppend(tr("Conditional Jump Backwards Lines (no jump)"), "SideBarConditionalJumpLineFalseBackwardsColor", "");
colorInfoListAppend(tr("Unconditional Jump Lines (jump)"), "SideBarUnconditionalJumpLineTrueColor", "");
colorInfoListAppend(tr("Unconditional Jump Backwards Lines (jump)"), "SideBarUnconditionalJumpLineTrueBackwardsColor", "");
colorInfoListAppend(tr("Unconditional Jump Lines (no jump)"), "SideBarUnconditionalJumpLineFalseColor", "");
colorInfoListAppend(tr("Unconditional Jump Backwards Lines (no jump)"), "SideBarUnconditionalJumpLineFalseBackwardsColor", "");
colorInfoListAppend(tr("Code Folding Checkbox Color"), "SideBarCheckBoxForeColor", "SideBarCheckBoxBackColor");
colorInfoListAppend(tr("Bullets"), "SideBarBulletColor", "");
colorInfoListAppend(tr("Breakpoint bullets"), "SideBarBulletBreakpointColor", "");
colorInfoListAppend(tr("Disabled Breakpoint bullets"), "SideBarBulletDisabledBreakpointColor", "");
colorInfoListAppend(tr("Bookmark bullets"), "SideBarBulletBookmarkColor", "");
colorInfoListAppend(tr("Conditional Jump Lines (jump)"), "SideBarConditionalJumpLineTrueColor", "");
colorInfoListAppend(tr("Conditional Jump Lines (no jump)"), "SideBarConditionalJumpLineFalseColor", "");
colorInfoListAppend(tr("Unconditional Jump Lines (jump)"), "SideBarUnconditionalJumpLineTrueColor", "");
colorInfoListAppend(tr("Unconditional Jump Lines (no jump)"), "SideBarUnconditionalJumpLineFalseColor", "");
colorInfoListAppend(tr("Conditional Jump Backwards Lines (jump)"), "SideBarConditionalJumpLineTrueBackwardsColor", "");
colorInfoListAppend(tr("Conditional Jump Backwards Lines (no jump)"), "SideBarConditionalJumpLineFalseBackwardsColor", "");
colorInfoListAppend(tr("Unconditional Jump Backwards Lines (jump)"), "SideBarUnconditionalJumpLineTrueBackwardsColor", "");
colorInfoListAppend(tr("Unconditional Jump Backwards Lines (no jump)"), "SideBarUnconditionalJumpLineFalseBackwardsColor", "");
colorInfoListAppend(tr("Code Folding Checkbox Color"), "SideBarCheckBoxForeColor", "SideBarCheckBoxBackColor");
colorInfoListAppend(tr("Background"), "SideBarBackgroundColor", "");
colorInfoListAppend(tr("Registers:"), "", "");
colorInfoListAppend(tr("Text"), "RegistersColor", "");
colorInfoListAppend(tr("Background"), "RegistersBackgroundColor", "");
colorInfoListAppend(tr("Selection"), "RegistersSelectionColor", "");
colorInfoListAppend(tr("Modified Registers"), "RegistersModifiedColor", "");
colorInfoListAppend(tr("Register Names"), "RegistersLabelColor", "");
colorInfoListAppend(tr("Argument Register Names"), "RegistersArgumentLabelColor", "");
colorInfoListAppend(tr("Extra Information"), "RegistersExtraInfoColor", "");
colorInfoListAppend(tr("Text"), "RegistersColor", "");
colorInfoListAppend(tr("Modified Registers"), "RegistersModifiedColor", "");
colorInfoListAppend(tr("Highlight Read"), "RegistersHighlightReadColor", "");
colorInfoListAppend(tr("Highlight Write"), "RegistersHighlightWriteColor", "");
colorInfoListAppend(tr("Highlight Read+Write"), "RegistersHighlightReadWriteColor", "");
colorInfoListAppend(tr("Extra Information"), "RegistersExtraInfoColor", "");
colorInfoListAppend(tr("Instructions:"), "", "");
colorInfoListAppend(tr("Text"), "InstructionUncategorizedColor", "InstructionUncategorizedBackgroundColor");
colorInfoListAppend(tr("Highlighting"), "InstructionHighlightColor", "InstructionHighlightBackgroundColor");
colorInfoListAppend(tr("Commas"), "InstructionCommaColor", "InstructionCommaBackgroundColor");
colorInfoListAppend(tr("Prefixes"), "InstructionPrefixColor", "InstructionPrefixBackgroundColor");
colorInfoListAppend(tr("Addresses"), "InstructionAddressColor", "InstructionAddressBackgroundColor");
colorInfoListAppend(tr("Values"), "InstructionValueColor", "InstructionValueBackgroundColor");
colorInfoListAppend(tr("Mnemonics"), "InstructionMnemonicColor", "InstructionMnemonicBackgroundColor");
colorInfoListAppend(tr("Push/Pops"), "InstructionPushPopColor", "InstructionPushPopBackgroundColor");
colorInfoListAppend(tr("Calls"), "InstructionCallColor", "InstructionCallBackgroundColor");
@ -496,6 +502,12 @@ void AppearanceDialog::colorInfoListInit()
colorInfoListAppend(tr("FAR"), "InstructionFarColor", "InstructionFarBackgroundColor");
colorInfoListAppend(tr("INT3s"), "InstructionInt3Color", "InstructionInt3BackgroundColor");
colorInfoListAppend(tr("Unusual Instructions"), "InstructionUnusualColor", "InstructionUnusualBackgroundColor");
colorInfoListAppend(tr("Prefixes"), "InstructionPrefixColor", "InstructionPrefixBackgroundColor");
colorInfoListAppend(tr("Addresses"), "InstructionAddressColor", "InstructionAddressBackgroundColor");
colorInfoListAppend(tr("Values"), "InstructionValueColor", "InstructionValueBackgroundColor");
colorInfoListAppend(tr("Commas"), "InstructionCommaColor", "InstructionCommaBackgroundColor");
colorInfoListAppend(tr("General Registers"), "InstructionGeneralRegisterColor", "InstructionGeneralRegisterBackgroundColor");
colorInfoListAppend(tr("FPU Registers"), "InstructionFpuRegisterColor", "InstructionFpuRegisterBackgroundColor");
colorInfoListAppend(tr("MMX Registers"), "InstructionMmxRegisterColor", "InstructionMmxRegisterBackgroundColor");
@ -504,14 +516,21 @@ void AppearanceDialog::colorInfoListInit()
colorInfoListAppend(tr("ZMM Registers"), "InstructionZmmRegisterColor", "InstructionZmmRegisterBackgroundColor");
colorInfoListAppend(tr("Memory Sizes"), "InstructionMemorySizeColor", "InstructionMemorySizeBackgroundColor");
colorInfoListAppend(tr("Memory Segments"), "InstructionMemorySegmentColor", "InstructionMemorySegmentBackgroundColor");
colorInfoListAppend(tr("Text"), "InstructionUncategorizedColor", "InstructionUncategorizedBackgroundColor");
colorInfoListAppend(tr("Memory Brackets"), "InstructionMemoryBracketsColor", "InstructionMemoryBracketsBackgroundColor");
colorInfoListAppend(tr("Memory Stack Brackets"), "InstructionMemoryStackBracketsColor", "InstructionMemoryStackBracketsBackgroundColor");
colorInfoListAppend(tr("Memory Base Registers"), "InstructionMemoryBaseRegisterColor", "InstructionMemoryBaseRegisterBackgroundColor");
colorInfoListAppend(tr("Memory Index Registers"), "InstructionMemoryIndexRegisterColor", "InstructionMemoryIndexRegisterBackgroundColor");
colorInfoListAppend(tr("Memory Scales"), "InstructionMemoryScaleColor", "InstructionMemoryScaleBackgroundColor");
colorInfoListAppend(tr("Memory Operators (+/-/*)"), "InstructionMemoryOperatorColor", "InstructionMemoryOperatorBackgroundColor");
colorInfoListAppend(tr("Highlighting"), "InstructionHighlightColor", "InstructionHighlightBackgroundColor");
colorInfoListAppend(tr("HexDump:"), "", "");
colorInfoListAppend(tr("Background"), "HexDumpBackgroundColor", "");
colorInfoListAppend(tr("Selection"), "HexDumpSelectionColor", "");
colorInfoListAppend(tr("Addresses"), "HexDumpAddressColor", "HexDumpAddressBackgroundColor");
colorInfoListAppend(tr("Labels"), "HexDumpLabelColor", "HexDumpLabelBackgroundColor");
colorInfoListAppend(tr("Text"), "HexDumpTextColor", "");
colorInfoListAppend(tr("Modified Bytes"), "HexDumpModifiedBytesColor", "HexDumpModifiedBytesBackgroundColor");
colorInfoListAppend(tr("Restored Bytes"), "HexDumpRestoredBytesColor", "HexDumpRestoredBytesBackgroundColor");
@ -519,10 +538,6 @@ void AppearanceDialog::colorInfoListInit()
colorInfoListAppend(tr("0x7F Bytes"), "HexDumpByte7FColor", "HexDumpByte7FBackgroundColor");
colorInfoListAppend(tr("0xFF Bytes"), "HexDumpByteFFColor", "HexDumpByteFFBackgroundColor");
colorInfoListAppend(tr("IsPrint Bytes"), "HexDumpByteIsPrintColor", "HexDumpByteIsPrintBackgroundColor");
colorInfoListAppend(tr("Background"), "HexDumpBackgroundColor", "");
colorInfoListAppend(tr("Selection"), "HexDumpSelectionColor", "");
colorInfoListAppend(tr("Addresses"), "HexDumpAddressColor", "HexDumpAddressBackgroundColor");
colorInfoListAppend(tr("Labels"), "HexDumpLabelColor", "HexDumpLabelBackgroundColor");
colorInfoListAppend(tr("User Code Pointer Highlight Color"), "HexDumpUserModuleCodePointerHighlightColor", "");
colorInfoListAppend(tr("User Data Pointer Highlight Color"), "HexDumpUserModuleDataPointerHighlightColor", "");
colorInfoListAppend(tr("System Code Pointer Highlight Color"), "HexDumpSystemModuleCodePointerHighlightColor", "");
@ -530,28 +545,34 @@ void AppearanceDialog::colorInfoListInit()
colorInfoListAppend(tr("Unknown Code Pointer Highlight Color"), "HexDumpUnknownCodePointerHighlightColor", "");
colorInfoListAppend(tr("Unknown Data Pointer Highlight Color"), "HexDumpUnknownDataPointerHighlightColor", "");
colorInfoListAppend(tr("Stack:"), "", "");
colorInfoListAppend(tr("Text"), "StackTextColor", "");
colorInfoListAppend(tr("Inactive Text"), "StackInactiveTextColor", "");
colorInfoListAppend(tr("Background"), "StackBackgroundColor", "");
colorInfoListAppend(tr("Selection"), "StackSelectionColor", "");
colorInfoListAppend(ArchValue(tr("ESP"), tr("RSP")), "StackCspColor", "StackCspBackgroundColor");
colorInfoListAppend(tr("Addresses"), "StackAddressColor", "StackAddressBackgroundColor");
colorInfoListAppend(tr("Selected Addresses"), "StackSelectedAddressColor", "StackSelectedAddressBackgroundColor");
colorInfoListAppend(tr("Labels"), "StackLabelColor", "StackLabelBackgroundColor");
colorInfoListAppend(tr("Return To Comment"), "StackReturnToColor", "");
colorInfoListAppend(tr("SEH Chain Comment"), "StackSEHChainColor", "");
colorInfoListAppend(tr("User Stack Frame Line"), "StackFrameColor", "");
colorInfoListAppend(tr("System Stack Frame Line"), "StackFrameSystemColor", "");
colorInfoListAppend(tr("Text"), "StackTextColor", "");
colorInfoListAppend(tr("Inactive Text"), "StackInactiveTextColor", "");
colorInfoListAppend(tr("Selection"), "StackSelectionColor", "");
colorInfoListAppend(tr("Return To Comment"), "StackReturnToColor", "");
colorInfoListAppend(tr("SEH Chain Comment"), "StackSEHChainColor", "");
colorInfoListAppend(tr("HexEdit:"), "", "");
colorInfoListAppend(tr("Text"), "HexEditTextColor", "");
colorInfoListAppend(tr("Wildcards"), "HexEditWildcardColor", "");
colorInfoListAppend(tr("Background"), "HexEditBackgroundColor", "");
colorInfoListAppend(tr("Selection"), "HexEditSelectionColor", "");
colorInfoListAppend(tr("Text"), "HexEditTextColor", "");
colorInfoListAppend(tr("Wildcards"), "HexEditWildcardColor", "");
colorInfoListAppend(tr("Graph:"), "", "");
colorInfoListAppend(tr("Background"), "GraphBackgroundColor", "");
colorInfoListAppend(ArchValue(tr("EIP"), tr("RIP")), "GraphCipColor", "");
colorInfoListAppend(tr("Breakpoint"), "GraphBreakpointColor", "");
colorInfoListAppend(tr("Disabled Breakpoint"), "GraphDisabledBreakpointColor", "");
colorInfoListAppend(tr("Node"), "GraphNodeColor", "GraphNodeBackgroundColor");
colorInfoListAppend(tr("Current node shadow"), "GraphCurrentShadowColor", "");
colorInfoListAppend(tr("Terminal node shadow"), "GraphRetShadowColor", "");
@ -559,30 +580,29 @@ void AppearanceDialog::colorInfoListInit()
colorInfoListAppend(tr("Unconditional branch line"), "GraphJmpColor", "");
colorInfoListAppend(tr("True branch line"), "GraphBrtrueColor", "");
colorInfoListAppend(tr("False branch line"), "GraphBrfalseColor", "");
colorInfoListAppend(ArchValue(tr("EIP"), tr("RIP")), "GraphCipColor", "");
colorInfoListAppend(tr("Breakpoint"), "GraphBreakpointColor", "");
colorInfoListAppend(tr("Disabled Breakpoint"), "GraphDisabledBreakpointColor", "");
colorInfoListAppend(tr("Other:"), "", "");
colorInfoListAppend(tr("Background Flicker Color"), "BackgroundFlickerColor", "");
colorInfoListAppend(tr("Log Link Color") + "*", "LogLinkColor", "LogLinkBackgroundColor");
colorInfoListAppend(tr("Search Highlight Color"), "SearchListViewHighlightColor", "SearchListViewHighlightBackgroundColor");
colorInfoListAppend(tr("Patch located in relocation region"), "PatchRelocatedByteHighlightColor", "");
colorInfoListAppend(tr("Current Thread"), "ThreadCurrentColor", "ThreadCurrentBackgroundColor");
colorInfoListAppend(tr("Watch (When Watchdog is Triggered)"), "WatchTriggeredColor", "WatchTriggeredBackgroundColor");
colorInfoListAppend(tr("Memory Map Breakpoint"), "MemoryMapBreakpointColor", "MemoryMapBreakpointBackgroundColor");
colorInfoListAppend(tr("Memory Map %1").arg(ArchValue(tr("EIP"), tr("RIP"))), "MemoryMapCipColor", "MemoryMapCipBackgroundColor");
colorInfoListAppend(tr("Memory Map Section Text"), "MemoryMapSectionTextColor", "");
colorInfoListAppend(tr("Search Highlight Color"), "SearchListViewHighlightColor", "SearchListViewHighlightBackgroundColor");
colorInfoListAppend(tr("Struct primary background"), "StructBackgroundColor", "");
colorInfoListAppend(tr("Struct secondary background"), "StructAlternateBackgroundColor", "");
colorInfoListAppend(tr("Log Link Color") + "*", "LogLinkColor", "LogLinkBackgroundColor");
colorInfoListAppend(tr("Breakpoint Summary Parentheses"), "BreakpointSummaryParenColor", "");
colorInfoListAppend(tr("Breakpoint Summary Keywords"), "BreakpointSummaryKeywordColor", "");
colorInfoListAppend(tr("Breakpoint Summary Strings"), "BreakpointSummaryStringColor", "");
colorInfoListAppend(tr("Patch located in relocation region"), "PatchRelocatedByteHighlightColor", "");
colorInfoListAppend(tr("Symbol User Module Text"), "SymbolUserTextColor", "");
colorInfoListAppend(tr("Symbol System Module Text"), "SymbolSystemTextColor", "");
colorInfoListAppend(tr("Symbol Unloaded Text"), "SymbolUnloadedTextColor", "");
colorInfoListAppend(tr("Symbol Loading Text"), "SymbolLoadingTextColor", "");
colorInfoListAppend(tr("Symbol Loaded Text"), "SymbolLoadedTextColor", "");
colorInfoListAppend(tr("Background Flicker Color"), "BackgroundFlickerColor", "");
//dev helper
const QMap<QString, QColor>* Colors = &Config()->defaultColors;

View File

@ -54,7 +54,7 @@ void CPUDisassembly::mousePressEvent(QMouseEvent* event)
if(!DbgIsDebugging())
return;
MessageBeep(MB_OK);
if(event->modifiers() & Qt::ShiftModifier)
if(event->modifiers() & (Qt::ShiftModifier | Qt::ControlModifier))
copyRvaSlot();
else
copyAddressSlot();

View File

@ -24,12 +24,10 @@ CPUDump::CPUDump(CPUDisassembly* disas, CPUMultiDump* multiDump, QWidget* parent
if(BridgeSettingGetUint("Gui", "AsciiSeparator", &setting))
mAsciiSeparator = setting & 0xF;
asciiAddressDumpModeUpdatedSlot();
setView((ViewEnum_t)ConfigUint("HexDump", "DefaultView"));
connect(this, SIGNAL(selectionUpdated()), this, SLOT(selectionUpdatedSlot()));
connect(this, SIGNAL(headerButtonReleased(int)), this, SLOT(headerButtonReleasedSlot(int)));
connect(Config(), SIGNAL(asciiAddressDumpModeUpdated()), this, SLOT(asciiAddressDumpModeUpdatedSlot()));
mPluginMenu = multiDump->mDumpPluginMenu;
@ -266,7 +264,7 @@ void CPUDump::setupContextMenu()
wFloatMenu->addAction(makeAction(DIcon("80bit-float.png"), tr("&Long double (80-bit)"), SLOT(floatLongDoubleSlot())));
mMenuBuilder->addMenu(makeMenu(DIcon("float.png"), tr("&Float")), wFloatMenu);
mMenuBuilder->addAction(makeAction(DIcon("address.png"), tr("&Address"), SLOT(addressSlot())));
mMenuBuilder->addAction(makeAction(DIcon("address.png"), tr("&Address"), SLOT(addressAsciiSlot())));
mMenuBuilder->addAction(makeAction(DIcon("processor-cpu.png"), tr("&Disassembly"), SLOT(disassemblySlot())));
mMenuBuilder->addSeparator();
@ -1184,50 +1182,8 @@ void CPUDump::floatLongDoubleSlot()
reloadData();
}
void CPUDump::addressSlot()
{
if(mAsciiAddressDumpMode)
{
addressAsciiSlot();
return;
}
Config()->setUint("HexDump", "DefaultView", (duint)ViewAddress);
int charwidth = getCharWidth();
ColumnDescriptor wColDesc;
DataDescriptor dDesc;
wColDesc.isData = true; //void*
wColDesc.itemCount = 1;
wColDesc.separator = 0;
#ifdef _WIN64
wColDesc.data.itemSize = Qword;
wColDesc.data.qwordMode = HexQword;
#else
wColDesc.data.itemSize = Dword;
wColDesc.data.dwordMode = HexDword;
#endif
appendResetDescriptor(8 + charwidth * 2 * sizeof(duint), tr("Value"), false, wColDesc);
wColDesc.isData = false; //comments
wColDesc.itemCount = 1;
wColDesc.separator = 0;
dDesc.itemSize = Byte;
dDesc.byteMode = AsciiByte;
wColDesc.data = dDesc;
appendDescriptor(0, tr("Comments"), false, wColDesc);
reloadData();
}
void CPUDump::addressAsciiSlot()
{
if(!mAsciiAddressDumpMode)
{
addressSlot();
return;
}
Config()->setUint("HexDump", "DefaultView", (duint)ViewAddressAscii);
int charwidth = getCharWidth();
ColumnDescriptor wColDesc;
@ -1273,12 +1229,6 @@ void CPUDump::addressAsciiSlot()
void CPUDump::addressUnicodeSlot()
{
if(!mAsciiAddressDumpMode)
{
addressSlot();
return;
}
Config()->setUint("HexDump", "DefaultView", (duint)ViewAddressUnicode);
int charwidth = getCharWidth();
ColumnDescriptor wColDesc;
@ -1630,8 +1580,6 @@ void CPUDump::setView(ViewEnum_t view)
floatLongDoubleSlot();
break;
case ViewAddress:
addressSlot();
break;
case ViewAddressAscii:
addressAsciiSlot();
break;
@ -1656,18 +1604,3 @@ void CPUDump::headerButtonReleasedSlot(int colIndex)
if(callback)
callback();
}
void CPUDump::asciiAddressDumpModeUpdatedSlot()
{
duint setting = 0;
mAsciiAddressDumpMode = BridgeSettingGetUint("Gui", "AsciiAddressDumpMode", &setting) && setting;
auto defaultView = (ViewEnum_t)ConfigUint("HexDump", "DefaultView");
switch(defaultView)
{
case ViewAddress:
case ViewAddressAscii:
case ViewAddressUnicode:
setView(defaultView);
break;
}
}

View File

@ -61,7 +61,6 @@ public slots:
void floatDoubleSlot();
void floatLongDoubleSlot();
void addressSlot();
void addressUnicodeSlot();
void addressAsciiSlot();
void disassemblySlot();
@ -86,7 +85,6 @@ public slots:
void allocMemorySlot();
void headerButtonReleasedSlot(int colIndex);
void asciiAddressDumpModeUpdatedSlot();
private:
MenuBuilder* mMenuBuilder;
@ -101,7 +99,6 @@ private:
CPUDisassembly* mDisas;
CPUMultiDump* mMultiDump;
int mAsciiSeparator = 0;
bool mAsciiAddressDumpMode;
enum ViewEnum_t
{

View File

@ -275,6 +275,18 @@ void CommandLineEdit::scriptTypeChanged(int index)
{
mCurrentScriptIndex = index;
// Custom placeholder for the default commands
duint timeWastedDebugging = 0;
BridgeSettingGetUint("Engine", "TimeWastedDebugging", &timeWastedDebugging);
if(index == 0 && timeWastedDebugging < 60 * 60 * 10)
{
setPlaceholderText(tr("Commands are comma separated (like assembly instructions): mov eax, ebx"));
}
else
{
setPlaceholderText(QString());
}
// Force reset autocompletion (blank string)
emit textEdited("");
}

View File

@ -296,7 +296,7 @@ MainWindow::MainWindow(QWidget* parent)
connect(ui->actionRunSelection, SIGNAL(triggered()), this, SLOT(runSelection()));
connect(ui->actionRunExpression, SIGNAL(triggered(bool)), this, SLOT(runExpression()));
makeCommandAction(ui->actionHideDebugger, "hide");
connect(ui->actionCpu, SIGNAL(triggered()), this, SLOT(displayCpuWidget()));
connect(ui->actionCpu, SIGNAL(triggered()), this, SLOT(displayCpuWidgetShowCpu()));
connect(ui->actionSymbolInfo, SIGNAL(triggered()), this, SLOT(displaySymbolWidget()));
connect(ui->actionModules, SIGNAL(triggered()), this, SLOT(displaySymbolWidget()));
connect(ui->actionSource, SIGNAL(triggered()), this, SLOT(displaySourceViewWidget()));
@ -1084,12 +1084,19 @@ void MainWindow::updateWindowTitleSlot(QString filename)
}
}
void MainWindow::displayCpuWidget()
// Used by View->CPU
void MainWindow::displayCpuWidgetShowCpu()
{
showQWidgetTab(mCpuWidget);
mCpuWidget->setDisasmFocus();
}
// GuiShowCpu()
void MainWindow::displayCpuWidget()
{
showQWidgetTab(mCpuWidget);
}
void MainWindow::displaySymbolWidget()
{
showQWidgetTab(mSymbolView);

View File

@ -83,6 +83,7 @@ public slots:
void execTRWord();
void execTRNone();
void displayCpuWidget();
void displayCpuWidgetShowCpu();
void displaySymbolWidget();
void displaySourceViewWidget();
void displayReferencesWidget();

View File

@ -17,7 +17,6 @@ SettingsDialog::SettingsDialog(QWidget* parent) :
adjustSize();
bTokenizerConfigUpdated = false;
bDisableAutoCompleteUpdated = false;
bAsciiAddressDumpModeUpdated = false;
LoadSettings(); //load settings from file
connect(Bridge::getBridge(), SIGNAL(setLastException(uint)), this, SLOT(setLastException(uint)));
lastException = 0;
@ -57,7 +56,8 @@ void SettingsDialog::LoadSettings()
settings.eventSystemBreakpoint = true;
settings.eventTlsCallbacks = true;
settings.eventEntryBreakpoint = true;
settings.eventAttachBreakpoint = true;
settings.eventNtTerminateProcess = false;
settings.engineType = DebugEngineTitanEngine;
settings.engineCalcType = calc_unsigned;
settings.engineBreakpointType = break_int3short;
settings.engineUndecorateSymbolNames = true;
@ -86,28 +86,35 @@ void SettingsDialog::LoadSettings()
settings.guiNoForegroundWindow = true;
settings.guiLoadSaveTabOrder = true;
settings.guiDisableAutoComplete = false;
settings.guiAsciiAddressDumpMode = false;
//Events tab
GetSettingBool("Events", "SystemBreakpoint", &settings.eventSystemBreakpoint);
GetSettingBool("Events", "NtTerminateProcess", &settings.eventNtTerminateProcess);
GetSettingBool("Events", "TlsCallbacks", &settings.eventTlsCallbacks);
GetSettingBool("Events", "TlsCallbacksSystem", &settings.eventTlsCallbacksSystem);
GetSettingBool("Events", "EntryBreakpoint", &settings.eventEntryBreakpoint);
GetSettingBool("Events", "DllEntry", &settings.eventDllEntry);
GetSettingBool("Events", "DllEntrySystem", &settings.eventDllEntrySystem);
GetSettingBool("Events", "ThreadEntry", &settings.eventThreadEntry);
GetSettingBool("Events", "AttachBreakpoint", &settings.eventAttachBreakpoint);
GetSettingBool("Events", "DllLoad", &settings.eventDllLoad);
GetSettingBool("Events", "DllUnload", &settings.eventDllUnload);
GetSettingBool("Events", "DllLoadSystem", &settings.eventDllLoadSystem);
GetSettingBool("Events", "DllUnloadSystem", &settings.eventDllUnloadSystem);
GetSettingBool("Events", "ThreadStart", &settings.eventThreadStart);
GetSettingBool("Events", "ThreadEnd", &settings.eventThreadEnd);
GetSettingBool("Events", "DebugStrings", &settings.eventDebugStrings);
ui->chkSystemBreakpoint->setCheckState(bool2check(settings.eventSystemBreakpoint));
ui->chkNtTerminateProcess->setCheckState(bool2check(settings.eventNtTerminateProcess));
ui->chkTlsCallbacks->setCheckState(bool2check(settings.eventTlsCallbacks));
ui->chkTlsCallbacksSystem->setCheckState(bool2check(settings.eventTlsCallbacksSystem));
ui->chkEntryBreakpoint->setCheckState(bool2check(settings.eventEntryBreakpoint));
ui->chkDllEntry->setCheckState(bool2check(settings.eventDllEntry));
ui->chkDllEntrySystem->setCheckState(bool2check(settings.eventDllEntrySystem));
ui->chkThreadEntry->setCheckState(bool2check(settings.eventThreadEntry));
ui->chkAttachBreakpoint->setCheckState(bool2check(settings.eventAttachBreakpoint));
ui->chkDllLoad->setCheckState(bool2check(settings.eventDllLoad));
ui->chkDllUnload->setCheckState(bool2check(settings.eventDllUnload));
ui->chkDllLoadSystem->setCheckState(bool2check(settings.eventDllLoadSystem));
ui->chkDllUnloadSystem->setCheckState(bool2check(settings.eventDllUnloadSystem));
ui->chkThreadStart->setCheckState(bool2check(settings.eventThreadStart));
ui->chkThreadEnd->setCheckState(bool2check(settings.eventThreadEnd));
ui->chkDebugStrings->setCheckState(bool2check(settings.eventDebugStrings));
@ -124,6 +131,10 @@ void SettingsDialog::LoadSettings()
break;
}
}
if(BridgeSettingGetUint("Engine", "DebugEngine", &cur))
{
settings.engineType = (DEBUG_ENGINE)cur;
}
if(BridgeSettingGetUint("Engine", "BreakpointType", &cur))
{
switch(cur)
@ -160,6 +171,15 @@ void SettingsDialog::LoadSettings()
ui->radioUnsigned->setChecked(true);
break;
}
switch(settings.engineType)
{
case DebugEngineTitanEngine:
ui->radioTitanEngine->setChecked(true);
break;
case DebugEngineGleeBug:
ui->radioGleeBug->setChecked(true);
break;
}
switch(settings.engineBreakpointType)
{
case break_int3short:
@ -249,7 +269,6 @@ void SettingsDialog::LoadSettings()
GetSettingBool("Gui", "GraphZoomMode", &settings.guiGraphZoomMode);
GetSettingBool("Gui", "ShowExitConfirmation", &settings.guiShowExitConfirmation);
GetSettingBool("Gui", "DisableAutoComplete", &settings.guiDisableAutoComplete);
GetSettingBool("Gui", "AsciiAddressDumpMode", &settings.guiAsciiAddressDumpMode);
ui->chkFpuRegistersLittleEndian->setChecked(settings.guiFpuRegistersLittleEndian);
ui->chkSaveColumnOrder->setChecked(settings.guiSaveColumnOrder);
ui->chkNoCloseDialog->setChecked(settings.guiNoCloseDialog);
@ -261,7 +280,6 @@ void SettingsDialog::LoadSettings()
ui->chkGraphZoomMode->setChecked(settings.guiGraphZoomMode);
ui->chkShowExitConfirmation->setChecked(settings.guiShowExitConfirmation);
ui->chkDisableAutoComplete->setChecked(settings.guiDisableAutoComplete);
ui->chkAsciiAddressDumpMode->setChecked(settings.guiAsciiAddressDumpMode);
//Misc tab
if(DbgFunctions()->GetJit)
@ -339,19 +357,24 @@ void SettingsDialog::SaveSettings()
{
//Events tab
BridgeSettingSetUint("Events", "SystemBreakpoint", settings.eventSystemBreakpoint);
BridgeSettingSetUint("Events", "NtTerminateProcess", settings.eventNtTerminateProcess);
BridgeSettingSetUint("Events", "TlsCallbacks", settings.eventTlsCallbacks);
BridgeSettingSetUint("Events", "TlsCallbacksSystem", settings.eventTlsCallbacksSystem);
BridgeSettingSetUint("Events", "EntryBreakpoint", settings.eventEntryBreakpoint);
BridgeSettingSetUint("Events", "DllEntry", settings.eventDllEntry);
BridgeSettingSetUint("Events", "DllEntrySystem", settings.eventDllEntrySystem);
BridgeSettingSetUint("Events", "ThreadEntry", settings.eventThreadEntry);
BridgeSettingSetUint("Events", "AttachBreakpoint", settings.eventAttachBreakpoint);
BridgeSettingSetUint("Events", "DllLoad", settings.eventDllLoad);
BridgeSettingSetUint("Events", "DllUnload", settings.eventDllUnload);
BridgeSettingSetUint("Events", "DllLoadSystem", settings.eventDllLoadSystem);
BridgeSettingSetUint("Events", "DllUnloadSystem", settings.eventDllUnloadSystem);
BridgeSettingSetUint("Events", "ThreadStart", settings.eventThreadStart);
BridgeSettingSetUint("Events", "ThreadEnd", settings.eventThreadEnd);
BridgeSettingSetUint("Events", "DebugStrings", settings.eventDebugStrings);
//Engine tab
BridgeSettingSetUint("Engine", "CalculationType", settings.engineCalcType);
BridgeSettingSetUint("Engine", "DebugEngine", settings.engineType);
BridgeSettingSetUint("Engine", "BreakpointType", settings.engineBreakpointType);
BridgeSettingSetUint("Engine", "UndecorateSymbolNames", settings.engineUndecorateSymbolNames);
BridgeSettingSetUint("Engine", "EnableDebugPrivilege", settings.engineEnableDebugPrivilege);
@ -406,7 +429,6 @@ void SettingsDialog::SaveSettings()
BridgeSettingSetUint("Gui", "GraphZoomMode", settings.guiGraphZoomMode);
BridgeSettingSetUint("Gui", "ShowExitConfirmation", settings.guiShowExitConfirmation);
BridgeSettingSetUint("Gui", "DisableAutoComplete", settings.guiDisableAutoComplete);
BridgeSettingSetUint("Gui", "AsciiAddressDumpMode", settings.guiAsciiAddressDumpMode);
//Misc tab
if(DbgFunctions()->GetJit)
@ -450,11 +472,6 @@ void SettingsDialog::SaveSettings()
emit Config()->disableAutoCompleteUpdated();
bDisableAutoCompleteUpdated = false;
}
if(bAsciiAddressDumpModeUpdated)
{
emit Config()->asciiAddressDumpModeUpdated();
bAsciiAddressDumpModeUpdated = false;
}
if(bGuiOptionsUpdated)
{
emit Config()->guiOptionsUpdated();
@ -505,58 +522,47 @@ void SettingsDialog::on_btnSave_clicked()
void SettingsDialog::on_chkSystemBreakpoint_stateChanged(int arg1)
{
if(arg1 == Qt::Unchecked)
settings.eventSystemBreakpoint = false;
else
settings.eventSystemBreakpoint = true;
settings.eventSystemBreakpoint = arg1 != Qt::Unchecked;
}
void SettingsDialog::on_chkNtTerminateProcess_stateChanged(int arg1)
{
settings.eventNtTerminateProcess = arg1 != Qt::Unchecked;
}
void SettingsDialog::on_chkTlsCallbacks_stateChanged(int arg1)
{
if(arg1 == Qt::Unchecked)
settings.eventTlsCallbacks = false;
else
settings.eventTlsCallbacks = true;
settings.eventTlsCallbacks = arg1 != Qt::Unchecked;
}
void SettingsDialog::on_chkTlsCallbacksSystem_stateChanged(int arg1)
{
settings.eventTlsCallbacksSystem = arg1 != Qt::Unchecked;
}
void SettingsDialog::on_chkEntryBreakpoint_stateChanged(int arg1)
{
if(arg1 == Qt::Unchecked)
settings.eventEntryBreakpoint = false;
else
settings.eventEntryBreakpoint = true;
settings.eventEntryBreakpoint = arg1 != Qt::Unchecked;
}
void SettingsDialog::on_chkDllEntry_stateChanged(int arg1)
{
if(arg1 == Qt::Unchecked)
settings.eventDllEntry = false;
else
settings.eventDllEntry = true;
settings.eventDllEntry = arg1 != Qt::Unchecked;
}
void SettingsDialog::on_chkDllEntrySystem_stateChanged(int arg1)
{
settings.eventDllEntrySystem = arg1 != Qt::Unchecked;
}
void SettingsDialog::on_chkThreadEntry_stateChanged(int arg1)
{
if(arg1 == Qt::Unchecked)
settings.eventThreadEntry = false;
else
settings.eventThreadEntry = true;
}
void SettingsDialog::on_chkAttachBreakpoint_stateChanged(int arg1)
{
if(arg1 == Qt::Unchecked)
settings.eventAttachBreakpoint = false;
else
settings.eventAttachBreakpoint = true;
settings.eventThreadEntry = arg1 != Qt::Unchecked;
}
void SettingsDialog::on_chkConfirmBeforeAtt_stateChanged(int arg1)
{
if(arg1 == Qt::Unchecked)
settings.miscSetJITAuto = false;
else
settings.miscSetJITAuto = true;
settings.miscSetJITAuto = arg1 != Qt::Unchecked;
}
void SettingsDialog::on_chkSetJIT_stateChanged(int arg1)
@ -608,6 +614,16 @@ void SettingsDialog::on_chkDllUnload_stateChanged(int arg1)
settings.eventDllUnload = arg1 != Qt::Unchecked;
}
void SettingsDialog::on_chkDllLoadSystem_stateChanged(int arg1)
{
settings.eventDllLoadSystem = arg1 != Qt::Unchecked;
}
void SettingsDialog::on_chkDllUnloadSystem_stateChanged(int arg1)
{
settings.eventDllUnloadSystem = arg1 != Qt::Unchecked;
}
void SettingsDialog::on_chkThreadStart_stateChanged(int arg1)
{
settings.eventThreadStart = arg1 != Qt::Unchecked;
@ -633,6 +649,16 @@ void SettingsDialog::on_radioSigned_clicked()
settings.engineCalcType = calc_signed;
}
void SettingsDialog::on_radioTitanEngine_clicked()
{
settings.engineType = DebugEngineTitanEngine;
}
void SettingsDialog::on_radioGleeBug_clicked()
{
settings.engineType = DebugEngineGleeBug;
}
void SettingsDialog::on_radioInt3Short_clicked()
{
settings.engineBreakpointType = break_int3short;
@ -919,12 +945,6 @@ void SettingsDialog::on_chkDisableAutoComplete_toggled(bool checked)
bDisableAutoCompleteUpdated = true;
}
void SettingsDialog::on_chkAsciiAddressDumpMode_toggled(bool checked)
{
settings.guiAsciiAddressDumpMode = checked;
bAsciiAddressDumpModeUpdated = true;
}
void SettingsDialog::on_chkUseLocalHelpFile_toggled(bool checked)
{
settings.miscUseLocalHelpFile = checked;

View File

@ -2,6 +2,7 @@
#define SETTINGSDIALOG_H
#include <QDialog>
#include "Imports.h"
namespace Ui
{
@ -28,19 +29,25 @@ private slots:
void on_btnSave_clicked();
//Event tab
void on_chkSystemBreakpoint_stateChanged(int arg1);
void on_chkNtTerminateProcess_stateChanged(int arg1);
void on_chkTlsCallbacks_stateChanged(int arg1);
void on_chkTlsCallbacksSystem_stateChanged(int arg1);
void on_chkEntryBreakpoint_stateChanged(int arg1);
void on_chkDllEntry_stateChanged(int arg1);
void on_chkDllEntrySystem_stateChanged(int arg1);
void on_chkThreadEntry_stateChanged(int arg1);
void on_chkAttachBreakpoint_stateChanged(int arg1);
void on_chkDllLoad_stateChanged(int arg1);
void on_chkDllUnload_stateChanged(int arg1);
void on_chkDllLoadSystem_stateChanged(int arg1);
void on_chkDllUnloadSystem_stateChanged(int arg1);
void on_chkThreadStart_stateChanged(int arg1);
void on_chkThreadEnd_stateChanged(int arg1);
void on_chkDebugStrings_stateChanged(int arg1);
//Engine tab
void on_radioUnsigned_clicked();
void on_radioSigned_clicked();
void on_radioTitanEngine_clicked();
void on_radioGleeBug_clicked();
void on_radioInt3Short_clicked();
void on_radioInt3Long_clicked();
void on_radioUd2_clicked();
@ -87,7 +94,6 @@ private slots:
void on_chkNoForegroundWindow_toggled(bool checked);
void on_chkShowExitConfirmation_toggled(bool checked);
void on_chkDisableAutoComplete_toggled(bool checked);
void on_chkAsciiAddressDumpMode_toggled(bool checked);
//Misc tab
void on_chkSetJIT_stateChanged(int arg1);
void on_chkConfirmBeforeAtt_stateChanged(int arg1);
@ -135,18 +141,23 @@ private:
{
//Event Tab
bool eventSystemBreakpoint;
bool eventNtTerminateProcess;
bool eventTlsCallbacks;
bool eventTlsCallbacksSystem;
bool eventEntryBreakpoint;
bool eventDllEntry;
bool eventDllEntrySystem;
bool eventThreadEntry;
bool eventAttachBreakpoint;
bool eventDllLoad;
bool eventDllUnload;
bool eventDllLoadSystem;
bool eventDllUnloadSystem;
bool eventThreadStart;
bool eventThreadEnd;
bool eventDebugStrings;
//Engine Tab
CalcType engineCalcType;
DEBUG_ENGINE engineType;
BreakpointType engineBreakpointType;
bool engineUndecorateSymbolNames;
bool engineEnableDebugPrivilege;
@ -191,7 +202,6 @@ private:
bool guiGraphZoomMode;
bool guiShowExitConfirmation;
bool guiDisableAutoComplete;
bool guiAsciiAddressDumpMode;
//Misc Tab
bool miscSetJIT;
bool miscSetJITAuto;
@ -213,7 +223,6 @@ private:
bool bGuiOptionsUpdated;
bool bTokenizerConfigUpdated;
bool bDisableAutoCompleteUpdated;
bool bAsciiAddressDumpModeUpdated;
//functions
void GetSettingBool(const char* section, const char* name, bool* set);

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>381</width>
<height>514</height>
<height>525</height>
</rect>
</property>
<property name="sizePolicy">
@ -40,100 +40,14 @@
<string>Events</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QCheckBox" name="chkSystemBreakpoint">
<item row="11" column="1">
<widget class="QCheckBox" name="chkDllUnloadSystem">
<property name="text">
<string>System Breakpoint*</string>
</property>
<property name="checked">
<bool>false</bool>
<string>System DLL Unload</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblBreakOn">
<property name="text">
<string>Break on:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="chkDllLoad">
<property name="text">
<string>DLL Load</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QCheckBox" name="chkAttachBreakpoint">
<property name="text">
<string>Attach Breakpoint</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="chkDllEntry">
<property name="text">
<string>DLL Entry</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="chkEntryBreakpoint">
<property name="text">
<string>Entry Breakpoint*</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="chkDllUnload">
<property name="text">
<string>DLL Unload</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="chkTlsCallbacks">
<property name="text">
<string>TLS Callbacks*</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="chkThreadEnd">
<property name="text">
<string>Thread End</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QCheckBox" name="chkThreadEntry">
<property name="text">
<string>Thread Entry</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QCheckBox" name="chkDebugStrings">
<property name="text">
<string>Debug Strings</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="chkThreadStart">
<property name="text">
<string>Thread Start</string>
</property>
</widget>
</item>
<item row="11" column="0">
<item row="12" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -146,6 +60,120 @@
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="chkEntryBreakpoint">
<property name="text">
<string>Entry Breakpoint*</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="chkDllEntrySystem">
<property name="text">
<string>System DLL Entry</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="chkSystemBreakpoint">
<property name="text">
<string>System Breakpoint*</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="chkNtTerminateProcess">
<property name="text">
<string>NtTerminateProcess*</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QCheckBox" name="chkDllLoadSystem">
<property name="text">
<string>System DLL Load</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="chkThreadStart">
<property name="text">
<string>Thread Start</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblBreakOn">
<property name="text">
<string>Break on:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="chkThreadEnd">
<property name="text">
<string>Thread End</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="chkDebugStrings">
<property name="text">
<string>Debug Strings</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="chkThreadEntry">
<property name="text">
<string>Thread Entry</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="chkTlsCallbacksSystem">
<property name="text">
<string>System TLS Callbacks*</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="chkTlsCallbacks">
<property name="text">
<string>TLS Callbacks*</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="chkDllEntry">
<property name="text">
<string>DLL Entry</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="chkDllLoad">
<property name="text">
<string>DLL Load</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QCheckBox" name="chkDllUnload">
<property name="text">
<string>DLL Unload</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabEngine">
@ -166,22 +194,19 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QGroupBox" name="groupBoxCalculationType">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Calculation Type</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QHBoxLayout" name="layoutCalulationType">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="groupBoxCalculationType">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Calculation Type</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QRadioButton" name="radioSigned">
<property name="text">
@ -200,9 +225,35 @@
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxDebugEngine">
<property name="title">
<string>Debug Engine*</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="radioTitanEngine">
<property name="text">
<string>TitanEngine</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioGleeBug">
<property name="text">
<string>GleeBug</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxDefaultBreakpointType">
@ -738,13 +789,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkAsciiAddressDumpMode">
<property name="text">
<string>Show ASCII/Unicode in address dump mode</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacerGUI">
<property name="orientation">
@ -943,18 +987,7 @@
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>chkSystemBreakpoint</tabstop>
<tabstop>chkDllLoad</tabstop>
<tabstop>chkTlsCallbacks</tabstop>
<tabstop>chkDllUnload</tabstop>
<tabstop>chkEntryBreakpoint</tabstop>
<tabstop>chkThreadStart</tabstop>
<tabstop>chkDllEntry</tabstop>
<tabstop>chkThreadEnd</tabstop>
<tabstop>chkAttachBreakpoint</tabstop>
<tabstop>chkDebugStrings</tabstop>
<tabstop>chkThreadEntry</tabstop>
<tabstop>radioSigned</tabstop>
<tabstop>radioUnsigned</tabstop>
<tabstop>radioInt3Short</tabstop>
<tabstop>radioInt3Long</tabstop>
<tabstop>radioUd2</tabstop>

View File

@ -51,7 +51,7 @@
<item>
<widget class="QGroupBox" name="groupBoxDebuggee">
<property name="title">
<string>2. System breakpoint script for a specific process (attach to a process to specify)</string>
<string>2. System breakpoint script for a specific process (debug a process to specify)</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>

View File

@ -355,12 +355,12 @@ void ThreadView::updateThreadList()
setCellContent(i, 12, ToLongLongHexString(threadList.list[i].Cycles));
setCellContent(i, 13, threadList.list[i].BasicInfo.threadName);
}
mCurrentThreadId = "NONE";
mCurrentThreadId = -1;
if(threadList.count)
{
int currentThread = threadList.CurrentThread;
if(currentThread >= 0 && currentThread < threadList.count)
mCurrentThreadId = ToHexString(threadList.list[currentThread].BasicInfo.ThreadId);
mCurrentThreadId = threadList.list[currentThread].BasicInfo.ThreadId;
BridgeFree(threadList.list);
}
reloadData();
@ -369,7 +369,7 @@ void ThreadView::updateThreadList()
QString ThreadView::paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h)
{
QString ret = StdTable::paintContent(painter, rowBase, rowOffset, col, x, y, w, h);
QString threadId = getCellContent(rowBase + rowOffset, 1);
duint threadId = getCellUserdata(rowBase + rowOffset, 1);
if(threadId == mCurrentThreadId && !col)
{
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("ThreadCurrentBackgroundColor")));
@ -382,21 +382,21 @@ QString ThreadView::paintContent(QPainter* painter, dsint rowBase, int rowOffset
void ThreadView::doubleClickedSlot()
{
QString threadId = getCellContent(getInitialSelection(), 1);
DbgCmdExecDirect(QString("switchthread " + threadId));
duint threadId = getCellUserdata(getInitialSelection(), 1);
DbgCmdExecDirect("switchthread " + ToHexString(threadId));
QString addr_text = getCellContent(getInitialSelection(), 4);
DbgCmdExecDirect(QString("disasm " + addr_text));
DbgCmdExec("disasm " + addr_text);
}
void ThreadView::SetNameSlot()
{
QString threadId = getCellContent(getInitialSelection(), 1);
duint threadId = getCellUserdata(getInitialSelection(), 1);
LineEditDialog mLineEdit(this);
mLineEdit.setWindowTitle(tr("Name") + threadId);
mLineEdit.setText(getCellContent(getInitialSelection(), 13));
if(mLineEdit.exec() != QDialog::Accepted)
return;
QString escapedName = mLineEdit.editText.replace("\"", "\\\"");
DbgCmdExec(QString("setthreadname %1, \"%2\"").arg(threadId).arg(escapedName));
DbgCmdExec(QString("setthreadname %1, \"%2\"").arg(ToHexString(threadId)).arg(escapedName));
}

View File

@ -22,7 +22,7 @@ public slots:
private:
QAction* makeCommandAction(QAction* action, const QString & command);
QString mCurrentThreadId;
duint mCurrentThreadId;
MenuBuilder* mMenuBuilder;
};

View File

@ -161,6 +161,14 @@ void WatchView::setupContextMenu()
watchdogBuilder->addAction(makeAction(DIcon("treat_selection_as_tbyte.png"), tr("Is true"), SLOT(watchdogIsTrueSlot()))); // TODO: better icon
watchdogBuilder->addAction(makeAction(DIcon("treat_selection_as_fword.png"), tr("Is false"), SLOT(watchdogIsFalseSlot())));
mMenu->addMenu(watchdogMenu, watchdogBuilder);
MenuBuilder* typeBuilder = new MenuBuilder(this, nonEmptyFunc);
QMenu* typeMenu = new QMenu(tr("Type"), this);
typeBuilder->addAction(makeAction(DIcon("integer.png"), tr("Uint"), SLOT(setTypeUintSlot())));
typeBuilder->addAction(makeAction(DIcon("integer.png"), tr("Int"), SLOT(setTypeIntSlot())));
typeBuilder->addAction(makeAction(DIcon("float.png"), tr("Float"), SLOT(setTypeFloatSlot())));
typeBuilder->addAction(makeAction(DIcon("ascii.png"), tr("Ascii"), SLOT(setTypeAsciiSlot())));
typeBuilder->addAction(makeAction(DIcon("ascii-extended.png"), tr("Unicode"), SLOT(setTypeUnicodeSlot())));
mMenu->addMenu(typeMenu, typeBuilder);
mMenu->addSeparator();
MenuBuilder* copyMenu = new MenuBuilder(this);
setupCopyMenu(copyMenu);
@ -240,7 +248,8 @@ void WatchView::modifyWatchSlot()
void WatchView::editWatchSlot()
{
QString expr;
if(SimpleInputBox(this, tr("Enter the expression to watch"), "", expr, tr("Example: [EAX]")))
QString originalExpr = getCellContent(getInitialSelection(), 1);
if(SimpleInputBox(this, tr("Enter the expression to watch"), originalExpr, expr, tr("Example: [EAX]")))
DbgCmdExecDirect(QString("SetWatchExpression ").append(getSelectedId()).append(",").append(expr));
updateWatch();
}
@ -274,3 +283,33 @@ void WatchView::watchdogIsFalseSlot()
DbgCmdExecDirect(QString("SetWatchdog %1, \"isfalse\"").arg(getSelectedId()));
updateWatch();
}
void WatchView::setTypeUintSlot()
{
DbgCmdExecDirect(QString("SetWatchType %1, \"uint\"").arg(getSelectedId()));
updateWatch();
}
void WatchView::setTypeIntSlot()
{
DbgCmdExecDirect(QString("SetWatchType %1, \"int\"").arg(getSelectedId()));
updateWatch();
}
void WatchView::setTypeFloatSlot()
{
DbgCmdExecDirect(QString("SetWatchType %1, \"float\"").arg(getSelectedId()));
updateWatch();
}
void WatchView::setTypeAsciiSlot()
{
DbgCmdExecDirect(QString("SetWatchType %1, \"ascii\"").arg(getSelectedId()));
updateWatch();
}
void WatchView::setTypeUnicodeSlot()
{
DbgCmdExecDirect(QString("SetWatchType %1, \"unicode\"").arg(getSelectedId()));
updateWatch();
}

View File

@ -26,6 +26,11 @@ public slots:
void watchdogUnchangedSlot();
void watchdogIsTrueSlot();
void watchdogIsFalseSlot();
void setTypeUintSlot();
void setTypeIntSlot();
void setTypeFloatSlot();
void setTypeAsciiSlot();
void setTypeUnicodeSlot();
protected:
void setupContextMenu();

View File

@ -69,23 +69,23 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
defaultColors.insert("DisassemblyFunctionColor", QColor("#000000"));
defaultColors.insert("DisassemblyLoopColor", QColor("#000000"));
defaultColors.insert("SideBarBackgroundColor", QColor("#FFF8F0"));
defaultColors.insert("SideBarCipLabelColor", QColor("#FFFFFF"));
defaultColors.insert("SideBarCipLabelBackgroundColor", QColor("#4040FF"));
defaultColors.insert("SideBarBackgroundColor", QColor("#FFF8F0"));
defaultColors.insert("SideBarConditionalJumpLineTrueColor", QColor("#FF0000"));
defaultColors.insert("SideBarConditionalJumpLineFalseColor", QColor("#00BBFF"));
defaultColors.insert("SideBarUnconditionalJumpLineTrueColor", QColor("#FF0000"));
defaultColors.insert("SideBarUnconditionalJumpLineFalseColor", QColor("#00BBFF"));
defaultColors.insert("SideBarConditionalJumpLineTrueBackwardsColor", QColor("#FF0000"));
defaultColors.insert("SideBarConditionalJumpLineFalseBackwardsColor", QColor("#FFA500"));
defaultColors.insert("SideBarUnconditionalJumpLineTrueBackwardsColor", QColor("#FF0000"));
defaultColors.insert("SideBarUnconditionalJumpLineFalseBackwardsColor", QColor("#FFA500"));
defaultColors.insert("SideBarBulletColor", QColor("#808080"));
defaultColors.insert("SideBarBulletBreakpointColor", QColor("#FF0000"));
defaultColors.insert("SideBarBulletDisabledBreakpointColor", QColor("#00AA00"));
defaultColors.insert("SideBarBulletBookmarkColor", QColor("#FEE970"));
defaultColors.insert("SideBarCheckBoxForeColor", QColor("#000000"));
defaultColors.insert("SideBarCheckBoxBackColor", QColor("#FFFFFF"));
defaultColors.insert("SideBarConditionalJumpLineTrueColor", QColor("#FF0000"));
defaultColors.insert("SideBarConditionalJumpLineTrueBackwardsColor", QColor("#FF0000"));
defaultColors.insert("SideBarConditionalJumpLineFalseColor", QColor("#00BBFF"));
defaultColors.insert("SideBarConditionalJumpLineFalseBackwardsColor", QColor("#FFA500"));
defaultColors.insert("SideBarUnconditionalJumpLineTrueColor", QColor("#FF0000"));
defaultColors.insert("SideBarUnconditionalJumpLineTrueBackwardsColor", QColor("#FF0000"));
defaultColors.insert("SideBarUnconditionalJumpLineFalseColor", QColor("#00BBFF"));
defaultColors.insert("SideBarUnconditionalJumpLineFalseBackwardsColor", QColor("#FFA500"));
defaultColors.insert("RegistersBackgroundColor", QColor("#FFF8F0"));
defaultColors.insert("RegistersColor", QColor("#000000"));
@ -670,21 +670,15 @@ void Configuration::readColors()
{
Colors = defaultColors;
//read config
for(int i = 0; i < Colors.size(); i++)
{
QString id = Colors.keys().at(i);
Colors[id] = colorFromConfig(id);
}
for(auto it = Colors.begin(); it != Colors.end(); ++it)
it.value() = colorFromConfig(it.key());
}
void Configuration::writeColors()
{
//write config
for(int i = 0; i < Colors.size(); i++)
{
QString id = Colors.keys().at(i);
colorToConfig(id, Colors[id]);
}
for(auto it = Colors.begin(); it != Colors.end(); ++it)
colorToConfig(it.key(), it.value());
emit colorsUpdated();
}
@ -692,14 +686,12 @@ void Configuration::readBools()
{
Bools = defaultBools;
//read config
for(int i = 0; i < Bools.size(); i++)
for(auto itMap = Bools.begin(); itMap != Bools.end(); ++itMap)
{
QString category = Bools.keys().at(i);
QMap<QString, bool> & currentBool = Bools[category];
for(int j = 0; j < currentBool.size(); j++)
const QString & category = itMap.key();
for(auto it = itMap.value().begin(); it != itMap.value().end(); it++)
{
QString id = currentBool.keys().at(j);
currentBool[id] = boolFromConfig(category, id);
it.value() = boolFromConfig(category, it.key());
}
}
}
@ -707,14 +699,12 @@ void Configuration::readBools()
void Configuration::writeBools()
{
//write config
for(int i = 0; i < Bools.size(); i++)
for(auto itMap = Bools.cbegin(); itMap != Bools.cend(); ++itMap)
{
QString category = Bools.keys().at(i);
QMap<QString, bool>* currentBool = &Bools[category];
for(int j = 0; j < currentBool->size(); j++)
const QString & category = itMap.key();
for(auto it = itMap.value().cbegin(); it != itMap.value().cend(); it++)
{
QString id = (*currentBool).keys().at(j);
boolToConfig(category, id, (*currentBool)[id]);
boolToConfig(category, it.key(), it.value());
}
}
}
@ -723,14 +713,12 @@ void Configuration::readUints()
{
Uints = defaultUints;
//read config
for(int i = 0; i < Uints.size(); i++)
for(auto itMap = Uints.begin(); itMap != Uints.end(); ++itMap)
{
QString category = Uints.keys().at(i);
QMap<QString, duint> & currentUint = Uints[category];
for(int j = 0; j < currentUint.size(); j++)
const QString & category = itMap.key();
for(auto it = itMap.value().begin(); it != itMap.value().end(); it++)
{
QString id = currentUint.keys().at(j);
currentUint[id] = uintFromConfig(category, id);
it.value() = uintFromConfig(category, it.key());
}
}
}
@ -741,19 +729,17 @@ void Configuration::writeUints()
bool bSaveLoadTabOrder = ConfigBool("Gui", "LoadSaveTabOrder");
//write config
for(int i = 0; i < Uints.size(); i++)
for(auto itMap = Bools.cbegin(); itMap != Bools.cend(); ++itMap)
{
QString category = Uints.keys().at(i);
QMap<QString, duint>* currentUint = &Uints[category];
for(int j = 0; j < currentUint->size(); j++)
const QString & category = itMap.key();
for(auto it = itMap.value().cbegin(); it != itMap.value().cend(); it++)
{
QString id = (*currentUint).keys().at(j);
// Do not save settings to file if saveLoadTabOrder checkbox is Unchecked
const QString & id = it.key();
if(!bSaveLoadTabOrder && category == "TabOrder" && BridgeSettingGetUint(category.toUtf8().constData(), id.toUtf8().constData(), &setting))
continue;
uintToConfig(category, id, (*currentUint)[id]);
uintToConfig(category, id, it.value());
}
}
}
@ -762,24 +748,21 @@ void Configuration::readFonts()
{
Fonts = defaultFonts;
//read config
for(int i = 0; i < Fonts.size(); i++)
for(auto it = Fonts.begin(); it != Fonts.end(); ++it)
{
QString id = Fonts.keys().at(i);
const QString & id = it.key();
QFont font = fontFromConfig(id);
QFontInfo fontInfo(font);
if(id == "Application" || fontInfo.fixedPitch())
Fonts[id] = font;
it.value() = font;
}
}
void Configuration::writeFonts()
{
//write config
for(int i = 0; i < Fonts.size(); i++)
{
QString id = Fonts.keys().at(i);
fontToConfig(id, Fonts[id]);
}
for(auto it = Fonts.cbegin(); it != Fonts.cend(); ++it)
fontToConfig(it.key(), it.value());
emit fontsUpdated();
}

View File

@ -33,7 +33,7 @@ public:
bool GlobalShortcut;
Shortcut(QString name = QString(), QString hotkey = QString(), bool global = false)
: Name(name), Hotkey(hotkey), GlobalShortcut(global) { }
: Name(name), Hotkey(hotkey, QKeySequence::PortableText), GlobalShortcut(global) { }
Shortcut(std::initializer_list<QString> names, QString hotkey = QString(), bool global = false)
: Shortcut(QStringList(names).join(" -> "), hotkey, global) { }
@ -112,7 +112,6 @@ signals:
void shortcutsUpdated();
void tokenizerConfigUpdated();
void disableAutoCompleteUpdated();
void asciiAddressDumpModeUpdated();
private:
QColor colorFromConfig(const QString & id);

View File

@ -7,12 +7,16 @@
#include "ComboBoxDialog.h"
#include "StringUtil.h"
#include "BrowseDialog.h"
#include <thread>
void SetApplicationIcon(WId winId)
{
HICON hIcon = LoadIcon(GetModuleHandleW(0), MAKEINTRESOURCE(100));
SendMessageW((HWND)winId, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
DestroyIcon(hIcon);
std::thread([winId]
{
HICON hIcon = LoadIcon(GetModuleHandleW(0), MAKEINTRESOURCE(100));
SendMessageW((HWND)winId, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
DestroyIcon(hIcon);
}).detach();
}
QByteArray & ByteReverse(QByteArray & array)
@ -39,7 +43,7 @@ QByteArray ByteReverse(QByteArray && array)
return array;
}
bool SimpleInputBox(QWidget* parent, const QString & title, QString defaultValue, QString & output, const QString & placeholderText, QIcon* icon)
bool SimpleInputBox(QWidget* parent, const QString & title, QString defaultValue, QString & output, const QString & placeholderText, const QIcon* icon)
{
LineEditDialog mEdit(parent);
mEdit.setWindowIcon(icon ? *icon : parent->windowIcon());
@ -56,7 +60,7 @@ bool SimpleInputBox(QWidget* parent, const QString & title, QString defaultValue
return false;
}
bool SimpleChoiceBox(QWidget* parent, const QString & title, QString defaultValue, const QStringList & choices, QString & output, bool editable, const QString & placeholderText, QIcon* icon, int minimumContentsLength)
bool SimpleChoiceBox(QWidget* parent, const QString & title, QString defaultValue, const QStringList & choices, QString & output, bool editable, const QString & placeholderText, const QIcon* icon, int minimumContentsLength)
{
ComboBoxDialog mChoice(parent);
mChoice.setWindowIcon(icon ? *icon : parent->windowIcon());

View File

@ -11,8 +11,8 @@ class QByteArray;
void SetApplicationIcon(WId winId);
QByteArray & ByteReverse(QByteArray & array);
QByteArray ByteReverse(QByteArray && array);
bool SimpleInputBox(QWidget* parent, const QString & title, QString defaultValue, QString & output, const QString & placeholderText, QIcon* icon = nullptr);
bool SimpleChoiceBox(QWidget* parent, const QString & title, QString defaultValue, const QStringList & choices, QString & output, bool editable, const QString & placeholderText, QIcon* icon = nullptr, int minimumContentsLength = -1);
bool SimpleInputBox(QWidget* parent, const QString & title, QString defaultValue, QString & output, const QString & placeholderText, const QIcon* icon = nullptr);
bool SimpleChoiceBox(QWidget* parent, const QString & title, QString defaultValue, const QStringList & choices, QString & output, bool editable, const QString & placeholderText, const QIcon* icon = nullptr, int minimumContentsLength = -1);
void SimpleErrorBox(QWidget* parent, const QString & title, const QString & text);
void SimpleWarningBox(QWidget* parent, const QString & title, const QString & text);
void SimpleInfoBox(QWidget* parent, const QString & title, const QString & text);
@ -23,5 +23,12 @@ bool isEaster();
QString couldItBeSeasonal(QString icon);
QIcon getFileIcon(QString file);
#define DIcon(file) QIcon(QString(":/icons/images/").append(couldItBeSeasonal(file)))
template<int>
static const QIcon & DIconHelper(const QString & file)
{
static QIcon icon(QString(":/icons/images/").append(couldItBeSeasonal(file)));
return icon;
}
#define DIcon(file) DIconHelper<__LINE__>(file)
#endif // MISCUTIL_H

View File

@ -85,4 +85,9 @@ QTabBar QToolButton::hover {
QTabBar::scroller {
width: 15px;
}
/* JIT debugger in SettingsDialog */
QLineEdit:read-only {
background-color: #f0f0f0;
}

View File

@ -399,7 +399,7 @@ bool Zydis::IsBranchType(std::underlying_type_t<BranchType> bt) const
ZydisMnemonic Zydis::GetId() const
{
if(!Success())
DebugBreak();
return ZYDIS_MNEMONIC_INVALID;
return mInstr.mnemonic;
}