1
0
Fork 0

DBG: removed the 'and' and 'or' defines

This commit is contained in:
Mr. eXoDia 2015-07-11 03:30:44 +02:00
parent e8ee2430c6
commit c86eaa5a08
16 changed files with 139 additions and 144 deletions

View File

@ -92,7 +92,7 @@ extern "C" DLL_EXPORT bool _dbg_isjumpgoingtoexecute(duint addr)
static uint cacheFlags; static uint cacheFlags;
static uint cacheAddr; static uint cacheAddr;
static bool cacheResult; static bool cacheResult;
if(cacheAddr != addr or cacheFlags != GetContextDataEx(hActiveThread, UE_EFLAGS)) if(cacheAddr != addr || cacheFlags != GetContextDataEx(hActiveThread, UE_EFLAGS))
{ {
cacheFlags = GetContextDataEx(hActiveThread, UE_EFLAGS); cacheFlags = GetContextDataEx(hActiveThread, UE_EFLAGS);
cacheAddr = addr; cacheAddr = addr;
@ -122,10 +122,10 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer; PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer;
pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO); pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
pSymbol->MaxNameLen = MAX_LABEL_SIZE; pSymbol->MaxNameLen = MAX_LABEL_SIZE;
if(SafeSymFromAddr(fdProcessInfo->hProcess, (DWORD64)addr, &displacement, pSymbol) and !displacement) if(SafeSymFromAddr(fdProcessInfo->hProcess, (DWORD64)addr, &displacement, pSymbol) && !displacement)
{ {
pSymbol->Name[pSymbol->MaxNameLen - 1] = '\0'; pSymbol->Name[pSymbol->MaxNameLen - 1] = '\0';
if(!bUndecorateSymbolNames or !SafeUnDecorateSymbolName(pSymbol->Name, addrinfo->label, MAX_LABEL_SIZE, UNDNAME_COMPLETE)) if(!bUndecorateSymbolNames || !SafeUnDecorateSymbolName(pSymbol->Name, addrinfo->label, MAX_LABEL_SIZE, UNDNAME_COMPLETE))
strcpy_s(addrinfo->label, pSymbol->Name); strcpy_s(addrinfo->label, pSymbol->Name);
retval = true; retval = true;
} }
@ -138,10 +138,10 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
uint val = 0; uint val = 0;
if(MemRead((void*)basicinfo.memory.value, &val, sizeof(val), 0)) if(MemRead((void*)basicinfo.memory.value, &val, sizeof(val), 0))
{ {
if(SafeSymFromAddr(fdProcessInfo->hProcess, (DWORD64)val, &displacement, pSymbol) and !displacement) if(SafeSymFromAddr(fdProcessInfo->hProcess, (DWORD64)val, &displacement, pSymbol) && !displacement)
{ {
pSymbol->Name[pSymbol->MaxNameLen - 1] = '\0'; pSymbol->Name[pSymbol->MaxNameLen - 1] = '\0';
if(!bUndecorateSymbolNames or !SafeUnDecorateSymbolName(pSymbol->Name, addrinfo->label, MAX_LABEL_SIZE, UNDNAME_COMPLETE)) if(!bUndecorateSymbolNames || !SafeUnDecorateSymbolName(pSymbol->Name, addrinfo->label, MAX_LABEL_SIZE, UNDNAME_COMPLETE))
sprintf_s(addrinfo->label, "JMP.&%s", pSymbol->Name); sprintf_s(addrinfo->label, "JMP.&%s", pSymbol->Name);
retval = true; retval = true;
} }
@ -175,12 +175,12 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
DWORD dwDisplacement; DWORD dwDisplacement;
IMAGEHLP_LINE64 line; IMAGEHLP_LINE64 line;
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
if(SafeSymGetLineFromAddr64(fdProcessInfo->hProcess, (DWORD64)addr, &dwDisplacement, &line) and !dwDisplacement) if(SafeSymGetLineFromAddr64(fdProcessInfo->hProcess, (DWORD64)addr, &dwDisplacement, &line) && !dwDisplacement)
{ {
char filename[deflen] = ""; char filename[deflen] = "";
strcpy_s(filename, line.FileName); strcpy_s(filename, line.FileName);
int len = (int)strlen(filename); int len = (int)strlen(filename);
while(filename[len] != '\\' and len != 0) while(filename[len] != '\\' && len != 0)
len--; len--;
if(len) if(len)
len++; len++;
@ -208,7 +208,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
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 || !disasmgetstringat(instr.arg[i].constant, &strtype, ascii, unicode, len_left) || strtype == str_none)
continue; continue;
switch(strtype) switch(strtype)
{ {
@ -228,7 +228,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
break; break;
} }
} }
else if(instr.arg[i].memvalue and (disasmgetstringat(instr.arg[i].memvalue, &strtype, ascii, unicode, len_left) or _dbg_addrinfoget(instr.arg[i].memvalue, instr.arg[i].segment, &newinfo))) else if(instr.arg[i].memvalue && (disasmgetstringat(instr.arg[i].memvalue, &strtype, ascii, unicode, len_left) || _dbg_addrinfoget(instr.arg[i].memvalue, instr.arg[i].segment, &newinfo)))
{ {
switch(strtype) switch(strtype)
{ {
@ -255,7 +255,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
break; break;
} }
} }
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))) else if(instr.arg[i].value && (disasmgetstringat(instr.arg[i].value, &strtype, ascii, unicode, len_left) || _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 if(instr.type != instr_normal) //stack/jumps (eg add esp,4 or jmp 401110) cannot directly point to strings
strtype = str_none; strtype = str_none;
@ -333,7 +333,7 @@ extern "C" DLL_EXPORT int _dbg_bpgettypeat(duint addr)
static int cacheBpCount; static int cacheBpCount;
static int cacheResult; static int cacheResult;
int bpcount = BpGetList(nullptr); int bpcount = BpGetList(nullptr);
if(cacheAddr != addr or cacheBpCount != bpcount) if(cacheAddr != addr || cacheBpCount != bpcount)
{ {
BREAKPOINT bp; BREAKPOINT bp;
cacheAddr = addr; cacheAddr = addr;
@ -792,7 +792,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
case DBG_DISASM_FAST_AT: case DBG_DISASM_FAST_AT:
{ {
if(!param1 or !param2) if(!param1 || !param2)
return 0; return 0;
BASIC_INSTRUCTION_INFO* basicinfo = (BASIC_INSTRUCTION_INFO*)param2; BASIC_INSTRUCTION_INFO* basicinfo = (BASIC_INSTRUCTION_INFO*)param2;
if(!disasmfast((uint)param1, basicinfo)) if(!disasmfast((uint)param1, basicinfo))

View File

@ -136,7 +136,7 @@ void setalloctrace(const char* file)
bool arraycontains(const char* cmd_list, const char* cmd) bool arraycontains(const char* cmd_list, const char* cmd)
{ {
//TODO: fix this function a little //TODO: fix this function a little
if(!cmd_list or !cmd) if(!cmd_list || !cmd)
return false; return false;
char temp[deflen] = ""; char temp[deflen] = "";
strcpy_s(temp, cmd_list); strcpy_s(temp, cmd_list);

View File

@ -30,11 +30,6 @@
#include "stringutils.h" #include "stringutils.h"
#include "dbghelp_safe.h" #include "dbghelp_safe.h"
#ifndef __GNUC__
#define and &&
#define or ||
#endif
#ifndef DLL_EXPORT #ifndef DLL_EXPORT
#define DLL_EXPORT __declspec(dllexport) #define DLL_EXPORT __declspec(dllexport)
#endif //DLL_IMPORT #endif //DLL_IMPORT

View File

@ -166,7 +166,7 @@ bool apienumexports(uint base, EXPORTENUMCALLBACK cbEnum)
memset(&export_dir, 0, sizeof(export_dir)); memset(&export_dir, 0, sizeof(export_dir));
MemRead((void*)(export_dir_rva + base), &export_dir, sizeof(export_dir), 0); MemRead((void*)(export_dir_rva + base), &export_dir, sizeof(export_dir), 0);
unsigned int NumberOfNames = export_dir.NumberOfNames; unsigned int NumberOfNames = export_dir.NumberOfNames;
if(!export_dir.NumberOfFunctions or !NumberOfNames) //no named exports if(!export_dir.NumberOfFunctions || !NumberOfNames) //no named exports
return false; return false;
char modname[MAX_MODULE_SIZE] = ""; char modname[MAX_MODULE_SIZE] = "";
ModNameFromAddr(base, modname, true); ModNameFromAddr(base, modname, true);
@ -190,14 +190,14 @@ bool apienumexports(uint base, EXPORTENUMCALLBACK cbEnum)
DWORD curFunctionRva = 0; DWORD curFunctionRva = 0;
MemRead(AddrOfFunctions_va + sizeof(DWORD)*curAddrOfNameOrdinals, &curFunctionRva, sizeof(DWORD), 0); MemRead(AddrOfFunctions_va + sizeof(DWORD)*curAddrOfNameOrdinals, &curFunctionRva, sizeof(DWORD), 0);
if(curFunctionRva >= export_dir_rva and curFunctionRva < export_dir_rva + export_dir_size) if(curFunctionRva >= export_dir_rva && curFunctionRva < export_dir_rva + export_dir_size)
{ {
char forwarded_api[deflen] = ""; char forwarded_api[deflen] = "";
memset(forwarded_api, 0, deflen); memset(forwarded_api, 0, deflen);
MemRead((void*)(curFunctionRva + base), forwarded_api, deflen, 0); MemRead((void*)(curFunctionRva + base), forwarded_api, deflen, 0);
int len = (int)strlen(forwarded_api); int len = (int)strlen(forwarded_api);
int j = 0; int j = 0;
while(forwarded_api[j] != '.' and j < len) while(forwarded_api[j] != '.' && j < len)
j++; j++;
if(forwarded_api[j] == '.') if(forwarded_api[j] == '.')
{ {

View File

@ -14,7 +14,7 @@
static bool cbUnknown(const char* text, ULONGLONG* value) static bool cbUnknown(const char* text, ULONGLONG* value)
{ {
if(!text or !value) if(!text || !value)
return false; return false;
uint val; uint val;
if(!valfromstring(text, &val)) if(!valfromstring(text, &val))

View File

@ -75,7 +75,7 @@ void cmdfree(COMMAND* cmd_list)
*/ */
bool cmdnew(COMMAND* command_list, const char* name, CBCOMMAND cbCommand, bool debugonly) bool cmdnew(COMMAND* command_list, const char* name, CBCOMMAND cbCommand, bool debugonly)
{ {
if(!command_list or !cbCommand or !name or !*name or cmdfind(command_list, name, 0)) if(!command_list || !cbCommand || !name || !*name || cmdfind(command_list, name, 0))
return false; return false;
COMMAND* cmd; COMMAND* cmd;
bool nonext = false; bool nonext = false;
@ -113,7 +113,7 @@ COMMAND* cmdget(COMMAND* command_list, const char* cmd)
strcpy_s(new_cmd, deflen, cmd); strcpy_s(new_cmd, deflen, cmd);
int len = (int)strlen(new_cmd); int len = (int)strlen(new_cmd);
int start = 0; int start = 0;
while(new_cmd[start] != ' ' and start < len) while(new_cmd[start] != ' ' && start < len)
start++; start++;
new_cmd[start] = 0; new_cmd[start] = 0;
COMMAND* found = cmdfind(command_list, new_cmd, 0); COMMAND* found = cmdfind(command_list, new_cmd, 0);
@ -195,7 +195,7 @@ error_is_fatal: error return of a command callback stops the command proce
*/ */
CMDRESULT cmdloop(COMMAND* command_list, CBCOMMAND cbUnknownCommand, CBCOMMANDPROVIDER cbCommandProvider, CBCOMMANDFINDER cbCommandFinder, bool error_is_fatal) CMDRESULT cmdloop(COMMAND* command_list, CBCOMMAND cbUnknownCommand, CBCOMMANDPROVIDER cbCommandProvider, CBCOMMANDFINDER cbCommandFinder, bool error_is_fatal)
{ {
if(!cbUnknownCommand or !cbCommandProvider) if(!cbUnknownCommand || !cbCommandProvider)
return STATUS_ERROR; return STATUS_ERROR;
char command[deflen] = ""; char command[deflen] = "";
bool bLoop = true; bool bLoop = true;
@ -212,17 +212,17 @@ CMDRESULT cmdloop(COMMAND* command_list, CBCOMMAND cbUnknownCommand, CBCOMMANDPR
else //'dirty' command processing else //'dirty' command processing
cmd = cbCommandFinder(command_list, command); cmd = cbCommandFinder(command_list, command);
if(!cmd or !cmd->cbCommand) //unknown command if(!cmd || !cmd->cbCommand) //unknown command
{ {
char* argv[1]; char* argv[1];
*argv = command; *argv = command;
CMDRESULT res = cbUnknownCommand(1, argv); CMDRESULT res = cbUnknownCommand(1, argv);
if((error_is_fatal and res == STATUS_ERROR) or res == STATUS_EXIT) if((error_is_fatal && res == STATUS_ERROR) || res == STATUS_EXIT)
bLoop = false; bLoop = false;
} }
else else
{ {
if(cmd->debugonly and !DbgIsDebugging()) if(cmd->debugonly && !DbgIsDebugging())
{ {
dputs("this command is debug-only"); dputs("this command is debug-only");
if(error_is_fatal) if(error_is_fatal)
@ -244,7 +244,7 @@ CMDRESULT cmdloop(COMMAND* command_list, CBCOMMAND cbUnknownCommand, CBCOMMANDPR
for(int i = 0; i < argcount; i++) for(int i = 0; i < argcount; i++)
efree(argv[i + 1], "cmdloop:argv[i+1]"); efree(argv[i + 1], "cmdloop:argv[i+1]");
efree(argv, "cmdloop:argv"); efree(argv, "cmdloop:argv");
if((error_is_fatal and res == STATUS_ERROR) or res == STATUS_EXIT) if((error_is_fatal && res == STATUS_ERROR) || res == STATUS_EXIT)
bLoop = false; bLoop = false;
} }
} }
@ -319,7 +319,7 @@ static void specialformat(char* string)
return; return;
} }
int flen = (int)strlen(found); //n(+)=n++ 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-- if((found[flen - 1] == '+' && found[flen - 2] == '+') || (found[flen - 1] == '-' && found[flen - 2] == '-')) //eax++/eax--
{ {
found[flen - 2] = 0; found[flen - 2] = 0;
char op = found[flen - 1]; char op = found[flen - 1];
@ -344,7 +344,7 @@ static void specialformat(char* string)
} }
strcpy(string, str); 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] == '+' && string[len - 2] == '+') || (string[len - 1] == '-' && string[len - 2] == '-')) //eax++/eax--
{ {
string[len - 2] = 0; string[len - 2] = 0;
char op = string[len - 1]; char op = string[len - 1];
@ -387,14 +387,14 @@ COMMAND* cmdfindmain(COMMAND* cmd_list, char* command)
*/ */
CMDRESULT cmddirectexec(COMMAND* cmd_list, const char* cmd) CMDRESULT cmddirectexec(COMMAND* cmd_list, const char* cmd)
{ {
if(!cmd or !strlen(cmd)) if(!cmd || !strlen(cmd))
return STATUS_ERROR; return STATUS_ERROR;
char command[deflen] = ""; char command[deflen] = "";
strcpy_s(command, StringUtils::Trim(cmd).c_str()); strcpy_s(command, StringUtils::Trim(cmd).c_str());
COMMAND* found = cmdfindmain(cmd_list, command); COMMAND* found = cmdfindmain(cmd_list, command);
if(!found or !found->cbCommand) if(!found || !found->cbCommand)
return STATUS_ERROR; return STATUS_ERROR;
if(found->debugonly and !DbgIsDebugging()) if(found->debugonly && !DbgIsDebugging())
return STATUS_ERROR; return STATUS_ERROR;
Command cmdParsed(command); Command cmdParsed(command);
int argcount = cmdParsed.GetArgCount(); int argcount = cmdParsed.GetArgCount();

View File

@ -207,7 +207,7 @@ void cbUserBreakpoint()
BRIDGEBP pluginBp; BRIDGEBP pluginBp;
PLUG_CB_BREAKPOINT bpInfo; PLUG_CB_BREAKPOINT bpInfo;
bpInfo.breakpoint = 0; bpInfo.breakpoint = 0;
if(!BpGet(GetContextDataEx(hActiveThread, UE_CIP), BPNORMAL, 0, &bp) and bp.enabled) if(!BpGet(GetContextDataEx(hActiveThread, UE_CIP), BPNORMAL, 0, &bp) && bp.enabled)
dputs("Breakpoint reached not in list!"); dputs("Breakpoint reached not in list!");
else else
{ {
@ -438,7 +438,7 @@ static BOOL CALLBACK SymRegisterCallbackProc64(HANDLE hProcess, ULONG ActionCode
suspress = true; suspress = true;
zerobar = true; zerobar = true;
} }
else if(sscanf(text, "%*s %d percent", &percent) == 1 or sscanf(text, "%d percent", &percent) == 1) else if(sscanf(text, "%*s %d percent", &percent) == 1 || sscanf(text, "%d percent", &percent) == 1)
{ {
GuiSymbolSetProgress(percent); GuiSymbolSetProgress(percent);
suspress = true; suspress = true;
@ -576,7 +576,7 @@ static unsigned char getCIPch()
void cbRtrStep() void cbRtrStep()
{ {
unsigned int cipch = getCIPch(); unsigned int cipch = getCIPch();
if(cipch == 0xC3 or cipch == 0xC2) if(cipch == 0xC3 || cipch == 0xC2)
cbRtrFinalStep(); cbRtrFinalStep();
else else
StepOver((void*)cbRtrStep); StepOver((void*)cbRtrStep);
@ -648,7 +648,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo)
BpEnumAll(cbSetModuleBreakpoints, modname); BpEnumAll(cbSetModuleBreakpoints, modname);
GuiUpdateBreakpointsView(); GuiUpdateBreakpointsView();
pCreateProcessBase = (uint)CreateProcessInfo->lpBaseOfImage; pCreateProcessBase = (uint)CreateProcessInfo->lpBaseOfImage;
if(!bFileIsDll and !bIsAttached) //Set entry breakpoint if(!bFileIsDll && !bIsAttached) //Set entry breakpoint
{ {
pDebuggedBase = pCreateProcessBase; //debugged base = executable pDebuggedBase = pCreateProcessBase; //debugged base = executable
char command[256] = ""; char command[256] = "";
@ -842,7 +842,7 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll)
char command[256] = ""; char command[256] = "";
bool bIsDebuggingThis = false; bool bIsDebuggingThis = false;
if(bFileIsDll and !_stricmp(DLLDebugFileName, szFileName) and !bIsAttached) //Set entry breakpoint if(bFileIsDll && !_stricmp(DLLDebugFileName, szFileName) && !bIsAttached) //Set entry breakpoint
{ {
bIsDebuggingThis = true; bIsDebuggingThis = true;
pDebuggedBase = (uint)base; pDebuggedBase = (uint)base;
@ -1044,7 +1044,7 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData)
memcpy(&nameInfo, ExceptionData->ExceptionRecord.ExceptionInformation, sizeof(THREADNAME_INFO)); memcpy(&nameInfo, ExceptionData->ExceptionRecord.ExceptionInformation, sizeof(THREADNAME_INFO));
if(nameInfo.dwThreadID == -1) //current thread if(nameInfo.dwThreadID == -1) //current thread
nameInfo.dwThreadID = ((DEBUG_EVENT*)GetDebugData())->dwThreadId; nameInfo.dwThreadID = ((DEBUG_EVENT*)GetDebugData())->dwThreadId;
if(nameInfo.dwType == 0x1000 and nameInfo.dwFlags == 0 and ThreadIsValid(nameInfo.dwThreadID)) //passed basic checks if(nameInfo.dwType == 0x1000 && nameInfo.dwFlags == 0 && ThreadIsValid(nameInfo.dwThreadID)) //passed basic checks
{ {
Memory<char*> ThreadName(MAX_THREAD_NAME_SIZE, "cbException:ThreadName"); Memory<char*> ThreadName(MAX_THREAD_NAME_SIZE, "cbException:ThreadName");
if(MemRead((void*)nameInfo.szName, ThreadName, MAX_THREAD_NAME_SIZE - 1, 0)) if(MemRead((void*)nameInfo.szName, ThreadName, MAX_THREAD_NAME_SIZE - 1, 0))
@ -1118,14 +1118,14 @@ DWORD WINAPI threadDebugLoop(void* lpParameter)
return 0; return 0;
} }
BOOL wow64 = false, mewow64 = false; BOOL wow64 = false, mewow64 = false;
if(!IsWow64Process(fdProcessInfo->hProcess, &wow64) or !IsWow64Process(GetCurrentProcess(), &mewow64)) if(!IsWow64Process(fdProcessInfo->hProcess, &wow64) || !IsWow64Process(GetCurrentProcess(), &mewow64))
{ {
dputs("IsWow64Process failed!"); dputs("IsWow64Process failed!");
StopDebug(); StopDebug();
unlock(WAITID_STOP); unlock(WAITID_STOP);
return 0; return 0;
} }
if((mewow64 and !wow64) or (!mewow64 and wow64)) if((mewow64 && !wow64) || (!mewow64 && wow64))
{ {
#ifdef _WIN64 #ifdef _WIN64
dputs("Use x32dbg to debug this process!"); dputs("Use x32dbg to debug this process!");
@ -1156,7 +1156,7 @@ DWORD WINAPI threadDebugLoop(void* lpParameter)
//set GUI title //set GUI title
strcpy_s(szBaseFileName, szFileName); strcpy_s(szBaseFileName, szFileName);
int len = (int)strlen(szBaseFileName); int len = (int)strlen(szBaseFileName);
while(szBaseFileName[len] != '\\' and len) while(szBaseFileName[len] != '\\' && len)
len--; len--;
if(len) if(len)
strcpy_s(szBaseFileName, szBaseFileName + len + 1); strcpy_s(szBaseFileName, szBaseFileName + len + 1);
@ -1198,7 +1198,7 @@ bool cbDeleteAllBreakpoints(const BREAKPOINT* bp)
dprintf("Delete breakpoint failed (BpDelete): "fhex"\n", bp->addr); dprintf("Delete breakpoint failed (BpDelete): "fhex"\n", bp->addr);
return false; return false;
} }
if(!bp->enabled or DeleteBPX(bp->addr)) if(!bp->enabled || DeleteBPX(bp->addr))
return true; return true;
dprintf("Delete breakpoint failed (DeleteBPX): "fhex"\n", bp->addr); dprintf("Delete breakpoint failed (DeleteBPX): "fhex"\n", bp->addr);
return false; return false;
@ -1206,7 +1206,7 @@ bool cbDeleteAllBreakpoints(const BREAKPOINT* bp)
bool cbEnableAllBreakpoints(const BREAKPOINT* bp) bool cbEnableAllBreakpoints(const BREAKPOINT* bp)
{ {
if(bp->type != BPNORMAL or bp->enabled) if(bp->type != BPNORMAL || bp->enabled)
return true; return true;
if(!BpEnable(bp->addr, BPNORMAL, true)) if(!BpEnable(bp->addr, BPNORMAL, true))
@ -1224,7 +1224,7 @@ bool cbEnableAllBreakpoints(const BREAKPOINT* bp)
bool cbDisableAllBreakpoints(const BREAKPOINT* bp) bool cbDisableAllBreakpoints(const BREAKPOINT* bp)
{ {
if(bp->type != BPNORMAL or !bp->enabled) if(bp->type != BPNORMAL || !bp->enabled)
return true; return true;
if(!BpEnable(bp->addr, BPNORMAL, false)) if(!BpEnable(bp->addr, BPNORMAL, false))
@ -1242,7 +1242,7 @@ bool cbDisableAllBreakpoints(const BREAKPOINT* bp)
bool cbEnableAllHardwareBreakpoints(const BREAKPOINT* bp) bool cbEnableAllHardwareBreakpoints(const BREAKPOINT* bp)
{ {
if(bp->type != BPHARDWARE or bp->enabled) if(bp->type != BPHARDWARE || bp->enabled)
return true; return true;
DWORD drx = 0; DWORD drx = 0;
if(!GetUnusedHardwareBreakPointRegister(&drx)) if(!GetUnusedHardwareBreakPointRegister(&drx))
@ -1268,7 +1268,7 @@ bool cbEnableAllHardwareBreakpoints(const BREAKPOINT* bp)
bool cbDisableAllHardwareBreakpoints(const BREAKPOINT* bp) bool cbDisableAllHardwareBreakpoints(const BREAKPOINT* bp)
{ {
if(bp->type != BPHARDWARE or !bp->enabled) if(bp->type != BPHARDWARE || !bp->enabled)
return true; return true;
if(!BpEnable(bp->addr, BPHARDWARE, false)) if(!BpEnable(bp->addr, BPHARDWARE, false))
{ {
@ -1285,7 +1285,7 @@ bool cbDisableAllHardwareBreakpoints(const BREAKPOINT* bp)
bool cbEnableAllMemoryBreakpoints(const BREAKPOINT* bp) bool cbEnableAllMemoryBreakpoints(const BREAKPOINT* bp)
{ {
if(bp->type != BPMEMORY or bp->enabled) if(bp->type != BPMEMORY || bp->enabled)
return true; return true;
uint size = 0; uint size = 0;
MemFindBaseAddr(bp->addr, &size); MemFindBaseAddr(bp->addr, &size);
@ -1304,7 +1304,7 @@ bool cbEnableAllMemoryBreakpoints(const BREAKPOINT* bp)
bool cbDisableAllMemoryBreakpoints(const BREAKPOINT* bp) bool cbDisableAllMemoryBreakpoints(const BREAKPOINT* bp)
{ {
if(bp->type != BPMEMORY or !bp->enabled) if(bp->type != BPMEMORY || !bp->enabled)
return true; return true;
if(!BpEnable(bp->addr, BPMEMORY, false)) if(!BpEnable(bp->addr, BPMEMORY, false))
{ {
@ -1417,7 +1417,7 @@ DWORD WINAPI threadAttachLoop(void* lpParameter)
//set GUI title //set GUI title
strcpy_s(szBaseFileName, szFileName); strcpy_s(szBaseFileName, szFileName);
int len = (int)strlen(szBaseFileName); int len = (int)strlen(szBaseFileName);
while(szBaseFileName[len] != '\\' and len) while(szBaseFileName[len] != '\\' && len)
len--; len--;
if(len) if(len)
strcpy_s(szBaseFileName, szBaseFileName + len + 1); strcpy_s(szBaseFileName, szBaseFileName + len + 1);
@ -1790,9 +1790,9 @@ bool dbglistprocesses(std::vector<PROCESSENTRY32>* list)
if(!hProcess) if(!hProcess)
continue; continue;
BOOL wow64 = false, mewow64 = false; BOOL wow64 = false, mewow64 = false;
if(!IsWow64Process(hProcess, &wow64) or !IsWow64Process(GetCurrentProcess(), &mewow64)) if(!IsWow64Process(hProcess, &wow64) || !IsWow64Process(GetCurrentProcess(), &mewow64))
continue; continue;
if((mewow64 and !wow64) or (!mewow64 and wow64)) if((mewow64 && !wow64) || (!mewow64 && wow64))
continue; continue;
wchar_t szExePath[MAX_PATH] = L""; wchar_t szExePath[MAX_PATH] = L"";
if(GetModuleFileNameExW(hProcess, 0, szExePath, MAX_PATH)) if(GetModuleFileNameExW(hProcess, 0, szExePath, MAX_PATH))

View File

@ -91,7 +91,7 @@ CMDRESULT cbDebugInit(int argc, char* argv[])
static char currentfolder[deflen] = ""; static char currentfolder[deflen] = "";
strcpy_s(currentfolder, arg1); strcpy_s(currentfolder, arg1);
int len = (int)strlen(currentfolder); int len = (int)strlen(currentfolder);
while(currentfolder[len] != '\\' and len != 0) while(currentfolder[len] != '\\' && len != 0)
len--; len--;
currentfolder[len] = 0; currentfolder[len] = 0;
@ -197,7 +197,7 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]]
bool has_arg2 = argc > 3; bool has_arg2 = argc > 3;
if(has_arg2) if(has_arg2)
strcpy_s(argtype, argv[3]); strcpy_s(argtype, argv[3]);
if(!has_arg2 and (scmp(argname, "ss") or scmp(argname, "long") or scmp(argname, "ud2"))) if(!has_arg2 && (scmp(argname, "ss") || scmp(argname, "long") || scmp(argname, "ud2")))
{ {
strcpy_s(argtype, argname); strcpy_s(argtype, argname);
*argname = 0; *argname = 0;
@ -293,7 +293,7 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[])
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
uint addr = 0; uint addr = 0;
if(!valfromstring(argv[1], &addr) or !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint
{ {
dprintf("No such breakpoint \"%s\"\n", argv[1]); dprintf("No such breakpoint \"%s\"\n", argv[1]);
return STATUS_ERROR; return STATUS_ERROR;
@ -346,7 +346,7 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
uint addr = 0; uint addr = 0;
if(!valfromstring(argv[1], &addr) or !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint
{ {
dprintf("No such breakpoint \"%s\"\n", argv[1]); dprintf("No such breakpoint \"%s\"\n", argv[1]);
return STATUS_ERROR; return STATUS_ERROR;
@ -404,7 +404,7 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
uint addr = 0; uint addr = 0;
if(!valfromstring(argv[1], &addr) or !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint
{ {
dprintf("No such breakpoint \"%s\"\n", argv[1]); dprintf("No such breakpoint \"%s\"\n", argv[1]);
return STATUS_ERROR; return STATUS_ERROR;
@ -605,7 +605,7 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[])
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
uint addr = 0; uint addr = 0;
if(!valfromstring(argv[1], &addr) or !BpGet(addr, BPMEMORY, 0, &found)) //invalid breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPMEMORY, 0, &found)) //invalid breakpoint
{ {
dprintf("No such memory breakpoint \"%s\"\n", argv[1]); dprintf("No such memory breakpoint \"%s\"\n", argv[1]);
return STATUS_ERROR; return STATUS_ERROR;
@ -763,7 +763,7 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
uint addr = 0; uint addr = 0;
if(!valfromstring(argv[1], &addr) or !BpGet(addr, BPHARDWARE, 0, &found)) //invalid breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPHARDWARE, 0, &found)) //invalid breakpoint
{ {
dprintf("No such hardware breakpoint \"%s\"\n", argv[1]); dprintf("No such hardware breakpoint \"%s\"\n", argv[1]);
return STATUS_ERROR; return STATUS_ERROR;
@ -844,7 +844,7 @@ CMDRESULT cbDebugMemset(int argc, char* argv[])
dputs("Not enough arguments"); dputs("Not enough arguments");
return STATUS_ERROR; return STATUS_ERROR;
} }
if(!valfromstring(argv[1], &addr, false) or !valfromstring(argv[2], &value, false)) if(!valfromstring(argv[1], &addr, false) || !valfromstring(argv[2], &value, false))
return STATUS_ERROR; return STATUS_ERROR;
if(argc > 3) if(argc > 3)
{ {
@ -980,12 +980,12 @@ CMDRESULT cbDebugAttach(int argc, char* argv[])
return STATUS_ERROR; return STATUS_ERROR;
} }
BOOL wow64 = false, mewow64 = false; BOOL wow64 = false, mewow64 = false;
if(!IsWow64Process(hProcess, &wow64) or !IsWow64Process(GetCurrentProcess(), &mewow64)) if(!IsWow64Process(hProcess, &wow64) || !IsWow64Process(GetCurrentProcess(), &mewow64))
{ {
dputs("IsWow64Process failed!"); dputs("IsWow64Process failed!");
return STATUS_ERROR; return STATUS_ERROR;
} }
if((mewow64 and !wow64) or (!mewow64 and wow64)) if((mewow64 && !wow64) || (!mewow64 && wow64))
{ {
#ifdef _WIN64 #ifdef _WIN64
dputs("Use x32dbg to debug this process!"); dputs("Use x32dbg to debug this process!");
@ -1303,7 +1303,7 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
} }
BREAKPOINT found; BREAKPOINT found;
uint addr = 0; uint addr = 0;
if(!valfromstring(argv[1], &addr) or !BpGet(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint
{ {
dprintf("No such hardware breakpoint \"%s\"\n", argv[1]); dprintf("No such hardware breakpoint \"%s\"\n", argv[1]);
return STATUS_ERROR; return STATUS_ERROR;
@ -1316,7 +1316,7 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
} }
TITANSETDRX(found.titantype, drx); TITANSETDRX(found.titantype, drx);
BpSetTitanType(found.addr, BPHARDWARE, found.titantype); BpSetTitanType(found.addr, BPHARDWARE, found.titantype);
if(!BpEnable(found.addr, BPHARDWARE, true) or !SetHardwareBreakPoint(found.addr, drx, TITANGETTYPE(found.titantype), TITANGETSIZE(found.titantype), (void*)cbHardwareBreakpoint)) if(!BpEnable(found.addr, BPHARDWARE, true) || !SetHardwareBreakPoint(found.addr, drx, TITANGETTYPE(found.titantype), TITANGETSIZE(found.titantype), (void*)cbHardwareBreakpoint))
{ {
dprintf("Could not enable hardware breakpoint "fhex"\n", found.addr); dprintf("Could not enable hardware breakpoint "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
@ -1343,7 +1343,7 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
} }
BREAKPOINT found; BREAKPOINT found;
uint addr = 0; uint addr = 0;
if(!valfromstring(argv[1], &addr) or !BpGet(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint
{ {
dprintf("No such hardware breakpoint \"%s\"\n", argv[1]); dprintf("No such hardware breakpoint \"%s\"\n", argv[1]);
return STATUS_ERROR; return STATUS_ERROR;
@ -1353,7 +1353,7 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
dputs("Hardware breakpoint already disabled!"); dputs("Hardware breakpoint already disabled!");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
if(!BpEnable(found.addr, BPHARDWARE, false) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) if(!BpEnable(found.addr, BPHARDWARE, false) || !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype)))
{ {
dprintf("Could not disable hardware breakpoint "fhex"\n", found.addr); dprintf("Could not disable hardware breakpoint "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
@ -1380,7 +1380,7 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
} }
BREAKPOINT found; BREAKPOINT found;
uint addr = 0; uint addr = 0;
if(!valfromstring(argv[1], &addr) or !BpGet(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint
{ {
dprintf("No such memory breakpoint \"%s\"\n", argv[1]); dprintf("No such memory breakpoint \"%s\"\n", argv[1]);
return STATUS_ERROR; return STATUS_ERROR;
@ -1393,7 +1393,7 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
} }
uint size = 0; uint size = 0;
MemFindBaseAddr(found.addr, &size); MemFindBaseAddr(found.addr, &size);
if(!BpEnable(found.addr, BPMEMORY, true) or !SetMemoryBPXEx(found.addr, size, found.titantype, !found.singleshoot, (void*)cbMemoryBreakpoint)) if(!BpEnable(found.addr, BPMEMORY, true) || !SetMemoryBPXEx(found.addr, size, found.titantype, !found.singleshoot, (void*)cbMemoryBreakpoint))
{ {
dprintf("Could not enable memory breakpoint "fhex"\n", found.addr); dprintf("Could not enable memory breakpoint "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
@ -1420,7 +1420,7 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
} }
BREAKPOINT found; BREAKPOINT found;
uint addr = 0; uint addr = 0;
if(!valfromstring(argv[1], &addr) or !BpGet(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint if(!valfromstring(argv[1], &addr) || !BpGet(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint
{ {
dprintf("No such memory breakpoint \"%s\"\n", argv[1]); dprintf("No such memory breakpoint \"%s\"\n", argv[1]);
return STATUS_ERROR; return STATUS_ERROR;
@ -1432,7 +1432,7 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
} }
uint size = 0; uint size = 0;
MemFindBaseAddr(found.addr, &size); MemFindBaseAddr(found.addr, &size);
if(!BpEnable(found.addr, BPMEMORY, false) or !RemoveMemoryBPX(found.addr, size)) if(!BpEnable(found.addr, BPMEMORY, false) || !RemoveMemoryBPX(found.addr, size))
{ {
dprintf("Could not disable memory breakpoint "fhex"\n", found.addr); dprintf("Could not disable memory breakpoint "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;

View File

@ -88,7 +88,7 @@ void fillbasicinfo(Capstone* cp, BASIC_INSTRUCTION_INFO* basicinfo)
bool disasmfast(unsigned char* data, uint addr, BASIC_INSTRUCTION_INFO* basicinfo) bool disasmfast(unsigned char* data, uint addr, BASIC_INSTRUCTION_INFO* basicinfo)
{ {
if(!data or !basicinfo) if(!data || !basicinfo)
return false; return false;
Capstone cp; Capstone cp;
if(!cp.Disassemble(addr, data, MAX_DISASM_BUFFER)) if(!cp.Disassemble(addr, data, MAX_DISASM_BUFFER))

View File

@ -248,10 +248,10 @@ static bool isasciistring(const unsigned char* data, int maxlen)
break; break;
} }
if(len < 2 or len + 1 >= maxlen) if(len < 2 || len + 1 >= maxlen)
return false; return false;
for(int i = 0; i < len; i++) for(int i = 0; i < len; i++)
if(!isprint(data[i]) and !isspace(data[i])) if(!isprint(data[i]) && !isspace(data[i]))
return false; return false;
return true; return true;
} }
@ -265,13 +265,13 @@ static bool isunicodestring(const unsigned char* data, int maxlen)
break; break;
} }
if(len < 2 or len + 1 >= maxlen) if(len < 2 || len + 1 >= maxlen)
return false; return false;
for(int i = 0; i < len * 2; i += 2) for(int i = 0; i < len * 2; i += 2)
{ {
if(data[i + 1]) //Extended ASCII only if(data[i + 1]) //Extended ASCII only
return false; return false;
if(!isprint(data[i]) and !isspace(data[i])) if(!isprint(data[i]) && !isspace(data[i]))
return false; return false;
} }
return true; return true;
@ -285,7 +285,7 @@ bool disasmispossiblestring(uint addr)
return false; return false;
uint test = 0; uint test = 0;
memcpy(&test, data, sizeof(uint)); memcpy(&test, data, sizeof(uint));
if(isasciistring(data, sizeof(data)) or isunicodestring(data, _countof(data))) if(isasciistring(data, sizeof(data)) || isunicodestring(data, _countof(data)))
return true; return true;
return false; return false;
} }

View File

@ -47,7 +47,7 @@ CMDRESULT cbBadCmd(int argc, char* argv[])
char format_str[deflen] = ""; char format_str[deflen] = "";
if(isvar)// and *cmd!='.' and *cmd!='x') //prevent stupid 0=0 stuff if(isvar)// and *cmd!='.' and *cmd!='x') //prevent stupid 0=0 stuff
{ {
if(value > 15 and !hexonly) if(value > 15 && !hexonly)
{ {
if(!valuesignedcalc()) //signed numbers if(!valuesignedcalc()) //signed numbers
sprintf(format_str, "%%s=%%.%d"fext"X (%%"fext"ud)\n", valsize); sprintf(format_str, "%%s=%%.%d"fext"X (%%"fext"ud)\n", valsize);
@ -63,7 +63,7 @@ CMDRESULT cbBadCmd(int argc, char* argv[])
} }
else else
{ {
if(value > 15 and !hexonly) if(value > 15 && !hexonly)
{ {
if(!valuesignedcalc()) //signed numbers if(!valuesignedcalc()) //signed numbers
sprintf(format_str, "%%s=%%.%d"fext"X (%%"fext"ud)\n", valsize); sprintf(format_str, "%%s=%%.%d"fext"X (%%"fext"ud)\n", valsize);
@ -207,7 +207,7 @@ CMDRESULT cbInstrMov(int argc, char* argv[])
valfromstring(argv[1], &temp, true, false, 0, &isvar, 0); valfromstring(argv[1], &temp, true, false, 0, &isvar, 0);
if(!isvar) if(!isvar)
isvar = vargettype(argv[1], 0); isvar = vargettype(argv[1], 0);
if(!isvar or !valtostring(argv[1], set_value, true)) if(!isvar || !valtostring(argv[1], set_value, true))
{ {
uint value; uint value;
if(valfromstring(argv[1], &value)) //if the var is a value already it's an invalid destination if(valfromstring(argv[1], &value)) //if the var is a value already it's an invalid destination
@ -464,7 +464,7 @@ CMDRESULT cbInstrFunctionAdd(int argc, char* argv[])
} }
uint start = 0; uint start = 0;
uint end = 0; uint end = 0;
if(!valfromstring(argv[1], &start, false) or !valfromstring(argv[2], &end, false)) if(!valfromstring(argv[1], &start, false) || !valfromstring(argv[2], &end, false))
return STATUS_ERROR; return STATUS_ERROR;
if(!FunctionAdd(start, end, true)) if(!FunctionAdd(start, end, true))
{ {
@ -887,10 +887,10 @@ CMDRESULT cbInstrRefFindRange(int argc, char* argv[])
VALUERANGE range; VALUERANGE range;
if(!valfromstring(argv[1], &range.start, false)) if(!valfromstring(argv[1], &range.start, false))
return STATUS_ERROR; return STATUS_ERROR;
if(argc < 3 or !valfromstring(argv[2], &range.end, false)) if(argc < 3 || !valfromstring(argv[2], &range.end, false))
range.end = range.start; range.end = range.start;
uint addr = 0; uint addr = 0;
if(argc < 4 or !valfromstring(argv[3], &addr)) if(argc < 4 || !valfromstring(argv[3], &addr))
addr = GetContextDataEx(hActiveThread, UE_CIP); addr = GetContextDataEx(hActiveThread, UE_CIP);
uint size = 0; uint size = 0;
if(argc >= 5) if(argc >= 5)
@ -932,7 +932,7 @@ bool cbRefStr(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refi
} }
if((basicinfo->type & TYPE_MEMORY) == TYPE_MEMORY) if((basicinfo->type & TYPE_MEMORY) == TYPE_MEMORY)
{ {
if(!found and disasmgetstringat(basicinfo->memory.value, &strtype, string, string, 500)) if(!found && disasmgetstringat(basicinfo->memory.value, &strtype, string, string, 500))
found = true; found = true;
} }
if(found) if(found)
@ -959,7 +959,7 @@ bool cbRefStr(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refi
CMDRESULT cbInstrRefStr(int argc, char* argv[]) CMDRESULT cbInstrRefStr(int argc, char* argv[])
{ {
uint addr; uint addr;
if(argc < 2 or !valfromstring(argv[1], &addr, true)) if(argc < 2 || !valfromstring(argv[1], &addr, true))
addr = GetContextDataEx(hActiveThread, UE_CIP); addr = GetContextDataEx(hActiveThread, UE_CIP);
uint size = 0; uint size = 0;
if(argc >= 3) if(argc >= 3)
@ -1015,7 +1015,7 @@ CMDRESULT cbInstrGetstr(int argc, char* argv[])
return STATUS_ERROR; return STATUS_ERROR;
} }
int size; int size;
if(!varget(argv[1], (char*)0, &size, 0) or !size) if(!varget(argv[1], (char*)0, &size, 0) || !size)
{ {
dprintf("failed to get variable size \"%s\"!\n", argv[1]); dprintf("failed to get variable size \"%s\"!\n", argv[1]);
return STATUS_ERROR; return STATUS_ERROR;
@ -1050,7 +1050,7 @@ CMDRESULT cbInstrCopystr(int argc, char* argv[])
return STATUS_ERROR; return STATUS_ERROR;
} }
int size; int size;
if(!varget(argv[2], (char*)0, &size, 0) or !size) if(!varget(argv[2], (char*)0, &size, 0) || !size)
{ {
dprintf("failed to get variable size \"%s\"!\n", argv[2]); dprintf("failed to get variable size \"%s\"!\n", argv[2]);
return STATUS_ERROR; return STATUS_ERROR;
@ -1276,7 +1276,7 @@ static bool cbModCallFind(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, R
CMDRESULT cbInstrModCallFind(int argc, char* argv[]) CMDRESULT cbInstrModCallFind(int argc, char* argv[])
{ {
uint addr; uint addr;
if(argc < 2 or !valfromstring(argv[1], &addr, true)) if(argc < 2 || !valfromstring(argv[1], &addr, true))
addr = GetContextDataEx(hActiveThread, UE_CIP); addr = GetContextDataEx(hActiveThread, UE_CIP);
uint size = 0; uint size = 0;
if(argc >= 3) if(argc >= 3)
@ -1532,7 +1532,7 @@ CMDRESULT cbInstrFindAsm(int argc, char* argv[])
} }
uint addr = 0; uint addr = 0;
if(argc < 3 or !valfromstring(argv[2], &addr)) if(argc < 3 || !valfromstring(argv[2], &addr))
addr = GetContextDataEx(hActiveThread, UE_CIP); addr = GetContextDataEx(hActiveThread, UE_CIP);
uint size = 0; uint size = 0;
if(argc >= 4) if(argc >= 4)

View File

@ -332,7 +332,7 @@ bool pluginunregistercallback(int pluginHandle, CBTYPE cbType)
int pluginCallbackCount = (int)pluginCallbackList.size(); int pluginCallbackCount = (int)pluginCallbackList.size();
for(int i = 0; i < pluginCallbackCount; i++) 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 && pluginCallbackList.at(i).cbType == cbType)
{ {
pluginCallbackList.erase(pluginCallbackList.begin() + i); pluginCallbackList.erase(pluginCallbackList.begin() + i);
return true; return true;
@ -370,7 +370,7 @@ void plugincbcall(CBTYPE cbType, void* callbackInfo)
*/ */
bool plugincmdregister(int pluginHandle, const char* command, CBPLUGINCOMMAND cbCommand, bool debugonly) bool plugincmdregister(int pluginHandle, const char* command, CBPLUGINCOMMAND cbCommand, bool debugonly)
{ {
if(!command or strlen(command) >= deflen or strstr(command, "\1")) if(!command || strlen(command) >= deflen || strstr(command, "\1"))
return false; return false;
PLUG_COMMAND plugCmd; PLUG_COMMAND plugCmd;
plugCmd.pluginHandle = pluginHandle; plugCmd.pluginHandle = pluginHandle;
@ -390,12 +390,12 @@ bool plugincmdregister(int pluginHandle, const char* command, CBPLUGINCOMMAND cb
*/ */
bool plugincmdunregister(int pluginHandle, const char* command) bool plugincmdunregister(int pluginHandle, const char* command)
{ {
if(!command or strlen(command) >= deflen or strstr(command, "\1")) if(!command || strlen(command) >= deflen || strstr(command, "\1"))
return false; return false;
int listsize = (int)pluginCommandList.size(); int listsize = (int)pluginCommandList.size();
for(int i = 0; i < listsize; i++) 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 && !strcmp(pluginCommandList.at(i).command, command))
{ {
if(!dbgcmddel(command)) if(!dbgcmddel(command))
return false; return false;
@ -415,12 +415,12 @@ bool plugincmdunregister(int pluginHandle, const char* command)
*/ */
int pluginmenuadd(int hMenu, const char* title) int pluginmenuadd(int hMenu, const char* title)
{ {
if(!title or !strlen(title)) if(!title || !strlen(title))
return -1; return -1;
int nFound = -1; int nFound = -1;
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 && pluginMenuList.at(i).hEntryPlugin == -1)
{ {
nFound = i; nFound = i;
break; break;
@ -446,7 +446,7 @@ int pluginmenuadd(int hMenu, const char* title)
*/ */
bool pluginmenuaddentry(int hMenu, int hEntry, const char* title) bool pluginmenuaddentry(int hMenu, int hEntry, const char* title)
{ {
if(!title || !strlen(title) or hEntry == -1) if(!title || !strlen(title) || hEntry == -1)
return false; return false;
int pluginHandle = -1; int pluginHandle = -1;
//find plugin handle //find plugin handle
@ -485,7 +485,7 @@ bool pluginmenuaddseparator(int hMenu)
bool bFound = false; bool bFound = false;
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 && pluginMenuList.at(i).hEntryPlugin == -1)
{ {
bFound = true; bFound = true;
break; break;
@ -507,7 +507,7 @@ bool pluginmenuclear(int hMenu)
bool bFound = false; bool bFound = false;
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 && pluginMenuList.at(i).hEntryPlugin == -1)
{ {
bFound = true; bFound = true;
break; break;
@ -585,7 +585,7 @@ void pluginmenuseticon(int hMenu, const ICONDATA* icon)
bool bFound = false; bool bFound = false;
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 && pluginMenuList.at(i).hEntryPlugin == -1)
{ {
GuiMenuSetIcon(hMenu, icon); GuiMenuSetIcon(hMenu, icon);
break; break;

View File

@ -31,19 +31,19 @@ static SCRIPTBRANCHTYPE scriptgetbranchtype(const char* text)
strcpy_s(newtext, StringUtils::Trim(text).c_str()); strcpy_s(newtext, StringUtils::Trim(text).c_str());
if(!strstr(newtext, " ")) if(!strstr(newtext, " "))
strcat(newtext, " "); strcat(newtext, " ");
if(!strncmp(newtext, "jmp ", 4) or !strncmp(newtext, "goto ", 5)) if(!strncmp(newtext, "jmp ", 4) || !strncmp(newtext, "goto ", 5))
return scriptjmp; return scriptjmp;
else if(!strncmp(newtext, "jbe ", 4) or !strncmp(newtext, "ifbe ", 5) or !strncmp(newtext, "ifbeq ", 6) or !strncmp(newtext, "jle ", 4) or !strncmp(newtext, "ifle ", 5) or !strncmp(newtext, "ifleq ", 6)) else if(!strncmp(newtext, "jbe ", 4) || !strncmp(newtext, "ifbe ", 5) || !strncmp(newtext, "ifbeq ", 6) || !strncmp(newtext, "jle ", 4) || !strncmp(newtext, "ifle ", 5) || !strncmp(newtext, "ifleq ", 6))
return scriptjbejle; return scriptjbejle;
else if(!strncmp(newtext, "jae ", 4) or !strncmp(newtext, "ifae ", 5) or !strncmp(newtext, "ifaeq ", 6) or !strncmp(newtext, "jge ", 4) or !strncmp(newtext, "ifge ", 5) or !strncmp(newtext, "ifgeq ", 6)) else if(!strncmp(newtext, "jae ", 4) || !strncmp(newtext, "ifae ", 5) || !strncmp(newtext, "ifaeq ", 6) || !strncmp(newtext, "jge ", 4) || !strncmp(newtext, "ifge ", 5) || !strncmp(newtext, "ifgeq ", 6))
return scriptjaejge; return scriptjaejge;
else if(!strncmp(newtext, "jne ", 4) or !strncmp(newtext, "ifne ", 5) or !strncmp(newtext, "ifneq ", 6) or !strncmp(newtext, "jnz ", 4) or !strncmp(newtext, "ifnz ", 5)) else if(!strncmp(newtext, "jne ", 4) || !strncmp(newtext, "ifne ", 5) || !strncmp(newtext, "ifneq ", 6) || !strncmp(newtext, "jnz ", 4) || !strncmp(newtext, "ifnz ", 5))
return scriptjnejnz; return scriptjnejnz;
else if(!strncmp(newtext, "je ", 3) or !strncmp(newtext, "ife ", 4) or !strncmp(newtext, "ifeq ", 5) or !strncmp(newtext, "jz ", 3) or !strncmp(newtext, "ifz ", 4)) else if(!strncmp(newtext, "je ", 3) || !strncmp(newtext, "ife ", 4) || !strncmp(newtext, "ifeq ", 5) || !strncmp(newtext, "jz ", 3) || !strncmp(newtext, "ifz ", 4))
return scriptjejz; return scriptjejz;
else if(!strncmp(newtext, "jb ", 3) or !strncmp(newtext, "ifb ", 4) or !strncmp(newtext, "jl ", 3) or !strncmp(newtext, "ifl ", 4)) else if(!strncmp(newtext, "jb ", 3) || !strncmp(newtext, "ifb ", 4) || !strncmp(newtext, "jl ", 3) || !strncmp(newtext, "ifl ", 4))
return scriptjbjl; return scriptjbjl;
else if(!strncmp(newtext, "ja ", 3) or !strncmp(newtext, "ifa ", 4) or !strncmp(newtext, "jg ", 3) or !strncmp(newtext, "ifg ", 4)) else if(!strncmp(newtext, "ja ", 3) || !strncmp(newtext, "ifa ", 4) || !strncmp(newtext, "jg ", 3) || !strncmp(newtext, "ifg ", 4))
return scriptjajg; return scriptjajg;
else if(!strncmp(newtext, "call ", 5)) else if(!strncmp(newtext, "call ", 5))
return scriptcall; return scriptcall;
@ -105,7 +105,7 @@ static bool scriptcreatelinemap(const char* filename)
std::vector<LINEMAPENTRY>().swap(linemap); 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' && filedata[i + 1] == '\n') //windows file
{ {
memset(&entry, 0, sizeof(entry)); memset(&entry, 0, sizeof(entry));
int add = 0; int add = 0;
@ -193,7 +193,7 @@ static bool scriptcreatelinemap(const char* filename)
char temp[256] = ""; char temp[256] = "";
strcpy_s(temp, cur.u.label + 2); strcpy_s(temp, cur.u.label + 2);
strcpy_s(cur.u.label, temp); //remove fake command strcpy_s(cur.u.label, temp); //remove fake command
if(!*cur.u.label or !strcmp(cur.u.label, "\"\"")) //no label text if(!*cur.u.label || !strcmp(cur.u.label, "\"\"")) //no label text
{ {
char message[256] = ""; char message[256] = "";
sprintf(message, "Empty label detected on line %d!", i + 1); sprintf(message, "Empty label detected on line %d!", i + 1);
@ -255,7 +255,7 @@ static bool scriptcreatelinemap(const char* filename)
currentLine.u.branch.dest = scriptinternalstep(labelline); currentLine.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 || linemap.at(linemapsize - 1).type == linelabel) //label/comment on the end
{ {
memset(&entry, 0, sizeof(entry)); memset(&entry, 0, sizeof(entry));
entry.type = linecommand; entry.type = linecommand;
@ -277,7 +277,7 @@ static bool scriptinternalbpget(int line) //internal bpget routine
static bool scriptinternalbptoggle(int line) //internal breakpoint static bool scriptinternalbptoggle(int line) //internal breakpoint
{ {
if(!line or line > (int)linemap.size()) //invalid line if(!line || line > (int)linemap.size()) //invalid line
return false; 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 if(scriptinternalbpget(line)) //remove breakpoint
@ -370,19 +370,19 @@ static bool scriptinternalbranch(SCRIPTBRANCHTYPE type) //determine if we should
bJump = true; bJump = true;
break; break;
case scriptjbjl: //$_BS_FLAG=0 and $_EZ_FLAG=0 //below, not equal case scriptjbjl: //$_BS_FLAG=0 and $_EZ_FLAG=0 //below, not equal
if(!bsflag and !ezflag) if(!bsflag && !ezflag)
bJump = true; bJump = true;
break; break;
case scriptjajg: //$_BS_FLAG=1 and $_EZ_FLAG=0 //above, not equal case scriptjajg: //$_BS_FLAG=1 and $_EZ_FLAG=0 //above, not equal
if(bsflag and !ezflag) if(bsflag && !ezflag)
bJump = true; bJump = true;
break; break;
case scriptjbejle: //$_BS_FLAG=0 or $_EZ_FLAG=1 case scriptjbejle: //$_BS_FLAG=0 or $_EZ_FLAG=1
if(!bsflag or ezflag) if(!bsflag || ezflag)
bJump = true; bJump = true;
break; break;
case scriptjaejge: //$_BS_FLAG=1 or $_EZ_FLAG=1 case scriptjaejge: //$_BS_FLAG=1 or $_EZ_FLAG=1
if(bsflag or ezflag) if(bsflag || ezflag)
bJump = true; bJump = true;
break; break;
default: default:
@ -431,7 +431,7 @@ static bool scriptinternalcmd()
static DWORD WINAPI scriptRunThread(void* arg) static DWORD WINAPI scriptRunThread(void* arg)
{ {
int destline = (int)(uint)arg; int destline = (int)(uint)arg;
if(!destline or destline > (int)linemap.size()) //invalid line if(!destline || destline > (int)linemap.size()) //invalid line
destline = 0; destline = 0;
if(destline) if(destline)
{ {
@ -532,7 +532,7 @@ void scriptstep()
bool scriptbptoggle(int line) bool scriptbptoggle(int line)
{ {
if(!line or line > (int)linemap.size()) //invalid line if(!line || line > (int)linemap.size()) //invalid line
return false; 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 if(scriptbpget(line)) //remove breakpoint
@ -622,7 +622,7 @@ void scriptreset()
bool scriptgetbranchinfo(int line, SCRIPTBRANCH* info) bool scriptgetbranchinfo(int line, SCRIPTBRANCH* info)
{ {
if(!info or !line or line > (int)linemap.size()) //invalid line if(!info || !line || line > (int)linemap.size()) //invalid line
return false; return false;
if(linemap.at(line - 1).type != linebranch) //no branch if(linemap.at(line - 1).type != linebranch) //no branch
return false; return false;

View File

@ -113,7 +113,7 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment)
void stackgetcallstack(uint csp, CALLSTACK* callstack) void stackgetcallstack(uint csp, CALLSTACK* callstack)
{ {
callstack->total = 0; callstack->total = 0;
if(!DbgIsDebugging() or csp % sizeof(uint)) //alignment problem if(!DbgIsDebugging() || csp % sizeof(uint)) //alignment problem
return; return;
if(!MemIsValidReadPtr(csp)) if(!MemIsValidReadPtr(csp))
return; return;

View File

@ -168,9 +168,9 @@ static bool isregister(const char* string)
return true; return true;
if(scmp(string, "dr3")) if(scmp(string, "dr3"))
return true; return true;
if(scmp(string, "dr6") or scmp(string, "dr4")) if(scmp(string, "dr6") || scmp(string, "dr4"))
return true; return true;
if(scmp(string, "dr7") or scmp(string, "dr5")) if(scmp(string, "dr7") || scmp(string, "dr5"))
return true; return true;
if(scmp(string, "cip")) if(scmp(string, "cip"))
@ -601,7 +601,7 @@ static bool setflag(const char* string, bool set)
flag = 0x100000; flag = 0x100000;
else if(scmp(string, "id")) else if(scmp(string, "id"))
flag = 0x200000; flag = 0x200000;
if(eflags & flag and !set) if(eflags & flag && !set)
xorval = flag; xorval = flag;
else if(set) else if(set)
xorval = flag; xorval = flag;
@ -843,11 +843,11 @@ static uint getregister(int* size, const char* string)
{ {
return GetContextDataEx(hActiveThread, UE_DR3); return GetContextDataEx(hActiveThread, UE_DR3);
} }
if(scmp(string, "dr6") or scmp(string, "dr4")) if(scmp(string, "dr6") || scmp(string, "dr4"))
{ {
return GetContextDataEx(hActiveThread, UE_DR6); return GetContextDataEx(hActiveThread, UE_DR6);
} }
if(scmp(string, "dr7") or scmp(string, "dr5")) if(scmp(string, "dr7") || scmp(string, "dr5"))
{ {
return GetContextDataEx(hActiveThread, UE_DR7); return GetContextDataEx(hActiveThread, UE_DR7);
} }
@ -1158,9 +1158,9 @@ bool setregister(const char* string, uint value)
return SetContextDataEx(hActiveThread, UE_DR2, value); return SetContextDataEx(hActiveThread, UE_DR2, value);
if(scmp(string, "dr3")) if(scmp(string, "dr3"))
return SetContextDataEx(hActiveThread, UE_DR3, value); return SetContextDataEx(hActiveThread, UE_DR3, value);
if(scmp(string, "dr6") or scmp(string, "dr4")) if(scmp(string, "dr6") || scmp(string, "dr4"))
return SetContextDataEx(hActiveThread, UE_DR6, value); return SetContextDataEx(hActiveThread, UE_DR6, value);
if(scmp(string, "dr7") or scmp(string, "dr5")) if(scmp(string, "dr7") || scmp(string, "dr5"))
return SetContextDataEx(hActiveThread, UE_DR7, value); return SetContextDataEx(hActiveThread, UE_DR7, value);
if(scmp(string, "cip")) if(scmp(string, "cip"))
@ -1274,7 +1274,7 @@ bool setregister(const char* string, uint value)
*/ */
bool valapifromstring(const char* name, uint* value, int* value_size, bool printall, bool silent, bool* hexonly) bool valapifromstring(const char* name, uint* value, int* value_size, bool printall, bool silent, bool* hexonly)
{ {
if(!value or !DbgIsDebugging()) if(!value || !DbgIsDebugging())
return false; return false;
//explicit API handling //explicit API handling
const char* apiname = strchr(name, ':'); //the ':' character cannot be in a path: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions const char* apiname = strchr(name, ':'); //the ':' character cannot be in a path: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions
@ -1329,9 +1329,9 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
addr = modbase + (addr - (uint)mod); //correct for loaded base addr = modbase + (addr - (uint)mod); //correct for loaded base
else //not found else //not found
{ {
if(scmp(apiname, "base") or scmp(apiname, "imagebase") or scmp(apiname, "header")) //get loaded base if(scmp(apiname, "base") || scmp(apiname, "imagebase") || scmp(apiname, "header")) //get loaded base
addr = modbase; addr = modbase;
else if(scmp(apiname, "entry") or scmp(apiname, "oep") or scmp(apiname, "ep")) //get entry point else if(scmp(apiname, "entry") || scmp(apiname, "oep") || scmp(apiname, "ep")) //get entry point
addr = modbase + GetPE32DataW(szModName, 0, UE_OEP); addr = modbase + GetPE32DataW(szModName, 0, UE_OEP);
else if(*apiname == '$') //RVA else if(*apiname == '$') //RVA
{ {
@ -1428,7 +1428,7 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
if(kernel32 != -1) //prioritize kernel32 exports if(kernel32 != -1) //prioritize kernel32 exports
{ {
*value = addrfound[kernel32]; *value = addrfound[kernel32];
if(!printall or silent) if(!printall || silent)
return true; return true;
for(int i = 0; i < found; i++) for(int i = 0; i < found; i++)
if(i != kernel32) if(i != kernel32)
@ -1437,7 +1437,7 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
else else
{ {
*value = *addrfound; *value = *addrfound;
if(!printall or silent) if(!printall || silent)
return true; return true;
for(int i = 1; i < found; i++) for(int i = 1; i < found; i++)
dprintf(fhex"\n", addrfound[i]); dprintf(fhex"\n", addrfound[i]);
@ -1452,7 +1452,7 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
*/ */
static bool isdecnumber(const char* string) static bool isdecnumber(const char* string)
{ {
if(*string != '.' or !string[1]) //dec indicator/no number if(*string != '.' || !string[1]) //dec indicator/no number
return false; return false;
int decAdd = 1; int decAdd = 1;
if(string[1] == '-') //minus if(string[1] == '-') //minus
@ -1476,7 +1476,7 @@ static bool isdecnumber(const char* string)
static bool ishexnumber(const char* string) static bool ishexnumber(const char* string)
{ {
int add = 0; int add = 0;
if(*string == '0' and string[1] == 'x') //0x prefix if(*string == '0' && string[1] == 'x') //0x prefix
add = 2; add = 2;
else if(*string == 'x') //hex indicator else if(*string == 'x') //hex indicator
add = 1; add = 1;
@ -1502,7 +1502,7 @@ static bool ishexnumber(const char* string)
*/ */
bool valfromstring_noexpr(const char* string, uint* value, bool silent, bool baseonly, int* value_size, bool* isvar, bool* hexonly) bool valfromstring_noexpr(const char* string, uint* value, bool silent, bool baseonly, int* value_size, bool* isvar, bool* hexonly)
{ {
if(!value or !string) if(!value || !string)
return false; return false;
if(!*string) if(!*string)
{ {
@ -1582,7 +1582,7 @@ bool valfromstring_noexpr(const char* string, uint* value, bool silent, bool bas
*isvar = true; *isvar = true;
return true; return true;
} }
else if(*string == '!' and isflag(string + 1)) //flag else if(*string == '!' && isflag(string + 1)) //flag
{ {
if(!DbgIsDebugging()) if(!DbgIsDebugging())
{ {
@ -1660,7 +1660,7 @@ bool valfromstring_noexpr(const char* string, uint* value, bool silent, bool bas
*/ */
bool valfromstring(const char* string, uint* value, bool silent, bool baseonly, int* value_size, bool* isvar, bool* hexonly) bool valfromstring(const char* string, uint* value, bool silent, bool baseonly, int* value_size, bool* isvar, bool* hexonly)
{ {
if(!value or !string) if(!value || !string)
return false; return false;
if(!*string) if(!*string)
{ {
@ -1744,7 +1744,7 @@ static void setfpuvalue(const char* string, uint value)
{ {
uint flags = GetContextDataEx(hActiveThread, UE_MXCSR); uint flags = GetContextDataEx(hActiveThread, UE_MXCSR);
flag = getmxcsrflagfromstring(string + STRLEN_USING_SIZEOF(MxCsr_PRE_FIELD_STRING)); flag = getmxcsrflagfromstring(string + STRLEN_USING_SIZEOF(MxCsr_PRE_FIELD_STRING));
if(flags & flag and !set) if(flags & flag && !set)
xorval = flag; xorval = flag;
else if(set) else if(set)
xorval = flag; xorval = flag;
@ -1792,7 +1792,7 @@ static void setfpuvalue(const char* string, uint value)
{ {
uint flags = GetContextDataEx(hActiveThread, UE_X87_STATUSWORD); uint flags = GetContextDataEx(hActiveThread, UE_X87_STATUSWORD);
flag = getx87statuswordflagfromstring(string + STRLEN_USING_SIZEOF(x87SW_PRE_FIELD_STRING)); flag = getx87statuswordflagfromstring(string + STRLEN_USING_SIZEOF(x87SW_PRE_FIELD_STRING));
if(flags & flag and !set) if(flags & flag && !set)
xorval = flag; xorval = flag;
else if(set) else if(set)
xorval = flag; xorval = flag;
@ -1825,7 +1825,7 @@ static void setfpuvalue(const char* string, uint value)
{ {
uint flags = GetContextDataEx(hActiveThread, UE_X87_CONTROLWORD); uint flags = GetContextDataEx(hActiveThread, UE_X87_CONTROLWORD);
flag = getx87controlwordflagfromstring(string + STRLEN_USING_SIZEOF(x87CW_PRE_FIELD_STRING)); flag = getx87controlwordflagfromstring(string + STRLEN_USING_SIZEOF(x87CW_PRE_FIELD_STRING));
if(flags & flag and !set) if(flags & flag && !set)
xorval = flag; xorval = flag;
else if(set) else if(set)
xorval = flag; xorval = flag;
@ -2109,7 +2109,7 @@ bool valtostring(const char* string, uint value, bool silent)
{ {
if(!*string) if(!*string)
return false; return false;
else if(*string == '@' or strstr(string, "[")) //memory location else if(*string == '@' || strstr(string, "[")) //memory location
{ {
if(!DbgIsDebugging()) if(!DbgIsDebugging())
{ {
@ -2125,7 +2125,7 @@ bool valtostring(const char* string, uint value, bool silent)
{ {
if(string[i] == ']') if(string[i] == ']')
j += sprintf(newstring + j, ")"); j += sprintf(newstring + j, ")");
else if(isdigit(string[i]) and string[i + 1] == ':' and string[i + 2] == '[') //n:[ else if(isdigit(string[i]) && string[i + 1] == ':' && string[i + 2] == '[') //n:[
{ {
j += sprintf(newstring + j, "@%c:(", string[i]); j += sprintf(newstring + j, "@%c:(", string[i]);
i += 2; i += 2;
@ -2140,7 +2140,7 @@ bool valtostring(const char* string, uint value, bool silent)
strcpy_s(newstring, len * 2, string); strcpy_s(newstring, len * 2, string);
int read_size = sizeof(uint); int read_size = sizeof(uint);
int add = 1; int add = 1;
if(newstring[2] == ':' and isdigit((newstring[1]))) if(newstring[2] == ':' && isdigit((newstring[1])))
{ {
add += 2; add += 2;
int new_size = newstring[1] - 0x30; int new_size = newstring[1] - 0x30;
@ -2200,7 +2200,7 @@ bool valtostring(const char* string, uint value, bool silent)
GuiUpdateAllViews(); //repaint gui GuiUpdateAllViews(); //repaint gui
return true; return true;
} }
else if(*string == '!' and isflag(string + 1)) //flag else if(*string == '!' && isflag(string + 1)) //flag
{ {
if(!DbgIsDebugging()) if(!DbgIsDebugging())
{ {

View File

@ -195,7 +195,7 @@ bool varget(const char* Name, uint* Value, int* Size, VAR_TYPE* Type)
VAR_VALUE varvalue; VAR_VALUE varvalue;
int varsize; int varsize;
VAR_TYPE vartype; VAR_TYPE vartype;
if(!varget(Name, &varvalue, &varsize, &vartype) or varvalue.type != VAR_UINT) if(!varget(Name, &varvalue, &varsize, &vartype) || varvalue.type != VAR_UINT)
return false; return false;
if(Size) if(Size)
*Size = varsize; *Size = varsize;
@ -219,7 +219,7 @@ bool varget(const char* Name, char* String, int* Size, VAR_TYPE* Type)
VAR_VALUE varvalue; VAR_VALUE varvalue;
int varsize; int varsize;
VAR_TYPE vartype; VAR_TYPE vartype;
if(!varget(Name, &varvalue, &varsize, &vartype) or varvalue.type != VAR_STRING) if(!varget(Name, &varvalue, &varsize, &vartype) || varvalue.type != VAR_STRING)
return false; return false;
if(Size) if(Size)
*Size = varsize; *Size = varsize;