forked from Public-Mirror/Textractor
improve config loading and prevent crashes
This commit is contained in:
parent
4cebe9462f
commit
60a5d74eda
@ -17001,7 +17001,7 @@ void InsertMonoHook(HMODULE h)
|
|||||||
if (!getDomain || !getName || !getJitInfo) goto failed;
|
if (!getDomain || !getName || !getJitInfo) goto failed;
|
||||||
static auto domain = getDomain();
|
static auto domain = getDomain();
|
||||||
if (!domain) goto failed;
|
if (!domain) goto failed;
|
||||||
ConsoleOutput("Textractor: Mono Dynamic ENTER (hooks = %s)", loadedConfig ? loadedConfig : "brute force");
|
ConsoleOutput("Textractor: Mono Dynamic ENTER (hooks = %s)", *loadedConfig ? loadedConfig : "brute force");
|
||||||
const BYTE prolog[] = { 0x55, 0x8b, 0xec };
|
const BYTE prolog[] = { 0x55, 0x8b, 0xec };
|
||||||
for (auto addr : Util::SearchMemory(prolog, sizeof(prolog), PAGE_EXECUTE_READWRITE))
|
for (auto addr : Util::SearchMemory(prolog, sizeof(prolog), PAGE_EXECUTE_READWRITE))
|
||||||
{
|
{
|
||||||
@ -17016,7 +17016,7 @@ void InsertMonoHook(HMODULE h)
|
|||||||
HookParam hp = {};
|
HookParam hp = {};
|
||||||
hp.address = addr;
|
hp.address = addr;
|
||||||
hp.type = USING_UNICODE | FULL_STRING;
|
hp.type = USING_UNICODE | FULL_STRING;
|
||||||
if (!loadedConfig) hp.type |= KNOWN_UNSTABLE;
|
if (!*loadedConfig) hp.type |= KNOWN_UNSTABLE;
|
||||||
hp.offset = 4;
|
hp.offset = 4;
|
||||||
char nameForUser[HOOK_NAME_SIZE] = {};
|
char nameForUser[HOOK_NAME_SIZE] = {};
|
||||||
strncpy_s(nameForUser, name + 1, HOOK_NAME_SIZE - 1);
|
strncpy_s(nameForUser, name + 1, HOOK_NAME_SIZE - 1);
|
||||||
@ -17034,7 +17034,7 @@ void InsertMonoHook(HMODULE h)
|
|||||||
__except (EXCEPTION_EXECUTE_HANDLER) {}
|
__except (EXCEPTION_EXECUTE_HANDLER) {}
|
||||||
}(addr);
|
}(addr);
|
||||||
}
|
}
|
||||||
if (!loadedConfig) ConsoleOutput("Textractor: Mono Dynamic used brute force: if performance issues arise, please specify the correct hook in the game configuration");
|
if (!*loadedConfig) ConsoleOutput("Textractor: Mono Dynamic used brute force: if performance issues arise, please specify the correct hook in the game configuration");
|
||||||
return true;
|
return true;
|
||||||
failed:
|
failed:
|
||||||
ConsoleOutput("Textractor: Mono Dynamic failed");
|
ConsoleOutput("Textractor: Mono Dynamic failed");
|
||||||
@ -17091,7 +17091,7 @@ bool InsertMonoHooks()
|
|||||||
if (FARPROC addr = ::GetProcAddress(h, func.functionName)) {
|
if (FARPROC addr = ::GetProcAddress(h, func.functionName)) {
|
||||||
hp.address = (DWORD)addr;
|
hp.address = (DWORD)addr;
|
||||||
hp.type = func.hookType;
|
hp.type = func.hookType;
|
||||||
if (loadedConfig) hp.type |= HOOK_EMPTY;
|
if (*loadedConfig) hp.type |= HOOK_EMPTY;
|
||||||
hp.filter_fun = NoAsciiFilter;
|
hp.filter_fun = NoAsciiFilter;
|
||||||
hp.offset = func.textIndex * 4;
|
hp.offset = func.textIndex * 4;
|
||||||
hp.length_offset = func.lengthIndex * 4;
|
hp.length_offset = func.lengthIndex * 4;
|
||||||
|
@ -14,7 +14,7 @@ namespace Engine {
|
|||||||
// Global variables
|
// Global variables
|
||||||
extern wchar_t *processName, // cached
|
extern wchar_t *processName, // cached
|
||||||
processPath[MAX_PATH]; // cached
|
processPath[MAX_PATH]; // cached
|
||||||
inline const char *requestedEngine = nullptr, *loadedConfig = nullptr;
|
inline const char *requestedEngine = "", * loadedConfig = "";
|
||||||
|
|
||||||
bool InsertMonoHooks(); // Mono
|
bool InsertMonoHooks(); // Mono
|
||||||
|
|
||||||
|
@ -45,13 +45,13 @@ namespace Engine
|
|||||||
if (AutoHandle<> configFile = CreateFileW(configFilename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL))
|
if (AutoHandle<> configFile = CreateFileW(configFilename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL))
|
||||||
{
|
{
|
||||||
ReadFile(configFile, configFileData, sizeof(configFileData) - 1, DUMMY, nullptr);
|
ReadFile(configFile, configFileData, sizeof(configFileData) - 1, DUMMY, nullptr);
|
||||||
if (strncmp(configFileData, "Engine:", 7) == 0)
|
if (strnicmp(configFileData, "engine:", 7) == 0)
|
||||||
{
|
{
|
||||||
if (loadedConfig = strchr(configFileData, '\n')) *(char*)loadedConfig++ = 0;
|
if (const char* config = strchr(configFileData, '\n')) *(char*)(loadedConfig = config)++ = 0;
|
||||||
ConsoleOutput("Textractor: Engine = %s", requestedEngine = configFileData + 7);
|
ConsoleOutput("Textractor: Engine = %s", requestedEngine = strlwr(configFileData + 7));
|
||||||
}
|
}
|
||||||
else loadedConfig = configFileData;
|
else loadedConfig = configFileData;
|
||||||
if ((loadedConfig && !*loadedConfig) || strstr(configFileData, "https://")) loadedConfig = nullptr;
|
if (!*loadedConfig || strstr(configFileData, "https://")) loadedConfig = "";
|
||||||
else ConsoleOutput("Textractor: game configuration loaded");
|
else ConsoleOutput("Textractor: game configuration loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,14 +67,14 @@ namespace Engine
|
|||||||
spDefault.maxAddress = processStopAddress;
|
spDefault.maxAddress = processStopAddress;
|
||||||
ConsoleOutput("Textractor: hijacking process located from 0x%p to 0x%p", processStartAddress, processStopAddress);
|
ConsoleOutput("Textractor: hijacking process located from 0x%p to 0x%p", processStartAddress, processStopAddress);
|
||||||
|
|
||||||
DetermineEngineType();
|
if (!strstr(requestedEngine, "none")) DetermineEngineType();
|
||||||
if (processStartAddress + 0x40000 > processStopAddress) ConsoleOutput("Textractor: WARNING injected process is very small, possibly a dummy!");
|
if (processStartAddress + 0x40000 > processStopAddress) ConsoleOutput("Textractor: WARNING injected process is very small, possibly a dummy!");
|
||||||
}(), 0);
|
}(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShouldMonoHook(const char* name)
|
bool ShouldMonoHook(const char* name)
|
||||||
{
|
{
|
||||||
if (!loadedConfig) return strstr(name, "string:") && !strstr(name, "string:mem");
|
if (!*loadedConfig) return strstr(name, "string:") && !strstr(name, "string:mem");
|
||||||
for (const char* hook = loadedConfig; hook; hook = strchr(hook + 1, '\t'))
|
for (const char* hook = loadedConfig; hook; hook = strchr(hook + 1, '\t'))
|
||||||
for (auto start = name; *start; ++start)
|
for (auto start = name; *start; ++start)
|
||||||
for (int i = 0; ; ++i)
|
for (int i = 0; ; ++i)
|
||||||
|
@ -80,7 +80,7 @@ namespace Engine
|
|||||||
if (!getDomain || !getName || !getJitInfo) goto failed;
|
if (!getDomain || !getName || !getJitInfo) goto failed;
|
||||||
static auto domain = getDomain();
|
static auto domain = getDomain();
|
||||||
if (!domain) goto failed;
|
if (!domain) goto failed;
|
||||||
ConsoleOutput("Textractor: Mono Dynamic ENTER (hooks = %s)", loadedConfig ? loadedConfig : "brute force");
|
ConsoleOutput("Textractor: Mono Dynamic ENTER (hooks = %s)", *loadedConfig ? loadedConfig : "brute force");
|
||||||
const BYTE prolog1[] = { 0x55, 0x48, 0x8b, 0xec };
|
const BYTE prolog1[] = { 0x55, 0x48, 0x8b, 0xec };
|
||||||
const BYTE prolog2[] = { 0x48, 0x83, 0xec };
|
const BYTE prolog2[] = { 0x48, 0x83, 0xec };
|
||||||
for (auto [prolog, size] : Array<const BYTE*, size_t>{ { prolog1, sizeof(prolog1) }, { prolog2, sizeof(prolog2) } })
|
for (auto [prolog, size] : Array<const BYTE*, size_t>{ { prolog1, sizeof(prolog1) }, { prolog2, sizeof(prolog2) } })
|
||||||
@ -97,7 +97,7 @@ namespace Engine
|
|||||||
HookParam hp = {};
|
HookParam hp = {};
|
||||||
hp.address = addr;
|
hp.address = addr;
|
||||||
hp.type = USING_STRING | USING_UNICODE | FULL_STRING;
|
hp.type = USING_STRING | USING_UNICODE | FULL_STRING;
|
||||||
if (!loadedConfig) hp.type |= KNOWN_UNSTABLE;
|
if (!*loadedConfig) hp.type |= KNOWN_UNSTABLE;
|
||||||
hp.offset = -0x20; // rcx
|
hp.offset = -0x20; // rcx
|
||||||
hp.padding = 20;
|
hp.padding = 20;
|
||||||
char nameForUser[HOOK_NAME_SIZE] = {};
|
char nameForUser[HOOK_NAME_SIZE] = {};
|
||||||
@ -119,7 +119,7 @@ namespace Engine
|
|||||||
}(addr);
|
}(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadedConfig) ConsoleOutput("Textractor: Mono Dynamic used brute force: if performance issues arise, please specify the correct hook in the game configuration");
|
if (!*loadedConfig) ConsoleOutput("Textractor: Mono Dynamic used brute force: if performance issues arise, please specify the correct hook in the game configuration");
|
||||||
return true;
|
return true;
|
||||||
failed:
|
failed:
|
||||||
ConsoleOutput("Textractor: Mono Dynamic failed");
|
ConsoleOutput("Textractor: Mono Dynamic failed");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user