mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-23 08:54:12 +08:00
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;
|
||||
static auto domain = getDomain();
|
||||
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 };
|
||||
for (auto addr : Util::SearchMemory(prolog, sizeof(prolog), PAGE_EXECUTE_READWRITE))
|
||||
{
|
||||
@ -17016,7 +17016,7 @@ void InsertMonoHook(HMODULE h)
|
||||
HookParam hp = {};
|
||||
hp.address = addr;
|
||||
hp.type = USING_UNICODE | FULL_STRING;
|
||||
if (!loadedConfig) hp.type |= KNOWN_UNSTABLE;
|
||||
if (!*loadedConfig) hp.type |= KNOWN_UNSTABLE;
|
||||
hp.offset = 4;
|
||||
char nameForUser[HOOK_NAME_SIZE] = {};
|
||||
strncpy_s(nameForUser, name + 1, HOOK_NAME_SIZE - 1);
|
||||
@ -17034,7 +17034,7 @@ void InsertMonoHook(HMODULE h)
|
||||
__except (EXCEPTION_EXECUTE_HANDLER) {}
|
||||
}(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;
|
||||
failed:
|
||||
ConsoleOutput("Textractor: Mono Dynamic failed");
|
||||
@ -17091,7 +17091,7 @@ bool InsertMonoHooks()
|
||||
if (FARPROC addr = ::GetProcAddress(h, func.functionName)) {
|
||||
hp.address = (DWORD)addr;
|
||||
hp.type = func.hookType;
|
||||
if (loadedConfig) hp.type |= HOOK_EMPTY;
|
||||
if (*loadedConfig) hp.type |= HOOK_EMPTY;
|
||||
hp.filter_fun = NoAsciiFilter;
|
||||
hp.offset = func.textIndex * 4;
|
||||
hp.length_offset = func.lengthIndex * 4;
|
||||
|
@ -14,7 +14,7 @@ namespace Engine {
|
||||
// Global variables
|
||||
extern wchar_t *processName, // cached
|
||||
processPath[MAX_PATH]; // cached
|
||||
inline const char *requestedEngine = nullptr, *loadedConfig = nullptr;
|
||||
inline const char *requestedEngine = "", * loadedConfig = "";
|
||||
|
||||
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))
|
||||
{
|
||||
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;
|
||||
ConsoleOutput("Textractor: Engine = %s", requestedEngine = configFileData + 7);
|
||||
if (const char* config = strchr(configFileData, '\n')) *(char*)(loadedConfig = config)++ = 0;
|
||||
ConsoleOutput("Textractor: Engine = %s", requestedEngine = strlwr(configFileData + 7));
|
||||
}
|
||||
else loadedConfig = configFileData;
|
||||
if ((loadedConfig && !*loadedConfig) || strstr(configFileData, "https://")) loadedConfig = nullptr;
|
||||
if (!*loadedConfig || strstr(configFileData, "https://")) loadedConfig = "";
|
||||
else ConsoleOutput("Textractor: game configuration loaded");
|
||||
}
|
||||
|
||||
@ -67,14 +67,14 @@ namespace Engine
|
||||
spDefault.maxAddress = 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!");
|
||||
}(), 0);
|
||||
}
|
||||
|
||||
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 (auto start = name; *start; ++start)
|
||||
for (int i = 0; ; ++i)
|
||||
|
@ -80,7 +80,7 @@ namespace Engine
|
||||
if (!getDomain || !getName || !getJitInfo) goto failed;
|
||||
static auto domain = getDomain();
|
||||
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 prolog2[] = { 0x48, 0x83, 0xec };
|
||||
for (auto [prolog, size] : Array<const BYTE*, size_t>{ { prolog1, sizeof(prolog1) }, { prolog2, sizeof(prolog2) } })
|
||||
@ -97,7 +97,7 @@ namespace Engine
|
||||
HookParam hp = {};
|
||||
hp.address = addr;
|
||||
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.padding = 20;
|
||||
char nameForUser[HOOK_NAME_SIZE] = {};
|
||||
@ -119,7 +119,7 @@ namespace Engine
|
||||
}(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;
|
||||
failed:
|
||||
ConsoleOutput("Textractor: Mono Dynamic failed");
|
||||
|
Loading…
x
Reference in New Issue
Block a user