1
0
Fork 0

DBG: fixed bugs found with Visual Studio static code analysis

This commit is contained in:
mrexodia 2016-10-02 14:19:26 +02:00
parent 7edf4616b3
commit fa50db9f6f
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
35 changed files with 165 additions and 161 deletions

View File

@ -154,8 +154,8 @@ static bool _getjit(char* jit, bool jit64)
}
else // if jit input == NULL: it returns false if there are not an OLD JIT STORED.
{
char oldjit[MAX_SETTING_SIZE] = "";
if(!BridgeSettingGet("JIT", "Old", (char*) & oldjit))
Memory<char*> oldjit(MAX_SETTING_SIZE + 1);
if(!BridgeSettingGet("JIT", "Old", oldjit()))
return false;
}

View File

@ -878,11 +878,11 @@ extern "C" DLL_EXPORT duint _dbg_sendmessage(DBGMSG type, void* param1, void* pa
else
assemblerEngine = AssemblerEngine::XEDParse;
char exceptionRange[MAX_SETTING_SIZE] = "";
Memory<char*> settingText(MAX_SETTING_SIZE + 1);
dbgclearignoredexceptions();
if(BridgeSettingGet("Exceptions", "IgnoreRange", exceptionRange))
if(BridgeSettingGet("Exceptions", "IgnoreRange", settingText()))
{
char* entry = strtok(exceptionRange, ",");
auto entry = strtok(settingText(), ",");
while(entry)
{
unsigned long start;
@ -894,15 +894,14 @@ extern "C" DLL_EXPORT duint _dbg_sendmessage(DBGMSG type, void* param1, void* pa
range.end = end;
dbgaddignoredexception(range);
}
entry = strtok(0, ",");
entry = strtok(nullptr, ",");
}
}
char cachePath[MAX_SETTING_SIZE];
if(BridgeSettingGet("Symbols", "CachePath", cachePath))
if(BridgeSettingGet("Symbols", "CachePath", settingText()))
{
// Trim the buffer to fit inside MAX_PATH
strncpy_s(szSymbolCachePath, cachePath, _TRUNCATE);
strncpy_s(szSymbolCachePath, settingText(), _TRUNCATE);
}
duint animateInterval;

View File

@ -321,7 +321,8 @@ bool ResolveShortcut(HWND hwnd, const wchar_t* szShortcutPath, char* szResolvedP
return SUCCEEDED(E_INVALIDARG);
//Initialize COM stuff
CoInitialize(NULL);
if(!SUCCEEDED(CoInitialize(NULL)))
return false;
//Get a pointer to the IShellLink interface.
IShellLink* psl = NULL;

View File

@ -98,7 +98,7 @@ bool FunctionPass::Analyse()
std::sort(funcs.begin(), funcs.end());
funcs.erase(std::unique(funcs.begin(), funcs.end()), funcs.end());
dprintf(QT_TRANSLATE_NOOP("DBG", "%u functions\n"), funcs.size());
dprintf(QT_TRANSLATE_NOOP("DBG", "%u functions\n"), DWORD(funcs.size()));
FunctionDelRange(m_VirtualStart, m_VirtualEnd - 1, false);
for(auto & func : funcs)

View File

@ -196,7 +196,7 @@ void AdvancedAnalysis::linearXrefPass()
}
}
dprintf("%u xrefs found in %ums!\n", mXrefs.size(), GetTickCount() - ticks);
dprintf("%d xrefs found in %ums!\n", int(mXrefs.size()), GetTickCount() - ticks);
}
void AdvancedAnalysis::findInvalidXrefs()
@ -300,8 +300,8 @@ void AdvancedAnalysis::writeDataXrefs()
else
{
memset(mEncMap + offset, (byte)enc_middle, size);
for(duint i = offset; i < offset + size; i += datasize)
mEncMap[i] = (byte)type;
for(duint j = offset; j < offset + size; j += datasize)
mEncMap[j] = (byte)type;
}
}
}

View File

@ -247,10 +247,10 @@ void ControlFlowAnalysis::BasicBlocks()
count++;
return true;
});
dprintf("%u functions from the exception directory...\n", count);
dprintf("%d functions from the exception directory...\n", count);
#endif // _WIN64
dprintf("%u basic blocks, %u function starts detected...\n", mBlocks.size(), mFunctionStarts.size());
dprintf("%d basic blocks, %d function starts detected...\n", int(mBlocks.size()), int(mFunctionStarts.size()));
}
void ControlFlowAnalysis::Functions()
@ -284,7 +284,7 @@ void ControlFlowAnalysis::Functions()
DebugBreak(); //this should not happen
}
auto delayedCount = int(delayedBlocks.size());
dprintf("%u/%u delayed blocks...\n", delayedCount, mBlocks.size());
dprintf("%d/%d delayed blocks...\n", delayedCount, int(mBlocks.size()));
auto resolved = 0;
for(auto & delayedBlock : delayedBlocks)
{
@ -310,7 +310,7 @@ void ControlFlowAnalysis::Functions()
block->function = function;
resolved++;
}
dprintf("%u/%u delayed blocks resolved (%u/%u still left, probably unreferenced functions)\n", resolved, delayedCount, delayedCount - resolved, mBlocks.size());
dprintf("%d/%d delayed blocks resolved (%d/%d still left, probably unreferenced functions)\n", resolved, delayedCount, delayedCount - resolved, int(mBlocks.size()));
auto unreferencedCount = 0;
for(const auto & block : mBlocks)
{
@ -322,8 +322,8 @@ void ControlFlowAnalysis::Functions()
}
found->second.insert(block.second.start);
}
dprintf("%u/%u unreferenced blocks\n", unreferencedCount, mBlocks.size());
dprintf("%u functions found!\n", mFunctions.size());
dprintf("%d/%u unreferenced blocks\n", unreferencedCount, DWORD(mBlocks.size()));
dprintf("%u functions found!\n", DWORD(mFunctions.size()));
}
void ControlFlowAnalysis::FunctionRanges()
@ -337,7 +337,7 @@ void ControlFlowAnalysis::FunctionRanges()
{
auto block = findBlock(blockstart);
if(!block)
DebugBreak(); //this shouldn't happen
__debugbreak(); //this shouldn't happen
if(block->end > end)
end = block->end;
}

View File

@ -75,7 +75,7 @@ void ExceptionDirectoryAnalysis::Analyse()
return true;
});
dprintf(QT_TRANSLATE_NOOP("DBG", "%u functions discovered!\n"), mFunctions.size());
dprintf(QT_TRANSLATE_NOOP("DBG", "%u functions discovered!\n"), DWORD(mFunctions.size()));
#else //x32
dputs(QT_TRANSLATE_NOOP("DBG", "This kind of analysis doesn't work on x32 executables...\n"));
#endif // _WIN64

View File

@ -13,7 +13,7 @@ void LinearAnalysis::Analyse()
auto ticks = GetTickCount();
populateReferences();
dprintf("%u called functions populated\n", mFunctions.size());
dprintf("%u called functions populated\n", DWORD(mFunctions.size()));
analyseFunctions();
dprintf("Analysis finished in %ums!\n", GetTickCount() - ticks);

