lots of work, added atomic queue, changed githuyb workflows and added patterns with memory functions. Changed from MS Detours to MinHook.

now works with lua prototype
This commit is contained in:
Anonymous275
2022-02-22 16:19:53 +02:00
parent 6dfeba1e49
commit 19d7120b13
22 changed files with 189 additions and 164 deletions

48
include/Memory/Hook.h Normal file
View File

@@ -0,0 +1,48 @@
///
/// Created by Anonymous275 on 1/21/22
/// Copyright (c) 2021-present Anonymous275 read the LICENSE file for more info.
///
#define WIN32_LEAN_AND_MEAN
#include "Memory/Memory.h"
#include <MinHook.h>
#pragma once
template <class FuncType>
class Hook {
FuncType targetPtr;
FuncType detourFunc;
bool Attached = false;
public:
Hook(FuncType src, FuncType dest) : targetPtr(src), detourFunc(dest) {
auto status = MH_CreateHook((void*)targetPtr, (void*)detourFunc, (void**)&Original);
if(status != MH_OK) {
Memory::Print(std::string("MH Error -> ") + MH_StatusToString(status));
return;
}
}
void Enable() {
if(!Attached){
auto status = MH_EnableHook((void*)targetPtr);
if(status != MH_OK) {
Memory::Print(std::string("MH Error -> ") + MH_StatusToString(status));
return;
}
Attached = true;
}
}
void Disable() {
if(Attached){
auto status = MH_DisableHook((void*)targetPtr);
if(status != MH_OK) {
Memory::Print(std::string("MH Error -> ") + MH_StatusToString(status));
return;
}
Attached = false;
}
}
FuncType Original{};
};