Implemented experimental patching method for SR

This commit is contained in:
mkrsym1 2024-01-07 19:01:03 +02:00
parent 2da21065a6
commit ecbab96427

View File

@ -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;
}