Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion HippoMocks/hippomocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ extern "C" __declspec(dllimport) void WINCALL DebugBreak();
#define SOME_ARM
#endif

#if defined(__x86_64__) || defined(_M_X64)
#if defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__)
#define CMOCK_FUNC_PLATFORMIS64BIT
#endif

Expand Down Expand Up @@ -307,6 +307,12 @@ class Replace
Unprotect _allow_write(origFunc, sizeof(backupData));
memcpy(backupData, origFunc, sizeof(backupData));

#ifdef CMOCK_FUNC_PLATFORMIS64BIT
unsigned int *rawptr = (unsigned int *)origFunc;
rawptr[0] = 0x58000051;
rawptr[1] = 0xD61F0220;
*(long long*)(horrible_cast<intptr_t>(origFunc) + 8) = (long long)(horrible_cast<intptr_t>(replacement));
#else
unsigned int *rawptr = (unsigned int *)((intptr_t)(origFunc) & (~3));
if ((intptr_t)origFunc & 1) {
rawptr[0] = 0x6800A001;
Expand All @@ -317,6 +323,8 @@ class Replace
rawptr[1] = (intptr_t)replacement;
rawptr[2] = (intptr_t)replacement;
}
#endif

__clear_cache((char *)rawptr, (char *)rawptr+16);
#endif
}
Expand Down