switched to new capnhook, updated unityhook, added LED 15093 to MU3

This commit is contained in:
2024-05-12 19:36:08 +02:00
parent 1069cfee26
commit 517469a60c
27 changed files with 406 additions and 186 deletions

View File

@ -8,7 +8,7 @@
#include <pathcch.h>
#include <psapi.h>
#include "hooklib/procaddr.h"
#include "hook/procaddr.h"
#include "util/dprintf.h"
#include "doorstop.h"
@ -37,7 +37,7 @@ void doorstop_mono_hook_init(const struct unity_config *cfg, HINSTANCE module) {
memcpy(&unity_config, cfg, sizeof(*cfg));
load_mono_functions(module);
proc_addr_table_push(module_name, unity_mono_syms, _countof(unity_mono_syms));
proc_addr_table_push(NULL, module_name, unity_mono_syms, _countof(unity_mono_syms));
doorstop_hook_initted = true;
}

View File

@ -2,7 +2,16 @@
#include <stdbool.h>
#include "hook/table.h"
#include "hook/procaddr.h"
#include "hook/iohook.h"
#include "hooklib/dll.h"
#include "hooklib/path.h"
#include "hooklib/printer.h"
#include "hooklib/reg.h"
#include "hooklib/touch.h"
#include "hooklib/serial.h"
#include "util/dprintf.h"
#include "doorstop.h"
@ -15,22 +24,35 @@ static const wchar_t *target_modules[] = {
L"mono.dll",
L"mono-2.0-bdwgc.dll",
L"cri_ware_unity.dll",
L"SerialPortAPI.dll",
L"C300usb.dll",
L"C300FWDLusb.dll",
L"apmled.dll",
L"apmmount.dll",
};
static const size_t target_modules_len = _countof(target_modules);
static void dll_hook_insert_hooks(HMODULE target);
static HMODULE WINAPI my_LoadLibraryW(const wchar_t *name);
static HMODULE WINAPI hook_LoadLibraryW(const wchar_t *name);
static HMODULE (WINAPI *next_LoadLibraryW)(const wchar_t *name);
static HMODULE WINAPI hook_LoadLibraryExW(const wchar_t *name, HANDLE hFile, DWORD dwFlags);
static HMODULE (WINAPI *next_LoadLibraryExW)(const wchar_t *name, HANDLE hFile, DWORD dwFlags);
static const struct hook_symbol unity_kernel32_syms[] = {
{
.name = "LoadLibraryW",
.patch = my_LoadLibraryW,
.patch = hook_LoadLibraryW,
.link = (void **) &next_LoadLibraryW,
},
}, {
.name = "LoadLibraryExW",
.patch = hook_LoadLibraryExW,
.link = (void **) &next_LoadLibraryExW,
}
};
void unity_hook_init(const struct unity_config *cfg, HINSTANCE self) {
assert(cfg != NULL);
@ -57,7 +79,14 @@ static void dll_hook_insert_hooks(HMODULE target) {
_countof(unity_kernel32_syms));
}
static HMODULE WINAPI my_LoadLibraryW(const wchar_t *name) {
static HMODULE WINAPI hook_LoadLibraryExW(const wchar_t *name, HANDLE hFile, DWORD dwFlags)
{
// dprintf("Unity: LoadLibraryExW %ls\n", name);
return hook_LoadLibraryW(name);
}
static HMODULE WINAPI hook_LoadLibraryW(const wchar_t *name)
{
const wchar_t *name_end;
const wchar_t *target_module;
bool already_loaded;
@ -107,6 +136,14 @@ static HMODULE WINAPI my_LoadLibraryW(const wchar_t *name) {
dll_hook_insert_hooks(result);
path_hook_insert_hooks(result);
// printer_hook_insert_hooks(result);
reg_hook_insert_hooks(result);
proc_addr_insert_hooks(result);
serial_hook_apply_hooks(result);
iohook_apply_hooks(result);
}
}