From 94e29ce135001ad07cf456e594f5989a80c39146 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Fri, 16 Dec 2022 09:17:32 -0700 Subject: [PATCH] kern_start: Patch ControlCenter.app Closes https://github.com/acidanthera/bugtracker/issues/2181 --- Changelog.md | 4 ++++ FeatureUnlock/kern_start.cpp | 10 ++++++++++ FeatureUnlock/kern_usr_patch.hpp | 16 ++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/Changelog.md b/Changelog.md index 4b89aa4..a40126f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ FeatureUnlock Changelog ====================== +### v1.1.2 +- Add AirPlay to Mac unlocking inside Control Center.app + - Applicable for macOS Ventura + ### v1.1.1 - Resolved Macmini8,1 patch regression from 1.1.0 - Resolved iPad Sidecar patch regression from 1.1.0 diff --git a/FeatureUnlock/kern_start.cpp b/FeatureUnlock/kern_start.cpp index 4f5cc0b..667cad6 100644 --- a/FeatureUnlock/kern_start.cpp +++ b/FeatureUnlock/kern_start.cpp @@ -77,6 +77,7 @@ bool has_applied_nightshift_patch; bool has_applied_airplay_to_mac_vmm_patch; bool has_applied_iPad_sidecar_patch; bool has_applied_uc_app_patch; +bool has_applied_cc_app_patch; // Misc variables @@ -324,6 +325,15 @@ static void patched_cs_validate_page(vnode_t vp, memory_object_t pager, memory_o } } } + if (!has_applied_cc_app_patch && host_needs_airplay_to_mac_vmm_patch) { + if (UNLIKELY(strcmp(path, controlCenterPath) == 0)) { + patch_result = searchAndPatch(data, PAGE_SIZE, path, kGenericVmmOriginal, kGenericVmmPatched, "Control Center (app)", false); + if (patch_result) { + has_applied_cc_app_patch = true; + return; + } + } + } } } } diff --git a/FeatureUnlock/kern_usr_patch.hpp b/FeatureUnlock/kern_usr_patch.hpp index 80d84e3..d8c481a 100644 --- a/FeatureUnlock/kern_usr_patch.hpp +++ b/FeatureUnlock/kern_usr_patch.hpp @@ -66,3 +66,19 @@ static const uint8_t kUniversalControlReplace[] = { 0x4E, 0x61, 0x63, 0x6D, 0x69, 0x6E, 0x69, 0x37, 0x2C, 0x31, 0x00, 0x4E, 0x61, 0x63, 0x50, 0x72, 0x6F, 0x36, 0x2C, 0x31 }; + +#pragma mark - ControlCenter Patch Set + +// With macOS 13.0, Apple added additional AirPlay to Mac blacklists inside of ControlCenter.app +// Specifically a kern.hv_vmm_present check +static const char *controlCenterPath = "/System/Library/CoreServices/ControlCenter.app/Contents/MacOS/ControlCenter"; + +static const uint8_t kGenericVmmOriginal[] = { + // kern.hv_vmm_present + 0x6B, 0x65, 0x72, 0x6E, 0x2E, 0x68, 0x76, 0x5F, 0x76, 0x6D, 0x6D, 0x5F, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6E, 0x74 +}; + +static const uint8_t kGenericVmmPatched[] = { + // kern.hv_acidanthera + 0x6B, 0x65, 0x72, 0x6E, 0x2E, 0x68, 0x76, 0x5F, 0x61, 0x63, 0x69, 0x64, 0x61, 0x6E, 0x74, 0x68, 0x65, 0x72, 0x61 +};