Skip to content

Commit

Permalink
USB updates, download now on Github
Browse files Browse the repository at this point in the history
  • Loading branch information
benbaker76 committed Mar 16, 2020
1 parent 3a008eb commit 780ba0a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
Binary file not shown.
4 changes: 3 additions & 1 deletion Hackintool/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
NSString *version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
[_window setTitle:[NSString stringWithFormat:@"Hackintool v%@", version]];

NSLog(@"Hackintool v%@", version);

_tableViewArray = [@[_infoOutlineView, _generateSerialInfoTableView, _modelInfoTableView, _selectedFBInfoTableView, _currentFBInfoTableView, _vramInfoTableView, _framebufferInfoTableView, _framebufferFlagsTableView, _connectorInfoTableView, _connectorFlagsTableView, _audioDevicesTableView1, _audioInfoTableView, _usbControllersTableView, _usbPortsTableView, _efiPartitionsTableView, _partitionSchemeTableView, _displaysTableView, _resolutionsTableView, _bootloaderInfoTableView, _bootloaderPatchTableView, _nvramTableView, _kextsTableView, _pciDevicesTableView, _networkInterfacesTableView, _bluetoothDevicesTableView, _graphicDevicesTableView, _audioDevicesTableView2, _storageDevicesTableView, _powerSettingsTableView] retain];

for (NSTableView *tableView in _tableViewArray)
Expand Down Expand Up @@ -1161,7 +1163,7 @@ - (void)initUSB
NSString *usbControllerType = [usbControllersDictionary objectForKey:@"Type"];
NSString *usbControllerName = [usbControllersDictionary objectForKey:@"Name"];
NSString *usbControllerSeries = [usbControllersDictionary objectForKey:@"Series"];
NSNumber *usbControllerID = [usbControllersDictionary objectForKey:@"ID"];
NSNumber *usbControllerID = [usbControllersDictionary objectForKey:@"DeviceID"];

NSLog(@"Found USB Controller: %@ %@ (%@-series) Controller (0x%08X)", usbControllerType, usbControllerName, usbControllerSeries, [usbControllerID unsignedIntValue]);
}
Expand Down
2 changes: 1 addition & 1 deletion Hackintool/Hackintool-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>SUFeedURL</key>
<string>https://headsoft.com.au/download/mac/appcast.xml</string>
<string>https://github.com/headkaze/Hackintool/releases/latest/download/appcast.xml</string>
<key>SUPublicEDKey</key>
<string>Dscj0/VuPnW8QjlmbHewn803JDopcJfwlC+R4FMHU/U=</string>
</dict>
Expand Down
44 changes: 30 additions & 14 deletions Hackintool/USB.m
Original file line number Diff line number Diff line change
Expand Up @@ -540,18 +540,28 @@ void addUSBDictionary(AppDelegate *appDelegate, NSMutableDictionary *ioKitPerson
NSString *name = [usbEntryDictionary objectForKey:@"name"];
NSString *usbController = [usbEntryDictionary objectForKey:@"UsbController"];
uint32_t usbControllerID = propertyToUInt32([usbEntryDictionary objectForKey:@"UsbControllerID"]);
//uint32_t usbControllerLocationID = propertyToUInt32([usbEntryDictionary objectForKey:@"UsbControllerLocationID"]);

uint32_t usbControllerLocationID = propertyToUInt32([usbEntryDictionary objectForKey:@"UsbControllerLocationID"]);
uint32_t vendorID = (usbControllerID & 0xFFFF);
uint32_t deviceID = (usbControllerID >> 16);
NSString *deviceName = (usbControllerID != 0 ? [NSString stringWithFormat:@"%04x_%04x", vendorID, deviceID] : @"???");

if (usbController == nil)
continue;

uint32_t port = propertyToUInt32([usbEntryDictionary objectForKey:@"port"]);
NSString *hubName = [usbEntryDictionary objectForKey:@"HubName"];
NSNumber *hubLocation = [usbEntryDictionary objectForKey:@"HubLocation"];
NSString *modelEntryName = [NSString stringWithFormat:@"%@-%@%@", appDelegate.modelIdentifier, usbController, hubName != nil ? @"-internal-hub" : @""];
NSString *modelEntryName = [NSString stringWithFormat:@"%@-%@", appDelegate.modelIdentifier, usbController];
NSString *providerClass = (hubName != nil ? hubName : [usbEntryDictionary objectForKey:@"UsbControllerIOClass"]);
//NSString *providerClass = (hubName != nil ? hubName : ([usbController hasPrefix:@"XH"] ? @"AppleUSBXHCIPCI" : @"AppleUSBEHCIPCI"));

if (hubName != nil)
modelEntryName = [modelEntryName stringByAppendingString:@"-internal-hub"];

// For controllers located at 0x00 we'll append VID/PID
if (usbControllerLocationID == 0x00)
modelEntryName = [modelEntryName stringByAppendingFormat:@"-%@", deviceName];

if (providerClass == nil)
providerClass = ([usbController hasPrefix:@"XH"] ? @"AppleUSBXHCIPCI" : @"AppleUSBEHCIPCI");

Expand Down Expand Up @@ -590,17 +600,19 @@ void addUSBDictionary(AppDelegate *appDelegate, NSMutableDictionary *ioKitPerson

[modelEntryDictionary setObject:@"com.apple.driver.AppleUSBMergeNub" forKey:@"CFBundleIdentifier"];
[modelEntryDictionary setObject:@"AppleUSBMergeNub" forKey:@"IOClass"];

if (usbControllerID != 0)
[modelEntryDictionary setObject:[NSString stringWithFormat:@"0x%08x", usbControllerID] forKey:@"IOPCIPrimaryMatch"];

[modelEntryDictionary setObject:usbController forKey:@"IONameMatch"];
[modelEntryDictionary setObject:providerClass forKey:@"IOProviderClass"];
}

[modelEntryDictionary setObject:appDelegate.modelIdentifier forKey:@"model"];
[modelEntryDictionary setObject:@(5000) forKey:@"IOProbeScore"];

[modelEntryDictionary setObject:usbController forKey:@"UsbController"];

if (usbControllerID != 0)
[modelEntryDictionary setObject:@(usbControllerID) forKey:@"UsbControllerID"];
[modelEntryDictionary setObject:@(usbControllerID) forKey:@"UsbControllerID"];
[modelEntryDictionary setObject:@(usbControllerLocationID) forKey:@"UsbControllerLocationID"];

//injectUSBControllerProperties(appDelegate, ioKitPersonalities, usbControllerID);
}
Expand Down Expand Up @@ -699,7 +711,7 @@ void exportUSBPortsKext(AppDelegate *appDelegate)
NSMutableDictionary *ioKitPersonalities = [NSMutableDictionary dictionary];

