MCPcopy Create free account
hub / github.com/Atarity/Lightpack / vfTableHookTestCase

Method vfTableHookTestCase

Software/tests/HooksTest.cpp:47–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47void HooksTest::vfTableHookTestCase() {
48// Mockup of target memory v-- our target starts here, first byte is to be sure we haven't broken it
49 unsigned char procMockup[8] ={0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22};
50
51// Original memory mockup to compare with
52 unsigned char procUntouchedMockup[8]={0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22};
53
54// Hooked memory mockup | absolute address |
55 unsigned char procHookedMockup[8] ={0x22,0x00,0x00,0x00,0x00,0x22,0x22,0x22};
56
57 unsigned int substAdr=0x12345678;
58
59 memcpy(procHookedMockup+1, &substAdr, sizeof(substAdr));
60
61 ProxyFuncVFTable *test = new ProxyFuncVFTable(procMockup+1, (void *)substAdr, Logger::getInstance());
62 QVERIFY2(!test->isHookInstalled(),"Hook shouldn't be installed");
63 QVERIFY2(test->init(), "init crashed");
64 QVERIFY2(test->installHook(), "installHook crashed 1");
65 QVERIFY2(test->isHookInstalled(),"Hook should be installed");
66
67 QVERIFY2(memcmp(procMockup, procHookedMockup, 8)==0,"Hook has been installed incorrectly");
68
69 QVERIFY2(test->removeHook(), "removeHook crashed");
70
71 QVERIFY2(memcmp(procMockup, procUntouchedMockup, 8)==0,"Hook has been removed incorrectly 1");
72
73 QVERIFY2(test->installHook(), "installHook crashed 2");
74
75 delete test;
76
77 QVERIFY2(memcmp(procMockup, procUntouchedMockup, 8)==0,"Hook should be removed after object deletion");
78}
79
80void HooksTest::reportLogTestCase() {
81

Callers

nothing calls this directly

Calls 4

isHookInstalledMethod · 0.45
initMethod · 0.45
installHookMethod · 0.45
removeHookMethod · 0.45

Tested by

no test coverage detected