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