1
0
Fork 0

PROJECT: code formatting

This commit is contained in:
Mr. eXoDia 2014-08-05 01:06:59 +02:00
parent 4a51b9dc5f
commit 9b1867bb5b
158 changed files with 5767 additions and 5767 deletions

View File

@ -4,7 +4,7 @@
#include <new>
static HINSTANCE hInst;
static char szIniFile[1024]="";
static char szIniFile[1024] = "";
#ifdef _WIN64
#define dbg_lib "x64_dbg.dll"
@ -34,17 +34,17 @@ BRIDGE_IMPEXP const char* BridgeInit()
///Settings load
if(!GetModuleFileNameA(0, szIniFile, 1024))
return "Error getting module path!";
int len=(int)strlen(szIniFile);
while(szIniFile[len]!='.' && szIniFile[len]!='\\' && len)
int len = (int)strlen(szIniFile);
while(szIniFile[len] != '.' && szIniFile[len] != '\\' && len)
len--;
if(szIniFile[len]=='\\')
if(szIniFile[len] == '\\')
strcat(szIniFile, ".ini");
else
strcpy(&szIniFile[len], ".ini");
HINSTANCE hInst;
const char* szLib;
static char szError[256]="";
static char szError[256] = "";
//GUI Load
LOADLIBRARY(gui_lib);
@ -86,7 +86,7 @@ BRIDGE_IMPEXP const char* BridgeStart()
BRIDGE_IMPEXP void* BridgeAlloc(size_t size)
{
unsigned char* a=(unsigned char*)GlobalAlloc(GMEM_FIXED, size);
unsigned char* a = (unsigned char*)GlobalAlloc(GMEM_FIXED, size);
if(!a)
{
MessageBoxA(0, "Could not allocate memory", "Error", MB_ICONERROR);
@ -114,13 +114,13 @@ BRIDGE_IMPEXP bool BridgeSettingGetUint(const char* section, const char* key, du
{
if(!section || !key || !value)
return false;
char newvalue[MAX_SETTING_SIZE]="";
char newvalue[MAX_SETTING_SIZE] = "";
if(!BridgeSettingGet(section, key, newvalue))
return false;
#ifdef _WIN64
int ret=sscanf(newvalue, "%llX", value);
int ret = sscanf(newvalue, "%llX", value);
#else
int ret=sscanf(newvalue, "%X", value);
int ret = sscanf(newvalue, "%X", value);
#endif //_WIN64
if(ret)
return true;
@ -140,7 +140,7 @@ BRIDGE_IMPEXP bool BridgeSettingSetUint(const char* section, const char* key, du
{
if(!section || !key)
return false;
char newvalue[MAX_SETTING_SIZE]="";
char newvalue[MAX_SETTING_SIZE] = "";
#ifdef _WIN64
sprintf(newvalue, "%llX", value);
#else
@ -162,7 +162,7 @@ BRIDGE_IMPEXP bool DbgMemRead(duint va, unsigned char* dest, duint size)
GuiAddLogMessage("DbgMemRead with invalid boundaries!\n");
return false;
}
bool ret=_dbg_memread(va, dest, size, 0);
bool ret = _dbg_memread(va, dest, size, 0);
if(!ret)
memset(dest, 0x90, size);
return ret;
@ -180,7 +180,7 @@ BRIDGE_IMPEXP bool DbgMemWrite(duint va, const unsigned char* src, duint size)
BRIDGE_IMPEXP duint DbgMemGetPageSize(duint base)
{
duint size=0;
duint size = 0;
_dbg_memfindbaseaddr(base, &size);
return size;
}
@ -202,7 +202,7 @@ BRIDGE_IMPEXP bool DbgMemMap(MEMMAP* memmap)
BRIDGE_IMPEXP bool DbgIsValidExpression(const char* expression)
{
duint value=0;
duint value = 0;
return _dbg_valfromstring(expression, &value);
}
@ -222,10 +222,10 @@ BRIDGE_IMPEXP bool DbgGetLabelAt(duint addr, SEGMENTREG segment, char* text) //(
return false;
ADDRINFO info;
memset(&info, 0, sizeof(info));
info.flags=flaglabel;
info.flags = flaglabel;
if(!_dbg_addrinfoget(addr, segment, &info))
{
duint addr_=0;
duint addr_ = 0;
if(!DbgMemIsValidReadPtr(addr))
return false;
DbgMemRead(addr, (unsigned char*)&addr_, sizeof(duint));
@ -240,11 +240,11 @@ BRIDGE_IMPEXP bool DbgGetLabelAt(duint addr, SEGMENTREG segment, char* text) //(
BRIDGE_IMPEXP bool DbgSetLabelAt(duint addr, const char* text)
{
if(!text || strlen(text)>=MAX_LABEL_SIZE || !addr)
if(!text || strlen(text) >= MAX_LABEL_SIZE || !addr)
return false;
ADDRINFO info;
memset(&info, 0, sizeof(info));
info.flags=flaglabel;
info.flags = flaglabel;
strcpy(info.label, text);
if(!_dbg_addrinfoset(addr, &info))
return false;
@ -257,7 +257,7 @@ BRIDGE_IMPEXP bool DbgGetCommentAt(duint addr, char* text) //comment (not live)
return false;
ADDRINFO info;
memset(&info, 0, sizeof(info));
info.flags=flagcomment;
info.flags = flagcomment;
if(!_dbg_addrinfoget(addr, SEG_DEFAULT, &info))
return false;
strcpy(text, info.comment);
@ -266,11 +266,11 @@ BRIDGE_IMPEXP bool DbgGetCommentAt(duint addr, char* text) //comment (not live)
BRIDGE_IMPEXP bool DbgSetCommentAt(duint addr, const char* text)
{
if(!text || strlen(text)>=MAX_COMMENT_SIZE || !addr)
if(!text || strlen(text) >= MAX_COMMENT_SIZE || !addr)
return false;
ADDRINFO info;
memset(&info, 0, sizeof(info));
info.flags=flagcomment;
info.flags = flagcomment;
strcpy(info.comment, text);
if(!_dbg_addrinfoset(addr, &info))
return false;
@ -283,7 +283,7 @@ BRIDGE_IMPEXP bool DbgGetModuleAt(duint addr, char* text)
return false;
ADDRINFO info;
memset(&info, 0, sizeof(info));
info.flags=flagmodule;
info.flags = flagmodule;
if(!_dbg_addrinfoget(addr, SEG_DEFAULT, &info))
return false;
strcpy(text, info.module);
@ -296,7 +296,7 @@ BRIDGE_IMPEXP bool DbgGetBookmarkAt(duint addr)
return false;
ADDRINFO info;
memset(&info, 0, sizeof(info));
info.flags=flagbookmark;
info.flags = flagbookmark;
if(!_dbg_addrinfoget(addr, SEG_DEFAULT, &info))
return false;
return info.isbookmark;
@ -308,8 +308,8 @@ BRIDGE_IMPEXP bool DbgSetBookmarkAt(duint addr, bool isbookmark)
return false;
ADDRINFO info;
memset(&info, 0, sizeof(info));
info.flags=flagbookmark;
info.isbookmark=isbookmark;
info.flags = flagbookmark;
info.isbookmark = isbookmark;
return _dbg_addrinfoset(addr, &info);
}
@ -330,7 +330,7 @@ BRIDGE_IMPEXP BPXTYPE DbgGetBpxTypeAt(duint addr)
BRIDGE_IMPEXP duint DbgValFromString(const char* string)
{
duint value=0;
duint value = 0;
_dbg_valfromstring(string, &value);
return value;
}
@ -342,7 +342,7 @@ BRIDGE_IMPEXP bool DbgGetRegDump(REGDUMP* regdump)
BRIDGE_IMPEXP bool DbgValToString(const char* string, duint value)
{
duint valueCopy=value;
duint valueCopy = value;
return _dbg_valtostring(string, &valueCopy);
}
@ -365,16 +365,16 @@ BRIDGE_IMPEXP FUNCTYPE DbgGetFunctionTypeAt(duint addr)
{
ADDRINFO info;
memset(&info, 0, sizeof(info));
info.flags=flagfunction;
info.flags = flagfunction;
if(!_dbg_addrinfoget(addr, SEG_DEFAULT, &info))
return FUNC_NONE;
duint start=info.function.start;
duint end=info.function.end;
if(start==end)
duint start = info.function.start;
duint end = info.function.end;
if(start == end)
return FUNC_SINGLE;
else if(addr==start)
else if(addr == start)
return FUNC_BEGIN;
else if(addr==end)
else if(addr == end)
return FUNC_END;
return FUNC_MIDDLE;
}
@ -383,15 +383,15 @@ BRIDGE_IMPEXP LOOPTYPE DbgGetLoopTypeAt(duint addr, int depth)
{
ADDRINFO info;
memset(&info, 0, sizeof(info));
info.flags=flagloop;
info.loop.depth=depth;
info.flags = flagloop;
info.loop.depth = depth;
if(!_dbg_addrinfoget(addr, SEG_DEFAULT, &info))
return LOOP_NONE;
duint start=info.loop.start;
duint end=info.loop.end;
if(addr==start)
duint start = info.loop.start;
duint end = info.loop.end;
if(addr == start)
return LOOP_BEGIN;
else if(addr==end)
else if(addr == end)
return LOOP_END;
return LOOP_MIDDLE;
}
@ -465,9 +465,9 @@ BRIDGE_IMPEXP bool DbgScriptGetBranchInfo(int line, SCRIPTBRANCH* info)
BRIDGE_IMPEXP void DbgSymbolEnum(duint base, CBSYMBOLENUM cbSymbolEnum, void* user)
{
SYMBOLCBINFO cbInfo;
cbInfo.base=base;
cbInfo.cbSymbolEnum=cbSymbolEnum;
cbInfo.user=user;
cbInfo.base = base;
cbInfo.cbSymbolEnum = cbSymbolEnum;
cbInfo.user = user;
_dbg_sendmessage(DBG_SYMBOL_ENUM, &cbInfo, 0);
}
@ -517,19 +517,19 @@ BRIDGE_IMPEXP void DbgMenuEntryClicked(int hEntry)
BRIDGE_IMPEXP bool DbgFunctionGet(duint addr, duint* start, duint* end)
{
FUNCTION_LOOP_INFO info;
info.addr=addr;
info.addr = addr;
if(!_dbg_sendmessage(DBG_FUNCTION_GET, &info, 0))
return false;
*start=info.start;
*end=info.end;
*start = info.start;
*end = info.end;
return true;
}
BRIDGE_IMPEXP bool DbgFunctionOverlaps(duint start, duint end)
{
FUNCTION_LOOP_INFO info;
info.start=start;
info.end=end;
info.start = start;
info.end = end;
if(!_dbg_sendmessage(DBG_FUNCTION_OVERLAPS, &info, 0))
return false;
return true;
@ -538,9 +538,9 @@ BRIDGE_IMPEXP bool DbgFunctionOverlaps(duint start, duint end)
BRIDGE_IMPEXP bool DbgFunctionAdd(duint start, duint end)
{
FUNCTION_LOOP_INFO info;
info.start=start;
info.end=end;
info.manual=false;
info.start = start;
info.end = end;
info.manual = false;
if(!_dbg_sendmessage(DBG_FUNCTION_ADD, &info, 0))
return false;
return true;
@ -549,7 +549,7 @@ BRIDGE_IMPEXP bool DbgFunctionAdd(duint start, duint end)
BRIDGE_IMPEXP bool DbgFunctionDel(duint addr)
{
FUNCTION_LOOP_INFO info;
info.addr=addr;
info.addr = addr;
if(!_dbg_sendmessage(DBG_FUNCTION_DEL, &info, 0))
return false;
return true;
@ -558,21 +558,21 @@ BRIDGE_IMPEXP bool DbgFunctionDel(duint addr)
BRIDGE_IMPEXP bool DbgLoopGet(int depth, duint addr, duint* start, duint* end)
{
FUNCTION_LOOP_INFO info;
info.addr=addr;
info.depth=depth;
info.addr = addr;
info.depth = depth;
if(!_dbg_sendmessage(DBG_LOOP_GET, &info, 0))
return false;
*start=info.start;
*end=info.end;
*start = info.start;
*end = info.end;
return true;
}
BRIDGE_IMPEXP bool DbgLoopOverlaps(int depth, duint start, duint end)
{
FUNCTION_LOOP_INFO info;
info.start=start;
info.end=end;
info.depth=depth;
info.start = start;
info.end = end;
info.depth = depth;
if(!_dbg_sendmessage(DBG_LOOP_OVERLAPS, &info, 0))
return false;
return true;
@ -581,9 +581,9 @@ BRIDGE_IMPEXP bool DbgLoopOverlaps(int depth, duint start, duint end)
BRIDGE_IMPEXP bool DbgLoopAdd(duint start, duint end)
{
FUNCTION_LOOP_INFO info;
info.start=start;
info.end=end;
info.manual=false;
info.start = start;
info.end = end;
info.manual = false;
if(!_dbg_sendmessage(DBG_LOOP_ADD, &info, 0))
return false;
return true;
@ -592,8 +592,8 @@ BRIDGE_IMPEXP bool DbgLoopAdd(duint start, duint end)
BRIDGE_IMPEXP bool DbgLoopDel(int depth, duint addr)
{
FUNCTION_LOOP_INFO info;
info.addr=addr;
info.depth=depth;
info.addr = addr;
info.depth = depth;
if(!_dbg_sendmessage(DBG_LOOP_DEL, &info, 0))
return false;
return true;
@ -842,9 +842,9 @@ BRIDGE_IMPEXP void GuiReferenceDeleteAllColumns()
BRIDGE_IMPEXP void GuiReferenceSetCellContent(int row, int col, const char* str)
{
CELLINFO info;
info.row=row;
info.col=col;
info.str=str;
info.row = row;
info.col = col;
info.str = str;
_gui_sendmessage(GUI_REF_SETCELLCONTENT, &info, 0);
}
@ -981,7 +981,7 @@ BRIDGE_IMPEXP void GuiUpdateCallStack()
//Main
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
hInst=hinstDLL;
hInst = hinstDLL;
return TRUE;
}

View File

@ -87,20 +87,20 @@ typedef enum
typedef enum
{
flagmodule=1,
flaglabel=2,
flagcomment=4,
flagbookmark=8,
flagfunction=16,
flagloop=32
flagmodule = 1,
flaglabel = 2,
flagcomment = 4,
flagbookmark = 8,
flagfunction = 16,
flagloop = 32
} ADDRINFOFLAGS;
typedef enum
{
bp_none=0,
bp_normal=1,
bp_hardware=2,
bp_memory=4
bp_none = 0,
bp_normal = 1,
bp_hardware = 2,
bp_memory = 4
} BPXTYPE;
typedef enum
@ -476,7 +476,7 @@ typedef struct
bool branch; //jumps/calls
bool call; //instruction is a call
int size;
char instruction[MAX_MNEMONIC_SIZE*4];
char instruction[MAX_MNEMONIC_SIZE * 4];
} BASIC_INSTRUCTION_INFO;
typedef struct

View File

@ -382,9 +382,9 @@ enum SPECIAL_INFO
extern "C"
#endif
BEA_API int __bea_callspec__ Disasm (LPDISASM pDisAsm);
BEA_API const__ char* __bea_callspec__ BeaEngineVersion (void);
BEA_API const__ char* __bea_callspec__ BeaEngineRevision (void);
BEA_API int __bea_callspec__ Disasm(LPDISASM pDisAsm);
BEA_API const__ char* __bea_callspec__ BeaEngineVersion(void);
BEA_API const__ char* __bea_callspec__ BeaEngineRevision(void);
#if defined(__cplusplus) && defined(__BORLANDC__)
};
using namespace BeaEngine;

View File

@ -24,7 +24,7 @@
#if defined(__cplusplus)
#define BEA_UNUSED_ID(identifier)
template <class T>
inline void BEA_UNUSED_ARG(const T& BEA_UNUSED_ID(t)) { }
inline void BEA_UNUSED_ARG(const T & BEA_UNUSED_ID(t)) { }
#else
#define BEA_UNUSED_ARG(a)
#endif

View File

@ -590,8 +590,8 @@ __declspec(dllexport) ULONG_PTR TITCALL ConvertVAtoFileOffset(ULONG_PTR FileMapV
__declspec(dllexport) ULONG_PTR TITCALL ConvertVAtoFileOffsetEx(ULONG_PTR FileMapVA, DWORD FileSize, ULONG_PTR ImageBase, ULONG_PTR AddressToConvert, bool AddressIsRVA, bool ReturnType);
__declspec(dllexport) ULONG_PTR TITCALL ConvertFileOffsetToVA(ULONG_PTR FileMapVA, ULONG_PTR AddressToConvert, bool ReturnType);
__declspec(dllexport) ULONG_PTR TITCALL ConvertFileOffsetToVAEx(ULONG_PTR FileMapVA, DWORD FileSize, ULONG_PTR ImageBase, ULONG_PTR AddressToConvert, bool ReturnType);
__declspec(dllexport) bool TITCALL MemoryReadSafe(HANDLE hProcess, LPVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T * lpNumberOfBytesRead);
__declspec(dllexport) bool TITCALL MemoryWriteSafe(HANDLE hProcess, LPVOID lpBaseAddress, LPCVOID lpBuffer, SIZE_T nSize, SIZE_T * lpNumberOfBytesWritten);
__declspec(dllexport) bool TITCALL MemoryReadSafe(HANDLE hProcess, LPVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesRead);
__declspec(dllexport) bool TITCALL MemoryWriteSafe(HANDLE hProcess, LPVOID lpBaseAddress, LPCVOID lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten);
// TitanEngine.Realigner.functions:
__declspec(dllexport) bool TITCALL FixHeaderCheckSum(char* szFileName);
__declspec(dllexport) bool TITCALL FixHeaderCheckSumW(wchar_t* szFileName);

View File

@ -16,13 +16,13 @@
#define XEDPARSE_MAXASMSIZE 16
//typedefs
typedef bool (XEDPARSE_CALL *CBXEDPARSE_UNKNOWN)(const char* text, ULONGLONG* value);
typedef bool (XEDPARSE_CALL* CBXEDPARSE_UNKNOWN)(const char* text, ULONGLONG* value);
//XEDParse enums
enum XEDPARSE_STATUS
{
XEDPARSE_ERROR=0,
XEDPARSE_OK=1
XEDPARSE_ERROR = 0,
XEDPARSE_OK = 1
};
//XEDParse structs

View File

@ -23,10 +23,10 @@ static bool _assembleatex(duint addr, const char* instruction, char* error, bool
static bool _sectionfromaddr(duint addr, char* section)
{
HMODULE hMod=(HMODULE)modbasefromaddr(addr);
HMODULE hMod = (HMODULE)modbasefromaddr(addr);
if(!hMod)
return false;
char curModPath[MAX_PATH]="";
char curModPath[MAX_PATH] = "";
if(!GetModuleFileNameExA(fdProcessInfo->hProcess, hMod, curModPath, MAX_PATH))
return false;
HANDLE FileHandle;
@ -35,11 +35,11 @@ static bool _sectionfromaddr(duint addr, char* section)
ULONG_PTR FileMapVA;
if(StaticFileLoad(curModPath, UE_ACCESS_READ, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA))
{
uint rva=addr-(uint)hMod;
int sectionNumber=GetPE32SectionNumberFromVA(FileMapVA, GetPE32DataFromMappedFile(FileMapVA, 0, UE_IMAGEBASE)+rva);
if(sectionNumber>=0)
uint rva = addr - (uint)hMod;
int sectionNumber = GetPE32SectionNumberFromVA(FileMapVA, GetPE32DataFromMappedFile(FileMapVA, 0, UE_IMAGEBASE) + rva);
if(sectionNumber >= 0)
{
const char* name=(const char*)GetPE32DataFromMappedFile(FileMapVA, sectionNumber, UE_SECTIONNAME);
const char* name = (const char*)GetPE32DataFromMappedFile(FileMapVA, sectionNumber, UE_SECTIONNAME);
if(section)
strcpy(section, name);
StaticFileUnload(curModPath, false, FileHandle, LoadedSize, FileMap, FileMapVA);
@ -59,11 +59,11 @@ static bool _patchinrange(duint start, duint end)
{
if(start > end)
{
duint a=start;
start=end;
end=a;
duint a = start;
start = end;
end = a;
}
for(duint i=start; i<end+1; i++)
for(duint i = start; i < end + 1; i++)
if(_patchget(i))
return true;
return false;
@ -78,11 +78,11 @@ static void _patchrestorerange(duint start, duint end)
{
if(start > end)
{
duint a=start;
start=end;
end=a;
duint a = start;
start = end;
end = a;
}
for(duint i=start; i<end+1; i++)
for(duint i = start; i < end + 1; i++)
patchdel(i, true);
GuiUpdatePatches();
}
@ -124,26 +124,26 @@ static bool _getjit(char* jit, bool jit64)
void dbgfunctionsinit()
{
_dbgfunctions.AssembleAtEx=_assembleatex;
_dbgfunctions.SectionFromAddr=_sectionfromaddr;
_dbgfunctions.ModNameFromAddr=modnamefromaddr;
_dbgfunctions.ModBaseFromAddr=modbasefromaddr;
_dbgfunctions.ModBaseFromName=modbasefromname;
_dbgfunctions.ModSizeFromAddr=modsizefromaddr;
_dbgfunctions.Assemble=assemble;
_dbgfunctions.PatchGet=_patchget;
_dbgfunctions.PatchInRange=_patchinrange;
_dbgfunctions.MemPatch=_mempatch;
_dbgfunctions.PatchRestoreRange=_patchrestorerange;
_dbgfunctions.PatchEnum=(PATCHENUM)patchenum;
_dbgfunctions.PatchRestore=_patchrestore;
_dbgfunctions.PatchFile=(PATCHFILE)patchfile;
_dbgfunctions.ModPathFromAddr=_modpathfromaddr;
_dbgfunctions.ModPathFromName=_modpathfromname;
_dbgfunctions.DisasmFast=disasmfast;
_dbgfunctions.MemUpdateMap=memupdatemap;
_dbgfunctions.GetCallStack=_getcallstack;
_dbgfunctions.SymbolDownloadAllSymbols=symdownloadallsymbols;
_dbgfunctions.AssembleAtEx = _assembleatex;
_dbgfunctions.SectionFromAddr = _sectionfromaddr;
_dbgfunctions.ModNameFromAddr = modnamefromaddr;
_dbgfunctions.ModBaseFromAddr = modbasefromaddr;
_dbgfunctions.ModBaseFromName = modbasefromname;
_dbgfunctions.ModSizeFromAddr = modsizefromaddr;
_dbgfunctions.Assemble = assemble;
_dbgfunctions.PatchGet = _patchget;
_dbgfunctions.PatchInRange = _patchinrange;
_dbgfunctions.MemPatch = _mempatch;
_dbgfunctions.PatchRestoreRange = _patchrestorerange;
_dbgfunctions.PatchEnum = (PATCHENUM)patchenum;
_dbgfunctions.PatchRestore = _patchrestore;
_dbgfunctions.PatchFile = (PATCHFILE)patchfile;
_dbgfunctions.ModPathFromAddr = _modpathfromaddr;
_dbgfunctions.ModPathFromName = _modpathfromname;
_dbgfunctions.DisasmFast = disasmfast;
_dbgfunctions.MemUpdateMap = memupdatemap;
_dbgfunctions.GetCallStack = _getcallstack;
_dbgfunctions.SymbolDownloadAllSymbols = symdownloadallsymbols;
_dbgfunctions.GetJit=_getjit;
_dbgfunctions.GetDefJit=dbggetdefjit;
}

View File

@ -36,15 +36,15 @@ extern "C" DLL_EXPORT bool _dbg_memwrite(duint addr, const unsigned char* src, d
extern "C" DLL_EXPORT bool _dbg_memmap(MEMMAP* memmap)
{
CriticalSectionLocker locker(LockMemoryPages);
int pagecount=(int)memoryPages.size();
int pagecount = (int)memoryPages.size();
memset(memmap, 0, sizeof(MEMMAP));
memmap->count=pagecount;
memmap->count = pagecount;
if(!pagecount)
return true;
memmap->page=(MEMPAGE*)BridgeAlloc(sizeof(MEMPAGE)*pagecount);
memmap->page = (MEMPAGE*)BridgeAlloc(sizeof(MEMPAGE) * pagecount);
memset(memmap->page, 0, sizeof(MEMPAGE)*pagecount);
int j=0;
for(MemoryMap::iterator i=memoryPages.begin(); i!=memoryPages.end(); ++i,j++)
int j = 0;
for(MemoryMap::iterator i = memoryPages.begin(); i != memoryPages.end(); ++i, j++)
memcpy(&memmap->page[j], &i->second, sizeof(MEMPAGE));
return true;
}
@ -71,11 +71,11 @@ extern "C" DLL_EXPORT bool _dbg_isjumpgoingtoexecute(duint addr)
static uint cacheFlags;
static uint cacheAddr;
static bool cacheResult;
if(cacheAddr!=addr or cacheFlags!=GetContextDataEx(hActiveThread, UE_EFLAGS))
if(cacheAddr != addr or cacheFlags != GetContextDataEx(hActiveThread, UE_EFLAGS))
{
cacheFlags=GetContextDataEx(hActiveThread, UE_EFLAGS);
cacheAddr=addr;
cacheResult=IsJumpGoingToExecuteEx(fdProcessInfo->hProcess, fdProcessInfo->hThread, (ULONG_PTR)cacheAddr, cacheFlags);
cacheFlags = GetContextDataEx(hActiveThread, UE_EFLAGS);
cacheAddr = addr;
cacheResult = IsJumpGoingToExecuteEx(fdProcessInfo->hProcess, fdProcessInfo->hThread, (ULONG_PTR)cacheAddr, cacheFlags);
}
return cacheResult;
}
@ -84,23 +84,23 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
{
if(!DbgIsDebugging())
return false;
bool retval=false;
if(addrinfo->flags&flagmodule) //get module
bool retval = false;
if(addrinfo->flags & flagmodule) //get module
{
char module[64]="";
if(modnamefromaddr(addr, module, false) and strlen(module)<MAX_MODULE_SIZE) //get module name
char module[64] = "";
if(modnamefromaddr(addr, module, false) and strlen(module) < MAX_MODULE_SIZE) //get module name
{
strcpy(addrinfo->module, module);
retval=true;
retval = true;
}
}
if(addrinfo->flags&flaglabel)
if(addrinfo->flags & flaglabel)
{
if(labelget(addr, addrinfo->label))
retval=true;
retval = true;
else //no user labels
{
DWORD64 displacement=0;
DWORD64 displacement = 0;
char buffer[sizeof(SYMBOL_INFO) + MAX_LABEL_SIZE * sizeof(char)];
PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer;
pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
@ -109,7 +109,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
{
if(settingboolget("Engine", "UndecorateSymbolNames") or !UnDecorateSymbolName(pSymbol->Name, addrinfo->label, MAX_LABEL_SIZE, UNDNAME_COMPLETE))
strcpy(addrinfo->label, pSymbol->Name);
retval=true;
retval = true;
}
if(!retval) //search for CALL <jmp.&user32.MessageBoxA>
{
@ -117,40 +117,40 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
memset(&basicinfo, 0, sizeof(BASIC_INSTRUCTION_INFO));
if(disasmfast(addr, &basicinfo) && basicinfo.branch && !basicinfo.call && basicinfo.memory.value) //thing is a JMP
{
uint val=0;
uint val = 0;
if(memread(fdProcessInfo->hProcess, (const void*)basicinfo.memory.value, &val, sizeof(val), 0))
{
if(SymFromAddr(fdProcessInfo->hProcess, (DWORD64)val, &displacement, pSymbol) and !displacement)
{
if(settingboolget("Engine", "UndecorateSymbolNames") or !UnDecorateSymbolName(pSymbol->Name, addrinfo->label, MAX_LABEL_SIZE, UNDNAME_COMPLETE))
sprintf_s(addrinfo->label, "JMP.&%s", pSymbol->Name);
retval=true;
retval = true;
}
}
}
}
}
}
if(addrinfo->flags&flagbookmark)
if(addrinfo->flags & flagbookmark)
{
addrinfo->isbookmark=bookmarkget(addr);
retval=true;
addrinfo->isbookmark = bookmarkget(addr);
retval = true;
}
if(addrinfo->flags&flagfunction)
if(addrinfo->flags & flagfunction)
{
if(functionget(addr, &addrinfo->function.start, &addrinfo->function.end))
retval=true;
retval = true;
}
if(addrinfo->flags&flagloop)
if(addrinfo->flags & flagloop)
{
if(loopget(addrinfo->loop.depth, addr, &addrinfo->loop.start, &addrinfo->loop.end))
retval=true;
retval = true;
}
if(addrinfo->flags&flagcomment)
if(addrinfo->flags & flagcomment)
{
*addrinfo->comment=0;
*addrinfo->comment = 0;
if(commentget(addr, addrinfo->comment))
retval=true;
retval = true;
else
{
DWORD dwDisplacement;
@ -158,50 +158,50 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
if(SymGetLineFromAddr64(fdProcessInfo->hProcess, (DWORD64)addr, &dwDisplacement, &line) and !dwDisplacement)
{
char filename[deflen]="";
char filename[deflen] = "";
strcpy(filename, line.FileName);
int len=(int)strlen(filename);
while(filename[len]!='\\' and len!=0)
int len = (int)strlen(filename);
while(filename[len] != '\\' and len != 0)
len--;
if(len)
len++;
sprintf(addrinfo->comment, "%s:%u", filename+len, line.LineNumber);
retval=true;
sprintf(addrinfo->comment, "%s:%u", filename + len, line.LineNumber);
retval = true;
}
else if(!bOnlyCipAutoComments || addr == GetContextDataEx(hActiveThread, UE_CIP)) //no line number
{
DISASM_INSTR instr;
std::string temp_string;
ADDRINFO newinfo;
char ascii[256*2]="";
char unicode[256*2]="";
char ascii[256 * 2] = "";
char unicode[256 * 2] = "";
memset(&instr, 0, sizeof(DISASM_INSTR));
disasmget(addr, &instr);
int len_left=MAX_COMMENT_SIZE;
for(int i=0,j=0; i<instr.argcount; i++)
int len_left = MAX_COMMENT_SIZE;
for(int i = 0, j = 0; i < instr.argcount; i++)
{
memset(&newinfo, 0, sizeof(ADDRINFO));
newinfo.flags=flaglabel;
newinfo.flags = flaglabel;
STRING_TYPE strtype=str_none;
STRING_TYPE strtype = str_none;
if(instr.arg[i].constant==instr.arg[i].value) //avoid: call <module.label> ; addr:label
if(instr.arg[i].constant == instr.arg[i].value) //avoid: call <module.label> ; addr:label
{
if(instr.type==instr_branch or !disasmgetstringat(instr.arg[i].constant, &strtype, ascii, unicode, len_left) or strtype==str_none)
if(instr.type == instr_branch or !disasmgetstringat(instr.arg[i].constant, &strtype, ascii, unicode, len_left) or strtype == str_none)
continue;
switch(strtype)
{
case str_none:
break;
case str_ascii:
temp_string=instr.arg[i].mnemonic;
temp_string = instr.arg[i].mnemonic;
temp_string.append(":\"");
temp_string.append(ascii);
temp_string.append("\"");
break;
case str_unicode:
temp_string=instr.arg[i].mnemonic;
temp_string = instr.arg[i].mnemonic;
temp_string.append(":L\"");
temp_string.append(unicode);
temp_string.append("\"");
@ -215,20 +215,20 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
case str_none:
if(*newinfo.label)
{
temp_string="[";
temp_string = "[";
temp_string.append(instr.arg[i].mnemonic);
temp_string.append("]:");
temp_string.append(newinfo.label);
}
break;
case str_ascii:
temp_string="[";
temp_string = "[";
temp_string.append(instr.arg[i].mnemonic);
temp_string.append("]:");
temp_string.append(ascii);
break;
case str_unicode:
temp_string="[";
temp_string = "[";
temp_string.append(instr.arg[i].mnemonic);
temp_string.append("]:");
temp_string.append(unicode);
@ -237,26 +237,26 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
}
else if(instr.arg[i].value and (disasmgetstringat(instr.arg[i].value, &strtype, ascii, unicode, len_left) or _dbg_addrinfoget(instr.arg[i].value, instr.arg[i].segment, &newinfo)))
{
if(instr.type!=instr_normal) //stack/jumps (eg add esp,4 or jmp 401110) cannot directly point to strings
strtype=str_none;
if(instr.type != instr_normal) //stack/jumps (eg add esp,4 or jmp 401110) cannot directly point to strings
strtype = str_none;
switch(strtype)
{
case str_none:
if(*newinfo.label)
{
temp_string=instr.arg[i].mnemonic;
temp_string = instr.arg[i].mnemonic;
temp_string.append(":");
temp_string.append(newinfo.label);
}
break;
case str_ascii:
temp_string=instr.arg[i].mnemonic;
temp_string = instr.arg[i].mnemonic;
temp_string.append(":\"");
temp_string.append(ascii);
temp_string.append("\"");
break;
case str_unicode:
temp_string=instr.arg[i].mnemonic;
temp_string = instr.arg[i].mnemonic;
temp_string.append(":L\"");
temp_string.append(unicode);
temp_string.append("\"");
@ -268,14 +268,14 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
if(!strstr(addrinfo->comment, temp_string.c_str()))
{
unsigned int maxlen=MAX_COMMENT_SIZE-j-1;
if(maxlen<temp_string.length())
temp_string.at(maxlen-1)=0;
unsigned int maxlen = MAX_COMMENT_SIZE - j - 1;
if(maxlen < temp_string.length())
temp_string.at(maxlen - 1) = 0;
if(j)
j+=sprintf(addrinfo->comment+j, ", %s", temp_string.c_str());
j += sprintf(addrinfo->comment + j, ", %s", temp_string.c_str());
else
j+=sprintf(addrinfo->comment+j, "%s", temp_string.c_str());
retval=true;
j += sprintf(addrinfo->comment + j, "%s", temp_string.c_str());
retval = true;
}
}
}
@ -286,23 +286,23 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
extern "C" DLL_EXPORT bool _dbg_addrinfoset(duint addr, ADDRINFO* addrinfo)
{
bool retval=false;
if(addrinfo->flags&flaglabel) //set label
bool retval = false;
if(addrinfo->flags & flaglabel) //set label
{
if(labelset(addr, addrinfo->label, true))
retval=true;
retval = true;
}
if(addrinfo->flags&flagcomment) //set comment
if(addrinfo->flags & flagcomment) //set comment
{
if(commentset(addr, addrinfo->comment, true))
retval=true;
retval = true;
}
if(addrinfo->flags&flagbookmark) //set bookmark
if(addrinfo->flags & flagbookmark) //set bookmark
{
if(addrinfo->isbookmark)
retval=bookmarkset(addr, true);
retval = bookmarkset(addr, true);
else
retval=bookmarkdel(addr);
retval = bookmarkdel(addr);
}
return retval;
}
@ -312,22 +312,22 @@ extern "C" DLL_EXPORT int _dbg_bpgettypeat(duint addr)
static uint cacheAddr;
static int cacheBpCount;
static int cacheResult;
int bpcount=bpgetlist(0);
if(cacheAddr!=addr or cacheBpCount!=bpcount)
int bpcount = bpgetlist(0);
if(cacheAddr != addr or cacheBpCount != bpcount)
{
BREAKPOINT bp;
cacheAddr=addr;
cacheResult=0;
cacheBpCount=bpcount;
cacheAddr = addr;
cacheResult = 0;
cacheBpCount = bpcount;
if(bpget(addr, BPNORMAL, 0, &bp))
if(bp.enabled)
cacheResult|=bp_normal;
cacheResult |= bp_normal;
if(bpget(addr, BPHARDWARE, 0, &bp))
if(bp.enabled)
cacheResult|=bp_hardware;
cacheResult |= bp_hardware;
if(bpget(addr, BPMEMORY, 0, &bp))
if(bp.enabled)
cacheResult|=bp_memory;
cacheResult |= bp_memory;
}
return cacheResult;
}
@ -341,89 +341,89 @@ extern "C" DLL_EXPORT bool _dbg_getregdump(REGDUMP* regdump)
}
REGDUMP r;
#ifdef _WIN64
r.cax=GetContextDataEx(hActiveThread, UE_RAX);
r.cax = GetContextDataEx(hActiveThread, UE_RAX);
#else
r.cax=(duint)GetContextDataEx(hActiveThread, UE_EAX);
r.cax = (duint)GetContextDataEx(hActiveThread, UE_EAX);
#endif // _WIN64
#ifdef _WIN64
r.ccx=GetContextDataEx(hActiveThread, UE_RCX);
r.ccx = GetContextDataEx(hActiveThread, UE_RCX);
#else
r.ccx=(duint)GetContextDataEx(hActiveThread, UE_ECX);
r.ccx = (duint)GetContextDataEx(hActiveThread, UE_ECX);
#endif // _WIN64
#ifdef _WIN64
r.cdx=GetContextDataEx(hActiveThread, UE_RDX);
r.cdx = GetContextDataEx(hActiveThread, UE_RDX);
#else
r.cdx=(duint)GetContextDataEx(hActiveThread, UE_EDX);
r.cdx = (duint)GetContextDataEx(hActiveThread, UE_EDX);
#endif // _WIN64
#ifdef _WIN64
r.cbx=GetContextDataEx(hActiveThread, UE_RBX);
r.cbx = GetContextDataEx(hActiveThread, UE_RBX);
#else
r.cbx=(duint)GetContextDataEx(hActiveThread, UE_EBX);
r.cbx = (duint)GetContextDataEx(hActiveThread, UE_EBX);
#endif // _WIN64
#ifdef _WIN64
r.cbp=GetContextDataEx(hActiveThread, UE_RBP);
r.cbp = GetContextDataEx(hActiveThread, UE_RBP);
#else
r.cbp=(duint)GetContextDataEx(hActiveThread, UE_EBP);
r.cbp = (duint)GetContextDataEx(hActiveThread, UE_EBP);
#endif // _WIN64
#ifdef _WIN64
r.csi=GetContextDataEx(hActiveThread, UE_RSI);
r.csi = GetContextDataEx(hActiveThread, UE_RSI);
#else
r.csi=(duint)GetContextDataEx(hActiveThread, UE_ESI);
r.csi = (duint)GetContextDataEx(hActiveThread, UE_ESI);
#endif // _WIN64
#ifdef _WIN64
r.cdi=GetContextDataEx(hActiveThread, UE_RDI);
r.cdi = GetContextDataEx(hActiveThread, UE_RDI);
#else
r.cdi=(duint)GetContextDataEx(hActiveThread, UE_EDI);
r.cdi = (duint)GetContextDataEx(hActiveThread, UE_EDI);
#endif // _WIN64
#ifdef _WIN64
r.r8=GetContextDataEx(hActiveThread, UE_R8);
r.r8 = GetContextDataEx(hActiveThread, UE_R8);
#endif // _WIN64
#ifdef _WIN64
r.r9=GetContextDataEx(hActiveThread, UE_R9);
r.r9 = GetContextDataEx(hActiveThread, UE_R9);
#endif // _WIN64
#ifdef _WIN64
r.r10=GetContextDataEx(hActiveThread, UE_R10);
r.r10 = GetContextDataEx(hActiveThread, UE_R10);
#endif // _WIN64
#ifdef _WIN64
r.r11=GetContextDataEx(hActiveThread, UE_R11);
r.r11 = GetContextDataEx(hActiveThread, UE_R11);
#endif // _WIN64
#ifdef _WIN64
r.r12=GetContextDataEx(hActiveThread, UE_R12);
r.r12 = GetContextDataEx(hActiveThread, UE_R12);
#endif // _WIN64
#ifdef _WIN64
r.r13=GetContextDataEx(hActiveThread, UE_R13);
r.r13 = GetContextDataEx(hActiveThread, UE_R13);
#endif // _WIN64
#ifdef _WIN64
r.r14=GetContextDataEx(hActiveThread, UE_R14);
r.r14 = GetContextDataEx(hActiveThread, UE_R14);
#endif // _WIN64
#ifdef _WIN64
r.r15=GetContextDataEx(hActiveThread, UE_R15);
r.r15 = GetContextDataEx(hActiveThread, UE_R15);
#endif // _WIN64
r.csp=(duint)GetContextDataEx(hActiveThread, UE_CSP);
r.cip=(duint)GetContextDataEx(hActiveThread, UE_CIP);
r.eflags=(unsigned int)GetContextDataEx(hActiveThread, UE_EFLAGS);
r.gs=(unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_GS)&0xFFFF);
r.fs=(unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_FS)&0xFFFF);
r.es=(unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_ES)&0xFFFF);
r.ds=(unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_DS)&0xFFFF);
r.cs=(unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_CS)&0xFFFF);
r.ss=(unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_SS)&0xFFFF);
r.dr0=(duint)GetContextDataEx(hActiveThread, UE_DR0);
r.dr1=(duint)GetContextDataEx(hActiveThread, UE_DR1);
r.dr2=(duint)GetContextDataEx(hActiveThread, UE_DR2);
r.dr3=(duint)GetContextDataEx(hActiveThread, UE_DR3);
r.dr6=(duint)GetContextDataEx(hActiveThread, UE_DR6);
r.dr7=(duint)GetContextDataEx(hActiveThread, UE_DR7);
duint cflags=r.eflags;
r.flags.c=valflagfromstring(cflags, "cf");
r.flags.p=valflagfromstring(cflags, "pf");
r.flags.a=valflagfromstring(cflags, "af");
r.flags.z=valflagfromstring(cflags, "zf");
r.flags.s=valflagfromstring(cflags, "sf");
r.flags.t=valflagfromstring(cflags, "tf");
r.flags.i=valflagfromstring(cflags, "if");
r.flags.d=valflagfromstring(cflags, "df");
r.flags.o=valflagfromstring(cflags, "of");
r.csp = (duint)GetContextDataEx(hActiveThread, UE_CSP);
r.cip = (duint)GetContextDataEx(hActiveThread, UE_CIP);
r.eflags = (unsigned int)GetContextDataEx(hActiveThread, UE_EFLAGS);
r.gs = (unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_GS) & 0xFFFF);
r.fs = (unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_FS) & 0xFFFF);
r.es = (unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_ES) & 0xFFFF);
r.ds = (unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_DS) & 0xFFFF);
r.cs = (unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_CS) & 0xFFFF);
r.ss = (unsigned short)(GetContextDataEx(hActiveThread, UE_SEG_SS) & 0xFFFF);
r.dr0 = (duint)GetContextDataEx(hActiveThread, UE_DR0);
r.dr1 = (duint)GetContextDataEx(hActiveThread, UE_DR1);
r.dr2 = (duint)GetContextDataEx(hActiveThread, UE_DR2);
r.dr3 = (duint)GetContextDataEx(hActiveThread, UE_DR3);
r.dr6 = (duint)GetContextDataEx(hActiveThread, UE_DR6);
r.dr7 = (duint)GetContextDataEx(hActiveThread, UE_DR7);
duint cflags = r.eflags;
r.flags.c = valflagfromstring(cflags, "cf");
r.flags.p = valflagfromstring(cflags, "pf");
r.flags.a = valflagfromstring(cflags, "af");
r.flags.z = valflagfromstring(cflags, "zf");
r.flags.s = valflagfromstring(cflags, "sf");
r.flags.t = valflagfromstring(cflags, "tf");
r.flags.i = valflagfromstring(cflags, "if");
r.flags.d = valflagfromstring(cflags, "df");
r.flags.o = valflagfromstring(cflags, "of");
memcpy(regdump, &r, sizeof(REGDUMP));
return true;
}
@ -438,18 +438,18 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap)
if(!bpmap)
return 0;
std::vector<BREAKPOINT> list;
int bpcount=bpgetlist(&list);
if(bpcount==0)
int bpcount = bpgetlist(&list);
if(bpcount == 0)
{
bpmap->count=0;
bpmap->count = 0;
return 0;
}
int retcount=0;
int retcount = 0;
std::vector<BRIDGEBP> bridgeList;
BRIDGEBP curBp;
unsigned short slot=0;
for(int i=0; i<bpcount; i++)
unsigned short slot = 0;
for(int i = 0; i < bpcount; i++)
{
memset(&curBp, 0, sizeof(BRIDGEBP));
switch(type)
@ -457,15 +457,15 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap)
case bp_none: //all types
break;
case bp_normal: //normal
if(list[i].type!=BPNORMAL)
if(list[i].type != BPNORMAL)
continue;
break;
case bp_hardware: //hardware
if(list[i].type!=BPHARDWARE)
if(list[i].type != BPHARDWARE)
continue;
break;
case bp_memory: //memory
if(list[i].type!=BPMEMORY)
if(list[i].type != BPMEMORY)
continue;
break;
default:
@ -474,39 +474,39 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap)
switch(list[i].type)
{
case BPNORMAL:
curBp.type=bp_normal;
curBp.type = bp_normal;
break;
case BPHARDWARE:
curBp.type=bp_hardware;
curBp.type = bp_hardware;
break;
case BPMEMORY:
curBp.type=bp_memory;
curBp.type = bp_memory;
break;
}
switch(((DWORD)list[i].titantype)>>8)
switch(((DWORD)list[i].titantype) >> 8)
{
case UE_DR0:
slot=0;
slot = 0;
break;
case UE_DR1:
slot=1;
slot = 1;
break;
case UE_DR2:
slot=2;
slot = 2;
break;
case UE_DR3:
slot=3;
slot = 3;
break;
}
curBp.addr=list[i].addr;
curBp.enabled=list[i].enabled;
curBp.addr = list[i].addr;
curBp.enabled = list[i].enabled;
//TODO: fix this
if(memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr))
curBp.active=true;
curBp.active = true;
strcpy(curBp.mod, list[i].mod);
strcpy(curBp.name, list[i].name);
curBp.singleshoot=list[i].singleshoot;
curBp.slot=slot;
curBp.singleshoot = list[i].singleshoot;
curBp.slot = slot;
if(curBp.active)
{
bridgeList.push_back(curBp);
@ -515,12 +515,12 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap)
}
if(!retcount)
{
bpmap->count=retcount;
bpmap->count = retcount;
return retcount;
}
bpmap->count=retcount;
bpmap->bp=(BRIDGEBP*)BridgeAlloc(sizeof(BRIDGEBP)*retcount);
for(int i=0; i<retcount; i++)
bpmap->count = retcount;
bpmap->bp = (BRIDGEBP*)BridgeAlloc(sizeof(BRIDGEBP) * retcount);
for(int i = 0; i < retcount; i++)
memcpy(&bpmap->bp[i], &bridgeList.at(i), sizeof(BRIDGEBP));
return retcount;
}
@ -530,17 +530,17 @@ extern "C" DLL_EXPORT uint _dbg_getbranchdestination(uint addr)
DISASM_INSTR instr;
memset(&instr, 0, sizeof(instr));
disasmget(addr, &instr);
if(instr.type!=instr_branch)
if(instr.type != instr_branch)
return 0;
if(strstr(instr.instruction, "ret"))
{
uint atcsp=DbgValFromString("@csp");
uint atcsp = DbgValFromString("@csp");
if(DbgMemIsValidReadPtr(atcsp))
return atcsp;
else
return 0;
}
else if(instr.arg[0].type==arg_memory)
else if(instr.arg[0].type == arg_memory)
return instr.arg[0].memvalue;
else
return instr.arg[0].value;
@ -623,7 +623,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
case DBG_SYMBOL_ENUM:
{
SYMBOLCBINFO* cbInfo=(SYMBOLCBINFO*)param1;
SYMBOLCBINFO* cbInfo = (SYMBOLCBINFO*)param1;
symenum(cbInfo->base, cbInfo->cbSymbolEnum, cbInfo->user);
}
break;
@ -695,23 +695,23 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
else
SetEngineVariable(UE_ENGINE_SET_DEBUG_PRIVILEGE, false);
}
char exceptionRange[MAX_SETTING_SIZE]="";
char exceptionRange[MAX_SETTING_SIZE] = "";
dbgclearignoredexceptions();
if(BridgeSettingGet("Exceptions", "IgnoreRange", exceptionRange))
{
char* entry=strtok(exceptionRange, ",");
char* entry = strtok(exceptionRange, ",");
while(entry)
{
unsigned long start;
unsigned long end;
if(sscanf(entry, "%08X-%08X", &start, &end)==2 && start<=end)
if(sscanf(entry, "%08X-%08X", &start, &end) == 2 && start <= end)
{
ExceptionRange range;
range.start=start;
range.end=end;
range.start = start;
range.end = end;
dbgaddignoredexception(range);
}
entry=strtok(0, ",");
entry = strtok(0, ",");
}
}
if(BridgeSettingGetUint("Disassembler", "OnlyCipAutoComments", &setting))
@ -734,77 +734,77 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
DISASM disasm;
memset(&disasm, 0, sizeof(disasm));
#ifdef _WIN64
disasm.Archi=64;
disasm.Archi = 64;
#endif // _WIN64
disasm.EIP=(UIntPtr)data;
disasm.VirtualAddr=(UInt64)param1;
int len=Disasm(&disasm);
uint i=0;
BASIC_INSTRUCTION_INFO* basicinfo=(BASIC_INSTRUCTION_INFO*)param2;
disasm.EIP = (UIntPtr)data;
disasm.VirtualAddr = (UInt64)param1;
int len = Disasm(&disasm);
uint i = 0;
BASIC_INSTRUCTION_INFO* basicinfo = (BASIC_INSTRUCTION_INFO*)param2;
fillbasicinfo(&disasm, basicinfo);
basicinfo->size=len;
basicinfo->size = len;
}
break;
case DBG_MENU_ENTRY_CLICKED:
{
int hEntry=(int)(uint)param1;
int hEntry = (int)(uint)param1;
pluginmenucall(hEntry);
}
break;
case DBG_FUNCTION_GET:
{
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1;
return (uint)functionget(info->addr, &info->start, &info->end);
}
break;
case DBG_FUNCTION_OVERLAPS:
{
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1;
return (uint)functionoverlaps(info->start, info->end);
}
break;
case DBG_FUNCTION_ADD:
{
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1;
return (uint)functionadd(info->start, info->end, info->manual);
}
break;
case DBG_FUNCTION_DEL:
{
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1;
return (uint)functiondel(info->addr);
}
break;
case DBG_LOOP_GET:
{
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1;
return (uint)loopget(info->depth, info->addr, &info->start, &info->end);
}
break;
case DBG_LOOP_OVERLAPS:
{
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1;
return (uint)loopoverlaps(info->depth, info->start, info->end, 0);
}
break;
case DBG_LOOP_ADD:
{
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1;
return (uint)loopadd(info->start, info->end, info->manual);
}
break;
case DBG_LOOP_DEL:
{
FUNCTION_LOOP_INFO* info=(FUNCTION_LOOP_INFO*)param1;
FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1;
return (uint)loopdel(info->depth, info->addr);
}
break;
@ -875,10 +875,10 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
case DBG_GET_STRING_AT:
{
STRING_TYPE strtype;
char string[512]="";
char string[512] = "";
if(disasmgetstringat((uint)param1, &strtype, string, string, 500))
{
if(strtype==str_ascii)
if(strtype == str_ascii)
sprintf((char*)param2, "\"%s\"", string);
else //unicode
sprintf((char*)param2, "L\"%s\"", string);

View File

@ -2,8 +2,8 @@
#include <new>
HINSTANCE hInst;
char dbbasepath[deflen]="";
char dbpath[3*deflen]="";
char dbbasepath[deflen] = "";
char dbpath[3 * deflen] = "";
void* emalloc(size_t size)
{
@ -15,12 +15,12 @@ void efree(void* ptr)
efree(ptr, "efree:???");
}
static int emalloc_count=0;
static char alloctrace[MAX_PATH]="";
static int emalloc_count = 0;
static char alloctrace[MAX_PATH] = "";
void* emalloc(size_t size, const char* reason)
{
unsigned char* a=(unsigned char*)GlobalAlloc(GMEM_FIXED, size);
unsigned char* a = (unsigned char*)GlobalAlloc(GMEM_FIXED, size);
if(!a)
{
MessageBoxA(0, "Could not allocate memory", "Error", MB_ICONERROR);
@ -62,23 +62,23 @@ bool arraycontains(const char* cmd_list, const char* cmd)
//TODO: fix this function a little
if(!cmd_list or !cmd)
return false;
char temp[deflen]="";
char temp[deflen] = "";
strcpy(temp, cmd_list);
int len=(int)strlen(cmd_list);
if(len>=deflen)
int len = (int)strlen(cmd_list);
if(len >= deflen)
return false;
for(int i=0; i<len; i++)
if(temp[i]==1)
temp[i]=0;
for(int i = 0; i < len; i++)
if(temp[i] == 1)
temp[i] = 0;
if(!_stricmp(temp, cmd))
return true;
for(int i=(int)strlen(temp); i<len; i++)
for(int i = (int)strlen(temp); i < len; i++)
{
if(!temp[i])
{
if(!_stricmp(temp+i+1, cmd))
if(!_stricmp(temp + i + 1, cmd))
return true;
i+=(int)strlen(temp+i+1);
i += (int)strlen(temp + i + 1);
}
}
return false;
@ -93,40 +93,40 @@ bool scmp(const char* a, const char* b)
void formathex(char* string)
{
int len=(int)strlen(string);
int len = (int)strlen(string);
_strupr(string);
char* new_string=(char*)emalloc(len+1, "formathex:new_string");
memset(new_string, 0, len+1);
for(int i=0,j=0; i<len; i++)
char* new_string = (char*)emalloc(len + 1, "formathex:new_string");
memset(new_string, 0, len + 1);
for(int i = 0, j = 0; i < len; i++)
if(isxdigit(string[i]))
j+=sprintf(new_string+j, "%c", string[i]);
j += sprintf(new_string + j, "%c", string[i]);
strcpy(string, new_string);
efree(new_string, "formathex:new_string");
}
void formatdec(char* string)
{
int len=(int)strlen(string);
int len = (int)strlen(string);
_strupr(string);
char* new_string=(char*)emalloc(len+1, "formatdec:new_string");
memset(new_string, 0, len+1);
for(int i=0,j=0; i<len; i++)
char* new_string = (char*)emalloc(len + 1, "formatdec:new_string");
memset(new_string, 0, len + 1);
for(int i = 0, j = 0; i < len; i++)
if(isdigit(string[i]))
j+=sprintf(new_string+j, "%c", string[i]);
j += sprintf(new_string + j, "%c", string[i]);
strcpy(string, new_string);
efree(new_string, "formatdec:new_string");
}
bool FileExists(const char* file)
{
DWORD attrib=GetFileAttributes(file);
DWORD attrib = GetFileAttributes(file);
return (attrib != INVALID_FILE_ATTRIBUTES && !(attrib & FILE_ATTRIBUTE_DIRECTORY));
}
bool DirExists(const char* dir)
{
DWORD attrib=GetFileAttributes(dir);
return (attrib==FILE_ATTRIBUTE_DIRECTORY);
DWORD attrib = GetFileAttributes(dir);
return (attrib == FILE_ATTRIBUTE_DIRECTORY);
}
bool GetFileNameFromHandle(HANDLE hFile, char* szFileName)

View File

@ -56,38 +56,38 @@ typedef long sint;
enum BITMASK
{
BIT1=0x1,
BIT2=0x2,
BIT3=0x4,
BIT4=0x8,
BIT5=0x10,
BIT6=0x20,
BIT7=0x40,
BIT8=0x80,
BIT9=0x100,
BIT10=0x200,
BIT11=0x400,
BIT12=0x800,
BIT13=0x1000,
BIT14=0x2000,
BIT15=0x4000,
BIT16=0x8000,
BIT17=0x10000,
BIT18=0x20000,
BIT19=0x40000,
BIT20=0x80000,
BIT21=0x100000,
BIT22=0x200000,
BIT23=0x400000,
BIT24=0x800000,
BIT25=0x1000000,
BIT26=0x2000000,
BIT27=0x4000000,
BIT28=0x8000000,
BIT29=0x10000000,
BIT30=0x20000000,
BIT31=0x40000000,
BIT32=0x80000000
BIT1 = 0x1,
BIT2 = 0x2,
BIT3 = 0x4,
BIT4 = 0x8,
BIT5 = 0x10,
BIT6 = 0x20,
BIT7 = 0x40,
BIT8 = 0x80,
BIT9 = 0x100,
BIT10 = 0x200,
BIT11 = 0x400,
BIT12 = 0x800,
BIT13 = 0x1000,
BIT14 = 0x2000,
BIT15 = 0x4000,
BIT16 = 0x8000,
BIT17 = 0x10000,
BIT18 = 0x20000,
BIT19 = 0x40000,
BIT20 = 0x80000,
BIT21 = 0x100000,
BIT22 = 0x200000,
BIT23 = 0x400000,
BIT24 = 0x800000,
BIT25 = 0x1000000,
BIT26 = 0x2000000,
BIT27 = 0x4000000,
BIT28 = 0x8000000,
BIT29 = 0x10000000,
BIT30 = 0x20000000,
BIT31 = 0x40000000,
BIT32 = 0x80000000
};
enum arch
@ -101,7 +101,7 @@ enum arch
//superglobal variables
extern HINSTANCE hInst;
extern char dbbasepath[deflen];
extern char dbpath[3*deflen];
extern char dbpath[3 * deflen];
//functions
void* emalloc(size_t size);

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@ typedef std::pair<int, ModuleRange> DepthModuleRange; //depth + modulerange
struct RangeCompare
{
bool operator()(const Range& a, const Range& b) const //a before b?
bool operator()(const Range & a, const Range & b) const //a before b?
{
return a.second < b.first;
}
@ -18,7 +18,7 @@ struct RangeCompare
struct OverlappingRangeCompare
{
bool operator()(const Range& a, const Range& b) const //a before b?
bool operator()(const Range & a, const Range & b) const //a before b?
{
return a.second < b.first || a.second < b.second;
}
@ -26,7 +26,7 @@ struct OverlappingRangeCompare
struct ModuleRangeCompare
{
bool operator()(const ModuleRange& a, const ModuleRange& b) const
bool operator()(const ModuleRange & a, const ModuleRange & b) const
{
if(a.first < b.first) //module hash is smaller
return true;
@ -38,7 +38,7 @@ struct ModuleRangeCompare
struct DepthModuleRangeCompare
{
bool operator()(const DepthModuleRange& a, const DepthModuleRange& b) const
bool operator()(const DepthModuleRange & a, const DepthModuleRange & b) const
{
if(a.first < b.first) //module depth is smaller
return true;

View File

@ -24,117 +24,117 @@ formatarg:
*/
void argformat(char* cmd)
{
if(strlen(cmd)>=deflen)
if(strlen(cmd) >= deflen)
return;
char command_[deflen]="";
char* command=command_;
char command_[deflen] = "";
char* command = command_;
strcpy(command, cmd);
while(*command==' ')
while(*command == ' ')
command++;
int len=(int)strlen(command);
int start=0;
for(int i=0; i<len; i++)
if(command[i]==' ')
int len = (int)strlen(command);
int start = 0;
for(int i = 0; i < len; i++)
if(command[i] == ' ')
{
command[i]=0;
start=i+1;
command[i] = 0;
start = i + 1;
break;
}
if(!start)
start=len;
char arguments_[deflen]="";
char* arguments=arguments_;
strcpy(arguments, command+start);
char temp[deflen]="";
len=(int)strlen(arguments);
for(int i=0,j=0; i<len; i++)
start = len;
char arguments_[deflen] = "";
char* arguments = arguments_;
strcpy(arguments, command + start);
char temp[deflen] = "";
len = (int)strlen(arguments);
for(int i = 0, j = 0; i < len; i++)
{
if(arguments[i]=='"' and arguments[i+1]=='"')
i+=2;
j+=sprintf(temp+j, "%c", arguments[i]);
if(arguments[i] == '"' and arguments[i + 1] == '"')
i += 2;
j += sprintf(temp + j, "%c", arguments[i]);
}
strcpy(arguments, temp);
len=(int)strlen(arguments);
for(int i=0; i<len; i++)
if(arguments[i]=='\\' and arguments[i+1]=='\\')
len = (int)strlen(arguments);
for(int i = 0; i < len; i++)
if(arguments[i] == '\\' and arguments[i + 1] == '\\')
{
arguments[i]=1;
arguments[i+1]=1;
arguments[i] = 1;
arguments[i + 1] = 1;
}
while((*arguments==',' or *arguments==' ') and *(arguments-1)!='\\')
while((*arguments == ',' or * arguments == ' ') and * (arguments - 1) != '\\')
arguments++;
len=(int)strlen(arguments);
while((arguments[len-1]==' ' or arguments[len-1]==',') and arguments[len-2]!='\\')
len = (int)strlen(arguments);
while((arguments[len - 1] == ' ' or arguments[len - 1] == ',') and arguments[len - 2] != '\\')
len--;
arguments[len]=0;
len=(int)strlen(arguments);
int quote_count=0;
for(int i=0; i<len; i++)
if(arguments[i]=='"')
arguments[len] = 0;
len = (int)strlen(arguments);
int quote_count = 0;
for(int i = 0; i < len; i++)
if(arguments[i] == '"')
quote_count++;
if(!(quote_count%2))
if(!(quote_count % 2))
{
for(int i=0; i<len; i++)
if(arguments[i]=='"')
arguments[i]=0;
for(int i = 0; i < len; i++)
if(arguments[i] == '"')
arguments[i] = 0;
for(int i=0; i<len; i++)
if(arguments[i]==1 and arguments[i+1]==1)
for(int i = 0; i < len; i++)
if(arguments[i] == 1 and arguments[i + 1] == 1)
{
arguments[i]='\\';
arguments[i+1]='\\';
arguments[i] = '\\';
arguments[i + 1] = '\\';
}
for(int i=0,j=0; i<len; i++)
for(int i = 0, j = 0; i < len; i++)
{
if(!arguments[i])
{
i++;
int len2=(int)strlen(arguments+i);
for(int k=0; k<len2; k++)
int len2 = (int)strlen(arguments + i);
for(int k = 0; k < len2; k++)
{
if(arguments[i+k]==',' or arguments[i+k]==' ' or arguments[i+k]=='\\')
j+=sprintf(temp+j, "\\%c", arguments[i+k]);
if(arguments[i + k] == ',' or arguments[i + k] == ' ' or arguments[i + k] == '\\')
j += sprintf(temp + j, "\\%c", arguments[i + k]);
else
j+=sprintf(temp+j, "%c", arguments[i+k]);
j += sprintf(temp + j, "%c", arguments[i + k]);
}
i+=len2;
i += len2;
}
else
j+=sprintf(temp+j, "%c", arguments[i]);
j += sprintf(temp + j, "%c", arguments[i]);
}
arguments=arguments_;
arguments = arguments_;
strcpy(arguments, temp);
}
len=(int)strlen(arguments);
for(int i=0; i<len; i++)
if(arguments[i]=='\\' and arguments[i+1]=='\\')
len = (int)strlen(arguments);
for(int i = 0; i < len; i++)
if(arguments[i] == '\\' and arguments[i + 1] == '\\')
{
arguments[i]=1;
arguments[i+1]=1;
arguments[i] = 1;
arguments[i + 1] = 1;
}
len=(int)strlen(arguments);
for(int i=0,j=0; i<len; i++)
len = (int)strlen(arguments);
for(int i = 0, j = 0; i < len; i++)
{
if(arguments[i]==',' and arguments[i+1]==',')
i+=2;
j+=sprintf(temp+j, "%c", arguments[i]);
if(arguments[i] == ',' and arguments[i + 1] == ',')
i += 2;
j += sprintf(temp + j, "%c", arguments[i]);
}
strcpy(arguments, temp);
len=(int)strlen(arguments);
for(int i=0,j=0; i<len; i++)
len = (int)strlen(arguments);
for(int i = 0, j = 0; i < len; i++)
{
while(arguments[i]==' ' and arguments[i-1]!='\\')
while(arguments[i] == ' ' and arguments[i - 1] != '\\')
i++;
j+=sprintf(temp+j, "%c", arguments[i]);
j += sprintf(temp + j, "%c", arguments[i]);
}
strcpy(arguments, temp);
len=(int)strlen(arguments);
for(int i=0; i<len; i++)
if(arguments[i]==1 and arguments[i+1]==1)
len = (int)strlen(arguments);
for(int i = 0; i < len; i++)
if(arguments[i] == 1 and arguments[i + 1] == 1)
{
arguments[i]='\\';
arguments[i+1]='\\';
arguments[i] = '\\';
arguments[i + 1] = '\\';
}
if(strlen(arguments))
sprintf(cmd, "%s %s", command, arguments);
@ -148,30 +148,30 @@ void argformat(char* cmd)
*/
int arggetcount(const char* cmd)
{
int len=(int)strlen(cmd);
if(!len or len>=deflen)
int len = (int)strlen(cmd);
if(!len or len >= deflen)
return -1;
int arg_count=0;
int arg_count = 0;
int start=0;
while(cmd[start]!=' ' and start<len)
int start = 0;
while(cmd[start] != ' ' and start < len)
start++;
if(start==len)
if(start == len)
return arg_count;
arg_count=1;
char temp_[deflen]="";
char* temp=temp_+1;
arg_count = 1;
char temp_[deflen] = "";
char* temp = temp_ + 1;
strcpy(temp, cmd);
for(int i=start; i<len; i++)
if(temp[i]=='\\' and temp[i+1]=='\\')
for(int i = start; i < len; i++)
if(temp[i] == '\\' and temp[i + 1] == '\\')
{
temp[i]=1;
temp[i+1]=1;
temp[i] = 1;
temp[i + 1] = 1;
}
for(int i=start; i<len; i++)
for(int i = start; i < len; i++)
{
if(temp[i]==',' and temp[i-1]!='\\')
if(temp[i] == ',' and temp[i - 1] != '\\')
arg_count++;
}
return arg_count;
@ -185,68 +185,68 @@ int arggetcount(const char* cmd)
*/
bool argget(const char* cmd, char* arg, int arg_num, bool optional)
{
if(strlen(cmd)>=deflen)
if(strlen(cmd) >= deflen)
return false;
int argcount=arggetcount(cmd);
if((arg_num+1)>argcount)
int argcount = arggetcount(cmd);
if((arg_num + 1) > argcount)
{
if(!optional)
dprintf("missing argument nr %d\n", arg_num+1);
dprintf("missing argument nr %d\n", arg_num + 1);
return false;
}
int start=0;
while(cmd[start]!=' ') //ignore the command
int start = 0;
while(cmd[start] != ' ') //ignore the command
start++;
while(cmd[start]==' ') //ignore initial spaces
while(cmd[start] == ' ') //ignore initial spaces
start++;
char temp_[deflen]="";
char* temp=temp_+1;
strcpy(temp, cmd+start);
int len=(int)strlen(temp);
for(int i=0; i<len; i++)
if(temp[i]=='\\' and temp[i+1]=='\\')
char temp_[deflen] = "";
char* temp = temp_ + 1;
strcpy(temp, cmd + start);
int len = (int)strlen(temp);
for(int i = 0; i < len; i++)
if(temp[i] == '\\' and temp[i + 1] == '\\')
{
temp[i]=1;
temp[i+1]=1;
temp[i] = 1;
temp[i + 1] = 1;
}
for(int i=0; i<len; i++)
for(int i = 0; i < len; i++)
{
if(temp[i]==',' and temp[i-1]!='\\')
temp[i]=0;
if(temp[i] == ',' and temp[i - 1] != '\\')
temp[i] = 0;
}
for(int i=0; i<len; i++)
if(temp[i]==1 and temp[i+1]==1)
for(int i = 0; i < len; i++)
if(temp[i] == 1 and temp[i + 1] == 1)
{
temp[i]='\\';
temp[i+1]='\\';
temp[i] = '\\';
temp[i + 1] = '\\';
}
char new_temp[deflen]="";
int new_len=len;
for(int i=0,j=0; i<len; i++) //handle escape characters
char new_temp[deflen] = "";
int new_len = len;
for(int i = 0, j = 0; i < len; i++) //handle escape characters
{
if(temp[i]=='\\' and (temp[i+1]==',' or temp[i+1]==' ' or temp[i+1]=='\\'))
if(temp[i] == '\\' and (temp[i + 1] == ',' or temp[i + 1] == ' ' or temp[i + 1] == '\\'))
{
new_len--;
j+=sprintf(new_temp+j, "%c", temp[i+1]);
j += sprintf(new_temp + j, "%c", temp[i + 1]);
i++;
}
else
j+=sprintf(new_temp+j, "%c", temp[i]);
j += sprintf(new_temp + j, "%c", temp[i]);
}
len=new_len;
memcpy(temp, new_temp, len+1);
if(arg_num==0) //first argument
len = new_len;
memcpy(temp, new_temp, len + 1);
if(arg_num == 0) //first argument
{
strcpy(arg, temp);
return true;
}
for(int i=0,j=0; i<len; i++)
for(int i = 0, j = 0; i < len; i++)
{
if(!temp[i])
j++;
if(j==arg_num)
if(j == arg_num)
{
strcpy(arg, temp+i+1);
strcpy(arg, temp + i + 1);
return true;
}
}

View File

@ -13,25 +13,25 @@ static bool cbUnknown(const char* text, ULONGLONG* value)
uint val;
if(!valfromstring(text, &val))
return false;
*value=val;
*value = val;
return true;
}
bool assemble(uint addr, unsigned char* dest, int* size, const char* instruction, char* error)
{
if(strlen(instruction)>=XEDPARSE_MAXBUFSIZE)
if(strlen(instruction) >= XEDPARSE_MAXBUFSIZE)
return false;
XEDPARSE parse;
memset(&parse, 0, sizeof(parse));
#ifdef _WIN64
parse.x64=true;
parse.x64 = true;
#else //x86
parse.x64=false;
parse.x64 = false;
#endif
parse.cbUnknown=cbUnknown;
parse.cip=addr;
parse.cbUnknown = cbUnknown;
parse.cip = addr;
strcpy(parse.instr, instruction);
if(XEDParseAssemble(&parse)==XEDPARSE_ERROR)
if(XEDParseAssemble(&parse) == XEDPARSE_ERROR)
{
if(error)
strcpy(error, parse.error);
@ -41,7 +41,7 @@ bool assemble(uint addr, unsigned char* dest, int* size, const char* instruction
if(dest)
memcpy(dest, parse.dest, parse.dest_size);
if(size)
*size=parse.dest_size;
*size = parse.dest_size;
return true;
}
@ -53,23 +53,23 @@ bool assembleat(uint addr, const char* instruction, int* size, char* error, bool
if(!assemble(addr, dest, &destSize, instruction, error))
return false;
//calculate the number of NOPs to insert
int origLen=disasmgetsize(addr);
while(origLen<destSize)
origLen+=disasmgetsize(addr+origLen);
int nopsize=origLen-destSize;
int origLen = disasmgetsize(addr);
while(origLen < destSize)
origLen += disasmgetsize(addr + origLen);
int nopsize = origLen - destSize;
unsigned char nops[16];
memset(nops, 0x90, sizeof(nops));
if(size)
*size=destSize;
*size = destSize;
bool ret=mempatch(fdProcessInfo->hProcess, (void*)addr, dest, destSize, 0);
bool ret = mempatch(fdProcessInfo->hProcess, (void*)addr, dest, destSize, 0);
if(ret && fillnop && nopsize)
{
if(size)
*size+=nopsize;
if(!mempatch(fdProcessInfo->hProcess, (void*)(addr+destSize), nops, nopsize, 0))
ret=false;
*size += nopsize;
if(!mempatch(fdProcessInfo->hProcess, (void*)(addr + destSize), nops, nopsize, 0))
ret = false;
}
GuiUpdatePatches();
return true;

View File

@ -12,12 +12,12 @@ int bpgetlist(std::vector<BREAKPOINT>* list)
if(!DbgIsDebugging())
return false;
BREAKPOINT curBp;
int count=0;
for(BreakpointsInfo::iterator i=breakpoints.begin(); i!=breakpoints.end(); ++i)
int count = 0;
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
{
curBp=i->second;
curBp.addr+=modbasefromname(curBp.mod);
curBp.active=memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr);
curBp = i->second;
curBp.addr += modbasefromname(curBp.mod);
curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr);
count++;
if(list)
list->push_back(curBp);
@ -31,18 +31,18 @@ bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE ty
return false;
BREAKPOINT bp;
modnamefromaddr(addr, bp.mod, true);
uint modbase=modbasefromaddr(addr);
bp.active=true;
bp.addr=addr-modbase;
bp.enabled=enabled;
if(name and *name)
uint modbase = modbasefromaddr(addr);
bp.active = true;
bp.addr = addr - modbase;
bp.enabled = enabled;
if(name and * name)
strcpy(bp.name, name);
else
*bp.name='\0';
bp.oldbytes=oldbytes;
bp.singleshoot=singleshoot;
bp.titantype=titantype;
bp.type=type;
*bp.name = '\0';
bp.oldbytes = oldbytes;
bp.singleshoot = singleshoot;
bp.titantype = titantype;
bp.type = type;
breakpoints.insert(std::make_pair(BreakpointKey(type, modhashfromva(addr)), bp));
return true;
}
@ -54,29 +54,29 @@ bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp)
BREAKPOINT curBp;
if(!name)
{
BreakpointsInfo::iterator found=breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
if(found==breakpoints.end()) //not found
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
if(found == breakpoints.end()) //not found
return false;
if(!bp)
return true;
curBp=found->second;
curBp.addr+=modbasefromaddr(addr);
curBp.active=memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr);
*bp=curBp;
curBp = found->second;
curBp.addr += modbasefromaddr(addr);
curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr);
*bp = curBp;
return true;
}
for(BreakpointsInfo::iterator i=breakpoints.begin(); i!=breakpoints.end(); ++i)
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
{
curBp=i->second;
if(name and *name)
curBp = i->second;
if(name and * name)
{
if(!strcmp(name, curBp.name))
{
if(bp)
{
curBp.addr+=modbasefromname(curBp.mod);
curBp.active=memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr);
*bp=curBp;
curBp.addr += modbasefromname(curBp.mod);
curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr);
*bp = curBp;
}
return true;
}
@ -89,17 +89,17 @@ bool bpdel(uint addr, BP_TYPE type)
{
if(!DbgIsDebugging())
return false;
return (breakpoints.erase(BreakpointKey(type, modhashfromva(addr)))>0);
return (breakpoints.erase(BreakpointKey(type, modhashfromva(addr))) > 0);
}
bool bpenable(uint addr, BP_TYPE type, bool enable)
{
if(!DbgIsDebugging())
return false;
BreakpointsInfo::iterator found=breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
if(found==breakpoints.end()) //not found
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
if(found == breakpoints.end()) //not found
return false;
breakpoints[found->first].enabled=enable;
breakpoints[found->first].enabled = enable;
return true;
}
@ -107,8 +107,8 @@ bool bpsetname(uint addr, BP_TYPE type, const char* name)
{
if(!DbgIsDebugging() or !name or !*name)
return false;
BreakpointsInfo::iterator found=breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
if(found==breakpoints.end()) //not found
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
if(found == breakpoints.end()) //not found
return false;
strcpy(breakpoints[found->first].name, name);
return true;
@ -118,10 +118,10 @@ bool bpsettitantype(uint addr, BP_TYPE type, int titantype)
{
if(!DbgIsDebugging())
return false;
BreakpointsInfo::iterator found=breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
if(found==breakpoints.end()) //not found
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
if(found == breakpoints.end()) //not found
return false;
breakpoints[found->first].titantype=titantype;
breakpoints[found->first].titantype = titantype;
return true;
}
@ -129,28 +129,28 @@ bool bpenumall(BPENUMCALLBACK cbEnum, const char* module)
{
if(!DbgIsDebugging())
return false;
bool retval=true;
bool retval = true;
BREAKPOINT curBp;
BreakpointsInfo::iterator i=breakpoints.begin();
while(i!=breakpoints.end())
BreakpointsInfo::iterator i = breakpoints.begin();
while(i != breakpoints.end())
{
BreakpointsInfo::iterator j=i;
BreakpointsInfo::iterator j = i;
++i;
curBp=j->second;
curBp.addr+=modbasefromname(curBp.mod); //RVA to VA
curBp.active=memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); //TODO: wtf am I doing?
if(module and *module)
curBp = j->second;
curBp.addr += modbasefromname(curBp.mod); //RVA to VA
curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); //TODO: wtf am I doing?
if(module and * module)
{
if(!strcmp(curBp.mod, module))
{
if(!cbEnum(&curBp))
retval=false;
retval = false;
}
}
else
{
if(!cbEnum(&curBp))
retval=false;
retval = false;
}
}
return retval;
@ -163,10 +163,10 @@ bool bpenumall(BPENUMCALLBACK cbEnum)
int bpgetcount(BP_TYPE type, bool enabledonly)
{
int count=0;
for(BreakpointsInfo::iterator i=breakpoints.begin(); i!=breakpoints.end(); ++i)
int count = 0;
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
{
if(i->first.first==type && (!enabledonly || i->second.enabled))
if(i->first.first == type && (!enabledonly || i->second.enabled))
count++;
}
return count;
@ -177,39 +177,39 @@ void bptobridge(const BREAKPOINT* bp, BRIDGEBP* bridge)
if(!bp or !bridge)
return;
memset(bridge, 0, sizeof(BRIDGEBP));
bridge->active=bp->active;
bridge->addr=bp->addr;
bridge->enabled=bp->enabled;
bridge->active = bp->active;
bridge->addr = bp->addr;
bridge->enabled = bp->enabled;
strcpy(bridge->mod, bp->mod);
strcpy(bridge->name, bp->name);
bridge->singleshoot=bp->singleshoot;
bridge->singleshoot = bp->singleshoot;
switch(bp->type)
{
case BPNORMAL:
bridge->type=bp_normal;
bridge->type = bp_normal;
break;
case BPHARDWARE:
bridge->type=bp_hardware;
bridge->type = bp_hardware;
break;
case BPMEMORY:
bridge->type=bp_memory;
bridge->type = bp_memory;
default:
bridge->type=bp_none;
bridge->type = bp_none;
}
}
void bpcachesave(JSON root)
{
const JSON jsonbreakpoints=json_array();
for(BreakpointsInfo::iterator i=breakpoints.begin(); i!=breakpoints.end(); ++i)
const JSON jsonbreakpoints = json_array();
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
{
const BREAKPOINT curBreakpoint=i->second;
const BREAKPOINT curBreakpoint = i->second;
if(curBreakpoint.singleshoot)
continue; //skip
JSON curjsonbreakpoint=json_object();
JSON curjsonbreakpoint = json_object();
json_object_set_new(curjsonbreakpoint, "address", json_hex(curBreakpoint.addr));
json_object_set_new(curjsonbreakpoint, "enabled", json_boolean(curBreakpoint.enabled));
if(curBreakpoint.type==BPNORMAL)
if(curBreakpoint.type == BPNORMAL)
json_object_set_new(curjsonbreakpoint, "oldbytes", json_hex(curBreakpoint.oldbytes));
json_object_set_new(curjsonbreakpoint, "type", json_integer(curBreakpoint.type));
json_object_set_new(curjsonbreakpoint, "titantype", json_hex(curBreakpoint.titantype));
@ -225,7 +225,7 @@ void bpcachesave(JSON root)
void bpcacheload(JSON root)
{
breakpoints.clear();
const JSON jsonbreakpoints=json_object_get(root, "breakpoints");
const JSON jsonbreakpoints = json_object_get(root, "breakpoints");
if(jsonbreakpoints)
{
size_t i;
@ -234,19 +234,19 @@ void bpcacheload(JSON root)
{
BREAKPOINT curBreakpoint;
memset(&curBreakpoint, 0, sizeof(BREAKPOINT));
curBreakpoint.type=(BP_TYPE)json_integer_value(json_object_get(value, "type"));
if(curBreakpoint.type==BPNORMAL)
curBreakpoint.oldbytes=(short)json_hex_value(json_object_get(value, "oldbytes"));
curBreakpoint.addr=(uint)json_hex_value(json_object_get(value, "address"));
curBreakpoint.enabled=json_boolean_value(json_object_get(value, "enabled"));
curBreakpoint.titantype=(DWORD)json_hex_value(json_object_get(value, "titantype"));
const char* name=json_string_value(json_object_get(value, "name"));
curBreakpoint.type = (BP_TYPE)json_integer_value(json_object_get(value, "type"));
if(curBreakpoint.type == BPNORMAL)
curBreakpoint.oldbytes = (short)json_hex_value(json_object_get(value, "oldbytes"));
curBreakpoint.addr = (uint)json_hex_value(json_object_get(value, "address"));
curBreakpoint.enabled = json_boolean_value(json_object_get(value, "enabled"));
curBreakpoint.titantype = (DWORD)json_hex_value(json_object_get(value, "titantype"));
const char* name = json_string_value(json_object_get(value, "name"));
if(name)
strcpy(curBreakpoint.name, name);
const char* mod=json_string_value(json_object_get(value, "module"));
if(mod && *mod && strlen(mod)<MAX_MODULE_SIZE)
const char* mod = json_string_value(json_object_get(value, "module"));
if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE)
strcpy(curBreakpoint.mod, mod);
const uint key=modhashfromname(curBreakpoint.mod)+curBreakpoint.addr;
const uint key = modhashfromname(curBreakpoint.mod) + curBreakpoint.addr;
breakpoints.insert(std::make_pair(BreakpointKey(curBreakpoint.type, key), curBreakpoint));
}
}

View File

@ -15,9 +15,9 @@
//enums
enum BP_TYPE
{
BPNORMAL=0,
BPHARDWARE=1,
BPMEMORY=2
BPNORMAL = 0,
BPHARDWARE = 1,
BPMEMORY = 2
};
//structs

View File

@ -7,40 +7,40 @@
COMMAND* cmdfind(COMMAND* command_list, const char* name, COMMAND** link)
{
COMMAND* cur=command_list;
COMMAND* cur = command_list;
if(!cur->name)
return 0;
COMMAND* prev=0;
COMMAND* prev = 0;
while(cur)
{
if(arraycontains(cur->name, name))
{
if(link)
*link=prev;
*link = prev;
return cur;
}
prev=cur;
cur=cur->next;
prev = cur;
cur = cur->next;
}
return 0;
}
COMMAND* cmdinit()
{
COMMAND* cmd=(COMMAND*)emalloc(sizeof(COMMAND), "cmdinit:cmd");
COMMAND* cmd = (COMMAND*)emalloc(sizeof(COMMAND), "cmdinit:cmd");
memset(cmd, 0, sizeof(COMMAND));
return cmd;
}
void cmdfree(COMMAND* cmd_list)
{
COMMAND* cur=cmd_list;
COMMAND* cur = cmd_list;
while(cur)
{
efree(cur->name, "cmdfree:cur->name");
COMMAND* next=cur->next;
COMMAND* next = cur->next;
efree(cur, "cmdfree:cur");
cur=next;
cur = next;
}
}
@ -49,39 +49,39 @@ bool cmdnew(COMMAND* command_list, const char* name, CBCOMMAND cbCommand, bool d
if(!command_list or !cbCommand or !name or !*name or cmdfind(command_list, name, 0))
return false;
COMMAND* cmd;
bool nonext=false;
bool nonext = false;
if(!command_list->name)
{
cmd=command_list;
nonext=true;
cmd = command_list;
nonext = true;
}
else
cmd=(COMMAND*)emalloc(sizeof(COMMAND), "cmdnew:cmd");
cmd = (COMMAND*)emalloc(sizeof(COMMAND), "cmdnew:cmd");
memset(cmd, 0, sizeof(COMMAND));
cmd->name=(char*)emalloc(strlen(name)+1, "cmdnew:cmd->name");
cmd->name = (char*)emalloc(strlen(name) + 1, "cmdnew:cmd->name");
strcpy(cmd->name, name);
cmd->cbCommand=cbCommand;
cmd->debugonly=debugonly;
COMMAND* cur=command_list;
cmd->cbCommand = cbCommand;
cmd->debugonly = debugonly;
COMMAND* cur = command_list;
if(!nonext)
{
while(cur->next)
cur=cur->next;
cur->next=cmd;
cur = cur->next;
cur->next = cmd;
}
return true;
}
COMMAND* cmdget(COMMAND* command_list, const char* cmd)
{
char new_cmd[deflen]="";
char new_cmd[deflen] = "";
strcpy(new_cmd, cmd);
int len=(int)strlen(new_cmd);
int start=0;
while(new_cmd[start]!=' ' and start<len)
int len = (int)strlen(new_cmd);
int start = 0;
while(new_cmd[start] != ' ' and start < len)
start++;
new_cmd[start]=0;
COMMAND* found=cmdfind(command_list, new_cmd, 0);
new_cmd[start] = 0;
COMMAND* found = cmdfind(command_list, new_cmd, 0);
if(!found)
return 0;
return found;
@ -91,29 +91,29 @@ CBCOMMAND cmdset(COMMAND* command_list, const char* name, CBCOMMAND cbCommand, b
{
if(!cbCommand)
return 0;
COMMAND* found=cmdfind(command_list, name, 0);
COMMAND* found = cmdfind(command_list, name, 0);
if(!found)
return 0;
CBCOMMAND old=found->cbCommand;
found->cbCommand=cbCommand;
found->debugonly=debugonly;
CBCOMMAND old = found->cbCommand;
found->cbCommand = cbCommand;
found->debugonly = debugonly;
return old;
}
bool cmddel(COMMAND* command_list, const char* name)
{
COMMAND* prev=0;
COMMAND* found=cmdfind(command_list, name, &prev);
COMMAND* prev = 0;
COMMAND* found = cmdfind(command_list, name, &prev);
if(!found)
return false;
efree(found->name, "cmddel:found->name");
if(found==command_list)
if(found == command_list)
{
COMMAND* next=command_list->next;
COMMAND* next = command_list->next;
if(next)
{
memcpy(command_list, command_list->next, sizeof(COMMAND));
command_list->next=next->next;
command_list->next = next->next;
efree(next, "cmddel:next");
}
else
@ -121,7 +121,7 @@ bool cmddel(COMMAND* command_list, const char* name)
}
else
{
prev->next=found->next;
prev->next = found->next;
efree(found, "cmddel:found");
}
return true;
@ -138,8 +138,8 @@ CMDRESULT cmdloop(COMMAND* command_list, CBCOMMAND cbUnknownCommand, CBCOMMANDPR
{
if(!cbUnknownCommand or !cbCommandProvider)
return STATUS_ERROR;
char command[deflen]="";
bool bLoop=true;
char command[deflen] = "";
bool bLoop = true;
while(bLoop)
{
if(!cbCommandProvider(command, deflen))
@ -149,17 +149,17 @@ CMDRESULT cmdloop(COMMAND* command_list, CBCOMMAND cbUnknownCommand, CBCOMMANDPR
argformat(command); //default formatting
COMMAND* cmd;
if(!cbCommandFinder) //'clean' command processing
cmd=cmdget(command_list, command);
cmd = cmdget(command_list, command);
else //'dirty' command processing
cmd=cbCommandFinder(command_list, command);
cmd = cbCommandFinder(command_list, command);
if(!cmd or !cmd->cbCommand) //unknown command
{
char* argv[1];
*argv=command;
CMDRESULT res=cbUnknownCommand(1, argv);
if((error_is_fatal and res==STATUS_ERROR) or res==STATUS_EXIT)
bLoop=false;
*argv = command;
CMDRESULT res = cbUnknownCommand(1, argv);
if((error_is_fatal and res == STATUS_ERROR) or res == STATUS_EXIT)
bLoop = false;
}
else
{
@ -167,25 +167,25 @@ CMDRESULT cmdloop(COMMAND* command_list, CBCOMMAND cbUnknownCommand, CBCOMMANDPR
{
dputs("this command is debug-only");
if(error_is_fatal)
bLoop=false;
bLoop = false;
}
else
{
int argcount=arggetcount(command);
char** argv=(char**)emalloc((argcount+1)*sizeof(char*), "cmdloop:argv");
argv[0]=command;
for(int i=0; i<argcount; i++)
int argcount = arggetcount(command);
char** argv = (char**)emalloc((argcount + 1) * sizeof(char*), "cmdloop:argv");
argv[0] = command;
for(int i = 0; i < argcount; i++)
{
argv[i+1]=(char*)emalloc(deflen, "cmdloop:argv[i+1]");
*argv[i+1]=0;
argget(command, argv[i+1], i, true);
argv[i + 1] = (char*)emalloc(deflen, "cmdloop:argv[i+1]");
*argv[i + 1] = 0;
argget(command, argv[i + 1], i, true);
}
CMDRESULT res=cmd->cbCommand(argcount+1, argv);
for(int i=0; i<argcount; i++)
efree(argv[i+1], "cmdloop:argv[i+1]");
CMDRESULT res = cmd->cbCommand(argcount + 1, argv);
for(int i = 0; i < argcount; i++)
efree(argv[i + 1], "cmdloop:argv[i+1]");
efree(argv, "cmdloop:argv");
if((error_is_fatal and res==STATUS_ERROR) or res==STATUS_EXIT)
bLoop=false;
if((error_is_fatal and res == STATUS_ERROR) or res == STATUS_EXIT)
bLoop = false;
}
}
}
@ -205,36 +205,36 @@ static bool isvalidexpression(const char* expression)
static void specialformat(char* string)
{
int len=(int)strlen(string);
char* found=strstr(string, "=");
char* str=(char*)emalloc(len*2, "specialformat:str");
char* backup=(char*)emalloc(len+1, "specialformat:backup");
int len = (int)strlen(string);
char* found = strstr(string, "=");
char* str = (char*)emalloc(len * 2, "specialformat:str");
char* backup = (char*)emalloc(len + 1, "specialformat:backup");
strcpy(backup, string); //create a backup of the string
memset(str, 0, len*2);
memset(str, 0, len * 2);
if(found) //contains =
{
char* a=(found-1);
*found=0;
char* a = (found - 1);
*found = 0;
found++;
if(!*found)
{
*found='=';
*found = '=';
efree(str, "specialformat:str");
efree(backup, "specialformat:backup");
return;
}
int flen=(int)strlen(found); //n(+)=n++
if((found[flen-1]=='+' and found[flen-2]=='+') or (found[flen-1]=='-' and found[flen-2]=='-')) //eax++/eax--
int flen = (int)strlen(found); //n(+)=n++
if((found[flen - 1] == '+' and found[flen - 2] == '+') or (found[flen - 1] == '-' and found[flen - 2] == '-')) //eax++/eax--
{
found[flen-2]=0;
char op=found[flen-1];
found[flen - 2] = 0;
char op = found[flen - 1];
sprintf(str, "%s%c1", found, op);
strcpy(found, str);
}
if(mathisoperator(*a)>2) //x*=3 -> x=x*3
if(mathisoperator(*a) > 2) //x*=3 -> x=x*3
{
char op=*a;
*a=0;
char op = *a;
*a = 0;
if(isvalidexpression(string))
sprintf(str, "mov %s,%s%c%s", string, string, op, found);
else
@ -249,10 +249,10 @@ static void specialformat(char* string)
}
strcpy(string, str);
}
else if((string[len-1]=='+' and string[len-2]=='+') or (string[len-1]=='-' and string[len-2]=='-')) //eax++/eax--
else if((string[len - 1] == '+' and string[len - 2] == '+') or (string[len - 1] == '-' and string[len - 2] == '-')) //eax++/eax--
{
string[len-2]=0;
char op=string[len-1];
string[len - 2] = 0;
char op = string[len - 1];
if(isvalidexpression(string))
sprintf(str, "mov %s,%s%c1", string, string, op);
else
@ -268,11 +268,11 @@ static void specialformat(char* string)
*/
COMMAND* cmdfindmain(COMMAND* cmd_list, char* command)
{
COMMAND* cmd=cmdfind(cmd_list, command, 0);
COMMAND* cmd = cmdfind(cmd_list, command, 0);
if(!cmd)
{
specialformat(command);
cmd=cmdget(cmd_list, command);
cmd = cmdget(cmd_list, command);
}
if(!cmd or !cmd->cbCommand)
mathformat(command);
@ -283,26 +283,26 @@ CMDRESULT cmddirectexec(COMMAND* cmd_list, const char* cmd)
{
if(!cmd or !strlen(cmd))
return STATUS_ERROR;
char command[deflen]="";
char command[deflen] = "";
strcpy(command, cmd);
argformat(command);
COMMAND* found=cmdfindmain(cmd_list, command);
COMMAND* found = cmdfindmain(cmd_list, command);
if(!found or !found->cbCommand)
return STATUS_ERROR;
if(found->debugonly and !DbgIsDebugging())
return STATUS_ERROR;
int argcount=arggetcount(command);
char** argv=(char**)emalloc((argcount+1)*sizeof(char*), "cmddirectexec:argv");
argv[0]=command;
for(int i=0; i<argcount; i++)
int argcount = arggetcount(command);
char** argv = (char**)emalloc((argcount + 1) * sizeof(char*), "cmddirectexec:argv");
argv[0] = command;
for(int i = 0; i < argcount; i++)
{
argv[i+1]=(char*)emalloc(deflen, "cmddirectexec:argv[i+1]");
*argv[i+1]=0;
argget(command, argv[i+1], i, true);
argv[i + 1] = (char*)emalloc(deflen, "cmddirectexec:argv[i+1]");
*argv[i + 1] = 0;
argget(command, argv[i + 1], i, true);
}
CMDRESULT res=found->cbCommand(argcount+1, argv);
for(int i=0; i<argcount; i++)
efree(argv[i+1], "cmddirectexec:argv[i+1]");
CMDRESULT res = found->cbCommand(argcount + 1, argv);
for(int i = 0; i < argcount; i++)
efree(argv[i + 1], "cmddirectexec:argv[i+1]");
efree(argv, "cmddirectexec:argv");
return res;
}

View File

@ -9,13 +9,13 @@ struct COMMAND;
enum CMDRESULT
{
STATUS_ERROR=false,
STATUS_CONTINUE=true,
STATUS_EXIT=2,
STATUS_PAUSE=3
STATUS_ERROR = false,
STATUS_CONTINUE = true,
STATUS_EXIT = 2,
STATUS_PAUSE = 3
};
typedef CMDRESULT (*CBCOMMAND)(int, char**);
typedef CMDRESULT(*CBCOMMAND)(int, char**);
typedef bool (*CBCOMMANDPROVIDER)(char*, int);
typedef COMMAND* (*CBCOMMANDFINDER)(COMMAND*, char*);

View File

@ -11,7 +11,7 @@ void dprintf(const char* format, ...)
{
va_list args;
va_start(args, format);
*msg=0;
*msg = 0;
vsnprintf(msg, sizeof(msg), format, args);
GuiAddLogMessage(msg);
}

View File

@ -141,7 +141,7 @@ typedef struct _LOADED_IMAGE
#define ERROR_NO_PDB_POINTER 0x8802 // image does not point to a pdb file
typedef BOOL
(CALLBACK *PFIND_DEBUG_FILE_CALLBACK)(
(CALLBACK* PFIND_DEBUG_FILE_CALLBACK)(
__in HANDLE FileHandle,
__in PCSTR FileName,
__in PVOID CallerData
@ -158,7 +158,7 @@ SymFindDebugInfoFile(
);
typedef BOOL
(CALLBACK *PFIND_DEBUG_FILE_CALLBACKW)(
(CALLBACK* PFIND_DEBUG_FILE_CALLBACKW)(
__in HANDLE FileHandle,
__in PCWSTR FileName,
__in PVOID CallerData
@ -176,7 +176,7 @@ SymFindDebugInfoFileW(
HANDLE
IMAGEAPI
FindDebugInfoFile (
FindDebugInfoFile(
__in PCSTR FileName,
__in PCSTR SymbolPath,
__out_ecount(MAX_PATH + 1) PSTR DebugFilePath
@ -184,7 +184,7 @@ FindDebugInfoFile (
HANDLE
IMAGEAPI
FindDebugInfoFileEx (
FindDebugInfoFileEx(
__in PCSTR FileName,
__in PCSTR SymbolPath,
__out_ecount(MAX_PATH + 1) PSTR DebugFilePath,
@ -194,7 +194,7 @@ FindDebugInfoFileEx (
HANDLE
IMAGEAPI
FindDebugInfoFileExW (
FindDebugInfoFileExW(
__in PCWSTR FileName,
__in PCWSTR SymbolPath,
__out_ecount(MAX_PATH + 1) PWSTR DebugFilePath,
@ -203,7 +203,7 @@ FindDebugInfoFileExW (
);
typedef BOOL
(CALLBACK *PFINDFILEINPATHCALLBACK)(
(CALLBACK* PFINDFILEINPATHCALLBACK)(
__in PCSTR filename,
__in PVOID context
);
@ -224,7 +224,7 @@ SymFindFileInPath(
);
typedef BOOL
(CALLBACK *PFINDFILEINPATHCALLBACKW)(
(CALLBACK* PFINDFILEINPATHCALLBACKW)(
__in PCWSTR filename,
__in PVOID context
);
@ -245,7 +245,7 @@ SymFindFileInPathW(
);
typedef BOOL
(CALLBACK *PFIND_EXE_FILE_CALLBACK)(
(CALLBACK* PFIND_EXE_FILE_CALLBACK)(
__in HANDLE FileHandle,
__in PCSTR FileName,
__in_opt PVOID CallerData
@ -262,7 +262,7 @@ SymFindExecutableImage(
);
typedef BOOL
(CALLBACK *PFIND_EXE_FILE_CALLBACKW)(
(CALLBACK* PFIND_EXE_FILE_CALLBACKW)(
__in HANDLE FileHandle,
__in PCWSTR FileName,
__in_opt PVOID CallerData
@ -308,23 +308,23 @@ FindExecutableImageExW(
PIMAGE_NT_HEADERS
IMAGEAPI
ImageNtHeader (
ImageNtHeader(
__in PVOID Base
);
PVOID
IMAGEAPI
ImageDirectoryEntryToDataEx (
ImageDirectoryEntryToDataEx(
__in PVOID Base,
__in BOOLEAN MappedAsImage,
__in USHORT DirectoryEntry,
__out PULONG Size,
__out_opt PIMAGE_SECTION_HEADER *FoundHeader
__out_opt PIMAGE_SECTION_HEADER* FoundHeader
);
PVOID
IMAGEAPI
ImageDirectoryEntryToData (
ImageDirectoryEntryToData(
__in PVOID Base,
__in BOOLEAN MappedAsImage,
__in USHORT DirectoryEntry,
@ -345,7 +345,7 @@ ImageRvaToVa(
__in PIMAGE_NT_HEADERS NtHeaders,
__in PVOID Base,
__in ULONG Rva,
__in_opt OUT PIMAGE_SECTION_HEADER *LastRvaSection
__in_opt OUT PIMAGE_SECTION_HEADER* LastRvaSection
);
#ifndef _WIN64
@ -433,7 +433,7 @@ SearchTreeForFileW(
);
typedef BOOL
(CALLBACK *PENUMDIRTREE_CALLBACK)(
(CALLBACK* PENUMDIRTREE_CALLBACK)(
__in PCSTR FilePath,
__in_opt PVOID CallerData
);
@ -450,7 +450,7 @@ EnumDirTree(
);
typedef BOOL
(CALLBACK *PENUMDIRTREE_CALLBACKW)(
(CALLBACK* PENUMDIRTREE_CALLBACKW)(
__in PCWSTR FilePath,
__in_opt PVOID CallerData
);
@ -800,7 +800,7 @@ typedef struct _tagSTACKFRAME
typedef
BOOL
(__stdcall *PREAD_PROCESS_MEMORY_ROUTINE64)(
(__stdcall* PREAD_PROCESS_MEMORY_ROUTINE64)(
__in HANDLE hProcess,
__in DWORD64 qwBaseAddress,
__out_bcount(nSize) PVOID lpBuffer,
@ -810,21 +810,21 @@ BOOL
typedef
PVOID
(__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE64)(
(__stdcall* PFUNCTION_TABLE_ACCESS_ROUTINE64)(
__in HANDLE ahProcess,
__in DWORD64 AddrBase
);
typedef
DWORD64
(__stdcall *PGET_MODULE_BASE_ROUTINE64)(
(__stdcall* PGET_MODULE_BASE_ROUTINE64)(
__in HANDLE hProcess,
__in DWORD64 Address
);
typedef
DWORD64
(__stdcall *PTRANSLATE_ADDRESS_ROUTINE64)(
(__stdcall* PTRANSLATE_ADDRESS_ROUTINE64)(
__in HANDLE hProcess,
__in HANDLE hThread,
__in LPADDRESS64 lpaddr
@ -857,7 +857,7 @@ StackWalk64(
typedef
BOOL
(__stdcall *PREAD_PROCESS_MEMORY_ROUTINE)(
(__stdcall* PREAD_PROCESS_MEMORY_ROUTINE)(
__in HANDLE hProcess,
__in DWORD lpBaseAddress,
__out_bcount(nSize) PVOID lpBuffer,
@ -867,21 +867,21 @@ BOOL
typedef
PVOID
(__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE)(
(__stdcall* PFUNCTION_TABLE_ACCESS_ROUTINE)(
__in HANDLE hProcess,
__in DWORD AddrBase
);
typedef
DWORD
(__stdcall *PGET_MODULE_BASE_ROUTINE)(
(__stdcall* PGET_MODULE_BASE_ROUTINE)(
__in HANDLE hProcess,
__in DWORD Address
);
typedef
DWORD
(__stdcall *PTRANSLATE_ADDRESS_ROUTINE)(
(__stdcall* PTRANSLATE_ADDRESS_ROUTINE)(
__in HANDLE hProcess,
__in HANDLE hThread,
__out LPADDRESS lpaddr
@ -936,21 +936,21 @@ GetTimestampForLoadedLibrary(
// typedefs for function pointers
//
typedef BOOL
(CALLBACK *PSYM_ENUMMODULES_CALLBACK64)(
(CALLBACK* PSYM_ENUMMODULES_CALLBACK64)(
__in PCSTR ModuleName,
__in DWORD64 BaseOfDll,
__in_opt PVOID UserContext
);
typedef BOOL
(CALLBACK *PSYM_ENUMMODULES_CALLBACKW64)(
(CALLBACK* PSYM_ENUMMODULES_CALLBACKW64)(
__in PCWSTR ModuleName,
__in DWORD64 BaseOfDll,
__in_opt PVOID UserContext
);
typedef BOOL
(CALLBACK *PENUMLOADED_MODULES_CALLBACK64)(
(CALLBACK* PENUMLOADED_MODULES_CALLBACK64)(
__in PCSTR ModuleName,
__in DWORD64 ModuleBase,
__in ULONG ModuleSize,
@ -958,7 +958,7 @@ typedef BOOL
);
typedef BOOL
(CALLBACK *PENUMLOADED_MODULES_CALLBACKW64)(
(CALLBACK* PENUMLOADED_MODULES_CALLBACKW64)(
__in PCWSTR ModuleName,
__in DWORD64 ModuleBase,
__in ULONG ModuleSize,
@ -966,7 +966,7 @@ typedef BOOL
);
typedef BOOL
(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64)(
(CALLBACK* PSYM_ENUMSYMBOLS_CALLBACK64)(
__in PCSTR SymbolName,
__in DWORD64 SymbolAddress,
__in ULONG SymbolSize,
@ -974,7 +974,7 @@ typedef BOOL
);
typedef BOOL
(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64W)(
(CALLBACK* PSYM_ENUMSYMBOLS_CALLBACK64W)(
__in PCWSTR SymbolName,
__in DWORD64 SymbolAddress,
__in ULONG SymbolSize,
@ -982,7 +982,7 @@ typedef BOOL
);
typedef BOOL
(CALLBACK *PSYMBOL_REGISTERED_CALLBACK64)(
(CALLBACK* PSYMBOL_REGISTERED_CALLBACK64)(
__in HANDLE hProcess,
__in ULONG ActionCode,
__in_opt ULONG64 CallbackData,
@ -991,7 +991,7 @@ typedef BOOL
typedef
PVOID
(CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK)(
(CALLBACK* PSYMBOL_FUNCENTRY_CALLBACK)(
__in HANDLE hProcess,
__in DWORD AddrBase,
__in_opt PVOID UserContext
@ -999,7 +999,7 @@ PVOID
typedef
PVOID
(CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK64)(
(CALLBACK* PSYMBOL_FUNCENTRY_CALLBACK64)(
__in HANDLE hProcess,
__in ULONG64 AddrBase,
__in ULONG64 UserContext
@ -1017,14 +1017,14 @@ PVOID
#else
typedef BOOL
(CALLBACK *PSYM_ENUMMODULES_CALLBACK)(
(CALLBACK* PSYM_ENUMMODULES_CALLBACK)(
__in PCSTR ModuleName,
__in ULONG BaseOfDll,
__in_opt PVOID UserContext
);
typedef BOOL
(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK)(
(CALLBACK* PSYM_ENUMSYMBOLS_CALLBACK)(
__in PCSTR SymbolName,
__in ULONG SymbolAddress,
__in ULONG SymbolSize,
@ -1032,7 +1032,7 @@ typedef BOOL
);
typedef BOOL
(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACKW)(
(CALLBACK* PSYM_ENUMSYMBOLS_CALLBACKW)(
__in PCWSTR SymbolName,
__in ULONG SymbolAddress,
__in ULONG SymbolSize,
@ -1040,7 +1040,7 @@ typedef BOOL
);
typedef BOOL
(CALLBACK *PENUMLOADED_MODULES_CALLBACK)(
(CALLBACK* PENUMLOADED_MODULES_CALLBACK)(
__in PCSTR ModuleName,
__in ULONG ModuleBase,
__in ULONG ModuleSize,
@ -1048,7 +1048,7 @@ typedef BOOL
);
typedef BOOL
(CALLBACK *PSYMBOL_REGISTERED_CALLBACK)(
(CALLBACK* PSYMBOL_REGISTERED_CALLBACK)(
__in HANDLE hProcess,
__in ULONG ActionCode,
__in_opt PVOID CallbackData,
@ -1416,7 +1416,7 @@ typedef struct _IMAGEHLP_CBA_READ_MEMORY
DWORD64 addr; // address to read from
PVOID buf; // buffer to read to
DWORD bytes; // amount of bytes to read
DWORD *bytesread; // pointer to store amount of bytes read
DWORD* bytesread; // pointer to store amount of bytes read
} IMAGEHLP_CBA_READ_MEMORY, *PIMAGEHLP_CBA_READ_MEMORY;
enum
@ -1569,9 +1569,9 @@ IMAGEAPI
SymGetOmaps(
__in HANDLE hProcess,
__in DWORD64 BaseOfDll,
__out POMAP *OmapTo,
__out POMAP* OmapTo,
__out PDWORD64 cOmapTo,
__out POMAP *OmapFrom,
__out POMAP* OmapFrom,
__out PDWORD64 cOmapFrom
);
@ -1651,7 +1651,7 @@ SymMatchStringW(
);
typedef BOOL
(CALLBACK *PSYM_ENUMSOURCEFILES_CALLBACK)(
(CALLBACK* PSYM_ENUMSOURCEFILES_CALLBACK)(
__in PSOURCEFILE pSourceFile,
__in_opt PVOID UserContext
);
@ -1670,7 +1670,7 @@ SymEnumSourceFiles(
);
typedef BOOL
(CALLBACK *PSYM_ENUMSOURCEFILES_CALLBACKW)(
(CALLBACK* PSYM_ENUMSOURCEFILES_CALLBACKW)(
__in PSOURCEFILEW pSourceFile,
__in_opt PVOID UserContext
);
@ -1862,7 +1862,7 @@ typedef struct _SRCCODEINFOW
} SRCCODEINFOW, *PSRCCODEINFOW;
typedef BOOL
(CALLBACK *PSYM_ENUMLINES_CALLBACK)(
(CALLBACK* PSYM_ENUMLINES_CALLBACK)(
__in PSRCCODEINFO LineInfo,
__in_opt PVOID UserContext
);
@ -1879,7 +1879,7 @@ SymEnumLines(
);
typedef BOOL
(CALLBACK *PSYM_ENUMLINES_CALLBACKW)(
(CALLBACK* PSYM_ENUMLINES_CALLBACKW)(
__in PSRCCODEINFOW LineInfo,
__in_opt PVOID UserContext
);
@ -2085,8 +2085,8 @@ IMAGEAPI
SymMatchFileName(
__in PCSTR FileName,
__in PCSTR Match,
__deref_opt_out PSTR *FileNameStop,
__deref_opt_out PSTR *MatchStop
__deref_opt_out PSTR* FileNameStop,
__deref_opt_out PSTR* MatchStop
);
BOOL
@ -2094,8 +2094,8 @@ IMAGEAPI
SymMatchFileNameW(
__in PCWSTR FileName,
__in PCWSTR Match,
__deref_opt_out PWSTR *FileNameStop,
__deref_opt_out PWSTR *MatchStop
__deref_opt_out PWSTR* FileNameStop,
__deref_opt_out PWSTR* MatchStop
);
BOOL
@ -2126,8 +2126,8 @@ SymGetSourceFileToken(
__in HANDLE hProcess,
__in ULONG64 Base,
__in PCSTR FileSpec,
__deref_out PVOID *Token,
__out DWORD *Size
__deref_out PVOID* Token,
__out DWORD* Size
);
BOOL
@ -2136,8 +2136,8 @@ SymGetSourceFileTokenW(
__in HANDLE hProcess,
__in ULONG64 Base,
__in PCWSTR FileSpec,
__deref_out PVOID *Token,
__out DWORD *Size
__deref_out PVOID* Token,
__out DWORD* Size
);
BOOL
@ -2182,7 +2182,7 @@ SymGetSourceVarFromTokenW(
__in DWORD Size
);
typedef BOOL (CALLBACK *PENUMSOURCEFILETOKENSCALLBACK)(__in PVOID token, __in size_t size);
typedef BOOL (CALLBACK* PENUMSOURCEFILETOKENSCALLBACK)(__in PVOID token, __in size_t size);
BOOL
IMAGEAPI
@ -2457,7 +2457,7 @@ SymSetScopeFromIndex(
);
typedef BOOL
(CALLBACK *PSYM_ENUMPROCESSES_CALLBACK)(
(CALLBACK* PSYM_ENUMPROCESSES_CALLBACK)(
__in HANDLE hProcess,
__in PVOID UserContext
);
@ -2556,7 +2556,7 @@ SymFromNameW(
);
typedef BOOL
(CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACK)(
(CALLBACK* PSYM_ENUMERATESYMBOLS_CALLBACK)(
__in PSYMBOL_INFO pSymInfo,
__in ULONG SymbolSize,
__in_opt PVOID UserContext
@ -2573,7 +2573,7 @@ SymEnumSymbols(
);
typedef BOOL
(CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACKW)(
(CALLBACK* PSYM_ENUMERATESYMBOLS_CALLBACKW)(
__in PSYMBOL_INFOW pSymInfo,
__in ULONG SymbolSize,
__in_opt PVOID UserContext
@ -2878,7 +2878,7 @@ SymAddSourceStream(
__in size_t Size
);
typedef BOOL (WINAPI *SYMADDSOURCESTREAM)(HANDLE, ULONG64, PCSTR, PBYTE, size_t);
typedef BOOL (WINAPI* SYMADDSOURCESTREAM)(HANDLE, ULONG64, PCSTR, PBYTE, size_t);
BOOL
IMAGEAPI
@ -2890,7 +2890,7 @@ SymAddSourceStreamA(
__in size_t Size
);
typedef BOOL (WINAPI *SYMADDSOURCESTREAMA)(HANDLE, ULONG64, PCSTR, PBYTE, size_t);
typedef BOOL (WINAPI* SYMADDSOURCESTREAMA)(HANDLE, ULONG64, PCSTR, PBYTE, size_t);
BOOL
IMAGEAPI
@ -2958,7 +2958,7 @@ BOOL
IMAGEAPI
SymSrvGetFileIndexes(
__in PCSTR File,
__out GUID *Id,
__out GUID* Id,
__out PDWORD Val1,
__out_opt PDWORD Val2,
__in DWORD Flags
@ -2968,7 +2968,7 @@ BOOL
IMAGEAPI
SymSrvGetFileIndexesW(
__in PCWSTR File,
__out GUID *Id,
__out GUID* Id,
__out PDWORD Val1,
__out_opt PDWORD Val2,
__in DWORD Flags
@ -2999,11 +2999,11 @@ SymSrvGetFileIndexString(
typedef struct
{
DWORD sizeofstruct;
char file[MAX_PATH +1];
char file[MAX_PATH + 1];
BOOL stripped;
DWORD timestamp;
DWORD size;
char dbgfile[MAX_PATH +1];
char dbgfile[MAX_PATH + 1];
char pdbfile[MAX_PATH + 1];
GUID guid;
DWORD sig;
@ -3013,11 +3013,11 @@ typedef struct
typedef struct
{
DWORD sizeofstruct;
WCHAR file[MAX_PATH +1];
WCHAR file[MAX_PATH + 1];
BOOL stripped;
DWORD timestamp;
DWORD size;
WCHAR dbgfile[MAX_PATH +1];
WCHAR dbgfile[MAX_PATH + 1];
WCHAR pdbfile[MAX_PATH + 1];
GUID guid;
DWORD sig;
@ -3119,7 +3119,7 @@ SymGetSymbolFileW(
// Full user-mode dump creation.
//
typedef BOOL (WINAPI *PDBGHELP_CREATE_USER_DUMP_CALLBACK)(
typedef BOOL (WINAPI* PDBGHELP_CREATE_USER_DUMP_CALLBACK)(
__in DWORD DataType,
__in PVOID* Data,
__out LPDWORD DataLength,
@ -3199,36 +3199,36 @@ SymGetSymFromName(
// Symbol server exports
typedef BOOL (WINAPI *PSYMBOLSERVERPROC)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR);
typedef BOOL (WINAPI *PSYMBOLSERVERPROCA)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR);
typedef BOOL (WINAPI *PSYMBOLSERVERPROCW)(PCWSTR, PCWSTR, PVOID, DWORD, DWORD, PWSTR);
typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROC)(PCSTR, PCSTR, PCSTR, PSTR);
typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROCA)(PCSTR, PCSTR, PCSTR, PSTR);
typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROCW)(PCWSTR, PCWSTR, PCWSTR, PWSTR);
typedef BOOL (WINAPI *PSYMBOLSERVEROPENPROC)(VOID);
typedef BOOL (WINAPI *PSYMBOLSERVERCLOSEPROC)(VOID);
typedef BOOL (WINAPI *PSYMBOLSERVERSETOPTIONSPROC)(UINT_PTR, ULONG64);
typedef BOOL (WINAPI *PSYMBOLSERVERSETOPTIONSWPROC)(UINT_PTR, ULONG64);
typedef BOOL (CALLBACK WINAPI *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, ULONG64 data, ULONG64 context);
typedef UINT_PTR (WINAPI *PSYMBOLSERVERGETOPTIONSPROC)();
typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROC)(PCSTR);
typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROCA)(PCSTR);
typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROCW)(PCWSTR);
typedef BOOL (WINAPI *PSYMBOLSERVERGETVERSION)(LPAPI_VERSION);
typedef BOOL (WINAPI *PSYMBOLSERVERDELTANAME)(PCSTR, PVOID, DWORD, DWORD, PVOID, DWORD, DWORD, PSTR, size_t);
typedef BOOL (WINAPI *PSYMBOLSERVERDELTANAMEW)(PCWSTR, PVOID, DWORD, DWORD, PVOID, DWORD, DWORD, PWSTR, size_t);
typedef BOOL (WINAPI *PSYMBOLSERVERGETSUPPLEMENT)(PCSTR, PCSTR, PCSTR, PSTR, size_t);
typedef BOOL (WINAPI *PSYMBOLSERVERGETSUPPLEMENTW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, size_t);
typedef BOOL (WINAPI *PSYMBOLSERVERSTORESUPPLEMENT)(PCSTR, PCSTR, PCSTR, PSTR, size_t, DWORD);
typedef BOOL (WINAPI *PSYMBOLSERVERSTORESUPPLEMENTW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, size_t, DWORD);
typedef BOOL (WINAPI *PSYMBOLSERVERGETINDEXSTRING)(PVOID, DWORD, DWORD, PSTR, size_t);
typedef BOOL (WINAPI *PSYMBOLSERVERGETINDEXSTRINGW)(PVOID, DWORD, DWORD, PWSTR, size_t);
typedef BOOL (WINAPI *PSYMBOLSERVERSTOREFILE)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR, size_t, DWORD);
typedef BOOL (WINAPI *PSYMBOLSERVERSTOREFILEW)(PCWSTR, PCWSTR, PVOID, DWORD, DWORD, PWSTR, size_t, DWORD);
typedef BOOL (WINAPI *PSYMBOLSERVERISSTORE)(PCSTR);
typedef BOOL (WINAPI *PSYMBOLSERVERISSTOREW)(PCWSTR);
typedef DWORD (WINAPI *PSYMBOLSERVERVERSION)();
typedef BOOL (CALLBACK WINAPI *PSYMBOLSERVERMESSAGEPROC)(UINT_PTR action, ULONG64 data, ULONG64 context);
typedef BOOL (WINAPI* PSYMBOLSERVERPROC)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR);
typedef BOOL (WINAPI* PSYMBOLSERVERPROCA)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR);
typedef BOOL (WINAPI* PSYMBOLSERVERPROCW)(PCWSTR, PCWSTR, PVOID, DWORD, DWORD, PWSTR);
typedef BOOL (WINAPI* PSYMBOLSERVERBYINDEXPROC)(PCSTR, PCSTR, PCSTR, PSTR);
typedef BOOL (WINAPI* PSYMBOLSERVERBYINDEXPROCA)(PCSTR, PCSTR, PCSTR, PSTR);
typedef BOOL (WINAPI* PSYMBOLSERVERBYINDEXPROCW)(PCWSTR, PCWSTR, PCWSTR, PWSTR);
typedef BOOL (WINAPI* PSYMBOLSERVEROPENPROC)(VOID);
typedef BOOL (WINAPI* PSYMBOLSERVERCLOSEPROC)(VOID);
typedef BOOL (WINAPI* PSYMBOLSERVERSETOPTIONSPROC)(UINT_PTR, ULONG64);
typedef BOOL (WINAPI* PSYMBOLSERVERSETOPTIONSWPROC)(UINT_PTR, ULONG64);
typedef BOOL (CALLBACK WINAPI* PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, ULONG64 data, ULONG64 context);
typedef UINT_PTR(WINAPI* PSYMBOLSERVERGETOPTIONSPROC)();
typedef BOOL (WINAPI* PSYMBOLSERVERPINGPROC)(PCSTR);
typedef BOOL (WINAPI* PSYMBOLSERVERPINGPROCA)(PCSTR);
typedef BOOL (WINAPI* PSYMBOLSERVERPINGPROCW)(PCWSTR);
typedef BOOL (WINAPI* PSYMBOLSERVERGETVERSION)(LPAPI_VERSION);
typedef BOOL (WINAPI* PSYMBOLSERVERDELTANAME)(PCSTR, PVOID, DWORD, DWORD, PVOID, DWORD, DWORD, PSTR, size_t);
typedef BOOL (WINAPI* PSYMBOLSERVERDELTANAMEW)(PCWSTR, PVOID, DWORD, DWORD, PVOID, DWORD, DWORD, PWSTR, size_t);
typedef BOOL (WINAPI* PSYMBOLSERVERGETSUPPLEMENT)(PCSTR, PCSTR, PCSTR, PSTR, size_t);
typedef BOOL (WINAPI* PSYMBOLSERVERGETSUPPLEMENTW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, size_t);
typedef BOOL (WINAPI* PSYMBOLSERVERSTORESUPPLEMENT)(PCSTR, PCSTR, PCSTR, PSTR, size_t, DWORD);
typedef BOOL (WINAPI* PSYMBOLSERVERSTORESUPPLEMENTW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, size_t, DWORD);
typedef BOOL (WINAPI* PSYMBOLSERVERGETINDEXSTRING)(PVOID, DWORD, DWORD, PSTR, size_t);
typedef BOOL (WINAPI* PSYMBOLSERVERGETINDEXSTRINGW)(PVOID, DWORD, DWORD, PWSTR, size_t);
typedef BOOL (WINAPI* PSYMBOLSERVERSTOREFILE)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR, size_t, DWORD);
typedef BOOL (WINAPI* PSYMBOLSERVERSTOREFILEW)(PCWSTR, PCWSTR, PVOID, DWORD, DWORD, PWSTR, size_t, DWORD);
typedef BOOL (WINAPI* PSYMBOLSERVERISSTORE)(PCSTR);
typedef BOOL (WINAPI* PSYMBOLSERVERISSTOREW)(PCWSTR);
typedef DWORD (WINAPI* PSYMBOLSERVERVERSION)();
typedef BOOL (CALLBACK WINAPI* PSYMBOLSERVERMESSAGEPROC)(UINT_PTR action, ULONG64 data, ULONG64 context);
#define SYMSRV_VERSION 2
@ -3857,7 +3857,7 @@ typedef struct _MINIDUMP_SYSTEM_INFO
// ThreadId must be 4 bytes on all architectures.
//
C_ASSERT (sizeof ( ((PPROCESS_INFORMATION)0)->dwThreadId ) == 4);
C_ASSERT(sizeof(((PPROCESS_INFORMATION)0)->dwThreadId) == 4);
typedef struct _MINIDUMP_THREAD
{
@ -4061,7 +4061,7 @@ typedef struct _MINIDUMP_HANDLE_DESCRIPTOR_2
// The latest MINIDUMP_HANDLE_DESCRIPTOR definition.
typedef MINIDUMP_HANDLE_DESCRIPTOR_2 MINIDUMP_HANDLE_DESCRIPTOR_N;
typedef MINIDUMP_HANDLE_DESCRIPTOR_N *PMINIDUMP_HANDLE_DESCRIPTOR_N;
typedef MINIDUMP_HANDLE_DESCRIPTOR_N* PMINIDUMP_HANDLE_DESCRIPTOR_N;
typedef struct _MINIDUMP_HANDLE_DATA_STREAM
{
@ -4603,7 +4603,7 @@ typedef enum _MINIDUMP_SECONDARY_FLAGS
typedef
BOOL
(WINAPI * MINIDUMP_CALLBACK_ROUTINE) (
(WINAPI* MINIDUMP_CALLBACK_ROUTINE)(
__inout PVOID CallbackParam,
__in PMINIDUMP_CALLBACK_INPUT CallbackInput,
__inout PMINIDUMP_CALLBACK_OUTPUT CallbackOutput
@ -4661,9 +4661,9 @@ WINAPI
MiniDumpReadDumpStream(
__in PVOID BaseOfDump,
__in ULONG StreamNumber,
__deref_out_opt PMINIDUMP_DIRECTORY * Dir,
__deref_out_opt PVOID * StreamPointer,
__out_opt ULONG * StreamSize
__deref_out_opt PMINIDUMP_DIRECTORY* Dir,
__deref_out_opt PVOID* StreamPointer,
__out_opt ULONG* StreamSize
);
#pragma pack(pop)

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@
#include "simplescript.h"
#include "symbolinfo.h"
static bool bScyllaLoaded=false;
static bool bScyllaLoaded = false;
CMDRESULT cbDebugInit(int argc, char* argv[])
{
@ -21,7 +21,7 @@ CMDRESULT cbDebugInit(int argc, char* argv[])
return STATUS_ERROR;
}
static char arg1[deflen]="";
static char arg1[deflen] = "";
if(!argget(*argv, arg1, 0, false))
return STATUS_ERROR;
if(!FileExists(arg1))
@ -29,8 +29,8 @@ CMDRESULT cbDebugInit(int argc, char* argv[])
dputs("file does not exist!");
return STATUS_ERROR;
}
HANDLE hFile=CreateFileA(arg1, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if(hFile==INVALID_HANDLE_VALUE)
HANDLE hFile = CreateFileA(arg1, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if(hFile == INVALID_HANDLE_VALUE)
{
dputs("could not open file!");
return STATUS_ERROR;
@ -56,29 +56,29 @@ CMDRESULT cbDebugInit(int argc, char* argv[])
break;
}
static char arg2[deflen]="";
static char arg2[deflen] = "";
argget(*argv, arg2, 1, true);
char* commandline=0;
char* commandline = 0;
if(strlen(arg2))
commandline=arg2;
commandline = arg2;
char arg3[deflen]="";
char arg3[deflen] = "";
argget(*argv, arg3, 2, true);
static char currentfolder[deflen]="";
static char currentfolder[deflen] = "";
strcpy(currentfolder, arg1);
int len=(int)strlen(currentfolder);
while(currentfolder[len]!='\\' and len!=0)
int len = (int)strlen(currentfolder);
while(currentfolder[len] != '\\' and len != 0)
len--;
currentfolder[len]=0;
currentfolder[len] = 0;
if(DirExists(arg3))
strcpy(currentfolder, arg3);
INIT_STRUCT* init=(INIT_STRUCT*)emalloc(sizeof(INIT_STRUCT), "cbDebugInit:init");
INIT_STRUCT* init = (INIT_STRUCT*)emalloc(sizeof(INIT_STRUCT), "cbDebugInit:init");
memset(init, 0, sizeof(INIT_STRUCT));
init->exe=arg1;
init->commandline=commandline;
init->exe = arg1;
init->commandline = commandline;
if(*currentfolder)
init->currentfolder=currentfolder;
init->currentfolder = currentfolder;
//initialize
wait(WAITID_STOP); //wait for the debugger to stop
waitclear(); //clear waiting flags NOTE: thread-unsafe
@ -105,7 +105,7 @@ CMDRESULT cbDebugRun(int argc, char* argv[])
GuiSetDebugState(running);
unlock(WAITID_RUN);
PLUG_CB_RESUMEDEBUG callbackInfo;
callbackInfo.reserved=0;
callbackInfo.reserved = 0;
plugincbcall(CB_RESUMEDEBUG, &callbackInfo);
return STATUS_CONTINUE;
}
@ -119,29 +119,29 @@ CMDRESULT cbDebugErun(int argc, char* argv[])
CMDRESULT cbDebugSetBPXOptions(int argc, char* argv[])
{
char argtype[deflen]="";
DWORD type=0;
char argtype[deflen] = "";
DWORD type = 0;
if(!argget(*argv, argtype, 0, false))
return STATUS_ERROR;
const char* a=0;
const char* a = 0;
uint setting_type;
if(strstr(argtype, "long"))
{
setting_type=1; //break_int3long
a="TYPE_LONG_INT3";
type=UE_BREAKPOINT_LONG_INT3;
setting_type = 1; //break_int3long
a = "TYPE_LONG_INT3";
type = UE_BREAKPOINT_LONG_INT3;
}
else if(strstr(argtype, "ud2"))
{
setting_type=2; //break_ud2
a="TYPE_UD2";
type=UE_BREAKPOINT_UD2;
setting_type = 2; //break_ud2
a = "TYPE_UD2";
type = UE_BREAKPOINT_UD2;
}
else if(strstr(argtype, "short"))
{
setting_type=0; //break_int3short
a="TYPE_INT3";
type=UE_BREAKPOINT_INT3;
setting_type = 0; //break_int3short
a = "TYPE_INT3";
type = UE_BREAKPOINT_INT3;
}
else
{
@ -156,44 +156,44 @@ CMDRESULT cbDebugSetBPXOptions(int argc, char* argv[])
CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]]
{
char argaddr[deflen]="";
char argaddr[deflen] = "";
if(!argget(*argv, argaddr, 0, false))
return STATUS_ERROR;
char argname[deflen]="";
char argname[deflen] = "";
argget(*argv, argname, 1, true);
char argtype[deflen]="";
bool has_arg2=argget(*argv, argtype, 2, true);
char argtype[deflen] = "";
bool has_arg2 = argget(*argv, argtype, 2, true);
if(!has_arg2 and (scmp(argname, "ss") or scmp(argname, "long") or scmp(argname, "ud2")))
{
strcpy(argtype, argname);
*argname=0;
*argname = 0;
}
_strlwr(argtype);
uint addr=0;
uint addr = 0;
if(!valfromstring(argaddr, &addr))
{
dprintf("invalid addr: \"%s\"\n", argaddr);
return STATUS_ERROR;
}
int type=0;
bool singleshoot=false;
int type = 0;
bool singleshoot = false;
if(strstr(argtype, "ss"))
{
type|=UE_SINGLESHOOT;
singleshoot=true;
type |= UE_SINGLESHOOT;
singleshoot = true;
}
else
type|=UE_BREAKPOINT;
type |= UE_BREAKPOINT;
if(strstr(argtype, "long"))
type|=UE_BREAKPOINT_TYPE_LONG_INT3;
type |= UE_BREAKPOINT_TYPE_LONG_INT3;
else if(strstr(argtype, "ud2"))
type|=UE_BREAKPOINT_TYPE_UD2;
type |= UE_BREAKPOINT_TYPE_UD2;
else if(strstr(argtype, "short"))
type|=UE_BREAKPOINT_TYPE_INT3;
type |= UE_BREAKPOINT_TYPE_INT3;
short oldbytes;
const char* bpname=0;
const char* bpname = 0;
if(*argname)
bpname=argname;
bpname = argname;
if(bpget(addr, BPNORMAL, bpname, 0))
{
dputs("breakpoint already set!");
@ -226,7 +226,7 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]]
CMDRESULT cbDebugDeleteBPX(int argc, char* argv[])
{
char arg1[deflen]="";
char arg1[deflen] = "";
if(!argget(*argv, arg1, 0, true)) //delete all breakpoints
{
if(!bpgetcount(BPNORMAL))
@ -256,7 +256,7 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[])
}
return STATUS_CONTINUE;
}
uint addr=0;
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint
{
dprintf("no such breakpoint \"%s\"\n", arg1);
@ -280,7 +280,7 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[])
CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
{
char arg1[deflen]="";
char arg1[deflen] = "";
if(!argget(*argv, arg1, 0, true)) //enable all breakpoints
{
if(!bpgetcount(BPNORMAL))
@ -305,7 +305,7 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
GuiUpdateAllViews();
return STATUS_CONTINUE;
}
uint addr=0;
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint
{
dprintf("no such breakpoint \"%s\"\n", arg1);
@ -329,7 +329,7 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
{
char arg1[deflen]="";
char arg1[deflen] = "";
if(!argget(*argv, arg1, 0, true)) //delete all breakpoints
{
if(!bpgetcount(BPNORMAL))
@ -354,7 +354,7 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
GuiUpdateAllViews();
return STATUS_CONTINUE;
}
uint addr=0;
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint
{
dprintf("no such breakpoint \"%s\"\n", arg1);
@ -409,12 +409,12 @@ CMDRESULT cbDebugeStepOver(int argc, char* argv[])
CMDRESULT cbDebugSingleStep(int argc, char* argv[])
{
char arg1[deflen]="";
uint stepcount=1;
char arg1[deflen] = "";
uint stepcount = 1;
if(argget(*argv, arg1, 0, true))
{
if(!valfromstring(arg1, &stepcount))
stepcount=1;
stepcount = 1;
}
SingleStep((DWORD)stepcount, (void*)cbStep);
dbgsetstepping(true);
@ -438,11 +438,11 @@ CMDRESULT cbDebugHide(int argc, char* argv[])
CMDRESULT cbDebugDisasm(int argc, char* argv[])
{
char arg1[deflen]="";
uint addr=GetContextDataEx(hActiveThread, UE_CIP);
char arg1[deflen] = "";
uint addr = GetContextDataEx(hActiveThread, UE_CIP);
if(argget(*argv, arg1, 0, true))
if(!valfromstring(arg1, &addr))
addr=GetContextDataEx(hActiveThread, UE_CIP);
addr = GetContextDataEx(hActiveThread, UE_CIP);
if(!memisvalidreadptr(fdProcessInfo->hProcess, addr))
return STATUS_CONTINUE;
DebugUpdateGui(addr, false);
@ -451,49 +451,49 @@ CMDRESULT cbDebugDisasm(int argc, char* argv[])
CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[])
{
char arg1[deflen]=""; //addr
char arg1[deflen] = ""; //addr
if(!argget(*argv, arg1, 0, false))
return STATUS_ERROR;
uint addr;
if(!valfromstring(arg1, &addr))
return STATUS_ERROR;
bool restore=false;
char arg2[deflen]=""; //restore
char arg3[deflen]=""; //type
bool restore = false;
char arg2[deflen] = ""; //restore
char arg3[deflen] = ""; //type
argget(*argv, arg3, 2, true);
if(argget(*argv, arg2, 1, true))
{
if(*arg2=='1')
restore=true;
else if(*arg2=='0')
restore=false;
if(*arg2 == '1')
restore = true;
else if(*arg2 == '0')
restore = false;
else
strcpy(arg3, arg2);
}
DWORD type=UE_MEMORY;
DWORD type = UE_MEMORY;
if(*arg3)
{
switch(*arg3)
{
case 'r':
type=UE_MEMORY_READ;
type = UE_MEMORY_READ;
break;
case 'w':
type=UE_MEMORY_WRITE;
type = UE_MEMORY_WRITE;
break;
case 'x':
type=UE_MEMORY_EXECUTE; //EXECUTE
type = UE_MEMORY_EXECUTE; //EXECUTE
break;
default:
dputs("invalid type (argument ignored)");
break;
}
}
uint size=0;
uint base=memfindbaseaddr(addr, &size, true);
bool singleshoot=false;
uint size = 0;
uint base = memfindbaseaddr(addr, &size, true);
bool singleshoot = false;
if(!restore)
singleshoot=true;
singleshoot = true;
if(bpget(base, BPMEMORY, 0, 0))
{
dputs("hardware breakpoint already set!");
@ -511,7 +511,7 @@ CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[])
CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[])
{
char arg1[deflen]="";
char arg1[deflen] = "";
if(!argget(*argv, arg1, 0, true)) //delete all breakpoints
{
if(!bpgetcount(BPMEMORY))
@ -537,7 +537,7 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[])
}
return STATUS_CONTINUE;
}
uint addr=0;
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid breakpoint
{
dprintf("no such memory breakpoint \"%s\"\n", arg1);
@ -570,23 +570,23 @@ CMDRESULT cbDebugeRtr(int argc, char* argv[])
CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
{
char arg1[deflen]=""; //addr
char arg1[deflen] = ""; //addr
if(!argget(*argv, arg1, 0, false))
return STATUS_ERROR;
uint addr;
if(!valfromstring(arg1, &addr))
return STATUS_ERROR;
DWORD type=UE_HARDWARE_EXECUTE;
char arg2[deflen]=""; //type
DWORD type = UE_HARDWARE_EXECUTE;
char arg2[deflen] = ""; //type
if(argget(*argv, arg2, 1, true))
{
switch(*arg2)
{
case 'r':
type=UE_HARDWARE_READWRITE;
type = UE_HARDWARE_READWRITE;
break;
case 'w':
type=UE_HARDWARE_WRITE;
type = UE_HARDWARE_WRITE;
break;
case 'x':
break;
@ -595,8 +595,8 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
break;
}
}
char arg3[deflen]=""; //size
uint size=UE_HARDWARE_SIZE_1;
char arg3[deflen] = ""; //size
uint size = UE_HARDWARE_SIZE_1;
if(argget(*argv, arg3, 2, true))
{
if(!valfromstring(arg3, &size))
@ -604,33 +604,33 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
switch(size)
{
case 2:
size=UE_HARDWARE_SIZE_2;
size = UE_HARDWARE_SIZE_2;
break;
case 4:
size=UE_HARDWARE_SIZE_4;
size = UE_HARDWARE_SIZE_4;
break;
#ifdef _WIN64
case 8:
size=UE_HARDWARE_SIZE_8;
size = UE_HARDWARE_SIZE_8;
break;
#endif // _WIN64
default:
dputs("invalid size, using 1");
break;
}
if((addr%size)!=0)
if((addr % size) != 0)
{
dprintf("address not aligned to %d\n", size);
return STATUS_ERROR;
}
}
DWORD drx=0;
DWORD drx = 0;
if(!GetUnusedHardwareBreakPointRegister(&drx))
{
dputs("you can only set 4 hardware breakpoints");
return STATUS_ERROR;
}
int titantype=0;
int titantype = 0;
TITANSETDRX(titantype, drx);
TITANSETTYPE(titantype, type);
TITANSETSIZE(titantype, size);
@ -652,7 +652,7 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
{
char arg1[deflen]="";
char arg1[deflen] = "";
if(!argget(*argv, arg1, 0, true)) //delete all breakpoints
{
if(!bpgetcount(BPHARDWARE))
@ -676,7 +676,7 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
}
return STATUS_CONTINUE;
}
uint addr=0;
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid breakpoint
{
dprintf("no such hardware breakpoint \"%s\"\n", arg1);
@ -694,12 +694,12 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
CMDRESULT cbDebugAlloc(int argc, char* argv[])
{
char arg1[deflen]=""; //size
uint size=0x1000;
char arg1[deflen] = ""; //size
uint size = 0x1000;
if(argget(*argv, arg1, 0, true))
if(!valfromstring(arg1, &size, false))
return STATUS_ERROR;
uint mem=(uint)memalloc(fdProcessInfo->hProcess, 0, size, PAGE_EXECUTE_READWRITE);
uint mem = (uint)memalloc(fdProcessInfo->hProcess, 0, size, PAGE_EXECUTE_READWRITE);
if(!mem)
dputs("VirtualAllocEx failed");
else
@ -716,8 +716,8 @@ CMDRESULT cbDebugFree(int argc, char* argv[])
{
uint lastalloc;
varget("$lastalloc", &lastalloc, 0, 0);
char arg1[deflen]=""; //addr
uint addr=lastalloc;
char arg1[deflen] = ""; //addr
uint addr = lastalloc;
if(argget(*argv, arg1, 0, true))
{
if(!valfromstring(arg1, &addr, false))
@ -728,9 +728,9 @@ CMDRESULT cbDebugFree(int argc, char* argv[])
dputs("lastalloc is zero, provide a page address");
return STATUS_ERROR;
}
if(addr==lastalloc)
if(addr == lastalloc)
varset("$lastalloc", (uint)0, true);
bool ok=!!VirtualFreeEx(fdProcessInfo->hProcess, (void*)addr, 0, MEM_RELEASE);
bool ok = !!VirtualFreeEx(fdProcessInfo->hProcess, (void*)addr, 0, MEM_RELEASE);
if(!ok)
dputs("VirtualFreeEx failed");
dbggetprivateusage(fdProcessInfo->hProcess, true);
@ -741,11 +741,11 @@ CMDRESULT cbDebugFree(int argc, char* argv[])
CMDRESULT cbDebugMemset(int argc, char* argv[])
{
char arg3[deflen]=""; //size
char arg3[deflen] = ""; //size
uint addr;
uint value;
uint size;
if(argc<3)
if(argc < 3)
{
dputs("not enough arguments");
return STATUS_ERROR;
@ -759,37 +759,37 @@ CMDRESULT cbDebugMemset(int argc, char* argv[])
}
else
{
uint base=memfindbaseaddr(addr, &size, true);
uint base = memfindbaseaddr(addr, &size, true);
if(!base)
{
dputs("invalid address specified");
return STATUS_ERROR;
}
uint diff=addr-base;
addr=base+diff;
size-=diff;
uint diff = addr - base;
addr = base + diff;
size -= diff;
}
BYTE fi=value&0xFF;
if(!Fill((void*)addr, size&0xFFFFFFFF, &fi))
BYTE fi = value & 0xFF;
if(!Fill((void*)addr, size & 0xFFFFFFFF, &fi))
dputs("memset failed");
else
dprintf("memory "fhex" (size: %.8X) set to %.2X\n", addr, size&0xFFFFFFFF, value&0xFF);
dprintf("memory "fhex" (size: %.8X) set to %.2X\n", addr, size & 0xFFFFFFFF, value & 0xFF);
return STATUS_CONTINUE;
}
CMDRESULT cbDebugBenchmark(int argc, char* argv[])
{
uint addr=memfindbaseaddr(GetContextDataEx(hActiveThread, UE_CIP), 0);
DWORD ticks=GetTickCount();
char comment[MAX_COMMENT_SIZE]="";
for(uint i=addr; i<addr+100000; i++)
uint addr = memfindbaseaddr(GetContextDataEx(hActiveThread, UE_CIP), 0);
DWORD ticks = GetTickCount();
char comment[MAX_COMMENT_SIZE] = "";
for(uint i = addr; i < addr + 100000; i++)
{
commentset(i, "test", false);
labelset(i, "test", false);
bookmarkset(i, false);
functionadd(i, i, false);
}
dprintf("%ums\n", GetTickCount()-ticks);
dprintf("%ums\n", GetTickCount() - ticks);
return STATUS_CONTINUE;
}
@ -808,19 +808,19 @@ CMDRESULT cbDebugPause(int argc, char* argv[])
static DWORD WINAPI scyllaThread(void* lpParam)
{
typedef INT (WINAPI * SCYLLASTARTGUI)(DWORD pid, HINSTANCE mod);
SCYLLASTARTGUI ScyllaStartGui=0;
HINSTANCE hScylla=LoadLibraryA("Scylla.dll");
SCYLLASTARTGUI ScyllaStartGui = 0;
HINSTANCE hScylla = LoadLibraryA("Scylla.dll");
if(!hScylla)
{
dputs("error loading Scylla.dll!");
bScyllaLoaded=false;
bScyllaLoaded = false;
return 0;
}
ScyllaStartGui=(SCYLLASTARTGUI)GetProcAddress(hScylla, "ScyllaStartGui");
ScyllaStartGui = (SCYLLASTARTGUI)GetProcAddress(hScylla, "ScyllaStartGui");
if(!ScyllaStartGui)
{
dputs("could not find export 'ScyllaStartGui' inside Scylla.dll");
bScyllaLoaded=false;
bScyllaLoaded = false;
return 0;
}
if(dbgisdll())
@ -828,7 +828,7 @@ static DWORD WINAPI scyllaThread(void* lpParam)
else
ScyllaStartGui(fdProcessInfo->dwProcessId, 0);
FreeLibrary(hScylla);
bScyllaLoaded=false;
bScyllaLoaded = false;
return 0;
}
@ -839,19 +839,19 @@ CMDRESULT cbDebugStartScylla(int argc, char* argv[])
dputs("Scylla is already loaded");
return STATUS_ERROR;
}
bScyllaLoaded=true;
bScyllaLoaded = true;
CloseHandle(CreateThread(0, 0, scyllaThread, 0, 0, 0));
return STATUS_CONTINUE;
}
CMDRESULT cbDebugAttach(int argc, char* argv[])
{
if(argc<2)
if(argc < 2)
{
dputs("not enough arguments!");
return STATUS_ERROR;
}
uint pid=0;
uint pid = 0;
if(!valfromstring(argv[1], &pid))
{
dprintf("invalid expression \"%s\"!\n", argv[1]);
@ -863,13 +863,13 @@ CMDRESULT cbDebugAttach(int argc, char* argv[])
dputs("terminate the current session!");
return STATUS_ERROR;
}
HANDLE hProcess=TitanOpenProcess(PROCESS_ALL_ACCESS, false, (DWORD)pid);
HANDLE hProcess = TitanOpenProcess(PROCESS_ALL_ACCESS, false, (DWORD)pid);
if(!hProcess)
{
dprintf("could not open process %X!\n", pid);
return STATUS_ERROR;
}
BOOL wow64=false, mewow64=false;
BOOL wow64 = false, mewow64 = false;
if(!IsWow64Process(hProcess, &wow64) or !IsWow64Process(GetCurrentProcess(), &mewow64))
{
dputs("IsWow64Process failed!");
@ -908,12 +908,12 @@ CMDRESULT cbDebugDetach(int argc, char* argv[])
CMDRESULT cbDebugDump(int argc, char* argv[])
{
if(argc<2)
if(argc < 2)
{
dputs("not enough arguments!");
return STATUS_ERROR;
}
duint addr=0;
duint addr = 0;
if(!valfromstring(argv[1], &addr))
{
dprintf("invalid address \"%s\"!\n", argv[1]);
@ -925,18 +925,18 @@ CMDRESULT cbDebugDump(int argc, char* argv[])
CMDRESULT cbDebugStackDump(int argc, char* argv[])
{
duint addr=0;
if(argc<2)
addr=GetContextDataEx(hActiveThread, UE_CSP);
duint addr = 0;
if(argc < 2)
addr = GetContextDataEx(hActiveThread, UE_CSP);
else if(!valfromstring(argv[1], &addr))
{
dprintf("invalid address \"%s\"!\n", argv[1]);
return STATUS_ERROR;
}
duint csp=GetContextDataEx(hActiveThread, UE_CSP);
duint size=0;
duint base=memfindbaseaddr(csp, &size);
if(base && addr>=base && addr<(base+size))
duint csp = GetContextDataEx(hActiveThread, UE_CSP);
duint size = 0;
duint base = memfindbaseaddr(csp, &size);
if(base && addr >= base && addr < (base + size))
GuiStackDumpAt(addr, csp);
else
dputs("invalid stack address!");
@ -945,7 +945,7 @@ CMDRESULT cbDebugStackDump(int argc, char* argv[])
CMDRESULT cbDebugContinue(int argc, char* argv[])
{
if(argc<2)
if(argc < 2)
{
SetNextDbgContinueStatus(DBG_CONTINUE);
dputs("exception will be swallowed");
@ -960,27 +960,27 @@ CMDRESULT cbDebugContinue(int argc, char* argv[])
CMDRESULT cbDebugBpDll(int argc, char* argv[])
{
if(argc<2)
if(argc < 2)
{
dputs("not enough arguments!");
return STATUS_ERROR;
}
DWORD type=UE_ON_LIB_ALL;
if(argc>2)
DWORD type = UE_ON_LIB_ALL;
if(argc > 2)
{
switch(*argv[2])
{
case 'l':
type=UE_ON_LIB_LOAD;
type = UE_ON_LIB_LOAD;
break;
case 'u':
type=UE_ON_LIB_UNLOAD;
type = UE_ON_LIB_UNLOAD;
break;
}
}
bool singleshoot=true;
if(argc>3)
singleshoot=false;
bool singleshoot = true;
if(argc > 3)
singleshoot = false;
LibrarianSetBreakPoint(argv[1], type, singleshoot, (void*)cbLibrarianBreakpoint);
dprintf("dll breakpoint set on \"%s\"!\n", argv[1]);
return STATUS_CONTINUE;
@ -988,7 +988,7 @@ CMDRESULT cbDebugBpDll(int argc, char* argv[])
CMDRESULT cbDebugBcDll(int argc, char* argv[])
{
if(argc<2)
if(argc < 2)
{
dputs("not enough arguments");
return STATUS_ERROR;
@ -1004,8 +1004,8 @@ CMDRESULT cbDebugBcDll(int argc, char* argv[])
CMDRESULT cbDebugSwitchthread(int argc, char* argv[])
{
uint threadid=fdProcessInfo->dwThreadId; //main thread
if(argc>1)
uint threadid = fdProcessInfo->dwThreadId; //main thread
if(argc > 1)
if(!valfromstring(argv[1], &threadid, false))
return STATUS_ERROR;
if(!threadisvalid((DWORD)threadid)) //check if the thread is valid
@ -1014,7 +1014,7 @@ CMDRESULT cbDebugSwitchthread(int argc, char* argv[])
return STATUS_ERROR;
}
//switch thread
hActiveThread=threadgethandle((DWORD)threadid);
hActiveThread = threadgethandle((DWORD)threadid);
DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true);
dputs("thread switched!");
return STATUS_CONTINUE;
@ -1023,7 +1023,7 @@ CMDRESULT cbDebugSwitchthread(int argc, char* argv[])
CMDRESULT cbDebugSuspendthread(int argc, char* argv[])
{
uint threadid = fdProcessInfo->dwThreadId;
if(argc>1)
if(argc > 1)
if(!valfromstring(argv[1], &threadid, false))
return STATUS_ERROR;
if(!threadisvalid((DWORD)threadid)) //check if the thread is valid
@ -1045,7 +1045,7 @@ CMDRESULT cbDebugSuspendthread(int argc, char* argv[])
CMDRESULT cbDebugResumethread(int argc, char* argv[])
{
uint threadid = fdProcessInfo->dwThreadId;
if(argc>1)
if(argc > 1)
if(!valfromstring(argv[1], &threadid, false))
return STATUS_ERROR;
if(!threadisvalid((DWORD)threadid)) //check if the thread is valid
@ -1067,11 +1067,11 @@ CMDRESULT cbDebugResumethread(int argc, char* argv[])
CMDRESULT cbDebugKillthread(int argc, char* argv[])
{
uint threadid = fdProcessInfo->dwThreadId;
if(argc>1)
if(argc > 1)
if(!valfromstring(argv[1], &threadid, false))
return STATUS_ERROR;
uint exitcode = 0;
if(argc>2)
if(argc > 2)
if(!valfromstring(argv[2], &exitcode, false))
return STATUS_ERROR;
if(!threadisvalid((DWORD)threadid)) //check if the thread is valid
@ -1092,7 +1092,7 @@ CMDRESULT cbDebugKillthread(int argc, char* argv[])
CMDRESULT cbDebugSetPriority(int argc, char* argv[])
{
if(argc<3)
if(argc < 3)
{
dputs("not enough arguments!");
return STATUS_ERROR;
@ -1158,8 +1158,8 @@ CMDRESULT cbDebugSetPriority(int argc, char* argv[])
CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
{
char arg1[deflen]="";
DWORD drx=0;
char arg1[deflen] = "";
DWORD drx = 0;
if(!GetUnusedHardwareBreakPointRegister(&drx))
{
dputs("you can only set 4 hardware breakpoints");
@ -1179,7 +1179,7 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
return STATUS_CONTINUE;
}
BREAKPOINT found;
uint addr=0;
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint
{
dprintf("no such hardware breakpoint \"%s\"\n", arg1);
@ -1205,7 +1205,7 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
{
char arg1[deflen]="";
char arg1[deflen] = "";
if(!argget(*argv, arg1, 0, true)) //delete all hardware breakpoints
{
if(!bpgetcount(BPHARDWARE))
@ -1220,7 +1220,7 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
return STATUS_CONTINUE;
}
BREAKPOINT found;
uint addr=0;
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint
{
dprintf("no such hardware breakpoint \"%s\"\n", arg1);
@ -1243,8 +1243,8 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
{
char arg1[deflen]="";
DWORD drx=0;
char arg1[deflen] = "";
DWORD drx = 0;
if(!GetUnusedHardwareBreakPointRegister(0))
{
dputs("you can only set 4 hardware breakpoints");
@ -1264,7 +1264,7 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
return STATUS_CONTINUE;
}
BREAKPOINT found;
uint addr=0;
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint
{
dprintf("no such memory breakpoint \"%s\"\n", arg1);
@ -1276,7 +1276,7 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
GuiUpdateAllViews();
return STATUS_CONTINUE;
}
uint size=0;
uint size = 0;
memfindbaseaddr(found.addr, &size);
if(!bpenable(found.addr, BPMEMORY, true) or !SetMemoryBPXEx(found.addr, size, found.titantype, !found.singleshoot, (void*)cbMemoryBreakpoint))
{
@ -1290,7 +1290,7 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
{
char arg1[deflen]="";
char arg1[deflen] = "";
if(!argget(*argv, arg1, 0, true)) //delete all memory breakpoints
{
if(!bpgetcount(BPMEMORY))
@ -1305,7 +1305,7 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
return STATUS_CONTINUE;
}
BREAKPOINT found;
uint addr=0;
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint
{
dprintf("no such memory breakpoint \"%s\"\n", arg1);
@ -1316,7 +1316,7 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
dputs("memory breakpoint already disabled!");
return STATUS_CONTINUE;
}
uint size=0;
uint size = 0;
memfindbaseaddr(found.addr, &size);
if(!bpenable(found.addr, BPMEMORY, false) or !RemoveMemoryBPX(found.addr, size))
{

View File

@ -25,69 +25,69 @@ void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo)
//copy instruction text
strcpy(basicinfo->instruction, disasm->CompleteInstr);
//find immidiat
if(disasm->Instruction.BranchType==0) //no branch
if(disasm->Instruction.BranchType == 0) //no branch
{
if((disasm->Argument1.ArgType&CONSTANT_TYPE)==CONSTANT_TYPE)
if((disasm->Argument1.ArgType & CONSTANT_TYPE) == CONSTANT_TYPE)
{
basicinfo->type|=TYPE_VALUE;
basicinfo->value.value=(ULONG_PTR)disasm->Instruction.Immediat;
basicinfo->value.size=argsize2memsize(disasm->Argument1.ArgSize);
basicinfo->type |= TYPE_VALUE;
basicinfo->value.value = (ULONG_PTR)disasm->Instruction.Immediat;
basicinfo->value.size = argsize2memsize(disasm->Argument1.ArgSize);
}
else if((disasm->Argument2.ArgType&CONSTANT_TYPE)==CONSTANT_TYPE)
else if((disasm->Argument2.ArgType & CONSTANT_TYPE) == CONSTANT_TYPE)
{
basicinfo->type|=TYPE_VALUE;
basicinfo->value.value=(ULONG_PTR)disasm->Instruction.Immediat;
basicinfo->value.size=argsize2memsize(disasm->Argument2.ArgSize);
basicinfo->type |= TYPE_VALUE;
basicinfo->value.value = (ULONG_PTR)disasm->Instruction.Immediat;
basicinfo->value.size = argsize2memsize(disasm->Argument2.ArgSize);
}
}
else //branch
{
basicinfo->branch=true;
if(disasm->Instruction.BranchType==CallType)
basicinfo->call=true;
if(disasm->Instruction.BranchType==RetType)
basicinfo->branch=false;
basicinfo->branch = true;
if(disasm->Instruction.BranchType == CallType)
basicinfo->call = true;
if(disasm->Instruction.BranchType == RetType)
basicinfo->branch = false;
}
//find memory displacement
if((disasm->Argument1.ArgType&MEMORY_TYPE)==MEMORY_TYPE || (disasm->Argument2.ArgType&MEMORY_TYPE)==MEMORY_TYPE)
if((disasm->Argument1.ArgType & MEMORY_TYPE) == MEMORY_TYPE || (disasm->Argument2.ArgType & MEMORY_TYPE) == MEMORY_TYPE)
{
if(disasm->Argument1.Memory.Displacement)
{
basicinfo->type|=TYPE_MEMORY;
basicinfo->memory.value=(ULONG_PTR)disasm->Argument1.Memory.Displacement;
basicinfo->type |= TYPE_MEMORY;
basicinfo->memory.value = (ULONG_PTR)disasm->Argument1.Memory.Displacement;
strcpy(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic);
basicinfo->memory.size=argsize2memsize(disasm->Argument1.ArgSize);
basicinfo->memory.size = argsize2memsize(disasm->Argument1.ArgSize);
}
else if(disasm->Argument2.Memory.Displacement)
{
basicinfo->type|=TYPE_MEMORY;
basicinfo->memory.value=(ULONG_PTR)disasm->Argument2.Memory.Displacement;
basicinfo->type |= TYPE_MEMORY;
basicinfo->memory.value = (ULONG_PTR)disasm->Argument2.Memory.Displacement;
strcpy(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic);
basicinfo->memory.size=argsize2memsize(disasm->Argument2.ArgSize);
basicinfo->memory.size = argsize2memsize(disasm->Argument2.ArgSize);
}
}
//find address value
if(disasm->Instruction.BranchType && disasm->Instruction.AddrValue)
{
basicinfo->type|=TYPE_ADDR;
basicinfo->addr=(ULONG_PTR)disasm->Instruction.AddrValue;
basicinfo->type |= TYPE_ADDR;
basicinfo->addr = (ULONG_PTR)disasm->Instruction.AddrValue;
}
//rip-relative (non-branch)
if(disasm->Instruction.BranchType==0)
if(disasm->Instruction.BranchType == 0)
{
if((disasm->Argument1.ArgType&RELATIVE_)==RELATIVE_)
if((disasm->Argument1.ArgType & RELATIVE_) == RELATIVE_)
{
basicinfo->type|=TYPE_MEMORY;
basicinfo->memory.value=(ULONG_PTR)disasm->Instruction.AddrValue;
basicinfo->type |= TYPE_MEMORY;
basicinfo->memory.value = (ULONG_PTR)disasm->Instruction.AddrValue;
strcpy(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic);
basicinfo->memory.size=argsize2memsize(disasm->Argument1.ArgSize);
basicinfo->memory.size = argsize2memsize(disasm->Argument1.ArgSize);
}
else if((disasm->Argument2.ArgType&RELATIVE_)==RELATIVE_)
else if((disasm->Argument2.ArgType & RELATIVE_) == RELATIVE_)
{
basicinfo->type|=TYPE_MEMORY;
basicinfo->memory.value=(ULONG_PTR)disasm->Instruction.AddrValue;
basicinfo->type |= TYPE_MEMORY;
basicinfo->memory.value = (ULONG_PTR)disasm->Instruction.AddrValue;
strcpy(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic);
basicinfo->memory.size=argsize2memsize(disasm->Argument2.ArgSize);
basicinfo->memory.size = argsize2memsize(disasm->Argument2.ArgSize);
}
}
}
@ -99,15 +99,15 @@ bool disasmfast(unsigned char* data, uint addr, BASIC_INSTRUCTION_INFO* basicinf
DISASM disasm;
memset(&disasm, 0, sizeof(disasm));
#ifdef _WIN64
disasm.Archi=64;
disasm.Archi = 64;
#endif // _WIN64
disasm.EIP=(UIntPtr)data;
disasm.VirtualAddr=(UInt64)addr;
int len=Disasm(&disasm);
if(len==UNKNOWN_OPCODE)
disasm.EIP = (UIntPtr)data;
disasm.VirtualAddr = (UInt64)addr;
int len = Disasm(&disasm);
if(len == UNKNOWN_OPCODE)
return false;
fillbasicinfo(&disasm, basicinfo);
basicinfo->size=len;
basicinfo->size = len;
return true;
}

View File

@ -20,16 +20,16 @@ uint disasmback(unsigned char* data, uint base, uint size, uint ip, int n)
#ifdef _WIN64
disasm.Archi = 64;
#endif
disasm.Options=NoformatNumeral;
disasm.Options = NoformatNumeral;
// Check if the pointer is not null
if (data == NULL)
if(data == NULL)
return 0;
// Round the number of back instructions to 127
if(n < 0)
n = 0;
else if (n > 127)
else if(n > 127)
n = 127;
// Check if the instruction pointer ip is not outside the memory range
@ -84,12 +84,12 @@ uint disasmnext(unsigned char* data, uint base, uint size, uint ip, int n)
#ifdef _WIN64
disasm.Archi = 64;
#endif
disasm.Options=NoformatNumeral;
disasm.Options = NoformatNumeral;
if(data == NULL)
return 0;
if (ip >= size)
if(ip >= size)
ip = size - 1;
if(n <= 0)
@ -115,18 +115,18 @@ uint disasmnext(unsigned char* data, uint base, uint size, uint ip, int n)
const char* disasmtext(uint addr)
{
unsigned char buffer[16]="";
unsigned char buffer[16] = "";
DbgMemRead(addr, buffer, 16);
DISASM disasm;
disasm.Options=NoformatNumeral;
disasm.Options = NoformatNumeral;
#ifdef _WIN64
disasm.Archi=64;
disasm.Archi = 64;
#endif // _WIN64
disasm.VirtualAddr=addr;
disasm.EIP=(UIntPtr)buffer;
int len=Disasm(&disasm);
static char instruction[INSTRUCT_LENGTH]="";
if(len==UNKNOWN_OPCODE)
disasm.VirtualAddr = addr;
disasm.EIP = (UIntPtr)buffer;
int len = Disasm(&disasm);
static char instruction[INSTRUCT_LENGTH] = "";
if(len == UNKNOWN_OPCODE)
strcpy(instruction, "???");
else
strcpy(instruction, disasm.CompleteInstr);
@ -161,26 +161,26 @@ static SEGMENTREG ConvertBeaSeg(int beaSeg)
static bool HandleArgument(ARGTYPE* Argument, INSTRTYPE* Instruction, DISASM_ARG* arg, uint addr)
{
int argtype=Argument->ArgType;
const char* argmnemonic=Argument->ArgMnemonic;
int argtype = Argument->ArgType;
const char* argmnemonic = Argument->ArgMnemonic;
if(!*argmnemonic)
return false;
arg->memvalue=0;
arg->memvalue = 0;
strcpy(arg->mnemonic, argmnemonic);
if((argtype&MEMORY_TYPE)==MEMORY_TYPE)
if((argtype & MEMORY_TYPE) == MEMORY_TYPE)
{
arg->type=arg_memory;
arg->segment=ConvertBeaSeg(Argument->SegmentReg);
uint value=(uint)Argument->Memory.Displacement;
if((Argument->ArgType&RELATIVE_)==RELATIVE_)
value=(uint)Instruction->AddrValue;
arg->constant=value;
arg->value=0;
arg->type = arg_memory;
arg->segment = ConvertBeaSeg(Argument->SegmentReg);
uint value = (uint)Argument->Memory.Displacement;
if((Argument->ArgType & RELATIVE_) == RELATIVE_)
value = (uint)Instruction->AddrValue;
arg->constant = value;
arg->value = 0;
if(!valfromstring(argmnemonic, &value, true, true))
return false;
if(DbgMemIsValidReadPtr(value))
{
arg->value=value;
arg->value = value;
switch(Argument->ArgSize) //TODO: segments
{
case 8:
@ -200,17 +200,17 @@ static bool HandleArgument(ARGTYPE* Argument, INSTRTYPE* Instruction, DISASM_ARG
}
else
{
arg->segment=SEG_DEFAULT;
arg->type=arg_normal;
uint value=0;
arg->segment = SEG_DEFAULT;
arg->type = arg_normal;
uint value = 0;
if(!valfromstring(argmnemonic, &value, true, true))
return false;
arg->value=value;
char sValue[64]="";
arg->value = value;
char sValue[64] = "";
sprintf(sValue, "%"fext"X", value);
if(_stricmp(argmnemonic, sValue))
value=0;
arg->constant=value;
value = 0;
arg->constant = value;
}
return true;
}
@ -220,34 +220,34 @@ void disasmget(unsigned char* buffer, uint addr, DISASM_INSTR* instr)
if(!DbgIsDebugging())
{
if(instr)
instr->argcount=0;
instr->argcount = 0;
return;
}
memset(instr, 0, sizeof(DISASM_INSTR));
DISASM disasm;
memset(&disasm, 0, sizeof(DISASM));
disasm.Options=NoformatNumeral;
disasm.Options = NoformatNumeral;
#ifdef _WIN64
disasm.Archi=64;
disasm.Archi = 64;
#endif // _WIN64
disasm.VirtualAddr=addr;
disasm.EIP=(UIntPtr)buffer;
int len=Disasm(&disasm);
disasm.VirtualAddr = addr;
disasm.EIP = (UIntPtr)buffer;
int len = Disasm(&disasm);
strcpy(instr->instruction, disasm.CompleteInstr);
if(len==UNKNOWN_OPCODE)
if(len == UNKNOWN_OPCODE)
{
instr->instr_size=1;
instr->type=instr_normal;
instr->argcount=0;
instr->instr_size = 1;
instr->type = instr_normal;
instr->argcount = 0;
return;
}
instr->instr_size=len;
instr->instr_size = len;
if(disasm.Instruction.BranchType)
instr->type=instr_branch;
instr->type = instr_branch;
else if(strstr(disasm.CompleteInstr, "sp") or strstr(disasm.CompleteInstr, "bp"))
instr->type=instr_stack;
instr->type = instr_stack;
else
instr->type=instr_normal;
instr->type = instr_normal;
if(HandleArgument(&disasm.Argument1, &disasm.Instruction, &instr->arg[instr->argcount], addr))
instr->argcount++;
if(HandleArgument(&disasm.Argument2, &disasm.Instruction, &instr->arg[instr->argcount], addr))
@ -261,10 +261,10 @@ void disasmget(uint addr, DISASM_INSTR* instr)
if(!DbgIsDebugging())
{
if(instr)
instr->argcount=0;
instr->argcount = 0;
return;
}
unsigned char buffer[16]="";
unsigned char buffer[16] = "";
DbgMemRead(addr, buffer, 16);
disasmget(buffer, addr, instr);
}
@ -275,22 +275,22 @@ void disasmprint(uint addr)
memset(&instr, 0, sizeof(instr));
disasmget(addr, &instr);
dprintf(">%d:\"%s\":\n", instr.type, instr.instruction);
for(int i=0; i<instr.argcount; i++)
for(int i = 0; i < instr.argcount; i++)
dprintf(" %d:%d:%"fext"X:%"fext"X:%"fext"X\n", i, instr.arg[i].type, instr.arg[i].constant, instr.arg[i].value, instr.arg[i].memvalue);
}
static bool isasciistring(const unsigned char* data, int maxlen)
{
int len = 0;
for (char *p = (char *)data; *p; len++, p++)
for(char* p = (char*)data; *p; len++, p++)
{
if (len >= maxlen)
if(len >= maxlen)
break;
}
if(len<2 or len+1>=maxlen)
if(len < 2 or len + 1 >= maxlen)
return false;
for(int i=0; i<len; i++)
for(int i = 0; i < len; i++)
if(!isprint(data[i]) and !isspace(data[i]))
return false;
return true;
@ -299,17 +299,17 @@ static bool isasciistring(const unsigned char* data, int maxlen)
static bool isunicodestring(const unsigned char* data, int maxlen)
{
int len = 0;
for (wchar_t *p = (wchar_t *)data; *p; len++, p++)
for(wchar_t* p = (wchar_t*)data; *p; len++, p++)
{
if (len >= maxlen)
if(len >= maxlen)
break;
}
if(len<2 or len+1>=maxlen)
if(len < 2 or len + 1 >= maxlen)
return false;
for(int i=0; i<len*2; i+=2)
for(int i = 0; i < len * 2; i += 2)
{
if(data[i+1])
if(data[i + 1])
return false;
if(!isprint(data[i]) and !isspace(data[i]))
return false;
@ -321,9 +321,9 @@ bool disasmispossiblestring(uint addr)
{
unsigned char data[11];
memset(data, 0, sizeof(data));
if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, sizeof(data)-3, 0))
if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, sizeof(data) - 3, 0))
return false;
uint test=0;
uint test = 0;
memcpy(&test, data, sizeof(uint));
if(memisvalidreadptr(fdProcessInfo->hProcess, test)) //imports/pointers
return false;
@ -335,17 +335,17 @@ bool disasmispossiblestring(uint addr)
bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode, int maxlen)
{
if(type)
*type=str_none;
*type = str_none;
if(!disasmispossiblestring(addr))
return false;
unsigned char* data=(unsigned char*)emalloc((maxlen+1)*2, "disasmgetstringat:data");
memset(data, 0, (maxlen+1)*2);
if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, (maxlen+1)*2, 0))
unsigned char* data = (unsigned char*)emalloc((maxlen + 1) * 2, "disasmgetstringat:data");
memset(data, 0, (maxlen + 1) * 2);
if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, (maxlen + 1) * 2, 0))
{
efree(data, "disasmgetstringat:data");
return false;
}
uint test=0;
uint test = 0;
memcpy(&test, data, sizeof(uint));
if(memisvalidreadptr(fdProcessInfo->hProcess, test))
{
@ -355,35 +355,35 @@ bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode,
if(isasciistring(data, maxlen))
{
if(type)
*type=str_ascii;
int len=(int)strlen((const char*)data);
for(int i=0,j=0; i<len; i++)
*type = str_ascii;
int len = (int)strlen((const char*)data);
for(int i = 0, j = 0; i < len; i++)
{
switch(data[i])
{
case '\t':
j+=sprintf(ascii+j, "\\t");
j += sprintf(ascii + j, "\\t");
break;
case '\f':
j+=sprintf(ascii+j, "\\f");
j += sprintf(ascii + j, "\\f");
break;
case '\v':
j+=sprintf(ascii+j, "\\v");
j += sprintf(ascii + j, "\\v");
break;
case '\n':
j+=sprintf(ascii+j, "\\n");
j += sprintf(ascii + j, "\\n");
break;
case '\r':
j+=sprintf(ascii+j, "\\r");
j += sprintf(ascii + j, "\\r");
break;
case '\\':
j+=sprintf(ascii+j, "\\\\");
j += sprintf(ascii + j, "\\\\");
break;
case '\"':
j+=sprintf(ascii+j, "\\\"");
j += sprintf(ascii + j, "\\\"");
break;
default:
j+=sprintf(ascii+j, "%c", data[i]);
j += sprintf(ascii + j, "%c", data[i]);
break;
}
}
@ -393,35 +393,35 @@ bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode,
else if(isunicodestring(data, maxlen))
{
if(type)
*type=str_unicode;
int len=(int)wcslen((const wchar_t*)data);
for(int i=0,j=0; i<len*2; i+=2)
*type = str_unicode;
int len = (int)wcslen((const wchar_t*)data);
for(int i = 0, j = 0; i < len * 2; i += 2)
{
switch(data[i])
{
case '\t':
j+=sprintf(unicode+j, "\\t");
j += sprintf(unicode + j, "\\t");
break;
case '\f':
j+=sprintf(unicode+j, "\\f");
j += sprintf(unicode + j, "\\f");
break;
case '\v':
j+=sprintf(unicode+j, "\\v");
j += sprintf(unicode + j, "\\v");
break;
case '\n':
j+=sprintf(unicode+j, "\\n");
j += sprintf(unicode + j, "\\n");
break;
case '\r':
j+=sprintf(unicode+j, "\\r");
j += sprintf(unicode + j, "\\r");
break;
case '\\':
j+=sprintf(unicode+j, "\\\\");
j += sprintf(unicode + j, "\\\\");
break;
case '\"':
j+=sprintf(unicode+j, "\\\"");
j += sprintf(unicode + j, "\\\"");
break;
default:
j+=sprintf(unicode+j, "%c", data[i]);
j += sprintf(unicode + j, "%c", data[i]);
break;
}
}
@ -436,15 +436,15 @@ int disasmgetsize(uint addr, unsigned char* data)
{
DISASM disasm;
memset(&disasm, 0, sizeof(DISASM));
disasm.Options=NoformatNumeral;
disasm.Options = NoformatNumeral;
#ifdef _WIN64
disasm.Archi=64;
disasm.Archi = 64;
#endif // _WIN64
disasm.VirtualAddr=addr;
disasm.EIP=(UIntPtr)data;
int len=Disasm(&disasm);
if(len==UNKNOWN_OPCODE)
len=1;
disasm.VirtualAddr = addr;
disasm.EIP = (UIntPtr)data;
int len = Disasm(&disasm);
if(len == UNKNOWN_OPCODE)
len = 1;
return len;
}

File diff suppressed because it is too large Load Diff

View File

@ -88,13 +88,13 @@ typedef long json_int_t;
__declspec(dllimport) json_t* json_object(void);
__declspec(dllimport) json_t* json_array(void);
__declspec(dllimport) json_t* json_string(const char *value);
__declspec(dllimport) json_t* json_stringn(const char *value, size_t len);
__declspec(dllimport) json_t* json_string_nocheck(const char *value);
__declspec(dllimport) json_t* json_stringn_nocheck(const char *value, size_t len);
__declspec(dllimport) json_t* json_string(const char* value);
__declspec(dllimport) json_t* json_stringn(const char* value, size_t len);
__declspec(dllimport) json_t* json_string_nocheck(const char* value);
__declspec(dllimport) json_t* json_stringn_nocheck(const char* value, size_t len);
__declspec(dllimport) json_t* json_integer(json_int_t value);
static JSON_INLINE
json_t *json_hex(json_int_t value)
json_t* json_hex(json_int_t value)
{
char hexvalue[20];
#ifdef _WIN64
@ -111,20 +111,20 @@ __declspec(dllimport) json_t* json_false(void);
__declspec(dllimport) json_t* json_null(void);
static JSON_INLINE
json_t *json_incref(json_t *json)
json_t* json_incref(json_t* json)
{
if(json && json->refcount != (size_t)-1)
if(json && json->refcount != (size_t) - 1)
++json->refcount;
return json;
}
/* do not call json_delete directly */
__declspec(dllimport) void json_delete(json_t *json);
__declspec(dllimport) void json_delete(json_t* json);
static JSON_INLINE
void json_decref(json_t *json)
void json_decref(json_t* json)
{
if(json && json->refcount != (size_t)-1 && --json->refcount == 0)
if(json && json->refcount != (size_t) - 1 && --json->refcount == 0)
json_delete(json);
}
@ -147,22 +147,22 @@ typedef struct
/* getters, setters, manipulation */
__declspec(dllimport) void json_object_seed(size_t seed);
__declspec(dllimport) size_t json_object_size(const json_t *object);
__declspec(dllimport) json_t* json_object_get(const json_t *object, const char *key);
__declspec(dllimport) int json_object_set_new(json_t *object, const char *key, json_t *value);
__declspec(dllimport) int json_object_set_new_nocheck(json_t *object, const char *key, json_t *value);
__declspec(dllimport) int json_object_del(json_t *object, const char *key);
__declspec(dllimport) int json_object_clear(json_t *object);
__declspec(dllimport) int json_object_update(json_t *object, json_t *other);
__declspec(dllimport) int json_object_update_existing(json_t *object, json_t *other);
__declspec(dllimport) int json_object_update_missing(json_t *object, json_t *other);
__declspec(dllimport) void* json_object_iter(json_t *object);
__declspec(dllimport) void* json_object_iter_at(json_t *object, const char *key);
__declspec(dllimport) void* json_object_key_to_iter(const char *key);
__declspec(dllimport) void* json_object_iter_next(json_t *object, void *iter);
__declspec(dllimport) const char* json_object_iter_key(void *iter);
__declspec(dllimport) json_t* json_object_iter_value(void *iter);
__declspec(dllimport) int json_object_iter_set_new(json_t *object, void *iter, json_t *value);
__declspec(dllimport) size_t json_object_size(const json_t* object);
__declspec(dllimport) json_t* json_object_get(const json_t* object, const char* key);
__declspec(dllimport) int json_object_set_new(json_t* object, const char* key, json_t* value);
__declspec(dllimport) int json_object_set_new_nocheck(json_t* object, const char* key, json_t* value);
__declspec(dllimport) int json_object_del(json_t* object, const char* key);
__declspec(dllimport) int json_object_clear(json_t* object);
__declspec(dllimport) int json_object_update(json_t* object, json_t* other);
__declspec(dllimport) int json_object_update_existing(json_t* object, json_t* other);
__declspec(dllimport) int json_object_update_missing(json_t* object, json_t* other);
__declspec(dllimport) void* json_object_iter(json_t* object);
__declspec(dllimport) void* json_object_iter_at(json_t* object, const char* key);
__declspec(dllimport) void* json_object_key_to_iter(const char* key);
__declspec(dllimport) void* json_object_iter_next(json_t* object, void* iter);
__declspec(dllimport) const char* json_object_iter_key(void* iter);
__declspec(dllimport) json_t* json_object_iter_value(void* iter);
__declspec(dllimport) int json_object_iter_set_new(json_t* object, void* iter, json_t* value);
#define json_object_foreach(object, key, value) \
for(key = json_object_iter_key(json_object_iter(object)); \
@ -175,59 +175,59 @@ __declspec(dllimport) int json_object_iter_set_new(json_t *object, void *iter, j
index++)
static JSON_INLINE
int json_object_set(json_t *object, const char *key, json_t *value)
int json_object_set(json_t* object, const char* key, json_t* value)
{
return json_object_set_new(object, key, json_incref(value));
}
static JSON_INLINE
int json_object_set_nocheck(json_t *object, const char *key, json_t *value)
int json_object_set_nocheck(json_t* object, const char* key, json_t* value)
{
return json_object_set_new_nocheck(object, key, json_incref(value));
}
static JSON_INLINE
int json_object_iter_set(json_t *object, void *iter, json_t *value)
int json_object_iter_set(json_t* object, void* iter, json_t* value)
{
return json_object_iter_set_new(object, iter, json_incref(value));
}
__declspec(dllimport) size_t json_array_size(const json_t *array);
__declspec(dllimport) json_t* json_array_get(const json_t *array, size_t index);
__declspec(dllimport) int json_array_set_new(json_t *array, size_t index, json_t *value);
__declspec(dllimport) int json_array_append_new(json_t *array, json_t *value);
__declspec(dllimport) int json_array_insert_new(json_t *array, size_t index, json_t *value);
__declspec(dllimport) int json_array_remove(json_t *array, size_t index);
__declspec(dllimport) int json_array_clear(json_t *array);
__declspec(dllimport) int json_array_extend(json_t *array, json_t *other);
__declspec(dllimport) size_t json_array_size(const json_t* array);
__declspec(dllimport) json_t* json_array_get(const json_t* array, size_t index);
__declspec(dllimport) int json_array_set_new(json_t* array, size_t index, json_t* value);
__declspec(dllimport) int json_array_append_new(json_t* array, json_t* value);
__declspec(dllimport) int json_array_insert_new(json_t* array, size_t index, json_t* value);
__declspec(dllimport) int json_array_remove(json_t* array, size_t index);
__declspec(dllimport) int json_array_clear(json_t* array);
__declspec(dllimport) int json_array_extend(json_t* array, json_t* other);
static JSON_INLINE
int json_array_set(json_t *array, size_t ind, json_t *value)
int json_array_set(json_t* array, size_t ind, json_t* value)
{
return json_array_set_new(array, ind, json_incref(value));
}
static JSON_INLINE
int json_array_append(json_t *array, json_t *value)
int json_array_append(json_t* array, json_t* value)
{
return json_array_append_new(array, json_incref(value));
}
static JSON_INLINE
int json_array_insert(json_t *array, size_t ind, json_t *value)
int json_array_insert(json_t* array, size_t ind, json_t* value)
{
return json_array_insert_new(array, ind, json_incref(value));
}
__declspec(dllimport) const char* json_string_value(const json_t *string);
__declspec(dllimport) size_t json_string_length(const json_t *string);
__declspec(dllimport) json_int_t json_integer_value(const json_t *integer);
__declspec(dllimport) const char* json_string_value(const json_t* string);
__declspec(dllimport) size_t json_string_length(const json_t* string);
__declspec(dllimport) json_int_t json_integer_value(const json_t* integer);
static JSON_INLINE
json_int_t json_hex_value(const json_t* hex)
{
json_int_t ret;
const char* hexvalue;
hexvalue=json_string_value(hex);
hexvalue = json_string_value(hex);
if(!hexvalue)
return 0;
#ifdef _WIN64
@ -237,39 +237,39 @@ json_int_t json_hex_value(const json_t* hex)
#endif //_WIN64
return ret;
}
__declspec(dllimport) double json_real_value(const json_t *real);
__declspec(dllimport) double json_number_value(const json_t *json);
__declspec(dllimport) double json_real_value(const json_t* real);
__declspec(dllimport) double json_number_value(const json_t* json);
__declspec(dllimport) int json_string_set(json_t *string, const char *value);
__declspec(dllimport) int json_string_setn(json_t *string, const char *value, size_t len);
__declspec(dllimport) int json_string_set_nocheck(json_t *string, const char *value);
__declspec(dllimport) int json_string_setn_nocheck(json_t *string, const char *value, size_t len);
__declspec(dllimport) int json_integer_set(json_t *integer, json_int_t value);
__declspec(dllimport) int json_real_set(json_t *real, double value);
__declspec(dllimport) int json_string_set(json_t* string, const char* value);
__declspec(dllimport) int json_string_setn(json_t* string, const char* value, size_t len);
__declspec(dllimport) int json_string_set_nocheck(json_t* string, const char* value);
__declspec(dllimport) int json_string_setn_nocheck(json_t* string, const char* value, size_t len);
__declspec(dllimport) int json_integer_set(json_t* integer, json_int_t value);
__declspec(dllimport) int json_real_set(json_t* real, double value);
/* pack, unpack */
__declspec(dllimport) json_t* json_pack(const char *fmt, ...);
__declspec(dllimport) json_t* json_pack_ex(json_error_t *error, size_t flags, const char *fmt, ...);
__declspec(dllimport) json_t* json_vpack_ex(json_error_t *error, size_t flags, const char *fmt, va_list ap);
__declspec(dllimport) json_t* json_pack(const char* fmt, ...);
__declspec(dllimport) json_t* json_pack_ex(json_error_t* error, size_t flags, const char* fmt, ...);
__declspec(dllimport) json_t* json_vpack_ex(json_error_t* error, size_t flags, const char* fmt, va_list ap);
#define JSON_VALIDATE_ONLY 0x1
#define JSON_STRICT 0x2
__declspec(dllimport) int json_unpack(json_t *root, const char *fmt, ...);
__declspec(dllimport) int json_unpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, ...);
__declspec(dllimport) int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, va_list ap);
__declspec(dllimport) int json_unpack(json_t* root, const char* fmt, ...);
__declspec(dllimport) int json_unpack_ex(json_t* root, json_error_t* error, size_t flags, const char* fmt, ...);
__declspec(dllimport) int json_vunpack_ex(json_t* root, json_error_t* error, size_t flags, const char* fmt, va_list ap);
/* equality */
__declspec(dllimport) int json_equal(json_t *value1, json_t *value2);
__declspec(dllimport) int json_equal(json_t* value1, json_t* value2);
/* copying */
__declspec(dllimport) json_t* json_copy(json_t *value);
__declspec(dllimport) json_t* json_deep_copy(const json_t *value);
__declspec(dllimport) json_t* json_copy(json_t* value);
__declspec(dllimport) json_t* json_deep_copy(const json_t* value);
/* decoding */
@ -280,13 +280,13 @@ __declspec(dllimport) json_t* json_deep_copy(const json_t *value);
#define JSON_DECODE_INT_AS_REAL 0x8
#define JSON_ALLOW_NUL 0x10
typedef size_t (*json_load_callback_t)(void *buffer, size_t buflen, void *data);
typedef size_t (*json_load_callback_t)(void* buffer, size_t buflen, void* data);
__declspec(dllimport) json_t* json_loads(const char *input, size_t flags, json_error_t *error);
__declspec(dllimport) json_t* json_loadb(const char *buffer, size_t buflen, size_t flags, json_error_t *error);
__declspec(dllimport) json_t* json_loadf(FILE *input, size_t flags, json_error_t *error);
__declspec(dllimport) json_t* json_load_file(const char *path, size_t flags, json_error_t *error);
__declspec(dllimport) json_t* json_load_callback(json_load_callback_t callback, void *data, size_t flags, json_error_t *error);
__declspec(dllimport) json_t* json_loads(const char* input, size_t flags, json_error_t* error);
__declspec(dllimport) json_t* json_loadb(const char* buffer, size_t buflen, size_t flags, json_error_t* error);
__declspec(dllimport) json_t* json_loadf(FILE* input, size_t flags, json_error_t* error);
__declspec(dllimport) json_t* json_load_file(const char* path, size_t flags, json_error_t* error);
__declspec(dllimport) json_t* json_load_callback(json_load_callback_t callback, void* data, size_t flags, json_error_t* error);
/* encoding */
@ -300,17 +300,17 @@ __declspec(dllimport) json_t* json_load_callback(json_load_callback_t callback,
#define JSON_ESCAPE_SLASH 0x400
#define JSON_REAL_PRECISION(n) (((n) & 0x1F) << 11)
typedef int (*json_dump_callback_t)(const char *buffer, size_t size, void *data);
typedef int (*json_dump_callback_t)(const char* buffer, size_t size, void* data);
__declspec(dllimport) char* json_dumps(const json_t *json, size_t flags);
__declspec(dllimport) int json_dumpf(const json_t *json, FILE *output, size_t flags);
__declspec(dllimport) int json_dump_file(const json_t *json, const char *path, size_t flags);
__declspec(dllimport) int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data, size_t flags);
__declspec(dllimport) char* json_dumps(const json_t* json, size_t flags);
__declspec(dllimport) int json_dumpf(const json_t* json, FILE* output, size_t flags);
__declspec(dllimport) int json_dump_file(const json_t* json, const char* path, size_t flags);
__declspec(dllimport) int json_dump_callback(const json_t* json, json_dump_callback_t callback, void* data, size_t flags);
/* custom memory allocation */
typedef void *(*json_malloc_t)(size_t);
typedef void (*json_free_t)(void *);
typedef void* (*json_malloc_t)(size_t);
typedef void (*json_free_t)(void*);
__declspec(dllimport) void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn);

View File

@ -60,8 +60,8 @@ extern "C"
Simple Functions
**************************************/
__declspec(dllimport) int LZ4_compress (const char* source, char* dest, int inputSize);
__declspec(dllimport) int LZ4_decompress_safe (const char* source, char* dest, int inputSize, int maxOutputSize);
__declspec(dllimport) int LZ4_compress(const char* source, char* dest, int inputSize);
__declspec(dllimport) int LZ4_decompress_safe(const char* source, char* dest, int inputSize, int maxOutputSize);
/*
LZ4_compress() :
@ -112,7 +112,7 @@ LZ4_compress_limitedOutput() :
return : the number of bytes written in buffer 'dest'
or 0 if the compression fails
*/
__declspec(dllimport) int LZ4_compress_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
__declspec(dllimport) int LZ4_compress_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize);
/*
@ -125,7 +125,7 @@ LZ4_decompress_fast() :
Use this function preferably into a trusted environment (data to decode comes from a trusted source).
Destination buffer must be already allocated. Its size must be a minimum of 'outputSize' bytes.
*/
__declspec(dllimport) int LZ4_decompress_fast (const char* source, char* dest, int originalSize);
__declspec(dllimport) int LZ4_decompress_fast(const char* source, char* dest, int originalSize);
/*
@ -140,7 +140,7 @@ LZ4_decompress_safe_partial() :
If the source stream is detected malformed, the function will stop decoding and return a negative result.
This function never writes outside of output buffer, and never reads outside of input buffer. It is therefore protected against malicious data packets
*/
__declspec(dllimport) int LZ4_decompress_safe_partial (const char* source, char* dest, int inputSize, int targetOutputSize, int maxOutputSize);
__declspec(dllimport) int LZ4_decompress_safe_partial(const char* source, char* dest, int inputSize, int targetOutputSize, int maxOutputSize);
/*
@ -155,18 +155,18 @@ LZ4_compress_withState() and LZ4_compress_limitedOutput_withState() are equivale
They just use the externally allocated memory area instead of allocating their own (on stack, or on heap).
*/
__declspec(dllimport) int LZ4_sizeofState(void);
__declspec(dllimport) int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize);
__declspec(dllimport) int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
__declspec(dllimport) int LZ4_compress_withState(void* state, const char* source, char* dest, int inputSize);
__declspec(dllimport) int LZ4_compress_limitedOutput_withState(void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
/**************************************
Streaming Functions
**************************************/
__declspec(dllimport) void* LZ4_create (const char* inputBuffer);
__declspec(dllimport) int LZ4_compress_continue (void* LZ4_Data, const char* source, char* dest, int inputSize);
__declspec(dllimport) int LZ4_compress_limitedOutput_continue (void* LZ4_Data, const char* source, char* dest, int inputSize, int maxOutputSize);
__declspec(dllimport) char* LZ4_slideInputBuffer (void* LZ4_Data);
__declspec(dllimport) int LZ4_free (void* LZ4_Data);
__declspec(dllimport) void* LZ4_create(const char* inputBuffer);
__declspec(dllimport) int LZ4_compress_continue(void* LZ4_Data, const char* source, char* dest, int inputSize);
__declspec(dllimport) int LZ4_compress_limitedOutput_continue(void* LZ4_Data, const char* source, char* dest, int inputSize, int maxOutputSize);
__declspec(dllimport) char* LZ4_slideInputBuffer(void* LZ4_Data);
__declspec(dllimport) int LZ4_free(void* LZ4_Data);
/*
These functions allow the compression of dependent blocks, where each block benefits from prior 64 KB within preceding blocks.
@ -223,8 +223,8 @@ Any other value means there was an error (typically, pointer is not aligned on 4
*/
__declspec(dllimport) int LZ4_decompress_safe_withPrefix64k (const char* source, char* dest, int inputSize, int maxOutputSize);
__declspec(dllimport) int LZ4_decompress_fast_withPrefix64k (const char* source, char* dest, int outputSize);
__declspec(dllimport) int LZ4_decompress_safe_withPrefix64k(const char* source, char* dest, int inputSize, int maxOutputSize);
__declspec(dllimport) int LZ4_decompress_fast_withPrefix64k(const char* source, char* dest, int outputSize);
/*
*_withPrefix64k() :
@ -241,8 +241,8 @@ __declspec(dllimport) int LZ4_decompress_fast_withPrefix64k (const char* source,
These functions are deprecated and should no longer be used.
They are provided here for compatibility with existing user programs.
*/
__declspec(dllimport) int LZ4_uncompress (const char* source, char* dest, int outputSize);
__declspec(dllimport) int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize);
__declspec(dllimport) int LZ4_uncompress(const char* source, char* dest, int outputSize);
__declspec(dllimport) int LZ4_uncompress_unknownOutputSize(const char* source, char* dest, int isize, int maxOutputSize);
#if defined (__cplusplus)

View File

@ -40,7 +40,7 @@ extern "C"
#endif
__declspec(dllimport) int LZ4_compressHC (const char* source, char* dest, int inputSize);
__declspec(dllimport) int LZ4_compressHC(const char* source, char* dest, int inputSize);
/*
LZ4_compressHC :
return : the number of bytes in compressed buffer dest
@ -50,7 +50,7 @@ LZ4_compressHC :
Worst case size evaluation is provided by function LZ4_compressBound() (see "lz4.h")
*/
__declspec(dllimport) int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
__declspec(dllimport) int LZ4_compressHC_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize);
/*
LZ4_compress_limitedOutput() :
Compress 'inputSize' bytes from 'source' into an output buffer 'dest' of maximum size 'maxOutputSize'.
@ -64,8 +64,8 @@ LZ4_compress_limitedOutput() :
*/
__declspec(dllimport) int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel);
__declspec(dllimport) int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
__declspec(dllimport) int LZ4_compressHC2(const char* source, char* dest, int inputSize, int compressionLevel);
__declspec(dllimport) int LZ4_compressHC2_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
/*
Same functions as above, but with programmable 'compressionLevel'.
Recommended values are between 4 and 9, although any value between 0 and 16 will work.
@ -83,10 +83,10 @@ Decompression functions are provided within LZ4 source code (see "lz4.h") (BSD l
Using an external allocation
**************************************/
__declspec(dllimport) int LZ4_sizeofStateHC(void);
__declspec(dllimport) int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize);
__declspec(dllimport) int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
__declspec(dllimport) int LZ4_compressHC_withStateHC(void* state, const char* source, char* dest, int inputSize);
__declspec(dllimport) int LZ4_compressHC_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
__declspec(dllimport) int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel);
__declspec(dllimport) int LZ4_compressHC2_withStateHC(void* state, const char* source, char* dest, int inputSize, int compressionLevel);
__declspec(dllimport) int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
/*
@ -105,14 +105,14 @@ They just use the externally allocated memory area instead of allocating their o
/**************************************
Streaming Functions
**************************************/
__declspec(dllimport) void* LZ4_createHC (const char* inputBuffer);
__declspec(dllimport) int LZ4_compressHC_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize);
__declspec(dllimport) int LZ4_compressHC_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize);
__declspec(dllimport) char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
__declspec(dllimport) int LZ4_freeHC (void* LZ4HC_Data);
__declspec(dllimport) void* LZ4_createHC(const char* inputBuffer);
__declspec(dllimport) int LZ4_compressHC_continue(void* LZ4HC_Data, const char* source, char* dest, int inputSize);
__declspec(dllimport) int LZ4_compressHC_limitedOutput_continue(void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize);
__declspec(dllimport) char* LZ4_slideInputBufferHC(void* LZ4HC_Data);
__declspec(dllimport) int LZ4_freeHC(void* LZ4HC_Data);
__declspec(dllimport) int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
__declspec(dllimport) int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
__declspec(dllimport) int LZ4_compressHC2_continue(void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
__declspec(dllimport) int LZ4_compressHC2_limitedOutput_continue(void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
/*
These functions allow the compression of dependent blocks, where each block benefits from prior 64 KB within preceding blocks.

View File

@ -2,7 +2,7 @@
extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
if(fdwReason==DLL_PROCESS_ATTACH)
hInst=hinstDLL;
if(fdwReason == DLL_PROCESS_ATTACH)
hInst = hinstDLL;
return TRUE;
}

View File

@ -30,21 +30,21 @@ operator precedence
int mathisoperator(char ch)
{
if(ch=='(' or ch==')')
if(ch == '(' or ch == ')')
return 1;
else if(ch=='~')
else if(ch == '~')
return 2;
else if(ch=='*' or ch=='$' or ch=='/' or ch=='%')
else if(ch == '*' or ch == '$' or ch == '/' or ch == '%')
return 3;
else if(ch=='+' or ch=='-')
else if(ch == '+' or ch == '-')
return 4;
else if(ch=='<' or ch=='>')
else if(ch == '<' or ch == '>')
return 5;
else if(ch=='&')
else if(ch == '&')
return 6;
else if(ch=='^')
else if(ch == '^')
return 7;
else if(ch=='|')
else if(ch == '|')
return 8;
return 0;
}
@ -55,12 +55,12 @@ mathformat:
*/
void mathformat(char* text)
{
int len=(int)strlen(text);
char* temp=(char*)emalloc(len+1, "mathformat:temp");
memset(temp, 0, len+1);
for(int i=0,j=0; i<len; i++)
if(mathisoperator(text[i])<3 or text[i]!=text[i+1])
j+=sprintf(temp+j, "%c", text[i]);
int len = (int)strlen(text);
char* temp = (char*)emalloc(len + 1, "mathformat:temp");
memset(temp, 0, len + 1);
for(int i = 0, j = 0; i < len; i++)
if(mathisoperator(text[i]) < 3 or text[i] != text[i + 1])
j += sprintf(temp + j, "%c", text[i]);
strcpy(text, temp);
efree(temp, "mathformat:temp");
}
@ -70,10 +70,10 @@ void mathformat(char* text)
*/
bool mathcontains(const char* text)
{
if(*text=='-') //ignore negative values
if(*text == '-') //ignore negative values
text++;
int len=(int)strlen(text);
for(int i=0; i<len; i++)
int len = (int)strlen(text);
for(int i = 0; i < len; i++)
if(mathisoperator(text[i]))
return true;
return false;
@ -82,37 +82,37 @@ bool mathcontains(const char* text)
#ifdef __MINGW64__
static inline unsigned long long umulhi(unsigned long long x, unsigned long long y)
{
return (unsigned long long)(((__uint128_t)x*y)>>64);
return (unsigned long long)(((__uint128_t)x * y) >> 64);
}
static inline long long mulhi(long long x, long long y)
{
return (long long)(((__int128_t)x*y)>>64);
return (long long)(((__int128_t)x * y) >> 64);
}
#elif _WIN64
#include <intrin.h>
static inline unsigned long long umulhi(unsigned long long x, unsigned long long y)
{
unsigned __int64 res;
_umul128(x,y,&res);
_umul128(x, y, &res);
return res;
}
static inline long long mulhi(long long x, long long y)
{
__int64 res;
_mul128(x,y,&res);
_mul128(x, y, &res);
return res;
}
#else
static inline unsigned int umulhi(unsigned int x, unsigned int y)
{
return (unsigned int)(((unsigned long long)x*y)>>32);
return (unsigned int)(((unsigned long long)x * y) >> 32);
}
static inline int mulhi(int x, int y)
{
return (int)(((long long)x*y)>>32);
return (int)(((long long)x * y) >> 32);
}
#endif //__MINGW64__
@ -121,45 +121,45 @@ bool mathdounsignedoperation(char op, uint left, uint right, uint* result)
switch(op)
{
case '*':
*result=left*right;
*result = left * right;
return true;
case '$':
*result=umulhi(left, right);
*result = umulhi(left, right);
return true;
case '/':
if(right)
{
*result=left/right;
*result = left / right;
return true;
}
return false;
case '%':
if(right)
{
*result=left%right;
*result = left % right;
return true;
}
return false;
case '+':
*result=left+right;
*result = left + right;
return true;
case '-':
*result=left-right;
*result = left - right;
return true;
case '<':
*result=left<<right;
*result = left << right;
return true;
case '>':
*result=left>>right;
*result = left >> right;
return true;
case '&':
*result=left&right;
*result = left & right;
return true;
case '^':
*result=left^right;
*result = left ^ right;
return true;
case '|':
*result=left|right;
*result = left | right;
return true;
}
return false;
@ -170,45 +170,45 @@ bool mathdosignedoperation(char op, sint left, sint right, sint* result)
switch(op)
{
case '*':
*result=left*right;
*result = left * right;
return true;
case '$':
*result=mulhi(left, right);
*result = mulhi(left, right);
return true;
case '/':
if(right)
{
*result=left/right;
*result = left / right;
return true;
}
return false;
case '%':
if(right)
{
*result=left%right;
*result = left % right;
return true;
}
return false;
case '+':
*result=left+right;
*result = left + right;
return true;
case '-':
*result=left-right;
*result = left - right;
return true;
case '<':
*result=left<<right;
*result = left << right;
return true;
case '>':
*result=left>>right;
*result = left >> right;
return true;
case '&':
*result=left&right;
*result = left & right;
return true;
case '^':
*result=left^right;
*result = left ^ right;
return true;
case '|':
*result=left|right;
*result = left | right;
return true;
}
return false;
@ -216,19 +216,19 @@ bool mathdosignedoperation(char op, sint left, sint right, sint* result)
static void fillpair(EXPRESSION* expstruct, int pos, int layer)
{
for(int i=0; i<expstruct->total_pairs; i++)
for(int i = 0; i < expstruct->total_pairs; i++)
{
if(!expstruct->pairs[i].isset)
{
expstruct->pairs[i].layer=layer;
expstruct->pairs[i].openpos=pos;
expstruct->pairs[i].isset=1;
expstruct->pairs[i].layer = layer;
expstruct->pairs[i].openpos = pos;
expstruct->pairs[i].isset = 1;
break;
}
else if(expstruct->pairs[i].layer==layer and expstruct->pairs[i].isset==1)
else if(expstruct->pairs[i].layer == layer and expstruct->pairs[i].isset == 1)
{
expstruct->pairs[i].closepos=pos;
expstruct->pairs[i].isset=2;
expstruct->pairs[i].closepos = pos;
expstruct->pairs[i].isset = 2;
break;
}
}
@ -237,22 +237,22 @@ static void fillpair(EXPRESSION* expstruct, int pos, int layer)
static int matchpairs(EXPRESSION* expstruct, char* expression, int endlayer)
{
int layer=endlayer;
int len=(int)strlen(expression);
for(int i=0; i<len; i++)
int layer = endlayer;
int len = (int)strlen(expression);
for(int i = 0; i < len; i++)
{
if(expression[i]=='(')
if(expression[i] == '(')
{
layer++;
int pos=(int)(expression+i-expstruct->expression);
int pos = (int)(expression + i - expstruct->expression);
fillpair(expstruct, pos, layer);
i+=matchpairs(expstruct, expression+i+1, layer);
i += matchpairs(expstruct, expression + i + 1, layer);
}
else if(expression[i]==')')
else if(expression[i] == ')')
{
if(layer==endlayer)
if(layer == endlayer)
{
int pos=(int)(expression+i-expstruct->expression);
int pos = (int)(expression + i - expstruct->expression);
fillpair(expstruct, pos, layer);
return i;
}
@ -265,59 +265,59 @@ static int matchpairs(EXPRESSION* expstruct, char* expression, int endlayer)
static int expressionformat(char* exp)
{
int len=(int)strlen(exp);
int open=0;
int close=0;
for(int i=0; i<len; i++)
int len = (int)strlen(exp);
int open = 0;
int close = 0;
for(int i = 0; i < len; i++)
{
if(exp[i]=='(')
if(exp[i] == '(')
open++;
else if(exp[i]==')')
else if(exp[i] == ')')
close++;
}
if(close>open)
if(close > open)
return -1;
int add=open-close;
int add = open - close;
if(add)
{
memset(exp+len, ')', add);
exp[len+add]=0;
memset(exp + len, ')', add);
exp[len + add] = 0;
}
return open;
}
static void adjustpairs(EXPRESSION* exps, int cur_open, int cur_close, int cur_len, int new_len)
{
for(int i=0; i<exps->total_pairs; i++)
for(int i = 0; i < exps->total_pairs; i++)
{
if(exps->pairs[i].openpos>cur_open)
exps->pairs[i].openpos+=new_len-cur_len;
if(exps->pairs[i].closepos>cur_close)
exps->pairs[i].closepos+=new_len-cur_len;
if(exps->pairs[i].openpos > cur_open)
exps->pairs[i].openpos += new_len - cur_len;
if(exps->pairs[i].closepos > cur_close)
exps->pairs[i].closepos += new_len - cur_len;
}
}
static bool printlayer(char* exp, EXPRESSION* exps, int layer, bool silent, bool baseonly)
{
for(int i=0; i<exps->total_pairs; i++)
for(int i = 0; i < exps->total_pairs; i++)
{
if(exps->pairs[i].layer==layer)
if(exps->pairs[i].layer == layer)
{
char temp[256]="";
char backup[256]="";
char temp[256] = "";
char backup[256] = "";
int open=exps->pairs[i].openpos;
int close=exps->pairs[i].closepos;
int len=close-open;
strncpy(temp, exp+open+1, len-1);
int open = exps->pairs[i].openpos;
int close = exps->pairs[i].closepos;
int len = close - open;
strncpy(temp, exp + open + 1, len - 1);
strcpy(backup, exp+open+len+1);
strcpy(backup, exp + open + len + 1);
uint value;
if(!mathfromstring(temp, &value, silent, baseonly, 0, 0))
return false;
adjustpairs(exps, open, close, len+1, sprintf(exp+open, "%"fext"X", value));
adjustpairs(exps, open, close, len + 1, sprintf(exp + open, "%"fext"X", value));
if(*backup)
strcat(exp, backup);
@ -330,23 +330,23 @@ static bool printlayer(char* exp, EXPRESSION* exps, int layer, bool silent, bool
bool mathhandlebrackets(char* expression, bool silent, bool baseonly)
{
EXPRESSION expstruct;
expstruct.expression=expression;
int total_pairs=expressionformat(expression);
if(total_pairs==-1)
expstruct.expression = expression;
int total_pairs = expressionformat(expression);
if(total_pairs == -1)
return false;
else if(!total_pairs)
return true;
expstruct.total_pairs=total_pairs;
expstruct.total_pairs = total_pairs;
expstruct.pairs=(BRACKET_PAIR*)emalloc(expstruct.total_pairs*sizeof(BRACKET_PAIR), "mathhandlebrackets:expstruct.pairs");
memset(expstruct.pairs, 0, expstruct.total_pairs*sizeof(BRACKET_PAIR));
expstruct.pairs = (BRACKET_PAIR*)emalloc(expstruct.total_pairs * sizeof(BRACKET_PAIR), "mathhandlebrackets:expstruct.pairs");
memset(expstruct.pairs, 0, expstruct.total_pairs * sizeof(BRACKET_PAIR));
matchpairs(&expstruct, expression, 0);
int deepest=0;
for(int i=0; i<expstruct.total_pairs; i++)
if(expstruct.pairs[i].layer>deepest)
deepest=expstruct.pairs[i].layer;
int deepest = 0;
for(int i = 0; i < expstruct.total_pairs; i++)
if(expstruct.pairs[i].layer > deepest)
deepest = expstruct.pairs[i].layer;
for(int i=deepest; i>0; i--)
for(int i = deepest; i > 0; i--)
if(!printlayer(expression, &expstruct, i, silent, baseonly))
{
efree(expstruct.pairs, "mathhandlebrackets:expstruct.pairs");
@ -362,32 +362,32 @@ bool mathhandlebrackets(char* expression, bool silent, bool baseonly)
*/
bool mathfromstring(const char* string, uint* value, bool silent, bool baseonly, int* value_size, bool* isvar)
{
int highestop=0;
int highestop_pos=0;
int len=(int)strlen(string);
bool negative=false;
if(*string=='-')
int highestop = 0;
int highestop_pos = 0;
int len = (int)strlen(string);
bool negative = false;
if(*string == '-')
{
negative=true;
negative = true;
string++;
}
for(int i=0; i<len; i++)
for(int i = 0; i < len; i++)
{
int curop=mathisoperator(string[i]);
if(curop>1 and curop>highestop)
int curop = mathisoperator(string[i]);
if(curop > 1 and curop > highestop)
{
highestop=curop;
highestop_pos=i;
highestop = curop;
highestop_pos = i;
}
}
if(!highestop)
return valfromstring(string, value, silent, baseonly, value_size, isvar, 0);
char* strleft=(char*)emalloc(len+1+negative, "mathfromstring:strleft");
char* strright=(char*)emalloc(len+1, "mathfromstring:strright");
memset(strleft, 0, len+1);
memset(strright, 0, len+1);
strncpy(strleft, string-negative, highestop_pos+negative);
strcpy(strright, string+highestop_pos+1);
char* strleft = (char*)emalloc(len + 1 + negative, "mathfromstring:strleft");
char* strright = (char*)emalloc(len + 1, "mathfromstring:strright");
memset(strleft, 0, len + 1);
memset(strright, 0, len + 1);
strncpy(strleft, string - negative, highestop_pos + negative);
strcpy(strright, string + highestop_pos + 1);
//dprintf("left: %s, right: %s, op: %c\n", strleft, strright, string[highestop_pos]);
if(!*strright)
{
@ -395,25 +395,25 @@ bool mathfromstring(const char* string, uint* value, bool silent, bool baseonly,
efree(strright, "mathfromstring:strright");
return false;
}
uint right=0;
uint right = 0;
if(!valfromstring(strright, &right, silent, baseonly))
{
efree(strleft, "mathfromstring:strleft");
efree(strright, "mathfromstring:strright");
return false;
}
if(string[highestop_pos]=='~')
if(string[highestop_pos] == '~')
{
right=~right;
right = ~right;
if(!strlen(strleft))
{
*value=right;
*value = right;
efree(strleft, "mathfromstring:strleft");
efree(strright, "mathfromstring:strright");
return true;
}
}
uint left=0;
uint left = 0;
if(!valfromstring(strleft, &left, silent, baseonly))
{
efree(strleft, "mathfromstring:strleft");
@ -422,9 +422,9 @@ bool mathfromstring(const char* string, uint* value, bool silent, bool baseonly,
}
bool math_ok;
if(valuesignedcalc())
math_ok=mathdosignedoperation(string[highestop_pos], left, right, (sint*)value);
math_ok = mathdosignedoperation(string[highestop_pos], left, right, (sint*)value);
else
math_ok=mathdounsignedoperation(string[highestop_pos], left, right, value);
math_ok = mathdounsignedoperation(string[highestop_pos], left, right, value);
efree(strleft, "mathfromstring:strleft");
efree(strright, "mathfromstring:strright");
return math_ok;

View File

@ -11,34 +11,34 @@ void memupdatemap(HANDLE hProcess)
CriticalSectionLocker locker(LockMemoryPages);
MEMORY_BASIC_INFORMATION mbi;
SIZE_T numBytes;
uint MyAddress=0, newAddress=0;
uint curAllocationBase=0;
uint MyAddress = 0, newAddress = 0;
uint curAllocationBase = 0;
bool bListAllPages = false; //TODO: settings for this
std::vector<MEMPAGE> pageVector;
do
{
numBytes=VirtualQueryEx(hProcess, (LPCVOID)MyAddress, &mbi, sizeof(mbi));
if(mbi.State==MEM_COMMIT)
numBytes = VirtualQueryEx(hProcess, (LPCVOID)MyAddress, &mbi, sizeof(mbi));
if(mbi.State == MEM_COMMIT)
{
if(bListAllPages || curAllocationBase!=(uint)mbi.AllocationBase) //only list allocation bases
if(bListAllPages || curAllocationBase != (uint)mbi.AllocationBase) //only list allocation bases
{
curAllocationBase=(uint)mbi.AllocationBase;
curAllocationBase = (uint)mbi.AllocationBase;
MEMPAGE curPage;
*curPage.info=0;
*curPage.info = 0;
modnamefromaddr(MyAddress, curPage.info, true);
memcpy(&curPage.mbi, &mbi, sizeof(mbi));
pageVector.push_back(curPage);
}
else
pageVector.at(pageVector.size()-1).mbi.RegionSize+=mbi.RegionSize;
pageVector.at(pageVector.size() - 1).mbi.RegionSize += mbi.RegionSize;
}
newAddress=(uint)mbi.BaseAddress+mbi.RegionSize;
if(newAddress<=MyAddress)
numBytes=0;
newAddress = (uint)mbi.BaseAddress + mbi.RegionSize;
if(newAddress <= MyAddress)
numBytes = 0;
else
MyAddress=newAddress;
MyAddress = newAddress;
}
while(numBytes);
@ -46,21 +46,21 @@ void memupdatemap(HANDLE hProcess)
int pagecount;
if(bListAllPages)
{
pagecount=(int)pageVector.size();
char curMod[MAX_MODULE_SIZE]="";
for(int i=pagecount-1,curIdx=0; i>-1; i--)
pagecount = (int)pageVector.size();
char curMod[MAX_MODULE_SIZE] = "";
for(int i = pagecount - 1, curIdx = 0; i > -1; i--)
{
if(pageVector.at(i).info[0]) //there is a module
{
if(!scmp(curMod, pageVector.at(i).info)) //mod is not the current mod
{
strcpy(curMod, pageVector.at(i).info);
curIdx=i;
curIdx = i;
}
else //current mod
{
pageVector.at(curIdx).mbi.RegionSize+=pageVector.at(i).mbi.RegionSize;
pageVector.erase(pageVector.begin()+i);
pageVector.at(curIdx).mbi.RegionSize += pageVector.at(i).mbi.RegionSize;
pageVector.erase(pageVector.begin() + i);
curIdx--; //the index changes when you remove an entry
}
}
@ -68,94 +68,94 @@ void memupdatemap(HANDLE hProcess)
}
//process file sections
pagecount=(int)pageVector.size();
char curMod[MAX_MODULE_SIZE]="";
for(int i=pagecount-1; i>-1; i--)
pagecount = (int)pageVector.size();
char curMod[MAX_MODULE_SIZE] = "";
for(int i = pagecount - 1; i > -1; i--)
{
if(bListAllPages || !pageVector.at(i).info[0] || scmp(curMod, pageVector.at(i).info)) //there is a module
continue; //skip non-modules
strcpy(curMod, pageVector.at(i).info);
uint base=modbasefromname(pageVector.at(i).info);
uint base = modbasefromname(pageVector.at(i).info);
if(!base)
continue;
std::vector<MODSECTIONINFO> sections;
if(!modsectionsfromaddr(base, &sections))
continue;
int SectionNumber=(int)sections.size();
int SectionNumber = (int)sections.size();
MEMPAGE newPage;
//remove the current module page (page = size of module at this point) and insert the module sections
pageVector.erase(pageVector.begin()+i); //remove the SizeOfImage page
for(int j=SectionNumber-1; j>-1; j--)
pageVector.erase(pageVector.begin() + i); //remove the SizeOfImage page
for(int j = SectionNumber - 1; j > -1; j--)
{
memset(&newPage, 0, sizeof(MEMPAGE));
VirtualQueryEx(hProcess, (LPCVOID)sections.at(j).addr, &newPage.mbi, sizeof(MEMORY_BASIC_INFORMATION));
uint SectionSize=sections.at(j).size;
if(SectionSize%PAGE_SIZE) //unaligned page size
SectionSize+=PAGE_SIZE-(SectionSize%PAGE_SIZE); //fix this
uint SectionSize = sections.at(j).size;
if(SectionSize % PAGE_SIZE) //unaligned page size
SectionSize += PAGE_SIZE - (SectionSize % PAGE_SIZE); //fix this
if(SectionSize)
newPage.mbi.RegionSize=SectionSize;
const char* SectionName=&sections.at(j).name[0];
int len=(int)strlen(SectionName);
int escape_count=0;
for(int k=0; k<len; k++)
if(SectionName[k]=='\\' or SectionName[k]=='\"' or !isprint(SectionName[k]))
newPage.mbi.RegionSize = SectionSize;
const char* SectionName = &sections.at(j).name[0];
int len = (int)strlen(SectionName);
int escape_count = 0;
for(int k = 0; k < len; k++)
if(SectionName[k] == '\\' or SectionName[k] == '\"' or !isprint(SectionName[k]))
escape_count++;
char* SectionNameEscaped=(char*)emalloc(len+escape_count*3+1, "_dbg_memmap:SectionNameEscaped");
memset(SectionNameEscaped, 0, len+escape_count*3+1);
for(int k=0,l=0; k<len; k++)
char* SectionNameEscaped = (char*)emalloc(len + escape_count * 3 + 1, "_dbg_memmap:SectionNameEscaped");
memset(SectionNameEscaped, 0, len + escape_count * 3 + 1);
for(int k = 0, l = 0; k < len; k++)
{
switch(SectionName[k])
{
case '\t':
l+=sprintf(SectionNameEscaped+l, "\\t");
l += sprintf(SectionNameEscaped + l, "\\t");
break;
case '\f':
l+=sprintf(SectionNameEscaped+l, "\\f");
l += sprintf(SectionNameEscaped + l, "\\f");
break;
case '\v':
l+=sprintf(SectionNameEscaped+l, "\\v");
l += sprintf(SectionNameEscaped + l, "\\v");
break;
case '\n':
l+=sprintf(SectionNameEscaped+l, "\\n");
l += sprintf(SectionNameEscaped + l, "\\n");
break;
case '\r':
l+=sprintf(SectionNameEscaped+l, "\\r");
l += sprintf(SectionNameEscaped + l, "\\r");
break;
case '\\':
l+=sprintf(SectionNameEscaped+l, "\\\\");
l += sprintf(SectionNameEscaped + l, "\\\\");
break;
case '\"':
l+=sprintf(SectionNameEscaped+l, "\\\"");
l += sprintf(SectionNameEscaped + l, "\\\"");
break;
default:
if(!isprint(SectionName[k])) //unknown unprintable character
l+=sprintf(SectionNameEscaped+l, "\\x%.2X", SectionName[k]);
l += sprintf(SectionNameEscaped + l, "\\x%.2X", SectionName[k]);
else
l+=sprintf(SectionNameEscaped+l, "%c", SectionName[k]);
l += sprintf(SectionNameEscaped + l, "%c", SectionName[k]);
break;
}
}
sprintf(newPage.info, " \"%s\"", SectionNameEscaped);
efree(SectionNameEscaped, "_dbg_memmap:SectionNameEscaped");
pageVector.insert(pageVector.begin()+i, newPage);
pageVector.insert(pageVector.begin() + i, newPage);
}
//insert the module itself (the module header)
memset(&newPage, 0, sizeof(MEMPAGE));
VirtualQueryEx(hProcess, (LPCVOID)base, &newPage.mbi, sizeof(MEMORY_BASIC_INFORMATION));
strcpy(newPage.info, curMod);
pageVector.insert(pageVector.begin()+i, newPage);
pageVector.insert(pageVector.begin() + i, newPage);
}
//convert to memoryPages map
pagecount=(int)pageVector.size();
pagecount = (int)pageVector.size();
memoryPages.clear();
for(int i=0; i<pagecount; i++)
for(int i = 0; i < pagecount; i++)
{
const MEMPAGE & curPage = pageVector.at(i);
uint start=(uint)curPage.mbi.BaseAddress;
uint size=curPage.mbi.RegionSize;
memoryPages.insert(std::make_pair(std::make_pair(start, start+size-1), curPage));
uint start = (uint)curPage.mbi.BaseAddress;
uint size = curPage.mbi.RegionSize;
memoryPages.insert(std::make_pair(std::make_pair(start, start + size - 1), curPage));
}
}
@ -164,11 +164,11 @@ uint memfindbaseaddr(uint addr, uint* size, bool refresh)
if(refresh)
memupdatemap(fdProcessInfo->hProcess); //update memory map
CriticalSectionLocker locker(LockMemoryPages);
MemoryMap::iterator found=memoryPages.find(std::make_pair(addr, addr));
if(found==memoryPages.end())
MemoryMap::iterator found = memoryPages.find(std::make_pair(addr, addr));
if(found == memoryPages.end())
return 0;
if(size)
*size=found->second.mbi.RegionSize;
*size = found->second.mbi.RegionSize;
return found->first.first;
}
@ -176,24 +176,24 @@ bool memread(HANDLE hProcess, const void* lpBaseAddress, void* lpBuffer, SIZE_T
{
if(!hProcess or !lpBaseAddress or !lpBuffer or !nSize) //generic failures
return false;
SIZE_T read=0;
DWORD oldprotect=0;
bool ret=MemoryReadSafe(hProcess, (void*)lpBaseAddress, lpBuffer, nSize, &read); //try 'normal' RPM
if(ret and read==nSize) //'normal' RPM worked!
SIZE_T read = 0;
DWORD oldprotect = 0;
bool ret = MemoryReadSafe(hProcess, (void*)lpBaseAddress, lpBuffer, nSize, &read); //try 'normal' RPM
if(ret and read == nSize) //'normal' RPM worked!
{
if(lpNumberOfBytesRead)
*lpNumberOfBytesRead=read;
*lpNumberOfBytesRead = read;
return true;
}
for(uint i=0; i<nSize; i++) //read byte-per-byte
for(uint i = 0; i < nSize; i++) //read byte-per-byte
{
unsigned char* curaddr=(unsigned char*)lpBaseAddress+i;
unsigned char* curbuf=(unsigned char*)lpBuffer+i;
ret=MemoryReadSafe(hProcess, curaddr, curbuf, 1, 0); //try 'normal' RPM
unsigned char* curaddr = (unsigned char*)lpBaseAddress + i;
unsigned char* curbuf = (unsigned char*)lpBuffer + i;
ret = MemoryReadSafe(hProcess, curaddr, curbuf, 1, 0); //try 'normal' RPM
if(!ret) //we failed
{
if(lpNumberOfBytesRead)
*lpNumberOfBytesRead=i;
*lpNumberOfBytesRead = i;
SetLastError(ERROR_PARTIAL_COPY);
return false;
}
@ -205,24 +205,24 @@ bool memwrite(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T
{
if(!hProcess or !lpBaseAddress or !lpBuffer or !nSize) //generic failures
return false;
SIZE_T written=0;
DWORD oldprotect=0;
bool ret=MemoryWriteSafe(hProcess, lpBaseAddress, lpBuffer, nSize, &written);
if(ret and written==nSize) //'normal' WPM worked!
SIZE_T written = 0;
DWORD oldprotect = 0;
bool ret = MemoryWriteSafe(hProcess, lpBaseAddress, lpBuffer, nSize, &written);
if(ret and written == nSize) //'normal' WPM worked!
{
if(lpNumberOfBytesWritten)
*lpNumberOfBytesWritten=written;
*lpNumberOfBytesWritten = written;
return true;
}
for(uint i=0; i<nSize; i++) //write byte-per-byte
for(uint i = 0; i < nSize; i++) //write byte-per-byte
{
unsigned char* curaddr=(unsigned char*)lpBaseAddress+i;
unsigned char* curbuf=(unsigned char*)lpBuffer+i;
ret=MemoryWriteSafe(hProcess, curaddr, curbuf, 1, 0); //try 'normal' WPM
unsigned char* curaddr = (unsigned char*)lpBaseAddress + i;
unsigned char* curbuf = (unsigned char*)lpBuffer + i;
ret = MemoryWriteSafe(hProcess, curaddr, curbuf, 1, 0); //try 'normal' WPM
if(!ret) //we failed
{
if(lpNumberOfBytesWritten)
*lpNumberOfBytesWritten=i;
*lpNumberOfBytesWritten = i;
SetLastError(ERROR_PARTIAL_COPY);
return false;
}
@ -234,28 +234,28 @@ bool mempatch(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T
{
if(!hProcess or !lpBaseAddress or !lpBuffer or !nSize) //generic failures
return false;
unsigned char* olddata=(unsigned char*)emalloc(nSize, "mempatch:olddata");
unsigned char* olddata = (unsigned char*)emalloc(nSize, "mempatch:olddata");
if(!memread(hProcess, lpBaseAddress, olddata, nSize, 0))
{
efree(olddata, "mempatch:olddata");
return memwrite(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten);
}
unsigned char* newdata=(unsigned char*)lpBuffer;
for(uint i=0; i<nSize; i++)
patchset((uint)lpBaseAddress+i, olddata[i], newdata[i]);
unsigned char* newdata = (unsigned char*)lpBuffer;
for(uint i = 0; i < nSize; i++)
patchset((uint)lpBaseAddress + i, olddata[i], newdata[i]);
efree(olddata, "mempatch:olddata");
return memwrite(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten);
}
bool memisvalidreadptr(HANDLE hProcess, uint addr)
{
unsigned char a=0;
unsigned char a = 0;
return memread(hProcess, (void*)addr, &a, 1, 0);
}
void* memalloc(HANDLE hProcess, uint addr, SIZE_T size, DWORD fdProtect)
{
return VirtualAllocEx(hProcess, (void*)addr, size, MEM_RESERVE|MEM_COMMIT, fdProtect);
return VirtualAllocEx(hProcess, (void*)addr, size, MEM_RESERVE | MEM_COMMIT, fdProtect);
}
void memfree(HANDLE hProcess, uint addr)
@ -265,13 +265,13 @@ void memfree(HANDLE hProcess, uint addr)
static int formathexpattern(char* string)
{
int len=(int)strlen(string);
int len = (int)strlen(string);
_strupr(string);
char* new_string=(char*)emalloc(len+1, "formathexpattern:new_string");
memset(new_string, 0, len+1);
for(int i=0,j=0; i<len; i++)
if(string[i]=='?' or isxdigit(string[i]))
j+=sprintf(new_string+j, "%c", string[i]);
char* new_string = (char*)emalloc(len + 1, "formathexpattern:new_string");
memset(new_string, 0, len + 1);
for(int i = 0, j = 0; i < len; i++)
if(string[i] == '?' or isxdigit(string[i]))
j += sprintf(new_string + j, "%c", string[i]);
strcpy(string, new_string);
efree(new_string, "formathexpattern:new_string");
return (int)strlen(string);
@ -282,41 +282,41 @@ static bool patterntransform(const char* text, std::vector<PATTERNBYTE>* pattern
if(!text or !pattern)
return false;
pattern->clear();
int len=(int)strlen(text);
int len = (int)strlen(text);
if(!len)
return false;
char* newtext=(char*)emalloc(len+2, "transformpattern:newtext");
char* newtext = (char*)emalloc(len + 2, "transformpattern:newtext");
strcpy(newtext, text);
len=formathexpattern(newtext);
if(len%2) //not a multiple of 2
len = formathexpattern(newtext);
if(len % 2) //not a multiple of 2
{
newtext[len]='?';
newtext[len+1]='\0';
newtext[len] = '?';
newtext[len + 1] = '\0';
len++;
}
PATTERNBYTE newByte;
for(int i=0,j=0; i<len; i++)
for(int i = 0, j = 0; i < len; i++)
{
if(newtext[i]=='?') //wildcard
if(newtext[i] == '?') //wildcard
{
newByte.n[j].all=true; //match anything
newByte.n[j].n=0;
newByte.n[j].all = true; //match anything
newByte.n[j].n = 0;
j++;
}
else //hex
{
char x[2]="";
*x=newtext[i];
unsigned int val=0;
char x[2] = "";
*x = newtext[i];
unsigned int val = 0;
sscanf(x, "%x", &val);
newByte.n[j].all=false;
newByte.n[j].n=val&0xF;
newByte.n[j].all = false;
newByte.n[j].n = val & 0xF;
j++;
}
if(j==2) //two nibbles = one byte
if(j == 2) //two nibbles = one byte
{
j=0;
j = 0;
pattern->push_back(newByte);
}
}
@ -326,18 +326,18 @@ static bool patterntransform(const char* text, std::vector<PATTERNBYTE>* pattern
static bool patternmatchbyte(unsigned char byte, PATTERNBYTE* pbyte)
{
unsigned char n1=(byte>>4)&0xF;
unsigned char n2=byte&0xF;
int matched=0;
unsigned char n1 = (byte >> 4) & 0xF;
unsigned char n2 = byte & 0xF;
int matched = 0;
if(pbyte->n[0].all)
matched++;
else if(pbyte->n[0].n==n1)
else if(pbyte->n[0].n == n1)
matched++;
if(pbyte->n[1].all)
matched++;
else if(pbyte->n[1].n==n2)
else if(pbyte->n[1].n == n2)
matched++;
return (matched==2);
return (matched == 2);
}
uint memfindpattern(unsigned char* data, uint size, const char* pattern, int* patternsize)
@ -345,21 +345,21 @@ uint memfindpattern(unsigned char* data, uint size, const char* pattern, int* pa
std::vector<PATTERNBYTE> searchpattern;
if(!patterntransform(pattern, &searchpattern))
return -1;
int searchpatternsize=(int)searchpattern.size();
int searchpatternsize = (int)searchpattern.size();
if(patternsize)
*patternsize=searchpatternsize;
for(uint i=0,pos=0; i<size; i++) //search for the pattern
*patternsize = searchpatternsize;
for(uint i = 0, pos = 0; i < size; i++) //search for the pattern
{
if(patternmatchbyte(data[i], &searchpattern.at(pos))) //check if our pattern matches the current byte
{
pos++;
if(pos==searchpatternsize) //everything matched
return i-searchpatternsize+1;
if(pos == searchpatternsize) //everything matched
return i - searchpatternsize + 1;
}
else if (pos>0) //fix by Computer_Angel
else if(pos > 0) //fix by Computer_Angel
{
i-=pos; // return to previous byte
pos=0; //reset current pattern position
i -= pos; // return to previous byte
pos = 0; //reset current pattern position
}
}
return -1;

View File

@ -16,7 +16,7 @@ static void msgfree(MESSAGE* msg)
//allocate a message stack
MESSAGE_STACK* msgallocstack()
{
MESSAGE_STACK* msgstack=(MESSAGE_STACK*)emalloc(sizeof(MESSAGE_STACK), "msgallocstack:msgstack");
MESSAGE_STACK* msgstack = (MESSAGE_STACK*)emalloc(sizeof(MESSAGE_STACK), "msgallocstack:msgstack");
if(!msgstack)
return 0;
memset(msgstack, 0, sizeof(MESSAGE_STACK));
@ -28,8 +28,8 @@ MESSAGE_STACK* msgallocstack()
void msgfreestack(MESSAGE_STACK* msgstack)
{
DeleteCriticalSection(&msgstack->cr);
int stackpos=msgstack->stackpos;
for(int i=0; i<stackpos; i++) //free all messages left in stack
int stackpos = msgstack->stackpos;
for(int i = 0; i < stackpos; i++) //free all messages left in stack
msgfree(msgstack->msg[i]);
efree(msgstack, "msgfreestack:msgstack");
}
@ -37,24 +37,24 @@ void msgfreestack(MESSAGE_STACK* msgstack)
//add a message to the stack
bool msgsend(MESSAGE_STACK* msgstack, int msg, uint param1, uint param2)
{
CRITICAL_SECTION* cr=&msgstack->cr;
CRITICAL_SECTION* cr = &msgstack->cr;
EnterCriticalSection(cr);
int stackpos=msgstack->stackpos;
if(stackpos>=MAX_MESSAGES)
int stackpos = msgstack->stackpos;
if(stackpos >= MAX_MESSAGES)
{
LeaveCriticalSection(cr);
return false;
}
MESSAGE* newmsg=msgalloc();
MESSAGE* newmsg = msgalloc();
if(!newmsg)
{
LeaveCriticalSection(cr);
return false;
}
newmsg->msg=msg;
newmsg->param1=param1;
newmsg->param2=param2;
msgstack->msg[stackpos]=newmsg;
newmsg->msg = msg;
newmsg->param1 = param1;
newmsg->param2 = param2;
msgstack->msg[stackpos] = newmsg;
msgstack->stackpos++; //increase stack pointer
LeaveCriticalSection(cr);
return true;
@ -63,9 +63,9 @@ bool msgsend(MESSAGE_STACK* msgstack, int msg, uint param1, uint param2)
//get a message from the stack (will return false when there are no messages)
bool msgget(MESSAGE_STACK* msgstack, MESSAGE* msg)
{
CRITICAL_SECTION* cr=&msgstack->cr;
CRITICAL_SECTION* cr = &msgstack->cr;
EnterCriticalSection(cr);
int stackpos=msgstack->stackpos;
int stackpos = msgstack->stackpos;
if(!msgstack->stackpos) //no messages to process
{
LeaveCriticalSection(cr);
@ -73,10 +73,10 @@ bool msgget(MESSAGE_STACK* msgstack, MESSAGE* msg)
}
msgstack->stackpos--; //current message is at stackpos-1
stackpos--;
MESSAGE* stackmsg=msgstack->msg[stackpos];
MESSAGE* stackmsg = msgstack->msg[stackpos];
memcpy(msg, stackmsg, sizeof(MESSAGE));
msgfree(stackmsg);
msgstack->msg[stackpos]=0;
msgstack->msg[stackpos] = 0;
LeaveCriticalSection(cr);
return true;
}

View File

@ -31,12 +31,12 @@
#define FORCE_INLINE inline __attribute__((always_inline))
inline uint32_t rotl32 ( uint32_t x, int8_t r )
inline uint32_t rotl32(uint32_t x, int8_t r)
{
return (x << r) | (x >> (32 - r));
}
inline uint64_t rotl64 ( uint64_t x, int8_t r )
inline uint64_t rotl64(uint64_t x, int8_t r)
{
return (x << r) | (x >> (64 - r));
}
@ -52,12 +52,12 @@ inline uint64_t rotl64 ( uint64_t x, int8_t r )
// Block read - if your platform needs to do endian-swapping or can only
// handle aligned reads, do the conversion here
FORCE_INLINE uint32_t getblock32 ( const uint32_t * p, int i )
FORCE_INLINE uint32_t getblock32(const uint32_t* p, int i)
{
return p[i];
}
FORCE_INLINE uint64_t getblock64 ( const uint64_t * p, int i )
FORCE_INLINE uint64_t getblock64(const uint64_t* p, int i)
{
return p[i];
}
@ -65,7 +65,7 @@ FORCE_INLINE uint64_t getblock64 ( const uint64_t * p, int i )
//-----------------------------------------------------------------------------
// Finalization mix - force all bits of a hash block to avalanche
FORCE_INLINE uint32_t fmix32 ( uint32_t h )
FORCE_INLINE uint32_t fmix32(uint32_t h)
{
h ^= h >> 16;
h *= 0x85ebca6b;
@ -78,7 +78,7 @@ FORCE_INLINE uint32_t fmix32 ( uint32_t h )
//----------
FORCE_INLINE uint64_t fmix64 ( uint64_t k )
FORCE_INLINE uint64_t fmix64(uint64_t k)
{
k ^= k >> 33;
k *= BIG_CONSTANT(0xff51afd7ed558ccd);
@ -91,10 +91,10 @@ FORCE_INLINE uint64_t fmix64 ( uint64_t k )
//-----------------------------------------------------------------------------
void MurmurHash3_x86_32 ( const void * key, int len,
uint32_t seed, void * out )
void MurmurHash3_x86_32(const void* key, int len,
uint32_t seed, void* out)
{
const uint8_t * data = (const uint8_t*)key;
const uint8_t* data = (const uint8_t*)key;
const int nblocks = len / 4;
uint32_t h1 = seed;
@ -105,25 +105,25 @@ void MurmurHash3_x86_32 ( const void * key, int len,
//----------
// body
const uint32_t * blocks = (const uint32_t *)(data + nblocks*4);
const uint32_t* blocks = (const uint32_t*)(data + nblocks * 4);
for(int i = -nblocks; i; i++)
{
uint32_t k1 = getblock32(blocks,i);
uint32_t k1 = getblock32(blocks, i);
k1 *= c1;
k1 = ROTL32(k1,15);
k1 = ROTL32(k1, 15);
k1 *= c2;
h1 ^= k1;
h1 = ROTL32(h1,13);
h1 = h1*5+0xe6546b64;
h1 = ROTL32(h1, 13);
h1 = h1 * 5 + 0xe6546b64;
}
//----------
// tail
const uint8_t * tail = (const uint8_t*)(data + nblocks*4);
const uint8_t* tail = (const uint8_t*)(data + nblocks * 4);
uint32_t k1 = 0;
@ -136,7 +136,7 @@ void MurmurHash3_x86_32 ( const void * key, int len,
case 1:
k1 ^= tail[0];
k1 *= c1;
k1 = ROTL32(k1,15);
k1 = ROTL32(k1, 15);
k1 *= c2;
h1 ^= k1;
};
@ -153,10 +153,10 @@ void MurmurHash3_x86_32 ( const void * key, int len,
//-----------------------------------------------------------------------------
void MurmurHash3_x86_128 ( const void * key, const int len,
uint32_t seed, void * out )
void MurmurHash3_x86_128(const void* key, const int len,
uint32_t seed, void* out)
{
const uint8_t * data = (const uint8_t*)key;
const uint8_t* data = (const uint8_t*)key;
const int nblocks = len / 16;
uint32_t h1 = seed;
@ -172,56 +172,56 @@ void MurmurHash3_x86_128 ( const void * key, const int len,
//----------
// body
const uint32_t * blocks = (const uint32_t *)(data + nblocks*16);
const uint32_t* blocks = (const uint32_t*)(data + nblocks * 16);
for(int i = -nblocks; i; i++)
{
uint32_t k1 = getblock32(blocks,i*4+0);
uint32_t k2 = getblock32(blocks,i*4+1);
uint32_t k3 = getblock32(blocks,i*4+2);
uint32_t k4 = getblock32(blocks,i*4+3);
uint32_t k1 = getblock32(blocks, i * 4 + 0);
uint32_t k2 = getblock32(blocks, i * 4 + 1);
uint32_t k3 = getblock32(blocks, i * 4 + 2);
uint32_t k4 = getblock32(blocks, i * 4 + 3);
k1 *= c1;
k1 = ROTL32(k1,15);
k1 = ROTL32(k1, 15);
k1 *= c2;
h1 ^= k1;
h1 = ROTL32(h1,19);
h1 = ROTL32(h1, 19);
h1 += h2;
h1 = h1*5+0x561ccd1b;
h1 = h1 * 5 + 0x561ccd1b;
k2 *= c2;
k2 = ROTL32(k2,16);
k2 = ROTL32(k2, 16);
k2 *= c3;
h2 ^= k2;
h2 = ROTL32(h2,17);
h2 = ROTL32(h2, 17);
h2 += h3;
h2 = h2*5+0x0bcaa747;
h2 = h2 * 5 + 0x0bcaa747;
k3 *= c3;
k3 = ROTL32(k3,17);
k3 = ROTL32(k3, 17);
k3 *= c4;
h3 ^= k3;
h3 = ROTL32(h3,15);
h3 = ROTL32(h3, 15);
h3 += h4;
h3 = h3*5+0x96cd1c35;
h3 = h3 * 5 + 0x96cd1c35;
k4 *= c4;
k4 = ROTL32(k4,18);
k4 = ROTL32(k4, 18);
k4 *= c1;
h4 ^= k4;
h4 = ROTL32(h4,13);
h4 = ROTL32(h4, 13);
h4 += h1;
h4 = h4*5+0x32ac3b17;
h4 = h4 * 5 + 0x32ac3b17;
}
//----------
// tail
const uint8_t * tail = (const uint8_t*)(data + nblocks*16);
const uint8_t* tail = (const uint8_t*)(data + nblocks * 16);
uint32_t k1 = 0;
uint32_t k2 = 0;
@ -237,7 +237,7 @@ void MurmurHash3_x86_128 ( const void * key, const int len,
case 13:
k4 ^= tail[12] << 0;
k4 *= c4;
k4 = ROTL32(k4,18);
k4 = ROTL32(k4, 18);
k4 *= c1;
h4 ^= k4;
@ -250,7 +250,7 @@ void MurmurHash3_x86_128 ( const void * key, const int len,
case 9:
k3 ^= tail[ 8] << 0;
k3 *= c3;
k3 = ROTL32(k3,17);
k3 = ROTL32(k3, 17);
k3 *= c4;
h3 ^= k3;
@ -263,7 +263,7 @@ void MurmurHash3_x86_128 ( const void * key, const int len,
case 5:
k2 ^= tail[ 4] << 0;
k2 *= c2;
k2 = ROTL32(k2,16);
k2 = ROTL32(k2, 16);
k2 *= c3;
h2 ^= k2;
@ -276,7 +276,7 @@ void MurmurHash3_x86_128 ( const void * key, const int len,
case 1:
k1 ^= tail[ 0] << 0;
k1 *= c1;
k1 = ROTL32(k1,15);
k1 = ROTL32(k1, 15);
k1 *= c2;
h1 ^= k1;
};
@ -316,10 +316,10 @@ void MurmurHash3_x86_128 ( const void * key, const int len,
//-----------------------------------------------------------------------------
void MurmurHash3_x64_128 ( const void * key, const int len,
const uint32_t seed, void * out )
void MurmurHash3_x64_128(const void* key, const int len,
const uint32_t seed, void* out)
{
const uint8_t * data = (const uint8_t*)key;
const uint8_t* data = (const uint8_t*)key;
const int nblocks = len / 16;
uint64_t h1 = seed;
@ -331,36 +331,36 @@ void MurmurHash3_x64_128 ( const void * key, const int len,
//----------
// body
const uint64_t * blocks = (const uint64_t *)(data);
const uint64_t* blocks = (const uint64_t*)(data);
for(int i = 0; i < nblocks; i++)
{
uint64_t k1 = getblock64(blocks,i*2+0);
uint64_t k2 = getblock64(blocks,i*2+1);
uint64_t k1 = getblock64(blocks, i * 2 + 0);
uint64_t k2 = getblock64(blocks, i * 2 + 1);
k1 *= c1;
k1 = ROTL64(k1,31);
k1 = ROTL64(k1, 31);
k1 *= c2;
h1 ^= k1;
h1 = ROTL64(h1,27);
h1 = ROTL64(h1, 27);
h1 += h2;
h1 = h1*5+0x52dce729;
h1 = h1 * 5 + 0x52dce729;
k2 *= c2;
k2 = ROTL64(k2,33);
k2 = ROTL64(k2, 33);
k2 *= c1;
h2 ^= k2;
h2 = ROTL64(h2,31);
h2 = ROTL64(h2, 31);
h2 += h1;
h2 = h2*5+0x38495ab5;
h2 = h2 * 5 + 0x38495ab5;
}
//----------
// tail
const uint8_t * tail = (const uint8_t*)(data + nblocks*16);
const uint8_t* tail = (const uint8_t*)(data + nblocks * 16);
uint64_t k1 = 0;
uint64_t k2 = 0;
@ -382,7 +382,7 @@ void MurmurHash3_x64_128 ( const void * key, const int len,
case 9:
k2 ^= ((uint64_t)tail[ 8]) << 0;
k2 *= c2;
k2 = ROTL64(k2,33);
k2 = ROTL64(k2, 33);
k2 *= c1;
h2 ^= k2;
@ -403,7 +403,7 @@ void MurmurHash3_x64_128 ( const void * key, const int len,
case 1:
k1 ^= ((uint64_t)tail[ 0]) << 0;
k1 *= c1;
k1 = ROTL64(k1,31);
k1 = ROTL64(k1, 31);
k1 *= c2;
h1 ^= k1;
};

View File

@ -26,11 +26,11 @@ typedef unsigned __int64 uint64_t;
//-----------------------------------------------------------------------------
void MurmurHash3_x86_32 ( const void * key, int len, uint32_t seed, void * out );
void MurmurHash3_x86_32(const void* key, int len, uint32_t seed, void* out);
void MurmurHash3_x86_128 ( const void * key, int len, uint32_t seed, void * out );
void MurmurHash3_x86_128(const void* key, int len, uint32_t seed, void* out);
void MurmurHash3_x64_128 ( const void * key, int len, uint32_t seed, void * out );
void MurmurHash3_x64_128(const void* key, int len, uint32_t seed, void* out);
//-----------------------------------------------------------------------------

View File

@ -10,16 +10,16 @@ bool patchset(uint addr, unsigned char oldbyte, unsigned char newbyte)
{
if(!DbgIsDebugging() || !memisvalidreadptr(fdProcessInfo->hProcess, addr))
return false;
if(oldbyte==newbyte)
if(oldbyte == newbyte)
return true; //no need to make a patch for a byte that is equal to itself
PATCHINFO newPatch;
newPatch.addr=addr-modbasefromaddr(addr);
newPatch.addr = addr - modbasefromaddr(addr);
modnamefromaddr(addr, newPatch.mod, true);
newPatch.oldbyte=oldbyte;
newPatch.newbyte=newbyte;
uint key=modhashfromva(addr);
PatchesInfo::iterator found=patches.find(key);
if(found!=patches.end()) //we found a patch on the specified address
newPatch.oldbyte = oldbyte;
newPatch.newbyte = newbyte;
uint key = modhashfromva(addr);
PatchesInfo::iterator found = patches.find(key);
if(found != patches.end()) //we found a patch on the specified address
{
if(found->second.oldbyte == newbyte) //patch is undone
{
@ -28,8 +28,8 @@ bool patchset(uint addr, unsigned char oldbyte, unsigned char newbyte)
}
else
{
newPatch.oldbyte=found->second.oldbyte; //keep the original byte from the previous patch
found->second=newPatch;
newPatch.oldbyte = found->second.oldbyte; //keep the original byte from the previous patch
found->second = newPatch;
}
}
else
@ -41,13 +41,13 @@ bool patchget(uint addr, PATCHINFO* patch)
{
if(!DbgIsDebugging())
return false;
PatchesInfo::iterator found=patches.find(modhashfromva(addr));
if(found==patches.end()) //not found
PatchesInfo::iterator found = patches.find(modhashfromva(addr));
if(found == patches.end()) //not found
return false;
if(patch)
{
*patch=found->second;
patch->addr+=modbasefromaddr(addr);
*patch = found->second;
patch->addr += modbasefromaddr(addr);
return true;
}
return (found->second.oldbyte != found->second.newbyte);
@ -57,11 +57,11 @@ bool patchdel(uint addr, bool restore)
{
if(!DbgIsDebugging())
return false;
PatchesInfo::iterator found=patches.find(modhashfromva(addr));
if(found==patches.end()) //not found
PatchesInfo::iterator found = patches.find(modhashfromva(addr));
if(found == patches.end()) //not found
return false;
if(restore)
memwrite(fdProcessInfo->hProcess, (void*)(found->second.addr+modbasefromaddr(addr)), &found->second.oldbyte, sizeof(char), 0);
memwrite(fdProcessInfo->hProcess, (void*)(found->second.addr + modbasefromaddr(addr)), &found->second.oldbyte, sizeof(char), 0);
patches.erase(found);
return true;
}
@ -70,19 +70,19 @@ void patchdelrange(uint start, uint end, bool restore)
{
if(!DbgIsDebugging())
return;
bool bDelAll=(start==0 && end==~0); //0x00000000-0xFFFFFFFF
uint modbase=modbasefromaddr(start);
if(modbase!=modbasefromaddr(end))
bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF
uint modbase = modbasefromaddr(start);
if(modbase != modbasefromaddr(end))
return;
start-=modbase;
end-=modbase;
PatchesInfo::iterator i=patches.begin();
while(i!=patches.end())
start -= modbase;
end -= modbase;
PatchesInfo::iterator i = patches.begin();
while(i != patches.end())
{
if(bDelAll || (i->second.addr>=start && i->second.addr<end))
if(bDelAll || (i->second.addr >= start && i->second.addr < end))
{
if(restore)
memwrite(fdProcessInfo->hProcess, (void*)(i->second.addr+modbase), &i->second.oldbyte, sizeof(char), 0);
memwrite(fdProcessInfo->hProcess, (void*)(i->second.addr + modbase), &i->second.oldbyte, sizeof(char), 0);
patches.erase(i++);
}
else
@ -96,8 +96,8 @@ void patchclear(const char* mod)
patches.clear();
else
{
PatchesInfo::iterator i=patches.begin();
while(i!=patches.end())
PatchesInfo::iterator i = patches.begin();
while(i != patches.end())
{
if(!_stricmp(i->second.mod, mod))
patches.erase(i++);
@ -115,15 +115,15 @@ bool patchenum(PATCHINFO* patcheslist, size_t* cbsize)
return false;
if(!patcheslist && cbsize)
{
*cbsize=patches.size()*sizeof(LOOPSINFO);
*cbsize = patches.size() * sizeof(LOOPSINFO);
return true;
}
int j=0;
for(PatchesInfo::iterator i=patches.begin(); i!=patches.end(); ++i,j++)
int j = 0;
for(PatchesInfo::iterator i = patches.begin(); i != patches.end(); ++i, j++)
{
patcheslist[j]=i->second;
uint modbase=modbasefromname(patcheslist[j].mod);
patcheslist[j].addr+=modbase;
patcheslist[j] = i->second;
uint modbase = modbasefromname(patcheslist[j].mod);
patcheslist[j].addr += modbase;
}
return true;
}
@ -136,24 +136,24 @@ int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, cha
strcpy(error, "no patches to apply");
return -1;
}
char modname[MAX_MODULE_SIZE]="";
char modname[MAX_MODULE_SIZE] = "";
strcpy(modname, patchlist[0].mod);
//check if all patches are in the same module
for(int i=0; i<count; i++)
for(int i = 0; i < count; i++)
if(_stricmp(patchlist[i].mod, modname))
{
if(error)
sprintf(error, "not all patches are in module %s", modname);
return -1;
}
uint modbase=modbasefromname(modname);
uint modbase = modbasefromname(modname);
if(!modbase) //module not loaded
{
if(error)
sprintf(error, "failed to get base of module %s", modname);
return -1;
}
char szOriginalName[MAX_PATH]="";
char szOriginalName[MAX_PATH] = "";
if(!GetModuleFileNameExA(fdProcessInfo->hProcess, (HMODULE)modbase, szOriginalName, MAX_PATH))
{
if(error)
@ -172,14 +172,14 @@ int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, cha
ULONG_PTR FileMapVA;
if(StaticFileLoad((char*)szFileName, UE_ACCESS_ALL, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA))
{
int patched=0;
for(int i=0; i<count; i++)
int patched = 0;
for(int i = 0; i < count; i++)
{
unsigned char* ptr = (unsigned char*)ConvertVAtoFileOffsetEx(FileMapVA, LoadedSize, modbase, patchlist[i].addr, false, true);
if(!ptr) //skip patches that do not have a raw address
continue;
dprintf("patch%.4d|%s[%.8X]:%.2X/%.2X->%.2X\n", i+1, modname, ptr-FileMapVA, *ptr, patchlist[i].oldbyte, patchlist[i].newbyte);
*ptr=patchlist[i].newbyte;
dprintf("patch%.4d|%s[%.8X]:%.2X/%.2X->%.2X\n", i + 1, modname, ptr - FileMapVA, *ptr, patchlist[i].oldbyte, patchlist[i].newbyte);
*ptr = patchlist[i].newbyte;
patched++;
}
if(!StaticFileUnload((char*)szFileName, true, FileHandle, LoadedSize, FileMap, FileMapVA))

View File

@ -4,7 +4,7 @@
#include "x64_dbg.h"
static std::vector<PLUG_DATA> pluginList;
static int curPluginHandle=0;
static int curPluginHandle = 0;
static std::vector<PLUG_CALLBACK> pluginCallbackList;
static std::vector<PLUG_COMMAND> pluginCommandList;
static std::vector<PLUG_MENU> pluginMenuList;
@ -13,18 +13,18 @@ static std::vector<PLUG_MENU> pluginMenuList;
void pluginload(const char* pluginDir)
{
//load new plugins
char currentDir[deflen]="";
char currentDir[deflen] = "";
GetCurrentDirectoryA(deflen, currentDir);
SetCurrentDirectoryA(pluginDir);
char searchName[deflen]="";
char searchName[deflen] = "";
#ifdef _WIN64
sprintf(searchName, "%s\\*.dp64", pluginDir);
#else
sprintf(searchName, "%s\\*.dp32", pluginDir);
#endif // _WIN64
WIN32_FIND_DATA foundData;
HANDLE hSearch=FindFirstFileA(searchName, &foundData);
if(hSearch==INVALID_HANDLE_VALUE)
HANDLE hSearch = FindFirstFileA(searchName, &foundData);
if(hSearch == INVALID_HANDLE_VALUE)
{
SetCurrentDirectoryA(currentDir);
return;
@ -33,27 +33,27 @@ void pluginload(const char* pluginDir)
do
{
//set plugin data
pluginData.initStruct.pluginHandle=curPluginHandle;
char szPluginPath[MAX_PATH]="";
pluginData.initStruct.pluginHandle = curPluginHandle;
char szPluginPath[MAX_PATH] = "";
sprintf(szPluginPath, "%s\\%s", pluginDir, foundData.cFileName);
pluginData.hPlugin=LoadLibraryA(szPluginPath); //load the plugin library
pluginData.hPlugin = LoadLibraryA(szPluginPath); //load the plugin library
if(!pluginData.hPlugin)
{
dprintf("[PLUGIN] Failed to load plugin: %s\n", foundData.cFileName);
continue;
}
pluginData.pluginit=(PLUGINIT)GetProcAddress(pluginData.hPlugin, "pluginit");
pluginData.pluginit = (PLUGINIT)GetProcAddress(pluginData.hPlugin, "pluginit");
if(!pluginData.pluginit)
{
dprintf("[PLUGIN] Export \"pluginit\" not found in plugin: %s\n", foundData.cFileName);
FreeLibrary(pluginData.hPlugin);
continue;
}
pluginData.plugstop=(PLUGSTOP)GetProcAddress(pluginData.hPlugin, "plugstop");
pluginData.plugsetup=(PLUGSETUP)GetProcAddress(pluginData.hPlugin, "plugsetup");
pluginData.plugstop = (PLUGSTOP)GetProcAddress(pluginData.hPlugin, "plugstop");
pluginData.plugsetup = (PLUGSETUP)GetProcAddress(pluginData.hPlugin, "plugsetup");
//auto-register callbacks for certain export names
CBPLUGIN cbPlugin;
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBALLEVENTS");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBALLEVENTS");
if(cbPlugin)
{
pluginregistercallback(curPluginHandle, CB_INITDEBUG, cbPlugin);
@ -78,67 +78,67 @@ void pluginload(const char* pluginDir)
pluginregistercallback(curPluginHandle, CB_WINEVENT, cbPlugin);
pluginregistercallback(curPluginHandle, CB_WINEVENTGLOBAL, cbPlugin);
}
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBINITDEBUG");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBINITDEBUG");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_INITDEBUG, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBSTOPDEBUG");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBSTOPDEBUG");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_STOPDEBUG, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBCREATEPROCESS");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBCREATEPROCESS");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_CREATEPROCESS, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBEXITPROCESS");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBEXITPROCESS");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_EXITPROCESS, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBCREATETHREAD");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBCREATETHREAD");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_CREATETHREAD, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBEXITTHREAD");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBEXITTHREAD");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_EXITTHREAD, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBSYSTEMBREAKPOINT");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBSYSTEMBREAKPOINT");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_SYSTEMBREAKPOINT, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBLOADDLL");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBLOADDLL");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_LOADDLL, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBUNLOADDLL");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBUNLOADDLL");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_UNLOADDLL, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBOUTPUTDEBUGSTRING");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBOUTPUTDEBUGSTRING");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_OUTPUTDEBUGSTRING, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBEXCEPTION");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBEXCEPTION");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_EXCEPTION, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBBREAKPOINT");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBBREAKPOINT");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_BREAKPOINT, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBPAUSEDEBUG");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBPAUSEDEBUG");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_PAUSEDEBUG, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBRESUMEDEBUG");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBRESUMEDEBUG");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_RESUMEDEBUG, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBSTEPPED");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBSTEPPED");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_STEPPED, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBATTACH");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBATTACH");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_ATTACH, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBDETACH");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBDETACH");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_DETACH, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBDEBUGEVENT");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBDEBUGEVENT");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_DEBUGEVENT, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBMENUENTRY");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBMENUENTRY");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_MENUENTRY, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBWINEVENT");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBWINEVENT");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_WINEVENT, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBWINEVENTGLOBAL");
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBWINEVENTGLOBAL");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_WINEVENTGLOBAL, cbPlugin);
//init plugin
@ -158,28 +158,28 @@ void pluginload(const char* pluginDir)
else
dprintf("[PLUGIN] %s v%d Loaded!\n", pluginData.initStruct.pluginName, pluginData.initStruct.pluginVersion);
//add plugin menu
int hNewMenu=GuiMenuAdd(GUI_PLUGIN_MENU, pluginData.initStruct.pluginName);
if(hNewMenu==-1)
int hNewMenu = GuiMenuAdd(GUI_PLUGIN_MENU, pluginData.initStruct.pluginName);
if(hNewMenu == -1)
{
dprintf("[PLUGIN] GuiMenuAdd failed for plugin: %s\n", pluginData.initStruct.pluginName);
pluginData.hMenu=-1;
pluginData.hMenu = -1;
}
else
{
PLUG_MENU newMenu;
newMenu.hEntryMenu=hNewMenu;
newMenu.hEntryPlugin=-1;
newMenu.pluginHandle=pluginData.initStruct.pluginHandle;
newMenu.hEntryMenu = hNewMenu;
newMenu.hEntryPlugin = -1;
newMenu.pluginHandle = pluginData.initStruct.pluginHandle;
pluginMenuList.push_back(newMenu);
pluginData.hMenu=hNewMenu;
pluginData.hMenu = hNewMenu;
}
pluginList.push_back(pluginData);
//setup plugin
if(pluginData.plugsetup)
{
PLUG_SETUPSTRUCT setupStruct;
setupStruct.hwndDlg=GuiGetWindowHandle();
setupStruct.hMenu=hNewMenu;
setupStruct.hwndDlg = GuiGetWindowHandle();
setupStruct.hMenu = hNewMenu;
pluginData.plugsetup(&setupStruct);
}
curPluginHandle++;
@ -190,23 +190,23 @@ void pluginload(const char* pluginDir)
static void plugincmdunregisterall(int pluginHandle)
{
int listsize=(int)pluginCommandList.size();
for(int i=listsize-1; i>=0; i--)
int listsize = (int)pluginCommandList.size();
for(int i = listsize - 1; i >= 0; i--)
{
if(pluginCommandList.at(i).pluginHandle==pluginHandle)
if(pluginCommandList.at(i).pluginHandle == pluginHandle)
{
dbgcmddel(pluginCommandList.at(i).command);
pluginCommandList.erase(pluginCommandList.begin()+i);
pluginCommandList.erase(pluginCommandList.begin() + i);
}
}
}
void pluginunload()
{
int pluginCount=(int)pluginList.size();
for(int i=0; i<pluginCount; i++)
int pluginCount = (int)pluginList.size();
for(int i = 0; i < pluginCount; i++)
{
PLUGSTOP stop=pluginList.at(i).plugstop;
PLUGSTOP stop = pluginList.at(i).plugstop;
if(stop)
stop();
plugincmdunregisterall(pluginList.at(i).initStruct.pluginHandle);
@ -222,20 +222,20 @@ void pluginregistercallback(int pluginHandle, CBTYPE cbType, CBPLUGIN cbPlugin)
{
pluginunregistercallback(pluginHandle, cbType); //remove previous callback
PLUG_CALLBACK cbStruct;
cbStruct.pluginHandle=pluginHandle;
cbStruct.cbType=cbType;
cbStruct.cbPlugin=cbPlugin;
cbStruct.pluginHandle = pluginHandle;
cbStruct.cbType = cbType;
cbStruct.cbPlugin = cbPlugin;
pluginCallbackList.push_back(cbStruct);
}
bool pluginunregistercallback(int pluginHandle, CBTYPE cbType)
{
int pluginCallbackCount=(int)pluginCallbackList.size();
for(int i=0; i<pluginCallbackCount; i++)
int pluginCallbackCount = (int)pluginCallbackList.size();
for(int i = 0; i < pluginCallbackCount; i++)
{
if(pluginCallbackList.at(i).pluginHandle==pluginHandle and pluginCallbackList.at(i).cbType==cbType)
if(pluginCallbackList.at(i).pluginHandle == pluginHandle and pluginCallbackList.at(i).cbType == cbType)
{
pluginCallbackList.erase(pluginCallbackList.begin()+i);
pluginCallbackList.erase(pluginCallbackList.begin() + i);
return true;
}
}
@ -244,10 +244,10 @@ bool pluginunregistercallback(int pluginHandle, CBTYPE cbType)
void plugincbcall(CBTYPE cbType, void* callbackInfo)
{
int pluginCallbackCount=(int)pluginCallbackList.size();
for(int i=0; i<pluginCallbackCount; i++)
int pluginCallbackCount = (int)pluginCallbackList.size();
for(int i = 0; i < pluginCallbackCount; i++)
{
if(pluginCallbackList.at(i).cbType==cbType)
if(pluginCallbackList.at(i).cbType == cbType)
{
//TODO: handle exceptions
pluginCallbackList.at(i).cbPlugin(cbType, callbackInfo);
@ -257,10 +257,10 @@ void plugincbcall(CBTYPE cbType, void* callbackInfo)
bool plugincmdregister(int pluginHandle, const char* command, CBPLUGINCOMMAND cbCommand, bool debugonly)
{
if(!command or strlen(command)>=deflen or strstr(command, "\1"))
if(!command or strlen(command) >= deflen or strstr(command, "\1"))
return false;
PLUG_COMMAND plugCmd;
plugCmd.pluginHandle=pluginHandle;
plugCmd.pluginHandle = pluginHandle;
strcpy(plugCmd.command, command);
if(!dbgcmdnew(command, (CBCOMMAND)cbCommand, debugonly))
return false;
@ -271,16 +271,16 @@ bool plugincmdregister(int pluginHandle, const char* command, CBPLUGINCOMMAND cb
bool plugincmdunregister(int pluginHandle, const char* command)
{
if(!command or strlen(command)>=deflen or strstr(command, "\1"))
if(!command or strlen(command) >= deflen or strstr(command, "\1"))
return false;
int listsize=(int)pluginCommandList.size();
for(int i=0; i<listsize; i++)
int listsize = (int)pluginCommandList.size();
for(int i = 0; i < listsize; i++)
{
if(pluginCommandList.at(i).pluginHandle==pluginHandle and !strcmp(pluginCommandList.at(i).command, command))
if(pluginCommandList.at(i).pluginHandle == pluginHandle and !strcmp(pluginCommandList.at(i).command, command))
{
if(!dbgcmddel(command))
return false;
pluginCommandList.erase(pluginCommandList.begin()+i);
pluginCommandList.erase(pluginCommandList.begin() + i);
dprintf("[PLUGIN] command \"%s\" unregistered!\n", command);
return true;
}
@ -292,65 +292,65 @@ int pluginmenuadd(int hMenu, const char* title)
{
if(!title or !strlen(title))
return -1;
int nFound=-1;
for(unsigned int i=0; i<pluginMenuList.size(); i++)
int nFound = -1;
for(unsigned int i = 0; i < pluginMenuList.size(); i++)
{
if(pluginMenuList.at(i).hEntryMenu==hMenu and pluginMenuList.at(i).hEntryPlugin==-1)
if(pluginMenuList.at(i).hEntryMenu == hMenu and pluginMenuList.at(i).hEntryPlugin == -1)
{
nFound=i;
nFound = i;
break;
}
}
if(nFound==-1) //not a valid menu handle
if(nFound == -1) //not a valid menu handle
return -1;
int hMenuNew=GuiMenuAdd(pluginMenuList.at(nFound).hEntryMenu, title);
int hMenuNew = GuiMenuAdd(pluginMenuList.at(nFound).hEntryMenu, title);
PLUG_MENU newMenu;
newMenu.pluginHandle=pluginMenuList.at(nFound).pluginHandle;
newMenu.hEntryPlugin=-1;
newMenu.hEntryMenu=hMenuNew;
newMenu.pluginHandle = pluginMenuList.at(nFound).pluginHandle;
newMenu.hEntryPlugin = -1;
newMenu.hEntryMenu = hMenuNew;
pluginMenuList.push_back(newMenu);
return hMenuNew;
}
bool pluginmenuaddentry(int hMenu, int hEntry, const char* title)
{
if(!title or !strlen(title) or hEntry==-1)
if(!title or !strlen(title) or hEntry == -1)
return false;
int pluginHandle=-1;
int pluginHandle = -1;
//find plugin handle
for(unsigned int i=0; i<pluginMenuList.size(); i++)
for(unsigned int i = 0; i < pluginMenuList.size(); i++)
{
if(pluginMenuList.at(i).hEntryMenu==hMenu and pluginMenuList.at(i).hEntryPlugin==-1)
if(pluginMenuList.at(i).hEntryMenu == hMenu and pluginMenuList.at(i).hEntryPlugin == -1)
{
pluginHandle=pluginMenuList.at(i).pluginHandle;
pluginHandle = pluginMenuList.at(i).pluginHandle;
break;
}
}
if(pluginHandle==-1) //not found
if(pluginHandle == -1) //not found
return false;
//search if hEntry was previously used
for(unsigned int i=0; i<pluginMenuList.size(); i++)
if(pluginMenuList.at(i).pluginHandle==pluginHandle && pluginMenuList.at(i).hEntryPlugin==hEntry)
for(unsigned int i = 0; i < pluginMenuList.size(); i++)
if(pluginMenuList.at(i).pluginHandle == pluginHandle && pluginMenuList.at(i).hEntryPlugin == hEntry)
return false;
int hNewEntry=GuiMenuAddEntry(hMenu, title);
if(hNewEntry==-1)
int hNewEntry = GuiMenuAddEntry(hMenu, title);
if(hNewEntry == -1)
return false;
PLUG_MENU newMenu;
newMenu.hEntryMenu=hNewEntry;
newMenu.hEntryPlugin=hEntry;
newMenu.pluginHandle=pluginHandle;
newMenu.hEntryMenu = hNewEntry;
newMenu.hEntryPlugin = hEntry;
newMenu.pluginHandle = pluginHandle;
pluginMenuList.push_back(newMenu);
return true;
}
bool pluginmenuaddseparator(int hMenu)
{
bool bFound=false;
for(unsigned int i=0; i<pluginMenuList.size(); i++)
bool bFound = false;
for(unsigned int i = 0; i < pluginMenuList.size(); i++)
{
if(pluginMenuList.at(i).hEntryMenu==hMenu and pluginMenuList.at(i).hEntryPlugin==-1)
if(pluginMenuList.at(i).hEntryMenu == hMenu and pluginMenuList.at(i).hEntryPlugin == -1)
{
bFound=true;
bFound = true;
break;
}
}
@ -362,12 +362,12 @@ bool pluginmenuaddseparator(int hMenu)
bool pluginmenuclear(int hMenu)
{
bool bFound=false;
for(unsigned int i=0; i<pluginMenuList.size(); i++)
bool bFound = false;
for(unsigned int i = 0; i < pluginMenuList.size(); i++)
{
if(pluginMenuList.at(i).hEntryMenu==hMenu and pluginMenuList.at(i).hEntryPlugin==-1)
if(pluginMenuList.at(i).hEntryMenu == hMenu and pluginMenuList.at(i).hEntryPlugin == -1)
{
bFound=true;
bFound = true;
break;
}
}
@ -379,19 +379,19 @@ bool pluginmenuclear(int hMenu)
void pluginmenucall(int hEntry)
{
if(hEntry==-1)
if(hEntry == -1)
return;
for(unsigned int i=0; i<pluginMenuList.size(); i++)
for(unsigned int i = 0; i < pluginMenuList.size(); i++)
{
if(pluginMenuList.at(i).hEntryMenu==hEntry && pluginMenuList.at(i).hEntryPlugin!=-1)
if(pluginMenuList.at(i).hEntryMenu == hEntry && pluginMenuList.at(i).hEntryPlugin != -1)
{
PLUG_CB_MENUENTRY menuEntryInfo;
menuEntryInfo.hEntry=pluginMenuList.at(i).hEntryPlugin;
int pluginCallbackCount=(int)pluginCallbackList.size();
int pluginHandle=pluginMenuList.at(i).pluginHandle;
for(int j=0; j<pluginCallbackCount; j++)
menuEntryInfo.hEntry = pluginMenuList.at(i).hEntryPlugin;
int pluginCallbackCount = (int)pluginCallbackList.size();
int pluginHandle = pluginMenuList.at(i).pluginHandle;
for(int j = 0; j < pluginCallbackCount; j++)
{
if(pluginCallbackList.at(j).pluginHandle==pluginHandle and pluginCallbackList.at(j).cbType==CB_MENUENTRY)
if(pluginCallbackList.at(j).pluginHandle == pluginHandle and pluginCallbackList.at(j).cbType == CB_MENUENTRY)
{
//TODO: handle exceptions
pluginCallbackList.at(j).cbPlugin(CB_MENUENTRY, &menuEntryInfo);
@ -405,9 +405,9 @@ void pluginmenucall(int hEntry)
bool pluginwinevent(MSG* message, long* result)
{
PLUG_CB_WINEVENT winevent;
winevent.message=message;
winevent.result=result;
winevent.retval=false;
winevent.message = message;
winevent.result = result;
winevent.retval = false;
plugincbcall(CB_WINEVENT, &winevent);
return winevent.retval;
}
@ -415,8 +415,8 @@ bool pluginwinevent(MSG* message, long* result)
bool pluginwineventglobal(MSG* message)
{
PLUG_CB_WINEVENTGLOBAL winevent;
winevent.message=message;
winevent.retval=false;
winevent.message = message;
winevent.retval = false;
plugincbcall(CB_WINEVENTGLOBAL, &winevent);
return winevent.retval;
}

View File

@ -9,7 +9,7 @@ int reffind(uint addr, uint size, CBREF cbRef, void* userinfo, bool silent)
uint start_size;
uint base;
uint base_size;
base=memfindbaseaddr(addr, &base_size, true);
base = memfindbaseaddr(addr, &base_size, true);
if(!base or !base_size)
{
if(!silent)
@ -19,19 +19,19 @@ int reffind(uint addr, uint size, CBREF cbRef, void* userinfo, bool silent)
if(!size) //assume the whole page
{
start_addr=base;
start_size=base_size;
start_addr = base;
start_size = base_size;
}
else //custom boundaries
{
start_addr=addr;
uint maxsize=size-(start_addr-base);
if(size<maxsize) //check if the size fits in the page
start_size=size;
start_addr = addr;
uint maxsize = size - (start_addr - base);
if(size < maxsize) //check if the size fits in the page
start_size = size;
else
start_size=maxsize;
start_size = maxsize;
}
unsigned char* data=(unsigned char*)emalloc(start_size, "reffind:data");
unsigned char* data = (unsigned char*)emalloc(start_size, "reffind:data");
if(!memread(fdProcessInfo->hProcess, (const void*)start_addr, data, start_size, 0))
{
if(!silent)
@ -42,36 +42,36 @@ int reffind(uint addr, uint size, CBREF cbRef, void* userinfo, bool silent)
DISASM disasm;
memset(&disasm, 0, sizeof(disasm));
#ifdef _WIN64
disasm.Archi=64;
disasm.Archi = 64;
#endif // _WIN64
disasm.EIP=(UIntPtr)data;
disasm.VirtualAddr=(UInt64)start_addr;
uint i=0;
disasm.EIP = (UIntPtr)data;
disasm.VirtualAddr = (UInt64)start_addr;
uint i = 0;
BASIC_INSTRUCTION_INFO basicinfo;
cbRef(&disasm, &basicinfo, 0); //allow initializing
REFINFO refinfo;
memset(&refinfo, 0, sizeof(REFINFO));
refinfo.userinfo=userinfo;
while(i<start_size)
refinfo.userinfo = userinfo;
while(i < start_size)
{
if(!(i%0x1000))
if(!(i % 0x1000))
{
double percent=(double)i/(double)start_size;
GuiReferenceSetProgress((int)(percent*100));
double percent = (double)i / (double)start_size;
GuiReferenceSetProgress((int)(percent * 100));
}
int len=Disasm(&disasm);
if(len!=UNKNOWN_OPCODE)
int len = Disasm(&disasm);
if(len != UNKNOWN_OPCODE)
{
fillbasicinfo(&disasm, &basicinfo);
basicinfo.size=len;
basicinfo.size = len;
if(cbRef(&disasm, &basicinfo, &refinfo))
refinfo.refcount++;
}
else
len=1;
disasm.EIP+=len;
disasm.VirtualAddr+=len;
i+=len;
len = 1;
disasm.EIP += len;
disasm.VirtualAddr += len;
i += len;
}
GuiReferenceSetProgress(100);
GuiReferenceReloadData();

View File

@ -10,13 +10,13 @@
static std::vector<LINEMAPENTRY> linemap;
static std::vector<SCRIPTBP> scriptbplist;
static std::vector<int> scriptstack;
static int scriptIp=0;
static bool volatile bAbort=false;
static bool volatile bIsRunning=false;
static int scriptIp = 0;
static bool volatile bAbort = false;
static bool volatile bIsRunning = false;
static SCRIPTBRANCHTYPE scriptgetbranchtype(const char* text)
{
char newtext[MAX_SCRIPT_LINE_SIZE]="";
char newtext[MAX_SCRIPT_LINE_SIZE] = "";
strcpy(newtext, text);
argformat(newtext); //format jump commands
if(!strstr(newtext, " "))
@ -42,19 +42,19 @@ static SCRIPTBRANCHTYPE scriptgetbranchtype(const char* text)
static int scriptlabelfind(const char* labelname)
{
int linecount=(int)linemap.size();
for(int i=0; i<linecount; i++)
if(linemap.at(i).type==linelabel && !strcmp(linemap.at(i).u.label, labelname))
return i+1;
int linecount = (int)linemap.size();
for(int i = 0; i < linecount; i++)
if(linemap.at(i).type == linelabel && !strcmp(linemap.at(i).u.label, labelname))
return i + 1;
return 0;
}
static int scriptinternalstep(int fromIp) //internal step routine
{
int maxIp=(int)linemap.size(); //maximum ip
if(fromIp>=maxIp) //script end
int maxIp = (int)linemap.size(); //maximum ip
if(fromIp >= maxIp) //script end
return fromIp;
while((linemap.at(fromIp).type==lineempty or linemap.at(fromIp).type==linecomment or linemap.at(fromIp).type==linelabel) and fromIp<maxIp) //skip empty lines
while((linemap.at(fromIp).type == lineempty or linemap.at(fromIp).type == linecomment or linemap.at(fromIp).type == linelabel) and fromIp < maxIp) //skip empty lines
fromIp++;
fromIp++;
return fromIp;
@ -62,22 +62,22 @@ static int scriptinternalstep(int fromIp) //internal step routine
static bool scriptcreatelinemap(const char* filename)
{
HANDLE hFile=CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if(hFile==INVALID_HANDLE_VALUE)
HANDLE hFile = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if(hFile == INVALID_HANDLE_VALUE)
{
GuiScriptError(0, "CreateFile failed...");
return false;
}
unsigned int filesize=GetFileSize(hFile, 0);
unsigned int filesize = GetFileSize(hFile, 0);
if(!filesize)
{
CloseHandle(hFile);
GuiScriptError(0, "Empty script...");
return false;
}
char* filedata=(char*)emalloc(filesize+1, "createlinemap:filedata");
memset(filedata, 0, filesize+1);
DWORD read=0;
char* filedata = (char*)emalloc(filesize + 1, "createlinemap:filedata");
memset(filedata, 0, filesize + 1);
DWORD read = 0;
if(!ReadFile(hFile, filedata, filesize, &read, 0))
{
CloseHandle(hFile);
@ -86,49 +86,49 @@ static bool scriptcreatelinemap(const char* filename)
return false;
}
CloseHandle(hFile);
int len=(int)strlen(filedata);
char temp[256]="";
int len = (int)strlen(filedata);
char temp[256] = "";
LINEMAPENTRY entry;
memset(&entry, 0, sizeof(entry));
std::vector<LINEMAPENTRY>().swap(linemap);
for(int i=0,j=0; i<len; i++) //make raw line map
for(int i = 0, j = 0; i < len; i++) //make raw line map
{
if(filedata[i]=='\r' and filedata[i+1]=='\n') //windows file
if(filedata[i] == '\r' and filedata[i + 1] == '\n') //windows file
{
memset(&entry, 0, sizeof(entry));
int add=0;
while(temp[add]==' ')
int add = 0;
while(temp[add] == ' ')
add++;
strcpy(entry.raw, temp+add);
*temp=0;
j=0;
strcpy(entry.raw, temp + add);
*temp = 0;
j = 0;
i++;
linemap.push_back(entry);
}
else if(filedata[i]=='\n') //other file
else if(filedata[i] == '\n') //other file
{
memset(&entry, 0, sizeof(entry));
int add=0;
while(temp[add]==' ')
int add = 0;
while(temp[add] == ' ')
add++;
strcpy(entry.raw, temp+add);
*temp=0;
j=0;
strcpy(entry.raw, temp + add);
*temp = 0;
j = 0;
linemap.push_back(entry);
}
else if(j>=254)
else if(j >= 254)
{
memset(&entry, 0, sizeof(entry));
int add=0;
while(temp[add]==' ')
int add = 0;
while(temp[add] == ' ')
add++;
strcpy(entry.raw, temp+add);
*temp=0;
j=0;
strcpy(entry.raw, temp + add);
*temp = 0;
j = 0;
linemap.push_back(entry);
}
else
j+=sprintf(temp+j, "%c", filedata[i]);
j += sprintf(temp + j, "%c", filedata[i]);
}
if(*temp)
{
@ -137,115 +137,115 @@ static bool scriptcreatelinemap(const char* filename)
linemap.push_back(entry);
}
efree(filedata, "createlinemap:filedata");
unsigned int linemapsize=(unsigned int)linemap.size();
while(!*linemap.at(linemapsize-1).raw) //remove empty lines from the end
unsigned int linemapsize = (unsigned int)linemap.size();
while(!*linemap.at(linemapsize - 1).raw) //remove empty lines from the end
{
linemapsize--;
linemap.pop_back();
}
for(unsigned int i=0; i<linemapsize; i++)
for(unsigned int i = 0; i < linemapsize; i++)
{
LINEMAPENTRY cur=linemap.at(i);
LINEMAPENTRY cur = linemap.at(i);
//temp. remove comments from the raw line
char line_comment[256]="";
char* comment=strstr(&cur.raw[0], "//");
if(comment && comment!=cur.raw) //only when the line doesnt start with a comment
char line_comment[256] = "";
char* comment = strstr(&cur.raw[0], "//");
if(comment && comment != cur.raw) //only when the line doesnt start with a comment
{
if(*(comment-1)==' ') //space before comment
if(*(comment - 1) == ' ') //space before comment
{
strcpy(line_comment, comment);
*(comment-1)='\0';
*(comment - 1) = '\0';
}
else //no space before comment
{
strcpy(line_comment, comment);
*comment=0;
*comment = 0;
}
}
int rawlen=(int)strlen(cur.raw);
int rawlen = (int)strlen(cur.raw);
if(!strlen(cur.raw)) //empty
{
cur.type=lineempty;
cur.type = lineempty;
}
else if(!strncmp(cur.raw, "//", 2)) //comment
{
cur.type=linecomment;
cur.type = linecomment;
strcpy(cur.u.comment, cur.raw);
}
else if(cur.raw[rawlen-1]==':') //label
else if(cur.raw[rawlen - 1] == ':') //label
{
cur.type=linelabel;
sprintf(cur.u.label, "l %.*s", rawlen-1, cur.raw); //create a fake command for formatting
cur.type = linelabel;
sprintf(cur.u.label, "l %.*s", rawlen - 1, cur.raw); //create a fake command for formatting
argformat(cur.u.label); //format labels
strcpy(cur.u.label, cur.u.label+2); //remove fake command
strcpy(cur.u.label, cur.u.label + 2); //remove fake command
if(!*cur.u.label or !strcmp(cur.u.label, "\"\"")) //no label text
{
char message[256]="";
sprintf(message, "Empty label detected on line %d!", i+1);
char message[256] = "";
sprintf(message, "Empty label detected on line %d!", i + 1);
GuiScriptError(0, message);
std::vector<LINEMAPENTRY>().swap(linemap);
return false;
}
int foundlabel=scriptlabelfind(cur.u.label);
int foundlabel = scriptlabelfind(cur.u.label);
if(foundlabel) //label defined twice
{
char message[256]="";
sprintf(message, "Duplicate label \"%s\" detected on lines %d and %d!", cur.u.label, foundlabel, i+1);
char message[256] = "";
sprintf(message, "Duplicate label \"%s\" detected on lines %d and %d!", cur.u.label, foundlabel, i + 1);
GuiScriptError(0, message);
std::vector<LINEMAPENTRY>().swap(linemap);
return false;
}
}
else if(scriptgetbranchtype(cur.raw)!=scriptnobranch) //branch
else if(scriptgetbranchtype(cur.raw) != scriptnobranch) //branch
{
cur.type=linebranch;
cur.u.branch.type=scriptgetbranchtype(cur.raw);
char newraw[MAX_SCRIPT_LINE_SIZE]="";
cur.type = linebranch;
cur.u.branch.type = scriptgetbranchtype(cur.raw);
char newraw[MAX_SCRIPT_LINE_SIZE] = "";
strcpy(newraw, cur.raw);
argformat(newraw);
int len=(int)strlen(newraw);
for(int i=0; i<len; i++)
if(newraw[i]==' ')
int len = (int)strlen(newraw);
for(int i = 0; i < len; i++)
if(newraw[i] == ' ')
{
strcpy(cur.u.branch.branchlabel, newraw+i+1);
strcpy(cur.u.branch.branchlabel, newraw + i + 1);
break;
}
}
else
{
cur.type=linecommand;
cur.type = linecommand;
strcpy(cur.u.command, cur.raw);
}
//append the comment to the raw line again
if(*line_comment)
sprintf(cur.raw+rawlen, " %s", line_comment);
linemap.at(i)=cur;
sprintf(cur.raw + rawlen, " %s", line_comment);
linemap.at(i) = cur;
}
linemapsize=(int)linemap.size();
for(unsigned int i=0; i<linemapsize; i++)
linemapsize = (int)linemap.size();
for(unsigned int i = 0; i < linemapsize; i++)
{
if(linemap.at(i).type==linebranch) //invalid branch label
if(linemap.at(i).type == linebranch) //invalid branch label
{
int labelline=scriptlabelfind(linemap.at(i).u.branch.branchlabel);
int labelline = scriptlabelfind(linemap.at(i).u.branch.branchlabel);
if(!labelline) //invalid branch label
{
char message[256]="";
sprintf(message, "Invalid branch label \"%s\" detected on line %d!", linemap.at(i).u.branch.branchlabel, i+1);
char message[256] = "";
sprintf(message, "Invalid branch label \"%s\" detected on line %d!", linemap.at(i).u.branch.branchlabel, i + 1);
GuiScriptError(0, message);
std::vector<LINEMAPENTRY>().swap(linemap);
return false;
}
else //set the branch destination line
linemap.at(i).u.branch.dest=scriptinternalstep(labelline);
linemap.at(i).u.branch.dest = scriptinternalstep(labelline);
}
}
if(linemap.at(linemapsize-1).type==linecomment or linemap.at(linemapsize-1).type==linelabel) //label/comment on the end
if(linemap.at(linemapsize - 1).type == linecomment or linemap.at(linemapsize - 1).type == linelabel) //label/comment on the end
{
memset(&entry, 0, sizeof(entry));
entry.type=linecommand;
entry.type = linecommand;
strcpy(entry.raw, "ret");
strcpy(entry.u.command, "ret");
linemap.push_back(entry);
@ -255,33 +255,33 @@ static bool scriptcreatelinemap(const char* filename)
static bool scriptinternalbpget(int line) //internal bpget routine
{
int bpcount=(int)scriptbplist.size();
for(int i=0; i<bpcount; i++)
if(scriptbplist.at(i).line==line)
int bpcount = (int)scriptbplist.size();
for(int i = 0; i < bpcount; i++)
if(scriptbplist.at(i).line == line)
return true;
return false;
}
static bool scriptinternalbptoggle(int line) //internal breakpoint
{
if(!line or line>(int)linemap.size()) //invalid line
if(!line or line > (int)linemap.size()) //invalid line
return false;
line=scriptinternalstep(line-1); //no breakpoints on non-executable locations
line = scriptinternalstep(line - 1); //no breakpoints on non-executable locations
if(scriptinternalbpget(line)) //remove breakpoint
{
int bpcount=(int)scriptbplist.size();
for(int i=0; i<bpcount; i++)
if(scriptbplist.at(i).line==line)
int bpcount = (int)scriptbplist.size();
for(int i = 0; i < bpcount; i++)
if(scriptbplist.at(i).line == line)
{
scriptbplist.erase(scriptbplist.begin()+i);
scriptbplist.erase(scriptbplist.begin() + i);
break;
}
}
else //add breakpoint
{
SCRIPTBP newbp;
newbp.silent=true;
newbp.line=line;
newbp.silent = true;
newbp.line = line;
scriptbplist.push_back(newbp);
}
return true;
@ -312,13 +312,13 @@ static bool scriptisruncommand(const char* cmdlist)
static bool scriptisinternalcommand(const char* text, const char* cmd)
{
int len=(int)strlen(text);
int cmdlen=(int)strlen(cmd);
if(cmdlen>len)
int len = (int)strlen(text);
int cmdlen = (int)strlen(cmd);
if(cmdlen > len)
return false;
else if(cmdlen==len)
else if(cmdlen == len)
return scmp(text, cmd);
else if(text[cmdlen]==' ')
else if(text[cmdlen] == ' ')
return (!_strnicmp(text, cmd, cmdlen));
return false;
}
@ -332,7 +332,7 @@ static CMDRESULT scriptinternalcmdexec(const char* cmd)
GuiScriptMessage("Script finished!");
return STATUS_EXIT;
}
scriptIp=scriptstack.back(); //set scriptIp to the call address (scriptinternalstep will step over it)
scriptIp = scriptstack.back(); //set scriptIp to the call address (scriptinternalstep will step over it)
scriptstack.pop_back(); //remove last stack entry
return STATUS_CONTINUE;
}
@ -342,10 +342,10 @@ static CMDRESULT scriptinternalcmdexec(const char* cmd)
return STATUS_PAUSE;
else if(scriptisinternalcommand(cmd, "nop")) //do nothing
return STATUS_CONTINUE;
char command[deflen]="";
char command[deflen] = "";
strcpy(command, cmd);
argformat(command);
COMMAND* found=cmdfindmain(dbggetcommandlist(), command);
COMMAND* found = cmdfindmain(dbggetcommandlist(), command);
if(!found) //invalid command
return STATUS_ERROR;
if(arraycontains(found->name, "var")) //var
@ -353,7 +353,7 @@ static CMDRESULT scriptinternalcmdexec(const char* cmd)
cmddirectexec(dbggetcommandlist(), command);
return STATUS_CONTINUE;
}
CMDRESULT res=cmddirectexec(dbggetcommandlist(), command);
CMDRESULT res = cmddirectexec(dbggetcommandlist(), command);
if(DbgIsDebugging())
{
while(!waitislocked(WAITID_RUN)) //while not locked (NOTE: possible deadlock)
@ -364,43 +364,43 @@ static CMDRESULT scriptinternalcmdexec(const char* cmd)
static bool scriptinternalbranch(SCRIPTBRANCHTYPE type) //determine if we should jump
{
uint ezflag=0;
uint bsflag=0;
uint ezflag = 0;
uint bsflag = 0;
varget("$_EZ_FLAG", &ezflag, 0, 0);
varget("$_BS_FLAG", &bsflag, 0, 0);
bool bJump=false;
bool bJump = false;
switch(type)
{
case scriptcall:
case scriptjmp:
bJump=true;
bJump = true;
break;
case scriptjnejnz: //$_EZ_FLAG=0
if(!ezflag)
bJump=true;
bJump = true;
break;
case scriptjejz: //$_EZ_FLAG=1
if(ezflag)
bJump=true;
bJump = true;
break;
case scriptjbjl: //$_BS_FLAG=0 and $_EZ_FLAG=0 //below, not equal
if(!bsflag and !ezflag)
bJump=true;
bJump = true;
break;
case scriptjajg: //$_BS_FLAG=1 and $_EZ_FLAG=0 //above, not equal
if(bsflag and !ezflag)
bJump=true;
bJump = true;
break;
case scriptjbejle: //$_BS_FLAG=0 or $_EZ_FLAG=1
if(!bsflag or ezflag)
bJump=true;
bJump = true;
break;
case scriptjaejge: //$_BS_FLAG=1 or $_EZ_FLAG=1
if(bsflag or ezflag)
bJump=true;
bJump = true;
break;
default:
bJump=false;
bJump = false;
break;
}
return bJump;
@ -408,71 +408,71 @@ static bool scriptinternalbranch(SCRIPTBRANCHTYPE type) //determine if we should
static bool scriptinternalcmd()
{
bool bContinue=true;
LINEMAPENTRY cur=linemap.at(scriptIp-1);
if(cur.type==linecommand)
bool bContinue = true;
LINEMAPENTRY cur = linemap.at(scriptIp - 1);
if(cur.type == linecommand)
{
switch(scriptinternalcmdexec(cur.u.command))
{
case STATUS_CONTINUE:
break;
case STATUS_ERROR:
bContinue=false;
bContinue = false;
GuiScriptError(scriptIp, "Error executing command!");
break;
case STATUS_EXIT:
bContinue=false;
scriptIp=scriptinternalstep(0);
bContinue = false;
scriptIp = scriptinternalstep(0);
GuiScriptSetIp(scriptIp);
break;
case STATUS_PAUSE:
bContinue=false; //stop running the script
scriptIp=scriptinternalstep(scriptIp);
bContinue = false; //stop running the script
scriptIp = scriptinternalstep(scriptIp);
GuiScriptSetIp(scriptIp);
break;
}
}
else if(cur.type==linebranch)
else if(cur.type == linebranch)
{
if(cur.u.branch.type==scriptcall) //calls have a special meaning
if(cur.u.branch.type == scriptcall) //calls have a special meaning
scriptstack.push_back(scriptIp);
if(scriptinternalbranch(cur.u.branch.type))
scriptIp=scriptlabelfind(cur.u.branch.branchlabel);
scriptIp = scriptlabelfind(cur.u.branch.branchlabel);
}
return bContinue;
}
static DWORD WINAPI scriptRunThread(void* arg)
{
int destline=(int)(uint)arg;
if(!destline or destline>(int)linemap.size()) //invalid line
destline=0;
int destline = (int)(uint)arg;
if(!destline or destline > (int)linemap.size()) //invalid line
destline = 0;
if(destline)
{
destline=scriptinternalstep(destline-1); //no breakpoints on non-executable locations
destline = scriptinternalstep(destline - 1); //no breakpoints on non-executable locations
if(!scriptinternalbpget(destline)) //no breakpoint set
scriptinternalbptoggle(destline);
}
bAbort=false;
bAbort = false;
if(scriptIp)
scriptIp--;
scriptIp=scriptinternalstep(scriptIp);
bool bContinue=true;
scriptIp = scriptinternalstep(scriptIp);
bool bContinue = true;
while(bContinue && !bAbort) //run loop
{
bContinue=scriptinternalcmd();
if(scriptIp==scriptinternalstep(scriptIp)) //end of script
bContinue = scriptinternalcmd();
if(scriptIp == scriptinternalstep(scriptIp)) //end of script
{
bContinue=false;
scriptIp=scriptinternalstep(0);
bContinue = false;
scriptIp = scriptinternalstep(0);
}
if(bContinue)
scriptIp=scriptinternalstep(scriptIp); //this is the next ip
scriptIp = scriptinternalstep(scriptIp); //this is the next ip
if(scriptinternalbpget(scriptIp)) //breakpoint=stop run loop
bContinue=false;
bContinue = false;
Sleep(1); //don't fry the processor
}
bIsRunning=false; //not running anymore
bIsRunning = false; //not running anymore
GuiScriptSetIp(scriptIp);
return 0;
}
@ -481,25 +481,25 @@ static DWORD WINAPI scriptLoadThread(void* filename)
{
GuiScriptClear();
GuiScriptEnableHighlighting(true); //enable default script syntax highlighting
scriptIp=0;
scriptIp = 0;
std::vector<SCRIPTBP>().swap(scriptbplist); //clear breakpoints
std::vector<int>().swap(scriptstack); //clear script stack
bAbort=false;
bAbort = false;
if(!scriptcreatelinemap((const char*)filename))
return 0;
int lines=(int)linemap.size();
const char** script=(const char**)BridgeAlloc(lines*sizeof(const char*));
for(int i=0; i<lines; i++) //add script lines
script[i]=linemap.at(i).raw;
int lines = (int)linemap.size();
const char** script = (const char**)BridgeAlloc(lines * sizeof(const char*));
for(int i = 0; i < lines; i++) //add script lines
script[i] = linemap.at(i).raw;
GuiScriptAdd(lines, script);
scriptIp=scriptinternalstep(0);
scriptIp = scriptinternalstep(0);
GuiScriptSetIp(scriptIp);
return 0;
}
void scriptload(const char* filename)
{
static char filename_[MAX_PATH]="";
static char filename_[MAX_PATH] = "";
strcpy(filename_, filename);
CloseHandle(CreateThread(0, 0, scriptLoadThread, filename_, 0, 0));
}
@ -507,9 +507,9 @@ void scriptload(const char* filename)
void scriptunload()
{
GuiScriptClear();
scriptIp=0;
scriptIp = 0;
std::vector<SCRIPTBP>().swap(scriptbplist); //clear breakpoints
bAbort=false;
bAbort = false;
}
void scriptrun(int destline)
@ -521,7 +521,7 @@ void scriptrun(int destline)
}
if(bIsRunning) //already running
return;
bIsRunning=true;
bIsRunning = true;
CloseHandle(CreateThread(0, 0, scriptRunThread, (void*)(uint)destline, 0, 0));
}
@ -529,12 +529,12 @@ DWORD WINAPI scriptStepThread(void* param)
{
if(bIsRunning) //already running
return 0;
scriptIp=scriptinternalstep(scriptIp-1); //probably useless
scriptIp = scriptinternalstep(scriptIp - 1); //probably useless
if(!scriptinternalcmd())
return 0;
if(scriptIp==scriptinternalstep(scriptIp)) //end of script
scriptIp=0;
scriptIp=scriptinternalstep(scriptIp);
if(scriptIp == scriptinternalstep(scriptIp)) //end of script
scriptIp = 0;
scriptIp = scriptinternalstep(scriptIp);
GuiScriptSetIp(scriptIp);
return 0;
}
@ -546,24 +546,24 @@ void scriptstep()
bool scriptbptoggle(int line)
{
if(!line or line>(int)linemap.size()) //invalid line
if(!line or line > (int)linemap.size()) //invalid line
return false;
line=scriptinternalstep(line-1); //no breakpoints on non-executable locations
line = scriptinternalstep(line - 1); //no breakpoints on non-executable locations
if(scriptbpget(line)) //remove breakpoint
{
int bpcount=(int)scriptbplist.size();
for(int i=0; i<bpcount; i++)
if(scriptbplist.at(i).line==line && !scriptbplist.at(i).silent)
int bpcount = (int)scriptbplist.size();
for(int i = 0; i < bpcount; i++)
if(scriptbplist.at(i).line == line && !scriptbplist.at(i).silent)
{
scriptbplist.erase(scriptbplist.begin()+i);
scriptbplist.erase(scriptbplist.begin() + i);
break;
}
}
else //add breakpoint
{
SCRIPTBP newbp;
newbp.silent=false;
newbp.line=line;
newbp.silent = false;
newbp.line = line;
scriptbplist.push_back(newbp);
}
return true;
@ -571,9 +571,9 @@ bool scriptbptoggle(int line)
bool scriptbpget(int line)
{
int bpcount=(int)scriptbplist.size();
for(int i=0; i<bpcount; i++)
if(scriptbplist.at(i).line==line && !scriptbplist.at(i).silent)
int bpcount = (int)scriptbplist.size();
for(int i = 0; i < bpcount; i++)
if(scriptbplist.at(i).line == line && !scriptbplist.at(i).silent)
return true;
return false;
}
@ -586,7 +586,7 @@ bool scriptcmdexec(const char* command)
return false;
break;
case STATUS_EXIT:
scriptIp=scriptinternalstep(0);
scriptIp = scriptinternalstep(0);
GuiScriptSetIp(scriptIp);
break;
case STATUS_PAUSE:
@ -600,7 +600,7 @@ void scriptabort()
{
if(bIsRunning)
{
bAbort=true;
bAbort = true;
while(bIsRunning)
Sleep(1);
}
@ -610,16 +610,16 @@ void scriptabort()
SCRIPTLINETYPE scriptgetlinetype(int line)
{
if(line>(int)linemap.size())
if(line > (int)linemap.size())
return lineempty;
return linemap.at(line-1).type;
return linemap.at(line - 1).type;
}
void scriptsetip(int line)
{
if(line)
line--;
scriptIp=scriptinternalstep(line);
scriptIp = scriptinternalstep(line);
GuiScriptSetIp(scriptIp);
}
@ -627,7 +627,7 @@ void scriptreset()
{
while(bIsRunning)
{
bAbort=true;
bAbort = true;
Sleep(1);
}
Sleep(10);
@ -636,17 +636,17 @@ void scriptreset()
bool scriptgetbranchinfo(int line, SCRIPTBRANCH* info)
{
if(!info or !line or line>(int)linemap.size()) //invalid line
if(!info or !line or line > (int)linemap.size()) //invalid line
return false;
if(linemap.at(line-1).type!=linebranch) //no branch
if(linemap.at(line - 1).type != linebranch) //no branch
return false;
memcpy(info, &linemap.at(line-1).u.branch, sizeof(SCRIPTBRANCH));
memcpy(info, &linemap.at(line - 1).u.branch, sizeof(SCRIPTBRANCH));
return true;
}
CMDRESULT cbScriptLoad(int argc, char* argv[])
{
if(argc<2)
if(argc < 2)
return STATUS_ERROR;
scriptload(argv[1]);
return STATUS_CONTINUE;
@ -654,7 +654,7 @@ CMDRESULT cbScriptLoad(int argc, char* argv[])
CMDRESULT cbScriptMsg(int argc, char* argv[])
{
if(argc<2)
if(argc < 2)
{
dputs("not enough arguments!");
return STATUS_ERROR;
@ -665,7 +665,7 @@ CMDRESULT cbScriptMsg(int argc, char* argv[])
CMDRESULT cbScriptMsgyn(int argc, char* argv[])
{
if(argc<2)
if(argc < 2)
{
dputs("not enough arguments!");
return STATUS_ERROR;

View File

@ -9,58 +9,58 @@
bool stackcommentget(uint addr, STACK_COMMENT* comment)
{
uint data=0;
uint data = 0;
memset(comment, 0, sizeof(STACK_COMMENT));
memread(fdProcessInfo->hProcess, (const void*)addr, &data, sizeof(uint), 0);
if(!memisvalidreadptr(fdProcessInfo->hProcess, data)) //the stack value is no pointer
return false;
uint size=0;
uint base=memfindbaseaddr(data, &size);
uint readStart=data-16*4;
if(readStart<base)
readStart=base;
uint size = 0;
uint base = memfindbaseaddr(data, &size);
uint readStart = data - 16 * 4;
if(readStart < base)
readStart = base;
unsigned char disasmData[256];
memread(fdProcessInfo->hProcess, (const void*)readStart, disasmData, sizeof(disasmData), 0);
uint prev=disasmback(disasmData, 0, sizeof(disasmData), data-readStart, 1);
uint previousInstr=readStart+prev;
uint prev = disasmback(disasmData, 0, sizeof(disasmData), data - readStart, 1);
uint previousInstr = readStart + prev;
DISASM disasm;
disasm.Options=NoformatNumeral;
disasm.Options = NoformatNumeral;
#ifdef _WIN64
disasm.Archi=64;
disasm.Archi = 64;
#endif // _WIN64
disasm.VirtualAddr=previousInstr;
disasm.EIP=(UIntPtr)(disasmData+prev);
int len=Disasm(&disasm);
disasm.VirtualAddr = previousInstr;
disasm.EIP = (UIntPtr)(disasmData + prev);
int len = Disasm(&disasm);
BASIC_INSTRUCTION_INFO basicinfo;
bool valid=disasmfast(disasmData+prev, previousInstr, &basicinfo);
bool valid = disasmfast(disasmData + prev, previousInstr, &basicinfo);
if(valid && basicinfo.call) //call
{
char label[MAX_LABEL_SIZE]="";
char label[MAX_LABEL_SIZE] = "";
ADDRINFO addrinfo;
addrinfo.flags=flaglabel;
addrinfo.flags = flaglabel;
if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo))
strcpy(label, addrinfo.label);
char module[MAX_MODULE_SIZE]="";
char module[MAX_MODULE_SIZE] = "";
modnamefromaddr(data, module, false);
char returnToAddr[MAX_COMMENT_SIZE]="";
char returnToAddr[MAX_COMMENT_SIZE] = "";
if(*module)
sprintf(returnToAddr, "%s.", module);
if(!*label)
sprintf(label, fhex, data);
strcat(returnToAddr, label);
data=basicinfo.addr;
data = basicinfo.addr;
if(data)
{
*label=0;
addrinfo.flags=flaglabel;
*label = 0;
addrinfo.flags = flaglabel;
if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo))
strcpy(label, addrinfo.label);
*module=0;
*module = 0;
modnamefromaddr(data, module, false);
char returnFromAddr[MAX_COMMENT_SIZE]="";
char returnFromAddr[MAX_COMMENT_SIZE] = "";
if(*module)
sprintf(returnFromAddr, "%s.", module);
if(!*label)
@ -76,10 +76,10 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment)
//string
STRING_TYPE strtype;
char string[512]="";
char string[512] = "";
if(disasmgetstringat(data, &strtype, string, string, 500))
{
if(strtype==str_ascii)
if(strtype == str_ascii)
sprintf(comment->comment, "\"%s\"", string);
else //unicode
sprintf(comment->comment, "L\"%s\"", string);
@ -87,14 +87,14 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment)
}
//label
char label[MAX_LABEL_SIZE]="";
char label[MAX_LABEL_SIZE] = "";
ADDRINFO addrinfo;
addrinfo.flags=flaglabel;
addrinfo.flags = flaglabel;
if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo))
strcpy(label, addrinfo.label);
char module[MAX_MODULE_SIZE]="";
char module[MAX_MODULE_SIZE] = "";
modnamefromaddr(data, module, false);
char addrInfo[MAX_COMMENT_SIZE]="";
char addrInfo[MAX_COMMENT_SIZE] = "";
if(*module) //module
{
if(*label) //+label
@ -114,46 +114,46 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment)
#include "console.h"
void stackgetcallstack(uint csp, CALLSTACK* callstack)
{
callstack->total=0;
if(!DbgIsDebugging() or csp%sizeof(uint)) //alignment problem
callstack->total = 0;
if(!DbgIsDebugging() or csp % sizeof(uint)) //alignment problem
return;
if(!memisvalidreadptr(fdProcessInfo->hProcess, csp))
return;
std::vector<CALLSTACKENTRY> callstackVector;
DWORD ticks=GetTickCount();
uint stacksize=0;
uint stackbase=memfindbaseaddr(csp, &stacksize, false);
DWORD ticks = GetTickCount();
uint stacksize = 0;
uint stackbase = memfindbaseaddr(csp, &stacksize, false);
if(!stackbase) //super-fail (invalid stack address)
return;
//walk up the stack
uint i=csp;
while(i!=stackbase+stacksize)
uint i = csp;
while(i != stackbase + stacksize)
{
uint data=0;
uint data = 0;
memread(fdProcessInfo->hProcess, (const void*)i, &data, sizeof(uint), 0);
if(memisvalidreadptr(fdProcessInfo->hProcess, data)) //the stack value is a pointer
{
uint size=0;
uint base=memfindbaseaddr(data, &size);
uint readStart=data-16*4;
if(readStart<base)
readStart=base;
uint size = 0;
uint base = memfindbaseaddr(data, &size);
uint readStart = data - 16 * 4;
if(readStart < base)
readStart = base;
unsigned char disasmData[256];
memread(fdProcessInfo->hProcess, (const void*)readStart, disasmData, sizeof(disasmData), 0);
uint prev=disasmback(disasmData, 0, sizeof(disasmData), data-readStart, 1);
uint previousInstr=readStart+prev;
uint prev = disasmback(disasmData, 0, sizeof(disasmData), data - readStart, 1);
uint previousInstr = readStart + prev;
BASIC_INSTRUCTION_INFO basicinfo;
bool valid=disasmfast(disasmData+prev, previousInstr, &basicinfo);
bool valid = disasmfast(disasmData + prev, previousInstr, &basicinfo);
if(valid && basicinfo.call) //call
{
char label[MAX_LABEL_SIZE]="";
char label[MAX_LABEL_SIZE] = "";
ADDRINFO addrinfo;
addrinfo.flags=flaglabel;
addrinfo.flags = flaglabel;
if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo))
strcpy(label, addrinfo.label);
char module[MAX_MODULE_SIZE]="";
char module[MAX_MODULE_SIZE] = "";
modnamefromaddr(data, module, false);
char returnToAddr[MAX_COMMENT_SIZE]="";
char returnToAddr[MAX_COMMENT_SIZE] = "";
if(*module)
sprintf(returnToAddr, "%s.", module);
if(!*label)
@ -162,21 +162,21 @@ void stackgetcallstack(uint csp, CALLSTACK* callstack)
CALLSTACKENTRY curEntry;
memset(&curEntry, 0, sizeof(CALLSTACKENTRY));
curEntry.addr=i;
curEntry.to=data;
curEntry.from=basicinfo.addr;
curEntry.addr = i;
curEntry.to = data;
curEntry.from = basicinfo.addr;
data=basicinfo.addr;
data = basicinfo.addr;
if(data)
{
*label=0;
addrinfo.flags=flaglabel;
*label = 0;
addrinfo.flags = flaglabel;
if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo))
strcpy(label, addrinfo.label);
*module=0;
*module = 0;
modnamefromaddr(data, module, false);
char returnFromAddr[MAX_COMMENT_SIZE]="";
char returnFromAddr[MAX_COMMENT_SIZE] = "";
if(*module)
sprintf(returnFromAddr, "%s.", module);
if(!*label)
@ -190,13 +190,13 @@ void stackgetcallstack(uint csp, CALLSTACK* callstack)
callstackVector.push_back(curEntry);
}
}
i+=sizeof(uint);
i += sizeof(uint);
}
callstack->total=(int)callstackVector.size();
callstack->total = (int)callstackVector.size();
if(callstack->total)
{
callstack->entries=(CALLSTACKENTRY*)BridgeAlloc(callstack->total*sizeof(CALLSTACKENTRY));
for(int i=0; i<callstack->total; i++)
callstack->entries = (CALLSTACKENTRY*)BridgeAlloc(callstack->total * sizeof(CALLSTACKENTRY));
for(int i = 0; i < callstack->total; i++)
{
//CALLSTACKENTRY curEntry;
//memcpy(&curEntry, &callstackVector.at(i), sizeof(CALLSTACKENTRY));

View File

@ -11,13 +11,13 @@ struct SYMBOLCBDATA
static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
{
int len=(int)strlen(pSymInfo->Name);
int len = (int)strlen(pSymInfo->Name);
SYMBOLINFO curSymbol;
memset(&curSymbol, 0, sizeof(SYMBOLINFO));
curSymbol.addr=(duint)pSymInfo->Address;
curSymbol.decoratedSymbol=(char*)BridgeAlloc(len+1);
curSymbol.addr = (duint)pSymInfo->Address;
curSymbol.decoratedSymbol = (char*)BridgeAlloc(len + 1);
strcpy(curSymbol.decoratedSymbol, pSymInfo->Name);
curSymbol.undecoratedSymbol=(char*)BridgeAlloc(MAX_SYM_NAME);
curSymbol.undecoratedSymbol = (char*)BridgeAlloc(MAX_SYM_NAME);
if(strstr(pSymInfo->Name, "Ordinal"))
{
//skip bad ordinals
@ -27,14 +27,14 @@ static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID
if(!UnDecorateSymbolName(pSymInfo->Name, curSymbol.undecoratedSymbol, MAX_SYM_NAME, UNDNAME_COMPLETE))
{
BridgeFree(curSymbol.undecoratedSymbol);
curSymbol.undecoratedSymbol=0;
curSymbol.undecoratedSymbol = 0;
}
else if(!strcmp(curSymbol.decoratedSymbol, curSymbol.undecoratedSymbol))
{
BridgeFree(curSymbol.undecoratedSymbol);
curSymbol.undecoratedSymbol=0;
curSymbol.undecoratedSymbol = 0;
}
SYMBOLCBDATA* cbData=(SYMBOLCBDATA*)UserContext;
SYMBOLCBDATA* cbData = (SYMBOLCBDATA*)UserContext;
cbData->cbSymbolEnum(&curSymbol, cbData->user);
return TRUE;
}
@ -42,9 +42,9 @@ static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID
void symenum(uint base, CBSYMBOLENUM cbSymbolEnum, void* user)
{
SYMBOLCBDATA symbolCbData;
symbolCbData.cbSymbolEnum=cbSymbolEnum;
symbolCbData.user=user;
char mask[]="*";
symbolCbData.cbSymbolEnum = cbSymbolEnum;
symbolCbData.user = user;
char mask[] = "*";
SymEnumSymbols(fdProcessInfo->hProcess, base, mask, EnumSymbols, &symbolCbData);
}
@ -56,7 +56,7 @@ static BOOL CALLBACK EnumModules(LPCTSTR ModuleName, ULONG BaseOfDll, PVOID User
{
SYMBOLMODULEINFO curModule;
memset(&curModule, 0, sizeof(SYMBOLMODULEINFO));
curModule.base=BaseOfDll;
curModule.base = BaseOfDll;
modnamefromaddr(BaseOfDll, curModule.name, true);
((std::vector<SYMBOLMODULEINFO>*)UserContext)->push_back(curModule);
return TRUE;
@ -67,9 +67,9 @@ void symupdatemodulelist()
std::vector<SYMBOLMODULEINFO> modList;
modList.clear();
SymEnumerateModules(fdProcessInfo->hProcess, EnumModules, &modList);
int modcount=(int)modList.size();
SYMBOLMODULEINFO* modListBridge=(SYMBOLMODULEINFO*)BridgeAlloc(sizeof(SYMBOLMODULEINFO)*modcount);
for(int i=0; i<modcount; i++)
int modcount = (int)modList.size();
SYMBOLMODULEINFO* modListBridge = (SYMBOLMODULEINFO*)BridgeAlloc(sizeof(SYMBOLMODULEINFO) * modcount);
for(int i = 0; i < modcount; i++)
memcpy(&modListBridge[i], &modList.at(i), sizeof(SYMBOLMODULEINFO));
GuiSymbolUpdateModuleList(modcount, modListBridge);
}
@ -81,7 +81,7 @@ void symdownloadallsymbols(const char* szSymbolStore)
std::vector<SYMBOLMODULEINFO> modList;
modList.clear();
SymEnumerateModules(fdProcessInfo->hProcess, EnumModules, &modList);
int modcount=(int)modList.size();
int modcount = (int)modList.size();
if(!modcount)
return;
char szOldSearchPath[MAX_PATH] = "";
@ -97,7 +97,7 @@ void symdownloadallsymbols(const char* szSymbolStore)
dputs("SymSetSearchPath (1) failed!");
return;
}
for(int i=0; i<modcount; i++) //reload all modules
for(int i = 0; i < modcount; i++) //reload all modules
{
dprintf("downloading symbols for %s...\n", modList.at(i).name);
uint modbase = modList.at(i).base;
@ -134,21 +134,21 @@ bool symfromname(const char* name, uint* addr)
pSymbol->MaxNameLen = MAX_LABEL_SIZE;
if(!SymFromName(fdProcessInfo->hProcess, name, pSymbol))
return false;
*addr=(uint)pSymbol->Address;
*addr = (uint)pSymbol->Address;
return true;
}
const char* symgetsymbolicname(uint addr)
{
//[modname.]symbolname
static char symbolicname[MAX_MODULE_SIZE+MAX_SYM_NAME]="";
char label[MAX_SYM_NAME]="";
bool retval=false;
static char symbolicname[MAX_MODULE_SIZE + MAX_SYM_NAME] = "";
char label[MAX_SYM_NAME] = "";
bool retval = false;
if(labelget(addr, label)) //user labels have priority
retval=true;
retval = true;
else //no user labels
{
DWORD64 displacement=0;
DWORD64 displacement = 0;
char buffer[sizeof(SYMBOL_INFO) + MAX_LABEL_SIZE * sizeof(char)];
PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer;
pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
@ -157,12 +157,12 @@ const char* symgetsymbolicname(uint addr)
{
if(!settingboolget("Engine", "UndecorateSymbolNames") or !UnDecorateSymbolName(pSymbol->Name, label, MAX_SYM_NAME, UNDNAME_COMPLETE))
strcpy(label, pSymbol->Name);
retval=true;
retval = true;
}
}
if(retval)
{
char modname[MAX_MODULE_SIZE]="";
char modname[MAX_MODULE_SIZE] = "";
if(modnamefromaddr(addr, modname, false))
sprintf(symbolicname, "%s.%s", modname, label);
else

View File

@ -1,6 +1,6 @@
#include "main.h"
char global[10]="0";
char global[10] = "0";
// a sample exported function
void DLL_EXPORT SomeFunction(const LPCSTR sometext)
@ -10,14 +10,14 @@ void DLL_EXPORT SomeFunction(const LPCSTR sometext)
extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
{
GetTickCount();
GetCurrentProcessId();
GetCurrentProcess();
DWORD old=0;
DWORD old = 0;
VirtualProtect(global, 10, PAGE_GUARD, &old);
asm("int3");
}

View File

@ -1,20 +1,20 @@
#include <windows.h>
char global[10]="0";
char global[10] = "0";
int main()
{
GetTickCount();
char* a=0;
char* a = 0;
GetCurrentProcessId();
GetCurrentProcess();
DWORD old=0;
VirtualProtect(global, 0x1000, PAGE_READWRITE|PAGE_GUARD, &old);
DWORD old = 0;
VirtualProtect(global, 0x1000, PAGE_READWRITE | PAGE_GUARD, &old);
/*throw exceptions*/
global[0]=0; //PAGE_GUARD
*a=0; //ACCESS_VIOLATION
global[0] = 0; //PAGE_GUARD
*a = 0; //ACCESS_VIOLATION
asm("int3"); //BREAKPOINT
return 0;
}

View File

@ -3,35 +3,35 @@
typedef bool (*CBRET)();
unsigned int globalvar=0;
unsigned int globalvar = 0;
int main()
{
unsigned int lol;
unsigned char* page=(unsigned char*)VirtualAlloc(0, 0x1000, MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE);
unsigned char* page = (unsigned char*)VirtualAlloc(0, 0x1000, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
if(!page)
{
puts("error: VirtualAlloc");
return 1;
}
page[0]=0x6A;
page[0] = 0x6A;
puts("write");
page[1]=0x01;
page[1] = 0x01;
puts("write");
page[2]=0x58;
page[2] = 0x58;
puts("write");
page[3]=0xC3;
page[3] = 0xC3;
puts("write");
CBRET cb=(CBRET)page;
CBRET cb = (CBRET)page;
cb();
puts("exec");
lol=globalvar;
lol = globalvar;
puts("read");
lol=page[1];
lol = page[1];
puts("read");
lol=page[3];
lol = page[3];
puts("read");
lol=page[2];
lol = page[2];
puts("read");
return 0;
}

View File

@ -10,12 +10,12 @@ static int currentThread;
void threadcreate(CREATE_THREAD_DEBUG_INFO* CreateThread)
{
THREADINFO curInfo;
curInfo.ThreadNumber=threadNum;
curInfo.hThread=CreateThread->hThread;
curInfo.dwThreadId=((DEBUG_EVENT*)GetDebugData())->dwThreadId;
curInfo.ThreadStartAddress=(uint)CreateThread->lpStartAddress;
curInfo.ThreadLocalBase=(uint)CreateThread->lpThreadLocalBase;
*curInfo.threadName='\0';
curInfo.ThreadNumber = threadNum;
curInfo.hThread = CreateThread->hThread;
curInfo.dwThreadId = ((DEBUG_EVENT*)GetDebugData())->dwThreadId;
curInfo.ThreadStartAddress = (uint)CreateThread->lpStartAddress;
curInfo.ThreadLocalBase = (uint)CreateThread->lpThreadLocalBase;
*curInfo.threadName = '\0';
if(!threadNum)
strcpy(curInfo.threadName, "Main Thread");
threadList.push_back(curInfo);
@ -25,10 +25,10 @@ void threadcreate(CREATE_THREAD_DEBUG_INFO* CreateThread)
void threadexit(DWORD dwThreadId)
{
for(unsigned int i=0; i<threadList.size(); i++)
if(threadList.at(i).dwThreadId==dwThreadId)
for(unsigned int i = 0; i < threadList.size(); i++)
if(threadList.at(i).dwThreadId == dwThreadId)
{
threadList.erase(threadList.begin()+i);
threadList.erase(threadList.begin() + i);
break;
}
GuiUpdateThreadView();
@ -36,7 +36,7 @@ void threadexit(DWORD dwThreadId)
void threadclear()
{
threadNum=0;
threadNum = 0;
std::vector<THREADINFO>().swap(threadList);
GuiUpdateThreadView();
}
@ -57,61 +57,61 @@ static DWORD GetThreadLastError(uint tebAddress)
void threadgetlist(THREADLIST* list)
{
int count=(int)threadList.size();
list->count=count;
int count = (int)threadList.size();
list->count = count;
if(!count)
return;
list->list=(THREADALLINFO*)BridgeAlloc(count*sizeof(THREADALLINFO));
for(int i=0; i<count; i++)
list->list = (THREADALLINFO*)BridgeAlloc(count * sizeof(THREADALLINFO));
for(int i = 0; i < count; i++)
{
if(hActiveThread==threadList.at(i).hThread)
currentThread=i;
if(hActiveThread == threadList.at(i).hThread)
currentThread = i;
memset(&list->list[i], 0, sizeof(THREADALLINFO));
memcpy(&list->list[i].BasicInfo, &threadList.at(i), sizeof(THREADINFO));
HANDLE hThread=list->list[i].BasicInfo.hThread;
list->list[i].ThreadCip=GetContextDataEx(hThread, UE_CIP);
list->list[i].SuspendCount=SuspendThread(hThread);
HANDLE hThread = list->list[i].BasicInfo.hThread;
list->list[i].ThreadCip = GetContextDataEx(hThread, UE_CIP);
list->list[i].SuspendCount = SuspendThread(hThread);
ResumeThread(hThread);
list->list[i].Priority=(THREADPRIORITY)GetThreadPriority(list->list[i].BasicInfo.hThread);
list->list[i].WaitReason=GetThreadWaitReason(list->list[i].BasicInfo.dwThreadId);
list->list[i].LastError=GetThreadLastError(list->list[i].BasicInfo.ThreadLocalBase);
list->list[i].Priority = (THREADPRIORITY)GetThreadPriority(list->list[i].BasicInfo.hThread);
list->list[i].WaitReason = GetThreadWaitReason(list->list[i].BasicInfo.dwThreadId);
list->list[i].LastError = GetThreadLastError(list->list[i].BasicInfo.ThreadLocalBase);
}
list->CurrentThread=currentThread;
list->CurrentThread = currentThread;
}
bool threadisvalid(DWORD dwThreadId)
{
for(unsigned int i=0; i<threadList.size(); i++)
if(threadList.at(i).dwThreadId==dwThreadId)
for(unsigned int i = 0; i < threadList.size(); i++)
if(threadList.at(i).dwThreadId == dwThreadId)
return true;
return false;
}
bool threadsetname(DWORD dwThreadId, const char* name)
{
for(unsigned int i=0; i<threadList.size(); i++)
if(threadList.at(i).dwThreadId==dwThreadId)
for(unsigned int i = 0; i < threadList.size(); i++)
if(threadList.at(i).dwThreadId == dwThreadId)
{
if(name)
strcpy(threadList.at(i).threadName, name);
else
*threadList.at(i).threadName='\0';
*threadList.at(i).threadName = '\0';
}
return false;
}
HANDLE threadgethandle(DWORD dwThreadId)
{
for(unsigned int i=0; i<threadList.size(); i++)
if(threadList.at(i).dwThreadId==dwThreadId)
for(unsigned int i = 0; i < threadList.size(); i++)
if(threadList.at(i).dwThreadId == dwThreadId)
return threadList.at(i).hThread;
return 0;
}
DWORD threadgetid(HANDLE hThread)
{
for(unsigned int i=0; i<threadList.size(); i++)
if(threadList.at(i).hThread==hThread)
for(unsigned int i = 0; i < threadList.size(); i++)
if(threadList.at(i).hThread == hThread)
return threadList.at(i).dwThreadId;
return 0;
}

View File

@ -15,12 +15,12 @@ void wait(WAIT_ID id)
void lock(WAIT_ID id)
{
waitarray[id]=true;
waitarray[id] = true;
}
void unlock(WAIT_ID id)
{
waitarray[id]=false;
waitarray[id] = false;
}
bool waitislocked(WAIT_ID id)
@ -35,24 +35,24 @@ static void CriticalSectionInitializeLocks()
{
if(bInitDone)
return;
for(int i=0; i<LockLast; i++)
for(int i = 0; i < LockLast; i++)
InitializeCriticalSection(&locks[i]);
bInitDone=true;
bInitDone = true;
}
void CriticalSectionDeleteLocks()
{
if(!bInitDone)
return;
for(int i=0; i<LockLast; i++)
for(int i = 0; i < LockLast; i++)
DeleteCriticalSection(&locks[i]);
bInitDone=false;
bInitDone = false;
}
CriticalSectionLocker::CriticalSectionLocker(CriticalSectionLock lock)
{
CriticalSectionInitializeLocks(); //initialize critical sections
gLock=lock;
gLock = lock;
EnterCriticalSection(&locks[gLock]);
}

File diff suppressed because it is too large Load Diff

View File

@ -4,20 +4,20 @@ static VAR* vars;
static VAR* varfind(const char* name, VAR** link)
{
VAR* cur=vars;
VAR* cur = vars;
if(!cur)
return 0;
VAR* prev=0;
VAR* prev = 0;
while(cur)
{
if(arraycontains(cur->name, name))
{
if(link)
*link=prev;
*link = prev;
return cur;
}
prev=cur;
cur=cur->next;
prev = cur;
cur = cur->next;
}
return 0;
}
@ -38,15 +38,15 @@ static void varsetvalue(VAR* var, VAR_VALUE* value)
static bool varset(const char* name, VAR_VALUE* value, bool setreadonly)
{
char newname[deflen]="$";
int add=0;
if(*name=='$')
add=1;
strcat(newname, name+add);
VAR* found=varfind(newname, 0);
char newname[deflen] = "$";
int add = 0;
if(*name == '$')
add = 1;
strcat(newname, name + add);
VAR* found = varfind(newname, 0);
if(!found)
return false;
if(!setreadonly and (found->type==VAR_READONLY or found->type==VAR_HIDDEN))
if(!setreadonly and (found->type == VAR_READONLY or found->type == VAR_HIDDEN))
return false;
varsetvalue(found, value);
return true;
@ -54,7 +54,7 @@ static bool varset(const char* name, VAR_VALUE* value, bool setreadonly)
void varinit()
{
vars=(VAR*)emalloc(sizeof(VAR), "varinit:vars");
vars = (VAR*)emalloc(sizeof(VAR), "varinit:vars");
memset(vars, 0, sizeof(VAR));
//General variables
varnew("$res\1$result", 0, VAR_SYSTEM);
@ -75,13 +75,13 @@ void varinit()
void varfree()
{
VAR* cur=vars;
VAR* cur = vars;
while(cur)
{
efree(cur->name, "varfree:cur->name");
VAR* next=cur->next;
VAR* next = cur->next;
efree(cur, "varfree:cur");
cur=next;
cur = next;
}
}
@ -94,11 +94,11 @@ bool varnew(const char* name_, uint value, VAR_TYPE type)
{
if(!name_)
return false;
char* name=(char*)emalloc(strlen(name_)+2, "varnew:name");
if(*name_!='$')
char* name = (char*)emalloc(strlen(name_) + 2, "varnew:name");
if(*name_ != '$')
{
*name='$';
strcpy(name+1, name_);
*name = '$';
strcpy(name + 1, name_);
}
else
strcpy(name, name_);
@ -113,44 +113,44 @@ bool varnew(const char* name_, uint value, VAR_TYPE type)
return false;
}
VAR* var;
bool nonext=false;
bool nonext = false;
if(!vars->name)
{
nonext=true;
var=vars;
nonext = true;
var = vars;
}
else
var=(VAR*)emalloc(sizeof(VAR), "varnew:var");
var = (VAR*)emalloc(sizeof(VAR), "varnew:var");
memset(var, 0, sizeof(VAR));
var->name=name;
var->type=type;
var->name = name;
var->type = type;
VAR_VALUE varvalue;
varvalue.size=sizeof(uint);
varvalue.type=VAR_UINT;
varvalue.u.value=value;
varvalue.size = sizeof(uint);
varvalue.type = VAR_UINT;
varvalue.u.value = value;
varsetvalue(var, &varvalue);
if(!nonext)
{
VAR* cur=vars;
VAR* cur = vars;
while(cur->next)
cur=cur->next;
cur->next=var;
cur = cur->next;
cur->next = var;
}
return true;
}
static bool varget(const char* name, VAR_VALUE* value, int* size, VAR_TYPE* type)
{
char newname[deflen]="$";
int add=0;
if(*name=='$')
add=1;
strcat(newname, name+add);
VAR* found=varfind(newname, 0);
char newname[deflen] = "$";
int add = 0;
if(*name == '$')
add = 1;
strcat(newname, name + add);
VAR* found = varfind(newname, 0);
if(!found or !value or !size or !type)
return false;
*type=found->type;
*size=found->value.size;
*type = found->type;
*size = found->value.size;
memcpy(value, &found->value, sizeof(VAR_VALUE));
return true;
}
@ -160,15 +160,15 @@ bool varget(const char* name, uint* value, int* size, VAR_TYPE* type)
VAR_VALUE varvalue;
int varsize;
VAR_TYPE vartype;
if(!varget(name, &varvalue, &varsize, &vartype) or varvalue.type!=VAR_UINT)
if(!varget(name, &varvalue, &varsize, &vartype) or varvalue.type != VAR_UINT)
return false;
if(size)
*size=varsize;
*size = varsize;
if(!value && size)
return true; //variable was valid, just get the size
if(type)
*type=vartype;
*value=varvalue.u.value;
*type = vartype;
*value = varvalue.u.value;
return true;
}
@ -177,14 +177,14 @@ bool varget(const char* name, char* string, int* size, VAR_TYPE* type)
VAR_VALUE varvalue;
int varsize;
VAR_TYPE vartype;
if(!varget(name, &varvalue, &varsize, &vartype) or varvalue.type!=VAR_STRING)
if(!varget(name, &varvalue, &varsize, &vartype) or varvalue.type != VAR_STRING)
return false;
if(size)
*size=varsize;
*size = varsize;
if(!string && size)
return true; //variable was valid, just get the size
if(type)
*type=vartype;
*type = vartype;
memcpy(string, &varvalue.u.data->front(), varsize);
return true;
}
@ -192,9 +192,9 @@ bool varget(const char* name, char* string, int* size, VAR_TYPE* type)
bool varset(const char* name, uint value, bool setreadonly)
{
VAR_VALUE varvalue;
varvalue.size=sizeof(uint);
varvalue.type=VAR_UINT;
varvalue.u.value=value;
varvalue.size = sizeof(uint);
varvalue.type = VAR_UINT;
varvalue.u.value = value;
varset(name, &varvalue, setreadonly);
return true;
}
@ -202,10 +202,10 @@ bool varset(const char* name, uint value, bool setreadonly)
bool varset(const char* name, const char* string, bool setreadonly)
{
VAR_VALUE varvalue;
int size=(int)strlen(string);
varvalue.size=size;
varvalue.type=VAR_STRING;
varvalue.u.data=new std::vector<unsigned char>;
int size = (int)strlen(string);
varvalue.size = size;
varvalue.type = VAR_STRING;
varvalue.u.data = new std::vector<unsigned char>;
varvalue.u.data->resize(size);
memcpy(&varvalue.u.data->front(), string, size);
if(!varset(name, &varvalue, setreadonly))
@ -219,37 +219,37 @@ bool varset(const char* name, const char* string, bool setreadonly)
bool vardel(const char* name, bool delsystem)
{
char* name_=(char*)emalloc(strlen(name)+2, "vardel:name");
if(*name!='$')
char* name_ = (char*)emalloc(strlen(name) + 2, "vardel:name");
if(*name != '$')
{
*name_='$';
strcpy(name_+1, name);
*name_ = '$';
strcpy(name_ + 1, name);
}
else
strcpy(name_, name);
VAR* prev=0;
VAR* found=varfind(name_, &prev);
VAR* prev = 0;
VAR* found = varfind(name_, &prev);
efree(name_, "vardel:name");
if(!found)
return false;
VAR_TYPE type=found->type;
if(!delsystem and type!=VAR_USER)
VAR_TYPE type = found->type;
if(!delsystem and type != VAR_USER)
return false;
if(type==VAR_HIDDEN)
if(type == VAR_HIDDEN)
return false;
VAR_VALUE varvalue;
varvalue.size=sizeof(uint);
varvalue.type=VAR_UINT;
varvalue.u.value=0;
varvalue.size = sizeof(uint);
varvalue.type = VAR_UINT;
varvalue.u.value = 0;
varsetvalue(found, &varvalue);
efree(found->name, "vardel:found->name");
if(found==vars)
if(found == vars)
{
VAR* next=vars->next;
VAR* next = vars->next;
if(next)
{
memcpy(vars, vars->next, sizeof(VAR));
vars->next=next->next;
vars->next = next->next;
efree(next, "vardel:next");
}
else
@ -257,7 +257,7 @@ bool vardel(const char* name, bool delsystem)
}
else
{
prev->next=found->next;
prev->next = found->next;
efree(found, "vardel:found");
}
return true;
@ -265,17 +265,17 @@ bool vardel(const char* name, bool delsystem)
bool vargettype(const char* name, VAR_TYPE* type, VAR_VALUE_TYPE* valtype)
{
char newname[deflen]="$";
int add=0;
if(*name=='$')
add=1;
strcat(newname, name+add);
VAR* found=varfind(newname, 0);
char newname[deflen] = "$";
int add = 0;
if(*name == '$')
add = 1;
strcat(newname, name + add);
VAR* found = varfind(newname, 0);
if(!found)
return false;
if(valtype)
*valtype=found->value.type;
*valtype = found->value.type;
if(type)
*type=found->type;
*type = found->type;
return true;
}

View File

@ -6,10 +6,10 @@
//enums
enum VAR_TYPE
{
VAR_SYSTEM=1,
VAR_USER=2,
VAR_READONLY=3,
VAR_HIDDEN=4
VAR_SYSTEM = 1,
VAR_USER = 2,
VAR_READONLY = 3,
VAR_HIDDEN = 4
};
enum VAR_VALUE_TYPE

View File

@ -17,15 +17,15 @@
#include "_dbgfunctions.h"
#include "debugger_commands.h"
static MESSAGE_STACK* gMsgStack=0;
static COMMAND* command_list=0;
static HANDLE hCommandLoopThread=0;
static char alloctrace[MAX_PATH]="";
static MESSAGE_STACK* gMsgStack = 0;
static COMMAND* command_list = 0;
static HANDLE hCommandLoopThread = 0;
static char alloctrace[MAX_PATH] = "";
//Original code by Aurel from http://www.codeguru.com/cpp/w-p/win32/article.php/c1427/A-Simple-Win32-CommandLine-Parser.htm
static void commandlinefree(int argc, char** argv)
{
for(int i=0; i<argc; i++)
for(int i = 0; i < argc; i++)
efree(argv[i]);
efree(argv);
}
@ -34,13 +34,13 @@ static char** commandlineparse(int* argc)
{
if(!argc)
return NULL;
LPWSTR wcCommandLine=GetCommandLineW();
LPWSTR* argw=CommandLineToArgvW(wcCommandLine, argc);
char** argv=(char**)emalloc(sizeof(void*)*(*argc+1));
for(int i=0; i<*argc; i++)
LPWSTR wcCommandLine = GetCommandLineW();
LPWSTR* argw = CommandLineToArgvW(wcCommandLine, argc);
char** argv = (char**)emalloc(sizeof(void*) * (*argc + 1));
for(int i = 0; i < *argc; i++)
{
int bufSize=WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, argw[i], -1, NULL, 0, NULL, NULL);
argv[i]=(char*)emalloc(bufSize+1);
int bufSize = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, argw[i], -1, NULL, 0, NULL, NULL);
argv[i] = (char*)emalloc(bufSize + 1);
WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, argw[i], bufSize, argv[i], bufSize * sizeof(char), NULL, NULL);
}
LocalFree(argw);
@ -49,7 +49,7 @@ static char** commandlineparse(int* argc)
static CMDRESULT cbStrLen(int argc, char* argv[])
{
if(argc<2)
if(argc < 2)
{
dputs("not enough arguments!");
return STATUS_ERROR;
@ -66,7 +66,7 @@ static CMDRESULT cbCls(int argc, char* argv[])
static CMDRESULT cbPrintf(int argc, char* argv[])
{
if(argc<2)
if(argc < 2)
dprintf("\n");
else
dprintf("%s", argv[1]);
@ -75,7 +75,7 @@ static CMDRESULT cbPrintf(int argc, char* argv[])
static void registercommands()
{
COMMAND* cmd=command_list=cmdinit();
COMMAND* cmd = command_list = cmdinit();
//debug control
dbgcmdnew("InitDebug\1init\1initdbg", cbDebugInit, false); //init debugger arg1:exefile,[arg2:commandline]
@ -209,9 +209,9 @@ static bool cbCommandProvider(char* cmd, int maxlen)
{
MESSAGE msg;
msgwait(gMsgStack, &msg);
char* newcmd=(char*)msg.param1;
if(strlen(newcmd)>=deflen)
newcmd[deflen-1]=0;
char* newcmd = (char*)msg.param1;
if(strlen(newcmd) >= deflen)
newcmd[deflen - 1] = 0;
strcpy(cmd, newcmd);
efree(newcmd, "cbCommandProvider:newcmd"); //free allocated command
return true;
@ -219,8 +219,8 @@ static bool cbCommandProvider(char* cmd, int maxlen)
extern "C" DLL_EXPORT bool _dbg_dbgcmdexec(const char* cmd)
{
int len=(int)strlen(cmd);
char* newcmd=(char*)emalloc((len+1)*sizeof(char), "_dbg_dbgcmdexec:newcmd");
int len = (int)strlen(cmd);
char* newcmd = (char*)emalloc((len + 1) * sizeof(char), "_dbg_dbgcmdexec:newcmd");
strcpy(newcmd, cmd);
return msgsend(gMsgStack, 0, (uint)newcmd, 0);
}
@ -246,13 +246,13 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
dbginit();
dbgfunctionsinit();
json_set_alloc_funcs(emalloc_json, efree_json);
char dir[deflen]="";
char dir[deflen] = "";
if(!GetModuleFileNameA(hInst, dir, deflen))
return "GetModuleFileNameA failed!";
int len=(int)strlen(dir);
while(dir[len]!='\\')
int len = (int)strlen(dir);
while(dir[len] != '\\')
len--;
dir[len]=0;
dir[len] = 0;
strcpy(alloctrace, dir);
PathAppendA(alloctrace, "\\alloctrace.txt");
DeleteFileA(alloctrace);
@ -263,24 +263,24 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
strcpy(szSymbolCachePath, dir);
PathAppendA(szSymbolCachePath, "symbols");
SetCurrentDirectoryA(dir);
gMsgStack=msgallocstack();
gMsgStack = msgallocstack();
if(!gMsgStack)
return "Could not allocate message stack!";
varinit();
registercommands();
hCommandLoopThread=CreateThread(0, 0, DbgCommandLoopThread, 0, 0, 0);
char plugindir[deflen]="";
hCommandLoopThread = CreateThread(0, 0, DbgCommandLoopThread, 0, 0, 0);
char plugindir[deflen] = "";
strcpy(plugindir, dir);
PathAppendA(plugindir, "plugins");
pluginload(plugindir);
//handle command line
int argc=0;
char** argv=commandlineparse(&argc);
if(argc>1) //we have an argument
int argc = 0;
char** argv = commandlineparse(&argc);
if(argc > 1) //we have an argument
{
std::string str="init \"";
str+=argv[1];
str+="\"";
std::string str = "init \"";
str += argv[1];
str += "\"";
DbgCmdExec(str.c_str());
}
commandlinefree(argc, argv);
@ -301,9 +301,9 @@ extern "C" DLL_EXPORT void _dbg_dbgexitsignal()
msgfreestack(gMsgStack);
if(memleaks())
{
char msg[256]="";
char msg[256] = "";
sprintf(msg, "%d memory leak(s) found!\n\nPlease send 'alloctrace.txt' to the authors of x64_dbg.", memleaks());
MessageBoxA(0, msg, "error", MB_ICONERROR|MB_SYSTEMMODAL);
MessageBoxA(0, msg, "error", MB_ICONERROR | MB_SYSTEMMODAL);
}
else
DeleteFileA(alloctrace);
@ -312,7 +312,7 @@ extern "C" DLL_EXPORT void _dbg_dbgexitsignal()
extern "C" DLL_EXPORT bool _dbg_dbgcmddirectexec(const char* cmd)
{
if(cmddirectexec(command_list, cmd)==STATUS_ERROR)
if(cmddirectexec(command_list, cmd) == STATUS_ERROR)
return false;
return true;
}

View File

@ -4,16 +4,16 @@
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
const char* errormsg=BridgeInit();
const char* errormsg = BridgeInit();
if(errormsg)
{
MessageBoxA(0, errormsg, "BridgeInit Error", MB_ICONERROR|MB_SYSTEMMODAL);
MessageBoxA(0, errormsg, "BridgeInit Error", MB_ICONERROR | MB_SYSTEMMODAL);
return 1;
}
errormsg=BridgeStart();
errormsg = BridgeStart();
if(errormsg)
{
MessageBoxA(0, errormsg, "BridgeStart Error", MB_ICONERROR|MB_SYSTEMMODAL);
MessageBoxA(0, errormsg, "BridgeStart Error", MB_ICONERROR | MB_SYSTEMMODAL);
return 1;
}
return 0;

View File

@ -1,15 +1,15 @@
#include "AbstractTableView.h"
#include "Configuration.h"
AbstractTableView::AbstractTableView(QWidget *parent) : QAbstractScrollArea(parent)
AbstractTableView::AbstractTableView(QWidget* parent) : QAbstractScrollArea(parent)
{
// Class variable initialization
mTableOffset = 0;
mPrevTableOffset = mTableOffset + 1;
Header_t data;
data.isVisible=true;
data.height=20;
data.activeButtonIndex=-1;
data.isVisible = true;
data.height = 20;
data.activeButtonIndex = -1;
mHeader = data;
fontsUpdated();
@ -46,11 +46,11 @@ void AbstractTableView::colorsUpdatedSlot()
void AbstractTableView::colorsUpdated()
{
backgroundColor=ConfigColor("AbstractTableViewBackgroundColor");
textColor=ConfigColor("AbstractTableViewTextColor");
separatorColor=ConfigColor("AbstractTableViewSeparatorColor");
headerTextColor=ConfigColor("AbstractTableViewHeaderTextColor");
selectionColor=ConfigColor("AbstractTableViewSelectionColor");
backgroundColor = ConfigColor("AbstractTableViewBackgroundColor");
textColor = ConfigColor("AbstractTableViewTextColor");
separatorColor = ConfigColor("AbstractTableViewSeparatorColor");
headerTextColor = ConfigColor("AbstractTableViewHeaderTextColor");
selectionColor = ConfigColor("AbstractTableViewSelectionColor");
}
void AbstractTableView::fontsUpdatedSlot()
@ -106,7 +106,7 @@ void AbstractTableView::paintEvent(QPaintEvent* event)
wOpt.rect = QRect(x, y, getColumnWidth(i), getHeaderHeight());
mHeaderButtonSytle.style()->drawControl(QStyle::CE_PushButton, &wOpt, &wPainter,&mHeaderButtonSytle);
mHeaderButtonSytle.style()->drawControl(QStyle::CE_PushButton, &wOpt, &wPainter, &mHeaderButtonSytle);
wPainter.setPen(headerTextColor);
wPainter.drawText(QRect(x + 4, y, getColumnWidth(i) - 8, getHeaderHeight()), Qt::AlignVCenter | Qt::AlignLeft, mColumnList[i].title);
@ -164,7 +164,7 @@ void AbstractTableView::mouseMoveEvent(QMouseEvent* event)
{
// qDebug() << "mouseMoveEvent";
switch (mGuiState)
switch(mGuiState)
{
case AbstractTableView::NoState:
{
@ -196,7 +196,7 @@ void AbstractTableView::mouseMoveEvent(QMouseEvent* event)
mColResizeData.splitHandle = true;
mGuiState = AbstractTableView::ReadyToResize;
}
if ((wHandle == false) && (wHasCursor == true))
if((wHandle == false) && (wHasCursor == true))
{
unsetCursor();
mColResizeData.splitHandle = false;
@ -230,7 +230,7 @@ void AbstractTableView::mouseMoveEvent(QMouseEvent* event)
wHandle = false;
}
if ((wHandle == false) && (mGuiState == AbstractTableView::ReadyToResize))
if((wHandle == false) && (mGuiState == AbstractTableView::ReadyToResize))
{
unsetCursor();
mColResizeData.splitHandle = false;
@ -446,7 +446,7 @@ void AbstractTableView::keyPressEvent(QKeyEvent* event)
{
verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd);
}
else if(wKey==Qt::Key_Return || wKey==Qt::Key_Enter) //user pressed enter
else if(wKey == Qt::Key_Return || wKey == Qt::Key_Enter) //user pressed enter
emit enterPressedSignal();
}
@ -795,7 +795,7 @@ void AbstractTableView::addColumnAt(int width, QString title, bool isClickable)
void AbstractTableView::setRowCount(int_t count)
{
if(count> getViewableRowsCount())
if(count > getViewableRowsCount())
updateScrollBarRange(count);
mRowCount = count;
}
@ -901,7 +901,7 @@ void AbstractTableView::setNbrOfLineToPrint(int parNbrOfLineToPrint)
void AbstractTableView::setShowHeader(bool show)
{
mHeader.isVisible=show;
mHeader.isVisible = show;
}
int AbstractTableView::getCharWidth()

View File

@ -17,7 +17,7 @@ public:
enum GuiState_t {NoState, ReadyToResize, ResizeColumnState, HeaderButtonPressed};
// Constructor
explicit AbstractTableView(QWidget *parent = 0);
explicit AbstractTableView(QWidget* parent = 0);
//config updates
virtual void colorsUpdated();

View File

@ -1,7 +1,7 @@
#include "Disassembly.h"
#include "Configuration.h"
Disassembly::Disassembly(QWidget *parent) : AbstractTableView(parent)
Disassembly::Disassembly(QWidget* parent) : AbstractTableView(parent)
{
fontsUpdated();
mMemPage = new MemoryPage(0, 0);
@ -16,8 +16,8 @@ Disassembly::Disassembly(QWidget *parent) : AbstractTableView(parent)
mCipRva = 0;
mHighlightToken.text="";
mHighlightingMode=false;
mHighlightToken.text = "";
mHighlightingMode = false;
mDisasm = new QBeaEngine();
@ -27,14 +27,14 @@ Disassembly::Disassembly(QWidget *parent) : AbstractTableView(parent)
setRowCount(mMemPage->getSize());
addColumnAt(getCharWidth()*2*sizeof(int_t)+8, "", false); //address
addColumnAt(getCharWidth()*2*12+8, "", false); //bytes
addColumnAt(getCharWidth()*40, "", false); //disassembly
addColumnAt(getCharWidth() * 2 * sizeof(int_t) + 8, "", false); //address
addColumnAt(getCharWidth() * 2 * 12 + 8, "", false); //bytes
addColumnAt(getCharWidth() * 40, "", false); //disassembly
addColumnAt(100, "", false); //comments
setShowHeader(false); //hide header
backgroundColor=ConfigColor("DisassemblyBackgroundColor");
backgroundColor = ConfigColor("DisassemblyBackgroundColor");
connect(Bridge::getBridge(), SIGNAL(repaintGui()), this, SLOT(reloadData()));
}
@ -42,7 +42,7 @@ Disassembly::Disassembly(QWidget *parent) : AbstractTableView(parent)
void Disassembly::colorsUpdated()
{
AbstractTableView::colorsUpdated();
backgroundColor=ConfigColor("DisassemblyBackgroundColor");
backgroundColor = ConfigColor("DisassemblyBackgroundColor");
}
void Disassembly::fontsUpdated()
@ -76,7 +76,7 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
QPen pen(ConfigColor("InstructionHighlightColor"));
pen.setWidth(2);
painter->setPen(pen);
QRect rect=viewport()->rect();
QRect rect = viewport()->rect();
rect.adjust(1, 1, -1, -1);
painter->drawRect(rect);
}
@ -91,71 +91,71 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
{
case 0: // Draw address (+ label)
{
char label[MAX_LABEL_SIZE]="";
int_t cur_addr=rvaToVa(mInstBuffer.at(rowOffset).rva);
QString addrText="";
char label[MAX_LABEL_SIZE] = "";
int_t cur_addr = rvaToVa(mInstBuffer.at(rowOffset).rva);
QString addrText = "";
if(mRvaDisplayEnabled) //RVA display
{
int_t rva=cur_addr-mRvaDisplayBase;
int_t rva = cur_addr - mRvaDisplayBase;
if(rva == 0)
{
#ifdef _WIN64
addrText="$ ==> ";
addrText = "$ ==> ";
#else
addrText="$ ==> ";
addrText = "$ ==> ";
#endif //_WIN64
}
else if(rva > 0)
{
#ifdef _WIN64
addrText="$+"+QString("%1").arg(rva, -15, 16, QChar(' ')).toUpper();
addrText = "$+" + QString("%1").arg(rva, -15, 16, QChar(' ')).toUpper();
#else
addrText="$+"+QString("%1").arg(rva, -7, 16, QChar(' ')).toUpper();
addrText = "$+" + QString("%1").arg(rva, -7, 16, QChar(' ')).toUpper();
#endif //_WIN64
}
else if(rva < 0)
{
#ifdef _WIN64
addrText="$-"+QString("%1").arg(-rva, -15, 16, QChar(' ')).toUpper();
addrText = "$-" + QString("%1").arg(-rva, -15, 16, QChar(' ')).toUpper();
#else
addrText="$-"+QString("%1").arg(-rva, -7, 16, QChar(' ')).toUpper();
addrText = "$-" + QString("%1").arg(-rva, -7, 16, QChar(' ')).toUpper();
#endif //_WIN64
}
}
addrText += QString("%1").arg(cur_addr, sizeof(int_t)*2, 16, QChar('0')).toUpper();
addrText += QString("%1").arg(cur_addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
if(DbgGetLabelAt(cur_addr, SEG_DEFAULT, label)) //has label
{
char module[MAX_MODULE_SIZE]="";
char module[MAX_MODULE_SIZE] = "";
if(DbgGetModuleAt(cur_addr, module) && !QString(label).startsWith("JMP.&"))
addrText+=" <"+QString(module)+"."+QString(label)+">";
addrText += " <" + QString(module) + "." + QString(label) + ">";
else
addrText+=" <"+QString(label)+">";
addrText += " <" + QString(label) + ">";
}
else
*label=0;
BPXTYPE bpxtype=DbgGetBpxTypeAt(cur_addr);
bool isbookmark=DbgGetBookmarkAt(cur_addr);
*label = 0;
BPXTYPE bpxtype = DbgGetBpxTypeAt(cur_addr);
bool isbookmark = DbgGetBookmarkAt(cur_addr);
if(mInstBuffer.at(rowOffset).rva == mCipRva) //cip
{
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyCipBackgroundColor")));
if(!isbookmark) //no bookmark
{
if(bpxtype&bp_normal) //normal breakpoint
if(bpxtype & bp_normal) //normal breakpoint
{
QColor bpColor=ConfigColor("DisassemblyBreakpointBackgroundColor");
QColor bpColor = ConfigColor("DisassemblyBreakpointBackgroundColor");
if(!bpColor.alpha()) //we don't want transparent text
bpColor=ConfigColor("DisassemblyBreakpointColor");
if(bpColor==ConfigColor("DisassemblyCipBackgroundColor"))
bpColor=ConfigColor("DisassemblyCipColor");
bpColor = ConfigColor("DisassemblyBreakpointColor");
if(bpColor == ConfigColor("DisassemblyCipBackgroundColor"))
bpColor = ConfigColor("DisassemblyCipColor");
painter->setPen(QPen(bpColor));
}
else if(bpxtype&bp_hardware) //hardware breakpoint only
else if(bpxtype & bp_hardware) //hardware breakpoint only
{
QColor hwbpColor=ConfigColor("DisassemblyHardwareBreakpointBackgroundColor");
QColor hwbpColor = ConfigColor("DisassemblyHardwareBreakpointBackgroundColor");
if(!hwbpColor.alpha()) //we don't want transparent text
hwbpColor=ConfigColor("DisassemblyHardwareBreakpointColor");
if(hwbpColor==ConfigColor("DisassemblyCipBackgroundColor"))
hwbpColor=ConfigColor("DisassemblyCipColor");
hwbpColor = ConfigColor("DisassemblyHardwareBreakpointColor");
if(hwbpColor == ConfigColor("DisassemblyCipBackgroundColor"))
hwbpColor = ConfigColor("DisassemblyCipColor");
painter->setPen(hwbpColor);
}
else //no breakpoint
@ -165,11 +165,11 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
}
else //bookmark
{
QColor bookmarkColor=ConfigColor("DisassemblyBookmarkBackgroundColor");
QColor bookmarkColor = ConfigColor("DisassemblyBookmarkBackgroundColor");
if(!bookmarkColor.alpha()) //we don't want transparent text
bookmarkColor=ConfigColor("DisassemblyBookmarkColor");
if(bookmarkColor==ConfigColor("DisassemblyCipBackgroundColor"))
bookmarkColor=ConfigColor("DisassemblyCipColor");
bookmarkColor = ConfigColor("DisassemblyBookmarkColor");
if(bookmarkColor == ConfigColor("DisassemblyCipBackgroundColor"))
bookmarkColor = ConfigColor("DisassemblyCipColor");
painter->setPen(QPen(bookmarkColor));
}
}
@ -179,19 +179,19 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
{
if(*label) //label
{
if(bpxtype==bp_none) //label only
if(bpxtype == bp_none) //label only
{
painter->setPen(QPen(ConfigColor("DisassemblyLabelColor"))); //red -> address + label text
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyLabelBackgroundColor"))); //fill label background
}
else //label+breakpoint
{
if(bpxtype&bp_normal) //label + normal breakpoint
if(bpxtype & bp_normal) //label + normal breakpoint
{
painter->setPen(QPen(ConfigColor("DisassemblyBreakpointColor")));
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyBreakpointBackgroundColor"))); //fill red
}
else if(bpxtype&bp_hardware) //label + hardware breakpoint only
else if(bpxtype & bp_hardware) //label + hardware breakpoint only
{
painter->setPen(QPen(ConfigColor("DisassemblyHardwareBreakpointColor")));
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyHardwareBreakpointBackgroundColor"))); //fill ?
@ -205,17 +205,17 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
}
else //no label
{
if(bpxtype==bp_none) //no label, no breakpoint
if(bpxtype == bp_none) //no label, no breakpoint
{
QColor background;
if(wIsSelected)
{
background=ConfigColor("DisassemblySelectedAddressBackgroundColor");
background = ConfigColor("DisassemblySelectedAddressBackgroundColor");
painter->setPen(QPen(ConfigColor("DisassemblySelectedAddressColor"))); //black address (DisassemblySelectedAddressColor)
}
else
{
background=ConfigColor("DisassemblyAddressBackgroundColor");
background = ConfigColor("DisassemblyAddressBackgroundColor");
painter->setPen(QPen(ConfigColor("DisassemblyAddressColor"))); //DisassemblyAddressColor
}
if(background.alpha())
@ -223,12 +223,12 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
}
else //breakpoint only
{
if(bpxtype&bp_normal) //normal breakpoint
if(bpxtype & bp_normal) //normal breakpoint
{
painter->setPen(QPen(ConfigColor("DisassemblyBreakpointColor")));
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyBreakpointBackgroundColor"))); //fill red
}
else if(bpxtype&bp_hardware) //hardware breakpoint only
else if(bpxtype & bp_hardware) //hardware breakpoint only
{
painter->setPen(QPen(ConfigColor("DisassemblyHardwareBreakpointColor")));
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyHardwareBreakpointBackgroundColor"))); //fill red
@ -238,12 +238,12 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
QColor background;
if(wIsSelected)
{
background=ConfigColor("DisassemblySelectedAddressBackgroundColor");
background = ConfigColor("DisassemblySelectedAddressBackgroundColor");
painter->setPen(QPen(ConfigColor("DisassemblySelectedAddressColor"))); //black address (DisassemblySelectedAddressColor)
}
else
{
background=ConfigColor("DisassemblyAddressBackgroundColor");
background = ConfigColor("DisassemblyAddressBackgroundColor");
painter->setPen(QPen(ConfigColor("DisassemblyAddressColor")));
}
if(background.alpha())
@ -256,22 +256,22 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
{
if(*label) //label + bookmark
{
if(bpxtype==bp_none) //label + bookmark
if(bpxtype == bp_none) //label + bookmark
{
painter->setPen(QPen(ConfigColor("DisassemblyLabelColor"))); //red -> address + label text
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyBookmarkBackgroundColor"))); //fill label background
}
else //label+breakpoint+bookmark
{
QColor color=ConfigColor("DisassemblyBookmarkBackgroundColor");
QColor color = ConfigColor("DisassemblyBookmarkBackgroundColor");
if(!color.alpha()) //we don't want transparent text
color=ConfigColor("DisassemblyAddressColor");
color = ConfigColor("DisassemblyAddressColor");
painter->setPen(QPen(color));
if(bpxtype&bp_normal) //label + bookmark + normal breakpoint
if(bpxtype & bp_normal) //label + bookmark + normal breakpoint
{
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyBreakpointBackgroundColor"))); //fill red
}
else if(bpxtype&bp_hardware) //label + bookmark + hardware breakpoint only
else if(bpxtype & bp_hardware) //label + bookmark + hardware breakpoint only
{
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyHardwareBreakpointBackgroundColor"))); //fill ?
}
@ -279,22 +279,22 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
}
else //bookmark, no label
{
if(bpxtype==bp_none) //bookmark only
if(bpxtype == bp_none) //bookmark only
{
painter->setPen(QPen(ConfigColor("DisassemblyBookmarkColor"))); //black address
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyBookmarkBackgroundColor"))); //fill bookmark color
}
else //bookmark + breakpoint
{
QColor color=ConfigColor("DisassemblyBookmarkBackgroundColor");
QColor color = ConfigColor("DisassemblyBookmarkBackgroundColor");
if(!color.alpha()) //we don't want transparent text
color=ConfigColor("DisassemblyAddressColor");
color = ConfigColor("DisassemblyAddressColor");
painter->setPen(QPen(color));
if(bpxtype&bp_normal) //bookmark + normal breakpoint
if(bpxtype & bp_normal) //bookmark + normal breakpoint
{
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyBreakpointBackgroundColor"))); //fill red
}
else if(bpxtype&bp_hardware) //bookmark + hardware breakpoint only
else if(bpxtype & bp_hardware) //bookmark + hardware breakpoint only
{
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyHardwareBreakpointBackgroundColor"))); //fill red
}
@ -314,28 +314,28 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
case 1: //draw bytes (TODO: some spaces between bytes)
{
//draw functions
int_t cur_addr=rvaToVa(mInstBuffer.at(rowOffset).rva);
int_t cur_addr = rvaToVa(mInstBuffer.at(rowOffset).rva);
Function_t funcType;
FUNCTYPE funcFirst = DbgGetFunctionTypeAt(cur_addr);
FUNCTYPE funcLast = DbgGetFunctionTypeAt(cur_addr+mInstBuffer.at(rowOffset).lentgh - 1);
FUNCTYPE funcLast = DbgGetFunctionTypeAt(cur_addr + mInstBuffer.at(rowOffset).lentgh - 1);
if(funcLast == FUNC_END)
funcFirst = funcLast;
switch(funcFirst)
{
case FUNC_SINGLE:
funcType=Function_single;
funcType = Function_single;
break;
case FUNC_NONE:
funcType=Function_none;
funcType = Function_none;
break;
case FUNC_BEGIN:
funcType=Function_start;
funcType = Function_start;
break;
case FUNC_MIDDLE:
funcType=Function_middle;
funcType = Function_middle;
break;
case FUNC_END:
funcType=Function_end;
funcType = Function_end;
break;
}
int funcsize = paintFunctionGraphic(painter, x, y, funcType, false);
@ -348,16 +348,16 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
QColor patchedBytesColor = ConfigColor("DisassemblyModifiedBytesColor");
QList<RichTextPainter::CustomRichText_t> richBytes;
RichTextPainter::CustomRichText_t space;
space.highlight=false;
space.flags=RichTextPainter::FlagNone;
space.text=" ";
space.highlight = false;
space.flags = RichTextPainter::FlagNone;
space.text = " ";
RichTextPainter::CustomRichText_t curByte;
curByte.highlight = false;
curByte.flags = RichTextPainter::FlagColor;
for(int i=0; i<mInstBuffer.at(rowOffset).dump.size(); i++)
for(int i = 0; i < mInstBuffer.at(rowOffset).dump.size(); i++)
{
curByte.text = QString("%1").arg((unsigned char)(mInstBuffer.at(rowOffset).dump.at(i)), 2, 16, QChar('0')).toUpper();
curByte.textColor = DbgFunctions()->PatchGet(cur_addr+i) ? patchedBytesColor : bytesColor;
curByte.textColor = DbgFunctions()->PatchGet(cur_addr + i) ? patchedBytesColor : bytesColor;
richBytes.push_back(curByte);
richBytes.push_back(space);
}
@ -367,35 +367,35 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
case 2: //draw disassembly (with colours needed)
{
int_t cur_addr=rvaToVa(mInstBuffer.at(rowOffset).rva);
int loopsize=0;
int depth=0;
int_t cur_addr = rvaToVa(mInstBuffer.at(rowOffset).rva);
int loopsize = 0;
int depth = 0;
while(1) //paint all loop depths
{
LOOPTYPE loopType=DbgGetLoopTypeAt(cur_addr, depth);
if(loopType==LOOP_NONE)
LOOPTYPE loopType = DbgGetLoopTypeAt(cur_addr, depth);
if(loopType == LOOP_NONE)
break;
Function_t funcType;
switch(loopType)
{
case LOOP_NONE:
funcType=Function_none;
funcType = Function_none;
break;
case LOOP_BEGIN:
funcType=Function_start;
funcType = Function_start;
break;
case LOOP_ENTRY:
funcType=Function_loop_entry;
funcType = Function_loop_entry;
break;
case LOOP_MIDDLE:
funcType=Function_middle;
funcType = Function_middle;
break;
case LOOP_END:
funcType=Function_end;
funcType = Function_end;
break;
}
loopsize+=paintFunctionGraphic(painter, x+loopsize, y, funcType, true);
loopsize += paintFunctionGraphic(painter, x + loopsize, y, funcType, true);
depth++;
}
@ -414,13 +414,13 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
case 3: //draw comments
{
char comment[MAX_COMMENT_SIZE]="";
char comment[MAX_COMMENT_SIZE] = "";
if(DbgGetCommentAt(rvaToVa(mInstBuffer.at(rowOffset).rva), comment))
{
painter->setPen(ConfigColor("DisassemblyCommentColor"));
int width = getCharWidth() * QString(comment).length() + 4;
if(width > w)
width=w;
width = w;
if(width)
painter->fillRect(QRect(x + 2, y, width, h), QBrush(ConfigColor("DisassemblyCommentBackgroundColor"))); //fill bookmark color
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, QString(comment));
@ -472,9 +472,9 @@ void Disassembly::mouseMoveEvent(QMouseEvent* event)
if(wRowIndex < getRowCount())
{
setSingleSelection(getInitialSelection());
expandSelectionUpTo(getInstructionRVA(getInitialSelection(), 1)-1);
expandSelectionUpTo(getInstructionRVA(getInitialSelection(), 1) - 1);
if(wRowIndex > getInitialSelection()) //select down
expandSelectionUpTo(wRowIndex+wInstrSize);
expandSelectionUpTo(wRowIndex + wInstrSize);
else
expandSelectionUpTo(wRowIndex);
@ -511,23 +511,23 @@ void Disassembly::mousePressEvent(QMouseEvent* event)
{
if(getColumnIndexFromX(event->x()) == 2) //click in instruction column
{
int rowOffset=getIndexOffsetFromY(transY(event->y()));
if(rowOffset<mInstBuffer.size())
int rowOffset = getIndexOffsetFromY(transY(event->y()));
if(rowOffset < mInstBuffer.size())
{
BeaTokenizer::BeaSingleToken token;
if(BeaTokenizer::TokenFromX(&mInstBuffer.at(rowOffset).tokens, &token, event->x(), getCharWidth()))
{
if(BeaTokenizer::IsHighlightableToken(&token) && !BeaTokenizer::TokenEquals(&token, &mHighlightToken))
mHighlightToken=token;
mHighlightToken = token;
else
mHighlightToken.text="";
mHighlightToken.text = "";
}
else
mHighlightToken.text="";
mHighlightToken.text = "";
}
}
else
mHighlightToken.text="";
mHighlightToken.text = "";
}
else if(event->y() > getHeaderHeight())
{
@ -541,13 +541,13 @@ void Disassembly::mousePressEvent(QMouseEvent* event)
if(getSelectionStart() > wRowIndex) //select up
{
setSingleSelection(getInitialSelection());
expandSelectionUpTo(getInstructionRVA(getInitialSelection(), 1)-1);
expandSelectionUpTo(getInstructionRVA(getInitialSelection(), 1) - 1);
expandSelectionUpTo(wRowIndex);
}
else //select down
{
setSingleSelection(getInitialSelection());
expandSelectionUpTo(wRowIndex+wInstrSize);
expandSelectionUpTo(wRowIndex + wInstrSize);
}
mGuiState = Disassembly::MultiRowsSelectionState;
@ -613,9 +613,9 @@ void Disassembly::keyPressEvent(QKeyEvent* event)
int_t botRVA = getTableOffset();
int_t topRVA = getInstructionRVA(getTableOffset(), getNbrOfLineToPrint() - 1);
bool expand=false;
bool expand = false;
if(event->modifiers() & Qt::ShiftModifier) //SHIFT pressed
expand=true;
expand = true;
if(key == Qt::Key_Up)
selectPrevious(expand);
@ -628,7 +628,7 @@ void Disassembly::keyPressEvent(QKeyEvent* event)
}
else if(getSelectionEnd() >= topRVA)
{
setTableOffset(getInstructionRVA(getSelectionEnd(),-getNbrOfLineToPrint() + 2));
setTableOffset(getInstructionRVA(getSelectionEnd(), -getNbrOfLineToPrint() + 2));
}
repaint();
@ -638,7 +638,7 @@ void Disassembly::keyPressEvent(QKeyEvent* event)
uint_t dest = DbgGetBranchDestination(rvaToVa(getInitialSelection()));
if(!dest)
return;
QString cmd="disasm "+QString("%1").arg(dest, sizeof(int_t)*2, 16, QChar('0')).toUpper();
QString cmd = "disasm " + QString("%1").arg(dest, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(cmd.toUtf8().constData());
}
else
@ -708,11 +708,11 @@ int Disassembly::paintJumpsGraphic(QPainter* painter, int x, int y, int_t addr)
GraphicDump_t wPict = GD_Nothing;
if(branchType && branchType!=RetType && branchType!=CallType)
if(branchType && branchType != RetType && branchType != CallType)
{
int_t destRVA = (int_t)DbgGetBranchDestination(rvaToVa(instruction.rva));
int_t base=mMemPage->getBase();
int_t base = mMemPage->getBase();
if(destRVA >= base && destRVA < base + (int_t)mMemPage->getSize())
{
destRVA -= (int_t)mMemPage->getBase();
@ -738,9 +738,9 @@ int Disassembly::paintJumpsGraphic(QPainter* painter, int x, int y, int_t addr)
}
}
bool bIsExecute=DbgIsJumpGoingToExecute(rvaToVa(instruction.rva));
bool bIsExecute = DbgIsJumpGoingToExecute(rvaToVa(instruction.rva));
if(branchType==JmpType) //unconditional
if(branchType == JmpType) //unconditional
{
painter->setPen(ConfigColor("DisassemblyUnconditionalJumpLineColor"));
}
@ -812,66 +812,66 @@ int Disassembly::paintJumpsGraphic(QPainter* painter, int x, int y, int_t addr)
int Disassembly::paintFunctionGraphic(QPainter* painter, int x, int y, Function_t funcType, bool loop)
{
if(loop && funcType==Function_none)
if(loop && funcType == Function_none)
return 0;
painter->setPen(QPen(Qt::black, 2)); //thick black line
int height=getRowHeight();
int x_add=5;
int y_add=4;
int end_add=2;
int line_width=3;
int height = getRowHeight();
int x_add = 5;
int y_add = 4;
int end_add = 2;
int line_width = 3;
if(loop)
{
end_add=-1;
x_add=4;
end_add = -1;
x_add = 4;
}
switch(funcType)
{
case Function_single:
{
if(loop)
y_add=height/2+1;
painter->drawLine(x+x_add+line_width, y+y_add, x+x_add, y+y_add);
painter->drawLine(x+x_add, y+y_add, x+x_add, y+height-y_add-1);
y_add = height / 2 + 1;
painter->drawLine(x + x_add + line_width, y + y_add, x + x_add, y + y_add);
painter->drawLine(x + x_add, y + y_add, x + x_add, y + height - y_add - 1);
if(loop)
y_add=height/2-1;
painter->drawLine(x+x_add, y+height-y_add, x+x_add+line_width, y+height-y_add);
y_add = height / 2 - 1;
painter->drawLine(x + x_add, y + height - y_add, x + x_add + line_width, y + height - y_add);
}
break;
case Function_start:
{
if(loop)
y_add=height/2+1;
painter->drawLine(x+x_add+line_width, y+y_add, x+x_add, y+y_add);
painter->drawLine(x+x_add, y+y_add, x+x_add, y+height);
y_add = height / 2 + 1;
painter->drawLine(x + x_add + line_width, y + y_add, x + x_add, y + y_add);
painter->drawLine(x + x_add, y + y_add, x + x_add, y + height);
}
break;
case Function_middle:
{
painter->drawLine(x+x_add, y, x+x_add, y+height);
painter->drawLine(x + x_add, y, x + x_add, y + height);
}
break;
case Function_loop_entry:
{
int trisize=2;
int y_start=(height-trisize*2)/2+y;
painter->drawLine(x+x_add, y_start, x+trisize+x_add, y_start+trisize);
painter->drawLine(x+trisize+x_add, y_start+trisize, x+x_add, y_start+trisize*2);
int trisize = 2;
int y_start = (height - trisize * 2) / 2 + y;
painter->drawLine(x + x_add, y_start, x + trisize + x_add, y_start + trisize);
painter->drawLine(x + trisize + x_add, y_start + trisize, x + x_add, y_start + trisize * 2);
painter->drawLine(x+x_add, y, x+x_add, y_start-1);
painter->drawLine(x+x_add, y_start+trisize*2+2, x+x_add, y+height);
painter->drawLine(x + x_add, y, x + x_add, y_start - 1);
painter->drawLine(x + x_add, y_start + trisize * 2 + 2, x + x_add, y + height);
}
break;
case Function_end:
{
if(loop)
y_add=height/2-1;
painter->drawLine(x+x_add, y, x+x_add, y+height-y_add);
painter->drawLine(x+x_add, y+height-y_add, x+x_add+line_width, y+height-y_add);
y_add = height / 2 - 1;
painter->drawLine(x + x_add, y, x + x_add, y + height - y_add);
painter->drawLine(x + x_add, y + height - y_add, x + x_add + line_width, y + height - y_add);
}
break;
@ -881,7 +881,7 @@ int Disassembly::paintFunctionGraphic(QPainter* painter, int x, int y, Function_
}
break;
}
return x_add+line_width+end_add;
return x_add + line_width + end_add;
}
@ -1000,7 +1000,7 @@ Instruction_t Disassembly::DisassembleAt(int_t rva)
//TODO: fix problems with negative sizes
int_t size = getSize();
if(!size)
size=rva;
size = rva;
wMaxByteCountToRead = wMaxByteCountToRead > (size - rva) ? (size - rva) : wMaxByteCountToRead;
@ -1079,10 +1079,10 @@ int_t Disassembly::getSelectionEnd()
void Disassembly::selectNext(bool expand)
{
int_t wAddr;
int_t wStart = getInstructionRVA(getSelectionStart(), 1)-1;
int_t wStart = getInstructionRVA(getSelectionStart(), 1) - 1;
if(expand)
{
if(getSelectionEnd()==getInitialSelection() && wStart!=getSelectionEnd()) //decrease down
if(getSelectionEnd() == getInitialSelection() && wStart != getSelectionEnd()) //decrease down
{
wAddr = getInstructionRVA(getSelectionStart(), 1);
expandSelectionUpTo(wAddr);
@ -1107,10 +1107,10 @@ void Disassembly::selectNext(bool expand)
void Disassembly::selectPrevious(bool expand)
{
int_t wAddr;
int_t wStart = getInstructionRVA(getSelectionStart(), 1)-1;
int_t wStart = getInstructionRVA(getSelectionStart(), 1) - 1;
if(expand)
{
if(getSelectionStart()==getInitialSelection() && wStart!=getSelectionEnd()) //decrease up
if(getSelectionStart() == getInitialSelection() && wStart != getSelectionEnd()) //decrease up
{
wAddr = getInstructionRVA(getSelectionEnd() + 1, -2);
int_t wInstrSize = getInstructionRVA(wAddr, 1) - wAddr - 1;
@ -1118,7 +1118,7 @@ void Disassembly::selectPrevious(bool expand)
}
else //expand up
{
wAddr = getInstructionRVA(wStart+1, -2);
wAddr = getInstructionRVA(wStart + 1, -2);
expandSelectionUpTo(wAddr);
}
}
@ -1236,15 +1236,15 @@ void Disassembly::disassembleAt(int_t parVA, int_t parCIP, bool history, int_t n
if(history)
{
//truncate everything right from the current VA
if(mVaHistory.size() && mCurrentVa<mVaHistory.size()-1) //mCurrentVa is not the last
mVaHistory.erase(mVaHistory.begin()+mCurrentVa+1, mVaHistory.end());
if(mVaHistory.size() && mCurrentVa < mVaHistory.size() - 1) //mCurrentVa is not the last
mVaHistory.erase(mVaHistory.begin() + mCurrentVa + 1, mVaHistory.end());
//NOTE: mCurrentVa always points to the last entry of the list
//add the currently selected address to the history
int_t selectionVA=rvaToVa(getInitialSelection()); //currently selected VA
int_t selectionTableOffset=getTableOffset();
if(selectionVA && mVaHistory.size() && mVaHistory.last().va!=selectionVA) //do not have 2x the same va in a row
int_t selectionVA = rvaToVa(getInitialSelection()); //currently selected VA
int_t selectionTableOffset = getTableOffset();
if(selectionVA && mVaHistory.size() && mVaHistory.last().va != selectionVA) //do not have 2x the same va in a row
{
if(mVaHistory.size() >= 1024) //max 1024 in the history
{
@ -1252,8 +1252,8 @@ void Disassembly::disassembleAt(int_t parVA, int_t parCIP, bool history, int_t n
mVaHistory.erase(mVaHistory.begin()); //remove the oldest element
}
mCurrentVa++;
newHistory.va=selectionVA;
newHistory.tableOffset=selectionTableOffset;
newHistory.va = selectionVA;
newHistory.tableOffset = selectionTableOffset;
mVaHistory.push_back(newHistory);
}
}
@ -1273,7 +1273,7 @@ void Disassembly::disassembleAt(int_t parVA, int_t parCIP, bool history, int_t n
//set CIP rva
mCipRva = wCipRva;
if(newTableOffset==-1) //nothing specified
if(newTableOffset == -1) //nothing specified
{
// Update table offset depending on the location of the instruction to disassemble
if(mInstBuffer.size() > 0 && wRVA >= (int_t)mInstBuffer.first().rva && wRVA < (int_t)mInstBuffer.last().rva)
@ -1312,11 +1312,11 @@ void Disassembly::disassembleAt(int_t parVA, int_t parCIP, bool history, int_t n
if(history)
{
//new disassembled address
newHistory.va=parVA;
newHistory.tableOffset=getTableOffset();
newHistory.va = parVA;
newHistory.tableOffset = getTableOffset();
if(mVaHistory.size())
{
if(mVaHistory.last().va!=parVA) //not 2x the same va in history
if(mVaHistory.last().va != parVA) //not 2x the same va in history
{
if(mVaHistory.size() >= 1024) //max 1024 in the history
{
@ -1368,8 +1368,8 @@ void Disassembly::disassembleAt(int_t parVA, int_t parCIP)
void Disassembly::disassembleClear()
{
mHighlightingMode=false;
mHighlightToken.text="";
mHighlightingMode = false;
mHighlightToken.text = "";
historyClear();
mMemPage->setAttributes(0, 0);
setRowCount(0);
@ -1379,7 +1379,7 @@ void Disassembly::disassembleClear()
void Disassembly::debugStateChangedSlot(DBGSTATE state)
{
if(state==stopped)
if(state == stopped)
{
disassembleClear();
}
@ -1412,7 +1412,7 @@ void Disassembly::historyPrevious()
void Disassembly::historyNext()
{
int size = mVaHistory.size();
if(!size || mCurrentVa >= mVaHistory.size()-1) //we are at the newest history entry
if(!size || mCurrentVa >= mVaHistory.size() - 1) //we are at the newest history entry
return;
mCurrentVa++;
disassembleAt(mVaHistory.at(mCurrentVa).va, rvaToVa(mCipRva), false, mVaHistory.at(mCurrentVa).tableOffset);
@ -1428,7 +1428,7 @@ bool Disassembly::historyHasPrevious()
bool Disassembly::historyHasNext()
{
int size = mVaHistory.size();
if(!size || mCurrentVa >= mVaHistory.size()-1) //we are at the newest history entry
if(!size || mCurrentVa >= mVaHistory.size() - 1) //we are at the newest history entry
return false;
return true;
}

View File

@ -15,7 +15,7 @@ class Disassembly : public AbstractTableView
{
Q_OBJECT
public:
explicit Disassembly(QWidget *parent = 0);
explicit Disassembly(QWidget* parent = 0);
void colorsUpdated();
void fontsUpdated();
@ -89,7 +89,7 @@ public:
//disassemble
void disassembleAt(int_t parVA, int_t parCIP, bool history, int_t newTableOffset);
QList<Instruction_t> *instructionsBuffer();
QList<Instruction_t>* instructionsBuffer();
const int_t baseAddress() const;
const int_t currentEIP() const;

View File

@ -7,7 +7,7 @@ class HeaderButton : public QWidget
{
Q_OBJECT
public:
explicit HeaderButton(QWidget *parent = 0);
explicit HeaderButton(QWidget* parent = 0);
void setGeometry(int x, int y, int w, int h);
signals:

View File

@ -1,7 +1,7 @@
#include "HexDump.h"
#include "Configuration.h"
HexDump::HexDump(QWidget *parent) : AbstractTableView(parent)
HexDump::HexDump(QWidget* parent) : AbstractTableView(parent)
{
fontsUpdated();
SelectionData_t data;
@ -16,9 +16,9 @@ HexDump::HexDump(QWidget *parent) : AbstractTableView(parent)
clearDescriptors();
backgroundColor=ConfigColor("HexDumpBackgroundColor");
textColor=ConfigColor("HexDumpTextColor");
selectionColor=ConfigColor("HexDumpSelectionColor");
backgroundColor = ConfigColor("HexDumpBackgroundColor");
textColor = ConfigColor("HexDumpTextColor");
selectionColor = ConfigColor("HexDumpSelectionColor");
connect(Bridge::getBridge(), SIGNAL(updateDump()), this, SLOT(reloadData()));
connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), this, SLOT(debugStateChanged(DBGSTATE)));
@ -27,9 +27,9 @@ HexDump::HexDump(QWidget *parent) : AbstractTableView(parent)
void HexDump::colorsUpdated()
{
AbstractTableView::colorsUpdated();
backgroundColor=ConfigColor("HexDumpBackgroundColor");
textColor=ConfigColor("HexDumpTextColor");
selectionColor=ConfigColor("HexDumpSelectionColor");
backgroundColor = ConfigColor("HexDumpBackgroundColor");
textColor = ConfigColor("HexDumpTextColor");
selectionColor = ConfigColor("HexDumpSelectionColor");
reloadData();
}
@ -322,7 +322,7 @@ void HexDump::getString(int col, int_t rva, QList<RichTextPainter::CustomRichTex
int maxLen = getStringMaxLength(mDescriptor.at(col).data);
QString append = " ";
if(!maxLen)
append="";
append = "";
if((rva + wI + wByteCount - 1) < (int_t)mMemPage->getSize())
wStr = toString(mDescriptor.at(col).data, (void*)(wData + wI * wByteCount)).rightJustified(maxLen, ' ') + append;
else
@ -443,8 +443,8 @@ QString HexDump::wordToString(uint16 word, WordViewMode_e mode)
case UnicodeWord:
{
QChar wChar((char)word&0xFF);
if(wChar.isPrint() == true && (word>>8)==0)
QChar wChar((char)word & 0xFF);
if(wChar.isPrint() == true && (word >> 8) == 0)
wStr = QString(wChar);
else
wStr = ".";
@ -500,7 +500,7 @@ QString HexDump::dwordToString(uint32 dword, DwordViewMode_e mode)
case FloatDword:
{
float* wPtr = (float*)&dword;
wStr = QString::number((double)*wPtr);
wStr = QString::number((double) * wPtr);
}
break;
@ -541,7 +541,7 @@ QString HexDump::qwordToString(uint64 qword, QwordViewMode_e mode)
case DoubleQword:
{
double* wPtr = (double*)&qword;
wStr = QString::number((double)*wPtr);
wStr = QString::number((double) * wPtr);
}
break;
@ -933,13 +933,13 @@ void HexDump::clearDescriptors()
{
deleteAllColumns();
mDescriptor.clear();
int charwidth=getCharWidth();
addColumnAt(8+charwidth*2*sizeof(uint_t), "Address", false); //address
int charwidth = getCharWidth();
addColumnAt(8 + charwidth * 2 * sizeof(uint_t), "Address", false); //address
}
void HexDump::debugStateChanged(DBGSTATE state)
{
if(state==stopped)
if(state == stopped)
{
mMemPage->setAttributes(0, 0);
setRowCount(0);

View File

@ -81,7 +81,7 @@ public:
DataDescriptor_t data;
} ColumnDescriptor_t;
explicit HexDump(QWidget *parent = 0);
explicit HexDump(QWidget* parent = 0);
void colorsUpdated();
void fontsUpdated();
@ -106,7 +106,7 @@ public:
void getString(int col, int_t rva, QList<RichTextPainter::CustomRichText_t>* richText);
int getSizeOf(DataSize_e size);
QString toString(DataDescriptor_t desc, void *data);
QString toString(DataDescriptor_t desc, void* data);
QString byteToString(byte_t byte, ByteViewMode_e mode);
QString wordToString(uint16 word, WordViewMode_e mode);

View File

@ -1,7 +1,7 @@
#include "HistoryLineEdit.h"
#include "Bridge.h"
HistoryLineEdit::HistoryLineEdit(QWidget *parent) : QLineEdit(parent)
HistoryLineEdit::HistoryLineEdit(QWidget* parent) : QLineEdit(parent)
{
mCmdHistory.clear();
mCmdIndex = -1;
@ -24,15 +24,15 @@ void HistoryLineEdit::keyPressEvent(QKeyEvent* event)
//This fixes a very annoying bug on some systems
if(bSixPressed)
{
bSixPressed=false;
if(event->text()=="^")
bSixPressed = false;
if(event->text() == "^")
{
event->ignore();
return;
}
}
if(wKey == Qt::Key_6)
bSixPressed=true;
bSixPressed = true;
if(wKey == Qt::Key_Up || wKey == Qt::Key_Down)
{

View File

@ -8,7 +8,7 @@ class HistoryLineEdit : public QLineEdit
{
Q_OBJECT
public:
explicit HistoryLineEdit(QWidget *parent = 0);
explicit HistoryLineEdit(QWidget* parent = 0);
void keyPressEvent(QKeyEvent* event);
void addLineToHistory(QString parLine);
void setFocus();

View File

@ -16,12 +16,12 @@ ReferenceView::ReferenceView()
mMainLayout->addWidget(mSearchProgress);
// Setup signals
connect(Bridge::getBridge(), SIGNAL(referenceAddColumnAt(int,QString)), this, SLOT(addColumnAt(int,QString)));
connect(Bridge::getBridge(), SIGNAL(referenceAddColumnAt(int, QString)), this, SLOT(addColumnAt(int, QString)));
connect(Bridge::getBridge(), SIGNAL(referenceSetRowCount(int_t)), this, SLOT(setRowCount(int_t)));
connect(Bridge::getBridge(), SIGNAL(referenceDeleteAllColumns()), this, SLOT(deleteAllColumns()));
connect(Bridge::getBridge(), SIGNAL(referenceSetCellContent(int,int,QString)), this, SLOT(setCellContent(int,int,QString)));
connect(Bridge::getBridge(), SIGNAL(referenceSetCellContent(int, int, QString)), this, SLOT(setCellContent(int, int, QString)));
connect(Bridge::getBridge(), SIGNAL(referenceReloadData()), this, SLOT(reloadData()));
connect(Bridge::getBridge(), SIGNAL(referenceSetSingleSelection(int,bool)), this, SLOT(setSingleSelection(int,bool)));
connect(Bridge::getBridge(), SIGNAL(referenceSetSingleSelection(int, bool)), this, SLOT(setSingleSelection(int, bool)));
connect(Bridge::getBridge(), SIGNAL(referenceSetProgress(int)), mSearchProgress, SLOT(setValue(int)));
connect(Bridge::getBridge(), SIGNAL(referenceSetSearchStartCol(int)), this, SLOT(setSearchStartCol(int)));
connect(this, SIGNAL(listContextMenuSignal(QMenu*)), this, SLOT(referenceContextMenu(QMenu*)));
@ -64,16 +64,16 @@ void ReferenceView::refreshShortcutsSlot()
void ReferenceView::addColumnAt(int width, QString title)
{
int charwidth=mList->getCharWidth();
int charwidth = mList->getCharWidth();
if(width)
width=charwidth*width+8;
width = charwidth * width + 8;
else
width=0;
width = 0;
mSearchBox->setText("");
if(title.toLower() == "&data&")
{
mFollowDumpDefault=true;
title="Data";
mFollowDumpDefault = true;
title = "Data";
}
mList->addColumnAt(width, title, true);
mSearchList->addColumnAt(width, title, true);
@ -208,15 +208,15 @@ void ReferenceView::toggleBookmark()
bool result;
if(DbgGetBookmarkAt(wVA))
result=DbgSetBookmarkAt(wVA, false);
result = DbgSetBookmarkAt(wVA, false);
else
result=DbgSetBookmarkAt(wVA, true);
result = DbgSetBookmarkAt(wVA, true);
if(!result)
{
QMessageBox msg(QMessageBox::Critical, "Error!", "DbgSetBookmarkAt failed!");
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
}
GuiUpdateAllViews();

View File

@ -1,7 +1,7 @@
#include "SearchListView.h"
#include "ui_SearchListView.h"
SearchListView::SearchListView(QWidget *parent) :
SearchListView::SearchListView(QWidget* parent) :
QWidget(parent),
ui(new Ui::SearchListView)
{
@ -46,7 +46,7 @@ SearchListView::SearchListView(QWidget *parent) :
ui->mainSplitter->setStretchFactor(0, 1);
// Disable main splitter
for(int i=0; i<ui->mainSplitter->count(); i++)
for(int i = 0; i < ui->mainSplitter->count(); i++)
ui->mainSplitter->handle(i)->setEnabled(false);
// Setup signals
@ -66,84 +66,84 @@ SearchListView::~SearchListView()
void SearchListView::listKeyPressed(QKeyEvent* event)
{
char ch=event->text().toUtf8().constData()[0];
char ch = event->text().toUtf8().constData()[0];
if(isprint(ch)) //add a char to the search box
mSearchBox->setText(mSearchBox->text()+QString(QChar(ch)));
else if(event->key()==Qt::Key_Backspace) //remove a char from the search box
mSearchBox->setText(mSearchBox->text() + QString(QChar(ch)));
else if(event->key() == Qt::Key_Backspace) //remove a char from the search box
{
QString newText;
if(event->modifiers()==Qt::ControlModifier) //clear the search box
newText="";
if(event->modifiers() == Qt::ControlModifier) //clear the search box
newText = "";
else
{
newText=mSearchBox->text();
newText = mSearchBox->text();
newText.chop(1);
}
mSearchBox->setText(newText);
}
else if((event->key()==Qt::Key_Return || event->key()==Qt::Key_Enter)) //user pressed enter
else if((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)) //user pressed enter
emit enterPressedSignal();
}
bool SearchListView::findTextInList(SearchListViewTable* list, QString text, int row, int startcol, bool startswith)
{
int count=list->getColumnCount();
if(startcol+1>count)
int count = list->getColumnCount();
if(startcol + 1 > count)
return false;
if(startswith)
{
for(int i=startcol; i<count; i++)
for(int i = startcol; i < count; i++)
if(list->getCellContent(row, i).startsWith(text, Qt::CaseInsensitive))
return true;
}
else
{
for(int i=startcol; i<count; i++)
for(int i = startcol; i < count; i++)
if(list->getCellContent(row, i).contains(text, Qt::CaseInsensitive))
return true;
}
return false;
}
void SearchListView::searchTextChanged(const QString &arg1)
void SearchListView::searchTextChanged(const QString & arg1)
{
if(arg1.length())
{
mList->hide();
mSearchList->show();
mCurList=mSearchList;
mCurList = mSearchList;
}
else
{
mSearchList->hide();
mList->show();
mList->setFocus();
mCurList=mList;
mCurList = mList;
}
mSearchList->setRowCount(0);
int rows=mList->getRowCount();
int columns=mList->getColumnCount();
for(int i=0,j=0; i<rows; i++)
int rows = mList->getRowCount();
int columns = mList->getColumnCount();
for(int i = 0, j = 0; i < rows; i++)
{
if(findTextInList(mList, arg1, i, mSearchStartCol, false))
{
mSearchList->setRowCount(j+1);
for(int k=0; k<columns; k++)
mSearchList->setRowCount(j + 1);
for(int k = 0; k < columns; k++)
mSearchList->setCellContent(j, k, mList->getCellContent(i, k));
j++;
}
}
rows=mSearchList->getRowCount();
rows = mSearchList->getRowCount();
mSearchList->setTableOffset(0);
for(int i=0; i<rows; i++)
for(int i = 0; i < rows; i++)
{
if(findTextInList(mSearchList, arg1, i, mSearchStartCol, true))
{
if(rows>mSearchList->getViewableRowsCount())
if(rows > mSearchList->getViewableRowsCount())
{
int cur=i-mSearchList->getViewableRowsCount()/2;
int cur = i - mSearchList->getViewableRowsCount() / 2;
if(!mSearchList->isValidIndex(cur, 0))
cur=i;
cur = i;
mSearchList->setTableOffset(cur);
}
mSearchList->setSingleSelection(i);

View File

@ -29,7 +29,7 @@ public:
bool findTextInList(SearchListViewTable* list, QString text, int row, int startcol, bool startswith);
private slots:
void searchTextChanged(const QString &arg1);
void searchTextChanged(const QString & arg1);
void listKeyPressed(QKeyEvent* event);
void listContextMenu(const QPoint & pos);
void doubleClickedSlot();

View File

@ -7,32 +7,32 @@ SearchListViewTable::SearchListViewTable(StdTable* parent) : StdTable(parent)
QString SearchListViewTable::paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h)
{
bool isaddr=true;
QString text=StdTable::paintContent(painter, rowBase, rowOffset, col, x, y, w, h);
bool isaddr = true;
QString text = StdTable::paintContent(painter, rowBase, rowOffset, col, x, y, w, h);
if(!DbgIsDebugging())
isaddr=false;
isaddr = false;
if(!getRowCount())
isaddr=false;
isaddr = false;
const char* addrText = text.toUtf8().constData();
ULONGLONG val=0;
ULONGLONG val = 0;
uint_t wVA;
if(sscanf(addrText, "%llX", &val)!=1)
isaddr=false;
if(sscanf(addrText, "%llX", &val) != 1)
isaddr = false;
else
wVA=val;
if(col==0 && isaddr)
wVA = val;
if(col == 0 && isaddr)
{
BPXTYPE bpxtype=DbgGetBpxTypeAt(wVA);
bool isbookmark=DbgGetBookmarkAt(wVA);
BPXTYPE bpxtype = DbgGetBpxTypeAt(wVA);
bool isbookmark = DbgGetBookmarkAt(wVA);
painter->setPen(ConfigColor("AbstractTableViewTextColor"));
if(!isbookmark)
{
if(bpxtype&bp_normal) //normal breakpoint
if(bpxtype & bp_normal) //normal breakpoint
{
painter->setPen(QPen(ConfigColor("DisassemblyBreakpointColor")));
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyBreakpointBackgroundColor"))); //fill red
}
else if(bpxtype&bp_hardware) //hardware breakpoint only
else if(bpxtype & bp_hardware) //hardware breakpoint only
{
painter->setPen(QPen(ConfigColor("DisassemblyHardwareBreakpointColor")));
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyHardwareBreakpointBackgroundColor"))); //fill red
@ -40,22 +40,22 @@ QString SearchListViewTable::paintContent(QPainter* painter, int_t rowBase, int
}
else //bookmark
{
if(bpxtype==bp_none) //bookmark only
if(bpxtype == bp_none) //bookmark only
{
painter->setPen(QPen(ConfigColor("DisassemblyBookmarkColor"))); //black address
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyBookmarkBackgroundColor"))); //fill bookmark color
}
else //bookmark + breakpoint
{
QColor color=ConfigColor("DisassemblyBookmarkBackgroundColor");
QColor color = ConfigColor("DisassemblyBookmarkBackgroundColor");
if(!color.alpha()) //we don't want transparent text
color=textColor;
color = textColor;
painter->setPen(QPen(color));
if(bpxtype&bp_normal) //bookmark + normal breakpoint
if(bpxtype & bp_normal) //bookmark + normal breakpoint
{
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyBreakpointBackgroundColor"))); //fill red
}
else if(bpxtype&bp_hardware) //bookmark + hardware breakpoint only
else if(bpxtype & bp_hardware) //bookmark + hardware breakpoint only
{
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyHardwareBreakpointBackgroundColor"))); //fill red
}
@ -67,7 +67,7 @@ QString SearchListViewTable::paintContent(QPainter* painter, int_t rowBase, int
}
}
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, text);
text="";
text = "";
}
return text;
}

View File

@ -1,7 +1,7 @@
#include "ShortcutEdit.h"
#include <QKeyEvent>
ShortcutEdit::ShortcutEdit(QWidget *parent) : QLineEdit(parent)
ShortcutEdit::ShortcutEdit(QWidget* parent) : QLineEdit(parent)
{
}
@ -21,14 +21,14 @@ void ShortcutEdit::setErrorState(bool error)
setStyleSheet("color: #000000");
}
void ShortcutEdit::keyPressEvent(QKeyEvent *event)
void ShortcutEdit::keyPressEvent(QKeyEvent* event)
{
keyInt = event->key();
// find key-id
const Qt::Key key = static_cast<Qt::Key>(keyInt);
// we do not know how to handle this case
if( key == Qt::Key_unknown )
if(key == Qt::Key_unknown)
{
keyInt = -1;
emit askForSave();
@ -36,7 +36,7 @@ void ShortcutEdit::keyPressEvent(QKeyEvent *event)
}
// these keys will be ignored
if( key == Qt::Key_Escape || key == Qt::Key_Backspace )
if(key == Qt::Key_Escape || key == Qt::Key_Backspace)
{
setText("");
keyInt = -1;
@ -55,9 +55,9 @@ void ShortcutEdit::keyPressEvent(QKeyEvent *event)
// some strange cases (only Ctrl)
QString KeyText = QKeySequence(keyInt).toString(QKeySequence::NativeText) ;
for(int i=0; i<KeyText.length(); i++)
for(int i = 0; i < KeyText.length(); i++)
{
if(KeyText[i].toAscii()==0)
if(KeyText[i].toAscii() == 0)
{
setText("");
keyInt = -1;
@ -68,7 +68,7 @@ void ShortcutEdit::keyPressEvent(QKeyEvent *event)
// display key combination
setText( QKeySequence(keyInt).toString(QKeySequence::NativeText) );
setText(QKeySequence(keyInt).toString(QKeySequence::NativeText));
// do not forward keypress-event
event->setAccepted(true);

View File

@ -10,7 +10,7 @@ class ShortcutEdit : public QLineEdit
int keyInt;
public:
explicit ShortcutEdit(QWidget *parent = 0);
explicit ShortcutEdit(QWidget* parent = 0);
const QKeySequence getKeysequence() const;
public slots:

View File

@ -1,7 +1,7 @@
#include "StdTable.h"
#include "Bridge.h"
StdTable::StdTable(QWidget *parent) : AbstractTableView(parent)
StdTable::StdTable(QWidget* parent) : AbstractTableView(parent)
{
SelectionData_t data;
memset(&data, 0, sizeof(SelectionData_t));
@ -10,7 +10,7 @@ StdTable::StdTable(QWidget *parent) : AbstractTableView(parent)
mIsMultiSelctionAllowed = false;
mData.clear();
mSort.first=-1;
mSort.first = -1;
mCopyMenuOnly = false;
mCopyMenuDebugOnly = true;
@ -229,7 +229,7 @@ void StdTable::addColumnAt(int width, QString title, bool isClickable, QString c
AbstractTableView::addColumnAt(width, title, isClickable);
//append empty column to list of rows
for(int i=0; i<mData.size(); i++)
for(int i = 0; i < mData.size(); i++)
mData[i].append("");
//Append copy title
@ -242,12 +242,12 @@ void StdTable::addColumnAt(int width, QString title, bool isClickable, QString c
void StdTable::setRowCount(int count)
{
int wRowToAddOrRemove = count - mData.size();
for(int i=0; i<qAbs(wRowToAddOrRemove); i++)
for(int i = 0; i < qAbs(wRowToAddOrRemove); i++)
{
if(wRowToAddOrRemove > 0)
{
mData.append(QList<QString>());
for(int j=0; j<getColumnCount(); j++)
for(int j = 0; j < getColumnCount(); j++)
mData.last().append("");
}
else
@ -292,7 +292,7 @@ void StdTable::copyLineSlot()
finalText = getCellContent(getInitialSelection(), 0);
else
{
for(int i=0; i<colCount; i++)
for(int i = 0; i < colCount; i++)
{
QString cellContent = getCellContent(getInitialSelection(), i);
if(!cellContent.length()) //skip empty cells
@ -314,7 +314,7 @@ void StdTable::copyTableSlot()
QString finalText = "";
if(colCount == 1)
{
for(int i=0; i<rowCount; i++)
for(int i = 0; i < rowCount; i++)
{
QString cellContent = getCellContent(i, 0);
if(!cellContent.length()) //skip empty cells
@ -324,27 +324,27 @@ void StdTable::copyTableSlot()
}
else
{
int charwidth=getCharWidth();
for(int i=0; i<colCount; i++)
int charwidth = getCharWidth();
for(int i = 0; i < colCount; i++)
{
if(i)
finalText += " ";
int colWidth = getColumnWidth(i)/charwidth;
int colWidth = getColumnWidth(i) / charwidth;
if(colWidth)
finalText += getColTitle(i).leftJustified(colWidth, QChar(' '), true);
else
finalText += getColTitle(i);
}
finalText += "\r\n";
for(int i=0; i<rowCount; i++)
for(int i = 0; i < rowCount; i++)
{
QString finalRowText = "";
for(int j=0; j<colCount; j++)
for(int j = 0; j < colCount; j++)
{
if(j)
finalRowText += " ";
QString cellContent = getCellContent(i, j);
int colWidth = getColumnWidth(j)/charwidth;
int colWidth = getColumnWidth(j) / charwidth;
if(colWidth)
finalRowText += cellContent.leftJustified(colWidth, QChar(' '), true);
else
@ -361,7 +361,7 @@ void StdTable::copyEntrySlot()
QAction* action = qobject_cast<QAction*>(sender());
if(!action)
return;
int col=action->objectName().toInt();
int col = action->objectName().toInt();
Bridge::CopyToClipboard(getCellContent(getInitialSelection(), col).toUtf8().constData());
}
@ -380,11 +380,11 @@ void StdTable::setupCopyMenu(QMenu* copyMenu)
//Copy->Separatoe
copyMenu->addSeparator();
//Copy->ColName
for(int i=0; i<getColumnCount(); i++)
for(int i = 0; i < getColumnCount(); i++)
{
if(!getCellContent(getInitialSelection(), i).length()) //skip empty cells
continue;
QString title=mCopyTitles.at(i);
QString title = mCopyTitles.at(i);
if(!title.length()) //skip empty copy titles
continue;
QAction* mCopyAction = new QAction(title, this);
@ -400,7 +400,7 @@ void StdTable::setCopyMenuOnly(bool bSet, bool bDebugOnly)
mCopyMenuDebugOnly = bDebugOnly;
}
void StdTable::contextMenuRequestedSlot(const QPoint &pos)
void StdTable::contextMenuRequestedSlot(const QPoint & pos)
{
if(!mCopyMenuOnly)
{
@ -424,11 +424,11 @@ void StdTable::headerButtonPressedSlot(int col)
{
if(mSort.first != -1)
{
mSort.first=col;
mSort.second=false;
mSort.first = col;
mSort.second = false;
}
else
mSort.second=!mSort.second;
mSort.second = !mSort.second;
qSort(mData.begin(), mData.end(), ColumnCompare(col, mSort.second));
reloadData();
}

View File

@ -10,7 +10,7 @@ class StdTable : public AbstractTableView
{
Q_OBJECT
public:
explicit StdTable(QWidget *parent = 0);
explicit StdTable(QWidget* parent = 0);
QString paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h);
void mouseMoveEvent(QMouseEvent* event);
@ -45,13 +45,13 @@ signals:
void selectionChangedSignal(int index);
void keyPressedSignal(QKeyEvent* event);
void doubleClickedSignal();
void contextMenuSignal(const QPoint &pos);
void contextMenuSignal(const QPoint & pos);
public slots:
void copyLineSlot();
void copyTableSlot();
void copyEntrySlot();
void contextMenuRequestedSlot(const QPoint &pos);
void contextMenuRequestedSlot(const QPoint & pos);
void headerButtonPressedSlot(int col);
private:
@ -60,13 +60,13 @@ private:
public:
ColumnCompare(int col, bool greater)
{
mCol=col;
mGreater=greater;
mCol = col;
mGreater = greater;
}
inline bool operator()(const QList<QString> & a, const QList<QString> & b) const
{
bool less=QString::compare(a.at(mCol), b.at(mCol), Qt::CaseInsensitive) < 0;
bool less = QString::compare(a.at(mCol), b.at(mCol), Qt::CaseInsensitive) < 0;
if(mGreater)
return !less;
return less;

View File

@ -8,7 +8,7 @@ static Bridge* mBridge;
/************************************************************************************
Class Members
************************************************************************************/
Bridge::Bridge(QObject *parent) : QObject(parent)
Bridge::Bridge(QObject* parent) : QObject(parent)
{
mBridgeMutex = new QMutex();
}
@ -21,13 +21,13 @@ Bridge::~Bridge()
void Bridge::CopyToClipboard(const char* text)
{
HGLOBAL hText;
char *pText;
int len=strlen(text);
char* pText;
int len = strlen(text);
if(!len)
return;
hText=GlobalAlloc(GMEM_DDESHARE|GMEM_MOVEABLE, len+1);
pText=(char*)GlobalLock(hText);
hText = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, len + 1);
pText = (char*)GlobalLock(hText);
strcpy(pText, text);
OpenClipboard(0);
@ -38,8 +38,8 @@ void Bridge::CopyToClipboard(const char* text)
void Bridge::BridgeSetResult(int_t result)
{
bridgeResult=result;
hasBridgeResult=true;
bridgeResult = result;
hasBridgeResult = true;
}
/************************************************************************************
@ -93,7 +93,7 @@ void Bridge::emitDumpAt(int_t va)
void Bridge::emitScriptAdd(int count, const char** lines)
{
mBridgeMutex->lock();
hasBridgeResult=false;
hasBridgeResult = false;
emit scriptAdd(count, lines);
while(!hasBridgeResult) //wait for thread completion
Sleep(100);
@ -133,7 +133,7 @@ void Bridge::emitScriptMessage(QString message)
int Bridge::emitScriptQuestion(QString message)
{
mBridgeMutex->lock();
hasBridgeResult=false;
hasBridgeResult = false;
emit scriptQuestion(message);
while(!hasBridgeResult) //wait for thread completion
Sleep(100);
@ -234,7 +234,7 @@ void Bridge::emitSetLastException(unsigned int exceptionCode)
int Bridge::emitMenuAddMenu(int hMenu, QString title)
{
mBridgeMutex->lock();
hasBridgeResult=false;
hasBridgeResult = false;
emit menuAddMenu(hMenu, title);
while(!hasBridgeResult) //wait for thread completion
Sleep(100);
@ -245,7 +245,7 @@ int Bridge::emitMenuAddMenu(int hMenu, QString title)
int Bridge::emitMenuAddMenuEntry(int hMenu, QString title)
{
mBridgeMutex->lock();
hasBridgeResult=false;
hasBridgeResult = false;
emit menuAddMenuEntry(hMenu, title);
while(!hasBridgeResult) //wait for thread completion
Sleep(100);
@ -273,7 +273,7 @@ bool Bridge::emitSelectionGet(int hWindow, SELECTIONDATA* selection)
if(!DbgIsDebugging())
return false;
mBridgeMutex->lock();
hasBridgeResult=false;
hasBridgeResult = false;
switch(hWindow)
{
case GUI_DISASSEMBLY:
@ -294,9 +294,9 @@ bool Bridge::emitSelectionGet(int hWindow, SELECTIONDATA* selection)
mBridgeMutex->unlock();
if(selection->start > selection->end) //swap start and end
{
int_t temp=selection->end;
selection->end=selection->start;
selection->start=temp;
int_t temp = selection->end;
selection->end = selection->start;
selection->start = temp;
}
return true;
}
@ -306,7 +306,7 @@ bool Bridge::emitSelectionSet(int hWindow, const SELECTIONDATA* selection)
if(!DbgIsDebugging())
return false;
mBridgeMutex->lock();
hasBridgeResult=false;
hasBridgeResult = false;
switch(hWindow)
{
case GUI_DISASSEMBLY:
@ -331,7 +331,7 @@ bool Bridge::emitSelectionSet(int hWindow, const SELECTIONDATA* selection)
bool Bridge::emitGetStrWindow(const QString title, QString* text)
{
mBridgeMutex->lock();
hasBridgeResult=false;
hasBridgeResult = false;
emit getStrWindow(title, text);
while(!hasBridgeResult) //wait for thread completion
Sleep(100);
@ -395,7 +395,7 @@ void Bridge::initBridge()
/************************************************************************************
Exported Functions
************************************************************************************/
__declspec(dllexport) int _gui_guiinit(int argc, char *argv[])
__declspec(dllexport) int _gui_guiinit(int argc, char* argv[])
{
return main(argc, argv);
}
@ -412,7 +412,7 @@ __declspec(dllexport) void* _gui_sendmessage(GUIMSG type, void* param1, void* pa
case GUI_SET_DEBUG_STATE:
{
Bridge::getBridge()->emitDbgStateChanged(reinterpret_cast<DBGSTATE&>(param1));
Bridge::getBridge()->emitDbgStateChanged(reinterpret_cast<DBGSTATE &>(param1));
}
break;
@ -568,7 +568,7 @@ __declspec(dllexport) void* _gui_sendmessage(GUIMSG type, void* param1, void* pa
case GUI_REF_SETCELLCONTENT:
{
CELLINFO* info=(CELLINFO*)param1;
CELLINFO* info = (CELLINFO*)param1;
Bridge::getBridge()->emitReferenceSetCellContent(info->row, info->col, QString(info->str));
}
break;
@ -635,21 +635,21 @@ __declspec(dllexport) void* _gui_sendmessage(GUIMSG type, void* param1, void* pa
case GUI_GET_DISASSEMBLY:
{
uint_t parVA=(uint_t)param1;
char* text=(char*)param2;
uint_t parVA = (uint_t)param1;
char* text = (char*)param2;
if(!text || !parVA || !DbgIsDebugging())
return 0;
byte_t wBuffer[16];
if(!DbgMemRead(parVA, wBuffer, 16))
return 0;
QBeaEngine* disasm = new QBeaEngine();
Instruction_t instr=disasm->DisassembleAt(wBuffer, 16, 0, 0, parVA);
Instruction_t instr = disasm->DisassembleAt(wBuffer, 16, 0, 0, parVA);
BeaTokenizer::TokenizeInstruction(&instr.tokens, &instr.disasm);
QList<RichTextPainter::CustomRichText_t> richText;
BeaTokenizer::TokenToRichText(&instr.tokens, &richText, 0);
QString finalInstruction="";
for(int i=0; i<richText.size(); i++)
finalInstruction+=richText.at(i).text;
QString finalInstruction = "";
for(int i = 0; i < richText.size(); i++)
finalInstruction += richText.at(i).text;
strcpy(text, finalInstruction.toUtf8().constData());
return (void*)1;
}
@ -696,8 +696,8 @@ __declspec(dllexport) void* _gui_sendmessage(GUIMSG type, void* param1, void* pa
QString text = "";
if(Bridge::getBridge()->emitGetStrWindow(QString(reinterpret_cast<const char*>(param1)), &text))
{
if(text.length()>=GUI_MAX_LINE_SIZE)
text.chop(text.length()-GUI_MAX_LINE_SIZE);
if(text.length() >= GUI_MAX_LINE_SIZE)
text.chop(text.length() - GUI_MAX_LINE_SIZE);
strcpy((char*)param2, text.toUtf8().constData());
return (void*)(uint_t)true;
}

View File

@ -17,7 +17,7 @@ class Bridge : public QObject
{
Q_OBJECT
public:
explicit Bridge(QObject *parent = 0);
explicit Bridge(QObject* parent = 0);
~Bridge();
static Bridge* getBridge();

View File

@ -16,19 +16,19 @@ BeaTokenizer::BeaTokenizer()
void BeaTokenizer::AddToken(BeaInstructionToken* instr, const BeaTokenType type, const QString text, const BeaTokenValue* value)
{
BeaSingleToken token;
token.type=type;
if(type!=TokenSpace && type!=TokenArgumentSpace && type!=TokenMemoryOperatorSpace)
token.text=text.trimmed(); //remove whitespaces from the start and end
token.type = type;
if(type != TokenSpace && type != TokenArgumentSpace && type != TokenMemoryOperatorSpace)
token.text = text.trimmed(); //remove whitespaces from the start and end
else
token.text=text;
token.text = text;
if(ConfigBool("Disassembler", "Uppercase"))
token.text=token.text.toUpper();
token.text = token.text.toUpper();
if(value)
token.value=*value;
token.value = *value;
else
{
token.value.size=0;
token.value.value=0;
token.value.size = 0;
token.value.value = 0;
}
instr->tokens.push_back(token);
}
@ -62,7 +62,7 @@ bool BeaTokenizer::IsNopInstruction(QString mnemonic, const DISASM* disasm)
{
Q_UNUSED(disasm);
//TODO: add instructions like "mov eax,eax" and "xchg ebx,ebx" and "lea eax,[eax]"
if(mnemonic=="nop")
if(mnemonic == "nop")
return true;
return false;
}
@ -70,14 +70,14 @@ bool BeaTokenizer::IsNopInstruction(QString mnemonic, const DISASM* disasm)
void BeaTokenizer::StringInstructionMemory(BeaInstructionToken* instr, int size, QString segment, ARGUMENTS_TYPE reg)
{
if(memSizeNames.contains(size))
AddToken(instr, TokenMemorySize, memSizeNames.find(size).value()+" ptr", 0);
AddToken(instr, TokenMemorySize, memSizeNames.find(size).value() + " ptr", 0);
else
AddToken(instr, TokenMemorySize, "??? ptr", 0);
AddToken(instr, TokenSpace, " ", 0);
AddToken(instr, TokenMemorySegment, segment, 0);
AddToken(instr, TokenUncategorized, ":", 0);
AddToken(instr, TokenMemoryBrackets, "[", 0);
AddToken(instr, TokenMemoryBaseRegister, RegisterToString(sizeof(int_t)*8, reg), 0); //EDI/RDI
AddToken(instr, TokenMemoryBaseRegister, RegisterToString(sizeof(int_t) * 8, reg), 0); //EDI/RDI
AddToken(instr, TokenMemoryBrackets, "]", 0);
}
@ -85,25 +85,25 @@ void BeaTokenizer::StringInstruction(QString mnemonic, BeaInstructionToken* inst
{
AddToken(instr, TokenMnemonicNormal, mnemonic, 0);
AddToken(instr, TokenSpace, " ", 0);
if(mnemonic=="movs")
if(mnemonic == "movs")
{
StringInstructionMemory(instr, disasm->Argument1.ArgSize, "es", REG7); //EDI/RDI
AddToken(instr, TokenComma, ",", 0);
AddToken(instr, TokenArgumentSpace, " ", 0);
StringInstructionMemory(instr, disasm->Argument1.ArgSize, "ds", REG6); //ESI/RSI
}
else if(mnemonic=="cmps")
else if(mnemonic == "cmps")
{
StringInstructionMemory(instr, disasm->Argument1.ArgSize, "ds", REG6); //EDI/RDI
AddToken(instr, TokenComma, ",", 0);
AddToken(instr, TokenArgumentSpace, " ", 0);
StringInstructionMemory(instr, disasm->Argument1.ArgSize, "es", REG7); //ESI/RSI
}
else if(mnemonic=="scas" || mnemonic=="stos")
else if(mnemonic == "scas" || mnemonic == "stos")
StringInstructionMemory(instr, disasm->Argument1.ArgSize, "es", REG7); //ESI/RSI
else if(mnemonic=="lods")
else if(mnemonic == "lods")
StringInstructionMemory(instr, disasm->Argument1.ArgSize, "ds", REG6); //ESI/RSI
else if(mnemonic=="outs")
else if(mnemonic == "outs")
{
AddToken(instr, TokenGeneralRegister, "dx", 0);
AddToken(instr, TokenComma, ",", 0);
@ -114,37 +114,37 @@ void BeaTokenizer::StringInstruction(QString mnemonic, BeaInstructionToken* inst
void BeaTokenizer::Mnemonic(BeaInstructionToken* instr, const DISASM* disasm)
{
QString mnemonic=QString(disasm->Instruction.Mnemonic).trimmed().toLower();
QString mnemonic = QString(disasm->Instruction.Mnemonic).trimmed().toLower();
bool farMnemonic = mnemonic.contains(" far");
if(farMnemonic)
mnemonic.truncate(mnemonic.indexOf(" far"));
QString completeInstr=QString(disasm->CompleteInstr).trimmed().toLower();
BeaTokenType type=TokenMnemonicNormal;
int brtype=disasm->Instruction.BranchType;
QString completeInstr = QString(disasm->CompleteInstr).trimmed().toLower();
BeaTokenType type = TokenMnemonicNormal;
int brtype = disasm->Instruction.BranchType;
if(brtype) //jump/call
{
if(brtype==CallType)
type=TokenMnemonicCall;
else if(brtype==RetType)
type=TokenMnemonicRet;
else if(brtype==JmpType)
type=TokenMnemonicUncondJump;
if(brtype == CallType)
type = TokenMnemonicCall;
else if(brtype == RetType)
type = TokenMnemonicRet;
else if(brtype == JmpType)
type = TokenMnemonicUncondJump;
else //cond jump
type=TokenMnemonicCondJump;
type = TokenMnemonicCondJump;
}
else if(mnemonic=="push" || mnemonic=="pop")
type=TokenMnemonicPushPop;
else if(mnemonic == "push" || mnemonic == "pop")
type = TokenMnemonicPushPop;
else if(IsNopInstruction(mnemonic, disasm)) //nop instructions
type=TokenMnemonicNop;
type = TokenMnemonicNop;
else if(completeInstr.contains("movs") || completeInstr.contains("cmps") || completeInstr.contains("scas") || completeInstr.contains("lods") || completeInstr.contains("stos") || completeInstr.contains("outs"))
{
completeInstr=completeInstr.replace("rep ", "").replace("repne ", "");
if(completeInstr.length()!=5)
completeInstr = completeInstr.replace("rep ", "").replace("repne ", "");
if(completeInstr.length() != 5)
{
AddToken(instr, type, mnemonic, 0);
return;
}
if(mnemonic[4]=='b' || mnemonic[4]=='w' || mnemonic[4]=='d' || mnemonic[4]=='q')
if(mnemonic[4] == 'b' || mnemonic[4] == 'w' || mnemonic[4] == 'd' || mnemonic[4] == 'q')
{
mnemonic.truncate(4);
StringInstruction(mnemonic, instr, disasm);
@ -163,31 +163,31 @@ void BeaTokenizer::Mnemonic(BeaInstructionToken* instr, const DISASM* disasm)
QString BeaTokenizer::PrintValue(const BeaTokenValue* value, bool module)
{
char labelText[MAX_LABEL_SIZE]="";
char moduleText[MAX_MODULE_SIZE]="";
int_t addr=value->value;
bool bHasLabel=DbgGetLabelAt(addr, SEG_DEFAULT, labelText);
bool bHasModule=(module && DbgGetModuleAt(addr, moduleText) && !QString(labelText).startsWith("JMP.&"));
char labelText[MAX_LABEL_SIZE] = "";
char moduleText[MAX_MODULE_SIZE] = "";
int_t addr = value->value;
bool bHasLabel = DbgGetLabelAt(addr, SEG_DEFAULT, labelText);
bool bHasModule = (module && DbgGetModuleAt(addr, moduleText) && !QString(labelText).startsWith("JMP.&"));
QString addrText;
addrText=QString("%1").arg(addr&(uint_t)-1, 0, 16, QChar('0')).toUpper();
addrText = QString("%1").arg(addr & (uint_t) - 1, 0, 16, QChar('0')).toUpper();
QString finalText;
if(bHasLabel && bHasModule) //<module.label>
finalText=QString("<%1.%2>").arg(moduleText).arg(labelText);
finalText = QString("<%1.%2>").arg(moduleText).arg(labelText);
else if(bHasModule) //module.addr
finalText=QString("%1.%2").arg(moduleText).arg(addrText);
finalText = QString("%1.%2").arg(moduleText).arg(addrText);
else if(bHasLabel) //<label>
finalText=QString("<%1>").arg(labelText);
finalText = QString("<%1>").arg(labelText);
else
finalText=addrText;
finalText = addrText;
return finalText;
}
QString BeaTokenizer::RegisterToString(int size, int reg)
{
ARGUMENTS_TYPE regValue=(ARGUMENTS_TYPE)(reg&0xFFFF);
ARGUMENTS_TYPE regValue = (ARGUMENTS_TYPE)(reg & 0xFFFF);
if(!registerMap.contains(size)) //invalid size
return QString("UNKNOWN_REGISTER(size:%1)").arg(size);
QMap<ARGUMENTS_TYPE, QString>* currentMap=&registerMap.find(size).value();
QMap<ARGUMENTS_TYPE, QString>* currentMap = &registerMap.find(size).value();
if(!currentMap->contains(regValue))
return QString("UNKNOWN_REGISTER(reg:%1)").arg(reg);
return currentMap->find(regValue).value();
@ -195,7 +195,7 @@ QString BeaTokenizer::RegisterToString(int size, int reg)
void BeaTokenizer::Argument(BeaInstructionToken* instr, const DISASM* disasm, const ARGTYPE* arg, bool* hadarg)
{
if(arg->ArgType==NO_ARGUMENT || !arg->ArgMnemonic[0]) //empty/implicit argument
if(arg->ArgType == NO_ARGUMENT || !arg->ArgMnemonic[0]) //empty/implicit argument
return;
if(*hadarg) //there already was an argument before this one
@ -207,8 +207,8 @@ void BeaTokenizer::Argument(BeaInstructionToken* instr, const DISASM* disasm, co
AddToken(instr, TokenSpace, " ", 0);
//print argument
QString argMnemonic=QString(arg->ArgMnemonic).toLower().trimmed();
if((arg->ArgType&MEMORY_TYPE)==MEMORY_TYPE && QString(disasm->CompleteInstr).contains('[')) //memory argument
QString argMnemonic = QString(arg->ArgMnemonic).toLower().trimmed();
if((arg->ArgType & MEMORY_TYPE) == MEMORY_TYPE && QString(disasm->CompleteInstr).contains('[')) //memory argument
{
//#size ptr #segment:[#BaseRegister + #IndexRegister*#Scale +/- #Displacement]
if(memSizeNames.contains(arg->ArgSize))
@ -219,16 +219,16 @@ void BeaTokenizer::Argument(BeaInstructionToken* instr, const DISASM* disasm, co
AddToken(instr, TokenMemorySegment, segmentNames.at(arg->SegmentReg), 0);
AddToken(instr, TokenUncategorized, ":", 0);
BeaTokenType bracketsType=TokenMemoryBrackets;
if((arg->Memory.BaseRegister&REG4)==REG4 || (arg->Memory.BaseRegister&REG5)==REG5) //ESP/EBP
bracketsType=TokenMemoryStackBrackets;
BeaTokenType bracketsType = TokenMemoryBrackets;
if((arg->Memory.BaseRegister & REG4) == REG4 || (arg->Memory.BaseRegister & REG5) == REG5) //ESP/EBP
bracketsType = TokenMemoryStackBrackets;
AddToken(instr, bracketsType, "[", 0);
bool prependPlusMinus=false;
bool prependPlusMinus = false;
if(arg->Memory.BaseRegister) //base register
{
AddToken(instr, TokenMemoryBaseRegister, RegisterToString(sizeof(int_t)*8, arg->Memory.BaseRegister), 0);
prependPlusMinus=true;
AddToken(instr, TokenMemoryBaseRegister, RegisterToString(sizeof(int_t) * 8, arg->Memory.BaseRegister), 0);
prependPlusMinus = true;
}
if(arg->Memory.IndexRegister) //index register + scale
{
@ -238,34 +238,34 @@ void BeaTokenizer::Argument(BeaInstructionToken* instr, const DISASM* disasm, co
AddToken(instr, TokenMemoryOperator, "+", 0);
AddToken(instr, TokenMemoryOperatorSpace, " ", 0);
}
AddToken(instr, TokenMemoryIndexRegister, RegisterToString(sizeof(int_t)*8, arg->Memory.IndexRegister), 0);
int scale=arg->Memory.Scale;
if(scale>1) //eax * 1 = eax
AddToken(instr, TokenMemoryIndexRegister, RegisterToString(sizeof(int_t) * 8, arg->Memory.IndexRegister), 0);
int scale = arg->Memory.Scale;
if(scale > 1) //eax * 1 = eax
{
AddToken(instr, TokenMemoryOperatorSpace, " ", 0);
AddToken(instr, TokenMemoryOperator, "*", 0);
AddToken(instr, TokenMemoryOperatorSpace, " ", 0);
AddToken(instr, TokenMemoryScale, QString("%1").arg(arg->Memory.Scale), 0);
}
prependPlusMinus=true;
prependPlusMinus = true;
}
//displacement
BeaTokenValue displacement;
displacement.size=arg->ArgSize;
if((arg->ArgType&RELATIVE_)==RELATIVE_) //rip-relative displacement
displacement.value=disasm->Instruction.AddrValue;
displacement.size = arg->ArgSize;
if((arg->ArgType & RELATIVE_) == RELATIVE_) //rip-relative displacement
displacement.value = disasm->Instruction.AddrValue;
else //direct displacement
displacement.value=arg->Memory.Displacement;
displacement.value = arg->Memory.Displacement;
if(displacement.value || !prependPlusMinus) //support dword ptr fs:[0]
{
BeaTokenValue printDisplacement=displacement;
QString plusMinus="+";
if(printDisplacement.value<0) //negative -> '-(displacement*-1)'
BeaTokenValue printDisplacement = displacement;
QString plusMinus = "+";
if(printDisplacement.value < 0) //negative -> '-(displacement*-1)'
{
printDisplacement.value*=-1;
printDisplacement.size=arg->ArgSize/8;
plusMinus="-";
printDisplacement.value *= -1;
printDisplacement.size = arg->ArgSize / 8;
plusMinus = "-";
}
if(prependPlusMinus)
{
@ -273,28 +273,28 @@ void BeaTokenizer::Argument(BeaInstructionToken* instr, const DISASM* disasm, co
AddToken(instr, TokenMemoryOperator, plusMinus, 0);
AddToken(instr, TokenMemoryOperatorSpace, " ", 0);
}
BeaTokenType type=TokenValue;
BeaTokenType type = TokenValue;
if(DbgMemIsValidReadPtr(displacement.value)) //pointer
type=TokenAddress;
type = TokenAddress;
AddToken(instr, type, PrintValue(&printDisplacement, false), &displacement);
}
AddToken(instr, bracketsType, "]", 0);
}
else if(disasm->Instruction.BranchType != 0 && disasm->Instruction.BranchType != RetType && (arg->ArgType&RELATIVE_)==RELATIVE_) //jump/call
else if(disasm->Instruction.BranchType != 0 && disasm->Instruction.BranchType != RetType && (arg->ArgType & RELATIVE_) == RELATIVE_) //jump/call
{
BeaTokenValue value;
value.size=arg->ArgSize/8;
value.value=disasm->Instruction.AddrValue;
value.size = arg->ArgSize / 8;
value.value = disasm->Instruction.AddrValue;
AddToken(instr, TokenAddress, PrintValue(&value, true), &value);
}
else if((arg->ArgType&CONSTANT_TYPE)==CONSTANT_TYPE) //immediat
else if((arg->ArgType & CONSTANT_TYPE) == CONSTANT_TYPE) //immediat
{
BeaTokenValue value;
value.size=arg->ArgSize/8;
value.size = arg->ArgSize / 8;
//nice little hack
LONGLONG val;
sscanf(arg->ArgMnemonic, "%llX", &val);
value.value=val;
value.value = val;
/*
switch(value.size)
{
@ -312,32 +312,32 @@ void BeaTokenizer::Argument(BeaInstructionToken* instr, const DISASM* disasm, co
break;
}
*/
BeaTokenType type=TokenValue;
BeaTokenType type = TokenValue;
if(DbgMemIsValidReadPtr(value.value)) //pointer
type=TokenAddress;
type = TokenAddress;
AddToken(instr, type, PrintValue(&value, true), &value);
}
else if((arg->ArgType&REGISTER_TYPE)==REGISTER_TYPE) //registers
else if((arg->ArgType & REGISTER_TYPE) == REGISTER_TYPE) //registers
{
BeaTokenType type=TokenGeneralRegister; //general x86/unknown register
if((arg->ArgType&FPU_REG)==FPU_REG) //floating point register
type=TokenFpuRegister;
else if((arg->ArgType&MMX_REG)==MMX_REG) //MMX register
type=TokenMmxRegister;
else if((arg->ArgType&SSE_REG)==SSE_REG) //SSE register
type=TokenSseRegister;
BeaTokenType type = TokenGeneralRegister; //general x86/unknown register
if((arg->ArgType & FPU_REG) == FPU_REG) //floating point register
type = TokenFpuRegister;
else if((arg->ArgType & MMX_REG) == MMX_REG) //MMX register
type = TokenMmxRegister;
else if((arg->ArgType & SSE_REG) == SSE_REG) //SSE register
type = TokenSseRegister;
AddToken(instr, type, argMnemonic, 0);
}
else //other
AddToken(instr, TokenUncategorized, argMnemonic, 0);
*hadarg=true; //we now added an argument
*hadarg = true; //we now added an argument
}
void BeaTokenizer::AddColorName(BeaTokenType type, QString color, QString backgroundColor)
{
BeaTokenColor tokenColor;
tokenColor.color=color;
tokenColor.backgroundColor=backgroundColor;
tokenColor.color = color;
tokenColor.backgroundColor = backgroundColor;
colorNamesMap.insert(type, tokenColor);
}
@ -447,7 +447,7 @@ void BeaTokenizer::Init()
memSizeNames.insert(256, "yword");
memSizeNames.insert(512, "zword");
segmentNames.clear();
segmentNames<<"??"<<"es"<<"ds"<<"fs"<<"gs"<<"cs"<<"ss";
segmentNames << "??" << "es" << "ds" << "fs" << "gs" << "cs" << "ss";
//color names map
colorNamesMap.clear();
@ -507,18 +507,18 @@ void BeaTokenizer::Init()
//djb2 (http://www.cse.yorku.ca/~oz/hash.html)
unsigned long BeaTokenizer::HashInstruction(const DISASM* disasm)
{
const char* str=disasm->CompleteInstr;
unsigned long hash=5381;
const char* str = disasm->CompleteInstr;
unsigned long hash = 5381;
int c;
while(c=*str++)
hash=((hash<<5)+hash)+c; /*hash*33+c*/
while(c = *str++)
hash = ((hash << 5) + hash) + c; /*hash*33+c*/
return hash;
}
void BeaTokenizer::TokenizeInstruction(BeaInstructionToken* instr, const DISASM* disasm)
{
//initialization
instr->hash=HashInstruction(disasm); //hash instruction
instr->hash = HashInstruction(disasm); //hash instruction
instr->tokens.clear(); //clear token list
//base instruction
@ -529,70 +529,70 @@ void BeaTokenizer::TokenizeInstruction(BeaInstructionToken* instr, const DISASM*
QString mnemonic = QString(disasm->Instruction.Mnemonic).trimmed();
if(mnemonic.contains("far") && !QString(disasm->CompleteInstr).contains("[")) //far jumps / calls (not the memory ones)
{
unsigned int segment=0;
unsigned int address=0;
unsigned int segment = 0;
unsigned int address = 0;
sscanf(disasm->Argument1.ArgMnemonic, "%X : %X", &segment, &address);
AddToken(instr, TokenSpace, QString(" "), 0);
BeaTokenValue val;
val.size=2;
val.value=segment;
val.size = 2;
val.value = segment;
AddToken(instr, TokenValue, PrintValue(&val, true), &val);
AddToken(instr, TokenUncategorized, ":", 0);
val.size=4;
val.value=address;
val.size = 4;
val.value = address;
AddToken(instr, TokenAddress, PrintValue(&val, true), &val);
}
else
{
bool hadarg=false;
bool hadarg = false;
Argument(instr, disasm, &disasm->Argument1, &hadarg);
Argument(instr, disasm, &disasm->Argument2, &hadarg);
Argument(instr, disasm, &disasm->Argument3, &hadarg);
}
//remove spaces when needed
bool bArgumentSpaces=ConfigBool("Disassembler", "ArgumentSpaces");
bool bMemorySpaces=ConfigBool("Disassembler", "MemorySpaces");
for(int i=instr->tokens.size()-1; i>-1; i--)
bool bArgumentSpaces = ConfigBool("Disassembler", "ArgumentSpaces");
bool bMemorySpaces = ConfigBool("Disassembler", "MemorySpaces");
for(int i = instr->tokens.size() - 1; i > -1; i--)
{
if(!bArgumentSpaces && instr->tokens.at(i).type==TokenArgumentSpace)
instr->tokens.erase(instr->tokens.begin()+i);
if(!bMemorySpaces && instr->tokens.at(i).type==TokenMemoryOperatorSpace)
instr->tokens.erase(instr->tokens.begin()+i);
if(!bArgumentSpaces && instr->tokens.at(i).type == TokenArgumentSpace)
instr->tokens.erase(instr->tokens.begin() + i);
if(!bMemorySpaces && instr->tokens.at(i).type == TokenMemoryOperatorSpace)
instr->tokens.erase(instr->tokens.begin() + i);
}
}
void BeaTokenizer::TokenToRichText(const BeaInstructionToken* instr, QList<RichTextPainter::CustomRichText_t>* richTextList, const BeaSingleToken* highlightToken)
{
QColor highlightColor=ConfigColor("InstructionHighlightColor");
for(int i=0; i<instr->tokens.size(); i++)
QColor highlightColor = ConfigColor("InstructionHighlightColor");
for(int i = 0; i < instr->tokens.size(); i++)
{
BeaSingleToken token=instr->tokens.at(i);
BeaSingleToken token = instr->tokens.at(i);
RichTextPainter::CustomRichText_t richText;
richText.highlight=TokenEquals(&token, highlightToken);
richText.highlightColor=highlightColor;
richText.flags=FlagNone;
richText.text=token.text;
richText.highlight = TokenEquals(&token, highlightToken);
richText.highlightColor = highlightColor;
richText.flags = FlagNone;
richText.text = token.text;
if(colorNamesMap.contains(token.type))
{
BeaTokenColor tokenColor=colorNamesMap[token.type];
QString color=tokenColor.color;
QString backgroundColor=tokenColor.backgroundColor;
BeaTokenColor tokenColor = colorNamesMap[token.type];
QString color = tokenColor.color;
QString backgroundColor = tokenColor.backgroundColor;
if(color.length() && backgroundColor.length())
{
richText.flags=FlagAll;
richText.textColor=ConfigColor(color);
richText.textBackground=ConfigColor(backgroundColor);
richText.flags = FlagAll;
richText.textColor = ConfigColor(color);
richText.textBackground = ConfigColor(backgroundColor);
}
else if(color.length())
{
richText.flags=FlagColor;
richText.textColor=ConfigColor(color);
richText.flags = FlagColor;
richText.textColor = ConfigColor(color);
}
else if(backgroundColor.length())
{
richText.flags=FlagBackground;
richText.textBackground=ConfigColor(backgroundColor);
richText.flags = FlagBackground;
richText.textBackground = ConfigColor(backgroundColor);
}
}
richTextList->append(richText);
@ -601,19 +601,19 @@ void BeaTokenizer::TokenToRichText(const BeaInstructionToken* instr, QList<RichT
bool BeaTokenizer::TokenFromX(const BeaInstructionToken* instr, BeaSingleToken* token, int x, int charwidth)
{
if(x<instr->x) //before the first token
if(x < instr->x) //before the first token
return false;
for(int i=0,xStart=instr->x; i<instr->tokens.size(); i++)
for(int i = 0, xStart = instr->x; i < instr->tokens.size(); i++)
{
const BeaSingleToken* curToken=&instr->tokens.at(i);
int curWidth=curToken->text.length()*charwidth;
int xEnd=xStart+curWidth;
if(x>=xStart && x<xEnd)
const BeaSingleToken* curToken = &instr->tokens.at(i);
int curWidth = curToken->text.length() * charwidth;
int xEnd = xStart + curWidth;
if(x >= xStart && x < xEnd)
{
*token=*curToken;
*token = *curToken;
return true;
}
xStart=xEnd;
xStart = xEnd;
}
return false; //not found
}

View File

@ -37,17 +37,17 @@ ulong QBeaEngine::DisassembleBack(byte_t* data, uint_t base, uint_t size, uint_t
#ifdef _WIN64
mDisasmStruct.Archi = 64;
#endif
mDisasmStruct.Options=NoformatNumeral;
mDisasmStruct.Options = NoformatNumeral;
// Check if the pointer is not null
if (data == NULL)
if(data == NULL)
return 0;
// Round the number of back instructions to 127
if(n < 0)
n = 0;
else if (n >= max_instructions)
n = max_instructions-1;
else if(n >= max_instructions)
n = max_instructions - 1;
// Check if the instruction pointer ip is not outside the memory range
if(ip >= size)
@ -114,13 +114,13 @@ ulong QBeaEngine::DisassembleNext(byte_t* data, uint_t base, uint_t size, uint_t
#ifdef _WIN64
mDisasmStruct.Archi = 64;
#endif
mDisasmStruct.Options=NoformatNumeral;
mDisasmStruct.Options = NoformatNumeral;
if(data == NULL)
return 0;
if (ip >= size)
if(ip >= size)
ip = size - 1;
if(n <= 0)
@ -167,7 +167,7 @@ Instruction_t QBeaEngine::DisassembleAt(byte_t* data, uint_t size, uint_t instIn
#ifdef _WIN64
mDisasmStruct.Archi = 64;
#endif
mDisasmStruct.Options=NoformatNumeral;
mDisasmStruct.Options = NoformatNumeral;
mDisasmStruct.EIP = (UIntPtr)((uint_t)data + (uint_t)instIndex);
mDisasmStruct.VirtualAddr = origBase + origInstRVA;
@ -178,7 +178,7 @@ Instruction_t QBeaEngine::DisassembleAt(byte_t* data, uint_t size, uint_t instIn
wInst.instStr = QString(mDisasmStruct.CompleteInstr);
int instrLen = wInst.instStr.length();
if(instrLen && wInst.instStr.at(instrLen-1)==' ')
if(instrLen && wInst.instStr.at(instrLen - 1) == ' ')
wInst.instStr.chop(1);
wInst.dump = QByteArray((char*)mDisasmStruct.EIP, len);
wInst.rva = origInstRVA;

View File

@ -23,8 +23,8 @@ class QBeaEngine
public:
explicit QBeaEngine();
ulong DisassembleBack(byte_t *data, uint_t base, uint_t size, uint_t ip, int n);
ulong DisassembleNext(byte_t *data, uint_t base, uint_t size, uint_t ip, int n);
ulong DisassembleBack(byte_t* data, uint_t base, uint_t size, uint_t ip, int n);
ulong DisassembleNext(byte_t* data, uint_t base, uint_t size, uint_t ip, int n);
Instruction_t DisassembleAt(byte_t* data, uint_t size, uint_t instIndex, uint_t origBase, uint_t origInstRVA);
signals:

View File

@ -8,7 +8,7 @@
************************************************************************************/
#ifdef BUILD_LIB
extern "C" __declspec(dllexport) int _gui_guiinit(int argc, char *argv[]);
extern "C" __declspec(dllexport) int _gui_guiinit(int argc, char* argv[]);
extern "C" __declspec(dllexport) void* _gui_sendmessage(GUIMSG type, void* param1, void* param2);
#endif

View File

@ -4,7 +4,7 @@
#include "Configuration.h"
#include <QFontDialog>
AppearanceDialog::AppearanceDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AppearanceDialog)
AppearanceDialog::AppearanceDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AppearanceDialog)
{
ui->setupUi(this);
//set window flags
@ -12,14 +12,14 @@ AppearanceDialog::AppearanceDialog(QWidget *parent) : QDialog(parent), ui(new Ui
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
setFixedSize(this->size()); //fixed size
//Colors
colorMap=&Config()->Colors;
colorBackupMap=*colorMap;
colorMap = &Config()->Colors;
colorBackupMap = *colorMap;
ui->groupColor->setEnabled(false);
ui->groupBackgroundColor->setEnabled(false);
colorInfoListInit();
//Fonts
fontMap=&Config()->Fonts;
fontBackupMap=*fontMap;
fontMap = &Config()->Fonts;
fontBackupMap = *fontMap;
fontInit();
connect(this, SIGNAL(rejected()), this, SLOT(rejectedSlot()));
}
@ -150,29 +150,29 @@ void AppearanceDialog::on_buttonBackgroundNone_clicked()
ui->editBackgroundColor->setText("#XXXXXX");
}
void AppearanceDialog::on_editBackgroundColor_textChanged(const QString &arg1)
void AppearanceDialog::on_editBackgroundColor_textChanged(const QString & arg1)
{
QString text=arg1;
QString text = arg1;
if(!arg1.length())
{
ui->editBackgroundColor->setText("#");
text=ui->editBackgroundColor->text();
text = ui->editBackgroundColor->text();
return;
}
if(arg1.at(0)!='#')
if(arg1.at(0) != '#')
{
ui->editBackgroundColor->setText("#"+arg1);
text=ui->editBackgroundColor->text();
ui->editBackgroundColor->setText("#" + arg1);
text = ui->editBackgroundColor->text();
}
QString styleSheet;
QString id=colorInfoList.at(colorInfoIndex).backgroundColorName;
if(text=="#XXXXXX")
QString id = colorInfoList.at(colorInfoIndex).backgroundColorName;
if(text == "#XXXXXX")
{
styleSheet = "border: 2px solid black; background-color: #C0C0C0";
ui->buttonBackgroundColor->setText("X");
if(colorMap->contains(id))
{
(*colorMap)[id]=Qt::transparent;
(*colorMap)[id] = Qt::transparent;
ui->buttonSave->setEnabled(true);
Config()->writeColors();
GuiUpdateAllViews();
@ -186,7 +186,7 @@ void AppearanceDialog::on_editBackgroundColor_textChanged(const QString &arg1)
styleSheet = "border: 2px solid black; background-color: " + text;
if(colorMap->contains(id))
{
(*colorMap)[id]=QColor(text);
(*colorMap)[id] = QColor(text);
ui->buttonSave->setEnabled(true);
Config()->writeColors();
GuiUpdateAllViews();
@ -202,28 +202,28 @@ void AppearanceDialog::on_editBackgroundColor_textChanged(const QString &arg1)
ui->buttonBackgroundColor->setStyleSheet(styleSheet);
}
void AppearanceDialog::on_editColor_textChanged(const QString &arg1)
void AppearanceDialog::on_editColor_textChanged(const QString & arg1)
{
QString text=arg1;
QString text = arg1;
if(!arg1.length())
{
ui->editColor->setText("#");
text=ui->editColor->text();
text = ui->editColor->text();
return;
}
if(arg1.at(0)!='#')
if(arg1.at(0) != '#')
{
ui->editColor->setText("#"+arg1);
text=ui->editColor->text();
ui->editColor->setText("#" + arg1);
text = ui->editColor->text();
}
QString id=colorInfoList.at(colorInfoIndex).colorName;
QString id = colorInfoList.at(colorInfoIndex).colorName;
QString styleSheet;
if(QColor(text).isValid())
{
styleSheet = "border: 2px solid black; background-color: " + text;
if(colorMap->contains(id))
{
(*colorMap)[id]=QColor(text);
(*colorMap)[id] = QColor(text);
ui->buttonSave->setEnabled(true);
Config()->writeColors();
GuiUpdateAllViews();
@ -241,18 +241,18 @@ void AppearanceDialog::on_editColor_textChanged(const QString &arg1)
void AppearanceDialog::on_buttonColor_clicked()
{
QColorDialog colorDialog(QColor(ui->editColor->text()), this);
if(colorDialog.exec()==QDialog::Accepted)
if(colorDialog.exec() == QDialog::Accepted)
ui->editColor->setText(colorDialog.selectedColor().name().toUpper());
}
void AppearanceDialog::on_buttonBackgroundColor_clicked()
{
QColor initialColor;
if(ui->editBackgroundColor->text().toUpper()=="#XXXXXX")
initialColor=Qt::black; //transparent will set the alpha channel, which users will forget
if(ui->editBackgroundColor->text().toUpper() == "#XXXXXX")
initialColor = Qt::black; //transparent will set the alpha channel, which users will forget
else
initialColor=QColor(ui->editBackgroundColor->text());
QColor selectedColor=QColorDialog::getColor(initialColor, this, "Select Color", QColorDialog::ShowAlphaChannel);
initialColor = QColor(ui->editBackgroundColor->text());
QColor selectedColor = QColorDialog::getColor(initialColor, this, "Select Color", QColorDialog::ShowAlphaChannel);
if(selectedColor.isValid())
{
if(!selectedColor.alpha())
@ -264,8 +264,8 @@ void AppearanceDialog::on_buttonBackgroundColor_clicked()
void AppearanceDialog::on_listColorNames_itemSelectionChanged()
{
colorInfoIndex=ui->listColorNames->row(ui->listColorNames->selectedItems().at(0));
ColorInfo info=colorInfoList.at(colorInfoIndex);
colorInfoIndex = ui->listColorNames->row(ui->listColorNames->selectedItems().at(0));
ColorInfo info = colorInfoList.at(colorInfoIndex);
defaultValueAction->setEnabled(false);
currentSettingAction->setEnabled(false);
ui->buttonSave->setEnabled(false);
@ -274,7 +274,7 @@ void AppearanceDialog::on_listColorNames_itemSelectionChanged()
if(info.colorName.length())
{
QString id=info.colorName;
QString id = info.colorName;
if(colorMap->contains(id))
{
ui->groupColor->setEnabled(true);
@ -282,10 +282,10 @@ void AppearanceDialog::on_listColorNames_itemSelectionChanged()
defaultValueAction->setEnabled(true);
currentSettingAction->setEnabled(true);
QColor color=(*colorMap)[id];
QString colorText=color.name().toUpper();
QColor color = (*colorMap)[id];
QString colorText = color.name().toUpper();
if(!color.alpha())
colorText="#XXXXXX";
colorText = "#XXXXXX";
ui->editColor->setText(colorText);
}
else
@ -296,7 +296,7 @@ void AppearanceDialog::on_listColorNames_itemSelectionChanged()
if(info.backgroundColorName.length())
{
QString id=info.backgroundColorName;
QString id = info.backgroundColorName;
if(colorMap->contains(id))
{
ui->groupBackgroundColor->setEnabled(true);
@ -304,10 +304,10 @@ void AppearanceDialog::on_listColorNames_itemSelectionChanged()
defaultValueAction->setEnabled(true);
currentSettingAction->setEnabled(true);
QColor color=(*colorMap)[id];
QString colorText=color.name().toUpper();
QColor color = (*colorMap)[id];
QString colorText = color.name().toUpper();
if(!color.alpha())
colorText="#XXXXXX";
colorText = "#XXXXXX";
ui->editBackgroundColor->setText(colorText);
}
else
@ -326,28 +326,28 @@ void AppearanceDialog::on_buttonSave_clicked()
void AppearanceDialog::defaultValueSlot()
{
ColorInfo info=colorInfoList.at(colorInfoIndex);
ColorInfo info = colorInfoList.at(colorInfoIndex);
if(info.colorName.length())
{
QString id=info.colorName;
QString id = info.colorName;
if(Config()->defaultColors.contains(id))
{
QColor color=Config()->defaultColors[id];
QString colorText=color.name().toUpper();
QColor color = Config()->defaultColors[id];
QString colorText = color.name().toUpper();
if(!color.alpha())
colorText="#XXXXXX";
colorText = "#XXXXXX";
ui->editColor->setText(colorText);
}
}
if(info.backgroundColorName.length())
{
QString id=info.backgroundColorName;
QString id = info.backgroundColorName;
if(Config()->defaultColors.contains(id))
{
QColor color=Config()->defaultColors[id];
QString colorText=color.name().toUpper();
QColor color = Config()->defaultColors[id];
QString colorText = color.name().toUpper();
if(!color.alpha())
colorText="#XXXXXX";
colorText = "#XXXXXX";
ui->editBackgroundColor->setText(colorText);
}
}
@ -355,28 +355,28 @@ void AppearanceDialog::defaultValueSlot()
void AppearanceDialog::currentSettingSlot()
{
ColorInfo info=colorInfoList.at(colorInfoIndex);
ColorInfo info = colorInfoList.at(colorInfoIndex);
if(info.colorName.length())
{
QString id=info.colorName;
QString id = info.colorName;
if(colorBackupMap.contains(id))
{
QColor color=colorBackupMap[id];
QString colorText=color.name().toUpper();
QColor color = colorBackupMap[id];
QString colorText = color.name().toUpper();
if(!color.alpha())
colorText="#XXXXXX";
colorText = "#XXXXXX";
ui->editColor->setText(colorText);
}
}
if(info.backgroundColorName.length())
{
QString id=info.backgroundColorName;
QString id = info.backgroundColorName;
if(colorBackupMap.contains(id))
{
QColor color=colorBackupMap[id];
QString colorText=color.name().toUpper();
QColor color = colorBackupMap[id];
QString colorText = color.name().toUpper();
if(!color.alpha())
colorText="#XXXXXX";
colorText = "#XXXXXX";
ui->editBackgroundColor->setText(colorText);
}
}
@ -386,12 +386,12 @@ void AppearanceDialog::colorInfoListAppend(QString propertyName, QString colorNa
{
ColorInfo info;
if(colorName.length() || backgroundColorName.length())
propertyName=" "+propertyName;
propertyName = " " + propertyName;
else
propertyName=QString(QChar(0x2022))+" "+propertyName; //bullet + space
info.propertyName=propertyName;
info.colorName=colorName;
info.backgroundColorName=backgroundColorName;
propertyName = QString(QChar(0x2022)) + " " + propertyName; //bullet + space
info.propertyName = propertyName;
info.colorName = colorName;
info.backgroundColorName = backgroundColorName;
colorInfoList.append(info);
ui->listColorNames->addItem(colorInfoList.last().propertyName);
}
@ -399,7 +399,7 @@ void AppearanceDialog::colorInfoListAppend(QString propertyName, QString colorNa
void AppearanceDialog::colorInfoListInit()
{
//clear list
colorInfoIndex=0;
colorInfoIndex = 0;
colorInfoList.clear();
//list entries
colorInfoListAppend("General Tables:", "", "");
@ -517,29 +517,29 @@ void AppearanceDialog::colorInfoListInit()
colorInfoListAppend("Memory Map Section Text", "MemoryMapSectionTextColor", "");
//dev helper
const QMap<QString, QColor>* Colors=&Config()->defaultColors;
const QMap<QString, QColor>* Colors = &Config()->defaultColors;
QString notFound;
for(int i=0; i<Colors->size(); i++)
for(int i = 0; i < Colors->size(); i++)
{
QString id=Colors->keys().at(i);
bool bFound=false;
for(int j=0; j<colorInfoList.size(); j++)
QString id = Colors->keys().at(i);
bool bFound = false;
for(int j = 0; j < colorInfoList.size(); j++)
{
if(colorInfoList.at(j).colorName==id || colorInfoList.at(j).backgroundColorName==id)
if(colorInfoList.at(j).colorName == id || colorInfoList.at(j).backgroundColorName == id)
{
bFound=true;
bFound = true;
break;
}
}
if(!bFound) //color not found in info list
notFound+=id+"\n";
notFound += id + "\n";
}
if(notFound.length())
{
QMessageBox msg(QMessageBox::Warning, "NOT FOUND IN CONFIG!", notFound);
msg.setWindowIcon(QIcon(":/icons/images/compile-warning.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
}
@ -557,9 +557,9 @@ void AppearanceDialog::colorInfoListInit()
void AppearanceDialog::fontInit()
{
isInit=true;
isInit = true;
//AbstractTableView
QFont font=fontMap->find("AbstractTableView").value();
QFont font = fontMap->find("AbstractTableView").value();
ui->fontAbstractTables->setCurrentFont(QFont(font.family()));
if(font.bold() && font.italic())
ui->fontAbstractTablesStyle->setCurrentIndex(3);
@ -569,11 +569,11 @@ void AppearanceDialog::fontInit()
ui->fontAbstractTablesStyle->setCurrentIndex(1);
else
ui->fontAbstractTablesStyle->setCurrentIndex(0);
int index=ui->fontAbstractTablesSize->findText(QString("%1").arg(font.pointSize()));
if(index!=-1)
int index = ui->fontAbstractTablesSize->findText(QString("%1").arg(font.pointSize()));
if(index != -1)
ui->fontAbstractTablesSize->setCurrentIndex(index);
//Disassembly
font=fontMap->find("Disassembly").value();
font = fontMap->find("Disassembly").value();
ui->fontDisassembly->setCurrentFont(QFont(font.family()));
if(font.bold() && font.italic())
ui->fontDisassemblyStyle->setCurrentIndex(3);
@ -583,11 +583,11 @@ void AppearanceDialog::fontInit()
ui->fontDisassemblyStyle->setCurrentIndex(1);
else
ui->fontDisassemblyStyle->setCurrentIndex(0);
index=ui->fontDisassemblySize->findText(QString("%1").arg(font.pointSize()));
if(index!=-1)
index = ui->fontDisassemblySize->findText(QString("%1").arg(font.pointSize()));
if(index != -1)
ui->fontDisassemblySize->setCurrentIndex(index);
//HexDump
font=fontMap->find("HexDump").value();
font = fontMap->find("HexDump").value();
ui->fontHexDump->setCurrentFont(QFont(font.family()));
if(font.bold() && font.italic())
ui->fontHexDumpStyle->setCurrentIndex(3);
@ -597,11 +597,11 @@ void AppearanceDialog::fontInit()
ui->fontHexDumpStyle->setCurrentIndex(1);
else
ui->fontHexDumpStyle->setCurrentIndex(0);
index=ui->fontHexDumpSize->findText(QString("%1").arg(font.pointSize()));
if(index!=-1)
index = ui->fontHexDumpSize->findText(QString("%1").arg(font.pointSize()));
if(index != -1)
ui->fontHexDumpSize->setCurrentIndex(index);
//Stack
font=fontMap->find("Stack").value();
font = fontMap->find("Stack").value();
ui->fontStack->setCurrentFont(QFont(font.family()));
if(font.bold() && font.italic())
ui->fontStackStyle->setCurrentIndex(3);
@ -611,11 +611,11 @@ void AppearanceDialog::fontInit()
ui->fontStackStyle->setCurrentIndex(1);
else
ui->fontStackStyle->setCurrentIndex(0);
index=ui->fontStackSize->findText(QString("%1").arg(font.pointSize()));
if(index!=-1)
index = ui->fontStackSize->findText(QString("%1").arg(font.pointSize()));
if(index != -1)
ui->fontStackSize->setCurrentIndex(index);
//Registers
font=fontMap->find("Registers").value();
font = fontMap->find("Registers").value();
ui->fontRegisters->setCurrentFont(QFont(font.family()));
if(font.bold() && font.italic())
ui->fontRegistersStyle->setCurrentIndex(3);
@ -625,11 +625,11 @@ void AppearanceDialog::fontInit()
ui->fontRegistersStyle->setCurrentIndex(1);
else
ui->fontRegistersStyle->setCurrentIndex(0);
index=ui->fontRegistersSize->findText(QString("%1").arg(font.pointSize()));
if(index!=-1)
index = ui->fontRegistersSize->findText(QString("%1").arg(font.pointSize()));
if(index != -1)
ui->fontRegistersSize->setCurrentIndex(index);
//HexEdit
font=fontMap->find("HexEdit").value();
font = fontMap->find("HexEdit").value();
ui->fontHexEdit->setCurrentFont(QFont(font.family()));
if(font.bold() && font.italic())
ui->fontHexEditStyle->setCurrentIndex(3);
@ -639,20 +639,20 @@ void AppearanceDialog::fontInit()
ui->fontHexEditStyle->setCurrentIndex(1);
else
ui->fontHexEditStyle->setCurrentIndex(0);
index=ui->fontHexEditSize->findText(QString("%1").arg(font.pointSize()));
if(index!=-1)
index = ui->fontHexEditSize->findText(QString("%1").arg(font.pointSize()));
if(index != -1)
ui->fontHexEditSize->setCurrentIndex(index);
//Application
ui->labelApplicationFont->setText(fontMap->find("Application").value().family());
isInit=false;
isInit = false;
}
void AppearanceDialog::on_fontAbstractTables_currentFontChanged(const QFont &f)
void AppearanceDialog::on_fontAbstractTables_currentFontChanged(const QFont & f)
{
QString id="AbstractTableView";
QFont font=fontMap->find(id).value();
QString id = "AbstractTableView";
QFont font = fontMap->find(id).value();
font.setFamily(f.family());
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
@ -661,39 +661,39 @@ void AppearanceDialog::on_fontAbstractTables_currentFontChanged(const QFont &f)
void AppearanceDialog::on_fontAbstractTablesStyle_currentIndexChanged(int index)
{
QString id="AbstractTableView";
QFont font=fontMap->find(id).value();
QString id = "AbstractTableView";
QFont font = fontMap->find(id).value();
font.setBold(false);
font.setItalic(false);
if(index==1 || index==3)
if(index == 1 || index == 3)
font.setBold(true);
if(index==2 || index==3)
if(index == 2 || index == 3)
font.setItalic(true);
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
GuiUpdateAllViews();
}
void AppearanceDialog::on_fontAbstractTablesSize_currentIndexChanged(const QString &arg1)
void AppearanceDialog::on_fontAbstractTablesSize_currentIndexChanged(const QString & arg1)
{
QString id="AbstractTableView";
QFont font=fontMap->find(id).value();
QString id = "AbstractTableView";
QFont font = fontMap->find(id).value();
font.setPointSize(arg1.toInt());
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
GuiUpdateAllViews();
}
void AppearanceDialog::on_fontDisassembly_currentFontChanged(const QFont &f)
void AppearanceDialog::on_fontDisassembly_currentFontChanged(const QFont & f)
{
QString id="Disassembly";
QFont font=fontMap->find(id).value();
QString id = "Disassembly";
QFont font = fontMap->find(id).value();
font.setFamily(f.family());
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
@ -702,39 +702,39 @@ void AppearanceDialog::on_fontDisassembly_currentFontChanged(const QFont &f)
void AppearanceDialog::on_fontDisassemblyStyle_currentIndexChanged(int index)
{
QString id="Disassembly";
QFont font=fontMap->find(id).value();
QString id = "Disassembly";
QFont font = fontMap->find(id).value();
font.setBold(false);
font.setItalic(false);
if(index==1 || index==3)
if(index == 1 || index == 3)
font.setBold(true);
if(index==2 || index==3)
if(index == 2 || index == 3)
font.setItalic(true);
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
GuiUpdateAllViews();
}
void AppearanceDialog::on_fontDisassemblySize_currentIndexChanged(const QString &arg1)
void AppearanceDialog::on_fontDisassemblySize_currentIndexChanged(const QString & arg1)
{
QString id="Disassembly";
QFont font=fontMap->find(id).value();
QString id = "Disassembly";
QFont font = fontMap->find(id).value();
font.setPointSize(arg1.toInt());
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
GuiUpdateAllViews();
}
void AppearanceDialog::on_fontHexDump_currentFontChanged(const QFont &f)
void AppearanceDialog::on_fontHexDump_currentFontChanged(const QFont & f)
{
QString id="HexDump";
QFont font=fontMap->find(id).value();
QString id = "HexDump";
QFont font = fontMap->find(id).value();
font.setFamily(f.family());
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
@ -743,39 +743,39 @@ void AppearanceDialog::on_fontHexDump_currentFontChanged(const QFont &f)
void AppearanceDialog::on_fontHexDumpStyle_currentIndexChanged(int index)
{
QString id="HexDump";
QFont font=fontMap->find(id).value();
QString id = "HexDump";
QFont font = fontMap->find(id).value();
font.setBold(false);
font.setItalic(false);
if(index==1 || index==3)
if(index == 1 || index == 3)
font.setBold(true);
if(index==2 || index==3)
if(index == 2 || index == 3)
font.setItalic(true);
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
GuiUpdateAllViews();
}
void AppearanceDialog::on_fontHexDumpSize_currentIndexChanged(const QString &arg1)
void AppearanceDialog::on_fontHexDumpSize_currentIndexChanged(const QString & arg1)
{
QString id="HexDump";
QFont font=fontMap->find(id).value();
QString id = "HexDump";
QFont font = fontMap->find(id).value();
font.setPointSize(arg1.toInt());
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
GuiUpdateAllViews();
}
void AppearanceDialog::on_fontStack_currentFontChanged(const QFont &f)
void AppearanceDialog::on_fontStack_currentFontChanged(const QFont & f)
{
QString id="Stack";
QFont font=fontMap->find(id).value();
QString id = "Stack";
QFont font = fontMap->find(id).value();
font.setFamily(f.family());
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
@ -784,39 +784,39 @@ void AppearanceDialog::on_fontStack_currentFontChanged(const QFont &f)
void AppearanceDialog::on_fontStackStyle_currentIndexChanged(int index)
{
QString id="Stack";
QFont font=fontMap->find(id).value();
QString id = "Stack";
QFont font = fontMap->find(id).value();
font.setBold(false);
font.setItalic(false);
if(index==1 || index==3)
if(index == 1 || index == 3)
font.setBold(true);
if(index==2 || index==3)
if(index == 2 || index == 3)
font.setItalic(true);
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
GuiUpdateAllViews();
}
void AppearanceDialog::on_fontStackSize_currentIndexChanged(const QString &arg1)
void AppearanceDialog::on_fontStackSize_currentIndexChanged(const QString & arg1)
{
QString id="Stack";
QFont font=fontMap->find(id).value();
QString id = "Stack";
QFont font = fontMap->find(id).value();
font.setPointSize(arg1.toInt());
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
GuiUpdateAllViews();
}
void AppearanceDialog::on_fontRegisters_currentFontChanged(const QFont &f)
void AppearanceDialog::on_fontRegisters_currentFontChanged(const QFont & f)
{
QString id="Registers";
QFont font=fontMap->find(id).value();
QString id = "Registers";
QFont font = fontMap->find(id).value();
font.setFamily(f.family());
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
@ -825,39 +825,39 @@ void AppearanceDialog::on_fontRegisters_currentFontChanged(const QFont &f)
void AppearanceDialog::on_fontRegistersStyle_currentIndexChanged(int index)
{
QString id="Registers";
QFont font=fontMap->find(id).value();
QString id = "Registers";
QFont font = fontMap->find(id).value();
font.setBold(false);
font.setItalic(false);
if(index==1 || index==3)
if(index == 1 || index == 3)
font.setBold(true);
if(index==2 || index==3)
if(index == 2 || index == 3)
font.setItalic(true);
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
GuiUpdateAllViews();
}
void AppearanceDialog::on_fontRegistersSize_currentIndexChanged(const QString &arg1)
void AppearanceDialog::on_fontRegistersSize_currentIndexChanged(const QString & arg1)
{
QString id="Registers";
QFont font=fontMap->find(id).value();
QString id = "Registers";
QFont font = fontMap->find(id).value();
font.setPointSize(arg1.toInt());
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
GuiUpdateAllViews();
}
void AppearanceDialog::on_fontHexEdit_currentFontChanged(const QFont &f)
void AppearanceDialog::on_fontHexEdit_currentFontChanged(const QFont & f)
{
QString id="HexEdit";
QFont font=fontMap->find(id).value();
QString id = "HexEdit";
QFont font = fontMap->find(id).value();
font.setFamily(f.family());
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
@ -866,27 +866,27 @@ void AppearanceDialog::on_fontHexEdit_currentFontChanged(const QFont &f)
void AppearanceDialog::on_fontHexEditStyle_currentIndexChanged(int index)
{
QString id="HexEdit";
QFont font=fontMap->find(id).value();
QString id = "HexEdit";
QFont font = fontMap->find(id).value();
font.setBold(false);
font.setItalic(false);
if(index==1 || index==3)
if(index == 1 || index == 3)
font.setBold(true);
if(index==2 || index==3)
if(index == 2 || index == 3)
font.setItalic(true);
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
GuiUpdateAllViews();
}
void AppearanceDialog::on_fontHexEditSize_currentIndexChanged(const QString &arg1)
void AppearanceDialog::on_fontHexEditSize_currentIndexChanged(const QString & arg1)
{
QString id="HexEdit";
QFont font=fontMap->find(id).value();
QString id = "HexEdit";
QFont font = fontMap->find(id).value();
font.setPointSize(arg1.toInt());
(*fontMap)[id]=font;
(*fontMap)[id] = font;
if(isInit)
return;
Config()->writeFonts();
@ -895,12 +895,12 @@ void AppearanceDialog::on_fontHexEditSize_currentIndexChanged(const QString &arg
void AppearanceDialog::on_buttonApplicationFont_clicked()
{
QString id="Application";
QString id = "Application";
QFontDialog fontDialog(this);
fontDialog.setCurrentFont(fontMap->find(id).value());
if(fontDialog.exec()!=QDialog::Accepted)
if(fontDialog.exec() != QDialog::Accepted)
return;
(*fontMap)[id]=fontDialog.currentFont();
(*fontMap)[id] = fontDialog.currentFont();
ui->labelApplicationFont->setText(fontDialog.currentFont().family());
if(isInit)
return;
@ -910,19 +910,19 @@ void AppearanceDialog::on_buttonApplicationFont_clicked()
void AppearanceDialog::on_buttonFontDefaults_clicked()
{
(*fontMap)=Config()->defaultFonts;
isInit=true;
(*fontMap) = Config()->defaultFonts;
isInit = true;
fontInit();
isInit=false;
isInit = false;
Config()->writeFonts();
GuiUpdateAllViews();
}
void AppearanceDialog::rejectedSlot()
{
Config()->Colors=colorBackupMap;
Config()->Colors = colorBackupMap;
Config()->writeColors();
Config()->Fonts=fontBackupMap;
Config()->Fonts = fontBackupMap;
Config()->writeFonts();
GuiUpdateAllViews();
}

View File

@ -16,7 +16,7 @@ class AppearanceDialog : public QDialog
Q_OBJECT
public:
explicit AppearanceDialog(QWidget *parent = 0);
explicit AppearanceDialog(QWidget* parent = 0);
~AppearanceDialog();
private slots:
@ -44,38 +44,38 @@ private slots:
void on_buttonBackgroundFF0000_clicked();
void on_buttonBackgroundFFFF00_clicked();
void on_buttonBackgroundNone_clicked();
void on_editBackgroundColor_textChanged(const QString &arg1);
void on_editColor_textChanged(const QString &arg1);
void on_editBackgroundColor_textChanged(const QString & arg1);
void on_editColor_textChanged(const QString & arg1);
void on_buttonColor_clicked();
void on_buttonBackgroundColor_clicked();
void on_buttonSave_clicked();
void on_listColorNames_itemSelectionChanged();
void defaultValueSlot();
void currentSettingSlot();
void on_fontAbstractTables_currentFontChanged(const QFont &f);
void on_fontAbstractTables_currentFontChanged(const QFont & f);
void on_fontAbstractTablesStyle_currentIndexChanged(int index);
void on_fontAbstractTablesSize_currentIndexChanged(const QString &arg1);
void on_fontDisassembly_currentFontChanged(const QFont &f);
void on_fontAbstractTablesSize_currentIndexChanged(const QString & arg1);
void on_fontDisassembly_currentFontChanged(const QFont & f);
void on_fontDisassemblyStyle_currentIndexChanged(int index);
void on_fontDisassemblySize_currentIndexChanged(const QString &arg1);
void on_fontHexDump_currentFontChanged(const QFont &f);
void on_fontDisassemblySize_currentIndexChanged(const QString & arg1);
void on_fontHexDump_currentFontChanged(const QFont & f);
void on_fontHexDumpStyle_currentIndexChanged(int index);
void on_fontHexDumpSize_currentIndexChanged(const QString &arg1);
void on_fontStack_currentFontChanged(const QFont &f);
void on_fontHexDumpSize_currentIndexChanged(const QString & arg1);
void on_fontStack_currentFontChanged(const QFont & f);
void on_fontStackStyle_currentIndexChanged(int index);
void on_fontStackSize_currentIndexChanged(const QString &arg1);
void on_fontRegisters_currentFontChanged(const QFont &f);
void on_fontStackSize_currentIndexChanged(const QString & arg1);
void on_fontRegisters_currentFontChanged(const QFont & f);
void on_fontRegistersStyle_currentIndexChanged(int index);
void on_fontRegistersSize_currentIndexChanged(const QString &arg1);
void on_fontHexEdit_currentFontChanged(const QFont &f);
void on_fontRegistersSize_currentIndexChanged(const QString & arg1);
void on_fontHexEdit_currentFontChanged(const QFont & f);
void on_fontHexEditStyle_currentIndexChanged(int index);
void on_fontHexEditSize_currentIndexChanged(const QString &arg1);
void on_fontHexEditSize_currentIndexChanged(const QString & arg1);
void on_buttonApplicationFont_clicked();
void on_buttonFontDefaults_clicked();
void rejectedSlot();
private:
Ui::AppearanceDialog *ui;
Ui::AppearanceDialog* ui;
struct ColorInfo
{

View File

@ -1,35 +1,35 @@
#include "BreakpointsView.h"
#include "Configuration.h"
BreakpointsView::BreakpointsView(QWidget *parent) : QWidget(parent)
BreakpointsView::BreakpointsView(QWidget* parent) : QWidget(parent)
{
// Software
mSoftBPTable = new StdTable(this);
int wCharWidth = mSoftBPTable->getCharWidth();
mSoftBPTable->setContextMenuPolicy(Qt::CustomContextMenu);
mSoftBPTable->addColumnAt(8+wCharWidth*2*sizeof(uint_t), "Software", false, "Address");
mSoftBPTable->addColumnAt(8+wCharWidth*32, "Name", false);
mSoftBPTable->addColumnAt(8+wCharWidth*32, "Module/Label", false);
mSoftBPTable->addColumnAt(8+wCharWidth*8, "State", false);
mSoftBPTable->addColumnAt(wCharWidth*10, "Comment", false);
mSoftBPTable->addColumnAt(8 + wCharWidth * 2 * sizeof(uint_t), "Software", false, "Address");
mSoftBPTable->addColumnAt(8 + wCharWidth * 32, "Name", false);
mSoftBPTable->addColumnAt(8 + wCharWidth * 32, "Module/Label", false);
mSoftBPTable->addColumnAt(8 + wCharWidth * 8, "State", false);
mSoftBPTable->addColumnAt(wCharWidth * 10, "Comment", false);
// Hardware
mHardBPTable = new StdTable(this);
mHardBPTable->setContextMenuPolicy(Qt::CustomContextMenu);
mHardBPTable->addColumnAt(8+wCharWidth*2*sizeof(uint_t), "Hardware", false, "Address");
mHardBPTable->addColumnAt(8+wCharWidth*32, "Name", false);
mHardBPTable->addColumnAt(8+wCharWidth*32, "Module/Label", false);
mHardBPTable->addColumnAt(8+wCharWidth*8, "State", false);
mHardBPTable->addColumnAt(wCharWidth*10, "Comment", false);
mHardBPTable->addColumnAt(8 + wCharWidth * 2 * sizeof(uint_t), "Hardware", false, "Address");
mHardBPTable->addColumnAt(8 + wCharWidth * 32, "Name", false);
mHardBPTable->addColumnAt(8 + wCharWidth * 32, "Module/Label", false);
mHardBPTable->addColumnAt(8 + wCharWidth * 8, "State", false);
mHardBPTable->addColumnAt(wCharWidth * 10, "Comment", false);
// Memory
mMemBPTable = new StdTable(this);
mMemBPTable->setContextMenuPolicy(Qt::CustomContextMenu);
mMemBPTable->addColumnAt(8+wCharWidth*2*sizeof(uint_t), "Memory", false, "Address");
mMemBPTable->addColumnAt(8+wCharWidth*32, "Name", false);
mMemBPTable->addColumnAt(8+wCharWidth*32, "Module/Label", false);
mMemBPTable->addColumnAt(8+wCharWidth*8, "State", false);
mMemBPTable->addColumnAt(wCharWidth*10, "Comment", false);
mMemBPTable->addColumnAt(8 + wCharWidth * 2 * sizeof(uint_t), "Memory", false, "Address");
mMemBPTable->addColumnAt(8 + wCharWidth * 32, "Name", false);
mMemBPTable->addColumnAt(8 + wCharWidth * 32, "Module/Label", false);
mMemBPTable->addColumnAt(8 + wCharWidth * 8, "State", false);
mMemBPTable->addColumnAt(wCharWidth * 10, "Comment", false);
// Splitter
mSplitter = new QSplitter(this);
@ -74,16 +74,16 @@ void BreakpointsView::reloadData()
mHardBPTable->setRowCount(wBPList.count);
for(wI = 0; wI < wBPList.count; wI++)
{
QString addr_text=QString("%1").arg(wBPList.bp[wI].addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
QString addr_text = QString("%1").arg(wBPList.bp[wI].addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
mHardBPTable->setCellContent(wI, 0, addr_text);
mHardBPTable->setCellContent(wI, 1, QString(wBPList.bp[wI].name));
QString label_text;
char label[MAX_LABEL_SIZE]="";
char label[MAX_LABEL_SIZE] = "";
if(DbgGetLabelAt(wBPList.bp[wI].addr, SEG_DEFAULT, label))
label_text="<"+QString(wBPList.bp[wI].mod)+"."+QString(label)+">";
label_text = "<" + QString(wBPList.bp[wI].mod) + "." + QString(label) + ">";
else
label_text=QString(wBPList.bp[wI].mod);
label_text = QString(wBPList.bp[wI].mod);
mHardBPTable->setCellContent(wI, 2, label_text);
if(wBPList.bp[wI].active == false)
@ -93,7 +93,7 @@ void BreakpointsView::reloadData()
else
mHardBPTable->setCellContent(wI, 3, "Disabled");
char comment[MAX_COMMENT_SIZE]="";
char comment[MAX_COMMENT_SIZE] = "";
if(DbgGetCommentAt(wBPList.bp[wI].addr, comment))
mHardBPTable->setCellContent(wI, 4, comment);
}
@ -106,16 +106,16 @@ void BreakpointsView::reloadData()
mSoftBPTable->setRowCount(wBPList.count);
for(wI = 0; wI < wBPList.count; wI++)
{
QString addr_text=QString("%1").arg(wBPList.bp[wI].addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
QString addr_text = QString("%1").arg(wBPList.bp[wI].addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
mSoftBPTable->setCellContent(wI, 0, addr_text);
mSoftBPTable->setCellContent(wI, 1, QString(wBPList.bp[wI].name));
QString label_text;
char label[MAX_LABEL_SIZE]="";
char label[MAX_LABEL_SIZE] = "";
if(DbgGetLabelAt(wBPList.bp[wI].addr, SEG_DEFAULT, label))
label_text="<"+QString(wBPList.bp[wI].mod)+"."+QString(label)+">";
label_text = "<" + QString(wBPList.bp[wI].mod) + "." + QString(label) + ">";
else
label_text=QString(wBPList.bp[wI].mod);
label_text = QString(wBPList.bp[wI].mod);
mSoftBPTable->setCellContent(wI, 2, label_text);
if(wBPList.bp[wI].active == false)
@ -125,7 +125,7 @@ void BreakpointsView::reloadData()
else
mSoftBPTable->setCellContent(wI, 3, "Disabled");
char comment[MAX_COMMENT_SIZE]="";
char comment[MAX_COMMENT_SIZE] = "";
if(DbgGetCommentAt(wBPList.bp[wI].addr, comment))
mSoftBPTable->setCellContent(wI, 4, comment);
}
@ -138,16 +138,16 @@ void BreakpointsView::reloadData()
mMemBPTable->setRowCount(wBPList.count);
for(wI = 0; wI < wBPList.count; wI++)
{
QString addr_text=QString("%1").arg(wBPList.bp[wI].addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
QString addr_text = QString("%1").arg(wBPList.bp[wI].addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
mMemBPTable->setCellContent(wI, 0, addr_text);
mMemBPTable->setCellContent(wI, 1, QString(wBPList.bp[wI].name));
QString label_text;
char label[MAX_LABEL_SIZE]="";
char label[MAX_LABEL_SIZE] = "";
if(DbgGetLabelAt(wBPList.bp[wI].addr, SEG_DEFAULT, label))
label_text="<"+QString(wBPList.bp[wI].mod)+"."+QString(label)+">";
label_text = "<" + QString(wBPList.bp[wI].mod) + "." + QString(label) + ">";
else
label_text=QString(wBPList.bp[wI].mod);
label_text = QString(wBPList.bp[wI].mod);
mMemBPTable->setCellContent(wI, 2, label_text);
if(wBPList.bp[wI].active == false)
@ -157,7 +157,7 @@ void BreakpointsView::reloadData()
else
mMemBPTable->setCellContent(wI, 3, "Disabled");
char comment[MAX_COMMENT_SIZE]="";
char comment[MAX_COMMENT_SIZE] = "";
if(DbgGetCommentAt(wBPList.bp[wI].addr, comment))
mMemBPTable->setCellContent(wI, 4, comment);
}
@ -277,7 +277,7 @@ void BreakpointsView::enableDisableHardBPActionSlot()
void BreakpointsView::doubleClickHardwareSlot()
{
QString addrText=mHardBPTable->getCellContent(mHardBPTable->getInitialSelection(), 0);
QString addrText = mHardBPTable->getCellContent(mHardBPTable->getInitialSelection(), 0);
DbgCmdExecDirect(QString("disasm " + addrText).toUtf8().constData());
emit showCpu();
}
@ -380,7 +380,7 @@ void BreakpointsView::enableDisableSoftBPActionSlot()
void BreakpointsView::doubleClickSoftwareSlot()
{
QString addrText=mSoftBPTable->getCellContent(mSoftBPTable->getInitialSelection(), 0);
QString addrText = mSoftBPTable->getCellContent(mSoftBPTable->getInitialSelection(), 0);
DbgCmdExecDirect(QString("disasm " + addrText).toUtf8().constData());
emit showCpu();
}
@ -483,7 +483,7 @@ void BreakpointsView::enableDisableMemBPActionSlot()
void BreakpointsView::doubleClickMemorySlot()
{
QString addrText=mMemBPTable->getCellContent(mMemBPTable->getInitialSelection(), 0);
QString addrText = mMemBPTable->getCellContent(mMemBPTable->getInitialSelection(), 0);
DbgCmdExecDirect(QString("disasm " + addrText).toUtf8().constData());
emit showCpu();
}

View File

@ -13,7 +13,7 @@ class BreakpointsView : public QWidget
{
Q_OBJECT
public:
explicit BreakpointsView(QWidget *parent = 0);
explicit BreakpointsView(QWidget* parent = 0);
void setupHardBPRightClickContextMenu();
void setupSoftBPRightClickContextMenu();
void setupMemBPRightClickContextMenu();
@ -26,7 +26,7 @@ public slots:
void reloadData();
// Hardware
void hardwareBPContextMenuSlot(const QPoint &pos);
void hardwareBPContextMenuSlot(const QPoint & pos);
void removeHardBPActionSlot();
void removeAllHardBPActionSlot();
void enableDisableHardBPActionSlot();

View File

@ -2,7 +2,7 @@
#include "Configuration.h"
#include "HexEditDialog.h"
CPUDisassembly::CPUDisassembly(QWidget *parent) : Disassembly(parent)
CPUDisassembly::CPUDisassembly(QWidget* parent) : Disassembly(parent)
{
// Create the action list for the right click context menu
setupRightClickContextMenu();
@ -21,7 +21,7 @@ void CPUDisassembly::mousePressEvent(QMouseEvent* event)
{
if(DbgIsDebugging())
{
QString addrText=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t)*2, 16, QChar('0')).toUpper();
QString addrText = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
Bridge::CopyToClipboard(addrText.toUtf8().constData());
}
}
@ -30,7 +30,7 @@ void CPUDisassembly::mousePressEvent(QMouseEvent* event)
Disassembly::mousePressEvent(event);
if(mHighlightingMode) //disable highlighting mode after clicked
{
mHighlightingMode=false;
mHighlightingMode = false;
reloadData();
}
}
@ -145,7 +145,7 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event)
//get enabled hwbp count
int enabledCount = wBPList.count;
for(int i=0; i<wBPList.count; i++)
for(int i = 0; i < wBPList.count; i++)
if(!wBPList.bp[i].enabled)
enabledCount--;
@ -214,12 +214,12 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event)
//remove previous actions
QList<QAction*> list = mFollowMenu->actions();
for(int i=0; i<list.length(); i++)
for(int i = 0; i < list.length(); i++)
mFollowMenu->removeAction(list.at(i));
//add follow actions
mFollowMenu->addAction(new QAction("&Selection", this));
mFollowMenu->actions().last()->setObjectName(QString("DUMP|")+QString("%1").arg(wVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper());
mFollowMenu->actions().last()->setObjectName(QString("DUMP|") + QString("%1").arg(wVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper());
connect(mFollowMenu->actions().last(), SIGNAL(triggered()), this, SLOT(followActionSlot()));
wMenu->addSeparator();
@ -601,19 +601,19 @@ void CPUDisassembly::setLabel()
return;
uint_t wVA = rvaToVa(getInitialSelection());
LineEditDialog mLineEdit(this);
QString addr_text=QString("%1").arg(wVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
char label_text[MAX_COMMENT_SIZE]="";
QString addr_text = QString("%1").arg(wVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
char label_text[MAX_COMMENT_SIZE] = "";
if(DbgGetLabelAt((duint)wVA, SEG_DEFAULT, label_text))
mLineEdit.setText(QString(label_text));
mLineEdit.setWindowTitle("Add label at " + addr_text);
if(mLineEdit.exec()!=QDialog::Accepted)
if(mLineEdit.exec() != QDialog::Accepted)
return;
if(!DbgSetLabelAt(wVA, mLineEdit.editText.toUtf8().constData()))
{
QMessageBox msg(QMessageBox::Critical, "Error!", "DbgSetLabelAt failed!");
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
}
GuiUpdateAllViews();
@ -625,19 +625,19 @@ void CPUDisassembly::setComment()
return;
uint_t wVA = rvaToVa(getInitialSelection());
LineEditDialog mLineEdit(this);
QString addr_text=QString("%1").arg(wVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
char comment_text[MAX_COMMENT_SIZE]="";
QString addr_text = QString("%1").arg(wVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
char comment_text[MAX_COMMENT_SIZE] = "";
if(DbgGetCommentAt((duint)wVA, comment_text))
mLineEdit.setText(QString(comment_text));
mLineEdit.setWindowTitle("Add comment at " + addr_text);
if(mLineEdit.exec()!=QDialog::Accepted)
if(mLineEdit.exec() != QDialog::Accepted)
return;
if(!DbgSetCommentAt(wVA, mLineEdit.editText.toUtf8().constData()))
{
QMessageBox msg(QMessageBox::Critical, "Error!", "DbgSetCommentAt failed!");
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
}
GuiUpdateAllViews();
@ -650,15 +650,15 @@ void CPUDisassembly::setBookmark()
uint_t wVA = rvaToVa(getInitialSelection());
bool result;
if(DbgGetBookmarkAt(wVA))
result=DbgSetBookmarkAt(wVA, false);
result = DbgSetBookmarkAt(wVA, false);
else
result=DbgSetBookmarkAt(wVA, true);
result = DbgSetBookmarkAt(wVA, true);
if(!result)
{
QMessageBox msg(QMessageBox::Critical, "Error!", "DbgSetBookmarkAt failed!");
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
}
GuiUpdateAllViews();
@ -670,21 +670,21 @@ void CPUDisassembly::toggleFunction()
return;
uint_t start = rvaToVa(getSelectionStart());
uint_t end = rvaToVa(getSelectionEnd());
uint_t function_start=0;
uint_t function_end=0;
uint_t function_start = 0;
uint_t function_end = 0;
if(!DbgFunctionOverlaps(start, end))
{
QString start_text=QString("%1").arg(start, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
QString end_text=QString("%1").arg(end, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
char labeltext[MAX_LABEL_SIZE]="";
QString label_text="";
QString start_text = QString("%1").arg(start, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
QString end_text = QString("%1").arg(end, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
char labeltext[MAX_LABEL_SIZE] = "";
QString label_text = "";
if(DbgGetLabelAt(start, SEG_DEFAULT, labeltext))
label_text = " (" + QString(labeltext) + ")";
QMessageBox msg(QMessageBox::Question, "Add the function?", start_text + "-" + end_text + label_text, QMessageBox::Yes|QMessageBox::No);
QMessageBox msg(QMessageBox::Question, "Add the function?", start_text + "-" + end_text + label_text, QMessageBox::Yes | QMessageBox::No);
msg.setWindowIcon(QIcon(":/icons/images/compile.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
if(msg.exec() != QMessageBox::Yes)
return;
QString cmd = "functionadd " + start_text + "," + end_text;
@ -692,23 +692,23 @@ void CPUDisassembly::toggleFunction()
}
else
{
for(uint_t i=start; i<=end; i++)
for(uint_t i = start; i <= end; i++)
{
if(DbgFunctionGet(i, &function_start, &function_end))
break;
}
QString start_text=QString("%1").arg(function_start, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
QString end_text=QString("%1").arg(function_end, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
char labeltext[MAX_LABEL_SIZE]="";
QString label_text="";
QString start_text = QString("%1").arg(function_start, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
QString end_text = QString("%1").arg(function_end, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
char labeltext[MAX_LABEL_SIZE] = "";
QString label_text = "";
if(DbgGetLabelAt(function_start, SEG_DEFAULT, labeltext))
label_text = " (" + QString(labeltext) + ")";
QMessageBox msg(QMessageBox::Warning, "Deleting function:", start_text + "-" + end_text + label_text, QMessageBox::Ok|QMessageBox::Cancel);
QMessageBox msg(QMessageBox::Warning, "Deleting function:", start_text + "-" + end_text + label_text, QMessageBox::Ok | QMessageBox::Cancel);
msg.setDefaultButton(QMessageBox::Cancel);
msg.setWindowIcon(QIcon(":/icons/images/compile-warning.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
if(msg.exec() != QMessageBox::Ok)
return;
QString cmd = "functiondel " + start_text;
@ -723,7 +723,7 @@ void CPUDisassembly::assembleAt()
int_t wRVA = getInitialSelection();
uint_t wVA = rvaToVa(wRVA);
LineEditDialog mLineEdit(this);
QString addr_text=QString("%1").arg(wVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
QString addr_text = QString("%1").arg(wVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
QByteArray wBuffer;
@ -732,7 +732,7 @@ void CPUDisassembly::assembleAt()
//TODO: fix size problems
int_t size = getSize();
if(!size)
size=wRVA;
size = wRVA;
// Bounding
wMaxByteCountToRead = wMaxByteCountToRead > (size - wRVA) ? (size - wRVA) : wMaxByteCountToRead;
@ -742,24 +742,24 @@ void CPUDisassembly::assembleAt()
mMemPage->read(reinterpret_cast<byte_t*>(wBuffer.data()), wRVA, wMaxByteCountToRead);
QBeaEngine* disasm = new QBeaEngine();
Instruction_t instr=disasm->DisassembleAt(reinterpret_cast<byte_t*>(wBuffer.data()), wMaxByteCountToRead, 0, 0, wVA);
Instruction_t instr = disasm->DisassembleAt(reinterpret_cast<byte_t*>(wBuffer.data()), wMaxByteCountToRead, 0, 0, wVA);
mLineEdit.setText(instr.instStr);
mLineEdit.setWindowTitle("Assemble at " + addr_text);
mLineEdit.setCheckBoxText("&Fill with NOP's");
mLineEdit.enableCheckBox(true);
mLineEdit.setCheckBox(ConfigBool("Disassembler", "FillNOPs"));
if(mLineEdit.exec()!=QDialog::Accepted)
if(mLineEdit.exec() != QDialog::Accepted)
return;
Config()->setBool("Disassembler", "FillNOPs", mLineEdit.bChecked);
char error[MAX_ERROR_SIZE]="";
char error[MAX_ERROR_SIZE] = "";
if(!DbgFunctions()->AssembleAtEx(wVA, mLineEdit.editText.toUtf8().constData(), error, mLineEdit.bChecked))
{
QMessageBox msg(QMessageBox::Critical, "Error!", "Failed to assemble instruction \"" + mLineEdit.editText + "\" (" + error + ")");
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
return;
}
@ -778,7 +778,7 @@ void CPUDisassembly::gotoExpression()
return;
if(!mGoto)
mGoto = new GotoDialog(this);
if(mGoto->exec()==QDialog::Accepted)
if(mGoto->exec() == QDialog::Accepted)
{
DbgCmdExec(QString().sprintf("disasm \"%s\"", mGoto->expressionText.toUtf8().constData()).toUtf8().constData());
}
@ -803,7 +803,7 @@ void CPUDisassembly::gotoNext()
void CPUDisassembly::findReferences()
{
QString addrText=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t)*2, 16, QChar('0')).toUpper();
QString addrText = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("findref " + addrText + ", " + addrText).toUtf8().constData());
emit displayReferencesWidget();
}
@ -814,22 +814,22 @@ void CPUDisassembly::findConstant()
wordEdit.setup("Enter Constant", 0, sizeof(int_t));
if(wordEdit.exec() != QDialog::Accepted) //cancel pressed
return;
QString addrText=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t)*2, 16, QChar('0')).toUpper();
QString constText=QString("%1").arg(wordEdit.getVal(), sizeof(int_t)*2, 16, QChar('0')).toUpper();
QString addrText = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
QString constText = QString("%1").arg(wordEdit.getVal(), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("findref " + constText + ", " + addrText).toUtf8().constData());
emit displayReferencesWidget();
}
void CPUDisassembly::findStrings()
{
QString addrText=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t)*2, 16, QChar('0')).toUpper();
QString addrText = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("strref " + addrText).toUtf8().constData());
emit displayReferencesWidget();
}
void CPUDisassembly::findCalls()
{
QString addrText=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t)*2, 16, QChar('0')).toUpper();
QString addrText = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("modcallfind " + addrText).toUtf8().constData());
emit displayReferencesWidget();
}
@ -845,24 +845,24 @@ void CPUDisassembly::findPattern()
int_t addr = rvaToVa(getSelectionStart());
if(hexEdit.entireBlock())
addr = DbgMemFindBaseAddr(addr, 0);
QString addrText=QString("%1").arg(addr, sizeof(int_t)*2, 16, QChar('0')).toUpper();
QString addrText = QString("%1").arg(addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("findall " + addrText + ", " + hexEdit.mHexEdit->pattern()).toUtf8().constData());
emit displayReferencesWidget();
}
void CPUDisassembly::selectionGet(SELECTIONDATA* selection)
{
selection->start=rvaToVa(getSelectionStart());
selection->end=rvaToVa(getSelectionEnd());
selection->start = rvaToVa(getSelectionStart());
selection->end = rvaToVa(getSelectionEnd());
Bridge::getBridge()->BridgeSetResult(1);
}
void CPUDisassembly::selectionSet(const SELECTIONDATA* selection)
{
int_t selMin=getBase();
int_t selMax=selMin + getSize();
int_t start=selection->start;
int_t end=selection->end;
int_t selMin = getBase();
int_t selMax = selMin + getSize();
int_t start = selection->start;
int_t end = selection->end;
if(start < selMin || start >= selMax || end < selMin || end >= selMax) //selection out of range
{
Bridge::getBridge()->BridgeSetResult(0);
@ -877,9 +877,9 @@ void CPUDisassembly::selectionSet(const SELECTIONDATA* selection)
void CPUDisassembly::enableHighlightingMode()
{
if(mHighlightingMode)
mHighlightingMode=false;
mHighlightingMode = false;
else
mHighlightingMode=true;
mHighlightingMode = true;
reloadData();
}
@ -956,7 +956,7 @@ void CPUDisassembly::binaryPasteSlot()
HexEditDialog hexEdit(this);
int_t selStart = getSelectionStart();
int_t selSize = getSelectionEnd() - selStart + 1;
QClipboard *clipboard = QApplication::clipboard();
QClipboard* clipboard = QApplication::clipboard();
hexEdit.mHexEdit->setData(clipboard->text());
byte_t* data = new byte_t[selSize];
@ -983,7 +983,7 @@ void CPUDisassembly::binaryPasteIgnoreSizeSlot()
HexEditDialog hexEdit(this);
int_t selStart = getSelectionStart();
int_t selSize = getSelectionEnd() - selStart + 1;
QClipboard *clipboard = QApplication::clipboard();
QClipboard* clipboard = QApplication::clipboard();
hexEdit.mHexEdit->setData(clipboard->text());
byte_t* data = new byte_t[selSize];

View File

@ -18,7 +18,7 @@ class CPUDisassembly : public Disassembly
{
Q_OBJECT
public:
explicit CPUDisassembly(QWidget *parent = 0);
explicit CPUDisassembly(QWidget* parent = 0);
// Mouse Management
void contextMenuEvent(QContextMenuEvent* event);

View File

@ -2,7 +2,7 @@
#include "Configuration.h"
#include "HexEditDialog.h"
CPUDump::CPUDump(QWidget *parent) : HexDump(parent)
CPUDump::CPUDump(QWidget* parent) : HexDump(parent)
{
switch((ViewEnum_t)ConfigUint("HexDump", "DefaultView"))
{
@ -344,44 +344,44 @@ QString CPUDump::paintContent(QPainter* painter, int_t rowBase, int rowOffset, i
QString wStr = "";
if(!col) //address
{
char label[MAX_LABEL_SIZE]="";
QString addrText="";
char label[MAX_LABEL_SIZE] = "";
QString addrText = "";
int_t curAddr = rvaToVa((rowBase + rowOffset) * getBytePerRowCount() - mByteOffset);
addrText = QString("%1").arg(curAddr, sizeof(int_t)*2, 16, QChar('0')).toUpper();
addrText = QString("%1").arg(curAddr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
if(DbgGetLabelAt(curAddr, SEG_DEFAULT, label)) //has label
{
char module[MAX_MODULE_SIZE]="";
char module[MAX_MODULE_SIZE] = "";
if(DbgGetModuleAt(curAddr, module) && !QString(label).startsWith("JMP.&"))
addrText+=" <"+QString(module)+"."+QString(label)+">";
addrText += " <" + QString(module) + "." + QString(label) + ">";
else
addrText+=" <"+QString(label)+">";
addrText += " <" + QString(label) + ">";
}
else
*label=0;
*label = 0;
if(*label) //label
{
QColor background=ConfigColor("HexDumpLabelBackgroundColor");
QColor background = ConfigColor("HexDumpLabelBackgroundColor");
if(background.alpha())
painter->fillRect(QRect(x, y, w, h), QBrush(background)); //fill bookmark color
painter->setPen(ConfigColor("HexDumpLabelColor")); //TODO: config
}
else
{
QColor background=ConfigColor("HexDumpAddressBackgroundColor");
QColor background = ConfigColor("HexDumpAddressBackgroundColor");
if(background.alpha())
painter->fillRect(QRect(x, y, w, h), QBrush(background)); //fill bookmark color
painter->setPen(ConfigColor("HexDumpAddressColor")); //TODO: config
}
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, addrText);
}
else if(col && mDescriptor.at(col - 1).isData == false && mDescriptor.at(col -1).itemCount == 1) //print comments
else if(col && mDescriptor.at(col - 1).isData == false && mDescriptor.at(col - 1).itemCount == 1) //print comments
{
uint_t data=0;
uint_t data = 0;
int_t wRva = (rowBase + rowOffset) * getBytePerRowCount() - mByteOffset;
mMemPage->read((byte_t*)&data, wRva, sizeof(uint_t));
char label_text[MAX_LABEL_SIZE]="";
char label_text[MAX_LABEL_SIZE] = "";
if(DbgGetLabelAt(data, SEG_DEFAULT, label_text))
wStr=QString(label_text);
wStr = QString(label_text);
}
else //data
{
@ -413,7 +413,7 @@ void CPUDump::contextMenuEvent(QContextMenuEvent* event)
wMenu->addAction(mDisassemblyAction);
int_t selectedAddr = rvaToVa(getInitialSelection());
if((DbgGetBpxTypeAt(selectedAddr)&bp_hardware)==bp_hardware) //hardware breakpoint set
if((DbgGetBpxTypeAt(selectedAddr)&bp_hardware) == bp_hardware) //hardware breakpoint set
{
mHardwareAccessMenu->menuAction()->setVisible(false);
mHardwareWriteMenu->menuAction()->setVisible(false);
@ -427,7 +427,7 @@ void CPUDump::contextMenuEvent(QContextMenuEvent* event)
mHardwareExecute->setVisible(true);
mHardwareRemove->setVisible(false);
}
if((DbgGetBpxTypeAt(selectedAddr)&bp_memory)==bp_memory) //memory breakpoint set
if((DbgGetBpxTypeAt(selectedAddr)&bp_memory) == bp_memory) //memory breakpoint set
{
mMemoryAccessMenu->menuAction()->setVisible(false);
mMemoryWriteMenu->menuAction()->setVisible(false);
@ -452,19 +452,19 @@ void CPUDump::setLabelSlot()
uint_t wVA = rvaToVa(getSelectionStart());
LineEditDialog mLineEdit(this);
QString addr_text=QString("%1").arg(wVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
char label_text[MAX_COMMENT_SIZE]="";
QString addr_text = QString("%1").arg(wVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
char label_text[MAX_COMMENT_SIZE] = "";
if(DbgGetLabelAt((duint)wVA, SEG_DEFAULT, label_text))
mLineEdit.setText(QString(label_text));
mLineEdit.setWindowTitle("Add label at " + addr_text);
if(mLineEdit.exec()!=QDialog::Accepted)
if(mLineEdit.exec() != QDialog::Accepted)
return;
if(!DbgSetLabelAt(wVA, mLineEdit.editText.toUtf8().constData()))
{
QMessageBox msg(QMessageBox::Critical, "Error!", "DbgSetLabelAt failed!");
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
}
GuiUpdateAllViews();
@ -477,7 +477,7 @@ void CPUDump::gotoExpressionSlot()
if(!mGoto)
mGoto = new GotoDialog(this);
mGoto->setWindowTitle("Enter expression to follow in Dump...");
if(mGoto->exec()==QDialog::Accepted)
if(mGoto->exec() == QDialog::Accepted)
{
QString cmd;
DbgCmdExec(cmd.sprintf("dump \"%s\"", mGoto->expressionText.toUtf8().constData()).toUtf8().constData());
@ -487,7 +487,7 @@ void CPUDump::gotoExpressionSlot()
void CPUDump::hexAsciiSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewHexAscii);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -496,14 +496,14 @@ void CPUDump::hexAsciiSlot()
dDesc.itemSize = Byte;
dDesc.byteMode = HexByte;
wColDesc.data = dDesc;
appendResetDescriptor(8+charwidth*47, "Hex", false, wColDesc);
appendResetDescriptor(8 + charwidth * 47, "Hex", false, wColDesc);
wColDesc.isData = true; //ascii byte
wColDesc.itemCount = 16;
dDesc.itemSize = Byte;
dDesc.byteMode = AsciiByte;
wColDesc.data = dDesc;
appendDescriptor(8+charwidth*16, "ASCII", false, wColDesc);
appendDescriptor(8 + charwidth * 16, "ASCII", false, wColDesc);
wColDesc.isData = false; //empty column
wColDesc.itemCount = 0;
@ -518,7 +518,7 @@ void CPUDump::hexAsciiSlot()
void CPUDump::hexUnicodeSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewHexUnicode);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -527,14 +527,14 @@ void CPUDump::hexUnicodeSlot()
dDesc.itemSize = Byte;
dDesc.byteMode = HexByte;
wColDesc.data = dDesc;
appendResetDescriptor(8+charwidth*47, "Hex", false, wColDesc);
appendResetDescriptor(8 + charwidth * 47, "Hex", false, wColDesc);
wColDesc.isData = true; //unicode short
wColDesc.itemCount = 8;
dDesc.itemSize = Word;
dDesc.wordMode = UnicodeWord;
wColDesc.data = dDesc;
appendDescriptor(8+charwidth*8, "UNICODE", false, wColDesc);
appendDescriptor(8 + charwidth * 8, "UNICODE", false, wColDesc);
wColDesc.isData = false; //empty column
wColDesc.itemCount = 0;
@ -549,7 +549,7 @@ void CPUDump::hexUnicodeSlot()
void CPUDump::textAsciiSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewTextAscii);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -558,7 +558,7 @@ void CPUDump::textAsciiSlot()
dDesc.itemSize = Byte;
dDesc.byteMode = AsciiByte;
wColDesc.data = dDesc;
appendResetDescriptor(8+charwidth*64, "ASCII", false, wColDesc);
appendResetDescriptor(8 + charwidth * 64, "ASCII", false, wColDesc);
wColDesc.isData = false; //empty column
wColDesc.itemCount = 0;
@ -573,7 +573,7 @@ void CPUDump::textAsciiSlot()
void CPUDump::textUnicodeSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewTextUnicode);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -582,7 +582,7 @@ void CPUDump::textUnicodeSlot()
dDesc.itemSize = Word;
dDesc.wordMode = UnicodeWord;
wColDesc.data = dDesc;
appendResetDescriptor(8+charwidth*64, "UNICODE", false, wColDesc);
appendResetDescriptor(8 + charwidth * 64, "UNICODE", false, wColDesc);
wColDesc.isData = false; //empty column
wColDesc.itemCount = 0;
@ -597,7 +597,7 @@ void CPUDump::textUnicodeSlot()
void CPUDump::integerSignedShortSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewIntegerSignedShort);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -605,7 +605,7 @@ void CPUDump::integerSignedShortSlot()
wColDesc.itemCount = 8;
wColDesc.data.itemSize = Word;
wColDesc.data.wordMode = SignedDecWord;
appendResetDescriptor(8+charwidth*55, "Signed short (16-bit)", false, wColDesc);
appendResetDescriptor(8 + charwidth * 55, "Signed short (16-bit)", false, wColDesc);
wColDesc.isData = false; //empty column
wColDesc.itemCount = 0;
@ -620,7 +620,7 @@ void CPUDump::integerSignedShortSlot()
void CPUDump::integerSignedLongSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewIntegerSignedLong);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -628,7 +628,7 @@ void CPUDump::integerSignedLongSlot()
wColDesc.itemCount = 4;
wColDesc.data.itemSize = Dword;
wColDesc.data.dwordMode = SignedDecDword;
appendResetDescriptor(8+charwidth*47, "Signed long (32-bit)", false, wColDesc);
appendResetDescriptor(8 + charwidth * 47, "Signed long (32-bit)", false, wColDesc);
wColDesc.isData = false; //empty column
wColDesc.itemCount = 0;
@ -643,7 +643,7 @@ void CPUDump::integerSignedLongSlot()
void CPUDump::integerSignedLongLongSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewIntegerSignedLongLong);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -651,7 +651,7 @@ void CPUDump::integerSignedLongLongSlot()
wColDesc.itemCount = 2;
wColDesc.data.itemSize = Qword;
wColDesc.data.qwordMode = SignedDecQword;
appendResetDescriptor(8+charwidth*41, "Signed long long (64-bit)", false, wColDesc);
appendResetDescriptor(8 + charwidth * 41, "Signed long long (64-bit)", false, wColDesc);
wColDesc.isData = false; //empty column
wColDesc.itemCount = 0;
@ -666,7 +666,7 @@ void CPUDump::integerSignedLongLongSlot()
void CPUDump::integerUnsignedShortSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewIntegerUnsignedShort);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -674,7 +674,7 @@ void CPUDump::integerUnsignedShortSlot()
wColDesc.itemCount = 8;
wColDesc.data.itemSize = Word;
wColDesc.data.wordMode = UnsignedDecWord;
appendResetDescriptor(8+charwidth*47, "Unsigned short (16-bit)", false, wColDesc);
appendResetDescriptor(8 + charwidth * 47, "Unsigned short (16-bit)", false, wColDesc);
wColDesc.isData = false; //empty column
wColDesc.itemCount = 0;
@ -689,7 +689,7 @@ void CPUDump::integerUnsignedShortSlot()
void CPUDump::integerUnsignedLongSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewIntegerUnsignedLong);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -697,7 +697,7 @@ void CPUDump::integerUnsignedLongSlot()
wColDesc.itemCount = 4;
wColDesc.data.itemSize = Dword;
wColDesc.data.dwordMode = UnsignedDecDword;
appendResetDescriptor(8+charwidth*43, "Unsigned long (32-bit)", false, wColDesc);
appendResetDescriptor(8 + charwidth * 43, "Unsigned long (32-bit)", false, wColDesc);
wColDesc.isData = false; //empty column
wColDesc.itemCount = 0;
@ -712,7 +712,7 @@ void CPUDump::integerUnsignedLongSlot()
void CPUDump::integerUnsignedLongLongSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewIntegerUnsignedLongLong);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -720,7 +720,7 @@ void CPUDump::integerUnsignedLongLongSlot()
wColDesc.itemCount = 2;
wColDesc.data.itemSize = Qword;
wColDesc.data.qwordMode = UnsignedDecQword;
appendResetDescriptor(8+charwidth*41, "Unsigned long long (64-bit)", false, wColDesc);
appendResetDescriptor(8 + charwidth * 41, "Unsigned long long (64-bit)", false, wColDesc);
wColDesc.isData = false; //empty column
wColDesc.itemCount = 0;
@ -735,7 +735,7 @@ void CPUDump::integerUnsignedLongLongSlot()
void CPUDump::integerHexShortSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewIntegerHexShort);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -743,7 +743,7 @@ void CPUDump::integerHexShortSlot()
wColDesc.itemCount = 8;
wColDesc.data.itemSize = Word;
wColDesc.data.wordMode = HexWord;
appendResetDescriptor(8+charwidth*34, "Hex short (16-bit)", false, wColDesc);
appendResetDescriptor(8 + charwidth * 34, "Hex short (16-bit)", false, wColDesc);
wColDesc.isData = false; //empty column
wColDesc.itemCount = 0;
@ -758,7 +758,7 @@ void CPUDump::integerHexShortSlot()
void CPUDump::integerHexLongSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewIntegerHexLong);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -766,7 +766,7 @@ void CPUDump::integerHexLongSlot()
wColDesc.itemCount = 4;
wColDesc.data.itemSize = Dword;
wColDesc.data.dwordMode = HexDword;
appendResetDescriptor(8+charwidth*35, "Hex long (32-bit)", false, wColDesc);
appendResetDescriptor(8 + charwidth * 35, "Hex long (32-bit)", false, wColDesc);
wColDesc.isData = false; //empty column
wColDesc.itemCount = 0;
@ -781,7 +781,7 @@ void CPUDump::integerHexLongSlot()
void CPUDump::integerHexLongLongSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewIntegerHexLongLong);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -789,7 +789,7 @@ void CPUDump::integerHexLongLongSlot()
wColDesc.itemCount = 2;
wColDesc.data.itemSize = Qword;
wColDesc.data.qwordMode = HexQword;
appendResetDescriptor(8+charwidth*33, "Hex long long (64-bit)", false, wColDesc);
appendResetDescriptor(8 + charwidth * 33, "Hex long long (64-bit)", false, wColDesc);
wColDesc.isData = false; //empty column
wColDesc.itemCount = 0;
@ -804,7 +804,7 @@ void CPUDump::integerHexLongLongSlot()
void CPUDump::floatFloatSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewFloatFloat);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -812,7 +812,7 @@ void CPUDump::floatFloatSlot()
wColDesc.itemCount = 4;
wColDesc.data.itemSize = Dword;
wColDesc.data.dwordMode = FloatDword;
appendResetDescriptor(8+charwidth*55, "Float (32-bit)", false, wColDesc);
appendResetDescriptor(8 + charwidth * 55, "Float (32-bit)", false, wColDesc);
wColDesc.isData = false; //empty column
wColDesc.itemCount = 0;
@ -827,7 +827,7 @@ void CPUDump::floatFloatSlot()
void CPUDump::floatDoubleSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewFloatDouble);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -835,7 +835,7 @@ void CPUDump::floatDoubleSlot()
wColDesc.itemCount = 2;
wColDesc.data.itemSize = Qword;
wColDesc.data.qwordMode = DoubleQword;
appendResetDescriptor(8+charwidth*47, "Double (64-bit)", false, wColDesc);
appendResetDescriptor(8 + charwidth * 47, "Double (64-bit)", false, wColDesc);
wColDesc.isData = false; //empty column
wColDesc.itemCount = 0;
@ -850,7 +850,7 @@ void CPUDump::floatDoubleSlot()
void CPUDump::floatLongDoubleSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewFloatLongDouble);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -858,7 +858,7 @@ void CPUDump::floatLongDoubleSlot()
wColDesc.itemCount = 2;
wColDesc.data.itemSize = Tword;
wColDesc.data.twordMode = FloatTword;
appendResetDescriptor(8+charwidth*59, "Long double (80-bit)", false, wColDesc);
appendResetDescriptor(8 + charwidth * 59, "Long double (80-bit)", false, wColDesc);
wColDesc.isData = false; //empty column
wColDesc.itemCount = 0;
@ -873,7 +873,7 @@ void CPUDump::floatLongDoubleSlot()
void CPUDump::addressSlot()
{
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewAddress);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -886,7 +886,7 @@ void CPUDump::addressSlot()
wColDesc.data.itemSize = Dword;
wColDesc.data.dwordMode = HexDword;
#endif
appendResetDescriptor(8+charwidth*2*sizeof(uint_t), "Address", false, wColDesc);
appendResetDescriptor(8 + charwidth * 2 * sizeof(uint_t), "Address", false, wColDesc);
wColDesc.isData = false; //comments
wColDesc.itemCount = 1;
@ -903,23 +903,23 @@ void CPUDump::disassemblySlot()
QMessageBox msg(QMessageBox::Critical, "Error!", "Not yet supported!");
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
}
void CPUDump::selectionGet(SELECTIONDATA* selection)
{
selection->start=rvaToVa(getSelectionStart());
selection->end=rvaToVa(getSelectionEnd());
selection->start = rvaToVa(getSelectionStart());
selection->end = rvaToVa(getSelectionEnd());
Bridge::getBridge()->BridgeSetResult(1);
}
void CPUDump::selectionSet(const SELECTIONDATA* selection)
{
int_t selMin=mMemPage->getBase();
int_t selMax=selMin + mMemPage->getSize();
int_t start=selection->start;
int_t end=selection->end;
int_t selMin = mMemPage->getBase();
int_t selMax = selMin + mMemPage->getSize();
int_t start = selection->start;
int_t end = selection->end;
if(start < selMin || start >= selMax || end < selMin || end >= selMax) //selection out of range
{
Bridge::getBridge()->BridgeSetResult(0);
@ -933,104 +933,104 @@ void CPUDump::selectionSet(const SELECTIONDATA* selection)
void CPUDump::memoryAccessSingleshootSlot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bpm "+addr_text+", 0, r").toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bpm " + addr_text + ", 0, r").toUtf8().constData());
}
void CPUDump::memoryAccessRestoreSlot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bpm "+addr_text+", 1, r").toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bpm " + addr_text + ", 1, r").toUtf8().constData());
}
void CPUDump::memoryWriteSingleshootSlot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bpm "+addr_text+", 0, w").toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bpm " + addr_text + ", 0, w").toUtf8().constData());
}
void CPUDump::memoryWriteRestoreSlot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bpm "+addr_text+", 1, w").toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bpm " + addr_text + ", 1, w").toUtf8().constData());
}
void CPUDump::memoryExecuteSingleshootSlot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bpm "+addr_text+", 0, x").toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bpm " + addr_text + ", 0, x").toUtf8().constData());
}
void CPUDump::memoryExecuteRestoreSlot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bpm "+addr_text+", 1, x").toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bpm " + addr_text + ", 1, x").toUtf8().constData());
}
void CPUDump::memoryRemoveSlot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bpmc "+addr_text).toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bpmc " + addr_text).toUtf8().constData());
}
void CPUDump::hardwareAccess1Slot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws "+addr_text+", r, 1").toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws " + addr_text + ", r, 1").toUtf8().constData());
}
void CPUDump::hardwareAccess2Slot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws "+addr_text+", r, 2").toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws " + addr_text + ", r, 2").toUtf8().constData());
}
void CPUDump::hardwareAccess4Slot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws "+addr_text+", r, 4").toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws " + addr_text + ", r, 4").toUtf8().constData());
}
void CPUDump::hardwareAccess8Slot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws "+addr_text+", r, 8").toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws " + addr_text + ", r, 8").toUtf8().constData());
}
void CPUDump::hardwareWrite1Slot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws "+addr_text+", w, 1").toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws " + addr_text + ", w, 1").toUtf8().constData());
}
void CPUDump::hardwareWrite2Slot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws "+addr_text+", w, 2").toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws " + addr_text + ", w, 2").toUtf8().constData());
}
void CPUDump::hardwareWrite4Slot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws "+addr_text+", w, 4").toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws " + addr_text + ", w, 4").toUtf8().constData());
}
void CPUDump::hardwareWrite8Slot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws "+addr_text+", w, 8").toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws " + addr_text + ", w, 8").toUtf8().constData());
}
void CPUDump::hardwareExecuteSlot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws "+addr_text+", x").toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphws " + addr_text + ", x").toUtf8().constData());
}
void CPUDump::hardwareRemoveSlot()
{
QString addr_text=QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphwc "+addr_text).toUtf8().constData());
QString addr_text = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("bphwc " + addr_text).toUtf8().constData());
}
void CPUDump::binaryEditSlot()
@ -1091,7 +1091,7 @@ void CPUDump::binaryPasteSlot()
HexEditDialog hexEdit(this);
int_t selStart = getSelectionStart();
int_t selSize = getSelectionEnd() - selStart + 1;
QClipboard *clipboard = QApplication::clipboard();
QClipboard* clipboard = QApplication::clipboard();
hexEdit.mHexEdit->setData(clipboard->text());
byte_t* data = new byte_t[selSize];
@ -1108,7 +1108,7 @@ void CPUDump::binaryPasteIgnoreSizeSlot()
HexEditDialog hexEdit(this);
int_t selStart = getSelectionStart();
int_t selSize = getSelectionEnd() - selStart + 1;
QClipboard *clipboard = QApplication::clipboard();
QClipboard* clipboard = QApplication::clipboard();
hexEdit.mHexEdit->setData(clipboard->text());
byte_t* data = new byte_t[selSize];
@ -1130,7 +1130,7 @@ void CPUDump::findPattern()
int_t addr = rvaToVa(getSelectionStart());
if(hexEdit.entireBlock())
addr = DbgMemFindBaseAddr(addr, 0);
QString addrText=QString("%1").arg(addr, sizeof(int_t)*2, 16, QChar('0')).toUpper();
QString addrText = QString("%1").arg(addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("findall " + addrText + ", " + hexEdit.mHexEdit->pattern() + ", &data&").toUtf8().constData());
emit displayReferencesWidget();
}

View File

@ -16,7 +16,7 @@ class CPUDump : public HexDump
{
Q_OBJECT
public:
explicit CPUDump(QWidget *parent = 0);
explicit CPUDump(QWidget* parent = 0);
QString paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h);
void setupContextMenu();
void contextMenuEvent(QContextMenuEvent* event);

View File

@ -1,6 +1,6 @@
#include "CPUInfoBox.h"
CPUInfoBox::CPUInfoBox(StdTable *parent) : StdTable(parent)
CPUInfoBox::CPUInfoBox(StdTable* parent) : StdTable(parent)
{
enableMultiSelection(false);
setShowHeader(false);
@ -43,27 +43,27 @@ void CPUInfoBox::disasmSelectionChanged(int_t parVA)
return;
clear();
QString info;
char mod[MAX_MODULE_SIZE]="";
char mod[MAX_MODULE_SIZE] = "";
if(DbgFunctions()->ModNameFromAddr(parVA, mod, true))
{
int_t modbase=DbgFunctions()->ModBaseFromAddr(parVA);
int_t modbase = DbgFunctions()->ModBaseFromAddr(parVA);
if(modbase)
info=QString(mod)+"["+QString("%1").arg(parVA-modbase, 0, 16, QChar('0')).toUpper()+"] | ";
info = QString(mod) + "[" + QString("%1").arg(parVA - modbase, 0, 16, QChar('0')).toUpper() + "] | ";
else
info=QString(mod)+" | ";
info = QString(mod) + " | ";
}
char section[10]="";
char section[10] = "";
if(DbgFunctions()->SectionFromAddr(parVA, section))
info+="\"" + QString(section) + "\":";
info+=QString("%1").arg(parVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
char label[MAX_LABEL_SIZE]="";
info += "\"" + QString(section) + "\":";
info += QString("%1").arg(parVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
char label[MAX_LABEL_SIZE] = "";
if(DbgGetLabelAt(parVA, SEG_DEFAULT, label))
info+=" <" + QString(label) + ">";
info += " <" + QString(label) + ">";
setInfoLine(2, info);
}
void CPUInfoBox::dbgStateChanged(DBGSTATE state)
{
if(state==stopped)
if(state == stopped)
clear();
}

View File

@ -10,7 +10,7 @@ class CPUInfoBox : public StdTable
{
Q_OBJECT
public:
explicit CPUInfoBox(StdTable *parent = 0);
explicit CPUInfoBox(StdTable* parent = 0);
int getHeight();
public slots:

View File

@ -2,7 +2,7 @@
#include "Configuration.h"
#include "Breakpoints.h"
CPUSideBar::CPUSideBar(CPUDisassembly *Ptr, QWidget *parent) : QAbstractScrollArea(parent)
CPUSideBar::CPUSideBar(CPUDisassembly* Ptr, QWidget* parent) : QAbstractScrollArea(parent)
{
topVA = -1;
selectedVA = -1;
@ -24,12 +24,12 @@ CPUSideBar::CPUSideBar(CPUDisassembly *Ptr, QWidget *parent) : QAbstractScrollAr
QSize CPUSideBar::sizeHint() const
{
return QSize(40,this->viewport()->height());
return QSize(40, this->viewport()->height());
}
void CPUSideBar::debugStateChangedSlot(DBGSTATE state)
{
if(state==stopped)
if(state == stopped)
{
repaint(); //clear
}
@ -43,7 +43,7 @@ void CPUSideBar::repaint()
void CPUSideBar::changeTopmostAddress(int_t i)
{
if(i!=topVA)
if(i != topVA)
{
topVA = i;
memset(&regDump, 0, sizeof(REGDUMP));
@ -68,18 +68,18 @@ void CPUSideBar::setSelection(int_t selVA)
bool CPUSideBar::isJump(int i) const
{
int BranchType=InstrBuffer->at(i).disasm.Instruction.BranchType;
if(BranchType && BranchType!=RetType && BranchType!=CallType)
int BranchType = InstrBuffer->at(i).disasm.Instruction.BranchType;
if(BranchType && BranchType != RetType && BranchType != CallType)
{
uint_t start=CodePtr->getBase();
uint_t end=start+CodePtr->getSize();
uint_t addr=DbgGetBranchDestination(CodePtr->rvaToVa(InstrBuffer->at(i).rva));
return addr>=start && addr<end; //do not draw jumps that go out of the section
uint_t start = CodePtr->getBase();
uint_t end = start + CodePtr->getSize();
uint_t addr = DbgGetBranchDestination(CodePtr->rvaToVa(InstrBuffer->at(i).rva));
return addr >= start && addr < end; //do not draw jumps that go out of the section
}
return false;
}
void CPUSideBar::paintEvent(QPaintEvent *event)
void CPUSideBar::paintEvent(QPaintEvent* event)
{
Q_UNUSED(event);
@ -96,9 +96,9 @@ void CPUSideBar::paintEvent(QPaintEvent *event)
int_t last_va = InstrBuffer->last().rva + CodePtr->getBase();
int_t first_va = InstrBuffer->first().rva + CodePtr->getBase();
for(int line=0; line<viewableRows; line++)
for(int line = 0; line < viewableRows; line++)
{
if(line>=InstrBuffer->size()) //at the end of the page it will crash otherwise
if(line >= InstrBuffer->size()) //at the end of the page it will crash otherwise
break;
Instruction_t instr = InstrBuffer->at(line);
int_t instrVA = instr.rva + CodePtr->getBase();
@ -125,16 +125,16 @@ void CPUSideBar::paintEvent(QPaintEvent *event)
bool isConditional = !((instr.disasm.Instruction.Opcode == 0xEB) || instr.disasm.Instruction.Opcode == 0xE9);
if(destVA==instrVA) //do not try to draw EBFE
if(destVA == instrVA) //do not try to draw EBFE
continue;
else if(destVA >= CodePtr->getBase()+CodePtr->getSize() || destVA < CodePtr->getBase()) //do not draw jumps that leave the page
else if(destVA >= CodePtr->getBase() + CodePtr->getSize() || destVA < CodePtr->getBase()) //do not draw jumps that leave the page
continue;
else if(destVA <= last_va && destVA >= first_va)
{
int destLine = line;
while(destLine>-1 && destLine < InstrBuffer->size() && InstrBuffer->at(destLine).rva+CodePtr->getBase() != destVA)
while(destLine > -1 && destLine < InstrBuffer->size() && InstrBuffer->at(destLine).rva + CodePtr->getBase() != destVA)
{
if(destVA>instrVA) //jump goes up
if(destVA > instrVA) //jump goes up
destLine++;
else //jump goes down
destLine--;
@ -142,7 +142,7 @@ void CPUSideBar::paintEvent(QPaintEvent *event)
drawJump(&painter, line, destLine, jumpoffset, isConditional, isJumpGoingToExecute, isSelected);
}
else if(destVA > last_va)
drawJump(&painter, line, viewableRows+6, jumpoffset, isConditional, isJumpGoingToExecute, isSelected);
drawJump(&painter, line, viewableRows + 6, jumpoffset, isConditional, isJumpGoingToExecute, isSelected);
else if(destVA < first_va)
drawJump(&painter, line, -6, jumpoffset, isConditional, isJumpGoingToExecute, isSelected);
}
@ -174,15 +174,15 @@ void CPUSideBar::paintEvent(QPaintEvent *event)
}
}
void CPUSideBar::mouseReleaseEvent(QMouseEvent *e)
void CPUSideBar::mouseReleaseEvent(QMouseEvent* e)
{
// get clicked line
const int x = e->pos().x();
const int y = e->pos().y();
const int line = y/fontHeight;
const int line = y / fontHeight;
const int bulletRadius = fontHeight/2; //14/2=7
const int bulletY = line*fontHeight + (fontHeight-bulletRadius)/2+1; //initial y
const int bulletRadius = fontHeight / 2; //14/2=7
const int bulletY = line * fontHeight + (fontHeight - bulletRadius) / 2 + 1; //initial y
const int bulletX = viewport()->width() - 10; //initial x
if(x < bulletX || x > bulletX + bulletRadius)
@ -198,7 +198,7 @@ void CPUSideBar::mouseReleaseEvent(QMouseEvent *e)
QString wCmd;
// create --> disable --> delete --> create --> ...
switch(Breakpoints::BPState(bp_normal,wVA))
switch(Breakpoints::BPState(bp_normal, wVA))
{
case bp_enabled:
// breakpoint exists and is enabled --> disable breakpoint
@ -219,7 +219,7 @@ void CPUSideBar::mouseReleaseEvent(QMouseEvent *e)
}
}
void CPUSideBar::drawJump(QPainter* painter, int startLine,int endLine,int jumpoffset, bool conditional, bool isexecute, bool isactive)
void CPUSideBar::drawJump(QPainter* painter, int startLine, int endLine, int jumpoffset, bool conditional, bool isexecute, bool isactive)
{
painter->save();
if(!conditional)
@ -242,10 +242,10 @@ void CPUSideBar::drawJump(QPainter* painter, int startLine,int endLine,int jumpo
painter->setPen(tmp);
const int JumpPadding = 11;
int x = viewport()->width() - jumpoffset*JumpPadding - 12;
int x = viewport()->width() - jumpoffset * JumpPadding - 12;
int x_right = viewport()->width() - 12;
const int y_start = fontHeight*(1+startLine)-0.5*fontHeight;
const int y_end = fontHeight*(1+endLine)-0.5*fontHeight;
const int y_start = fontHeight * (1 + startLine) - 0.5 * fontHeight;
const int y_end = fontHeight * (1 + endLine) - 0.5 * fontHeight;
//horizontal
painter->drawLine(x_right, y_start, x, y_start);
@ -257,12 +257,12 @@ void CPUSideBar::drawJump(QPainter* painter, int startLine,int endLine,int jumpo
//horizontal
painter->drawLine(x, y_end, x_right, y_end);
if(endLine == viewableRows+6)
if(endLine == viewableRows + 6)
{
int y = this->viewport()->height()-1;
if(y>y_start)
int y = this->viewport()->height() - 1;
if(y > y_start)
{
QPen temp=painter->pen();
QPen temp = painter->pen();
temp.setStyle(Qt::SolidLine);
painter->setPen(temp);
QPoint wPoints[] =
@ -277,7 +277,7 @@ void CPUSideBar::drawJump(QPainter* painter, int startLine,int endLine,int jumpo
else if(endLine == -6)
{
int y = 0;
QPen temp=painter->pen();
QPen temp = painter->pen();
temp.setStyle(Qt::SolidLine);
painter->setPen(temp);
QPoint wPoints[] =
@ -290,7 +290,7 @@ void CPUSideBar::drawJump(QPainter* painter, int startLine,int endLine,int jumpo
}
else
{
QPen temp=painter->pen();
QPen temp = painter->pen();
temp.setStyle(Qt::SolidLine);
painter->setPen(temp);
QPoint wPoints[] =
@ -304,11 +304,11 @@ void CPUSideBar::drawJump(QPainter* painter, int startLine,int endLine,int jumpo
}
else
{
if(endLine == viewableRows+6)
if(endLine == viewableRows + 6)
{
int y = this->viewport()->height()-1;
int y = this->viewport()->height() - 1;
x--;
QPen temp=painter->pen();
QPen temp = painter->pen();
temp.setStyle(Qt::SolidLine);
painter->setPen(temp);
QPoint wPoints[] =
@ -322,7 +322,7 @@ void CPUSideBar::drawJump(QPainter* painter, int startLine,int endLine,int jumpo
else if(endLine == -6)
{
int y = 0;
QPen temp=painter->pen();
QPen temp = painter->pen();
temp.setStyle(Qt::SolidLine);
painter->setPen(temp);
QPoint wPoints[] =
@ -352,9 +352,9 @@ void CPUSideBar::drawBullets(QPainter* painter, int line, bool isbp, bool isbpdi
painter->setPen(ConfigColor("SideBarBackgroundColor"));
const int radius = fontHeight/2; //14/2=7
const int y = line*fontHeight; //initial y
const int yAdd = (fontHeight-radius)/2+1;
const int radius = fontHeight / 2; //14/2=7
const int y = line * fontHeight; //initial y
const int yAdd = (fontHeight - radius) / 2 + 1;
const int x = viewport()->width() - 10; //initial x
//painter->drawLine(0, y, viewport()->width(), y); //draw raster
@ -362,7 +362,7 @@ void CPUSideBar::drawBullets(QPainter* painter, int line, bool isbp, bool isbpdi
painter->setRenderHint(QPainter::Antialiasing, true);
if(isbpdisabled) //disabled breakpoint
painter->setBrush(QBrush(ConfigColor("SideBarBulletDisabledBreakpointColor")));
painter->drawEllipse(x, y+yAdd, radius, radius);
painter->drawEllipse(x, y + yAdd, radius, radius);
painter->restore();
}
@ -370,15 +370,15 @@ void CPUSideBar::drawBullets(QPainter* painter, int line, bool isbp, bool isbpdi
void CPUSideBar::drawLabel(QPainter* painter, int Line, QString Text)
{
painter->save();
const int LineCoordinate = fontHeight*(1+Line);
const int LineCoordinate = fontHeight * (1 + Line);
int length = Text.length();
const QColor IPLabel = ConfigColor("SideBarCipLabelColor");
const QColor IPLabelBG = ConfigColor("SideBarCipLabelBackgroundColor");
int width = length*fontWidth + 2;
int width = length * fontWidth + 2;
int x = 1;
int y = LineCoordinate-fontHeight;
int y = LineCoordinate - fontHeight;
QRect rect(x, y, width, fontHeight);
@ -392,18 +392,18 @@ void CPUSideBar::drawLabel(QPainter* painter, int Line, QString Text)
painter->drawText(rect, Qt::AlignHCenter | Qt::AlignVCenter, Text);
//draw arrow
y = fontHeight*(1+Line)-0.5*fontHeight;
y = fontHeight * (1 + Line) - 0.5 * fontHeight;
//y+=3;
painter->setPen(QPen(IPLabelBG, 2));
painter->setBrush(QBrush(IPLabelBG));
drawStraightArrow(painter, rect.right()+2, y, this->viewport()->width()-x-15, y);
drawStraightArrow(painter, rect.right() + 2, y, this->viewport()->width() - x - 15, y);
painter->restore();
}
void CPUSideBar::drawStraightArrow(QPainter *painter, int x1, int y1, int x2, int y2)
void CPUSideBar::drawStraightArrow(QPainter* painter, int x1, int y1, int x2, int y2)
{
painter->drawLine(x1,y1,x2,y2);
painter->drawLine(x1, y1, x2, y2);
/*
// this does not work
@ -419,8 +419,8 @@ void CPUSideBar::drawStraightArrow(QPainter *painter, int x1, int y1, int x2, in
const int ArrowSizeX = 4; // width of arrow tip in pixel
const int ArrowSizeY = 4; // height of arrow tip in pixel
painter->drawLine(x2,y2,x2-ArrowSizeX,y2-ArrowSizeY);
painter->drawLine(x2,y2,x2-ArrowSizeX,y2+ArrowSizeY);
painter->drawLine(x2, y2, x2 - ArrowSizeX, y2 - ArrowSizeY);
painter->drawLine(x2, y2, x2 - ArrowSizeX, y2 + ArrowSizeY);
}

View File

@ -10,11 +10,11 @@
class CPUSideBar : public QAbstractScrollArea
{
Q_OBJECT
QPair<int_t,int_t> mHighlightedJump;
QPair<int_t, int_t> mHighlightedJump;
public:
explicit CPUSideBar(CPUDisassembly *Ptr, QWidget *parent = 0);
explicit CPUSideBar(CPUDisassembly* Ptr, QWidget* parent = 0);
QSize sizeHint() const;
void drawStraightArrow(QPainter *painter, int x1, int y1, int x2, int y2);
void drawStraightArrow(QPainter* painter, int x1, int y1, int x2, int y2);
public slots:
void debugStateChangedSlot(DBGSTATE state);
@ -24,8 +24,8 @@ public slots:
void setSelection(int_t selVA);
protected:
virtual void paintEvent(QPaintEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *e);
virtual void paintEvent(QPaintEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* e);
void drawLabel(QPainter* painter, int Line, QString Text);
void drawBullets(QPainter* painter, int line, bool ispb, bool isbpdisabled, bool isbookmark);
@ -40,8 +40,8 @@ private:
int fontWidth, fontHeight;
int viewableRows;
CPUDisassembly *CodePtr;
QList<Instruction_t> *InstrBuffer;
CPUDisassembly* CodePtr;
QList<Instruction_t>* InstrBuffer;
QColor backgroundColor;
REGDUMP regDump;
};

View File

@ -3,11 +3,11 @@
#include "HexEditDialog.h"
#include "WordEditDialog.h"
CPUStack::CPUStack(QWidget *parent) : HexDump(parent)
CPUStack::CPUStack(QWidget* parent) : HexDump(parent)
{
fontsUpdated();
setShowHeader(false);
int charwidth=getCharWidth();
int charwidth = getCharWidth();
ColumnDescriptor_t wColDesc;
DataDescriptor_t dDesc;
@ -20,7 +20,7 @@ CPUStack::CPUStack(QWidget *parent) : HexDump(parent)
wColDesc.data.itemSize = Dword;
wColDesc.data.dwordMode = HexDword;
#endif
appendDescriptor(8+charwidth*2*sizeof(uint_t), "void*", false, wColDesc);
appendDescriptor(8 + charwidth * 2 * sizeof(uint_t), "void*", false, wColDesc);
wColDesc.isData = false; //comments
wColDesc.itemCount = 0;
@ -29,7 +29,7 @@ CPUStack::CPUStack(QWidget *parent) : HexDump(parent)
wColDesc.data = dDesc;
appendDescriptor(0, "Comments", false, wColDesc);
connect(Bridge::getBridge(), SIGNAL(stackDumpAt(uint_t,uint_t)), this, SLOT(stackDumpAt(uint_t,uint_t)));
connect(Bridge::getBridge(), SIGNAL(stackDumpAt(uint_t, uint_t)), this, SLOT(stackDumpAt(uint_t, uint_t)));
connect(Bridge::getBridge(), SIGNAL(selectionStackGet(SELECTIONDATA*)), this, SLOT(selectionGet(SELECTIONDATA*)));
connect(Bridge::getBridge(), SIGNAL(selectionStackSet(const SELECTIONDATA*)), this, SLOT(selectionSet(const SELECTIONDATA*)));
@ -37,17 +37,17 @@ CPUStack::CPUStack(QWidget *parent) : HexDump(parent)
mGoto = 0;
backgroundColor=ConfigColor("StackBackgroundColor");
textColor=ConfigColor("StackTextColor");
selectionColor=ConfigColor("StackSelectionColor");
backgroundColor = ConfigColor("StackBackgroundColor");
textColor = ConfigColor("StackTextColor");
selectionColor = ConfigColor("StackSelectionColor");
}
void CPUStack::colorsUpdated()
{
HexDump::colorsUpdated();
backgroundColor=ConfigColor("StackBackgroundColor");
textColor=ConfigColor("StackTextColor");
selectionColor=ConfigColor("StackSelectionColor");
backgroundColor = ConfigColor("StackBackgroundColor");
textColor = ConfigColor("StackTextColor");
selectionColor = ConfigColor("StackSelectionColor");
}
void CPUStack::fontsUpdated()
@ -168,61 +168,61 @@ QString CPUStack::paintContent(QPainter* painter, int_t rowBase, int rowOffset,
int_t wRva = (rowBase + rowOffset) * wBytePerRowCount - mByteOffset;
uint_t wVa = rvaToVa(wRva);
bool wIsSelected=isSelected(wRva);
bool wIsSelected = isSelected(wRva);
if(wIsSelected) //highlight if selected
painter->fillRect(QRect(x, y, w, h), QBrush(selectionColor));
bool wActiveStack=true;
if(wVa<mCsp) //inactive stack
wActiveStack=false;
bool wActiveStack = true;
if(wVa < mCsp) //inactive stack
wActiveStack = false;
STACK_COMMENT comment;
if(col == 0) // paint stack address
{
char label[MAX_LABEL_SIZE]="";
QString addrText="";
char label[MAX_LABEL_SIZE] = "";
QString addrText = "";
int_t curAddr = rvaToVa((rowBase + rowOffset) * getBytePerRowCount() - mByteOffset);
addrText = QString("%1").arg(curAddr, sizeof(int_t)*2, 16, QChar('0')).toUpper();
addrText = QString("%1").arg(curAddr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
if(DbgGetLabelAt(curAddr, SEG_DEFAULT, label)) //has label
{
char module[MAX_MODULE_SIZE]="";
char module[MAX_MODULE_SIZE] = "";
if(DbgGetModuleAt(curAddr, module) && !QString(label).startsWith("JMP.&"))
addrText+=" <"+QString(module)+"."+QString(label)+">";
addrText += " <" + QString(module) + "." + QString(label) + ">";
else
addrText+=" <"+QString(label)+">";
addrText += " <" + QString(label) + ">";
}
else
*label=0;
*label = 0;
QColor background;
if(*label) //label
{
if(wVa==mCsp) //CSP
if(wVa == mCsp) //CSP
{
background=ConfigColor("StackCspBackgroundColor");
background = ConfigColor("StackCspBackgroundColor");
painter->setPen(QPen(ConfigColor("StackCspColor")));
}
else //no CSP
{
background=ConfigColor("StackLabelBackgroundColor");
background = ConfigColor("StackLabelBackgroundColor");
painter->setPen(ConfigColor("StackLabelColor"));
}
}
else //no label
{
if(wVa==mCsp) //CSP
if(wVa == mCsp) //CSP
{
background=ConfigColor("StackCspBackgroundColor");
background = ConfigColor("StackCspBackgroundColor");
painter->setPen(QPen(ConfigColor("StackCspColor")));
}
else if(wIsSelected) //selected normal address
{
background=ConfigColor("StackSelectedAddressBackgroundColor");
background = ConfigColor("StackSelectedAddressBackgroundColor");
painter->setPen(QPen(ConfigColor("StackSelectedAddressColor"))); //black address (DisassemblySelectedAddressColor)
}
else //normal address
{
background=ConfigColor("StackAddressBackgroundColor");
background = ConfigColor("StackAddressBackgroundColor");
painter->setPen(QPen(ConfigColor("StackAddressColor")));
}
}
@ -240,7 +240,7 @@ QString CPUStack::paintContent(QPainter* painter, int_t rowBase, int rowOffset,
if(!wActiveStack)
{
QColor inactiveColor = ConfigColor("StackInactiveTextColor");
for(int i=0; i<richText.size(); i++)
for(int i = 0; i < richText.size(); i++)
{
richText[i].flags = RichTextPainter::FlagColor;
richText[i].textColor = inactiveColor;
@ -300,7 +300,7 @@ void CPUStack::contextMenuEvent(QContextMenuEvent* event)
void CPUStack::stackDumpAt(uint_t addr, uint_t csp)
{
mCsp=csp;
mCsp = csp;
printDumpAt(addr);
}
@ -324,14 +324,14 @@ void CPUStack::gotoExpressionSlot()
{
if(!DbgIsDebugging())
return;
uint_t size=0;
uint_t base=DbgMemFindBaseAddr(mCsp, &size);
uint_t size = 0;
uint_t base = DbgMemFindBaseAddr(mCsp, &size);
if(!mGoto)
mGoto = new GotoDialog(this);
mGoto->validRangeStart=base;
mGoto->validRangeEnd=base+size;
mGoto->validRangeStart = base;
mGoto->validRangeEnd = base + size;
mGoto->setWindowTitle("Enter expression to follow in Stack...");
if(mGoto->exec()==QDialog::Accepted)
if(mGoto->exec() == QDialog::Accepted)
{
QString cmd;
DbgCmdExec(cmd.sprintf("sdump \"%s\"", mGoto->expressionText.toUtf8().constData()).toUtf8().constData());
@ -340,17 +340,17 @@ void CPUStack::gotoExpressionSlot()
void CPUStack::selectionGet(SELECTIONDATA* selection)
{
selection->start=rvaToVa(getSelectionStart());
selection->end=rvaToVa(getSelectionEnd());
selection->start = rvaToVa(getSelectionStart());
selection->end = rvaToVa(getSelectionEnd());
Bridge::getBridge()->BridgeSetResult(1);
}
void CPUStack::selectionSet(const SELECTIONDATA* selection)
{
int_t selMin=mMemPage->getBase();
int_t selMax=selMin + mMemPage->getSize();
int_t start=selection->start;
int_t end=selection->end;
int_t selMin = mMemPage->getBase();
int_t selMax = selMin + mMemPage->getSize();
int_t start = selection->start;
int_t end = selection->end;
if(start < selMin || start >= selMax || end < selMin || end >= selMax) //selection out of range
{
Bridge::getBridge()->BridgeSetResult(0);
@ -368,7 +368,7 @@ void CPUStack::followDisasmSlot()
if(mMemPage->read((byte_t*)&selectedData, getInitialSelection(), sizeof(uint_t)))
if(DbgMemIsValidReadPtr(selectedData)) //data is a pointer
{
QString addrText=QString("%1").arg(selectedData, sizeof(int_t)*2, 16, QChar('0')).toUpper();
QString addrText = QString("%1").arg(selectedData, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("disasm " + addrText).toUtf8().constData());
}
}
@ -379,7 +379,7 @@ void CPUStack::followDumpSlot()
if(mMemPage->read((byte_t*)&selectedData, getInitialSelection(), sizeof(uint_t)))
if(DbgMemIsValidReadPtr(selectedData)) //data is a pointer
{
QString addrText=QString("%1").arg(selectedData, sizeof(int_t)*2, 16, QChar('0')).toUpper();
QString addrText = QString("%1").arg(selectedData, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("dump " + addrText).toUtf8().constData());
}
}
@ -390,7 +390,7 @@ void CPUStack::followStackSlot()
if(mMemPage->read((byte_t*)&selectedData, getInitialSelection(), sizeof(uint_t)))
if(DbgMemIsValidReadPtr(selectedData)) //data is a pointer
{
QString addrText=QString("%1").arg(selectedData, sizeof(int_t)*2, 16, QChar('0')).toUpper();
QString addrText = QString("%1").arg(selectedData, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("sdump " + addrText).toUtf8().constData());
}
}
@ -453,7 +453,7 @@ void CPUStack::binaryPasteSlot()
HexEditDialog hexEdit(this);
int_t selStart = getSelectionStart();
int_t selSize = getSelectionEnd() - selStart + 1;
QClipboard *clipboard = QApplication::clipboard();
QClipboard* clipboard = QApplication::clipboard();
hexEdit.mHexEdit->setData(clipboard->text());
byte_t* data = new byte_t[selSize];
@ -470,7 +470,7 @@ void CPUStack::binaryPasteIgnoreSizeSlot()
HexEditDialog hexEdit(this);
int_t selStart = getSelectionStart();
int_t selSize = getSelectionEnd() - selStart + 1;
QClipboard *clipboard = QApplication::clipboard();
QClipboard* clipboard = QApplication::clipboard();
hexEdit.mHexEdit->setData(clipboard->text());
byte_t* data = new byte_t[selSize];
@ -492,7 +492,7 @@ void CPUStack::findPattern()
int_t addr = rvaToVa(getSelectionStart());
if(hexEdit.entireBlock())
addr = DbgMemFindBaseAddr(addr, 0);
QString addrText=QString("%1").arg(addr, sizeof(int_t)*2, 16, QChar('0')).toUpper();
QString addrText = QString("%1").arg(addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("findall " + addrText + ", " + hexEdit.mHexEdit->pattern() + ", &data&").toUtf8().constData());
emit displayReferencesWidget();
}
@ -511,12 +511,12 @@ void CPUStack::modifySlot()
{
int_t addr = getInitialSelection();
WordEditDialog wEditDialog(this);
int_t value=0;
int_t value = 0;
mMemPage->read(&value, addr, sizeof(int_t));
wEditDialog.setup("Modify", value, sizeof(int_t));
if(wEditDialog.exec()!=QDialog::Accepted)
if(wEditDialog.exec() != QDialog::Accepted)
return;
value=wEditDialog.getVal();
value = wEditDialog.getVal();
mMemPage->write(&value, addr, sizeof(int_t));
reloadData();
}

View File

@ -14,7 +14,7 @@ class CPUStack : public HexDump
{
Q_OBJECT
public:
explicit CPUStack(QWidget *parent = 0);
explicit CPUStack(QWidget* parent = 0);
void colorsUpdated();
void fontsUpdated();
QString paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h);

View File

@ -1,19 +1,19 @@
#include "CPUWidget.h"
#include "ui_CPUWidget.h"
CPUWidget::CPUWidget(QWidget *parent) :QWidget(parent), ui(new Ui::CPUWidget)
CPUWidget::CPUWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CPUWidget)
{
ui->setupUi(this);
setDefaultDisposition();
mDisas = new CPUDisassembly(0);
mSideBar = new CPUSideBar(mDisas);
connect(mDisas,SIGNAL(tableOffsetChanged(int_t)),mSideBar,SLOT(changeTopmostAddress(int_t)));
connect(mDisas,SIGNAL(viewableRows(int)),mSideBar,SLOT(setViewableRows(int)));
connect(mDisas,SIGNAL(repainted()),mSideBar,SLOT(repaint()));
connect(mDisas,SIGNAL(selectionChanged(int_t)),mSideBar,SLOT(setSelection(int_t)));
connect(Bridge::getBridge(),SIGNAL(dbgStateChanged(DBGSTATE)),mSideBar,SLOT(debugStateChangedSlot(DBGSTATE)));
connect(Bridge::getBridge(),SIGNAL(updateSideBar()),mSideBar,SLOT(repaint()));
connect(mDisas, SIGNAL(tableOffsetChanged(int_t)), mSideBar, SLOT(changeTopmostAddress(int_t)));
connect(mDisas, SIGNAL(viewableRows(int)), mSideBar, SLOT(setViewableRows(int)));
connect(mDisas, SIGNAL(repainted()), mSideBar, SLOT(repaint()));
connect(mDisas, SIGNAL(selectionChanged(int_t)), mSideBar, SLOT(setSelection(int_t)));
connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), mSideBar, SLOT(debugStateChangedSlot(DBGSTATE)));
connect(Bridge::getBridge(), SIGNAL(updateSideBar()), mSideBar, SLOT(repaint()));
QSplitter* splitter = new QSplitter(this);
splitter->addWidget(mSideBar);
@ -26,8 +26,8 @@ CPUWidget::CPUWidget(QWidget *parent) :QWidget(parent), ui(new Ui::CPUWidget)
mInfo = new CPUInfoBox();
ui->mTopLeftLowerFrameLayout->addWidget(mInfo);
int height = mInfo->getHeight();
ui->mTopLeftLowerFrame->setMinimumHeight(height+2);
ui->mTopLeftLowerFrame->setMaximumHeight(height+2);
ui->mTopLeftLowerFrame->setMinimumHeight(height + 2);
ui->mTopLeftLowerFrame->setMaximumHeight(height + 2);
connect(mDisas, SIGNAL(selectionChanged(int_t)), mInfo, SLOT(disasmSelectionChanged(int_t)));
@ -59,24 +59,24 @@ void CPUWidget::setDefaultDisposition(void)
// Vertical Splitter
wTotalSize = ui->mVSplitter->widget(0)->size().height() + ui->mVSplitter->widget(1)->size().height();
sizesList.append(wTotalSize*70/100);
sizesList.append(wTotalSize-wTotalSize*70/100);
sizesList.append(wTotalSize * 70 / 100);
sizesList.append(wTotalSize - wTotalSize * 70 / 100);
ui->mVSplitter->setSizes(sizesList);
// Top Horizontal Splitter
wTotalSize = ui->mTopHSplitter->widget(0)->size().height() + ui->mTopHSplitter->widget(1)->size().height();
sizesList.append(wTotalSize*70/100);
sizesList.append(wTotalSize-wTotalSize*70/100);
sizesList.append(wTotalSize * 70 / 100);
sizesList.append(wTotalSize - wTotalSize * 70 / 100);
ui->mTopHSplitter->setSizes(sizesList);
// Bottom Horizontal Splitter
wTotalSize = ui->mBotHSplitter->widget(0)->size().height() + ui->mBotHSplitter->widget(1)->size().height();
sizesList.append(wTotalSize*70/100);
sizesList.append(wTotalSize-wTotalSize*70/100);
sizesList.append(wTotalSize * 70 / 100);
sizesList.append(wTotalSize - wTotalSize * 70 / 100);
ui->mBotHSplitter->setSizes(sizesList);
}

View File

@ -21,7 +21,7 @@ class CPUWidget : public QWidget
Q_OBJECT
public:
explicit CPUWidget(QWidget *parent = 0);
explicit CPUWidget(QWidget* parent = 0);
~CPUWidget();
void setDefaultDisposition(void);
QVBoxLayout* getTopLeftUpperWidget(void);
@ -40,7 +40,7 @@ public:
QTabWidget* mRegsTab;
private:
Ui::CPUWidget *ui;
Ui::CPUWidget* ui;
};
#endif // CPUWIDGET_H

View File

@ -2,15 +2,15 @@
#include "ui_CalculatorDialog.h"
#include <QString>
CalculatorDialog::CalculatorDialog(QWidget *parent) : QDialog(parent), ui(new Ui::CalculatorDialog)
CalculatorDialog::CalculatorDialog(QWidget* parent) : QDialog(parent), ui(new Ui::CalculatorDialog)
{
ui->setupUi(this);
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
setFixedSize(this->size()); //fixed size
connect(ui->txtExpression,SIGNAL(textChanged(QString)),this,SLOT(answerExpression(QString)));
connect(this,SIGNAL(validAddress(bool)),ui->btnGoto,SLOT(setEnabled(bool)));
connect(ui->txtExpression, SIGNAL(textChanged(QString)), this, SLOT(answerExpression(QString)));
connect(this, SIGNAL(validAddress(bool)), ui->btnGoto, SLOT(setEnabled(bool)));
emit validAddress(false);
ui->txtBin->setInputMask(QString("bbbb ").repeated(sizeof(uint_t)*2));
ui->txtBin->setInputMask(QString("bbbb ").repeated(sizeof(uint_t) * 2));
ui->txtExpression->setText("0");
ui->txtExpression->selectAll();
ui->txtExpression->setFocus();
@ -51,29 +51,29 @@ void CalculatorDialog::answerExpression(QString expression)
{
ui->txtExpression->setStyleSheet("");
uint_t ans = DbgValFromString(expression.toUtf8().constData());
ui->txtHex->setText(inFormat(ans,N_HEX));
ui->txtSignedDec->setText(inFormat(ans,N_SDEC));
ui->txtUnsignedDec->setText(inFormat(ans,N_UDEC));
int cursorpos=ui->txtBin->cursorPosition();
ui->txtBin->setText(inFormat(ans,N_BIN));
ui->txtHex->setText(inFormat(ans, N_HEX));
ui->txtSignedDec->setText(inFormat(ans, N_SDEC));
ui->txtUnsignedDec->setText(inFormat(ans, N_UDEC));
int cursorpos = ui->txtBin->cursorPosition();
ui->txtBin->setText(inFormat(ans, N_BIN));
ui->txtBin->setCursorPosition(cursorpos);
ui->txtOct->setText(inFormat(ans,N_OCT));
if((ans == (ans & 0xFF)) )
ui->txtOct->setText(inFormat(ans, N_OCT));
if((ans == (ans & 0xFF)))
{
QChar c = QChar((char)ans);
if(c.isPrint())
ui->txtAscii->setText("'"+QString(c)+"'");
ui->txtAscii->setText("'" + QString(c) + "'");
else
ui->txtAscii->setText("???");
}
else
ui->txtAscii->setText("???");
ui->txtAscii->setCursorPosition(1);
if((ans == (ans & 0xFFF)) ) //UNICODE?
if((ans == (ans & 0xFFF))) //UNICODE?
{
QChar c = QChar((wchar_t)ans);
if(c.isPrint())
ui->txtUnicode->setText("L'"+QString(c)+"'");
ui->txtUnicode->setText("L'" + QString(c) + "'");
else
ui->txtUnicode->setText("????");
}
@ -99,11 +99,11 @@ QString CalculatorDialog::inFormat(const uint_t val, CalculatorDialog::NUMBERFOR
return QString("%1").arg(val);
case N_BIN:
{
QString binary = QString("%1").arg(val, 8*sizeof(uint_t), 2, QChar('0')).toUpper();
QString binary = QString("%1").arg(val, 8 * sizeof(uint_t), 2, QChar('0')).toUpper();
QString ans = "";
for(int i=0; i<sizeof(uint_t)*8; i++)
for(int i = 0; i < sizeof(uint_t) * 8; i++)
{
if((i%4==0) && (i!=0))
if((i % 4 == 0) && (i != 0))
ans += " ";
ans += binary[i];
}
@ -122,9 +122,9 @@ void CalculatorDialog::on_btnGoto_clicked()
emit showCpu();
}
void CalculatorDialog::on_txtHex_textEdited(const QString &arg1)
void CalculatorDialog::on_txtHex_textEdited(const QString & arg1)
{
bool ok=false;
bool ok = false;
ULONGLONG val = arg1.toULongLong(&ok, 16);
if(!ok)
{
@ -135,9 +135,9 @@ void CalculatorDialog::on_txtHex_textEdited(const QString &arg1)
ui->txtExpression->setText(QString("%1").arg(val, 1, 16, QChar('0')).toUpper());
}
void CalculatorDialog::on_txtSignedDec_textEdited(const QString &arg1)
void CalculatorDialog::on_txtSignedDec_textEdited(const QString & arg1)
{
bool ok=false;
bool ok = false;
LONGLONG val = arg1.toLongLong(&ok, 10);
if(!ok)
{
@ -148,9 +148,9 @@ void CalculatorDialog::on_txtSignedDec_textEdited(const QString &arg1)
ui->txtExpression->setText(QString("%1").arg(val, 1, 16, QChar('0')).toUpper());
}
void CalculatorDialog::on_txtUnsignedDec_textEdited(const QString &arg1)
void CalculatorDialog::on_txtUnsignedDec_textEdited(const QString & arg1)
{
bool ok=false;
bool ok = false;
LONGLONG val = arg1.toULongLong(&ok, 10);
if(!ok)
{
@ -161,9 +161,9 @@ void CalculatorDialog::on_txtUnsignedDec_textEdited(const QString &arg1)
ui->txtExpression->setText(QString("%1").arg(val, 1, 16, QChar('0')).toUpper());
}
void CalculatorDialog::on_txtOct_textEdited(const QString &arg1)
void CalculatorDialog::on_txtOct_textEdited(const QString & arg1)
{
bool ok=false;
bool ok = false;
ULONGLONG val = arg1.toULongLong(&ok, 8);
if(!ok)
{
@ -174,9 +174,9 @@ void CalculatorDialog::on_txtOct_textEdited(const QString &arg1)
ui->txtExpression->setText(QString("%1").arg(val, 1, 16, QChar('0')).toUpper());
}
void CalculatorDialog::on_txtBin_textEdited(const QString &arg1)
void CalculatorDialog::on_txtBin_textEdited(const QString & arg1)
{
bool ok=false;
bool ok = false;
QString text = arg1;
text = text.replace(" ", "");
ULONGLONG val = text.toULongLong(&ok, 2);
@ -189,7 +189,7 @@ void CalculatorDialog::on_txtBin_textEdited(const QString &arg1)
ui->txtExpression->setText(QString("%1").arg(val, 1, 16, QChar('0')).toUpper());
}
void CalculatorDialog::on_txtAscii_textEdited(const QString &arg1)
void CalculatorDialog::on_txtAscii_textEdited(const QString & arg1)
{
QString text = arg1;
text = text.replace("'", "");
@ -203,7 +203,7 @@ void CalculatorDialog::on_txtAscii_textEdited(const QString &arg1)
ui->txtAscii->setCursorPosition(1);
}
void CalculatorDialog::on_txtUnicode_textEdited(const QString &arg1)
void CalculatorDialog::on_txtUnicode_textEdited(const QString & arg1)
{
QString text = arg1;
text = text.replace("L'", "").replace("'", "");

View File

@ -14,17 +14,17 @@ class CalculatorDialog : public QDialog
enum NUMBERFORMAT
{
N_HEX=16,
N_SDEC=10,
N_UDEC=11,
N_BIN=2,
N_OCT=8,
N_ASCII=0,
N_UNKNOWN=-1
N_HEX = 16,
N_SDEC = 10,
N_UDEC = 11,
N_BIN = 2,
N_OCT = 8,
N_ASCII = 0,
N_UNKNOWN = -1
};
public:
explicit CalculatorDialog(QWidget *parent = 0);
explicit CalculatorDialog(QWidget* parent = 0);
~CalculatorDialog();
void setExpressionFocus();
@ -37,16 +37,16 @@ public slots:
private slots:
void on_btnGoto_clicked();
void on_txtHex_textEdited(const QString &arg1);
void on_txtSignedDec_textEdited(const QString &arg1);
void on_txtUnsignedDec_textEdited(const QString &arg1);
void on_txtOct_textEdited(const QString &arg1);
void on_txtBin_textEdited(const QString &arg1);
void on_txtAscii_textEdited(const QString &arg1);
void on_txtUnicode_textEdited(const QString &arg1);
void on_txtHex_textEdited(const QString & arg1);
void on_txtSignedDec_textEdited(const QString & arg1);
void on_txtUnsignedDec_textEdited(const QString & arg1);
void on_txtOct_textEdited(const QString & arg1);
void on_txtBin_textEdited(const QString & arg1);
void on_txtAscii_textEdited(const QString & arg1);
void on_txtUnicode_textEdited(const QString & arg1);
private:
Ui::CalculatorDialog *ui;
Ui::CalculatorDialog* ui;
QString inFormat(const uint_t val, CalculatorDialog::NUMBERFORMAT NF) const;
};

View File

@ -5,9 +5,9 @@ CallStackView::CallStackView(StdTable* parent) : StdTable(parent)
{
int charwidth = getCharWidth();
addColumnAt(8+charwidth*sizeof(int_t)*2, "Address", true); //address in the stack
addColumnAt(8+charwidth*sizeof(int_t)*2, "To", true); //return to
addColumnAt(8+charwidth*sizeof(int_t)*2, "From", true); //return from
addColumnAt(8 + charwidth * sizeof(int_t) * 2, "Address", true); //address in the stack
addColumnAt(8 + charwidth * sizeof(int_t) * 2, "To", true); //return to
addColumnAt(8 + charwidth * sizeof(int_t) * 2, "From", true); //return from
addColumnAt(0, "Comment", true);
connect(Bridge::getBridge(), SIGNAL(updateCallStack()), this, SLOT(updateCallStack()));
@ -36,15 +36,15 @@ void CallStackView::updateCallStack()
memset(&callstack, 0, sizeof(DBGCALLSTACK));
DbgFunctions()->GetCallStack(&callstack);
setRowCount(callstack.total);
for(int i=0; i<callstack.total; i++)
for(int i = 0; i < callstack.total; i++)
{
QString addrText=QString("%1").arg((uint_t)callstack.entries[i].addr, sizeof(uint_t)*2, 16, QChar('0')).toUpper();
QString addrText = QString("%1").arg((uint_t)callstack.entries[i].addr, sizeof(uint_t) * 2, 16, QChar('0')).toUpper();
setCellContent(i, 0, addrText);
addrText=QString("%1").arg((uint_t)callstack.entries[i].to, sizeof(uint_t)*2, 16, QChar('0')).toUpper();
addrText = QString("%1").arg((uint_t)callstack.entries[i].to, sizeof(uint_t) * 2, 16, QChar('0')).toUpper();
setCellContent(i, 1, addrText);
if(callstack.entries[i].from)
{
addrText=QString("%1").arg((uint_t)callstack.entries[i].from, sizeof(uint_t)*2, 16, QChar('0')).toUpper();
addrText = QString("%1").arg((uint_t)callstack.entries[i].from, sizeof(uint_t) * 2, 16, QChar('0')).toUpper();
setCellContent(i, 2, addrText);
}
setCellContent(i, 3, callstack.entries[i].comment);

View File

@ -1,7 +1,7 @@
#include "CloseDialog.h"
#include "ui_CloseDialog.h"
CloseDialog::CloseDialog(QWidget *parent) :
CloseDialog::CloseDialog(QWidget* parent) :
QDialog(parent),
ui(new Ui::CloseDialog)
{

View File

@ -13,11 +13,11 @@ class CloseDialog : public QDialog
Q_OBJECT
public:
explicit CloseDialog(QWidget *parent = 0);
explicit CloseDialog(QWidget* parent = 0);
~CloseDialog();
private:
Ui::CloseDialog *ui;
Ui::CloseDialog* ui;
};
#endif // CLOSEDIALOG_H

View File

@ -1,7 +1,7 @@
#include "CommandHelpView.h"
#include "ui_CommandHelpView.h"
CommandHelpView::CommandHelpView(QWidget *parent) :
CommandHelpView::CommandHelpView(QWidget* parent) :
QWidget(parent),
ui(new Ui::CommandHelpView)
{
@ -75,17 +75,17 @@ void CommandHelpView::moduleSelectionChanged(int index)
{
mSearchListView->mList->setRowCount(0);
if(index==0) //x64_dbg
if(index == 0) //x64_dbg
{
mCurrentMode=0;
mCurrentMode = 0;
mSearchListView->mList->setRowCount(3);
mSearchListView->mList->setCellContent(0, 0, "InitDebug");
mSearchListView->mList->setCellContent(1, 0, "StopDebug");
mSearchListView->mList->setCellContent(2, 0, "run");
}
else if(index==1) //testplugin
else if(index == 1) //testplugin
{
mCurrentMode=1;
mCurrentMode = 1;
mSearchListView->mList->setRowCount(2);
mSearchListView->mList->setCellContent(0, 0, "plugin1");
mSearchListView->mList->setCellContent(1, 0, "grs");
@ -100,31 +100,31 @@ void CommandHelpView::moduleSelectionChanged(int index)
void CommandHelpView::symbolSelectionChanged(int index)
{
QString info="";
if(mCurrentMode==0) //x64_dbg
QString info = "";
if(mCurrentMode == 0) //x64_dbg
{
switch(index)
{
case 0: //InitDebug
info="Initialize debugging a file.\n\nExample:\nInitDebug \"C:\\test.exe\", commandline, \"C:\\homeDir\"";
info = "Initialize debugging a file.\n\nExample:\nInitDebug \"C:\\test.exe\", commandline, \"C:\\homeDir\"";
break;
case 1: //StopDebug
info="Stop debugging (terminate the target).\n\nExample:\nStopDebug";
info = "Stop debugging (terminate the target).\n\nExample:\nStopDebug";
break;
case 2: //run
info="Resume debugging.\n\nExample:\nrun";
info = "Resume debugging.\n\nExample:\nrun";
break;
}
}
else if(mCurrentMode==1) //testplugin
else if(mCurrentMode == 1) //testplugin
{
switch(index)
{
case 0: //plugin1
info="Just a simple plugin test command.\n\nExample:\nplugin1";
info = "Just a simple plugin test command.\n\nExample:\nplugin1";
break;
case 1: //grs
info="Get relocation table size.\n\nExample:\ngrs 404000";
info = "Get relocation table size.\n\nExample:\ngrs 404000";
break;
}

View File

@ -19,7 +19,7 @@ class CommandHelpView : public QWidget
Q_OBJECT
public:
explicit CommandHelpView(QWidget *parent = 0);
explicit CommandHelpView(QWidget* parent = 0);
~CommandHelpView();
private slots:
@ -30,7 +30,7 @@ signals:
void showCpu();
private:
Ui::CommandHelpView *ui;
Ui::CommandHelpView* ui;
QVBoxLayout* mMainLayout;
QVBoxLayout* mSymbolLayout;
QWidget* mSymbolPlaceHolder;

View File

@ -1,6 +1,6 @@
#include "CommandLineEdit.h"
CommandLineEdit::CommandLineEdit(QWidget *parent) : HistoryLineEdit(parent)
CommandLineEdit::CommandLineEdit(QWidget* parent) : HistoryLineEdit(parent)
{
//Initialize QCompleter
mCompleter = new QCompleter(QStringList(), this);
@ -28,7 +28,7 @@ void CommandLineEdit::autoCompleteDelCmd(const QString cmd)
QStringListModel* model = (QStringListModel*)(mCompleter->model());
QStringList stringList = model->stringList();
QStringList deleteList = cmd.split(QChar('\1'), QString::SkipEmptyParts);
for(int i=0; i<deleteList.size(); i++)
for(int i = 0; i < deleteList.size(); i++)
stringList.removeAll(deleteList.at(i));
model->setStringList(stringList);
}

View File

@ -9,7 +9,7 @@ class CommandLineEdit : public HistoryLineEdit
{
Q_OBJECT
public:
explicit CommandLineEdit(QWidget *parent = 0);
explicit CommandLineEdit(QWidget* parent = 0);
public slots:
void autoCompleteAddCmd(const QString cmd);

View File

@ -1,7 +1,7 @@
#include "ExceptionRangeDialog.h"
#include "ui_ExceptionRangeDialog.h"
ExceptionRangeDialog::ExceptionRangeDialog(QWidget *parent) :
ExceptionRangeDialog::ExceptionRangeDialog(QWidget* parent) :
QDialog(parent),
ui(new Ui::ExceptionRangeDialog)
{
@ -20,7 +20,7 @@ ExceptionRangeDialog::~ExceptionRangeDialog()
delete ui;
}
void ExceptionRangeDialog::on_editStart_textChanged(const QString &arg1)
void ExceptionRangeDialog::on_editStart_textChanged(const QString & arg1)
{
Q_UNUSED(arg1)
if(!ui->editStart->text().size()) //nothing entered
@ -28,24 +28,24 @@ void ExceptionRangeDialog::on_editStart_textChanged(const QString &arg1)
ui->btnOk->setEnabled(false);
return;
}
if(ui->editStart->text()=="-1")
if(ui->editStart->text() == "-1")
ui->editStart->setText("FFFFFFFF");
bool converted=false;
unsigned long start=ui->editStart->text().toUInt(&converted, 16);
bool converted = false;
unsigned long start = ui->editStart->text().toUInt(&converted, 16);
if(!converted)
{
ui->btnOk->setEnabled(false);
return;
}
unsigned long end=ui->editEnd->text().toUInt(&converted, 16);
if(converted && end<start)
unsigned long end = ui->editEnd->text().toUInt(&converted, 16);
if(converted && end < start)
ui->btnOk->setEnabled(false);
else
ui->btnOk->setEnabled(true);
}
void ExceptionRangeDialog::on_editEnd_textChanged(const QString &arg1)
void ExceptionRangeDialog::on_editEnd_textChanged(const QString & arg1)
{
Q_UNUSED(arg1)
if(!ui->editEnd->text().size() || !ui->editStart->text().size())
@ -53,22 +53,22 @@ void ExceptionRangeDialog::on_editEnd_textChanged(const QString &arg1)
ui->btnOk->setEnabled(false);
return;
}
if(ui->editEnd->text()=="-1")
if(ui->editEnd->text() == "-1")
ui->editEnd->setText("FFFFFFFF");
bool converted=false;
unsigned long start=ui->editStart->text().toUInt(&converted, 16);
bool converted = false;
unsigned long start = ui->editStart->text().toUInt(&converted, 16);
if(!converted)
{
ui->btnOk->setEnabled(false);
return;
}
unsigned long end=ui->editEnd->text().toUInt(&converted, 16);
unsigned long end = ui->editEnd->text().toUInt(&converted, 16);
if(!converted)
{
ui->btnOk->setEnabled(false);
return;
}
if(end<start)
if(end < start)
ui->btnOk->setEnabled(false);
else
ui->btnOk->setEnabled(true);
@ -76,10 +76,10 @@ void ExceptionRangeDialog::on_editEnd_textChanged(const QString &arg1)
void ExceptionRangeDialog::on_btnOk_clicked()
{
rangeStart=ui->editStart->text().toUInt(0, 16);
bool converted=false;
rangeEnd=ui->editEnd->text().toUInt(&converted, 16);
rangeStart = ui->editStart->text().toUInt(0, 16);
bool converted = false;
rangeEnd = ui->editEnd->text().toUInt(&converted, 16);
if(!converted)
rangeEnd=rangeStart;
rangeEnd = rangeStart;
accept();
}

View File

@ -13,19 +13,19 @@ class ExceptionRangeDialog : public QDialog
Q_OBJECT
public:
explicit ExceptionRangeDialog(QWidget *parent = 0);
explicit ExceptionRangeDialog(QWidget* parent = 0);
~ExceptionRangeDialog();
unsigned long rangeStart;
unsigned long rangeEnd;
private slots:
void on_editStart_textChanged(const QString &arg1);
void on_editEnd_textChanged(const QString &arg1);
void on_editStart_textChanged(const QString & arg1);
void on_editEnd_textChanged(const QString & arg1);
void on_btnOk_clicked();
private:
Ui::ExceptionRangeDialog *ui;
Ui::ExceptionRangeDialog* ui;
};
#endif // EXCEPTIONRANGEDIALOG_H

Some files were not shown because too many files have changed in this diff Show More