diff --git a/hyperdbg/include/SDK/imports/user/HyperDbgScriptImports.h b/hyperdbg/include/SDK/imports/user/HyperDbgScriptImports.h index d943040a..29f188fc 100644 --- a/hyperdbg/include/SDK/imports/user/HyperDbgScriptImports.h +++ b/hyperdbg/include/SDK/imports/user/HyperDbgScriptImports.h @@ -98,7 +98,7 @@ IMPORT_EXPORT_HYPERDBG_SCRIPT_ENGINE BOOLEAN ScriptEngineCreateSymbolTableForDisassembler(void * CallbackFunction); IMPORT_EXPORT_HYPERDBG_SCRIPT_ENGINE BOOLEAN -ScriptEngineConvertFileToPdbPath(const char * LocalFilePath, char * ResultPath); +ScriptEngineConvertFileToPdbPath(const char * LocalFilePath, char * ResultPath, size_t ResultPathSize); IMPORT_EXPORT_HYPERDBG_SCRIPT_ENGINE BOOLEAN ScriptEngineConvertFileToPdbFileAndGuidAndAgeDetails(const char * LocalFilePath, char * PdbFilePath, char * GuidAndAgeDetails, BOOLEAN Is32BitModule); diff --git a/hyperdbg/include/SDK/imports/user/HyperDbgSymImports.h b/hyperdbg/include/SDK/imports/user/HyperDbgSymImports.h index 8f0762a1..98d97b53 100644 --- a/hyperdbg/include/SDK/imports/user/HyperDbgSymImports.h +++ b/hyperdbg/include/SDK/imports/user/HyperDbgSymImports.h @@ -55,7 +55,7 @@ IMPORT_EXPORT_HYPERDBG_SYMBOL_PARSER BOOLEAN SymCreateSymbolTableForDisassembler(void * CallbackFunction); IMPORT_EXPORT_HYPERDBG_SYMBOL_PARSER BOOLEAN -SymConvertFileToPdbPath(const char * LocalFilePath, char * ResultPath); +SymConvertFileToPdbPath(const char * LocalFilePath, char * ResultPath, size_t ResultPathSize); IMPORT_EXPORT_HYPERDBG_SYMBOL_PARSER BOOLEAN SymConvertFileToPdbFileAndGuidAndAgeDetails(const char * LocalFilePath, diff --git a/hyperdbg/libhyperdbg/code/debugger/script-engine/script-engine-wrapper.cpp b/hyperdbg/libhyperdbg/code/debugger/script-engine/script-engine-wrapper.cpp index fb80d854..e4f0db88 100644 --- a/hyperdbg/libhyperdbg/code/debugger/script-engine/script-engine-wrapper.cpp +++ b/hyperdbg/libhyperdbg/code/debugger/script-engine/script-engine-wrapper.cpp @@ -172,10 +172,10 @@ ScriptEngineCreateSymbolTableForDisassemblerWrapper(void * CallbackFunction) * @return BOOLEAN */ BOOLEAN -ScriptEngineConvertFileToPdbPathWrapper(const char * LocalFilePath, char * ResultPath) +ScriptEngineConvertFileToPdbPathWrapper(const char * LocalFilePath, char * ResultPath, size_t ResultPathSize) { - return ScriptEngineConvertFileToPdbPath(LocalFilePath, ResultPath); + return ScriptEngineConvertFileToPdbPath(LocalFilePath, ResultPath, ResultPathSize); } /** diff --git a/hyperdbg/libhyperdbg/header/script-engine.h b/hyperdbg/libhyperdbg/header/script-engine.h index 2c0ce3f7..e9fe3fbf 100644 --- a/hyperdbg/libhyperdbg/header/script-engine.h +++ b/hyperdbg/libhyperdbg/header/script-engine.h @@ -42,7 +42,7 @@ BOOLEAN ScriptEngineCreateSymbolTableForDisassemblerWrapper(void * CallbackFunction); BOOLEAN -ScriptEngineConvertFileToPdbPathWrapper(const char * LocalFilePath, char * ResultPath); +ScriptEngineConvertFileToPdbPathWrapper(const char * LocalFilePath, char * ResultPath, size_t ResultPathSize); BOOLEAN ScriptEngineConvertFileToPdbFileAndGuidAndAgeDetailsWrapper(const char * LocalFilePath, diff --git a/hyperdbg/script-engine/code/script-engine.c b/hyperdbg/script-engine/code/script-engine.c index 2dedbf23..87f321e7 100644 --- a/hyperdbg/script-engine/code/script-engine.c +++ b/hyperdbg/script-engine/code/script-engine.c @@ -213,12 +213,12 @@ ScriptEngineCreateSymbolTableForDisassembler(void * CallbackFunction) * @return BOOLEAN */ BOOLEAN -ScriptEngineConvertFileToPdbPath(const char * LocalFilePath, char * ResultPath) +ScriptEngineConvertFileToPdbPath(const char * LocalFilePath, char * ResultPath, size_t ResultPathSize) { // // A wrapper for pdb to path converter // - return SymConvertFileToPdbPath(LocalFilePath, ResultPath); + return SymConvertFileToPdbPath(LocalFilePath, ResultPath, ResultPathSize); } /** diff --git a/hyperdbg/symbol-parser/code/symbol-parser.cpp b/hyperdbg/symbol-parser/code/symbol-parser.cpp index fc95eedc..8fd708ac 100644 --- a/hyperdbg/symbol-parser/code/symbol-parser.cpp +++ b/hyperdbg/symbol-parser/code/symbol-parser.cpp @@ -1684,33 +1684,44 @@ SymTagStr(ULONG Tag) * @return BOOLEAN */ BOOLEAN -SymConvertFileToPdbPath(const char * LocalFilePath, char * ResultPath) +SymConvertFileToPdbPath(const char * LocalFilePath, char * ResultPath, size_t ResultPathSize) { + if (LocalFilePath == NULL && ResultPath == NULL) + { + return FALSE; + } + SYMSRV_INDEX_INFO SymInfo = {0}; - const char * FormatStr = - "%s/%08x%04x%04x%02x%02x%02x%02x%02x%02x%02x%02x%x/%s"; + const char * FormatStr = "%s/%08x%04x%04x%02x%02x%02x%02x%02x%02x%02x%02x%x/%s"; SymInfo.sizeofstruct = sizeof(SYMSRV_INDEX_INFO); BOOL Ret = SymSrvGetFileIndexInfo(LocalFilePath, &SymInfo, 0); if (Ret) { - wsprintfA(ResultPath, - FormatStr, - SymInfo.pdbfile, - SymInfo.guid.Data1, - SymInfo.guid.Data2, - SymInfo.guid.Data3, - SymInfo.guid.Data4[0], - SymInfo.guid.Data4[1], - SymInfo.guid.Data4[2], - SymInfo.guid.Data4[3], - SymInfo.guid.Data4[4], - SymInfo.guid.Data4[5], - SymInfo.guid.Data4[6], - SymInfo.guid.Data4[7], - SymInfo.age, - SymInfo.pdbfile); + HRESULT hresult = StringCchPrintfA( + ResultPath, + ResultPathSize, + FormatStr, + SymInfo.pdbfile, + SymInfo.guid.Data1, + SymInfo.guid.Data2, + SymInfo.guid.Data3, + SymInfo.guid.Data4[0], + SymInfo.guid.Data4[1], + SymInfo.guid.Data4[2], + SymInfo.guid.Data4[3], + SymInfo.guid.Data4[4], + SymInfo.guid.Data4[5], + SymInfo.guid.Data4[6], + SymInfo.guid.Data4[7], + SymInfo.age, + SymInfo.pdbfile); + + if (FAILED(hresult)) + { + return FALSE; + } return TRUE; } diff --git a/hyperdbg/symbol-parser/pch.h b/hyperdbg/symbol-parser/pch.h index cc979aa7..05df59f1 100644 --- a/hyperdbg/symbol-parser/pch.h +++ b/hyperdbg/symbol-parser/pch.h @@ -29,7 +29,7 @@ using namespace std; #include #include #include - +#include #define _NO_CVCONST_H // for symbol parsing #include