Add option to enable/disable hook

This commit is contained in:
beerpsi 2024-04-16 01:27:48 +07:00
parent c895c275cf
commit 3c2609798b
3 changed files with 9 additions and 0 deletions

View File

@ -1,6 +1,8 @@
#include "config.h"
void unity_config_load(struct unity_config *cfg, const wchar_t *filename) {
cfg->enable = GetPrivateProfileIntW(L"unity",L"enable",1,filename);
GetPrivateProfileStringW(
L"unity",
L"targetAssembly",

View File

@ -1,8 +1,11 @@
#pragma once
#include <stdbool.h>
#include <windows.h>
struct unity_config {
bool enable;
wchar_t target_assembly[MAX_PATH];
};

View File

@ -34,6 +34,10 @@ static const struct hook_symbol unity_kernel32_syms[] = {
void unity_hook_init(const struct unity_config *cfg, HINSTANCE self) {
assert(cfg != NULL);
if (!cfg->enable) {
return;
}
if (unity_hook_initted) {
return;
}