| 244 | #pragma mark - Patches on start/stop |
| 245 | |
| 246 | static void pluginStart() { |
| 247 | SYSLOG(MODULE_SHORT, "start"); |
| 248 | // There is no point in routing cs_validate_range, because this kext should only be running on Monterey+ |
| 249 | if (getKernelVersion() < KernelVersion::Monterey) |
| 250 | return; |
| 251 | lilu.onPatcherLoadForce([](void *user, KernelPatcher &patcher) { |
| 252 | if (getKernelVersion() >= KernelVersion::Sonoma) { |
| 253 | shouldPatchBoardId = checkKernelArgument("-btlfxboardid"); |
| 254 | } else { |
| 255 | auto boardId = BaseDeviceInfo::get().boardIdentifier; |
| 256 | auto boardIdSize = strlen(boardId) + 1; |
| 257 | shouldPatchBoardId = boardIdSize == kBoardIdSize || boardIdSize == kBoardIdSizeLegacy; |
| 258 | if (shouldPatchBoardId) |
| 259 | for (size_t i = 0; i < arrsize(boardIdsWithUSBBluetooth); i++) |
| 260 | if (strcmp(boardIdsWithUSBBluetooth[i], boardId) == 0) { |
| 261 | shouldPatchBoardId = false; |
| 262 | break; |
| 263 | } |
| 264 | } |
| 265 | if ((getKernelVersion() == KernelVersion::Monterey && getKernelMinorVersion() >= 5) || getKernelVersion() > KernelVersion::Monterey) |
| 266 | // 12.4 Beta 3+, XNU 21.5 |
| 267 | shouldPatchAddress = checkKernelArgument("-btlfxallowanyaddr"); |
| 268 | if (getKernelVersion() <= KernelVersion::Sonoma) |
| 269 | shouldPatchNvramCheck = checkKernelArgument("-btlfxnvramcheck"); |
| 270 | KernelPatcher::RouteRequest csRoute = KernelPatcher::RouteRequest("_cs_validate_page", patched_cs_validate_page, orig_cs_validate); |
| 271 | if (!patcher.routeMultipleLong(KernelPatcher::KernelID, &csRoute, 1)) |
| 272 | SYSLOG(MODULE_SHORT, "failed to route cs validation pages"); |
| 273 | }); |
| 274 | } |
| 275 | |
| 276 | // Boot args. |
| 277 | static const char *bootargOff[] { |
nothing calls this directly
no outgoing calls
no test coverage detected