From ecbab96427625c891d0d1c72089db4f1ecc08562 Mon Sep 17 00:00:00 2001 From: mkrsym1 Date: Sun, 7 Jan 2024 19:01:03 +0200 Subject: [PATCH] Implemented experimental patching method for SR --- game_payload/src/hsr/hsr.c | 56 ++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/game_payload/src/hsr/hsr.c b/game_payload/src/hsr/hsr.c index 2273d1b..ceae83f 100644 --- a/game_payload/src/hsr/hsr.c +++ b/game_payload/src/hsr/hsr.c @@ -70,25 +70,53 @@ static void _unityplayer_callback(HMODULE unityModule) { utils_write_protected_memory(wtsud_patch_addr, payload, sizeof(payload)); } -void hsr_fill_data(struct game_data *buf) { - uint32_t crc = utils_file_crc32c(L"UnityPlayer.dll"); - - enum hsr_region id = HSR_INVALID; - for (size_t i = 0; i < UTILS_COUNT(HSR_REGIONS); i++) { - if (HSR_REGIONS[i].crc == crc) { - id = HSR_REGIONS[i].id; - break; - } +static void _break_cryptcat() { + const char STUB[] = { + 0xB8, 0x01, 0x00, 0x00, 0x00, // mov eax, 1 + 0xC3 // ret + }; + + const char *STUB_FUNCTIONS[] = { + "CryptCATAdminEnumCatalogFromHash", + "CryptCATCatalogInfoFromContext", + "CryptCATAdminReleaseCatalogContext" + }; + + HMODULE wintrust = LoadLibraryA("wintrust.dll"); + + for (size_t i = 0; i < UTILS_COUNT(STUB_FUNCTIONS); i++) { + void *fn = GetProcAddress(wintrust, STUB_FUNCTIONS[i]); + utils_write_protected_memory(fn, STUB, sizeof(STUB)); } - - if (id == HSR_INVALID) { - msg_err_a("Invalid UnityPlayer.dll checksum: 0x%08x. This patch is intended to be used with HSR v" HSR_VERSION, crc); +} + +void hsr_fill_data(struct game_data *buf) { + if (!utils_env_enabled("BREAK_CRYPTCAT")) { + uint32_t crc = utils_file_crc32c(L"UnityPlayer.dll"); + + enum hsr_region id = HSR_INVALID; + for (size_t i = 0; i < UTILS_COUNT(HSR_REGIONS); i++) { + if (HSR_REGIONS[i].crc == crc) { + id = HSR_REGIONS[i].id; + break; + } + } + + if (id == HSR_INVALID) { + msg_err_a("Invalid UnityPlayer.dll checksum: 0x%08x. This patch is intended to be used with HSR v" HSR_VERSION, crc); + } + + // WriteTextureStatisticUserData patch + buf->unityplayer_callback = &_unityplayer_callback; + } else { + msg_warn_a("Using experimental patching method"); + _break_cryptcat(); + + buf->unityplayer_callback = NULL; } buf->base_module_name = HSR_BASE_MODULE_NAME; buf->assembly_path = HSR_ASSEMBLY_PATH; buf->txs_section_name = HSR_TXS_SECTION_NAME; buf->tvm_section_name = HSR_TVM_SECTION_NAME; - - buf->unityplayer_callback = &_unityplayer_callback; }