This commit is contained in:
Akash Mozumdar 2019-02-02 16:54:13 -05:00
parent b7ec42ee4e
commit f74cd553c0
3 changed files with 11 additions and 22 deletions

View File

@ -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()); }

View File

@ -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];
};

View File

@ -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;
}
}