diff --git a/src/hook.cpp b/src/hook.cpp index d3c6810..f7f4777 100644 --- a/src/hook.cpp +++ b/src/hook.cpp @@ -890,6 +890,58 @@ namespace return GameVersion{ .gameVersion = gameVer , .resourceVersion = resVersion }; } + std::pair getManifestFile(Il2CppString* defaultFileName) { + try { + auto defaultData = checkAndDownloadFile(defaultFileName); + if (defaultData != NULL) { + return std::make_pair(nullptr, defaultData); + } + printf("Try get fallback version...\n"); + + static auto CatalogManifest_FromUniqueVersion = reinterpret_cast( + il2cpp_symbols::get_method_pointer("Limelight.Shared.dll", "Limelight", + "CatalogManifest", "FromUniqueVersion", 2) + ); + static auto CatalogManifest_GetRealName = reinterpret_cast( + il2cpp_symbols::get_method_pointer("Limelight.Shared.dll", "Limelight", + "CatalogManifest", "GetRealName", 0) + ); + + const auto gameVerInfo = getGameVersions(); + const std::wstring gameVer = gameVerInfo.gameVersion; + const std::wstring resVersion = gameVerInfo.resourceVersion; + + const auto subPointPos = gameVer.rfind(L'.', -1); + if (subPointPos == std::wstring::npos) { + wprintf(L"Invalid game version: %ls\n", gameVer.c_str()); + return std::make_pair(nullptr, nullptr); + } + const auto baseVersionString = gameVer.substr(0, subPointPos + 1); + auto subVersion = std::stoi(gameVer.substr(subPointPos + 1, gameVer.length())); + + while (subVersion >= 0) { + const auto currentVersion = std::format(L"{}{}", baseVersionString, subVersion); + wprintf(L"Checking version: %ls\n", currentVersion.c_str()); + auto manifest = CatalogManifest_FromUniqueVersion(il2cpp_symbols::NewWStr(resVersion), il2cpp_symbols::NewWStr(currentVersion)); + if (manifest) { + auto data = checkAndDownloadFile(CatalogManifest_GetRealName(manifest)); + if (data != NULL) { + return std::make_pair(manifest, data); + } + } + else { + printf("manifest is null.\n"); + } + subVersion--; + } + } + catch (std::exception& ex) { + printf("getManifestFile error: %s\n", ex.what()); + } + printf("Get manifest file failed.\n"); + return std::make_pair(nullptr, nullptr); + } + int dumpScenarioFromCatalog() { static auto string_op_Implicit = reinterpret_cast( @@ -930,6 +982,11 @@ namespace "CatalogBinaryEntry", "get_Label", 0) ); + static auto CatalogManifest_FromUniqueVersion = reinterpret_cast( + il2cpp_symbols::get_method_pointer("Limelight.Shared.dll", "Limelight", + "CatalogManifest", "FromUniqueVersion", 2) + ); + static auto CatalogBinaryEntry_klass = il2cpp_symbols::get_class("Limelight.Shared.dll", "Limelight", "CatalogBinaryEntry"); static auto Label_field = il2cpp_class_get_field_from_name(CatalogBinaryEntry_klass, "