Skip to content

Commit

Permalink
#1235 POC: remove space animation when using cmd+tab
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Apr 19, 2022
1 parent 910fb43 commit f9a7727
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/osax/arm64/payload.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ uint64_t get_dppm_offset(NSOperatingSystemVersion os_version) {
return 0;
}

uint64_t get_fix_animation_offset(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 12) {
return 0x0;
}

return 0;
}

uint64_t get_add_space_offset(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 12) {
return 0x220000;
Expand Down Expand Up @@ -68,6 +76,14 @@ uint64_t get_set_front_window_offset(NSOperatingSystemVersion os_version) {
return NULL;
}

const char *get_fix_animation_pattern(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 12) {
return NULL;
}

return NULL;
}

const char *get_add_space_pattern(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 12) {
return "7F 23 03 D5 FF C3 01 D1 E1 03 1E AA ?? ?? 00 94 FE 03 01 AA FD 7B 06 A9 FD 83 01 91 F5 03 14 AA F3 03 00 AA 89 E2 40 39 96 16 40 F9 C8 FE 7E D3 3F 05 00 71 A1 00 00 54 ?? 14 00 B5 C8 E2 7D 92 17 09 40 F9 ?? 00 00 14 ?? ?? 00 B5 C8 E2 7D 92 17 09 40 F9 ?? ?? 00 94 ?? ?? 00 B4 F8 06 00 F1 ?? 15 00 54 DA 0A 42 F2 E1 17 9F 1A E0 03 18 AA E2 03 16 AA ?? ?? FD 97 ?? 14 00 B5 C8 0E 18 8B ?? ?? 00 94 F4 03 00 AA";
Expand Down
16 changes: 16 additions & 0 deletions src/osax/payload.m
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,22 @@ static void init_instances()
#endif
}

uint64_t animation_time_addr = hex_find_seq(baseaddr + get_fix_animation_offset(os_version), get_fix_animation_pattern(os_version));
if (animation_time_addr == 0x0) {
NSLog(@"[yabai-sa] failed to get pointer to animation-time..");
} else {
#ifdef __x86_64__
uint8_t *offset_instr = (uint8_t *) animation_time_addr + 4;
uint64_t offset_value = (offset_instr[3] << 24) + (offset_instr[2] << 16) + (offset_instr[1] << 8) + *offset_instr;
uint64_t target_addr = animation_time_addr + 8 + offset_value;

NSLog(@"[yabai-sa] (0x%llx) animation_time_addr found at address 0x%llX (0x%llx)", baseaddr, animation_time_addr, animation_time_addr - baseaddr);
vm_protect(mach_task_self(), target_addr, 8ULL, 0, 23);
*(double *)target_addr = 0.0001;
#elif __arm64__
#endif
}

managed_space = objc_getClass("Dock.ManagedSpace");
_connection = CGSMainConnectionID();
}
Expand Down
34 changes: 34 additions & 0 deletions src/osax/x86_64/payload.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ uint64_t get_dppm_offset(NSOperatingSystemVersion os_version) {
return 0;
}

uint64_t get_fix_animation_offset(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 12) {
return 0x0;
} else if ((os_version.majorVersion == 11) || (os_version.majorVersion == 10 && os_version.minorVersion == 16)) {
return 0x232000;
} else if (os_version.minorVersion == 15) {
return 0x0;
} else if (os_version.minorVersion == 14) {
return 0x0;
} else if (os_version.minorVersion == 13) {
return 0x0;
}

return 0;
}

uint64_t get_add_space_offset(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 12) {
return 0x230000;
Expand Down Expand Up @@ -150,6 +166,23 @@ uint64_t get_set_front_window_offset(NSOperatingSystemVersion os_version) {
return NULL;
}


const char *get_fix_animation_pattern(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 12) {
return NULL;
} else if ((os_version.majorVersion == 11) || (os_version.majorVersion == 10 && os_version.minorVersion == 16)) {
return "F2 0F 10 05 ?? ?? 0F 00 4C 89 EF 48 8B 75 B8 4C 89 F2 44 8B 45 A8 4C 8B 8D 28 FF FF FF 4C 8B 6D 98 50 56 6A 01 49 89 DF 53 41 54 E8 ?? ?? 08 00 48 83 C4 30 48 89 45 98";
} else if (os_version.minorVersion == 15) {
return NULL;
} else if (os_version.minorVersion == 14) {
return NULL;
} else if (os_version.minorVersion == 13) {
return NULL;
}

return NULL;
}

const char *get_add_space_pattern(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 12) {
return "55 48 89 E5 41 57 41 56 41 55 41 54 53 48 83 EC 18 48 89 7D D0 48 B8 01 00 00 00 00 00 00 40 49 BF F8 FF FF FF FF FF FF 00 4D 8B 65 28 4C 89 6D C8 41 80 7D 38 01 75 16 49 85 C4 0F 85 ?? 03 00 00 4D 21 FC 4D 8B 74 24 10 E9 ?? 01 00 00 49 85 C4 0F 85 ?? 03 00 00 4C 89 E0 4C 21 F8 4C 8B 70 10 4C 89 E7 E8 ?? ?? 0E 00 4D 85 F6 0F 84 ?? 01 00 00 4D 89 F7 49 FF CF 0F 80 ?? 03 00 00 48 BB 03 00 00 00 00 00 00 C0 31";
Expand Down Expand Up @@ -258,3 +291,4 @@ uint64_t get_set_front_window_offset(NSOperatingSystemVersion os_version) {

return NULL;
}

0 comments on commit f9a7727

Please sign in to comment.