Skip to content

Commit

Permalink
Fix Create Windows Bluetooth Registry File
Browse files Browse the repository at this point in the history
  • Loading branch information
benbaker76 committed Jan 23, 2020
1 parent 680e444 commit c5dc8d8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
8 changes: 4 additions & 4 deletions Hackintool.xcodeproj/project.pbxproj
Expand Up @@ -690,7 +690,7 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0292;
CURRENT_PROJECT_VERSION = 0293;
DEVELOPMENT_TEAM = 5LGHPJM9ZR;
ENABLE_HARDENED_RUNTIME = NO;
ENABLE_STRICT_OBJC_MSGSEND = NO;
Expand All @@ -704,7 +704,7 @@
HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libxml2";
INFOPLIST_FILE = "Hackintool/Hackintool-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @executable_path/../Frameworks";
MARKETING_VERSION = 2.9.2;
MARKETING_VERSION = 2.9.3;
PRODUCT_BUNDLE_IDENTIFIER = com.Headsoft.Hackintool;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -724,7 +724,7 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0292;
CURRENT_PROJECT_VERSION = 0293;
DEVELOPMENT_TEAM = 5LGHPJM9ZR;
ENABLE_HARDENED_RUNTIME = NO;
ENABLE_STRICT_OBJC_MSGSEND = NO;
Expand All @@ -738,7 +738,7 @@
HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libxml2";
INFOPLIST_FILE = "Hackintool/Hackintool-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @executable_path/../Frameworks";
MARKETING_VERSION = 2.9.2;
MARKETING_VERSION = 2.9.3;
PRODUCT_BUNDLE_IDENTIFIER = com.Headsoft.Hackintool;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Binary file not shown.
31 changes: 19 additions & 12 deletions Hackintool/AppDelegate.m
Expand Up @@ -35,8 +35,8 @@
#include <cstddef>

#define MyPrivateTableViewDataType @"MyPrivateTableViewDataType"
#define BluetoothPath1 @"blued.plist"
#define BluetoothPath2 @"com.apple.Bluetoothd.plist"
#define BluetoothPath1 @"com.apple.Bluetoothd.plist"
#define BluetoothPath2 @"blued.plist"
#define PCIIDsUrl @"https://pci-ids.ucw.cz/pci.ids"
#define PCIIDsPath [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"pci.ids"]
#define GitSubmoduleUpdate @"/usr/bin/git submodule update --init --recursive"
Expand Down Expand Up @@ -9563,24 +9563,31 @@ - (void)createWindowsBluetoothRegistryFile
if (requestAdministratorRights() != 0)
return;

NSError *error;
NSError *error = nil;
NSString *stdoutString = nil;

if (!launchCommandAsAdmin(@"/usr/bin/defaults", @[@"read", BluetoothPath1, @"LinkKeys"], &stdoutString))
launchCommandAsAdmin(@"/usr/bin/defaults", @[@"read", BluetoothPath2, @"LinkKeys"], &stdoutString);

if (stdoutString == nil)
return;

// Convert new NSData to old format
NSRegularExpression *regEx = [NSRegularExpression regularExpressionWithPattern:@"\\{length = \\d+, bytes = 0x([0-9a-fA-F .]*)\\}" options:0 error:&error];
stdoutString = [regEx stringByReplacingMatchesInString:stdoutString options:0 range:NSMakeRange(0, [stdoutString length]) withTemplate:@"<$1>"];

NSDictionary *linkKeysDictionary = [NSPropertyListSerialization propertyListWithData:[stdoutString dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions format:nil error:&error];

if (linkKeysDictionary == nil)
return;

NSMutableString *outputString = [NSMutableString string];

[outputString appendString:@"Windows Registry Editor Version 5.00\n"];
[outputString appendString:@"\n"];
[outputString appendString:@"[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\BTHPORT\\Parameters\\Keys]\n"];
[outputString appendString:@"\n"];

if (!launchCommandAsAdmin(@"/usr/bin/defaults", @[@"read", BluetoothPath1], &stdoutString))
launchCommandAsAdmin(@"/usr/bin/defaults", @[@"read", BluetoothPath2], &stdoutString);

if (stdoutString == nil)
return;

NSDictionary *bluetoothDictionary = [NSPropertyListSerialization propertyListWithData:[stdoutString dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions format:NULL error:&error];
NSDictionary *linkKeysDictionary = [bluetoothDictionary objectForKey:@"LinkKeys"];

for (NSString *linkKey in linkKeysDictionary.allKeys)
{
NSDictionary *linkKeyDictionary = [linkKeysDictionary objectForKey:linkKey];
Expand Down

0 comments on commit c5dc8d8

Please sign in to comment.