diff --git a/GUI/misc.h b/GUI/misc.h index c932300..900e839 100644 --- a/GUI/misc.h +++ b/GUI/misc.h @@ -2,12 +2,7 @@ #include "qtcommon.h" -struct QTextFile : QFile -{ - using QFile::QFile; - QTextFile(const QString& name, QIODevice::OpenMode mode) : QFile(name) { open(mode | QIODevice::Text); } -}; - +struct QTextFile : 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 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()); } diff --git a/include/types.h b/include/types.h index 36fa387..28f5ab6 100644 --- a/include/types.h +++ b/include/types.h @@ -50,11 +50,6 @@ private: // jichi 3/7/2014: Add guessed comment 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 int offset, // offset of the data in the memory index, // deref_offset1 @@ -71,9 +66,9 @@ struct HookParam short length_offset; // index of the string length DWORD user_value; // 7/20/2014: jichi additional parameters for PSP games - text_fun_t text_fun; - filter_fun_t filter_fun; - hook_fun_t hook_fun; + void(*text_fun)(DWORD stack, HookParam* hp, BYTE obsoleteAlwaysZero, DWORD* data, DWORD* split, DWORD* len); + bool(*filter_fun)(void* data, DWORD* len, HookParam* hp, BYTE obsoleteAlwaysZero); // jichi 10/24/2014: Add filter function. Return true if skip the text + 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]; }; diff --git a/vnrhook/engine/engine.cc b/vnrhook/engine/engine.cc index c6f5bd3..e6d8dc0 100644 --- a/vnrhook/engine/engine.cc +++ b/vnrhook/engine/engine.cc @@ -16639,17 +16639,16 @@ bool InsertMonoHooks() HookParam hp = {}; const MonoFunction funcs[] = { MONO_FUNCTIONS_INITIALIZER }; enum { FunctionCount = sizeof(funcs) / sizeof(*funcs) }; - for (int i = 0; i < FunctionCount; i++) { - const auto &it = funcs[i]; - if (FARPROC addr = ::GetProcAddress(h, it.functionName)) { + for (auto func : funcs) { + if (FARPROC addr = ::GetProcAddress(h, func.functionName)) { hp.address = (DWORD)addr; - hp.type = it.hookType; + hp.type = func.hookType; hp.filter_fun = NoAsciiFilter; - hp.offset = it.textIndex * 4; - hp.length_offset = it.lengthIndex * 4; - hp.text_fun = (HookParam::text_fun_t)it.text_fun; + hp.offset = func.textIndex * 4; + hp.length_offset = func.lengthIndex * 4; + hp.text_fun = (decltype(hp.text_fun))func.text_fun; ConsoleOutput("vnreng: Mono: INSERT"); - NewHook(hp, it.functionName); + NewHook(hp, func.functionName); ret = true; } }