Skip to content

Commit

Permalink
Implement MP7,1 patch for Ventura (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
PMheart authored Jun 30, 2022
1 parent d45ae54 commit af0074a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ RestrictEvents Changelog
#### v1.0.8
- Added constants for macOS 13 support
- Do not enable Memory and PCI UI patching on real Macs in `auto` mode
- Added `MacPro7,1` memory patch for macOS 13 `System Settings`->`General`->`About`

#### v1.0.7
- Fixed detecting CPU core count on Intel CPU with altered topology
Expand Down
16 changes: 12 additions & 4 deletions RestrictEvents/RestrictEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static const char *binPathSystemInformation;
static const char binPathSystemInformationLegacy[] = "/Applications/Utilities/System Information.app/Contents/MacOS/System Information";
static const char binPathSystemInformationCatalina[] = "/System/Applications/Utilities/System Information.app/Contents/MacOS/System Information";
static const char binPathSPMemoryReporter[] = "/System/Library/SystemProfiler/SPMemoryReporter.spreporter/Contents/MacOS/SPMemoryReporter";
static const char binPathAboutExtension[] = "/System/Library/ExtensionKit/Extensions/AboutExtension.appex/Contents/MacOS/AboutExtension";

static const char binPathDiskArbitrationAgent[] = "/System/Library/Frameworks/DiskArbitration.framework/Versions/A/Support/DiskArbitrationAgent";

Expand Down Expand Up @@ -120,7 +121,12 @@ struct RestrictEventsPolicy {
// Mavericks has the MacBookAir/MacBookPro10 whitelist in System Information and SPMemoryReporter.
// Yosemite and newer have the MacBookAir/MacBookPro10 whitelist in System Information, SPMemoryReporter, and AppleSystemInfo.framework.
//
if (modelFindPatch != nullptr && UNLIKELY(strcmp(path, binPathSystemInformation) == 0)) {
if (modelFindPatch != nullptr && getKernelVersion() >= KernelVersion::Ventura && UNLIKELY(strcmp(path, binPathAboutExtension) == 0)) {
if (UNLIKELY(KernelPatcher::findAndReplace(const_cast<void *>(data), size, modelFindPatch, modelFindSize, modelReplPatch, modelFindSize))) {
DBGLOG("rev", "patched %s in AboutExtension", reinterpret_cast<const char *>(modelFindPatch));
return;
}
} else if (modelFindPatch != nullptr && UNLIKELY(strcmp(path, binPathSystemInformation) == 0)) {
if (UNLIKELY(KernelPatcher::findAndReplace(const_cast<void *>(data), size, modelFindPatch, modelFindSize, modelReplPatch, modelFindSize))) {
DBGLOG("rev", "patched %s in System Information.app", reinterpret_cast<const char *>(modelFindPatch));
return;
Expand Down Expand Up @@ -461,9 +467,11 @@ PluginConfiguration ADDPR(config) {
if (enableMemoryUiPatching | enablePciUiPatching) {
// Rename existing values to invalid ones to avoid matching.
if (strcmp(di.modelIdentifier, "MacPro7,1") == 0) {
modelFindPatch = "MacPro7,1";
modelReplPatch = "HacPro7,1";
modelFindSize = sizeof("MacPro7,1");
// on 13.0 MacPro7,1 string literal is inlined, but "MacPro7," will do the matching.
modelFindPatch = "MacPro7,";
modelReplPatch = "HacPro7,";
// partial matching, thus exclude '\0'.
modelFindSize = sizeof("MacPro7,") - 1;
DBGLOG("rev", "detected MP71");
} else if (strncmp(di.modelIdentifier, "MacBookAir", strlen("MacBookAir")) == 0) {
needsMemPatch = true;
Expand Down

0 comments on commit af0074a

Please sign in to comment.