PROJECT: fixed various bugs (thanks to Coverity!)
This commit is contained in:
parent
b1ca7db063
commit
1a13962806
|
@ -68,7 +68,7 @@ bool TraceRecordManager::setTraceRecordType(duint pageAddress, TraceRecordType t
|
|||
auto inserted = TraceRecord.insert(std::make_pair(ModHashFromAddr(pageAddress), newPage));
|
||||
if(inserted.second == false) // we failed to insert new page into the map
|
||||
{
|
||||
free(newPage.rawPtr);
|
||||
efree(newPage.rawPtr);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -2249,14 +2249,14 @@ CMDRESULT cbDebugLoadLib(int argc, char* argv[])
|
|||
counter += size;
|
||||
|
||||
SetContextDataEx(LoadLibThread, UE_CIP, (duint)ASMAddr);
|
||||
SetBPX((duint)ASMAddr + counter, UE_SINGLESHOOT | UE_BREAKPOINT_TYPE_INT3, (void*)cbDebugLoadLibBPX);
|
||||
auto ok = SetBPX((duint)ASMAddr + counter, UE_SINGLESHOOT | UE_BREAKPOINT_TYPE_INT3, (void*)cbDebugLoadLibBPX);
|
||||
|
||||
ThreadSuspendAll();
|
||||
ResumeThread(LoadLibThread);
|
||||
|
||||
unlock(WAITID_RUN);
|
||||
|
||||
return STATUS_CONTINUE;
|
||||
return ok ? STATUS_CONTINUE : STATUS_ERROR;
|
||||
}
|
||||
|
||||
void cbDebugLoadLibBPX()
|
||||
|
|
|
@ -190,7 +190,11 @@ CMDRESULT cbInstrMov(int argc, char* argv[])
|
|||
b[0] = dataText[i];
|
||||
b[1] = dataText[i + 1];
|
||||
int res = 0;
|
||||
sscanf_s(b, "%X", &res);
|
||||
if(sscanf_s(b, "%X", &res) != 1)
|
||||
{
|
||||
dprintf("invalid hex byte \"%s\"\n", b);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
data()[j] = res;
|
||||
}
|
||||
//Move data to destination
|
||||
|
@ -212,7 +216,7 @@ CMDRESULT cbInstrMov(int argc, char* argv[])
|
|||
}
|
||||
bool isvar = false;
|
||||
duint temp = 0;
|
||||
valfromstring(argv[1], &temp, true, false, 0, &isvar, 0);
|
||||
valfromstring(argv[1], &temp, true, false, 0, &isvar, 0); //there is no return check on this because the destination might not exist yet
|
||||
if(!isvar)
|
||||
isvar = vargettype(argv[1], 0);
|
||||
if(!isvar || !valtostring(argv[1], set_value, true))
|
||||
|
|
|
@ -387,7 +387,7 @@ bool ModAddImportToModule(duint Base, const MODIMPORTINFO & importInfo)
|
|||
|
||||
// Search in Import Vector
|
||||
auto pImports = &(module->imports);
|
||||
auto it = std::find_if(pImports->begin(), pImports->end(), [importInfo](const MODIMPORTINFO & currentImportInfo)->bool
|
||||
auto it = std::find_if(pImports->begin(), pImports->end(), [&importInfo](const MODIMPORTINFO & currentImportInfo)->bool
|
||||
{
|
||||
return (importInfo.addr == currentImportInfo.addr);
|
||||
});
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "variable.h"
|
||||
#include "x64_dbg.h"
|
||||
#include "debugger.h"
|
||||
#include "filehelper.h"
|
||||
|
||||
static std::vector<LINEMAPENTRY> linemap;
|
||||
|
||||
|
@ -74,34 +75,20 @@ static int scriptinternalstep(int fromIp) //internal step routine
|
|||
|
||||
static bool scriptcreatelinemap(const char* filename)
|
||||
{
|
||||
Handle hFile = CreateFileW(StringUtils::Utf8ToUtf16(filename).c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
|
||||
if(hFile == INVALID_HANDLE_VALUE)
|
||||
String filedata;
|
||||
if(FileHelper::ReadAllText(filename, filedata))
|
||||
{
|
||||
GuiScriptError(0, "CreateFile failed...");
|
||||
GuiScriptError(0, "FileHelper::ReadAllText failed...");
|
||||
return false;
|
||||
}
|
||||
unsigned int filesize = GetFileSize(hFile, 0);
|
||||
if(!filesize)
|
||||
{
|
||||
GuiScriptError(0, "Empty script...");
|
||||
return false;
|
||||
}
|
||||
Memory<char*> filedata(filesize + 1, "createlinemap:filedata");
|
||||
DWORD read = 0;
|
||||
if(!ReadFile(hFile, filedata(), filesize, &read, 0))
|
||||
{
|
||||
GuiScriptError(0, "ReadFile failed...");
|
||||
return false;
|
||||
}
|
||||
hFile.Close();
|
||||
int len = (int)strlen(filedata());
|
||||
auto len = filedata.length();
|
||||
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(size_t i = 0, j = 0; i < len; i++) //make raw line map
|
||||
{
|
||||
if(filedata()[i] == '\r' && filedata()[i + 1] == '\n') //windows file
|
||||
if(filedata[i] == '\r' && filedata[i + 1] == '\n') //windows file
|
||||
{
|
||||
memset(&entry, 0, sizeof(entry));
|
||||
int add = 0;
|
||||
|
@ -113,7 +100,7 @@ static bool scriptcreatelinemap(const char* filename)
|
|||
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;
|
||||
|
@ -136,7 +123,7 @@ static bool scriptcreatelinemap(const char* filename)
|
|||
linemap.push_back(entry);
|
||||
}
|
||||
else
|
||||
j += sprintf(temp + j, "%c", filedata()[i]);
|
||||
j += sprintf(temp + j, "%c", filedata[i]);
|
||||
}
|
||||
if(*temp)
|
||||
{
|
||||
|
|
|
@ -44,7 +44,6 @@ protected:
|
|||
|
||||
private:
|
||||
QCheckBox* mRegexCheckbox;
|
||||
QWidget* mListPlaceHolder;
|
||||
QAction* mSearchAction;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#include "CommandLineEdit.h"
|
||||
#include "Bridge.h"
|
||||
|
||||
CommandLineEdit::CommandLineEdit(QWidget* parent) : HistoryLineEdit(parent)
|
||||
CommandLineEdit::CommandLineEdit(QWidget* parent)
|
||||
: HistoryLineEdit(parent),
|
||||
mCurrentScriptIndex(-1)
|
||||
{
|
||||
// QComboBox
|
||||
mCmdScriptType = new QComboBox(this);
|
||||
|
@ -77,6 +79,8 @@ bool CommandLineEdit::focusNextPrevChild(bool next)
|
|||
|
||||
void CommandLineEdit::execute()
|
||||
{
|
||||
if(mCurrentScriptIndex == -1)
|
||||
return;
|
||||
GUISCRIPTEXECUTE exec = mScriptInfo[mCurrentScriptIndex].execute;
|
||||
const QString & cmd = text();
|
||||
|
||||
|
@ -99,6 +103,8 @@ QWidget* CommandLineEdit::selectorWidget()
|
|||
|
||||
void CommandLineEdit::autoCompleteUpdate(const QString text)
|
||||
{
|
||||
if(mCurrentScriptIndex == -1)
|
||||
return;
|
||||
// No command, no completer
|
||||
if(text.length() <= 0)
|
||||
{
|
||||
|
|
|
@ -643,7 +643,7 @@ void PatchDialog::on_btnExport_clicked()
|
|||
// TODO: C program source
|
||||
}
|
||||
|
||||
void PatchDialog::saveAs1337(const QString &filename)
|
||||
void PatchDialog::saveAs1337(const QString & filename)
|
||||
{
|
||||
QStringList lines;
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ static HRESULT AddDesktopShortcut(TCHAR* szPathOfFile, const TCHAR* szNameOfLink
|
|||
|
||||
//Get the working directory
|
||||
TCHAR pathFile[MAX_PATH + 1];
|
||||
_tcscpy(pathFile, szPathOfFile);
|
||||
_tcscpy_s(pathFile, szPathOfFile);
|
||||
PathRemoveFileSpec(pathFile);
|
||||
|
||||
CComPtr<IShellLink> psl;
|
||||
|
|
Loading…
Reference in New Issue