### Flashrom Installation Path Example Source: https://github.com/pranelio/swift-apple-efi-patcher/blob/master/README.md Provides example paths for the flashrom executable when installed via Homebrew. You will need to provide the full path in the EFI Patcher preferences. ```bash /usr/local/bin/flashrom ``` ```bash /usr/local/Cellar/flashrom/1.1/bin/flashrom ``` -------------------------------- ### Install Prerequisites with Homebrew Source: https://context7.com/pranelio/swift-apple-efi-patcher/llms.txt Installs Xcode Command Line Tools, Homebrew, and Flashrom using shell commands. Ensure Homebrew is installed before proceeding with flashrom. ```bash xcode-select --install ``` ```bash ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null ``` ```bash brew install flashrom ``` -------------------------------- ### Install Xcode Command Line Tools Source: https://github.com/pranelio/swift-apple-efi-patcher/blob/master/README.md Installs the necessary command line tools for Xcode. Run this command in your terminal. ```bash xcode-select --install ``` -------------------------------- ### Install Flashrom using Homebrew Source: https://github.com/pranelio/swift-apple-efi-patcher/blob/master/README.md Installs flashrom, a utility for reading and writing flash chips, using the Homebrew package manager. This is a prerequisite for hardware interaction. ```bash brew install flashrom ``` -------------------------------- ### Install Homebrew Package Manager Source: https://github.com/pranelio/swift-apple-efi-patcher/blob/master/README.md Installs Homebrew, a package manager for macOS. This command should be run in your terminal. ```bash ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null ``` -------------------------------- ### Flashrom Dump EFI Chip Command Source: https://context7.com/pranelio/swift-apple-efi-patcher/llms.txt Examples of flashrom commands for reading firmware from an EFI chip. Includes basic read, read with chip specification, and read with verification. ```bash # Flashrom read command executed by the application # Basic read without chip specification (auto-detect) flashrom -p ch341a_spi -r /Users/username/Desktop/firmware_dump.bin ``` ```bash # Read with chip type specified flashrom -p ch341a_spi -c MX25L6405 -r /Users/username/Desktop/firmware_dump.bin ``` ```bash # Read with verification enabled flashrom -p ch341a_spi -r /Users/username/Desktop/firmware_dump.bin flashrom -p ch341a_spi -v /Users/username/Desktop/firmware_dump.bin ``` -------------------------------- ### Flashrom Write EFI Chip Command Source: https://context7.com/pranelio/swift-apple-efi-patcher/llms.txt Examples of flashrom commands for writing patched firmware to an EFI chip. Includes basic write and write with chip specification. ```bash # Flashrom write command executed by the application # Basic write without chip specification flashrom -p ch341a_spi -w /Users/username/Desktop/firmware_dump.bin ``` ```bash # Write with chip type specified flashrom -p ch341a_spi -c MX25L6405 -w /Users/username/Desktop/firmware_dump_patched.bin ``` -------------------------------- ### Build from Source with Xcode Source: https://context7.com/pranelio/swift-apple-efi-patcher/llms.txt Instructions for cloning the repository, opening the project in Xcode, and build configuration requirements for Swift Apple EFI Patcher. ```bash # Clone repository git clone https://github.com/sadponyguerillaboy/Swift-Apple-EFI-Patcher.git # Open project in Xcode cd Swift-Apple-EFI-Patcher/Source/EFI\ Patcher open "EFI Patcher.xcodeproj" # Build configuration: # - Xcode 11.3+ # - Swift 5 # - Deployment targets: macOS 10.13, 10.14, 10.15 ``` -------------------------------- ### Extend JSON Configuration Files Source: https://context7.com/pranelio/swift-apple-efi-patcher/llms.txt Shows how to extend programmer and chip type lists by editing chipList.json and progList.json within the application bundle. ```bash # Access configuration files # Right-click EFI Patcher.app -> Show Package Contents # Navigate to: Contents/Resources/ # chipList.json - Add new chip types [ { "vendor": "Custom", "device": "CUSTOM_CHIP_MODEL", "size": "8192", "type": "SPI" } ] # progList.json - Add new programmers [ { "device": "custom_programmer:dev=/dev/ttyUSB0" } ] ``` -------------------------------- ### Xcode Build Settings Source: https://github.com/pranelio/swift-apple-efi-patcher/blob/master/README.md Project development configuration including Xcode version, macOS version, and Swift version. Optimized for deployment to specific macOS versions. ```text Xcode 11.3 macOS 10.15 swift 5 ``` -------------------------------- ### ME Region File Structure Source: https://context7.com/pranelio/swift-apple-efi-patcher/llms.txt Illustrates the directory structure and file naming convention for ME region files, organized by Mac model identifier. ```text ME_Regions/ ├── IM121/ # iMac 12,1 ├── IM131/ # iMac 13,1 ├── IM141/ # iMac 14,1 ├── MBP101/ # MacBook Pro 10,1 ├── MBP111/ # MacBook Pro 11,1 ├── MBA51/ # MacBook Air 5,1 ├── MBA61/ # MacBook Air 6,1 ├── MM61/ # Mac mini 6,1 └── MP61/ # Mac Pro 6,1 # File naming convention: # {macOS_version}_{model}_{build}_{ME_version}.rgn # Example: 10.14.6_MBP111_9.5.3.1526.rgn ``` -------------------------------- ### Supported Programmers Configuration Source: https://context7.com/pranelio/swift-apple-efi-patcher/llms.txt JSON array defining supported USB-based programmers for flashrom integration. This list can be extended in the `progList.json` file. ```json [ { "device": "ch341a_spi" }, { "device": "ft2232_spi" }, { "device": "buspirate_spi" }, { "device": "dediprog" }, { "device": "linux_spi" }, { "device": "pickit2_spi" }, { "device": "serprog" } ] ``` -------------------------------- ### Supported Chip Types Configuration Source: https://context7.com/pranelio/swift-apple-efi-patcher/llms.txt JSON array detailing common SPI flash chips supported by the application. This list is extensible via the `chipList.json` file. ```json [ { "vendor": "Macronix", "device": "MX25L6405", "size": "8192", "type": "SPI" }, { "vendor": "Macronix", "device": "MX25L6405D", "size": "8192", "type": "SPI" }, { "vendor": "Micron/Numonyx/ST", "device": "N25Q064..1E", "size": "8192", "type": "SPI" }, { "vendor": "Winbond", "device": "W25Q64.V", "size": "8192", "type": "SPI" }, { "vendor": "SST", "device": "SST25VF064C", "size": "8192", "type": "SPI" } ] ``` -------------------------------- ### Run External Commands in Swift Source: https://context7.com/pranelio/swift-apple-efi-patcher/llms.txt Executes external commands and captures their stdout, stderr, and exit codes. Useful for integrating tools like flashrom. ```swift func runCommand(cmd: String, args: [String]) -> (output: [String], error: [String], exitCode: Int32) { let task = Process() task.launchPath = cmd task.arguments = args let outpipe = Pipe() task.standardOutput = outpipe let errpipe = Pipe() task.standardError = errpipe try task.run() let outdata = outpipe.fileHandleForReading.readDataToEndOfFile() let errdata = errpipe.fileHandleForReading.readDataToEndOfFile() task.waitUntilExit() return (output, error, task.terminationStatus) } // Example usage for flashrom read let (output, error, status) = runCommand( cmd: "/usr/local/bin/flashrom", args: ["-p", "ch341a_spi", "-r", "/Users/username/Desktop/dump.bin"] ) ``` -------------------------------- ### Fix macOS Security Warnings Source: https://context7.com/pranelio/swift-apple-efi-patcher/llms.txt Removes the quarantine attribute from downloaded applications to resolve 'App is Damaged' security messages. ```bash # Fix quarantine attribute for application in Applications folder sudo xattr -rd com.apple.quarantine /Applications/EFI\ Patcher.app # Or drag-and-drop the app after typing: sudo xattr -rd com.apple.quarantine ``` -------------------------------- ### Fix 'App is Damaged' Error in Terminal Source: https://github.com/pranelio/swift-apple-efi-patcher/blob/master/README.md Command to resolve the 'App is Damaged & Can't Be Opened' message on macOS by re-signing the application. Assumes the app is in the Applications folder. ```bash xattr -cr "/Applications/YourAppName.app" ``` -------------------------------- ### Clean ME Region in EFI Firmware Source: https://context7.com/pranelio/swift-apple-efi-patcher/llms.txt Replaces the Management Engine region with a known-good ME region file. Requires ME region files for specific Mac models. ```swift // ME Region header patterns searched in firmware var meRegionBytesV1: [UInt8] = [ 0x20, 0x20, 0x80, 0x0F, 0x40, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x46, 0x50, 0x54 ] var meRegionBytesV2: [UInt8] = [ 0x20, 0x20, 0x80, 0x0F, 0x40, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x46, 0x50, 0x54 ] // Locate ME region and patch with clean region file let meRegionOffset = findInitialMeRegionOffset(file: data, searchItem1: meRegionV1, searchItem2: meRegionV2, searchItem3: meRegionV3) let mePatch = NSMutableData(contentsOf: meRegionFileURL) patchBytesRaw(file: data, toReplace: mePatch.bytes, start: meRegionOffset, end: (mePatch.count + meRegionOffset)) ``` -------------------------------- ### Remove Firmware Lock Source: https://context7.com/pranelio/swift-apple-efi-patcher/llms.txt Removes firmware password locks by filling the $SVS region with 0xFF bytes. Ensure the correct offsets are identified. ```swift // Locate and clear firmware lock region let svs = Data(bytes: "$SVS", count: 4) let svsOffset = findInitialOffset(file: data, searchItem: svs) // Skip 16-byte header, find end of SVS region let lockStartOffset = svsOffset + 16 let lockEndOffset = findOtherOffsetsRestricted(file: data, searchItem: svs, start: lockStartOffset, end: data.count) // Generate fill bytes (0xFF) and patch let svsFill = NSMutableData() svsFill.calculateFill(255, start: lockStartOffset, end: lockEndOffset) patchBytesRaw(file: data, toReplace: svsFill.bytes, start: lockStartOffset, end: (lockEndOffset - 1)) ``` -------------------------------- ### Calculate CRC32 Checksum Source: https://context7.com/pranelio/swift-apple-efi-patcher/llms.txt Calculates CRC32 checksums for data integrity, used here for Fsys block verification. Includes lookup table generation and checksum calculation functions. ```swift // CRC32 lookup table generation var table: [UInt32] = { (0...255).map { i -> UInt32 in (0..<8).reduce(UInt32(i), { c, _ in (c % 2 == 0) ? (c >> 1) : (0xEDB88320 ^ (c >> 1)) }) } }() // CRC32 checksum calculation func checksum(bytes: [UInt8]) -> UInt32 { return ~(bytes.reduce(~UInt32(0), { crc, byte in (crc >> 8) ^ table[(Int(crc) ^ Int(byte)) & 0xFF] })) } // Create CRC32 bytes for patching func createCRC32Bytes(data: NSData, startOffset: Int, endOffset: UInt64) -> UnsafeRawPointer { let fsysBlockAltered = [UInt8](data[startOffset...Int(endOffset)]) let newCRC32 = checksum(bytes: fsysBlockAltered) var littleEndian = newCRC32.littleEndian // Convert to byte array and return pointer } ``` -------------------------------- ### Clear NVRAM Region Source: https://context7.com/pranelio/swift-apple-efi-patcher/llms.txt Clears NVRAM by filling the first $VSS region with 0xFF bytes. This operation should be performed with caution as it erases NVRAM settings. ```swift // Locate and clear NVRAM region let vss = Data(bytes: "$VSS", count: 4) let vssOffset = findInitialOffset(file: data, searchItem: vss) // Skip 16-byte header, find end of VSS region let nvramStartOffset = vssOffset + 16 let nvramEndOffset = findOtherOffsetsRestricted(file: data, searchItem: vss, start: nvramStartOffset, end: data.count) // Generate fill bytes (0xFF) and patch let vssFill = NSMutableData() vssFill.calculateFill(255, start: nvramStartOffset, end: nvramEndOffset) patchBytesRaw(file: data, toReplace: vssFill.bytes, start: nvramStartOffset, end: (nvramEndOffset - 1)) ``` -------------------------------- ### Patch Serial Number in EFI Firmware Source: https://context7.com/pranelio/swift-apple-efi-patcher/llms.txt Locates the Fsys block, replaces serial numbers (lowercase and uppercase), and recalculates the CRC32 checksum. Ensure the input data is mutable. ```swift // Serial number patching logic // Fsys block structure searched in firmware: let fsys = Data(bytes: "Fsys", count: 4) // Fsys block header let ssn = Data(bytes: "ssn", count: 3) // Lowercase serial field let ssnUpperCase = Data(bytes: "SSN", count: 3) // Uppercase serial field let eof = Data(bytes: "EOF", count: 3) // End of Fsys block // Locate offsets let fsysStartOffset = findInitialOffset(file: data, searchItem: fsys) let eofOffset = findOtherOffsetsRestricted(file: data, searchItem: eof, start: fsysStartOffset, end: data.count) let serialOffset = findOtherOffsets(file: data, searchItem: ssn, start: fsysStartOffset, end: eofOffset) // Patch serial (12 characters, uppercase) let patch_ssn = NSData(bytes: "NEWSERIAL123".uppercased(), length: 12) patchBytesRaw(file: data, toReplace: patch_ssn.bytes, start: (serialOffset + 5), end: (serialOffset + 17)) // Recalculate CRC32 for Fsys block let crc32Ptr = createCRC32Bytes(data: patchedData, startOffset: fsysStartOffset, endOffset: crc32Offset - 1) patchBytesRaw(file: patchedData, toReplace: crc32Ptr, start: Int(crc32Offset), end: Int(crc32Offset + 3)) ``` -------------------------------- ### Remove Quarantine Attribute from EFI Patcher App Source: https://github.com/pranelio/swift-apple-efi-patcher/blob/master/README.md Execute this command in the terminal to remove the quarantine attribute from the EFI Patcher application. This is often required before running applications downloaded from the internet on macOS. ```bash sudo xattr -rd com.apple.quarantine /Applications/EFI\ Patcher.app ``` ```bash sudo xattr -rd com.apple.quarantine ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.