cleaner output for mono

This commit is contained in:
Akash Mozumdar 2020-03-05 02:19:04 -07:00
parent 3ff31e0ac6
commit 2be920c50e
4 changed files with 10 additions and 5 deletions

View File

@ -30,4 +30,5 @@ enum HookParamType : unsigned
HEX_DUMP = 0x4000,
HOOK_ENGINE = 0x8000,
HOOK_ADDITIONAL = 0x10000,
KNOWN_UNSTABLE = 0x20000,
};

View File

@ -16734,10 +16734,12 @@ void InsertMonoHook(HMODULE h)
HookParam hp = {};
hp.address = addr;
hp.type = USING_UNICODE | FULL_STRING;
if (!loadedConfig) hp.type |= KNOWN_UNSTABLE;
hp.offset = 4;
char nameForUser[HOOK_NAME_SIZE] = {};
strncpy_s(nameForUser, name + 1, HOOK_NAME_SIZE - 1);
if (char* end = strstr(nameForUser, " + 0x0")) *end = 0;
if (char* end = strstr(nameForUser, "{")) *end = 0;
hp.text_fun = [](DWORD esp_base, HookParam*, BYTE, DWORD* data, DWORD* split, DWORD* len)
{
MonoString* string = (MonoString*)argof(1, esp_base);
@ -16750,8 +16752,7 @@ void InsertMonoHook(HMODULE h)
__except (EXCEPTION_EXECUTE_HANDLER) {}
}(addr);
}
if (!loadedConfig) ConsoleOutput("Textractor: Mono Dynamic used brute force: if performance issues arise, please create a TextractorConfig.txt file"
"next to the main executable and put the name of a working hook inside it");
if (!loadedConfig) ConsoleOutput("Textractor: Mono Dynamic used brute force: if performance issues arise, please specify the correct hook in the game configuration");
return true;
failed:
ConsoleOutput("Textractor: Mono Dynamic failed");

View File

@ -98,11 +98,13 @@ namespace Engine
HookParam hp = {};
hp.address = addr;
hp.type = USING_STRING | USING_UNICODE | FULL_STRING;
if (!loadedConfig) hp.type |= KNOWN_UNSTABLE;
hp.offset = -0x20; // rcx
hp.padding = 20;
char nameForUser[HOOK_NAME_SIZE] = {};
strncpy_s(nameForUser, name + 1, HOOK_NAME_SIZE - 1);
if (char* end = strstr(nameForUser, " + 0x0")) *end = 0;
if (char* end = strstr(nameForUser, "{")) *end = 0;
hp.length_fun = [](uintptr_t, uintptr_t data)
{
/* Artikash 6/18/2019:
@ -117,8 +119,8 @@ namespace Engine
__except (EXCEPTION_EXECUTE_HANDLER) {}
}(addr);
}
if (!loadedConfig) ConsoleOutput("Textractor: Mono Dynamic used brute force: if performance issues arise, please create a TextractorConfig.txt file"
"next to the main executable and put the name of a working hook inside it");
if (!loadedConfig) ConsoleOutput("Textractor: Mono Dynamic used brute force: if performance issues arise, please specify the correct hook in the game configuration");
return true;
failed:
ConsoleOutput("Textractor: Mono Dynamic failed");

View File

@ -201,7 +201,7 @@ void TextHook::Send(uintptr_t dwDataBase)
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
if (!err)
if (!err && !(hp.type & KNOWN_UNSTABLE))
{
err = true;
ConsoleOutput("%s in %s", SEND_ERROR, hp.name);
@ -222,6 +222,7 @@ bool TextHook::InsertHookCode()
else if (HMODULE moduleBase = GetModuleHandleW(hp.module)) address += (uint64_t)moduleBase;
else return ConsoleOutput(MODULE_MISSING), false;
VirtualProtect(location, 10, PAGE_EXECUTE_READWRITE, DUMMY);
void* original;
MH_STATUS error;
while ((error = MH_CreateHook(location, trampoline, &original)) != MH_OK)