Skip to content

Commit

Permalink
fix: Store matched drivers statically
Browse files Browse the repository at this point in the history
To prevent injecting twice
  • Loading branch information
VisualEhrmanntraut committed Aug 27, 2024
1 parent f3a7cfd commit 958f7c8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions NootRX/NootRX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ static const char *DriverBundleIdentifiers[] = {
"com.apple.kext.AMDRadeonX6000Framebuffer",
};

bool NootRXMain::wrapAddDrivers(void *that, OSArray *array, bool doNubMatching) {
UInt8 matched = 0;
static UInt8 matchedDrivers = 0;

bool NootRXMain::wrapAddDrivers(void *that, OSArray *array, bool doNubMatching) {
UInt32 driverCount = array->getCount();
for (UInt32 driverIndex = 0; driverIndex < driverCount; driverIndex += 1) {
OSObject *object = array->getObject(driverIndex);
Expand All @@ -204,10 +204,10 @@ bool NootRXMain::wrapAddDrivers(void *that, OSArray *array, bool doNubMatching)
if (bundleIdentifierCStr == nullptr) { continue; }

for (size_t identifierIndex = 0; identifierIndex < arrsize(DriverBundleIdentifiers); identifierIndex += 1) {
if ((matched & (1U << identifierIndex)) != 0) { continue; }
if ((matchedDrivers & (1U << identifierIndex)) != 0) { continue; }

if (strcmp(bundleIdentifierCStr, DriverBundleIdentifiers[identifierIndex]) == 0) {
matched |= (1U << identifierIndex);
matchedDrivers |= (1U << identifierIndex);

DBGLOG("NootRX", "Matched %s, injecting.", bundleIdentifierCStr);

Expand Down

0 comments on commit 958f7c8

Please sign in to comment.