1
0
Fork 0

DBG: fixed minor things (Nukem's code didn't trigger anythign in Coverity, yay!)

This commit is contained in:
Mr. eXoDia 2015-04-06 00:16:45 +02:00
parent e6658562ca
commit e38619b2b1
7 changed files with 45 additions and 25 deletions

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) //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) //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)
{
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)
{
if(a.first < b.first) //module depth is smaller
return true;

View File

@ -52,7 +52,7 @@ int BpGetList(std::vector<BREAKPOINT>* List)
}
}
return breakpoints.size();
return (int)breakpoints.size();
}
bool BpNew(uint Address, bool Enable, bool Singleshot, short OldBytes, BP_TYPE Type, DWORD TitanType, const char* Name)

View File

@ -366,7 +366,7 @@ CMDRESULT cmddirectexec(COMMAND* cmd_list, const char* cmd)
if(!cmd or !strlen(cmd))
return STATUS_ERROR;
char command[deflen] = "";
strcpy(command, StringUtils::Trim(cmd).c_str());
strcpy_s(command, StringUtils::Trim(cmd).c_str());
COMMAND* found = cmdfindmain(cmd_list, command);
if(!found or !found->cbCommand)
return STATUS_ERROR;

View File

@ -3,7 +3,7 @@
Command::Command(const String & command)
{
ParseState state = Default;
int len = command.length();
int len = (int)command.length();
for(int i = 0; i < len; i++)
{
char ch = command[i];
@ -91,7 +91,7 @@ const String Command::GetText()
const int Command::GetArgCount()
{
return _tokens.size() ? _tokens.size() - 1 : 0;
return _tokens.size() ? (int)_tokens.size() - 1 : 0;
}
const String Command::GetArg(int argnum)

View File

@ -409,7 +409,11 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
CMDRESULT cbDebugBplist(int argc, char* argv[])
{
BpEnumAll(cbBreakpointList);
if (!BpEnumAll(cbBreakpointList))
{
dputs("Something went wrong...");
return STATUS_ERROR;
}
return STATUS_CONTINUE;
}
@ -467,10 +471,12 @@ CMDRESULT cbDebugHide(int argc, char* argv[])
CMDRESULT cbDebugDisasm(int argc, char* argv[])
{
uint addr;
if(argc > 1)
if(!valfromstring(argv[1], &addr))
addr = GetContextDataEx(hActiveThread, UE_CIP);
uint addr = 0;
if (argc > 1)
{
if (!valfromstring(argv[1], &addr))
addr = GetContextDataEx(hActiveThread, UE_CIP);
}
if(!MemIsValidReadPtr(addr))
return STATUS_CONTINUE;
DebugUpdateGui(addr, false);
@ -1841,7 +1847,11 @@ CMDRESULT cbDebugLoadLib(int argc, char* argv[])
GetFullContextDataEx(LoadLibThread, &backupctx);
valfromstring("kernel32:LoadLibraryA", &LoadLibraryA, false);
if (!valfromstring("kernel32:LoadLibraryA", &LoadLibraryA, false))
{
dprintf("Error: couldn't get kernel32:LoadLibraryA");
return STATUS_ERROR;
}
// Arch specific asm code
#ifdef _WIN64

View File

@ -814,7 +814,7 @@ struct VALUERANGE
static bool cbRefFind(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
{
if(!disasm && !basicinfo) //initialize
if(!disasm || !basicinfo) //initialize
{
GuiReferenceInitialize(refinfo->name);
GuiReferenceAddColumn(2 * sizeof(uint), "Address");
@ -907,7 +907,7 @@ CMDRESULT cbInstrRefFindRange(int argc, char* argv[])
bool cbRefStr(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
{
if(!disasm && !basicinfo) //initialize
if(!disasm || !basicinfo) //initialize
{
GuiReferenceInitialize(refinfo->name);
GuiReferenceAddColumn(2 * sizeof(uint), "Address");
@ -1218,8 +1218,11 @@ CMDRESULT cbInstrFindAll(int argc, char* argv[])
k += sprintf(msg + k, "%.2X", printData[j]);
}
}
else
GuiGetDisassembly(result, msg);
else
{
if (!GuiGetDisassembly(result, msg))
strcpy_s(msg, "[Error disassembling]");
}
GuiReferenceSetCellContent(refCount, 1, msg);
result++;
refCount++;
@ -1232,7 +1235,7 @@ CMDRESULT cbInstrFindAll(int argc, char* argv[])
static bool cbModCallFind(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
{
if(!disasm && !basicinfo) //initialize
if(!disasm || !basicinfo) //initialize
{
GuiReferenceInitialize(refinfo->name);
GuiReferenceAddColumn(2 * sizeof(uint), "Address");
@ -1487,7 +1490,7 @@ CMDRESULT cbInstrSleep(int argc, char* argv[])
static bool cbFindAsm(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
{
if(!disasm && !basicinfo) //initialize
if(!disasm || !basicinfo) //initialize
{
GuiReferenceInitialize(refinfo->name);
GuiReferenceAddColumn(2 * sizeof(uint), "Address");
@ -1752,12 +1755,18 @@ CMDRESULT cbInstrYara(int argc, char* argv[])
else
dputs("error while getting the rules!");
}
else
dputs("errors in the rules file!");
else
{
fclose(rulesFile);
dputs("errors in the rules file!");
}
yr_compiler_destroy(yrCompiler);
}
else
dputs("yr_compiler_create failed!");
else
{
fclose(rulesFile);
dputs("yr_compiler_create failed!");
}
return bSuccess ? STATUS_CONTINUE : STATUS_ERROR;
}

View File

@ -102,7 +102,7 @@ void ThreadGetList(THREADLIST* List)
List->list[i].SuspendCount = ThreadGetSuspendCount(threadHandle);
List->list[i].Priority = ThreadGetPriority(threadHandle);
List->list[i].WaitReason = ThreadGetWaitReason(threadHandle);
List->list[i].LastError = ThreadGetLastError(List->list[i].BasicInfo.ThreadLocalBase);
List->list[i].LastError = ThreadGetLastError(List->list[i].BasicInfo.ThreadId);
}
}
@ -164,6 +164,7 @@ DWORD ThreadGetLastError(DWORD ThreadId)
SHARED_ACQUIRE(LockThreads);
TEB teb;
memset(&teb, 0, sizeof(TEB));
for(auto & entry : threadList)
{
if(entry.ThreadId != ThreadId)