diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 1d5dc8f4d..f3c8e5a8f 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -397,4 +397,4 @@ target_include_directories(skyline PRIVATE ${source_DIR}/skyline) target_compile_options(skyline PRIVATE -Wall -Wno-unknown-attributes -Wno-c++20-extensions -Wno-c++17-extensions -Wno-c99-designator -Wno-reorder -Wno-missing-braces -Wno-unused-variable -Wno-unused-private-field -Wno-dangling-else -Wconversion -fsigned-bitfields) target_link_libraries(skyline PRIVATE shader_recompiler audio_core) -target_link_libraries_system(skyline android perfetto fmt lz4_static tzcode vkma mbedcrypto opus Boost::intrusive Boost::container Boost::preprocessor range-v3 adrenotools tsl::robin_map) +target_link_libraries_system(skyline android perfetto fmt lz4_static tzcode vkma mbedcrypto opus Boost::intrusive Boost::container Boost::preprocessor Boost::regex range-v3 adrenotools tsl::robin_map) diff --git a/app/src/main/cpp/skyline/loader/nso.cpp b/app/src/main/cpp/skyline/loader/nso.cpp index ffd726a6c..6e555c82d 100644 --- a/app/src/main/cpp/skyline/loader/nso.cpp +++ b/app/src/main/cpp/skyline/loader/nso.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "nso.h" namespace skyline::loader { @@ -56,6 +57,8 @@ namespace skyline::loader { executable.dynstr = {header.dynstr.offset, header.dynstr.size}; } + PrintRoContentsInfo(executable.ro.contents); + return loader->LoadExecutable(process, state, executable, offset, name, dynamicallyLinked); } @@ -65,4 +68,46 @@ namespace skyline::loader { state.process->memory.InitializeRegions(span{loadInfo.base, loadInfo.size}); return loadInfo.entry; } + + void NsoLoader::PrintRoContentsInfo(const std::vector &contents) { + const boost::regex moduleRegex(R"([a-z]:[\\/][ -~]{5,}\.nss)", boost::regex::icase); + const boost::regex fsSdkRegex("sdk_version: ([0-9.]*)"); + const boost::regex sdkMwRegex("SDK MW[ -~]*"); + + std::string contentsRaw(contents.begin(), contents.end()); + std::string modulePath; + if (memcmp(&contents[0], "\x00\x00\x00\x00", 4) == 0) { + i32 length; + std::memcpy(&length, &contents[4], sizeof(i32)); + + if (length > 0) + modulePath = reinterpret_cast(&contents[4 + sizeof(i32)]); + } + + if (modulePath.empty()) { + boost::smatch moduleMatch; + if (boost::regex_search(contentsRaw, moduleMatch, moduleRegex)) + modulePath = moduleMatch.str(); + } + + LOGI("Module Path: {}", modulePath); + + boost::smatch fsSdkMatch; + if (boost::regex_search(contentsRaw, fsSdkMatch, fsSdkRegex)) + LOGI("SDK Version: {}", fsSdkMatch[1].str()); + + boost::sregex_iterator sdkMwMatchesBegin(contentsRaw.begin(), contentsRaw.end(), sdkMwRegex); + boost::sregex_iterator sdkMwMatchesEnd; + + if (sdkMwMatchesBegin != sdkMwMatchesEnd) { + std::string libContent; + + while (sdkMwMatchesBegin != sdkMwMatchesEnd) { + libContent += sdkMwMatchesBegin->str() + "\n"; + sdkMwMatchesBegin++; + } + + LOGI("SDK Libraries: {}", libContent); + } + } } diff --git a/app/src/main/cpp/skyline/loader/nso.h b/app/src/main/cpp/skyline/loader/nso.h index 93738c2b8..89e1706e5 100644 --- a/app/src/main/cpp/skyline/loader/nso.h +++ b/app/src/main/cpp/skyline/loader/nso.h @@ -89,6 +89,8 @@ namespace skyline::loader { */ static ExecutableLoadInfo LoadNso(Loader *loader, const std::shared_ptr &backing, const std::shared_ptr &process, const DeviceState &state, size_t offset = 0, const std::string &name = {}, bool dynamicallyLinked = false); + static void PrintRoContentsInfo(const std::vector &contents); + void *LoadProcessData(const std::shared_ptr &process, const DeviceState &state) override; }; }