Kaynağa Gözat

add advanced_instructions with mhook

master
aaaaaa aaaaaaa 7 yıl önce
ebeveyn
işleme
21fa828b4c
4 değiştirilmiş dosya ile 32 ekleme ve 2 silme
  1. +3
    -0
      tester/abstracthook.h
  2. +19
    -1
      tester/mhook.cpp
  3. +5
    -0
      tester/mhook.h
  4. +5
    -1
      tester/typedefs.h

+ 3
- 0
tester/abstracthook.h Dosyayı Görüntüle

@@ -9,6 +9,9 @@ public:
bool small_;
bool branch;
bool rip_relative;

bool avx;
bool rdrand;
};
public:
AbstractHookEngine(const char* name) : name_(name) {

+ 19
- 1
tester/mhook.cpp Dosyayı Görüntüle

@@ -10,6 +10,8 @@
static TypeSmall trueSmall = &_small;
static TypeBranch trueBranch = &_branch;
static TypeRip_relative trueRip_Relative = &_rip_relative;
static TypeAVX trueAVX = &_AVX;
static TypeRDRAND trueRDRAND = &_RDRAND;

AbstractHookEngine* g_mhook = new MHook();

@@ -31,16 +33,32 @@ uint64_t MHook_Hooks::hookRip_relative(void) {
return trueRip_Relative();
}

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

return trueAVX(num, res);
}

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

return trueRDRAND();
}

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);

return ret;
}

bool MHook::unhook_all() {
return Mhook_Unhook((PVOID*)&trueSmall) &&
Mhook_Unhook((PVOID*)&trueBranch) &&
Mhook_Unhook((PVOID*)&trueRip_Relative);
Mhook_Unhook((PVOID*)&trueAVX) &&
Mhook_Unhook((PVOID*)&trueRDRAND);
}

+ 5
- 0
tester/mhook.h Dosyayı Görüntüle

@@ -4,6 +4,8 @@ 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);
};

class MHook : public AbstractHookEngine {
@@ -18,4 +20,7 @@ public:
friend uint64_t MHook_Hooks::hookSmall(void);
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);
};

+ 5
- 1
tester/typedefs.h Dosyayı Görüntüle

@@ -5,4 +5,8 @@ typedef uint64_t(*TypeSmall)(void);

typedef uint64_t (*TypeBranch)(uint64_t);

typedef uint64_t (*TypeRip_relative)(void);
typedef uint64_t (*TypeRip_relative)(void);

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

typedef uint32_t (*TypeRDRAND)(void);

Yükleniyor…
İptal
Kaydet