Skip to content

Commit 781b4b9

Browse files
committed
fixup, quick-fix for coolxv/cpp-stub#21
1 parent dfc3fc9 commit 781b4b9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/cpp-stub/cpp_stub.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@
124124

125125
//5 byte(jmp rel32)
126126
#define REPLACE_NEAR(t, fn, fn_stub)\
127+
do{\
128+
const int addr = fn_stub - fn - CODESIZE_MIN;\
127129
*fn = 0xE9;\
128-
*(int *)(fn + 1) = (int)(fn_stub - fn - CODESIZE_MIN);\
130+
memcpy((int *)(fn + 1), &addr, sizeof(int));\
131+
}while(false)
129132
//CACHEFLUSH((char *)fn, CODESIZE);
130133
#endif
131134

0 commit comments

Comments
 (0)