From 7732915b18b0190185a9e3b7f159cb6f0117403f Mon Sep 17 00:00:00 2001 From: Martin Baliet Date: Fri, 15 Mar 2024 18:03:40 +0100 Subject: [PATCH] dump every sce symbol in the project --- modules/setupModule.cmake | 2 +- tools/dll2nids/main.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/setupModule.cmake b/modules/setupModule.cmake index 947b8d7..c46b8a0 100644 --- a/modules/setupModule.cmake +++ b/modules/setupModule.cmake @@ -1,6 +1,6 @@ function(setupModule _Target) add_custom_command(TARGET ${_Target} POST_BUILD - COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/${_Target}.dll + COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/${_Target}.dll "${CMAKE_BINARY_DIR}/symbols" ) add_dependencies(${_Target} logging dll2Nids) install(FILES $ DESTINATION debug OPTIONAL) diff --git a/tools/dll2nids/main.cpp b/tools/dll2nids/main.cpp index 55aadea..469723c 100644 --- a/tools/dll2nids/main.cpp +++ b/tools/dll2nids/main.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -64,6 +65,10 @@ std::string hexId2nid(std::string_view hexId) { } int main(int argc, char* argv[]) { + if (argc != 3) { + printf("Wrong argument count: filepath, symbolFolder"); + return -1; + } std::ifstream file; file.open(argv[1], std::ios::binary); @@ -147,6 +152,11 @@ int main(int argc, char* argv[]) { // ### Read all symbol names, make nids, store with new offset // Read all and change to nids + std::filesystem::create_directory(argv[2]); + std::ofstream fDumpSymbols((std::filesystem::path(argv[2]) / (std::filesystem::path(argv[1]).stem().string() + ".txt")).c_str(), std::ios::trunc); + + auto funcLogSymbol = [&fDumpSymbols](std::string_view nid, std::string_view name) { fDumpSymbols << nid << '\t' << name << '\n'; }; + std::vector symbols(numNames); bool hasModuleName = false; for (size_t n = 0; n < numNames; n++) { @@ -160,12 +170,15 @@ int main(int argc, char* argv[]) { if (name.starts_with("sce") || name.starts_with("_sce")) { // Change to nids symbols[n] = name2nid(name); + funcLogSymbol(symbols[n], name); } else if (name.starts_with("__hex_")) { // Change to nids symbols[n] = hexId2nid(name.substr(6)); + funcLogSymbol(symbols[n], ""); } else if (name.starts_with("__sce_")) { // Change to nids symbols[n] = name2nid(name.substr(6)); + funcLogSymbol(symbols[n], name.substr(6)); } else { symbols[n] = std::string(name); if (!hasModuleName && name == "MODULE_NAME") {