[infoDictionary setObject:@"English" forKey:@"CFBundleDevelopmentRegion"];
[infoDictionary setObject:@"1.0 Copyright © 2018 Headsoft. All rights reserved." forKey:@"CFBundleGetInfoString"];
[infoDictionary setObject:@"1.0 Copyright © 2018-2020 Headsoft. All rights reserved." forKey:@"CFBundleGetInfoString"];
[infoDictionary setObject:@"com.Headsoft.USBPorts" forKey:@"CFBundleIdentifier"];
[infoDictionary setObject:@"6.0" forKey:@"CFBundleInfoDictionaryVersion"];
[infoDictionary setObject:@"USBPorts" forKey:@"CFBundleName"];
Expand Down Expand Up @@ -787,10 +799,11 @@ void exportUSBPortsSSDT(AppDelegate *appDelegate)
continue;

uint32_t usbControllerID = propertyToUInt32([modelEntryDictionary objectForKey:@"UsbControllerID"]);
uint32_t deviceID = (usbControllerID & 0xFFFF);
uint32_t productID = (usbControllerID >> 16);
uint32_t usbControllerLocationID = propertyToUInt32([modelEntryDictionary objectForKey:@"UsbControllerLocationID"]);
uint32_t vendorID = (usbControllerID & 0xFFFF);
uint32_t deviceID = (usbControllerID >> 16);
NSString *name = usbController;
NSString *deviceName = (usbControllerID != 0 ? [NSString stringWithFormat:@"%04x_%04x", deviceID, productID] : @"???");
NSString *deviceName = (usbControllerID != 0 ? [NSString stringWithFormat:@"%04x_%04x", vendorID, deviceID] : @"???");
NSNumber *locationID = [modelEntryDictionary objectForKey:@"locationID"];
NSMutableDictionary *ioProviderMergePropertiesDictionary = [modelEntryDictionary objectForKey:@"IOProviderMergeProperties"];
NSData *portCount = [ioProviderMergePropertiesDictionary objectForKey:@"port-count"];
Expand All @@ -805,7 +818,7 @@ void exportUSBPortsSSDT(AppDelegate *appDelegate)

if (usbControllerID != 0)
{
if (![usbController hasPrefix:@"EH"] && ![usbController hasPrefix:@"XH"])
if ((![usbController hasPrefix:@"EH"] && ![usbController hasPrefix:@"XH"]) || usbControllerLocationID == 0x00)
name = deviceName;
}

Expand All @@ -817,14 +830,17 @@ void exportUSBPortsSSDT(AppDelegate *appDelegate)
name = @"HUB2";
}

[ssdtUIACString appendString:[NSString stringWithFormat:@" // %@ (%@)\n", name, deviceName]];
[ssdtUIACString appendString:[NSString stringWithFormat:@" // %@ (%@)\n", usbController, deviceName]];
[ssdtUIACString appendString:[NSString stringWithFormat:@" \"%@\", Package()\n", name]];
[ssdtUIACString appendString:@" {\n"];
[ssdtUIACString appendString:[NSString stringWithFormat:@" \"port-count\", Buffer() { %@ },\n", getByteString(portCount)]];
[ssdtUIACString appendString:@" \"ports\", Package()\n"];
[ssdtUIACString appendString:@" {\n"];

for (NSString *portKey in [portsDictionary allKeys])
NSArray *portKeys = [portsDictionary allKeys];
portKeys = [portKeys sortedArrayUsingSelector:@selector(compare:)];

for (NSString *portKey in portKeys)
{
NSMutableDictionary *usbEntryDictionary = [portsDictionary objectForKey:portKey];

Expand Down

0 comments on commit 780ba0a

Please sign in to comment.