From 1575bdf4bddf217de491704d4d5209f12e3d7b48 Mon Sep 17 00:00:00 2001 From: Martin Olivier Date: Thu, 1 Aug 2024 11:25:25 +0200 Subject: [PATCH] fix: coding style Signed-off-by: Martin Olivier --- src/demangle.cpp | 1 + src/symbols.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/demangle.cpp b/src/demangle.cpp index b94416d..87c9a8b 100644 --- a/src/demangle.cpp +++ b/src/demangle.cpp @@ -68,6 +68,7 @@ std::string get_demangled_name(const char *symbol) { res = abi::__cxa_demangle(symbol, buf, &size, &status); if (!res) { free(buf); + return ""; } diff --git a/src/symbols.cpp b/src/symbols.cpp index 064c146..4da6614 100644 --- a/src/symbols.cpp +++ b/src/symbols.cpp @@ -51,7 +51,7 @@ std::vector get_symbols(HMODULE hModule, bool demangle) { throw std::string("Invalid DOS header"); // Get the NT headers - PIMAGE_NT_HEADERS pNTHeaders = (PIMAGE_NT_HEADERS)((BYTE*)hModule + pDosHeader->e_lfanew); + PIMAGE_NT_HEADERS pNTHeaders = (PIMAGE_NT_HEADERS)((BYTE *)hModule + pDosHeader->e_lfanew); if (pNTHeaders->Signature != IMAGE_NT_SIGNATURE) throw std::string("Invalid NT headers"); @@ -60,15 +60,15 @@ std::vector get_symbols(HMODULE hModule, bool demangle) { if (exportDirRVA == 0) throw std::string("No export directory found"); - PIMAGE_EXPORT_DIRECTORY pExportDir = (PIMAGE_EXPORT_DIRECTORY)((BYTE*)hModule + exportDirRVA); + PIMAGE_EXPORT_DIRECTORY pExportDir = (PIMAGE_EXPORT_DIRECTORY)((BYTE *)hModule + exportDirRVA); // Get the list of exported function names - DWORD* pNames = (DWORD*)((BYTE*)hModule + pExportDir->AddressOfNames); - DWORD* pFunctions = (DWORD*)((BYTE*)hModule + pExportDir->AddressOfFunctions); - WORD* pNameOrdinals = (WORD*)((BYTE*)hModule + pExportDir->AddressOfNameOrdinals); + DWORD *pNames = (DWORD *)((BYTE *)hModule + pExportDir->AddressOfNames); + DWORD *pFunctions = (DWORD *)((BYTE *)hModule + pExportDir->AddressOfFunctions); + WORD *pNameOrdinals = (WORD *)((BYTE *)hModule + pExportDir->AddressOfNameOrdinals); for (DWORD i = 0; i < pExportDir->NumberOfNames; ++i) { - const char* name = (const char*)((BYTE*)hModule + pNames[i]); + const char *name = (const char *)((BYTE *)hModule + pNames[i]); add_symbol(result, name, demangle); }