View File

@ -35,7 +35,7 @@ void XrefsAnalysis::Analyse()
mXrefs.push_back(xref);
}
dprintf("%u xrefs found in %ums!\n", mXrefs.size(), GetTickCount() - ticks);
dprintf("%u xrefs found in %ums!\n", DWORD(mXrefs.size()), GetTickCount() - ticks);
}
void XrefsAnalysis::SetMarkers()

View File

@ -48,6 +48,16 @@ COMMAND* cmdfind(const char* name, COMMAND** link)
return 0;
}
bool IsArgumentsLessThan(int argc, int minimumCount)
{
if(argc < minimumCount)
{
dprintf(QT_TRANSLATE_NOOP("DBG", "Not enough arguments! At least %d arguments must be specified.\n"), minimumCount - 1);
return true;
}
return false;
}
/**
\brief Initialize a command list.
\return a ::COMMAND*

View File

@ -4,16 +4,7 @@
#include "_global.h"
#include "console.h"
inline bool IsArgumentsLessThan(int argc, int minimumCount)
{
if(argc < minimumCount)
{
dprintf(QT_TRANSLATE_NOOP("DBG", "Not enough arguments! At least %d arguments must be specified.\n"), minimumCount - 1);
return true;
}
else
return false;
}
bool IsArgumentsLessThan(int argc, int minimumCount);
//typedefs

View File

@ -153,12 +153,12 @@ CMDRESULT cbInstrVirtualmod(int argc, char* argv[])
CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[])
{
dputs(QT_TRANSLATE_NOOP("DBG", "This may take very long, depending on your network connection and data in the debug directory..."));
char szDefaultStore[MAX_SETTING_SIZE] = "";
const char* szSymbolStore = szDefaultStore;
if(!BridgeSettingGet("Symbols", "DefaultStore", szDefaultStore)) //get default symbol store from settings
Memory<char*> szDefaultStore(MAX_SETTING_SIZE + 1);
const char* szSymbolStore = szDefaultStore();
if(!BridgeSettingGet("Symbols", "DefaultStore", szDefaultStore())) //get default symbol store from settings
{
strcpy_s(szDefaultStore, "http://msdl.microsoft.com/download/symbols");
BridgeSettingSet("Symbols", "DefaultStore", szDefaultStore);
strcpy_s(szDefaultStore(), MAX_SETTING_SIZE, "http://msdl.microsoft.com/download/symbols");
BridgeSettingSet("Symbols", "DefaultStore", szDefaultStore());
}
if(argc < 2) //no arguments
{
@ -269,7 +269,7 @@ CMDRESULT cbInstrImageinfo(int argc, char* argv[])
dprintf(QT_TRANSLATE_NOOP("DBG", "Image information for %s\n"), modname);
dprintf(QT_TRANSLATE_NOOP("DBG", "Characteristics (0x%X):\n"), c);
dprintf(QT_TRANSLATE_NOOP("DBG", "Characteristics (0x%X):\n"), DWORD(c));
if(!c)
dputs(QT_TRANSLATE_NOOP("DBG", " None\n"));
pFlag(c, IMAGE_FILE_RELOCS_STRIPPED, QT_TRANSLATE_NOOP("DBG", "IMAGE_FILE_RELOCS_STRIPPED: Relocation info stripped from file."));
@ -288,7 +288,7 @@ CMDRESULT cbInstrImageinfo(int argc, char* argv[])
pFlag(c, IMAGE_FILE_UP_SYSTEM_ONLY, QT_TRANSLATE_NOOP("DBG", "IMAGE_FILE_UP_SYSTEM_ONLY: File should only be run on a UP machine"));
pFlag(c, IMAGE_FILE_BYTES_REVERSED_HI, QT_TRANSLATE_NOOP("DBG", "IMAGE_FILE_BYTES_REVERSED_HI: Bytes of machine word are reversed."));
dprintf(QT_TRANSLATE_NOOP("DBG", "DLL Characteristics (0x%X):\n"), dllc);
dprintf(QT_TRANSLATE_NOOP("DBG", "DLL Characteristics (0x%X):\n"), DWORD(dllc));
if(!dllc)
dputs(QT_TRANSLATE_NOOP("DBG", " None\n"));
pFlag(dllc, IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE, QT_TRANSLATE_NOOP("DBG", "IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE: DLL can move."));
@ -417,15 +417,15 @@ CMDRESULT cbInstrExinfo(int argc, char* argv[])
dprintf(" ExceptionAddress: %p %s\n", record.ExceptionAddress, symbolic.c_str());
else
dprintf(" ExceptionAddress: %p\n", record.ExceptionAddress);
dprintf(" NumberParameters: %d\n", record.NumberParameters);
dprintf(" NumberParameters: %u\n", record.NumberParameters);
if(record.NumberParameters)
for(DWORD i = 0; i < record.NumberParameters; i++)
{
symbolic = SymGetSymbolicName(duint(record.ExceptionInformation[i]));
if(symbolic.length())
dprintf("ExceptionInformation[%02d]: %p %s\n", i, record.ExceptionInformation[i], symbolic.c_str());
dprintf("ExceptionInformation[%02u]: %p %s\n", i, record.ExceptionInformation[i], symbolic.c_str());
else
dprintf("ExceptionInformation[%02d]: %p\n", i, record.ExceptionInformation[i]);
dprintf("ExceptionInformation[%02u]: %p\n", i, record.ExceptionInformation[i]);
}
return STATUS_CONTINUE;
}

View File

@ -438,7 +438,7 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
}
if((addr % size) != 0)
{
dprintf(QT_TRANSLATE_NOOP("DBG", "Address not aligned to %d\n"), size);
dprintf(QT_TRANSLATE_NOOP("DBG", "Address not aligned to %d\n"), int(size));
return STATUS_ERROR;
}
}
@ -1155,7 +1155,7 @@ CMDRESULT cbDebugSetExceptionBPX(int argc, char* argv[])
const String & ExceptionName = ExceptionCodeToName((unsigned int)ExceptionCode);
if(BpGet(ExceptionCode, BPEXCEPTION, nullptr, nullptr))
{
dprintf(QT_TRANSLATE_NOOP("DBG", "Exception breakpoint %X(%s) already exists!\n"), ExceptionCode, ExceptionName.c_str());
dprintf(QT_TRANSLATE_NOOP("DBG", "Exception breakpoint %X (%s) already exists!\n"), DWORD(ExceptionCode), ExceptionName.c_str());
return STATUS_ERROR;
}
duint chance = 1;

View File

@ -81,7 +81,7 @@ static CMDRESULT cbDebugSetBPXFastResumeCommon(BP_TYPE Type, int argc, char* arg
}
if(!BpSetFastResume(bp.addr, Type, fastResume))
{
dprintf(QT_TRANSLATE_NOOP("DBG", "Can't set fast resume on breakpoint \"%1\"\n"), argv[1]);
dprintf(QT_TRANSLATE_NOOP("DBG", "Can't set fast resume on breakpoint \"%s\"\n"), argv[1]);
return STATUS_ERROR;
}
DebugUpdateBreakpointsViewAsync();
@ -111,7 +111,7 @@ static CMDRESULT cbDebugSetBPXSingleshootCommon(BP_TYPE Type, int argc, char* ar
}
if(!BpSetSingleshoot(bp.addr, Type, singleshoot))
{
dprintf(QT_TRANSLATE_NOOP("DBG", "Can't set singleshoot on breakpoint \"%1\"\n"), argv[1]);
dprintf(QT_TRANSLATE_NOOP("DBG", "Can't set singleshoot on breakpoint \"%s\"\n"), argv[1]);
return STATUS_ERROR;
}
DebugUpdateBreakpointsViewAsync();
@ -141,7 +141,7 @@ static CMDRESULT cbDebugSetBPXSilentCommon(BP_TYPE Type, int argc, char* argv[])
}
if(!BpSetSilent(bp.addr, Type, silent))
{
dprintf(QT_TRANSLATE_NOOP("DBG", "Can't set silent on breakpoint \"%1\"\n"), argv[1]);
dprintf(QT_TRANSLATE_NOOP("DBG", "Can't set silent on breakpoint \"%s\"\n"), argv[1]);
return STATUS_ERROR;
}
DebugUpdateBreakpointsViewAsync();

View File

@ -153,7 +153,7 @@ CMDRESULT cbDebugAttach(int argc, char* argv[])
Handle hProcess = TitanOpenProcess(PROCESS_ALL_ACCESS, false, (DWORD)pid);
if(!hProcess)
{
dprintf(QT_TRANSLATE_NOOP("DBG", "Could not open process %X!\n"), pid);
dprintf(QT_TRANSLATE_NOOP("DBG", "Could not open process %X!\n"), DWORD(pid));
return STATUS_ERROR;
}
BOOL wow64 = false, mewow64 = false;
@ -174,7 +174,7 @@ CMDRESULT cbDebugAttach(int argc, char* argv[])
wchar_t wszFileName[MAX_PATH] = L"";
if(!GetModuleFileNameExW(hProcess, 0, wszFileName, MAX_PATH))
{
dprintf(QT_TRANSLATE_NOOP("DBG", "Could not get module filename %X!\n"), pid);
dprintf(QT_TRANSLATE_NOOP("DBG", "Could not get module filename %X!\n"), DWORD(pid));
return STATUS_ERROR;
}
strcpy_s(szFileName, StringUtils::Utf16ToUtf8(wszFileName).c_str());

View File

@ -116,7 +116,7 @@ CMDRESULT cbInstrBswap(int argc, char* argv[])
{
if(IsArgumentsLessThan(argc, 2))
return STATUS_ERROR;
return ReadWriteVariable(argv[1], [argv](duint * value, int size)
return ReadWriteVariable(argv[1], [](duint * value, int size)
{
if(size == 2)
*value = _byteswap_ushort((uint16) * value);

View File

@ -8,11 +8,14 @@
CMDRESULT cbDebugAlloc(int argc, char* argv[])
{
duint size = 0x1000;
duint size = 0x1000, addr = 0;
if(argc > 1)
if(!valfromstring(argv[1], &size, false))
return STATUS_ERROR;
duint mem = (duint)MemAllocRemote(0, size);
if(argc > 2)
if(!valfromstring(argv[2], &addr, false))
return STATUS_ERROR;
duint mem = (duint)MemAllocRemote(addr, size);
if(!mem)
dputs(QT_TRANSLATE_NOOP("DBG", "VirtualAllocEx failed"));
else
@ -88,7 +91,7 @@ CMDRESULT cbDebugMemset(int argc, char* argv[])
if(!Fill((void*)addr, size & 0xFFFFFFFF, &fi))
dputs(QT_TRANSLATE_NOOP("DBG", "Memset failed"));
else
dprintf(QT_TRANSLATE_NOOP("DBG", "Memory %p (size: %.8X) set to %.2X\n"), addr, size & 0xFFFFFFFF, value & 0xFF);
dprintf(QT_TRANSLATE_NOOP("DBG", "Memory %p (size: %.8X) set to %.2X\n"), addr, DWORD(size & 0xFFFFFFFF), BYTE(value & 0xFF));
return STATUS_CONTINUE;
}

View File

@ -106,28 +106,28 @@ CMDRESULT cbDebugLoadLib(int argc, char* argv[])
// Arch specific asm code
#ifdef _WIN64
sprintf_s(command, "mov rcx, %p", (duint)DLLNameMem);
sprintf_s(command, "mov rcx, %p", DLLNameMem);
#else
sprintf_s(command, "push %p", DLLNameMem);
#endif // _WIN64
assembleat((duint)ASMAddr, command, &size, error, true);
assembleat(ASMAddr, command, &size, error, true);
counter += size;
#ifdef _WIN64
sprintf_s(command, "mov rax, %p", LoadLibraryA);
assembleat((duint)ASMAddr + counter, command, &size, error, true);
assembleat(ASMAddr + counter, command, &size, error, true);
counter += size;
sprintf_s(command, "call rax");
#else
sprintf_s(command, "call %p", LoadLibraryA);
#endif // _WIN64
assembleat((duint)ASMAddr + counter, command, &size, error, true);
assembleat(ASMAddr + counter, command, &size, error, true);
counter += size;
SetContextDataEx(LoadLibThread, UE_CIP, (duint)ASMAddr);
auto ok = SetBPX((duint)ASMAddr + counter, UE_SINGLESHOOT | UE_BREAKPOINT_TYPE_INT3, (void*)cbDebugLoadLibBPX);
SetContextDataEx(LoadLibThread, UE_CIP, ASMAddr);
auto ok = SetBPX(ASMAddr + counter, UE_SINGLESHOOT | UE_BREAKPOINT_TYPE_INT3, (void*)cbDebugLoadLibBPX);
ThreadSuspendAll();
ResumeThread(LoadLibThread);
@ -188,7 +188,7 @@ CMDRESULT cbDebugSetJIT(int argc, char* argv[])
{
arch actual_arch = invalid;
char* jit_debugger_cmd = "";
char oldjit[MAX_SETTING_SIZE] = "";
Memory<char*> oldjit(MAX_SETTING_SIZE + 1);
char path[JIT_ENTRY_DEF_SIZE];
if(!IsProcessElevated())
{
@ -210,7 +210,7 @@ CMDRESULT cbDebugSetJIT(int argc, char* argv[])
{
if(!_strcmpi(argv[1], "old"))
{
jit_debugger_cmd = oldjit;
jit_debugger_cmd = oldjit();
if(!BridgeSettingGet("JIT", "Old", jit_debugger_cmd))
{
dputs(QT_TRANSLATE_NOOP("DBG", "Error there is no old JIT entry stored."));
@ -234,7 +234,7 @@ CMDRESULT cbDebugSetJIT(int argc, char* argv[])
get_last_jit = false;
}
else
strcpy_s(oldjit, get_entry);
strcpy_s(oldjit(), MAX_SETTING_SIZE, get_entry);
jit_debugger_cmd = path;
if(!dbgsetjit(jit_debugger_cmd, notfound, &actual_arch, NULL))
@ -244,13 +244,13 @@ CMDRESULT cbDebugSetJIT(int argc, char* argv[])
}
if(get_last_jit)
{
if(_stricmp(oldjit, path))
BridgeSettingSet("JIT", "Old", oldjit);
if(_stricmp(oldjit(), path))
BridgeSettingSet("JIT", "Old", oldjit());
}
}
else if(!_strcmpi(argv[1], "restore"))
{
jit_debugger_cmd = oldjit;
jit_debugger_cmd = oldjit();
if(!BridgeSettingGet("JIT", "Old", jit_debugger_cmd))
{
@ -335,17 +335,17 @@ CMDRESULT cbDebugGetJIT(int argc, char* argv[])
else
{
readwritejitkey_error_t rw_error;
char oldjit[MAX_SETTING_SIZE] = "";
Memory<char*> oldjit(MAX_SETTING_SIZE + 1);
if(_strcmpi(argv[1], "OLD") == 0)
{
if(!BridgeSettingGet("JIT", "Old", oldjit))
if(!BridgeSettingGet("JIT", "Old", oldjit()))
{
dputs(QT_TRANSLATE_NOOP("DBG", "Error: there is not an OLD JIT entry stored yet."));
return STATUS_ERROR;
}
else
{
dprintf(QT_TRANSLATE_NOOP("DBG", "OLD JIT entry stored: %s\n"), oldjit);
dprintf(QT_TRANSLATE_NOOP("DBG", "OLD JIT entry stored: %s\n"), oldjit());
return STATUS_CONTINUE;
}
}

View File

@ -84,7 +84,7 @@ CMDRESULT cbHandleClose(int argc, char* argv[])
duint handle;
if(!valfromstring(argv[1], &handle, false))
return STATUS_ERROR;
if(!DuplicateHandle(fdProcessInfo->hProcess, HANDLE(handle), NULL, NULL, 0, FALSE, DUPLICATE_CLOSE_SOURCE))
if(!handle || !DuplicateHandle(fdProcessInfo->hProcess, HANDLE(handle), NULL, NULL, 0, FALSE, DUPLICATE_CLOSE_SOURCE))
{
dprintf(QT_TRANSLATE_NOOP("DBG", "DuplicateHandle failed: %s\n"), ErrorCodeToName(GetLastError()).c_str());
return STATUS_ERROR;

View File

@ -15,7 +15,6 @@ static DWORD WINAPI scyllaThread(void* lpParam)
{
dputs(QT_TRANSLATE_NOOP("DBG", "Error loading Scylla.dll!"));
bScyllaLoaded = false;
FreeLibrary(hScylla);
return 0;
}
ScyllaStartGui = (SCYLLASTARTGUI)GetProcAddress(hScylla, "ScyllaStartGui");

View File

@ -143,7 +143,7 @@ CMDRESULT cbInstrFindAll(int argc, char* argv[])
i += foundoffset + 1;
result = addr + i - 1;
char msg[deflen] = "";
sprintf(msg, "%p", result);
sprintf_s(msg, "%p", result);
GuiReferenceSetRowCount(refCount + 1);
GuiReferenceSetCellContent(refCount, 0, msg);
if(findData)
@ -247,7 +247,7 @@ CMDRESULT cbInstrFindAllMem(int argc, char* argv[])
for(duint result : results)
{
char msg[deflen] = "";
sprintf(msg, "%p", result);
sprintf_s(msg, "%p", result);
GuiReferenceSetRowCount(refCount + 1);
GuiReferenceSetCellContent(refCount, 0, msg);
if(findData)
@ -293,7 +293,7 @@ static bool cbFindAsm(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFIN
if(found)
{
char addrText[20] = "";
sprintf(addrText, "%p", disasm->Address());
sprintf_s(addrText, "%p", disasm->Address());
GuiReferenceSetRowCount(refinfo->refcount + 1);
GuiReferenceSetCellContent(refinfo->refcount, 0, addrText);
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";
@ -339,7 +339,7 @@ CMDRESULT cbInstrFindAsm(int argc, char* argv[])
char title[256] = "";
sprintf_s(title, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Command: \"%s\"")), basicinfo.instruction);
int found = RefFind(addr, size, cbFindAsm, (void*)&basicinfo.instruction[0], false, title, (REFFINDTYPE)refFindType, true);
dprintf(QT_TRANSLATE_NOOP("DBG", "%u result(s) in %ums\n"), found, GetTickCount() - ticks);
dprintf(QT_TRANSLATE_NOOP("DBG", "%u result(s) in %ums\n"), DWORD(found), GetTickCount() - DWORD(ticks));
varset("$result", found, false);
return STATUS_CONTINUE;
}
@ -400,7 +400,7 @@ static bool cbRefFind(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFIN
if(found)
{
char addrText[20] = "";
sprintf(addrText, "%p", disasm->Address());
sprintf_s(addrText, "%p", disasm->Address());
GuiReferenceSetRowCount(refinfo->refcount + 1);
GuiReferenceSetCellContent(refinfo->refcount, 0, addrText);
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";
@ -441,7 +441,7 @@ CMDRESULT cbInstrRefFindRange(int argc, char* argv[])
refFindType = CURRENT_REGION;
int found = RefFind(addr, size, cbRefFind, &range, false, title, (REFFINDTYPE)refFindType, false);
dprintf(QT_TRANSLATE_NOOP("DBG", "%u reference(s) in %ums\n"), found, GetTickCount() - ticks);
dprintf(QT_TRANSLATE_NOOP("DBG", "%u reference(s) in %ums\n"), DWORD(found), GetTickCount() - DWORD(ticks));
varset("$result", found, false);
return STATUS_CONTINUE;
}
@ -476,7 +476,7 @@ static bool cbRefStr(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINF
if(found)
{
char addrText[20] = "";
sprintf(addrText, "%p", disasm->Address());
sprintf_s(addrText, "%p", disasm->Address());
GuiReferenceSetRowCount(refinfo->refcount + 1);
GuiReferenceSetCellContent(refinfo->refcount, 0, addrText);
char disassembly[4096] = "";
@ -510,7 +510,7 @@ CMDRESULT cbInstrRefStr(int argc, char* argv[])
TranslatedString = GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Strings"));
int found = RefFind(addr, size, cbRefStr, 0, false, TranslatedString.c_str(), (REFFINDTYPE)refFindType, false);
dprintf(QT_TRANSLATE_NOOP("DBG", "%u string(s) in %ums\n"), found, GetTickCount() - ticks);
dprintf(QT_TRANSLATE_NOOP("DBG", "%u string(s) in %ums\n"), DWORD(found), GetTickCount() - DWORD(ticks));
varset("$result", found, false);
return STATUS_CONTINUE;
}
@ -539,7 +539,7 @@ static bool cbModCallFind(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, R
{
char addrText[20] = "";
char moduleTargetText[256] = "";
sprintf(addrText, "%p", disasm->Address());
sprintf_s(addrText, "%p", disasm->Address());
sprintf(moduleTargetText, "%s.%s", module, label);
GuiReferenceSetRowCount(refinfo->refcount + 1);
GuiReferenceSetCellContent(refinfo->refcount, 0, addrText);
@ -576,7 +576,7 @@ CMDRESULT cbInstrModCallFind(int argc, char* argv[])
duint ticks = GetTickCount();
String Calls = GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Calls"));
int found = RefFind(addr, size, cbModCallFind, 0, false, Calls.c_str(), (REFFINDTYPE)refFindType, false);
dprintf(QT_TRANSLATE_NOOP("DBG", "%u call(s) in %ums\n"), found, GetTickCount() - ticks);
dprintf(QT_TRANSLATE_NOOP("DBG", "%u call(s) in %ums\n"), DWORD(found), GetTickCount() - DWORD(ticks));
varset("$result", found, false);
return STATUS_CONTINUE;
}
@ -657,7 +657,7 @@ static int yaraScanCallback(int message, void* message_data, void* user_data)
scanInfo->index++;
char addr_text[deflen] = "";
sprintf(addr_text, "%p", addr);
sprintf_s(addr_text, "%p", addr);
GuiReferenceSetCellContent(index, 0, addr_text); //Address
String ruleFullName = "";
ruleFullName += yrRule->identifier;
@ -790,7 +790,7 @@ CMDRESULT cbInstrYara(int argc, char* argv[])
memcpy(data(), rawFileData.data(), size);
else if(!MemRead(base, data(), size))
{
dprintf(QT_TRANSLATE_NOOP("DBG", "failed to read memory page %p[%X]!\n"), base, size);
dprintf(QT_TRANSLATE_NOOP("DBG", "failed to read memory page %p[%X]!\n"), base, DWORD(size));
return STATUS_ERROR;
}
@ -838,7 +838,7 @@ CMDRESULT cbInstrYara(int argc, char* argv[])
switch(err)
{
case ERROR_SUCCESS:
dprintf(QT_TRANSLATE_NOOP("DBG", "%u scan results in %ums...\n"), scanInfo.index, GetTickCount() - ticks);
dprintf(QT_TRANSLATE_NOOP("DBG", "%u scan results in %ums...\n"), DWORD(scanInfo.index), GetTickCount() - DWORD(ticks));
bSuccess = true;
break;
case ERROR_TOO_MANY_MATCHES:

View File

@ -52,7 +52,7 @@ CMDRESULT cbDebugSwitchthread(int argc, char* argv[])
return STATUS_ERROR;
if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid
{
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), threadid);
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), DWORD(threadid));
return STATUS_ERROR;
}
//switch thread
@ -74,7 +74,7 @@ CMDRESULT cbDebugSuspendthread(int argc, char* argv[])
return STATUS_ERROR;
if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid
{
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), threadid);
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), DWORD(threadid));
return STATUS_ERROR;
}
//suspend thread
@ -96,7 +96,7 @@ CMDRESULT cbDebugResumethread(int argc, char* argv[])
return STATUS_ERROR;
if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid
{
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), threadid);
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), DWORD(threadid));
return STATUS_ERROR;
}
//resume thread
@ -122,7 +122,7 @@ CMDRESULT cbDebugKillthread(int argc, char* argv[])
return STATUS_ERROR;
if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid
{
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), threadid);
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), DWORD(threadid));
return STATUS_ERROR;
}
//terminate thread
@ -204,7 +204,7 @@ CMDRESULT cbDebugSetPriority(int argc, char* argv[])
}
if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid
{
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), threadid);
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), DWORD(threadid));
return STATUS_ERROR;
}
//set thread priority
@ -231,13 +231,13 @@ CMDRESULT cbDebugSetthreadname(int argc, char* argv[])
THREADINFO info;
if(!ThreadGetInfo(DWORD(threadid), info))
{
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), threadid);
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid thread %X\n"), DWORD(threadid));
return STATUS_ERROR;
}
auto newname = argc > 2 ? argv[2] : "";
if(!ThreadSetName(DWORD(threadid), newname))
{
dprintf(QT_TRANSLATE_NOOP("DBG", "Failed to change the name for thread %X\n"), threadid);
dprintf(QT_TRANSLATE_NOOP("DBG", "Failed to change the name for thread %X\n"), DWORD(threadid));
return STATUS_ERROR;
}
if(!*info.threadName)

View File

@ -4,6 +4,7 @@
#include "value.h"
#include "types.h"
#include "memory.h"
#include "variable.h"
using namespace Types;
@ -314,6 +315,7 @@ CMDRESULT cbInstrSizeofType(int argc, char* argv[])
return STATUS_ERROR;
}
dprintf_untranslated("sizeof(%s) = %d\n", argv[1], size);
varset("$result", size, false);
return STATUS_CONTINUE;
}

View File

@ -229,9 +229,9 @@ CMDRESULT cbInstrLoopList(int argc, char* argv[])
{
GuiReferenceSetRowCount(i + 1);
char addrText[20] = "";
sprintf(addrText, "%p", loops()[i].start);
sprintf_s(addrText, "%p", loops()[i].start);
GuiReferenceSetCellContent(i, 0, addrText);
sprintf(addrText, "%p", loops()[i].end);
sprintf_s(addrText, "%p", loops()[i].end);
GuiReferenceSetCellContent(i, 1, addrText);
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";
if(GuiGetDisassembly(loops()[i].start, disassembly))

View File

@ -84,7 +84,7 @@ CMDRESULT cbInstrCommentList(int argc, char* argv[])
{
GuiReferenceSetRowCount(i + 1);
char addrText[20] = "";
sprintf(addrText, "%p", comments()[i].addr);
sprintf_s(addrText, "%p", comments()[i].addr);
GuiReferenceSetCellContent(i, 0, addrText);
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";
if(GuiGetDisassembly(comments()[i].addr, disassembly))
@ -159,7 +159,7 @@ CMDRESULT cbInstrLabelList(int argc, char* argv[])
{
GuiReferenceSetRowCount(i + 1);
char addrText[20] = "";
sprintf(addrText, "%p", labels()[i].addr);
sprintf_s(addrText, "%p", labels()[i].addr);
GuiReferenceSetCellContent(i, 0, addrText);
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";
if(GuiGetDisassembly(labels()[i].addr, disassembly))
@ -235,7 +235,7 @@ CMDRESULT cbInstrBookmarkList(int argc, char* argv[])
{
GuiReferenceSetRowCount(i + 1);
char addrText[20] = "";
sprintf(addrText, "%p", bookmarks()[i].addr);
sprintf_s(addrText, "%p", bookmarks()[i].addr);
GuiReferenceSetCellContent(i, 0, addrText);
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";
if(GuiGetDisassembly(bookmarks()[i].addr, disassembly))
@ -323,9 +323,9 @@ CMDRESULT cbInstrFunctionList(int argc, char* argv[])
{
GuiReferenceSetRowCount(i + 1);
char addrText[20] = "";
sprintf(addrText, "%p", functions()[i].start);
sprintf_s(addrText, "%p", functions()[i].start);
GuiReferenceSetCellContent(i, 0, addrText);
sprintf(addrText, "%p", functions()[i].end);
sprintf_s(addrText, "%p", functions()[i].end);
GuiReferenceSetCellContent(i, 1, addrText);
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";
if(GuiGetDisassembly(functions()[i].start, disassembly))
@ -413,9 +413,9 @@ CMDRESULT cbInstrArgumentList(int argc, char* argv[])
{
GuiReferenceSetRowCount(i + 1);
char addrText[20] = "";
sprintf(addrText, "%p", arguments()[i].start);
sprintf_s(addrText, "%p", arguments()[i].start);
GuiReferenceSetCellContent(i, 0, addrText);
sprintf(addrText, "%p", arguments()[i].end);
sprintf_s(addrText, "%p", arguments()[i].end);
GuiReferenceSetCellContent(i, 1, addrText);
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";
if(GuiGetDisassembly(arguments()[i].start, disassembly))

View File

@ -6,7 +6,7 @@
#include "console.h"
#include "taskthread.h"
static void GuiAddLogMessageAsync(const char* msg)
static void GuiAddLogMessageAsync(_In_z_ const char* msg)
{
static StringConcatTaskThread_<void(*)(const std::string &)> task([](const std::string & msg)
{
@ -19,7 +19,7 @@ static void GuiAddLogMessageAsync(const char* msg)
\brief Print a line with text, terminated with a newline to the console.
\param text The text to print.
*/
void dputs(const char* Text)
void dputs(_In_z_ const char* Text)
{
// Only append the newline if the caller didn't
const char* TranslatedText = GuiTranslateText(Text);
@ -40,7 +40,7 @@ void dputs(const char* Text)
\brief Print a formatted string to the console.
\param format The printf format to use (see documentation of printf for more information).
*/
void dprintf(const char* Format, ...)
void dprintf(_In_z_ _Printf_format_string_ const char* Format, ...)
{
va_list args;
@ -49,7 +49,7 @@ void dprintf(const char* Format, ...)
va_end(args);
}
void dprintf_untranslated(const char* Format, ...)
void dprintf_untranslated(_In_z_ _Printf_format_string_ const char* Format, ...)
{
va_list args;
@ -63,7 +63,7 @@ void dprintf_untranslated(const char* Format, ...)
\param format The printf format to use (see documentation of printf for more information).
\param Args The argument buffer passed to the string parser.
*/
void dprintf_args(const char* Format, va_list Args)
void dprintf_args(_In_z_ _Printf_format_string_ const char* Format, va_list Args)
{
char buffer[16384];
vsnprintf_s(buffer, _TRUNCATE, GuiTranslateText(Format), Args);
@ -75,7 +75,7 @@ void dprintf_args(const char* Format, va_list Args)
\brief Print a line with text, terminated with a newline to the console.
\param text The text to print.
*/
void dputs_untranslated(const char* Text)
void dputs_untranslated(_In_z_ const char* Text)
{
// Only append the newline if the caller didn't
size_t textlen = strlen(Text);
@ -95,7 +95,7 @@ void dputs_untranslated(const char* Text)
\param format The printf format to use (see documentation of printf for more information).
\param Args The argument buffer passed to the string parser.
*/
void dprintf_args_untranslated(const char* Format, va_list Args)
void dprintf_args_untranslated(_In_z_ _Printf_format_string_ const char* Format, va_list Args)
{
char buffer[16384];
vsnprintf_s(buffer, _TRUNCATE, Format, Args);

View File

@ -3,11 +3,11 @@
#include "_global.h"
void dputs(const char* Text);
void dprintf(const char* Format, ...);
void dprintf_args(const char* Format, va_list Args);
void dputs_untranslated(const char* Text);
void dprintf_untranslated(const char* Format, ...);
void dprintf_args_untranslated(const char* Format, va_list Args);
void dputs(_In_z_ const char* Text);
void dprintf(_In_z_ _Printf_format_string_ const char* Format, ...);
void dprintf_args(_In_z_ _Printf_format_string_ const char* Format, va_list Args);
void dputs_untranslated(_In_z_ const char* Text);
void dprintf_untranslated(_In_z_ _Printf_format_string_ const char* Format, ...);
void dprintf_args_untranslated(_In_z_ _Printf_format_string_ const char* Format, va_list Args);
#endif // _CONSOLE_H

View File

@ -380,7 +380,7 @@ void DebugUpdateGui(duint disasm_addr, bool stack)
duint csp = GetContextDataEx(hActiveThread, UE_CSP);
if(stack)
DebugUpdateStack(csp, csp);
static duint cacheCsp = 0;
static volatile duint cacheCsp = 0;
if(csp != cacheCsp)
{
InterlockedExchange(&cacheCsp, csp);
@ -849,10 +849,8 @@ void cbLibrarianBreakpoint(void* lpData)
bBreakOnNextDll = true;
}
static BOOL CALLBACK SymRegisterCallbackProc64(HANDLE hProcess, ULONG ActionCode, ULONG64 CallbackData, ULONG64 UserContext)
static BOOL CALLBACK SymRegisterCallbackProc64(HANDLE, ULONG ActionCode, ULONG64 CallbackData, ULONG64)
{
UNREFERENCED_PARAMETER(hProcess);
UNREFERENCED_PARAMETER(UserContext);
PIMAGEHLP_CBA_EVENT evt;
switch(ActionCode)
{
@ -1221,7 +1219,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo)
TLSGrabCallBackDataW(StringUtils::Utf8ToUtf16(DebugFileName).c_str(), 0, &NumberOfCallBacks);
if(NumberOfCallBacks)
{
dprintf(QT_TRANSLATE_NOOP("DBG", "TLS Callbacks: %d\n"), NumberOfCallBacks);
dprintf(QT_TRANSLATE_NOOP("DBG", "TLS Callbacks: %d\n"), int(NumberOfCallBacks));
Memory<duint*> TLSCallBacks(NumberOfCallBacks * sizeof(duint), "cbCreateProcess:TLSCallBacks");
if(!TLSGrabCallBackDataW(StringUtils::Utf8ToUtf16(DebugFileName).c_str(), TLSCallBacks(), &NumberOfCallBacks))
dputs(QT_TRANSLATE_NOOP("DBG", "Failed to get TLS callback addresses!"));
@ -1390,10 +1388,10 @@ static void cbExitThread(EXIT_THREAD_DEBUG_INFO* ExitThread)
static DWORD WINAPI cbInitializationScriptThread(void*)
{
char script[MAX_SETTING_SIZE];
if(BridgeSettingGet("Engine", "InitializeScript", script)) // Global script file
Memory<char*> script(MAX_SETTING_SIZE + 1);
if(BridgeSettingGet("Engine", "InitializeScript", script())) // Global script file
{
if(scriptLoadSync(script) == 0)
if(scriptLoadSync(script()) == 0)
scriptRunSync((void*)0);
else
dputs(QT_TRANSLATE_NOOP("DBG", "Error: Cannot load global initialization script."));
@ -1494,7 +1492,7 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll)
TLSGrabCallBackDataW(StringUtils::Utf8ToUtf16(DLLDebugFileName).c_str(), 0, &NumberOfCallBacks);
if(NumberOfCallBacks)
{
dprintf(QT_TRANSLATE_NOOP("DBG", "TLS Callbacks: %d\n"), NumberOfCallBacks);
dprintf(QT_TRANSLATE_NOOP("DBG", "TLS Callbacks: %d\n"), int(NumberOfCallBacks));
Memory<duint*> TLSCallBacks(NumberOfCallBacks * sizeof(duint), "cbLoadDll:TLSCallBacks");
if(!TLSGrabCallBackDataW(StringUtils::Utf8ToUtf16(DLLDebugFileName).c_str(), TLSCallBacks(), &NumberOfCallBacks))
dputs(QT_TRANSLATE_NOOP("DBG", "Failed to get TLS callback addresses!"));
@ -2422,7 +2420,7 @@ static void debugLoopFunction(void* lpParameter, bool attach)
if(AttachDebugger(pid, true, fdProcessInfo, (void*)cbAttachDebugger) == false)
{
unsigned int errorCode = GetLastError();
dprintf(QT_TRANSLATE_NOOP("DBG", "Attach to process failed! GetLastError() = %d (%s)\n"), errorCode, ErrorCodeToName(errorCode).c_str());
dprintf(QT_TRANSLATE_NOOP("DBG", "Attach to process failed! GetLastError() = %d (%s)\n"), int(errorCode), ErrorCodeToName(errorCode).c_str());
}
}
else
@ -2437,7 +2435,6 @@ static void debugLoopFunction(void* lpParameter, bool attach)
plugincbcall(CB_STOPDEBUG, &stopInfo);
//cleanup dbghelp
SafeSymRegisterCallbackW64(hProcess, nullptr, 0);
SafeSymCleanup(hProcess);
//message the user/do final stuff

View File

@ -19,6 +19,7 @@ duint disasmback(unsigned char* data, duint base, duint size, duint ip, int n)
{
int i;
duint abuf[131], addr, back, cmdsize;
memset(abuf, 0, sizeof(abuf));
unsigned char* pdata;
// Reset Disasm Structure

View File

@ -339,7 +339,7 @@ bool MemRead(duint BaseAddress, void* Buffer, duint Size, duint* NumberOfBytesRe
bool MemReadUnsafe(duint BaseAddress, void* Buffer, duint Size, duint* NumberOfBytesRead)
{
SIZE_T read;
SIZE_T read = 0;
auto result = !!ReadProcessMemory(fdProcessInfo->hProcess, LPCVOID(BaseAddress), Buffer, Size, &read);
if(NumberOfBytesRead)
*NumberOfBytesRead = read;

View File

@ -106,7 +106,7 @@ int RefFind(duint Address, duint Size, CBREF Callback, void* UserData, bool Sile
GuiReferenceSetProgress(percent);
}, disasmText);
}
else if(type == ALL_MODULES) // Search in all Modules
else if(type == ALL_MODULES) // Search in all Modules
{
bool initCallBack = true;
std::vector<MODINFO> modList;
@ -134,7 +134,7 @@ int RefFind(duint Address, duint Size, CBREF Callback, void* UserData, bool Sile
for(duint i = 0; i < modList.size(); i++)
{
scanStart = modList[i].base;
scanSize = modList[i].size;
scanSize = modList[i].size;
if(i != 0)
initCallBack = false;
@ -154,6 +154,8 @@ int RefFind(duint Address, duint Size, CBREF Callback, void* UserData, bool Sile
}, disasmText);
}
}
else
return 0;
GuiReferenceSetProgress(100);
GuiReferenceReloadData();

View File

@ -175,7 +175,6 @@ static bool scriptcreatelinemap(const char* filename)
cur.type = linelabel;
sprintf(cur.u.label, "l %.*s", rawlen - 1, cur.raw); //create a fake command for formatting
strcpy_s(cur.u.label, StringUtils::Trim(cur.u.label).c_str());
char temp[256] = "";
strcpy_s(temp, cur.u.label + 2);
strcpy_s(cur.u.label, temp); //remove fake command
if(!*cur.u.label || !strcmp(cur.u.label, "\"\"")) //no label text
@ -202,11 +201,11 @@ static bool scriptcreatelinemap(const char* filename)
cur.u.branch.type = scriptgetbranchtype(cur.raw);
char newraw[MAX_SCRIPT_LINE_SIZE] = "";
strcpy_s(newraw, StringUtils::Trim(cur.raw).c_str());
int len = (int)strlen(newraw);
for(int i = 0; i < len; i++)
if(newraw[i] == ' ')
int rlen = (int)strlen(newraw);
for(int j = 0; j < rlen; j++)
if(newraw[j] == ' ')
{
strcpy_s(cur.u.branch.branchlabel, newraw + i + 1);
strcpy_s(cur.u.branch.branchlabel, newraw + j + 1);
break;
}
}

View File

@ -82,7 +82,7 @@ bool stackcommentget(duint addr, STACK_COMMENT* comment)
if(*module)
sprintf(returnToAddr, "%s.", module);
if(!*label)
sprintf(label, "%p", data);
sprintf_s(label, "%p", data);
strcat(returnToAddr, label);
data = basicinfo.addr;
@ -96,9 +96,9 @@ bool stackcommentget(duint addr, STACK_COMMENT* comment)
ModNameFromAddr(data, module, false);
char returnFromAddr[MAX_COMMENT_SIZE] = "";
if(*module)
sprintf(returnFromAddr, "%s.", module);
sprintf_s(returnFromAddr, "%s.", module);
if(!*label)
sprintf(label, "%p", data);
sprintf_s(label, "%p", data);
strcat_s(returnFromAddr, label);
sprintf_s(comment->comment, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "return to %s from %s")), returnToAddr, returnFromAddr);
}
@ -128,14 +128,14 @@ bool stackcommentget(duint addr, STACK_COMMENT* comment)
if(*module) //module
{
if(*label) //+label
sprintf(comment->comment, "%s.%s", module, label);
sprintf_s(comment->comment, "%s.%s", module, label);
else //module only
sprintf(comment->comment, "%s.%p", module, data);
sprintf_s(comment->comment, "%s.%p", module, data);
return true;
}
else if(*label) //label only
{
sprintf(comment->comment, "<%s>", label);
sprintf_s(comment->comment, "<%s>", label);
return true;
}

View File

@ -1320,7 +1320,7 @@ bool valapifromstring(const char* name, duint* value, int* value_size, bool prin
if(!mod)
{
if(!silent)
dprintf(QT_TRANSLATE_NOOP("DBG", "unable to load library %s\n"), szModName);
dprintf(QT_TRANSLATE_NOOP("DBG", "unable to load library %s\n"), StringUtils::Utf16ToUtf8(szModName).c_str());
}
else
{
@ -1820,9 +1820,9 @@ static void setfpuvalue(const char* string, duint value)
if(startsWith(MxCsr_PRE_FIELD_STRING, string))
{
if(StrNCmpI(string + STRLEN_USING_SIZEOF(MxCsr_PRE_FIELD_STRING), "RC", (int) strlen("RC")) == 0)
if(_strnicmp(string + STRLEN_USING_SIZEOF(MxCsr_PRE_FIELD_STRING), "RC", (int)strlen("RC")) == 0)
{
duint flags = GetContextDataEx(hActiveThread, UE_MXCSR);
flags = GetContextDataEx(hActiveThread, UE_MXCSR);
int i = 3;
i <<= 13;
flags &= ~i;
@ -1832,7 +1832,7 @@ static void setfpuvalue(const char* string, duint value)
}
else
{
duint flags = GetContextDataEx(hActiveThread, UE_MXCSR);
flags = GetContextDataEx(hActiveThread, UE_MXCSR);
flag = getmxcsrflagfromstring(string + STRLEN_USING_SIZEOF(MxCsr_PRE_FIELD_STRING));
if(flags & flag && !set)
xorval = flag;
@ -1868,9 +1868,9 @@ static void setfpuvalue(const char* string, duint value)
}
else if(startsWith(x87SW_PRE_FIELD_STRING, string))
{
if(StrNCmpI(string + STRLEN_USING_SIZEOF(x87SW_PRE_FIELD_STRING), "TOP", (int) strlen("TOP")) == 0)
if(_strnicmp(string + STRLEN_USING_SIZEOF(x87SW_PRE_FIELD_STRING), "TOP", (int)strlen("TOP")) == 0)
{
duint flags = GetContextDataEx(hActiveThread, UE_X87_STATUSWORD);
flags = GetContextDataEx(hActiveThread, UE_X87_STATUSWORD);
int i = 7;
i <<= 11;
flags &= ~i;
@ -1880,7 +1880,7 @@ static void setfpuvalue(const char* string, duint value)
}
else
{
duint flags = GetContextDataEx(hActiveThread, UE_X87_STATUSWORD);
flags = GetContextDataEx(hActiveThread, UE_X87_STATUSWORD);
flag = getx87statuswordflagfromstring(string + STRLEN_USING_SIZEOF(x87SW_PRE_FIELD_STRING));
if(flags & flag && !set)
xorval = flag;
@ -1891,9 +1891,9 @@ static void setfpuvalue(const char* string, duint value)
}
else if(startsWith(x87CW_PRE_FIELD_STRING, string))
{
if(StrNCmpI(string + STRLEN_USING_SIZEOF(x87CW_PRE_FIELD_STRING), "RC", (int) strlen("RC")) == 0)
if(_strnicmp(string + STRLEN_USING_SIZEOF(x87CW_PRE_FIELD_STRING), "RC", (int)strlen("RC")) == 0)
{
duint flags = GetContextDataEx(hActiveThread, UE_X87_CONTROLWORD);
flags = GetContextDataEx(hActiveThread, UE_X87_CONTROLWORD);
int i = 3;
i <<= 10;
flags &= ~i;
@ -1901,9 +1901,9 @@ static void setfpuvalue(const char* string, duint value)
flags |= value;
SetContextDataEx(hActiveThread, UE_X87_CONTROLWORD, flags);
}
else if(StrNCmpI(string + STRLEN_USING_SIZEOF(x87CW_PRE_FIELD_STRING), "PC", (int) strlen("PC")) == 0)
else if(_strnicmp(string + STRLEN_USING_SIZEOF(x87CW_PRE_FIELD_STRING), "PC", (int)strlen("PC")) == 0)
{
duint flags = GetContextDataEx(hActiveThread, UE_X87_CONTROLWORD);
flags = GetContextDataEx(hActiveThread, UE_X87_CONTROLWORD);
int i = 3;
i <<= 8;
flags &= ~i;
@ -1913,7 +1913,7 @@ static void setfpuvalue(const char* string, duint value)
}
else
{
duint flags = GetContextDataEx(hActiveThread, UE_X87_CONTROLWORD);
flags = GetContextDataEx(hActiveThread, UE_X87_CONTROLWORD);
flag = getx87controlwordflagfromstring(string + STRLEN_USING_SIZEOF(x87CW_PRE_FIELD_STRING));
if(flags & flag && !set)
xorval = flag;
@ -1922,19 +1922,19 @@ static void setfpuvalue(const char* string, duint value)
SetContextDataEx(hActiveThread, UE_X87_CONTROLWORD, flags ^ xorval);
}
}
else if(StrNCmpI(string, "x87TagWord", (int) strlen(string)) == 0)
else if(_strnicmp(string, "x87TagWord", (int)strlen(string)) == 0)
{
SetContextDataEx(hActiveThread, UE_X87_TAGWORD, (unsigned short) value);
}
else if(StrNCmpI(string, "x87StatusWord", (int) strlen(string)) == 0)
else if(_strnicmp(string, "x87StatusWord", (int)strlen(string)) == 0)
{
SetContextDataEx(hActiveThread, UE_X87_STATUSWORD, (unsigned short) value);
}
else if(StrNCmpI(string, "x87ControlWord", (int) strlen(string)) == 0)
else if(_strnicmp(string, "x87ControlWord", (int)strlen(string)) == 0)
{
SetContextDataEx(hActiveThread, UE_X87_CONTROLWORD, (unsigned short) value);
}
else if(StrNCmpI(string, "MxCsr", (int) strlen(string)) == 0)
else if(_strnicmp(string, "MxCsr", (int)strlen(string)) == 0)
{
SetContextDataEx(hActiveThread, UE_MXCSR, value);
}

View File

@ -41,7 +41,7 @@ static CMDRESULT cbStrLen(int argc, char* argv[])
dputs(QT_TRANSLATE_NOOP("DBG", "not enough arguments!"));
return STATUS_ERROR;
}
dprintf_untranslated("\"%s\"[%d]\n", argv[1], strlen(argv[1]));
dprintf_untranslated("\"%s\"[%d]\n", argv[1], int(strlen(argv[1])));
return STATUS_CONTINUE;
}
@ -627,23 +627,23 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
strcpy_s(szLocalSymbolPath, szProgramDir);
strcat_s(szLocalSymbolPath, "\\symbols");
char cachePath[MAX_SETTING_SIZE];
if(!BridgeSettingGet("Symbols", "CachePath", cachePath) || !*cachePath)
Memory<char*> cachePath(MAX_SETTING_SIZE + 1);
if(!BridgeSettingGet("Symbols", "CachePath", cachePath()) || !*cachePath())
{
strcpy_s(szSymbolCachePath, szLocalSymbolPath);
BridgeSettingSet("Symbols", "CachePath", ".\\symbols");
}
else
{
if(_strnicmp(cachePath, ".\\", 2) == 0)
if(_strnicmp(cachePath(), ".\\", 2) == 0)
{
strncpy_s(szSymbolCachePath, szProgramDir, _TRUNCATE);
strncat_s(szSymbolCachePath, cachePath + 1, _TRUNCATE);
strncat_s(szSymbolCachePath, cachePath() + 1, _TRUNCATE);
}
else
{
// Trim the buffer to fit inside MAX_PATH
strncpy_s(szSymbolCachePath, cachePath, _TRUNCATE);
strncpy_s(szSymbolCachePath, cachePath(), _TRUNCATE);
}
if(strstr(szSymbolCachePath, "http://") || strstr(szSymbolCachePath, "https://"))