refactor
This commit is contained in:
parent
b7ec42ee4e
commit
f74cd553c0
@ -2,12 +2,7 @@
|
|||||||
|
|
||||||
#include "qtcommon.h"
|
#include "qtcommon.h"
|
||||||
|
|
||||||
struct QTextFile : QFile
|
struct QTextFile : QFile { QTextFile(const QString& name, QIODevice::OpenMode mode) : QFile(name) { open(mode | QIODevice::Text); } };
|
||||||
{
|
|
||||||
using QFile::QFile;
|
|
||||||
QTextFile(const QString& name, QIODevice::OpenMode mode) : QFile(name) { open(mode | QIODevice::Text); }
|
|
||||||
};
|
|
||||||
|
|
||||||
inline std::wstring S(const QString& S) { return { S.toStdWString() }; }
|
inline std::wstring S(const QString& S) { return { S.toStdWString() }; }
|
||||||
inline QString S(const std::wstring& S) { return QString::fromStdWString(S); }
|
inline QString S(const std::wstring& S) { return QString::fromStdWString(S); }
|
||||||
inline HMODULE LoadLibraryOnce(std::wstring fileName) { if (HMODULE module = GetModuleHandleW(fileName.c_str())) return module; return LoadLibraryW(fileName.c_str()); }
|
inline HMODULE LoadLibraryOnce(std::wstring fileName) { if (HMODULE module = GetModuleHandleW(fileName.c_str())) return module; return LoadLibraryW(fileName.c_str()); }
|
||||||
|
@ -50,11 +50,6 @@ private:
|
|||||||
// jichi 3/7/2014: Add guessed comment
|
// jichi 3/7/2014: Add guessed comment
|
||||||
struct HookParam
|
struct HookParam
|
||||||
{
|
{
|
||||||
// jichi 8/24/2013: For special hooks.
|
|
||||||
typedef void(*text_fun_t)(DWORD esp, HookParam *hp, BYTE index, DWORD *data, DWORD *split, DWORD *len);
|
|
||||||
typedef bool(*filter_fun_t)(LPVOID str, DWORD *len, HookParam *hp, BYTE index); // jichi 10/24/2014: Add filter function. Return true if skip the text
|
|
||||||
typedef bool(*hook_fun_t)(DWORD esp, HookParam *hp); // jichi 10/24/2014: Add generic hook function, return false if stop execution.
|
|
||||||
|
|
||||||
uint64_t address; // absolute or relative address
|
uint64_t address; // absolute or relative address
|
||||||
int offset, // offset of the data in the memory
|
int offset, // offset of the data in the memory
|
||||||
index, // deref_offset1
|
index, // deref_offset1
|
||||||
@ -71,9 +66,9 @@ struct HookParam
|
|||||||
short length_offset; // index of the string length
|
short length_offset; // index of the string length
|
||||||
DWORD user_value; // 7/20/2014: jichi additional parameters for PSP games
|
DWORD user_value; // 7/20/2014: jichi additional parameters for PSP games
|
||||||
|
|
||||||
text_fun_t text_fun;
|
void(*text_fun)(DWORD stack, HookParam* hp, BYTE obsoleteAlwaysZero, DWORD* data, DWORD* split, DWORD* len);
|
||||||
filter_fun_t filter_fun;
|
bool(*filter_fun)(void* data, DWORD* len, HookParam* hp, BYTE obsoleteAlwaysZero); // jichi 10/24/2014: Add filter function. Return true if skip the text
|
||||||
hook_fun_t hook_fun;
|
bool(*hook_fun)(DWORD stack, HookParam* hp); // jichi 10/24/2014: Add generic hook function, return false if stop execution.
|
||||||
|
|
||||||
char name[HOOK_NAME_SIZE];
|
char name[HOOK_NAME_SIZE];
|
||||||
};
|
};
|
||||||
|
@ -16639,17 +16639,16 @@ bool InsertMonoHooks()
|
|||||||
HookParam hp = {};
|
HookParam hp = {};
|
||||||
const MonoFunction funcs[] = { MONO_FUNCTIONS_INITIALIZER };
|
const MonoFunction funcs[] = { MONO_FUNCTIONS_INITIALIZER };
|
||||||
enum { FunctionCount = sizeof(funcs) / sizeof(*funcs) };
|
enum { FunctionCount = sizeof(funcs) / sizeof(*funcs) };
|
||||||
for (int i = 0; i < FunctionCount; i++) {
|
for (auto func : funcs) {
|
||||||
const auto &it = funcs[i];
|
if (FARPROC addr = ::GetProcAddress(h, func.functionName)) {
|
||||||
if (FARPROC addr = ::GetProcAddress(h, it.functionName)) {
|
|
||||||
hp.address = (DWORD)addr;
|
hp.address = (DWORD)addr;
|
||||||
hp.type = it.hookType;
|
hp.type = func.hookType;
|
||||||
hp.filter_fun = NoAsciiFilter;
|
hp.filter_fun = NoAsciiFilter;
|
||||||
hp.offset = it.textIndex * 4;
|
hp.offset = func.textIndex * 4;
|
||||||
hp.length_offset = it.lengthIndex * 4;
|
hp.length_offset = func.lengthIndex * 4;
|
||||||
hp.text_fun = (HookParam::text_fun_t)it.text_fun;
|
hp.text_fun = (decltype(hp.text_fun))func.text_fun;
|
||||||
ConsoleOutput("vnreng: Mono: INSERT");
|
ConsoleOutput("vnreng: Mono: INSERT");
|
||||||
NewHook(hp, it.functionName);
|
NewHook(hp, func.functionName);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user