Sfoglia il codice sorgente

disable crashing hooks

master
aaaaaa aaaaaaa 6 anni fa
parent
commit
d27893167c
3 ha cambiato i file con 5 aggiunte e 43 eliminazioni
  1. +2
    -40
      tester/main.cpp
  2. +1
    -1
      tester/mhook.cpp
  3. +2
    -2
      tester/polyhook.cpp

+ 2
- 40
tester/main.cpp Vedi File

@@ -7,53 +7,15 @@

#include "abstracthook.h"


//#pragma comment(lib, "..\\x64\\debug\\test_cases.lib")

extern AbstractHookEngine* g_mhook,
*g_PolyHook,
*g_MinHook;

#if 0
typedef BOOL(__stdcall* tBitBlt)(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight,
HDC hdcSrc, int nXSrc, int nYSrc, DWORD dwRop);
tBitBlt oBitBlt;

//Just an int that gets incremented to verify handler got called for unit tests

int BitBltHookVerifier = 0;
BOOL __stdcall hkBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight,
HDC hdcSrc, int nXSrc, int nYSrc, DWORD dwRop)
{
BitBltHookVerifier += 1337;
return oBitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
}

void test()
{
std::shared_ptr<PLH::Detour> Detour_Ex(new PLH::Detour);
//REQUIRE(Detour_Ex->GetType() == PLH::HookType::Detour);

assert(BitBltHookVerifier == 0);
Detour_Ex->SetupHook((uint8_t*)GetProcAddress(LoadLibrary(L"Gdi32.dll"), "BitBlt"), (BYTE*)&hkBitBlt);
assert(Detour_Ex->Hook());
oBitBlt = Detour_Ex->GetOriginal<tBitBlt>();
BitBlt(NULL, 0, 0, 0, 0, NULL, 0, 0, 0);
assert(BitBltHookVerifier == 1337);
Detour_Ex->UnHook();
BitBlt(NULL, 0, 0, 0, 0, NULL, 0, 0, 0);
assert(BitBltHookVerifier == 1337);

std::cout << (Detour_Ex->GetLastError().GetSeverity() != PLH::RuntimeError::Severity::UnRecoverable) << '\n';
std::cout << (Detour_Ex->GetLastError().GetSeverity() != PLH::RuntimeError::Severity::Critical) << '\n';
}
#endif

int main(int argc, char** argv) {
AbstractHookEngine* engines[] = {
g_mhook,
g_PolyHook,
g_MinHook
g_MinHook,
g_mhook,
};

SelfTest();

+ 1
- 1
tester/mhook.cpp Vedi File

@@ -80,6 +80,6 @@ bool MHook::unhook_all() {
Mhook_Unhook((PVOID*)&trueBranch) &&
Mhook_Unhook((PVOID*)&trueAVX) &&
Mhook_Unhook((PVOID*)&trueRDRAND) &&
//Mhook_Unhook((PVOID*)&trueLoop) &&
Mhook_Unhook((PVOID*)&trueLoop) &&
Mhook_Unhook((PVOID*)&trueTailRecursion);
}

+ 2
- 2
tester/polyhook.cpp Vedi File

@@ -69,8 +69,8 @@ bool PolyHook::hook_all(void) {
ret |= hook<decltype(&_AVX)>(detAVX, getAVX(), trueAVX, &PolyHook_Hooks::hookAVX);
ret |= hook<decltype(&_RDRAND)>(detRDRAND, getRDRAND(), trueRDRAND, &PolyHook_Hooks::hookRDRAND);

ret |= hook<decltype(&_loop)>(detLoop, getLoop(), trueLoop, &PolyHook_Hooks::hookLoop);
ret |= hook<decltype(&_tail_recursion)>(detTailRecursion, getTailRecursion(), trueTailRecursion, &PolyHook_Hooks::hookTail_recursion);
//ret |= hook<decltype(&_loop)>(detLoop, getLoop(), trueLoop, &PolyHook_Hooks::hookLoop);
//ret |= hook<decltype(&_tail_recursion)>(detTailRecursion, getTailRecursion(), trueTailRecursion, &PolyHook_Hooks::hookTail_recursion);

return ret;
}

Loading…
Annulla
Salva