Skip to content

Commit

Permalink
SoftwareUpdate.cpp: Expand sbvmm to support more environments (#15)
Browse files Browse the repository at this point in the history
* SoftwareUpdate.cpp: Set VMM in installers

Ensures VMM checks always pass during OS installs, regardless of binary packaging

* RestrictEvents.cpp: Allow routing in recovery/installer

* SoftwareUpdate.cpp: Expand to Install.app support

* SoftwareUpdate.cpp: Set explicit runMode comparison

* Sync changelog
  • Loading branch information
khronokernel committed Sep 26, 2023
1 parent 9f45386 commit 0febd7e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
RestrictEvents Changelog
========================
#### v1.1.3
- Expanded `sbvmm` to support more environments:
- macOS install applications (ex. `Install macOS Sonoma.app`)
- Booted installer and recoveryOS
- `-no_compat_check` or boot.efi patch required to pass bootloaders' compatibility checks

#### v1.1.2
- Added constants for macOS 14 support

Expand Down
29 changes: 16 additions & 13 deletions RestrictEvents/RestrictEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ PluginConfiguration ADDPR(config) {
revassetIsSet = enableAssetPatching;
revsbvmmIsSet = enableSbvmmPatching;

if ((lilu.getRunMode() & LiluAPI::RunningNormal) != 0) {
if ((lilu.getRunMode() & LiluAPI::RunningNormal) != 0 || (lilu.getRunMode() & LiluAPI::AllowInstallerRecovery) != 0) {
if (enableMemoryUiPatching | enablePciUiPatching) {
// Rename existing values to invalid ones to avoid matching.
if (strcmp(di.modelIdentifier, "MacPro7,1") == 0) {
Expand Down Expand Up @@ -546,21 +546,24 @@ PluginConfiguration ADDPR(config) {
(getKernelVersion() >= KernelVersion::Monterey ||
(getKernelVersion() == KernelVersion::BigSur && getKernelMinorVersion() >= 4))) {
lilu.onPatcherLoadForce([](void *user, KernelPatcher &patcher) {
if (needsCpuNamePatch) RestrictEventsPolicy::calculatePatchedBrandString();
KernelPatcher::RouteRequest csRoute =
if ((lilu.getRunMode() & LiluAPI::RunningNormal) != 0) {
if (needsCpuNamePatch) RestrictEventsPolicy::calculatePatchedBrandString();
KernelPatcher::RouteRequest csRoute =
getKernelVersion() >= KernelVersion::BigSur ?
KernelPatcher::RouteRequest("_cs_validate_page", RestrictEventsPolicy::csValidatePageBigSur, orgCsValidateFunc) :
(getKernelVersion() >= KernelVersion::Sierra ?
KernelPatcher::RouteRequest("_cs_validate_range", RestrictEventsPolicy::csValidateRangeSierra, orgCsValidateFunc) :
KernelPatcher::RouteRequest("_cs_validate_page", RestrictEventsPolicy::csValidatePageMountainLion, orgCsValidateFunc));
if (getKernelVersion() < KernelVersion::Sierra) {
vnodePagerOpsKernel = reinterpret_cast<void *>(patcher.solveSymbol(KernelPatcher::KernelID, "_vnode_pager_ops"));
if (!vnodePagerOpsKernel)
SYSLOG("rev", "failed to solve _vnode_pager_ops");
(getKernelVersion() >= KernelVersion::Sierra ?
KernelPatcher::RouteRequest("_cs_validate_range", RestrictEventsPolicy::csValidateRangeSierra, orgCsValidateFunc) :
KernelPatcher::RouteRequest("_cs_validate_page", RestrictEventsPolicy::csValidatePageMountainLion, orgCsValidateFunc));
if (getKernelVersion() < KernelVersion::Sierra) {
vnodePagerOpsKernel = reinterpret_cast<void *>(patcher.solveSymbol(KernelPatcher::KernelID, "_vnode_pager_ops"));
if (!vnodePagerOpsKernel)
SYSLOG("rev", "failed to solve _vnode_pager_ops");
}

if (!patcher.routeMultipleLong(KernelPatcher::KernelID, &csRoute, 1))
SYSLOG("rev", "failed to route cs validation pages");
}

if (!patcher.routeMultipleLong(KernelPatcher::KernelID, &csRoute, 1))
SYSLOG("rev", "failed to route cs validation pages");
// Perform regardless of Normal vs Installer
if ((getKernelVersion() >= KernelVersion::Monterey ||
(getKernelVersion() == KernelVersion::BigSur && getKernelMinorVersion() >= 4)) &&
(revsbvmmIsSet || revassetIsSet))
Expand Down
11 changes: 10 additions & 1 deletion RestrictEvents/SoftwareUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,16 @@ static int my_sysctl_vmm_present(__unused struct sysctl_oid *oidp, __unused void
char procname[64];
proc_name(proc_pid(req->p), procname, sizeof(procname));
// SYSLOG("supd", "\n\n\n\nsoftwareupdated vmm_present %d - >>> %s <<<<\n\n\n\n", arg2, procname);
if (revsbvmmIsSet && (strcmp(procname, "softwareupdated") == 0 || strcmp(procname, "com.apple.Mobile") == 0)) {
if (revsbvmmIsSet && (
// Always return 1 in recovery/installers
(lilu.getRunMode() & LiluAPI::RunningInstallerRecovery != 0) ||
// Otherwise, check if userspace OS updaters/installers
(
strcmp(procname, "softwareupdated") == 0 ||
strcmp(procname, "com.apple.Mobile") == 0 ||
strcmp(procname, "osinstallersetup") == 0 // Primarily for 'Install macOS.app'
)
)) {
int hv_vmm_present_on = 1;
return SYSCTL_OUT(req, &hv_vmm_present_on, sizeof(hv_vmm_present_on));
} else if (revassetIsSet && (strncmp(procname, "AssetCache", sizeof("AssetCache")-1) == 0)) {
Expand Down

0 comments on commit 0febd7e

Please sign in to comment.