├── .github └── FUNDING.yml ├── .gitignore ├── Assets ├── PhysLocation.png └── Screenshot.png ├── Changelog.md ├── FAQ.md ├── GenericCardReaderFriend.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ ├── GenericCardReaderFriend (Debug).xcscheme │ └── GenericCardReaderFriend (Release).xcscheme ├── GenericCardReaderFriend ├── GenericCardReaderFriend.cpp ├── GenericUSBCardReaderController.cpp ├── GenericUSBCardReaderController.hpp └── Info.plist ├── LICENSE └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: 0xFireWolf 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Gcc Patch 26 | /*.gcno 27 | 28 | .idea/ 29 | .DS_Store 30 | ._DS_Store 31 | __private/ 32 | MacKernelSDK/ 33 | Lilu.kext/ 34 | -------------------------------------------------------------------------------- /Assets/PhysLocation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xFireWolf/GenericCardReaderFriend/17900cbb50db218e2c3057f3d3e6cc3e8d9ad146/Assets/PhysLocation.png -------------------------------------------------------------------------------- /Assets/Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xFireWolf/GenericCardReaderFriend/17900cbb50db218e2c3057f3d3e6cc3e8d9ad146/Assets/Screenshot.png -------------------------------------------------------------------------------- /Changelog.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | #### v1.0.4 4 | - Add support for macOS Ventura. 5 | 6 | #### v1.0.3 7 | - Recomplie the kext with Lilu v1.5.8 to fix the kernel panic of the general protection error. 8 | 9 | #### v1.0.2 10 | - Recomplie the kext with Lilu v1.5.7 to fix the kernel panic of the general protection error. 11 | 12 | #### v1.0.1 13 | - Set the minimum kernel version to macOS El Capitan. 14 | 15 | #### v1.0.0 16 | - Initial release. 17 | -------------------------------------------------------------------------------- /FAQ.md: -------------------------------------------------------------------------------- 1 | # Frequently Asked Questions 2 | 3 | **Last Updated:** Jul 25, 2021 4 | 5 | ## >> Guide to customize the plugin 6 | 7 | **Step 1:** Find the `Product ID` and the `Vendor ID` of your card reader (see below) and convert them to decimal values. 8 | **Step 2:** Download the latest release version. 9 | **Step 3:** Open `Info.plist` in `GenericCardReaderFriend.kext/Contents`. 10 | **Step 4:** Locate the `GenericUSBCardReaderController` entry under `IOKitPersonalities`. 11 | **Step 5:** Replace the value of `idProduct` with your **decimal** product id you found in Step 1. 12 | **Step 6:** Replace the value of `idVendor` with your **decimal** product id you found in Step 1. 13 | **Step 7:** You may change the value of `Physical Interconnect Location` to `External` (see below). 14 | **Step 8:** Save your changes and install the driver. 15 | 16 | ## >> How do I find the product and the vendor ID of my card reader? 17 | Open `System Information` and click the tab `USB`. 18 | Find your card reader under the `USB Device Tree`. 19 | Click the entry and you should be able to see the hexadecimal representation of both identifiers below. 20 | 21 | ## >> When should I change the value of `Physical Interconnect Location` to `External`? 22 | 23 | #### Short Story: 24 | In short, it does not matter at all. 25 | Changing the value to `External` will change the title of your card reader to `External SD Card Reader` in `System Information`. 26 | 27 | ![](Assets/PhysLocation.png) 28 | 29 | #### Long Story: 30 | You may notice that your USB card reader shows up in the system only when you insert a SD card. 31 | In this case, your card reader works like a thumb drive, and System Information will list it only when the card is present. 32 | So, you may want to change the value to `External` to describe such behavior more precisely. 33 | On the contrary, if your card reader shows up even if the card is not present, you may change the value to `Internal`. 34 | 35 | ## >> Can I change the value of other entries in `IOKitPersonalities`? 36 | No, you should not. 37 | 38 | ## >> Why can't System Information present card information like Realtek Card Reader Friend? 39 | You may think of your card reader having its own firmware to do all dirty work, such as chip initialization, card detection and initialization, behind the scenes 40 | and exposing a USB mass storage interface to the system. Your card reader may hide all details about the card, so the dummy driver in this plugin has no way to fetch those information. In contrast, both `AppleUSBCardReader.kext` and `RealtekCardReader.kext` initialize the card reader and the card by themselves, 41 | so they know everything about the card you inserted and can publish those properties to IORegistry which are subsequently read by System Information. 42 | -------------------------------------------------------------------------------- /GenericCardReaderFriend.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D5096EA526A0E5B70065BE70 /* GenericCardReaderFriend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D5096EA426A0E5B70065BE70 /* GenericCardReaderFriend.cpp */; }; 11 | D5096EAE26A0E6870065BE70 /* libkmod.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D5096EAD26A0E6700065BE70 /* libkmod.a */; }; 12 | D5096EDD26A0E7620065BE70 /* plugin_start.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D5096EB626A0E7620065BE70 /* plugin_start.cpp */; }; 13 | D5096F0326A0E7C10065BE70 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = D5096F0026A0E7C10065BE70 /* LICENSE */; }; 14 | D58FCBB426AC06CD009D3C46 /* GenericUSBCardReaderController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D58FCBB226AC06CD009D3C46 /* GenericUSBCardReaderController.cpp */; }; 15 | D58FCBB526AC06CD009D3C46 /* GenericUSBCardReaderController.hpp in Headers */ = {isa = PBXBuildFile; fileRef = D58FCBB326AC06CD009D3C46 /* GenericUSBCardReaderController.hpp */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | D5096E9F26A0E5B70065BE70 /* GenericCardReaderFriend.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GenericCardReaderFriend.kext; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | D5096EA426A0E5B70065BE70 /* GenericCardReaderFriend.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GenericCardReaderFriend.cpp; sourceTree = ""; }; 21 | D5096EA626A0E5B70065BE70 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 22 | D5096EAD26A0E6700065BE70 /* libkmod.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libkmod.a; path = MacKernelSDK/Library/x86_64/libkmod.a; sourceTree = ""; }; 23 | D5096EB226A0E7620065BE70 /* entry64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = entry64.S; sourceTree = ""; }; 24 | D5096EB326A0E7620065BE70 /* build.tool */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = build.tool; sourceTree = ""; }; 25 | D5096EB426A0E7620065BE70 /* entry32.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = entry32.S; sourceTree = ""; }; 26 | D5096EB526A0E7620065BE70 /* wrappers.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; path = wrappers.inc; sourceTree = ""; }; 27 | D5096EB626A0E7620065BE70 /* plugin_start.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = plugin_start.cpp; sourceTree = ""; }; 28 | D5096EB826A0E7620065BE70 /* kern_config.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_config.hpp; sourceTree = ""; }; 29 | D5096EB926A0E7620065BE70 /* hde64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hde64.h; sourceTree = ""; }; 30 | D5096EBA26A0E7620065BE70 /* kern_time.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_time.hpp; sourceTree = ""; }; 31 | D5096EBB26A0E7620065BE70 /* kern_nvram.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_nvram.hpp; sourceTree = ""; }; 32 | D5096EBC26A0E7620065BE70 /* kern_cpu.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_cpu.hpp; sourceTree = ""; }; 33 | D5096EBD26A0E7620065BE70 /* kern_devinfo.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_devinfo.hpp; sourceTree = ""; }; 34 | D5096EBE26A0E7620065BE70 /* kern_efi.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_efi.hpp; sourceTree = ""; }; 35 | D5096EBF26A0E7620065BE70 /* kern_policy.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_policy.hpp; sourceTree = ""; }; 36 | D5096EC026A0E7620065BE70 /* kern_user.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_user.hpp; sourceTree = ""; }; 37 | D5096EC126A0E7620065BE70 /* plugin_start.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = plugin_start.hpp; sourceTree = ""; }; 38 | D5096EC226A0E7620065BE70 /* kern_iokit.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_iokit.hpp; sourceTree = ""; }; 39 | D5096EC326A0E7620065BE70 /* kern_crypto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_crypto.hpp; sourceTree = ""; }; 40 | D5096EC426A0E7620065BE70 /* kern_mach.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_mach.hpp; sourceTree = ""; }; 41 | D5096EC526A0E7620065BE70 /* kern_version.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_version.hpp; sourceTree = ""; }; 42 | D5096EC626A0E7620065BE70 /* kern_compression.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_compression.hpp; sourceTree = ""; }; 43 | D5096EC726A0E7620065BE70 /* kern_file.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_file.hpp; sourceTree = ""; }; 44 | D5096EC826A0E7620065BE70 /* kern_rtc.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_rtc.hpp; sourceTree = ""; }; 45 | D5096EC926A0E7620065BE70 /* kern_disasm.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_disasm.hpp; sourceTree = ""; }; 46 | D5096ECB26A0E7620065BE70 /* capstone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = capstone.h; sourceTree = ""; }; 47 | D5096ECC26A0E7620065BE70 /* mips.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mips.h; sourceTree = ""; }; 48 | D5096ECD26A0E7620065BE70 /* sparc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sparc.h; sourceTree = ""; }; 49 | D5096ECE26A0E7620065BE70 /* systemz.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = systemz.h; sourceTree = ""; }; 50 | D5096ECF26A0E7620065BE70 /* arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = arm.h; sourceTree = ""; }; 51 | D5096ED026A0E7620065BE70 /* x86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = x86.h; sourceTree = ""; }; 52 | D5096ED126A0E7620065BE70 /* ppc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ppc.h; sourceTree = ""; }; 53 | D5096ED226A0E7620065BE70 /* arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = arm64.h; sourceTree = ""; }; 54 | D5096ED326A0E7620065BE70 /* xcore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xcore.h; sourceTree = ""; }; 55 | D5096ED426A0E7620065BE70 /* platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = platform.h; sourceTree = ""; }; 56 | D5096ED526A0E7620065BE70 /* kern_patcher.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_patcher.hpp; sourceTree = ""; }; 57 | D5096ED626A0E7620065BE70 /* kern_compat.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_compat.hpp; sourceTree = ""; }; 58 | D5096ED726A0E7620065BE70 /* kern_api.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_api.hpp; sourceTree = ""; }; 59 | D5096ED826A0E7620065BE70 /* kern_util.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_util.hpp; sourceTree = ""; }; 60 | D5096EFE26A0E7C10065BE70 /* Changelog.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = Changelog.md; sourceTree = SOURCE_ROOT; }; 61 | D5096EFF26A0E7C10065BE70 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; }; 62 | D5096F0026A0E7C10065BE70 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = SOURCE_ROOT; }; 63 | D58FCBB226AC06CD009D3C46 /* GenericUSBCardReaderController.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GenericUSBCardReaderController.cpp; sourceTree = ""; }; 64 | D58FCBB326AC06CD009D3C46 /* GenericUSBCardReaderController.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = GenericUSBCardReaderController.hpp; sourceTree = ""; }; 65 | D58FCBB626AE0892009D3C46 /* FAQ.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = FAQ.md; sourceTree = SOURCE_ROOT; }; 66 | /* End PBXFileReference section */ 67 | 68 | /* Begin PBXFrameworksBuildPhase section */ 69 | D5096E9C26A0E5B70065BE70 /* Frameworks */ = { 70 | isa = PBXFrameworksBuildPhase; 71 | buildActionMask = 2147483647; 72 | files = ( 73 | D5096EAE26A0E6870065BE70 /* libkmod.a in Frameworks */, 74 | ); 75 | runOnlyForDeploymentPostprocessing = 0; 76 | }; 77 | /* End PBXFrameworksBuildPhase section */ 78 | 79 | /* Begin PBXGroup section */ 80 | D5096E9526A0E5B70065BE70 = { 81 | isa = PBXGroup; 82 | children = ( 83 | D5096EAF26A0E74A0065BE70 /* SDK */, 84 | D5096EA126A0E5B70065BE70 /* GenericCardReaderFriend */, 85 | D5096EA026A0E5B70065BE70 /* Products */, 86 | D5096EAC26A0E6700065BE70 /* Frameworks */, 87 | ); 88 | sourceTree = ""; 89 | }; 90 | D5096EA026A0E5B70065BE70 /* Products */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | D5096E9F26A0E5B70065BE70 /* GenericCardReaderFriend.kext */, 94 | ); 95 | name = Products; 96 | sourceTree = ""; 97 | }; 98 | D5096EA126A0E5B70065BE70 /* GenericCardReaderFriend */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | D5096EFE26A0E7C10065BE70 /* Changelog.md */, 102 | D5096EA426A0E5B70065BE70 /* GenericCardReaderFriend.cpp */, 103 | D58FCBB226AC06CD009D3C46 /* GenericUSBCardReaderController.cpp */, 104 | D58FCBB326AC06CD009D3C46 /* GenericUSBCardReaderController.hpp */, 105 | D5096EA626A0E5B70065BE70 /* Info.plist */, 106 | D5096F0026A0E7C10065BE70 /* LICENSE */, 107 | D5096EFF26A0E7C10065BE70 /* README.md */, 108 | D58FCBB626AE0892009D3C46 /* FAQ.md */, 109 | ); 110 | path = GenericCardReaderFriend; 111 | sourceTree = ""; 112 | }; 113 | D5096EAC26A0E6700065BE70 /* Frameworks */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | D5096EAD26A0E6700065BE70 /* libkmod.a */, 117 | ); 118 | name = Frameworks; 119 | sourceTree = ""; 120 | }; 121 | D5096EAF26A0E74A0065BE70 /* SDK */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | D5096EB726A0E7620065BE70 /* Headers */, 125 | D5096EB026A0E7620065BE70 /* Library */, 126 | ); 127 | name = SDK; 128 | sourceTree = ""; 129 | }; 130 | D5096EB026A0E7620065BE70 /* Library */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | D5096EB126A0E7620065BE70 /* wrappers */, 134 | D5096EB626A0E7620065BE70 /* plugin_start.cpp */, 135 | ); 136 | name = Library; 137 | path = Lilu.kext/Contents/Resources/Library; 138 | sourceTree = ""; 139 | }; 140 | D5096EB126A0E7620065BE70 /* wrappers */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | D5096EB226A0E7620065BE70 /* entry64.S */, 144 | D5096EB326A0E7620065BE70 /* build.tool */, 145 | D5096EB426A0E7620065BE70 /* entry32.S */, 146 | D5096EB526A0E7620065BE70 /* wrappers.inc */, 147 | ); 148 | path = wrappers; 149 | sourceTree = ""; 150 | }; 151 | D5096EB726A0E7620065BE70 /* Headers */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | D5096EB826A0E7620065BE70 /* kern_config.hpp */, 155 | D5096EB926A0E7620065BE70 /* hde64.h */, 156 | D5096EBA26A0E7620065BE70 /* kern_time.hpp */, 157 | D5096EBB26A0E7620065BE70 /* kern_nvram.hpp */, 158 | D5096EBC26A0E7620065BE70 /* kern_cpu.hpp */, 159 | D5096EBD26A0E7620065BE70 /* kern_devinfo.hpp */, 160 | D5096EBE26A0E7620065BE70 /* kern_efi.hpp */, 161 | D5096EBF26A0E7620065BE70 /* kern_policy.hpp */, 162 | D5096EC026A0E7620065BE70 /* kern_user.hpp */, 163 | D5096EC126A0E7620065BE70 /* plugin_start.hpp */, 164 | D5096EC226A0E7620065BE70 /* kern_iokit.hpp */, 165 | D5096EC326A0E7620065BE70 /* kern_crypto.hpp */, 166 | D5096EC426A0E7620065BE70 /* kern_mach.hpp */, 167 | D5096EC526A0E7620065BE70 /* kern_version.hpp */, 168 | D5096EC626A0E7620065BE70 /* kern_compression.hpp */, 169 | D5096EC726A0E7620065BE70 /* kern_file.hpp */, 170 | D5096EC826A0E7620065BE70 /* kern_rtc.hpp */, 171 | D5096EC926A0E7620065BE70 /* kern_disasm.hpp */, 172 | D5096ECA26A0E7620065BE70 /* capstone */, 173 | D5096ED526A0E7620065BE70 /* kern_patcher.hpp */, 174 | D5096ED626A0E7620065BE70 /* kern_compat.hpp */, 175 | D5096ED726A0E7620065BE70 /* kern_api.hpp */, 176 | D5096ED826A0E7620065BE70 /* kern_util.hpp */, 177 | ); 178 | name = Headers; 179 | path = Lilu.kext/Contents/Resources/Headers; 180 | sourceTree = ""; 181 | }; 182 | D5096ECA26A0E7620065BE70 /* capstone */ = { 183 | isa = PBXGroup; 184 | children = ( 185 | D5096ECB26A0E7620065BE70 /* capstone.h */, 186 | D5096ECC26A0E7620065BE70 /* mips.h */, 187 | D5096ECD26A0E7620065BE70 /* sparc.h */, 188 | D5096ECE26A0E7620065BE70 /* systemz.h */, 189 | D5096ECF26A0E7620065BE70 /* arm.h */, 190 | D5096ED026A0E7620065BE70 /* x86.h */, 191 | D5096ED126A0E7620065BE70 /* ppc.h */, 192 | D5096ED226A0E7620065BE70 /* arm64.h */, 193 | D5096ED326A0E7620065BE70 /* xcore.h */, 194 | D5096ED426A0E7620065BE70 /* platform.h */, 195 | ); 196 | path = capstone; 197 | sourceTree = ""; 198 | }; 199 | /* End PBXGroup section */ 200 | 201 | /* Begin PBXHeadersBuildPhase section */ 202 | D5096E9A26A0E5B70065BE70 /* Headers */ = { 203 | isa = PBXHeadersBuildPhase; 204 | buildActionMask = 2147483647; 205 | files = ( 206 | D58FCBB526AC06CD009D3C46 /* GenericUSBCardReaderController.hpp in Headers */, 207 | ); 208 | runOnlyForDeploymentPostprocessing = 0; 209 | }; 210 | /* End PBXHeadersBuildPhase section */ 211 | 212 | /* Begin PBXNativeTarget section */ 213 | D5096E9E26A0E5B70065BE70 /* GenericCardReaderFriend */ = { 214 | isa = PBXNativeTarget; 215 | buildConfigurationList = D5096EA926A0E5B70065BE70 /* Build configuration list for PBXNativeTarget "GenericCardReaderFriend" */; 216 | buildPhases = ( 217 | D5096E9A26A0E5B70065BE70 /* Headers */, 218 | D5096E9B26A0E5B70065BE70 /* Sources */, 219 | D5096E9C26A0E5B70065BE70 /* Frameworks */, 220 | D5096E9D26A0E5B70065BE70 /* Resources */, 221 | D58DAFF9273DFAD600564716 /* Archive */, 222 | ); 223 | buildRules = ( 224 | ); 225 | dependencies = ( 226 | ); 227 | name = GenericCardReaderFriend; 228 | productName = RealtekCardReaderFriend; 229 | productReference = D5096E9F26A0E5B70065BE70 /* GenericCardReaderFriend.kext */; 230 | productType = "com.apple.product-type.kernel-extension"; 231 | }; 232 | /* End PBXNativeTarget section */ 233 | 234 | /* Begin PBXProject section */ 235 | D5096E9626A0E5B70065BE70 /* Project object */ = { 236 | isa = PBXProject; 237 | attributes = { 238 | LastUpgradeCheck = 1250; 239 | TargetAttributes = { 240 | D5096E9E26A0E5B70065BE70 = { 241 | CreatedOnToolsVersion = 12.5.1; 242 | }; 243 | }; 244 | }; 245 | buildConfigurationList = D5096E9926A0E5B70065BE70 /* Build configuration list for PBXProject "GenericCardReaderFriend" */; 246 | compatibilityVersion = "Xcode 9.3"; 247 | developmentRegion = en; 248 | hasScannedForEncodings = 0; 249 | knownRegions = ( 250 | en, 251 | Base, 252 | ); 253 | mainGroup = D5096E9526A0E5B70065BE70; 254 | productRefGroup = D5096EA026A0E5B70065BE70 /* Products */; 255 | projectDirPath = ""; 256 | projectRoot = ""; 257 | targets = ( 258 | D5096E9E26A0E5B70065BE70 /* GenericCardReaderFriend */, 259 | ); 260 | }; 261 | /* End PBXProject section */ 262 | 263 | /* Begin PBXResourcesBuildPhase section */ 264 | D5096E9D26A0E5B70065BE70 /* Resources */ = { 265 | isa = PBXResourcesBuildPhase; 266 | buildActionMask = 2147483647; 267 | files = ( 268 | D5096F0326A0E7C10065BE70 /* LICENSE in Resources */, 269 | ); 270 | runOnlyForDeploymentPostprocessing = 0; 271 | }; 272 | /* End PBXResourcesBuildPhase section */ 273 | 274 | /* Begin PBXShellScriptBuildPhase section */ 275 | D58DAFF9273DFAD600564716 /* Archive */ = { 276 | isa = PBXShellScriptBuildPhase; 277 | buildActionMask = 2147483647; 278 | files = ( 279 | ); 280 | inputFileListPaths = ( 281 | ); 282 | inputPaths = ( 283 | ); 284 | name = Archive; 285 | outputFileListPaths = ( 286 | ); 287 | outputPaths = ( 288 | ); 289 | runOnlyForDeploymentPostprocessing = 0; 290 | shellPath = /bin/sh; 291 | shellScript = "# Get the latest hash\ncd \"$(PROJECT_DIR)\"\nHASH=`git log --pretty=format:'%h' -n 1`\n\n# Archive the kext\ncd \"${TARGET_BUILD_DIR}\"\nrm -rf *.zip\narchive=\"${PRODUCT_NAME}_${MODULE_VERSION}_${HASH}_$(echo $CONFIGURATION | tr /a-z/ /A-Z/).zip\"\nzip \"${archive}\" -r \"$FULL_PRODUCT_NAME\"\n"; 292 | }; 293 | /* End PBXShellScriptBuildPhase section */ 294 | 295 | /* Begin PBXSourcesBuildPhase section */ 296 | D5096E9B26A0E5B70065BE70 /* Sources */ = { 297 | isa = PBXSourcesBuildPhase; 298 | buildActionMask = 2147483647; 299 | files = ( 300 | D5096EDD26A0E7620065BE70 /* plugin_start.cpp in Sources */, 301 | D58FCBB426AC06CD009D3C46 /* GenericUSBCardReaderController.cpp in Sources */, 302 | D5096EA526A0E5B70065BE70 /* GenericCardReaderFriend.cpp in Sources */, 303 | ); 304 | runOnlyForDeploymentPostprocessing = 0; 305 | }; 306 | /* End PBXSourcesBuildPhase section */ 307 | 308 | /* Begin XCBuildConfiguration section */ 309 | D5096EA726A0E5B70065BE70 /* Debug */ = { 310 | isa = XCBuildConfiguration; 311 | buildSettings = { 312 | ALWAYS_SEARCH_USER_PATHS = NO; 313 | CLANG_ANALYZER_NONNULL = YES; 314 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 315 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 316 | CLANG_CXX_LIBRARY = "libc++"; 317 | CLANG_ENABLE_MODULES = YES; 318 | CLANG_ENABLE_OBJC_ARC = YES; 319 | CLANG_ENABLE_OBJC_WEAK = YES; 320 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 321 | CLANG_WARN_BOOL_CONVERSION = YES; 322 | CLANG_WARN_COMMA = YES; 323 | CLANG_WARN_CONSTANT_CONVERSION = YES; 324 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 325 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 326 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 327 | CLANG_WARN_EMPTY_BODY = YES; 328 | CLANG_WARN_ENUM_CONVERSION = YES; 329 | CLANG_WARN_INFINITE_RECURSION = YES; 330 | CLANG_WARN_INT_CONVERSION = YES; 331 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 332 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 333 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 334 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 335 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 336 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 337 | CLANG_WARN_STRICT_PROTOTYPES = YES; 338 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 339 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 340 | CLANG_WARN_UNREACHABLE_CODE = YES; 341 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 342 | COPY_PHASE_STRIP = NO; 343 | DEBUG_INFORMATION_FORMAT = dwarf; 344 | ENABLE_STRICT_OBJC_MSGSEND = YES; 345 | ENABLE_TESTABILITY = YES; 346 | GCC_C_LANGUAGE_STANDARD = gnu11; 347 | GCC_DYNAMIC_NO_PIC = NO; 348 | GCC_NO_COMMON_BLOCKS = YES; 349 | GCC_OPTIMIZATION_LEVEL = 0; 350 | GCC_PREPROCESSOR_DEFINITIONS = ( 351 | "DEBUG=1", 352 | "$(inherited)", 353 | ); 354 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 355 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 356 | GCC_WARN_UNDECLARED_SELECTOR = YES; 357 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 358 | GCC_WARN_UNUSED_FUNCTION = YES; 359 | GCC_WARN_UNUSED_VARIABLE = YES; 360 | KERNEL_EXTENSION_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/MacKernelSDK/Headers"; 361 | KERNEL_FRAMEWORK_HEADERS = "$(PROJECT_DIR)/MacKernelSDK/Headers"; 362 | MACOSX_DEPLOYMENT_TARGET = 10.14; 363 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 364 | MTL_FAST_MATH = YES; 365 | ONLY_ACTIVE_ARCH = YES; 366 | SDKROOT = macosx; 367 | }; 368 | name = Debug; 369 | }; 370 | D5096EA826A0E5B70065BE70 /* Release */ = { 371 | isa = XCBuildConfiguration; 372 | buildSettings = { 373 | ALWAYS_SEARCH_USER_PATHS = NO; 374 | CLANG_ANALYZER_NONNULL = YES; 375 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 376 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 377 | CLANG_CXX_LIBRARY = "libc++"; 378 | CLANG_ENABLE_MODULES = YES; 379 | CLANG_ENABLE_OBJC_ARC = YES; 380 | CLANG_ENABLE_OBJC_WEAK = YES; 381 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 382 | CLANG_WARN_BOOL_CONVERSION = YES; 383 | CLANG_WARN_COMMA = YES; 384 | CLANG_WARN_CONSTANT_CONVERSION = YES; 385 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 386 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 387 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 388 | CLANG_WARN_EMPTY_BODY = YES; 389 | CLANG_WARN_ENUM_CONVERSION = YES; 390 | CLANG_WARN_INFINITE_RECURSION = YES; 391 | CLANG_WARN_INT_CONVERSION = YES; 392 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 393 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 394 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 395 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 396 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 397 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 398 | CLANG_WARN_STRICT_PROTOTYPES = YES; 399 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 400 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 401 | CLANG_WARN_UNREACHABLE_CODE = YES; 402 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 403 | COPY_PHASE_STRIP = NO; 404 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 405 | ENABLE_NS_ASSERTIONS = NO; 406 | ENABLE_STRICT_OBJC_MSGSEND = YES; 407 | GCC_C_LANGUAGE_STANDARD = gnu11; 408 | GCC_NO_COMMON_BLOCKS = YES; 409 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 410 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 411 | GCC_WARN_UNDECLARED_SELECTOR = YES; 412 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 413 | GCC_WARN_UNUSED_FUNCTION = YES; 414 | GCC_WARN_UNUSED_VARIABLE = YES; 415 | KERNEL_EXTENSION_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/MacKernelSDK/Headers"; 416 | KERNEL_FRAMEWORK_HEADERS = "$(PROJECT_DIR)/MacKernelSDK/Headers"; 417 | MACOSX_DEPLOYMENT_TARGET = 10.14; 418 | MTL_ENABLE_DEBUG_INFO = NO; 419 | MTL_FAST_MATH = YES; 420 | SDKROOT = macosx; 421 | }; 422 | name = Release; 423 | }; 424 | D5096EAA26A0E5B70065BE70 /* Debug */ = { 425 | isa = XCBuildConfiguration; 426 | buildSettings = { 427 | ARCHS = x86_64; 428 | CLANG_WARN_DOCUMENTATION_COMMENTS = NO; 429 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; 430 | CODE_SIGN_STYLE = Automatic; 431 | COMBINE_HIDPI_IMAGES = YES; 432 | CURRENT_PROJECT_VERSION = "$(MODULE_VERSION)"; 433 | GCC_PREPROCESSOR_DEFINITIONS = ( 434 | "DEBUG=1", 435 | "MODULE_VERSION=$(MODULE_VERSION)", 436 | "PRODUCT_NAME=$(PRODUCT_NAME)", 437 | "$(inherited)", 438 | ); 439 | HEADER_SEARCH_PATHS = "${PROJECT_DIR}/Lilu.kext/Contents/Resources"; 440 | INFOPLIST_FILE = GenericCardReaderFriend/Info.plist; 441 | LIBRARY_SEARCH_PATHS = ( 442 | "$(inherited)", 443 | "$(PROJECT_DIR)/MacKernelSDK/Library/x86_64", 444 | ); 445 | MACOSX_DEPLOYMENT_TARGET = 10.11; 446 | MARKETING_VERSION = "$(MODULE_VERSION)"; 447 | MODULE_NAME = science.firewolf.gcrf; 448 | MODULE_START = "$(PRODUCT_NAME)_kern_start"; 449 | MODULE_STOP = "$(PRODUCT_NAME)_kern_stop"; 450 | MODULE_VERSION = 1.0.4; 451 | PRODUCT_BUNDLE_IDENTIFIER = science.firewolf.gcrf; 452 | PRODUCT_NAME = "$(TARGET_NAME)"; 453 | RUN_CLANG_STATIC_ANALYZER = YES; 454 | WRAPPER_EXTENSION = kext; 455 | }; 456 | name = Debug; 457 | }; 458 | D5096EAB26A0E5B70065BE70 /* Release */ = { 459 | isa = XCBuildConfiguration; 460 | buildSettings = { 461 | ARCHS = x86_64; 462 | CLANG_WARN_DOCUMENTATION_COMMENTS = NO; 463 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; 464 | CODE_SIGN_STYLE = Automatic; 465 | COMBINE_HIDPI_IMAGES = YES; 466 | CURRENT_PROJECT_VERSION = "$(MODULE_VERSION)"; 467 | GCC_PREPROCESSOR_DEFINITIONS = ( 468 | "MODULE_VERSION=$(MODULE_VERSION)", 469 | "PRODUCT_NAME=$(PRODUCT_NAME)", 470 | ); 471 | HEADER_SEARCH_PATHS = "${PROJECT_DIR}/Lilu.kext/Contents/Resources"; 472 | INFOPLIST_FILE = GenericCardReaderFriend/Info.plist; 473 | LIBRARY_SEARCH_PATHS = ( 474 | "$(inherited)", 475 | "$(PROJECT_DIR)/MacKernelSDK/Library/x86_64", 476 | ); 477 | MACOSX_DEPLOYMENT_TARGET = 10.11; 478 | MARKETING_VERSION = "$(MODULE_VERSION)"; 479 | MODULE_NAME = science.firewolf.gcrf; 480 | MODULE_START = "$(PRODUCT_NAME)_kern_start"; 481 | MODULE_STOP = "$(PRODUCT_NAME)_kern_stop"; 482 | MODULE_VERSION = 1.0.4; 483 | PRODUCT_BUNDLE_IDENTIFIER = science.firewolf.gcrf; 484 | PRODUCT_NAME = "$(TARGET_NAME)"; 485 | RUN_CLANG_STATIC_ANALYZER = YES; 486 | WRAPPER_EXTENSION = kext; 487 | }; 488 | name = Release; 489 | }; 490 | /* End XCBuildConfiguration section */ 491 | 492 | /* Begin XCConfigurationList section */ 493 | D5096E9926A0E5B70065BE70 /* Build configuration list for PBXProject "GenericCardReaderFriend" */ = { 494 | isa = XCConfigurationList; 495 | buildConfigurations = ( 496 | D5096EA726A0E5B70065BE70 /* Debug */, 497 | D5096EA826A0E5B70065BE70 /* Release */, 498 | ); 499 | defaultConfigurationIsVisible = 0; 500 | defaultConfigurationName = Release; 501 | }; 502 | D5096EA926A0E5B70065BE70 /* Build configuration list for PBXNativeTarget "GenericCardReaderFriend" */ = { 503 | isa = XCConfigurationList; 504 | buildConfigurations = ( 505 | D5096EAA26A0E5B70065BE70 /* Debug */, 506 | D5096EAB26A0E5B70065BE70 /* Release */, 507 | ); 508 | defaultConfigurationIsVisible = 0; 509 | defaultConfigurationName = Release; 510 | }; 511 | /* End XCConfigurationList section */ 512 | }; 513 | rootObject = D5096E9626A0E5B70065BE70 /* Project object */; 514 | } 515 | -------------------------------------------------------------------------------- /GenericCardReaderFriend.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GenericCardReaderFriend.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GenericCardReaderFriend.xcodeproj/xcshareddata/xcschemes/GenericCardReaderFriend (Debug).xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 57 | 58 | 59 | 60 | 62 | 63 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /GenericCardReaderFriend.xcodeproj/xcshareddata/xcschemes/GenericCardReaderFriend (Release).xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 57 | 58 | 59 | 60 | 62 | 63 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /GenericCardReaderFriend/GenericCardReaderFriend.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // GenericCardReaderFriend.cpp 3 | // GenericCardReaderFriend 4 | // 5 | // Created by FireWolf on 7/24/21. 6 | // 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | // 13 | // MARK: - Constants & Patches 14 | // 15 | 16 | static const char* kCardReaderReporterPath = "/System/Library/SystemProfiler/SPCardReaderReporter.spreporter"; 17 | 18 | static const size_t kCardReaderReporterPathLength = strlen(kCardReaderReporterPath); 19 | 20 | // MARK: USB-based Card Reader 21 | 22 | // Function: SPCardReaderReporter::updateDictionary() 23 | // Find: IOServiceMatching("com_apple_driver_AppleUSBCardReaderSBC") 24 | // Repl: IOServiceMatching("GenericUSBCardReaderController") 25 | // Note: Patch the name of the controller class 26 | static const uint8_t kAppleUSBCardReaderSBC[] = 27 | { 28 | 0x63, 0x6F, 0x6D, // "com" 29 | 0x5F, // "_" 30 | 0x61, 0x70, 0x70, 0x6C, 0x65, // "apple" 31 | 0x5F, // "_" 32 | 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, // "driver" 33 | 0x5F, // "_" 34 | 0x41, 0x70, 0x70, 0x6C, 0x65, // "Apple" 35 | 0x55, 0x53, 0x42, // "USB" 36 | 0x43, 0x61, 0x72, 0x64, // "Card" 37 | 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, // "Reader" 38 | 0x53, 0x42, 0x43, // "SBC" 39 | 0x00 // "\0" 40 | }; 41 | 42 | static const uint8_t kGenericUSBCardReaderController[] = 43 | { 44 | 0x47, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 45 | 0x55, 0x53, 0x42, 46 | 0x43, 0x61, 0x72, 0x64, 47 | 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, 48 | 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 50 | }; 51 | 52 | // Function: SPCardReaderReporter::updateDictionary() 53 | // Find: IORegistryEntrySearchCFProperty(entry, "IOService", kCFBundleIdentifierKey, kCFAllocatorDefault, kIORegistryIterateRecursively) 54 | // NSString isEqualToString("com.apple.driver.AppleUSBCardReader") 55 | // Repl: NSString isEqualToString("science.firewolf.gcrf") 56 | // Note: Patch the bundle identifier 57 | static const uint8_t kAppleUCRBundleIdentifier[] = 58 | { 59 | 0x63, 0x6F, 0x6D, // "com" 60 | 0x2E, // "." 61 | 0x61, 0x70, 0x70, 0x6C, 0x65, // "apple" 62 | 0x2E, // "." 63 | 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, // "driver" 64 | 0x2E, // "." 65 | 0x41, 0x70, 0x70, 0x6C, 0x65, // "Apple" 66 | 0x55, 0x53, 0x42, // "USB" 67 | 0x43, 0x61, 0x72, 0x64, // "Card" 68 | 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, // "Reader" 69 | 0x00 // "\0" 70 | }; 71 | 72 | static const uint8_t kDummyUCRBundleIdentifier[] = 73 | { 74 | 0x73, 0x63, 0x69, 0x65, 0x6E, 0x63, 0x65, 75 | 0x2E, 76 | 0x66, 0x69, 0x72, 0x65, 0x77, 0x6F, 0x6C, 0x66, 77 | 0x2E, 78 | 0x67, 0x63, 0x72, 0x66, 79 | 0x00, 0x00, 0x00, 0x00, 0x00, 80 | 0x00, 0x00, 0x00, 0x00, 0x00, 81 | 0x00, 0x00, 0x00, 0x00, 0x00, 82 | }; 83 | 84 | // 85 | // MARK: - Helper Functions 86 | // 87 | 88 | static inline bool matchReporterPath(const char* path) 89 | { 90 | return strncmp(path, kCardReaderReporterPath, kCardReaderReporterPathLength) == 0; 91 | } 92 | 93 | static void patchReporter(const void* data, vm_size_t size) 94 | { 95 | void* memory = const_cast(data); 96 | 97 | SYSLOG_COND(UNLIKELY(KernelPatcher::findAndReplace(memory, size, kAppleUSBCardReaderSBC, kGenericUSBCardReaderController)), "GCRF", "Patched the USB controller name."); 98 | 99 | SYSLOG_COND(UNLIKELY(KernelPatcher::findAndReplace(memory, size, kAppleUCRBundleIdentifier, kDummyUCRBundleIdentifier)), "GCRF", "Patched the USB bundle identifier."); 100 | } 101 | 102 | // 103 | // MARK: - Routed Functions 104 | // 105 | 106 | // macOS Catalina and earlier 107 | static boolean_t (*orgCSValidateRange)(vnode_t, memory_object_t, memory_object_offset_t, const void*, vm_size_t, unsigned int*) = nullptr; 108 | 109 | static boolean_t wrapCSValidateRange(vnode_t vp, memory_object_t pager, memory_object_offset_t offset, const void* data, vm_size_t size, unsigned int* result) 110 | { 111 | char path[PATH_MAX]; 112 | 113 | int pathlen = PATH_MAX; 114 | 115 | boolean_t retVal = (*orgCSValidateRange)(vp, pager, offset, data, size, result); 116 | 117 | if (retVal && vn_getpath(vp, path, &pathlen) == 0 && matchReporterPath(path)) 118 | { 119 | patchReporter(data, size); 120 | } 121 | 122 | return retVal; 123 | } 124 | 125 | // macOS Big Sur and later 126 | static void (*orgCSValidatePage)(vnode_t, memory_object_t, memory_object_offset_t, const void*, int*, int*, int*) = nullptr; 127 | 128 | static void wrapCSValidatePage(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) 129 | { 130 | char path[PATH_MAX]; 131 | 132 | int pathlen = PATH_MAX; 133 | 134 | (*orgCSValidatePage)(vp, pager, page_offset, data, validated_p, tainted_p, nx_p); 135 | 136 | if (vn_getpath(vp, path, &pathlen) == 0 && matchReporterPath(path)) 137 | { 138 | patchReporter(data, PAGE_SIZE); 139 | } 140 | } 141 | 142 | // 143 | // MARK: - Boot Args 144 | // 145 | 146 | static const char *bootargOff[] = 147 | { 148 | "-gcrfoff" 149 | }; 150 | 151 | static const char *bootargDebug[] = 152 | { 153 | "-gcrfdbg" 154 | }; 155 | 156 | static const char *bootargBeta[] = 157 | { 158 | "-gcrfbeta" 159 | }; 160 | 161 | // 162 | // MARK: - Plugin Start Routine 163 | // 164 | 165 | static KernelPatcher::RouteRequest gRequestLegacy = 166 | { 167 | "_cs_validate_range", 168 | wrapCSValidateRange, 169 | orgCSValidateRange 170 | }; 171 | 172 | static KernelPatcher::RouteRequest gRequestCurrent = 173 | { 174 | "_cs_validate_page", 175 | wrapCSValidatePage, 176 | orgCSValidatePage 177 | }; 178 | 179 | static void start() 180 | { 181 | DBGLOG("GCRF", "Realtek card reader friend started."); 182 | 183 | auto action = [](void*, KernelPatcher& patcher) -> void 184 | { 185 | KernelPatcher::RouteRequest* request = getKernelVersion() >= KernelVersion::BigSur ? &gRequestCurrent : &gRequestLegacy; 186 | 187 | if (!patcher.routeMultipleLong(KernelPatcher::KernelID, request, 1)) 188 | { 189 | SYSLOG("GCRF", "Failed to route the function."); 190 | } 191 | }; 192 | 193 | lilu.onPatcherLoadForce(action); 194 | } 195 | 196 | // 197 | // MARK: - Plugin Configuration 198 | // 199 | 200 | PluginConfiguration ADDPR(config) = 201 | { 202 | xStringify(PRODUCT_NAME), 203 | parseModuleVersion(xStringify(MODULE_VERSION)), 204 | LiluAPI::AllowNormal, 205 | bootargOff, 206 | arrsize(bootargOff), 207 | bootargDebug, 208 | arrsize(bootargDebug), 209 | bootargBeta, 210 | arrsize(bootargBeta), 211 | KernelVersion::ElCapitan, 212 | KernelVersion::Ventura, 213 | start 214 | }; 215 | -------------------------------------------------------------------------------- /GenericCardReaderFriend/GenericUSBCardReaderController.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // GenericUSBCardReaderController.cpp 3 | // GenericCardReaderFriend 4 | // 5 | // Created by FireWolf on 7/24/21. 6 | // 7 | 8 | #include "GenericUSBCardReaderController.hpp" 9 | 10 | // 11 | // MARK: - Meta Class Definitions 12 | // 13 | 14 | OSDefineMetaClassAndStructors(GenericUSBCardReaderController, IOService); 15 | 16 | // 17 | // MARK: - IOKit Basics 18 | // 19 | 20 | /// 21 | /// Start the controller 22 | /// 23 | /// @param provider An instance of USB host device that represents the card reader 24 | /// @return `true` on success, `false` otherwise. 25 | /// 26 | bool GenericUSBCardReaderController::start(IOService* provider) 27 | { 28 | // Start the super class 29 | if (!super::start(provider)) 30 | { 31 | return false; 32 | } 33 | 34 | // Fetch the USB host device 35 | this->device = OSDynamicCast(IOUSBHostDevice, provider); 36 | 37 | if (this->device == nullptr) 38 | { 39 | return false; 40 | } 41 | 42 | this->device->retain(); 43 | 44 | // Publish the USB device information 45 | static const char* keys[] = 46 | { 47 | "idVendor", 48 | "idProduct", 49 | "kUSBSerialNumberString", 50 | }; 51 | 52 | OSDictionary* deviceInfo = OSDictionary::withCapacity(3); 53 | 54 | for (const char* key : keys) 55 | { 56 | deviceInfo->setObject(key, this->device->getProperty(key)); 57 | } 58 | 59 | this->setProperty("USB Device Info", deviceInfo); 60 | 61 | OSSafeReleaseNULL(deviceInfo); 62 | 63 | // Publish the revision level 64 | this->setProperty("Product Revision Level", "1.00"); 65 | 66 | // Finished the decoration 67 | this->registerService(); 68 | 69 | return true; 70 | } 71 | 72 | /// 73 | /// Stop the controller 74 | /// 75 | /// @param provider An instance of USB host device that represents the card reader 76 | /// 77 | void GenericUSBCardReaderController::stop(IOService* provider) 78 | { 79 | OSSafeReleaseNULL(this->device); 80 | 81 | super::stop(provider); 82 | } 83 | -------------------------------------------------------------------------------- /GenericCardReaderFriend/GenericUSBCardReaderController.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // GenericUSBCardReaderController.hpp 3 | // GenericCardReaderFriend 4 | // 5 | // Created by FireWolf on 7/24/21. 6 | // 7 | 8 | #ifndef GenericUSBCardReaderController_hpp 9 | #define GenericUSBCardReaderController_hpp 10 | 11 | // Get rid of a bunch of documentation warnings in the USB headers 12 | #pragma clang diagnostic push 13 | #pragma clang diagnostic ignored "-Wdocumentation" 14 | #include 15 | #pragma clang diagnostic pop 16 | 17 | /// 18 | /// A generic USB-based card reader controller that injects properties for decoration 19 | /// 20 | class GenericUSBCardReaderController: public IOService 21 | { 22 | // 23 | // MARK: - Constructors & Destructors 24 | // 25 | 26 | OSDeclareDefaultStructors(GenericUSBCardReaderController); 27 | 28 | using super = IOService; 29 | 30 | // 31 | // MARK: - IOKit Basics 32 | // 33 | 34 | /// The USB host device (provider) 35 | IOUSBHostDevice* device; 36 | 37 | public: 38 | /// 39 | /// Start the controller 40 | /// 41 | /// @param provider An instance of USB host device that represents the card reader 42 | /// @return `true` on success, `false` otherwise. 43 | /// 44 | bool start(IOService* provider) override; 45 | 46 | /// 47 | /// Stop the controller 48 | /// 49 | /// @param provider An instance of USB host device that represents the card reader 50 | /// 51 | void stop(IOService* provider) override; 52 | }; 53 | 54 | #endif /* GenericUSBCardReaderController_hpp */ 55 | -------------------------------------------------------------------------------- /GenericCardReaderFriend/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | $(MARKETING_VERSION) 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | IOKitPersonalities 22 | 23 | GenericCardReaderFriend 24 | 25 | CFBundleIdentifier 26 | $(PRODUCT_BUNDLE_IDENTIFIER) 27 | IOClass 28 | $(PRODUCT_NAME:rfc1034identifier) 29 | IOMatchCategory 30 | $(PRODUCT_NAME:rfc1034identifier) 31 | IOProviderClass 32 | IOResources 33 | IOResourceMatch 34 | IOKit 35 | 36 | GenericUSBCardReaderController 37 | 38 | CFBundleIdentifier 39 | $(PRODUCT_BUNDLE_IDENTIFIER) 40 | IOClass 41 | GenericUSBCardReaderController 42 | IOMatchCategory 43 | GenericUSBCardReaderController 44 | IOProbeScore 45 | 1000 46 | IOProviderClass 47 | IOUSBHostDevice 48 | Physical Interconnect Location 49 | Internal 50 | Protocol Characteristics 51 | 52 | Physical Interconnect 53 | USB 54 | 55 | idProduct 56 | 375 57 | idVendor 58 | 3034 59 | 60 | 61 | NSHumanReadableCopyright 62 | Copyright © 2021 FireWolf. All rights reserved. 63 | OSBundleLibraries 64 | 65 | as.vit9696.Lilu 66 | 1.4.7 67 | com.apple.iokit.IOUSBHostFamily 68 | 1.2 69 | com.apple.kpi.bsd 70 | 12.0.0 71 | com.apple.kpi.dsep 72 | 12.0.0 73 | com.apple.kpi.iokit 74 | 12.0.0 75 | com.apple.kpi.libkern 76 | 12.0.0 77 | com.apple.kpi.mach 78 | 12.0.0 79 | com.apple.kpi.unsupported 80 | 12.0.0 81 | 82 | OSBundleRequired 83 | Root 84 | 85 | 86 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2021, FireWolf @ FireWolf Pl. 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Generic Card Reader Driver Friend 2 | 3 | ## Introduction 4 | 5 | A Lilu plugin that makes System Information recognize your builtin USB card reader as a native one. 6 | 7 | ![](Assets/Screenshot.png) 8 | 9 | ## Supported Systems 10 | - macOS Ventura 11 | - macOS Monterey 12 | - macOS Big Sur 13 | - macOS Catalina 14 | - macOS Mojave 15 | - macOS High Sierra 16 | - macOS Sierra 17 | - macOS El Capitan 18 | 19 | ## Dependencies 20 | - [Lilu](https://github.com/acidanthera/Lilu) v1.4.7 or later. 21 | 22 | ## Limitations & Notes 23 | - This plugin contains a dummy driver that attaches to your USB card reader and injects necessary properties. 24 | - This plugin is derived from but **NOT** compatible with [RealtekCardReaderFriend](https://github.com/0xFireWolf/RealtekCardReaderFriend/). 25 | - This plugin is for decoration purposes only, and your card information will **NOT** be present by System Information. 26 | - This plugin does **NOT** work out of box, and you must follow the [guide](FAQ.md) to specify the vendor and the product identifiers of your card reader. 27 | - If your card reader is powered by either [`AppleUSBCardReader.kext`](file:///System/Library/Extensions/AppleStorageDrivers.kext/Contents/PlugIns/AppleUSBCardReader.kext) or [`RealtekCardReader.kext`](https://github.com/0xFireWolf/RealtekCardReader), you should **NOT** use this plugin. 28 | 29 | ## Support 30 | If you would like to support my work, please consider a donation. 31 | 32 | [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate/?business=M6AHXMUVSZQTS&no_recurring=0&item_name=Support+Realtek+PCIe+card+deader+driver+for+macOS¤cy_code=USD) 33 | 34 | 35 | ## Boot Arguments 36 | - `-gcrfoff` (or `-liluoff`) to disable 37 | - `-gcrfdbg` (or `-liludbgall`) to enable verbose logging (in DEBUG builds) 38 | - `-gcrfbeta` (or `-lilubetaall`) to enable on macOS newer than 12 39 | 40 | ## Credits 41 | - [vit9696](https://github.com/vit9696) for [Lilu.kext](https://github.com/vit9696/Lilu) 42 | - [Acidanthera](https://github.com/acidanthera) for [MacKernelSDK](https://github.com/acidanthera/MacKernelSDK) 43 | - [FireWolf](https://github.com/0xFireWolf) for developing the card reader driver and its companion Lilu plugin for macOS 44 | 45 | ## Acknowledgement 46 | - [dreamwhite](https://github.com/dreamwhite) for testing the early beta release. 47 | 48 | ## License 49 | This project is licensed under BSD-3-Clause. 50 | Copyright (C) 2021 FireWolf @ FireWolf Pl. All Rights Reserved. 51 | --------------------------------------------------------------------------------