Skip to content

Commit 1e02b52

Browse files
committed
FIX : supported apple silicon mac os
1 parent b9936f8 commit 1e02b52

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

CoreAudioFuzz/jackalope-modifications/function_hooks.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ limitations under the License.
1919
void HALSWriteSettingHook::OnFunctionEntered() {
2020
printf("HALS_SettingsManager::_WriteSetting Entered\n");
2121

22+
#if defined(__x86_64__)
2223
if (!GetRegister(RDX)) {
2324
printf("NULL plist passed as argument, returning to prevent NULL CFRelease\n");
2425
printf("Current $RSP: %p\n", GetRegister(RSP));
@@ -38,6 +39,27 @@ void HALSWriteSettingHook::OnFunctionEntered() {
3839

3940
printf("$RSP is now: %p\n", GetRegister(RSP));
4041
}
42+
#elif defined(__arm64__)
43+
// On Apple Silicon, use X2 instead of RDX, SP instead of RSP, PC instead of RIP
44+
if (!GetRegister(X2)) {
45+
printf("NULL plist passed as argument, returning to prevent NULL CFRelease\n");
46+
printf("Current SP: %p\n", GetRegister(SP));
47+
48+
void *return_address;
49+
RemoteRead((void*)GetRegister(SP), &return_address, sizeof(void *));
50+
printf("Current return address: %p\n", GetReturnAddress());
51+
printf("Current PC: %p\n", GetRegister(PC));
52+
53+
SetRegister(X0, 0); // X0 is usually return value on ARM64
54+
SetRegister(PC, GetReturnAddress());
55+
printf("PC register is now: %p\n", GetRegister(ARCH_PC));
56+
57+
SetRegister(SP, GetRegister(SP) + 8); // Simulate a return instruction
58+
printf("SP is now: %p\n", GetRegister(SP));
59+
}
60+
#else
61+
#error "Unsupported architecture"
62+
#endif
4163
}
4264

4365
FunctionHookInst::FunctionHookInst() {

0 commit comments

Comments
 (0)