From b7c1dd005e8122fec9518e3b89003722ea69e96b Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Wed, 22 Jun 2022 10:01:56 -0600 Subject: [PATCH] kern_start.cpp: Add VMM patching in Ventura --- Changelog.md | 1 + FeatureUnlock/kern_dyld_patch.hpp | 14 +++++++++++++- FeatureUnlock/kern_start.cpp | 11 +++++++++++ README.md | 1 + 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 3c0760c..614962f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,7 @@ FeatureUnlock Changelog ====================== ### v1.0.9 - Added constants for macOS 13 support +- Added AirPlay to Mac unlocking for systems with `kern.hv_vmm_present` set to `1` in Ventura ### v1.0.8 - Add AirPlay to Mac patching for Macmini8,1 diff --git a/FeatureUnlock/kern_dyld_patch.hpp b/FeatureUnlock/kern_dyld_patch.hpp index d752c87..b4f32ea 100644 --- a/FeatureUnlock/kern_dyld_patch.hpp +++ b/FeatureUnlock/kern_dyld_patch.hpp @@ -228,7 +228,7 @@ static const uint8_t kSidecariPadModelPatched[] = { 0x68, 0x50, 0x61, 0x64, 0x36, 0x2C, 0x31, 0x32 }; -// AirPlayCore.framework +// AirPlaySupport.framework // Replaces Mac with Nac static const uint8_t kMacModelAirplayExtendedOriginal[] = { // iMac17,1 iMac18,1 iMac18,2 iMac18,3 @@ -264,6 +264,18 @@ static const uint8_t kMacModelAirplayExtendedPatched[] = { 0x4E, 0x61, 0x63, // 0x4E, 0x69, 0x6E, 0x69, 0x38, 0x2C, 0x31 // 12.0 - 12.3 B1 is MacMini8,1, 12.3 B2+ is Macmini8,1 }; +static const uint8_t kAirPlayVmmOriginal[] = { + // p2pAllow kern.hv_vmm_present + 0x70, 0x32, 0x70, 0x41, 0x6C, 0x6C, 0x6F, 0x77, 0x00, + 0x6B, 0x65, 0x72, 0x6E, 0x2E, 0x68, 0x76, 0x5F, 0x76, 0x6D, 0x6D, 0x5F, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6E, 0x74 +}; + +static const uint8_t kAirPlayVmmPatched[] = { + // p2pAllow kern.hv_acidanthera + 0x70, 0x32, 0x70, 0x41, 0x6C, 0x6C, 0x6F, 0x77, 0x00, + 0x6B, 0x65, 0x72, 0x6E, 0x2E, 0x68, 0x76, 0x5F, 0x61, 0x63, 0x69, 0x64, 0x61, 0x6E, 0x74, 0x68, 0x65, 0x72, 0x61 +}; + #pragma mark - NightShift Patch Set // CoreBrightness.framework diff --git a/FeatureUnlock/kern_start.cpp b/FeatureUnlock/kern_start.cpp index 718a8ac..c99d3c5 100644 --- a/FeatureUnlock/kern_start.cpp +++ b/FeatureUnlock/kern_start.cpp @@ -26,6 +26,7 @@ bool os_supports_nightshift_old; bool os_supports_nightshift_new; bool os_supports_sidecar; bool os_supports_airplay_to_mac; +bool os_supports_airplay_to_mac_vmm_checks; bool os_supports_universal_control; bool model_is_iMac; @@ -128,6 +129,9 @@ static void patched_cs_validate_page(vnode_t vp, memory_object_t pager, memory_o if (os_supports_airplay_to_mac && (model_is_MacBookPro_2016_2017 || model_is_iMac_2015_17 || model_is_Macmini_2018)) { searchAndPatch(data, PAGE_SIZE, path, kMacModelAirplayExtendedOriginal, kMacModelAirplayExtendedPatched, "AirPlay to Mac (Extended)", true); } + if (os_supports_airplay_to_mac_vmm_checks) { + searchAndPatch(data, PAGE_SIZE, path, kAirPlayVmmOriginal, kAirPlayVmmPatched, "AirPlay to Mac (VMM)", true); + } } if (allow_sidecar_ipad && os_supports_sidecar) { searchAndPatch(data, PAGE_SIZE, path, kSidecariPadModelOriginal, kSidecariPadModelPatched, "Sidecar (iPad)", true); @@ -239,6 +243,10 @@ static void detectSupportedPatchSets() { os_supports_universal_control = true; } } + if (getKernelVersion() >= KernelVersion::Ventura) { + // Apple added kern.hv_vmm_present checks in Ventura, in addition to their normal model checks... + os_supports_airplay_to_mac_vmm_checks = true; + } } static void detectNumberOfPatches() { @@ -257,6 +265,9 @@ static void detectNumberOfPatches() { if (!disable_universal_control && os_supports_universal_control && model_needs_uc_patch) { total_allowed_loops++; } + if (os_supports_airplay_to_mac_vmm_checks) { + total_allowed_loops++; + } } } if (allow_sidecar_ipad) { diff --git a/README.md b/README.md index aca3f2e..147327d 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ MacBookPro9,x - MacBookPro14,x Macmini6,x - Macmini8,1 MacPro5,1 - MacPro6,1 iMac13,x - iMac18,x +Systems with 'kern.hv_vmm_present' set to as 1 (Ventura and newer) # NightShift Unlock MacBook1,1 - MacBook7,1