MCPcopy Create free account
hub / github.com/KDAB/GammaRay / writeJmp

Function writeJmp

tests/hooktest/main.cpp:33–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31}
32
33void writeJmp(void *func, void *replacement)
34{
35 quint8 *cur = ( quint8 * )func;
36 quint8 *aligned = ( quint8 * )page_align(cur);
37 assert(mprotect(aligned, 0xFFFF, PROT_READ | PROT_WRITE | PROT_EXEC) == 0);
38
39 *cur = 0xff;
40 *(++cur) = 0x25;
41
42 *(( quint32 * )++cur) = 0;
43 cur += sizeof(quint32);
44 *(( quint64 * )cur) = ( quint64 )replacement;
45
46 assert(mprotect(aligned, 0xFFFF, PROT_READ | PROT_EXEC) == 0);
47}
48
49void test()
50{

Callers 1

mainFunction · 0.85

Calls 1

page_alignFunction · 0.85

Tested by

no test coverage detected