diff --git a/tests/cpp-stub/cpp_stub.h b/tests/cpp-stub/cpp_stub.h index 6d6b13a9fe..e74fb0a62d 100644 --- a/tests/cpp-stub/cpp_stub.h +++ b/tests/cpp-stub/cpp_stub.h @@ -124,8 +124,11 @@ //5 byte(jmp rel32) #define REPLACE_NEAR(t, fn, fn_stub)\ + do{\ + const int addr = fn_stub - fn - CODESIZE_MIN;\ *fn = 0xE9;\ - *(int *)(fn + 1) = (int)(fn_stub - fn - CODESIZE_MIN);\ + memcpy((int *)(fn + 1), &addr, sizeof(int));\ + }while(false) //CACHEFLUSH((char *)fn, CODESIZE); #endif