diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e558f53..5d2b439 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,6 +25,9 @@ jobs: - name: CI Bootstrap run: | src=$(/usr/bin/curl -Lfs https://raw.githubusercontent.com/acidanthera/ocbuild/master/ci-bootstrap.sh) && eval "$src" || exit 1 + - name: Lilu Bootstrap + run: | + src=$(/usr/bin/curl -Lfs https://raw.githubusercontent.com/acidanthera/Lilu/master/Lilu/Scripts/bootstrap.sh) && eval "$src" || exit 1 - run: xcodebuild -jobs 1 -target Package -configuration Debug - run: xcodebuild -jobs 1 -target Package -configuration Release @@ -57,6 +60,9 @@ jobs: - name: CI Bootstrap run: | src=$(/usr/bin/curl -Lfs https://raw.githubusercontent.com/acidanthera/ocbuild/master/ci-bootstrap.sh) && eval "$src" || exit 1 + - name: Lilu Bootstrap + run: | + src=$(/usr/bin/curl -Lfs https://raw.githubusercontent.com/acidanthera/Lilu/master/Lilu/Scripts/bootstrap.sh) && eval "$src" || exit 1 - run: xcodebuild analyze -quiet -scheme Package -target Package -configuration Debug CLANG_ANALYZER_OUTPUT=plist-html CLANG_ANALYZER_OUTPUT_DIR="$(pwd)/clang-analyze" && [ "$(find clang-analyze -name "*.html")" = "" ] - run: xcodebuild clean -quiet -scheme Package @@ -77,6 +83,9 @@ jobs: - name: CI Bootstrap run: | src=$(/usr/bin/curl -Lfs https://raw.githubusercontent.com/acidanthera/ocbuild/master/ci-bootstrap.sh) && eval "$src" || exit 1 + - name: Lilu Bootstrap + run: | + src=$(/usr/bin/curl -Lfs https://raw.githubusercontent.com/acidanthera/Lilu/master/Lilu/Scripts/bootstrap.sh) && eval "$src" || exit 1 - name: Run Coverity run: | diff --git a/.gitignore b/.gitignore index 83e1836..033950c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ ModuleCache GeneratedFirmwares.cpp GeneratedFirmwaresMD5.txt /MacKernelSDK +/Lilu.kext diff --git a/BrcmPatchRAM.xcodeproj/project.pbxproj b/BrcmPatchRAM.xcodeproj/project.pbxproj index 0b62381..43e410f 100644 --- a/BrcmPatchRAM.xcodeproj/project.pbxproj +++ b/BrcmPatchRAM.xcodeproj/project.pbxproj @@ -7,6 +7,10 @@ objects = { /* Begin PBXBuildFile section */ + 51E2E7F52674FA4F00BBD815 /* plugin_start.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51E2E7F42674FA4F00BBD815 /* plugin_start.cpp */; }; + 51E67F002673C86300FB6051 /* libkmod.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CE8DA13225182BB2008C44E8 /* libkmod.a */; }; + 51E67F062673CA2B00FB6051 /* BlueToolFixup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51E67F042673CA2B00FB6051 /* BlueToolFixup.cpp */; }; + 51E67F082673CC4800FB6051 /* BlueToolFixup-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 51E67F072673CC4800FB6051 /* BlueToolFixup-Info.plist */; }; 841AD87E1BB3C0350082B7B0 /* BrcmFirmwareStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D4049E551A3252B1003A1893 /* BrcmFirmwareStore.cpp */; }; 841AD8811BB3C0350082B7B0 /* BrcmPatchRAM.h in Headers */ = {isa = PBXBuildFile; fileRef = D4F91B031A2998CE0030D10D /* BrcmPatchRAM.h */; }; 841AD8821BB3C0350082B7B0 /* BrcmFirmwareStore.h in Headers */ = {isa = PBXBuildFile; fileRef = D4049E561A3252B1003A1893 /* BrcmFirmwareStore.h */; }; @@ -98,6 +102,13 @@ remoteGlobalIDString = D346F7B823475DF60073A60D; remoteInfo = BrcmPatchRAM3; }; + 51E67F012673C8ED00FB6051 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D4F91AF51A2998CE0030D10D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 51E67EF52673C7FB00FB6051; + remoteInfo = BlueToolFixup; + }; ED0247B31BB84D6E007AC58D /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = D4F91AF51A2998CE0030D10D /* Project object */; @@ -108,6 +119,15 @@ /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ + 51E67F032673C95000FB6051 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 7; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 841AD8871BB3C0350082B7B0 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -175,6 +195,32 @@ /* Begin PBXFileReference section */ 4C7783482526A0DC00DBB02E /* package.tool */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = package.tool; sourceTree = ""; }; + 517C9A0D2674FB1700338A13 /* kern_devinfo.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_devinfo.hpp; sourceTree = ""; }; + 517C9A0E2674FB1700338A13 /* plugin_start.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = plugin_start.hpp; sourceTree = ""; }; + 517C9A0F2674FB1700338A13 /* kern_api.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_api.hpp; sourceTree = ""; }; + 517C9A102674FB1700338A13 /* kern_file.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_file.hpp; sourceTree = ""; }; + 517C9A112674FB1700338A13 /* kern_user.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_user.hpp; sourceTree = ""; }; + 517C9A122674FB1700338A13 /* kern_config.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_config.hpp; sourceTree = ""; }; + 517C9A132674FB1700338A13 /* kern_util.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_util.hpp; sourceTree = ""; }; + 517C9A142674FB1700338A13 /* kern_cpu.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_cpu.hpp; sourceTree = ""; }; + 517C9A152674FB1700338A13 /* kern_nvram.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_nvram.hpp; sourceTree = ""; }; + 517C9A162674FB1700338A13 /* kern_compression.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_compression.hpp; sourceTree = ""; }; + 517C9A172674FB1700338A13 /* kern_crypto.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_crypto.hpp; sourceTree = ""; }; + 517C9A182674FB1700338A13 /* kern_version.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_version.hpp; sourceTree = ""; }; + 517C9A192674FB1700338A13 /* kern_policy.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_policy.hpp; sourceTree = ""; }; + 517C9A1A2674FB1700338A13 /* kern_disasm.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_disasm.hpp; sourceTree = ""; }; + 517C9A1B2674FB1700338A13 /* hde64.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = hde64.h; sourceTree = ""; }; + 517C9A1C2674FB1700338A13 /* kern_iokit.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_iokit.hpp; sourceTree = ""; }; + 517C9A1D2674FB1700338A13 /* kern_patcher.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_patcher.hpp; sourceTree = ""; }; + 517C9A1E2674FB1700338A13 /* kern_rtc.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_rtc.hpp; sourceTree = ""; }; + 517C9A1F2674FB1700338A13 /* kern_compat.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_compat.hpp; sourceTree = ""; }; + 517C9A202674FB1700338A13 /* kern_efi.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_efi.hpp; sourceTree = ""; }; + 517C9A212674FB1700338A13 /* kern_time.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_time.hpp; sourceTree = ""; }; + 517C9A222674FB1700338A13 /* kern_mach.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_mach.hpp; sourceTree = ""; }; + 51E2E7F42674FA4F00BBD815 /* plugin_start.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = plugin_start.cpp; sourceTree = ""; }; + 51E67EF62673C7FB00FB6051 /* BlueToolFixup.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BlueToolFixup.kext; sourceTree = BUILT_PRODUCTS_DIR; }; + 51E67F042673CA2B00FB6051 /* BlueToolFixup.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BlueToolFixup.cpp; sourceTree = ""; }; + 51E67F072673CC4800FB6051 /* BlueToolFixup-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "BlueToolFixup-Info.plist"; sourceTree = ""; }; 841AD88C1BB3C0350082B7B0 /* BrcmFirmwareData.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BrcmFirmwareData.kext; sourceTree = BUILT_PRODUCTS_DIR; }; 841AD88E1BB3C0F40082B7B0 /* BrcmFirmwareData-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "BrcmFirmwareData-Info.plist"; sourceTree = ""; }; 841AD8901BB3C12F0082B7B0 /* FirmwareData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FirmwareData.cpp; sourceTree = ""; }; @@ -211,6 +257,14 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 51E67EF32673C7FB00FB6051 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 51E67F002673C86300FB6051 /* libkmod.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 841AD87F1BB3C0350082B7B0 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -268,6 +322,54 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 51E2E7E92674F95700BBD815 /* SDK */ = { + isa = PBXGroup; + children = ( + 51E2E7F32674FA0800BBD815 /* Library */, + 51E2E7EF2674F9B800BBD815 /* Headers */, + ); + name = SDK; + sourceTree = ""; + }; + 51E2E7EF2674F9B800BBD815 /* Headers */ = { + isa = PBXGroup; + children = ( + 517C9A1B2674FB1700338A13 /* hde64.h */, + 517C9A0F2674FB1700338A13 /* kern_api.hpp */, + 517C9A1F2674FB1700338A13 /* kern_compat.hpp */, + 517C9A162674FB1700338A13 /* kern_compression.hpp */, + 517C9A122674FB1700338A13 /* kern_config.hpp */, + 517C9A142674FB1700338A13 /* kern_cpu.hpp */, + 517C9A172674FB1700338A13 /* kern_crypto.hpp */, + 517C9A0D2674FB1700338A13 /* kern_devinfo.hpp */, + 517C9A1A2674FB1700338A13 /* kern_disasm.hpp */, + 517C9A202674FB1700338A13 /* kern_efi.hpp */, + 517C9A102674FB1700338A13 /* kern_file.hpp */, + 517C9A1C2674FB1700338A13 /* kern_iokit.hpp */, + 517C9A222674FB1700338A13 /* kern_mach.hpp */, + 517C9A152674FB1700338A13 /* kern_nvram.hpp */, + 517C9A1D2674FB1700338A13 /* kern_patcher.hpp */, + 517C9A192674FB1700338A13 /* kern_policy.hpp */, + 517C9A1E2674FB1700338A13 /* kern_rtc.hpp */, + 517C9A212674FB1700338A13 /* kern_time.hpp */, + 517C9A112674FB1700338A13 /* kern_user.hpp */, + 517C9A132674FB1700338A13 /* kern_util.hpp */, + 517C9A182674FB1700338A13 /* kern_version.hpp */, + 517C9A0E2674FB1700338A13 /* plugin_start.hpp */, + ); + name = Headers; + path = Lilu.kext/Contents/Resources/Headers; + sourceTree = ""; + }; + 51E2E7F32674FA0800BBD815 /* Library */ = { + isa = PBXGroup; + children = ( + 51E2E7F42674FA4F00BBD815 /* plugin_start.cpp */, + ); + name = Library; + path = Lilu.kext/Contents/Resources/Library; + sourceTree = SOURCE_ROOT; + }; CE8DA13125182BB2008C44E8 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -279,6 +381,7 @@ D4F91AF41A2998CE0030D10D = { isa = PBXGroup; children = ( + 51E2E7E92674F95700BBD815 /* SDK */, 8480E9531BB4312200FF61B0 /* README.md */, ED4CFCEE1CE8BCB300A285B2 /* README-Mac.md */, CEBB57BF242D458200614D73 /* Changelog.md */, @@ -302,6 +405,7 @@ EDC9E2BC1D185240007E69B6 /* BrcmNonPatchRAM2.kext */, D346F7C923475DF60073A60D /* BrcmPatchRAM3.kext */, CE8DA729235248C300BCE180 /* BrcmPatchRAM.kext */, + 51E67EF62673C7FB00FB6051 /* BlueToolFixup.kext */, ); name = Products; sourceTree = ""; @@ -309,6 +413,7 @@ D4F91B001A2998CE0030D10D /* BrcmPatchRAM */ = { isa = PBXGroup; children = ( + 51E67F042673CA2B00FB6051 /* BlueToolFixup.cpp */, D4049E561A3252B1003A1893 /* BrcmFirmwareStore.h */, D4049E551A3252B1003A1893 /* BrcmFirmwareStore.cpp */, 841AD8921BB3C1960082B7B0 /* FirmwareData.h */, @@ -331,6 +436,7 @@ D4F91B011A2998CE0030D10D /* Supporting Files */ = { isa = PBXGroup; children = ( + 51E67F072673CC4800FB6051 /* BlueToolFixup-Info.plist */, CE8DA72B2352496A00BCE180 /* BrcmPatchRAM-Info.plist */, ED5817CB1B7A6BDF006C5522 /* BrcmPatchRAM2-Info.plist */, D346F7CA23475DF70073A60D /* BrcmPatchRAM3-Info.plist */, @@ -353,6 +459,13 @@ /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ + 51E67EF12673C7FB00FB6051 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 841AD8801BB3C0350082B7B0 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -439,6 +552,7 @@ buildToolPath = "${SRCROOT}/BrcmPatchRAM/package.tool"; buildWorkingDirectory = ""; dependencies = ( + 51E67F022673C8ED00FB6051 /* PBXTargetDependency */, 4C7783432526A09D00DBB02E /* PBXTargetDependency */, 4C7783452526A09D00DBB02E /* PBXTargetDependency */, 4C7783472526A09D00DBB02E /* PBXTargetDependency */, @@ -468,6 +582,25 @@ /* End PBXLegacyTarget section */ /* Begin PBXNativeTarget section */ + 51E67EF52673C7FB00FB6051 /* BlueToolFixup */ = { + isa = PBXNativeTarget; + buildConfigurationList = 51E67EFF2673C7FB00FB6051 /* Build configuration list for PBXNativeTarget "BlueToolFixup" */; + buildPhases = ( + 51E67EF22673C7FB00FB6051 /* Sources */, + 51E67EF32673C7FB00FB6051 /* Frameworks */, + 51E67EF12673C7FB00FB6051 /* Headers */, + 51E67EF42673C7FB00FB6051 /* Resources */, + 51E67F032673C95000FB6051 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = BlueToolFixup; + productName = BlueToolFixup; + productReference = 51E67EF62673C7FB00FB6051 /* BlueToolFixup.kext */; + productType = "com.apple.product-type.kernel-extension"; + }; 841AD87C1BB3C0350082B7B0 /* BrcmFirmwareData */ = { isa = PBXNativeTarget; buildConfigurationList = 841AD8891BB3C0350082B7B0 /* Build configuration list for PBXNativeTarget "BrcmFirmwareData" */; @@ -615,6 +748,9 @@ CreatedOnToolsVersion = 12.0.1; ProvisioningStyle = Automatic; }; + 51E67EF52673C7FB00FB6051 = { + CreatedOnToolsVersion = 13.0; + }; 84CDEE051BB3CA2200238DD1 = { CreatedOnToolsVersion = 7.0; }; @@ -638,6 +774,7 @@ CE8DA714235248C300BCE180 /* BrcmPatchRAM */, ED5817BB1B7A6AEF006C5522 /* BrcmPatchRAM2 */, D346F7B823475DF60073A60D /* BrcmPatchRAM3 */, + 51E67EF52673C7FB00FB6051 /* BlueToolFixup */, 841AD87C1BB3C0350082B7B0 /* BrcmFirmwareData */, 842B20B71BB2F0D900D3C468 /* BrcmFirmwareRepo */, ED7470ED1D184C5D005F75F1 /* BrcmNonPatchRAM */, @@ -647,6 +784,14 @@ /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 51E67EF42673C7FB00FB6051 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 51E67F082673CC4800FB6051 /* BlueToolFixup-Info.plist in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 841AD8861BB3C0350082B7B0 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -720,6 +865,15 @@ /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 51E67EF22673C7FB00FB6051 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 51E2E7F52674FA4F00BBD815 /* plugin_start.cpp in Sources */, + 51E67F062673CA2B00FB6051 /* BlueToolFixup.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 841AD87D1BB3C0350082B7B0 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -816,6 +970,11 @@ target = D346F7B823475DF60073A60D /* BrcmPatchRAM3 */; targetProxy = 4C7783462526A09D00DBB02E /* PBXContainerItemProxy */; }; + 51E67F022673C8ED00FB6051 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 51E67EF52673C7FB00FB6051 /* BlueToolFixup */; + targetProxy = 51E67F012673C8ED00FB6051 /* PBXContainerItemProxy */; + }; ED0247B41BB84D6E007AC58D /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 84CDEE051BB3CA2200238DD1 /* Prebuild */; @@ -889,6 +1048,61 @@ }; name = Release; }; + 51E67EFD2673C7FB00FB6051 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_WEAK = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "PRODUCT_NAME=$(PRODUCT_NAME)", + "MODULE_VERSION=$(MODULE_VERSION)", + "LILU_CUSTOM_IOKIT_INIT=1", + "$(inherited)", + ); + HEADER_SEARCH_PATHS = "${PROJECT_DIR}/Lilu.kext/Contents/Resources"; + INFOPLIST_FILE = "$(SRCROOT)/BrcmPatchRAM/BlueToolFixup-Info.plist"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/MacKernelSDK/Library/x86_64", + ); + MACOSX_DEPLOYMENT_TARGET = 10.8; + MODULE_NAME = as.acidanthera.BlueToolFixup; + MODULE_START = "$(PRODUCT_NAME)_kern_start"; + MODULE_STOP = "$(PRODUCT_NAME)_kern_stop"; + MODULE_VERSION = "$(CURRENT_PROJECT_VERSION)"; + PRODUCT_BUNDLE_IDENTIFIER = as.acidanthera.BlueToolFixup; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = kext; + }; + name = Debug; + }; + 51E67EFE2673C7FB00FB6051 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_WEAK = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "LILU_CUSTOM_IOKIT_INIT=1", + "PRODUCT_NAME=$(PRODUCT_NAME)", + "MODULE_VERSION=$(MODULE_VERSION)", + "$(inherited)", + ); + HEADER_SEARCH_PATHS = "${PROJECT_DIR}/Lilu.kext/Contents/Resources"; + INFOPLIST_FILE = "$(SRCROOT)/BrcmPatchRAM/BlueToolFixup-Info.plist"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/MacKernelSDK/Library/x86_64", + ); + MACOSX_DEPLOYMENT_TARGET = 10.8; + MODULE_NAME = as.acidanthera.BlueToolFixup; + MODULE_START = "$(PRODUCT_NAME)_kern_start"; + MODULE_STOP = "$(PRODUCT_NAME)_kern_stop"; + MODULE_VERSION = "$(CURRENT_PROJECT_VERSION)"; + PRODUCT_BUNDLE_IDENTIFIER = as.acidanthera.BlueToolFixup; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = kext; + }; + name = Release; + }; 841AD88A1BB3C0350082B7B0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -1355,6 +1569,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 51E67EFF2673C7FB00FB6051 /* Build configuration list for PBXNativeTarget "BlueToolFixup" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 51E67EFD2673C7FB00FB6051 /* Debug */, + 51E67EFE2673C7FB00FB6051 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 841AD8891BB3C0350082B7B0 /* Build configuration list for PBXNativeTarget "BrcmFirmwareData" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/BrcmPatchRAM/BlueToolFixup-Info.plist b/BrcmPatchRAM/BlueToolFixup-Info.plist new file mode 100644 index 0000000..db67fc8 --- /dev/null +++ b/BrcmPatchRAM/BlueToolFixup-Info.plist @@ -0,0 +1,57 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + KEXT + CFBundleShortVersionString + $(MODULE_VERSION) + CFBundleVersion + $(MODULE_VERSION) + IOKitPersonalities + + BlueToolFixup + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + IOClass + $(PRODUCT_NAME:rfc1034identifier) + IOMatchCategory + $(PRODUCT_NAME:rfc1034identifier) + IOProviderClass + IOResources + IOResourceMatch + IOKit + + + OSBundleLibraries + + as.vit9696.Lilu + 1.4.7 + com.apple.kpi.bsd + 12.0.0 + com.apple.kpi.dsep + 12.0.0 + com.apple.kpi.iokit + 12.0.0 + com.apple.kpi.libkern + 12.0.0 + com.apple.kpi.mach + 12.0.0 + com.apple.kpi.unsupported + 12.0.0 + + OSBundleRequired + Root + + diff --git a/BrcmPatchRAM/BlueToolFixup.cpp b/BrcmPatchRAM/BlueToolFixup.cpp new file mode 100644 index 0000000..0fa891a --- /dev/null +++ b/BrcmPatchRAM/BlueToolFixup.cpp @@ -0,0 +1,120 @@ +// +// BlueToolFixup.cpp +// BrcmPatchRAM +// +// Created by Dhinak G on 6/11/21. +// + + +#include +#include +#include +#include +#include + + +#define MODULE_SHORT "btlfx" + + +class EXPORT BlueToolFixup : public IOService { + OSDeclareDefaultStructors(BlueToolFixup) +public: + IOService *probe(IOService *provider, SInt32 *score) override; + bool start(IOService *provider) override; +}; + +OSDefineMetaClassAndStructors(BlueToolFixup, IOService) + + +IOService *BlueToolFixup::probe(IOService *provider, SInt32 *score) { + return ADDPR(startSuccess) ? IOService::probe(provider, score) : nullptr; +} + +bool BlueToolFixup::start(IOService *provider) { + if (!IOService::start(provider)) { + SYSLOG("init", "failed to start the parent"); + return false; + } + setProperty("VersionInfo", kextVersion); + setName("bluetooth"); + uint8_t bytes[] {0x00, 0x00, 0x00, 0x00}; + setProperty("transport-encoding", bytes, sizeof(bytes)); + registerService(); + + return true; +} + + +#pragma mark - Patches + +static const uint8_t kSkipUpdateFilePathOriginal[] = "/etc/bluetool/SkipBluetoothAutomaticFirmwareUpdate"; +static const uint8_t kSkipUpdateFilePathPatched[] = "/System/Library/CoreServices/boot.efi"; + +static const char *blueToolPath = "/usr/sbin/BlueTool"; + +static mach_vm_address_t orig_cs_validate {}; + +#pragma mark - Kernel patching code + +template +static inline void searchAndPatch(const void *haystack, size_t haystackSize, const char *path, const uint8_t (&needle)[findSize], const uint8_t (&patch)[replaceSize]) { + if (UNLIKELY(KernelPatcher::findAndReplace(const_cast(haystack), haystackSize, needle, findSize, patch, replaceSize))) + DBGLOG(MODULE_SHORT, "found string to patch at %s!", path); +} + + + +#pragma mark - Patched functions + +// For Big Sur +static void patched_cs_validate_page(vnode_t vp, memory_object_t pager, memory_object_offset_t page_offset, const void *data, int *validated_p, int *tainted_p, int *nx_p) { + char path[PATH_MAX]; + int pathlen = PATH_MAX; + FunctionCast(patched_cs_validate_page, orig_cs_validate)(vp, pager, page_offset, data, validated_p, tainted_p, nx_p); + if (vn_getpath(vp, path, &pathlen) == 0 && UNLIKELY(strcmp(path, blueToolPath) == 0)) { + searchAndPatch(data, PAGE_SIZE, path, kSkipUpdateFilePathOriginal, kSkipUpdateFilePathPatched); + } +} + + +#pragma mark - Patches on start/stop + +static void pluginStart() { + SYSLOG(MODULE_SHORT, "start"); + // There is no point in routing cs_validate_range, because this kext should only be running on Monterey+ + if (getKernelVersion() >= KernelVersion::Monterey) { + lilu.onPatcherLoadForce([](void *user, KernelPatcher &patcher) { + KernelPatcher::RouteRequest csRoute = KernelPatcher::RouteRequest("_cs_validate_page", patched_cs_validate_page, orig_cs_validate); + if (!patcher.routeMultipleLong(KernelPatcher::KernelID, &csRoute, 1)) + SYSLOG(MODULE_SHORT, "failed to route cs validation pages"); + }); + } +} + +// Boot args. +static const char *bootargOff[] { + "-btlfxoff" +}; +static const char *bootargDebug[] { + "-btlfxdbg" +}; +static const char *bootargBeta[] { + "-btlfxbeta" +}; + +// Plugin configuration. +PluginConfiguration ADDPR(config) { + xStringify(PRODUCT_NAME), + parseModuleVersion(xStringify(MODULE_VERSION)), + LiluAPI::AllowNormal | LiluAPI::AllowInstallerRecovery | LiluAPI::AllowSafeMode, + bootargOff, + arrsize(bootargOff), + bootargDebug, + arrsize(bootargDebug), + bootargBeta, + arrsize(bootargBeta), + KernelVersion::Monterey, + KernelVersion::Monterey, + pluginStart +}; +