inital commit of the tester
This commit is contained in:
@@ -6,6 +6,13 @@ MinimumVisualStudioVersion = 10.0.40219.1
|
|||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_cases", "test_cases\test_cases.vcxproj", "{8C444ABC-D25C-4B44-8F27-081B464D9AE4}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_cases", "test_cases\test_cases.vcxproj", "{8C444ABC-D25C-4B44-8F27-081B464D9AE4}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tester", "tester\tester.vcxproj", "{8182D1BA-E651-4668-9EC1-A3023AAFD5AC}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tester", "tester\tester.vcxproj", "{8182D1BA-E651-4668-9EC1-A3023AAFD5AC}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{8C444ABC-D25C-4B44-8F27-081B464D9AE4} = {8C444ABC-D25C-4B44-8F27-081B464D9AE4}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mhook-test", "third_party\mhook\mhook-test.vcxproj", "{0E055CAF-C68B-42CB-A302-F775CA5A917F}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PolyHook", "third_party\poly\PolyHook\PolyHook.vcxproj", "{64269F60-A538-4327-82EE-AB4BF4766CE9}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -31,6 +38,22 @@ Global
|
|||||||
{8182D1BA-E651-4668-9EC1-A3023AAFD5AC}.Release|x64.Build.0 = Release|x64
|
{8182D1BA-E651-4668-9EC1-A3023AAFD5AC}.Release|x64.Build.0 = Release|x64
|
||||||
{8182D1BA-E651-4668-9EC1-A3023AAFD5AC}.Release|x86.ActiveCfg = Release|Win32
|
{8182D1BA-E651-4668-9EC1-A3023AAFD5AC}.Release|x86.ActiveCfg = Release|Win32
|
||||||
{8182D1BA-E651-4668-9EC1-A3023AAFD5AC}.Release|x86.Build.0 = Release|Win32
|
{8182D1BA-E651-4668-9EC1-A3023AAFD5AC}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{0E055CAF-C68B-42CB-A302-F775CA5A917F}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{0E055CAF-C68B-42CB-A302-F775CA5A917F}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{0E055CAF-C68B-42CB-A302-F775CA5A917F}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{0E055CAF-C68B-42CB-A302-F775CA5A917F}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{0E055CAF-C68B-42CB-A302-F775CA5A917F}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{0E055CAF-C68B-42CB-A302-F775CA5A917F}.Release|x64.Build.0 = Release|x64
|
||||||
|
{0E055CAF-C68B-42CB-A302-F775CA5A917F}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{0E055CAF-C68B-42CB-A302-F775CA5A917F}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{64269F60-A538-4327-82EE-AB4BF4766CE9}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{64269F60-A538-4327-82EE-AB4BF4766CE9}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{64269F60-A538-4327-82EE-AB4BF4766CE9}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{64269F60-A538-4327-82EE-AB4BF4766CE9}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{64269F60-A538-4327-82EE-AB4BF4766CE9}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{64269F60-A538-4327-82EE-AB4BF4766CE9}.Release|x64.Build.0 = Release|x64
|
||||||
|
{64269F60-A538-4327-82EE-AB4BF4766CE9}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{64269F60-A538-4327-82EE-AB4BF4766CE9}.Release|x86.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
static Catch::Session session;
|
static Catch::Session session;
|
||||||
|
|
||||||
_declspec(dllexport) void SelfTest() {
|
void SelfTest() {
|
||||||
session.run();
|
session.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
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 <Windows.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <iostream>
|
||||||
#include "../test_cases/test_cases.h"
|
#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) {
|
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>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>test_cases.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="main.cpp" />
|
<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>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
|||||||
@@ -18,5 +18,26 @@
|
|||||||
<ClCompile Include="main.cpp">
|
<ClCompile Include="main.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</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>
|
</ItemGroup>
|
||||||
</Project>
|
</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