Skip to content

Commit

Permalink
kern_start.cpp: Add VMM patching in Ventura
Browse files Browse the repository at this point in the history
  • Loading branch information
khronokernel committed Jun 22, 2022
1 parent 66ce42b commit b7c1dd0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion FeatureUnlock/kern_dyld_patch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions FeatureUnlock/kern_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b7c1dd0

Please sign in to comment.