Bladeren bron

add backwards mhook tests

master
aaaaaa aaaaaaa 7 jaren geleden
bovenliggende
commit
605d03c0f5
4 gewijzigde bestanden met toevoegingen van 40 en 10 verwijderingen
  1. +3
    -0
      tester/abstracthook.h
  2. +24
    -5
      tester/mhook.cpp
  3. +8
    -4
      tester/mhook.h
  4. +5
    -1
      tester/typedefs.h

+ 3
- 0
tester/abstracthook.h Bestand weergeven

@@ -12,6 +12,9 @@ public:

bool avx;
bool rdrand;

bool loop;
bool tail_recursion;
};
public:
AbstractHookEngine(const char* name) : name_(name) {

+ 24
- 5
tester/mhook.cpp Bestand weergeven

@@ -12,6 +12,8 @@ static TypeBranch trueBranch = &_branch;
static TypeRip_relative trueRip_Relative = &_rip_relative;
static TypeAVX trueAVX = &_AVX;
static TypeRDRAND trueRDRAND = &_RDRAND;
static TypeLoop trueLoop = &_loop;
static TypeTailRecursion trueTailRecursion = &_tail_recursion;

AbstractHookEngine* g_mhook = new MHook();

@@ -33,25 +35,40 @@ uint64_t MHook_Hooks::hookRip_relative(void) {
return trueRip_Relative();
}

void MHook_Hooks::_AVX(float num, void* res) {
void MHook_Hooks::hookAVX(float num, void* res) {
g_mhook->avx = true;

return trueAVX(num, res);
}

uint32_t MHook_Hooks::_RDRAND(void) {
uint32_t MHook_Hooks::hookRDRAND(void) {
g_mhook->rdrand = true;

return trueRDRAND();
}

uint32_t MHook_Hooks::hookLoop(uint32_t num, uint32_t cnt) {
g_mhook->loop = true;

return trueLoop(num, cnt);
}

uint32_t MHook_Hooks::hookTail_recursion(uint32_t x) {
g_mhook->tail_recursion = true;

return trueTailRecursion(x);
}

bool MHook::hook_all(void) {
bool ret = Mhook_SetHook((PVOID*)&trueSmall, &MHook_Hooks::hookSmall);
ret |= Mhook_SetHook((PVOID*)&trueBranch, &MHook_Hooks::hookBranch);
ret |= Mhook_SetHook((PVOID*)&trueRip_Relative, &MHook_Hooks::hookRip_relative);

ret |= Mhook_SetHook((PVOID*)&trueAVX, &MHook_Hooks::_AVX);
ret |= Mhook_SetHook((PVOID*)&trueRDRAND, &MHook_Hooks::_RDRAND);
ret |= Mhook_SetHook((PVOID*)&trueAVX, &MHook_Hooks::hookAVX);
ret |= Mhook_SetHook((PVOID*)&trueRDRAND, &MHook_Hooks::hookRDRAND);

ret |= Mhook_SetHook((PVOID*)&trueLoop, &MHook_Hooks::hookLoop);
ret |= Mhook_SetHook((PVOID*)&trueTailRecursion, &MHook_Hooks::hookTail_recursion);

return ret;
}
@@ -60,5 +77,7 @@ bool MHook::unhook_all() {
return Mhook_Unhook((PVOID*)&trueSmall) &&
Mhook_Unhook((PVOID*)&trueBranch) &&
Mhook_Unhook((PVOID*)&trueAVX) &&
Mhook_Unhook((PVOID*)&trueRDRAND);
Mhook_Unhook((PVOID*)&trueRDRAND) &&
Mhook_Unhook((PVOID*)&trueLoop) &&
Mhook_Unhook((PVOID*)&trueTailRecursion);
}

+ 8
- 4
tester/mhook.h Bestand weergeven

@@ -4,8 +4,10 @@ namespace MHook_Hooks {
uint64_t hookSmall(void);
uint64_t hookBranch(uint64_t);
uint64_t hookRip_relative(void);
void _AVX(float num, void* res);
uint32_t _RDRAND(void);
void hookAVX(float num, void* res);
uint32_t hookRDRAND(void);
uint32_t hookLoop(uint32_t num, uint32_t cnt);
uint32_t hookTail_recursion(uint32_t x);
};

class MHook : public AbstractHookEngine {
@@ -21,6 +23,8 @@ public:
friend uint64_t MHook_Hooks::hookBranch(uint64_t);
friend uint64_t MHook_Hooks::hookRip_relative(void);
friend void MHook_Hooks::_AVX(float num, void* res);
friend uint32_t MHook_Hooks::_RDRAND(void);
friend void MHook_Hooks::hookAVX(float num, void* res);
friend uint32_t MHook_Hooks::hookRDRAND(void);
friend uint32_t MHook_Hooks::hookLoop(uint32_t num, uint32_t cnt);
friend uint32_t MHook_Hooks::hookTail_recursion(uint32_t x);
};

+ 5
- 1
tester/typedefs.h Bestand weergeven

@@ -9,4 +9,8 @@ typedef uint64_t (*TypeRip_relative)(void);

typedef void (*TypeAVX)(float num, void* res);

typedef uint32_t (*TypeRDRAND)(void);
typedef uint32_t (*TypeRDRAND)(void);

typedef uint32_t (*TypeLoop)(uint32_t num, uint32_t cnt);

typedef uint32_t (*TypeTailRecursion)(uint32_t x);

Laden…
Annuleren
Opslaan