Skip to content

Commit

Permalink
cleaner output for mono
Browse files Browse the repository at this point in the history
  • Loading branch information
Artikash committed Mar 5, 2020
1 parent 3ff31e0 commit 2be920c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ enum HookParamType : unsigned
HEX_DUMP = 0x4000,
HOOK_ENGINE = 0x8000,
HOOK_ADDITIONAL = 0x10000,
KNOWN_UNSTABLE = 0x20000,
};
5 changes: 3 additions & 2 deletions texthook/engine/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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");
Expand Down
6 changes: 4 additions & 2 deletions texthook/engine/match64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion texthook/texthook.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down

0 comments on commit 2be920c

Please sign in to comment.