inital commit of the tester
This commit is contained in:
17
tester/abstracthook.h
Normal file
17
tester/abstracthook.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
class AbstractHookEngine {
|
||||
private:
|
||||
const char* name_;
|
||||
public:
|
||||
AbstractHookEngine(const char* name) : name_(name) {
|
||||
|
||||
}
|
||||
|
||||
virtual bool hook_all() = 0;
|
||||
virtual bool unhook_all() = 0;
|
||||
virtual bool all_hooked() = 0;
|
||||
|
||||
const char* name() {
|
||||
return name_;
|
||||
}
|
||||
};
|
||||
@@ -1,9 +1,24 @@
|
||||
#include <Windows.h>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include "../test_cases/test_cases.h"
|
||||
|
||||
#pragma comment(lib, "..\\x64\\debug\\test_cases.lib")
|
||||
#include "abstracthook.h"
|
||||
#include "mhook.h"
|
||||
|
||||
#pragma comment(lib, "..\\x64\\release\\test_cases.lib")
|
||||
|
||||
extern AbstractHookEngine* g_mhook;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
SelfTest();
|
||||
AbstractHookEngine* engines[] = {
|
||||
g_mhook,
|
||||
};
|
||||
|
||||
for(auto&& x : engines) {
|
||||
x->hook_all();
|
||||
SelfTest();
|
||||
std::cout << x->name() << ':' << x->all_hooked() << '\n';
|
||||
x->unhook_all();
|
||||
}
|
||||
}
|
||||
28
tester/mhook.cpp
Normal file
28
tester/mhook.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <Windows.h>
|
||||
#include <cstdint>
|
||||
#include "../third_party/mhook/mhook-lib/mhook.h"
|
||||
#include "typedefs.h"
|
||||
#include "abstracthook.h"
|
||||
#include "mhook.h"
|
||||
|
||||
#pragma comment(lib, "..\\x64\\debug\\test_cases.lib")
|
||||
|
||||
static TypeSmall trueSmall = &_small;
|
||||
|
||||
AbstractHookEngine* g_mhook = new MHook();
|
||||
|
||||
static uint64_t hookSmall(void) {
|
||||
return trueSmall();
|
||||
}
|
||||
|
||||
bool MHook::hook_all(void) {
|
||||
return Mhook_SetHook((PVOID*)&trueSmall, hookSmall);
|
||||
}
|
||||
|
||||
bool MHook::unhook_all() {
|
||||
return Mhook_Unhook((PVOID*)&trueSmall);
|
||||
}
|
||||
|
||||
bool MHook::all_hooked() {
|
||||
return true;
|
||||
}
|
||||
11
tester/mhook.h
Normal file
11
tester/mhook.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
class MHook : public AbstractHookEngine {
|
||||
public:
|
||||
bool hook_all();
|
||||
bool unhook_all();
|
||||
bool all_hooked();
|
||||
|
||||
MHook() : AbstractHookEngine("MHook") {
|
||||
|
||||
}
|
||||
};
|
||||
@@ -143,11 +143,24 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>test_cases.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="mhook.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="abstracthook.h" />
|
||||
<ClInclude Include="mhook.h" />
|
||||
<ClInclude Include="typedefs.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Object Include="..\x64\Debug\cpu.obj" />
|
||||
<Object Include="..\x64\Debug\disasm.obj" />
|
||||
<Object Include="..\x64\Debug\disasm_x86.obj" />
|
||||
<Object Include="..\x64\Debug\mhook.obj" />
|
||||
<Object Include="..\x64\Debug\misc.obj" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
||||
@@ -18,5 +18,26 @@
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="mhook.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="typedefs.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="mhook.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="abstracthook.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Object Include="..\x64\Debug\mhook.obj" />
|
||||
<Object Include="..\x64\Debug\disasm.obj" />
|
||||
<Object Include="..\x64\Debug\disasm_x86.obj" />
|
||||
<Object Include="..\x64\Debug\misc.obj" />
|
||||
<Object Include="..\x64\Debug\cpu.obj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
4
tester/typedefs.h
Normal file
4
tester/typedefs.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
#include "../test_cases/test_cases.h"
|
||||
|
||||
typedef uint64_t(*TypeSmall)(void);
|
||||
Reference in New Issue
Block a user