├── .vscode └── settings.json ├── README.md ├── all.sh ├── build.sh ├── main.m ├── patch.py └── run.sh /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "python.linting.enabled": false 3 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Inect code into Marzipan compatible host app. 2 | 3 | Quick PoC of running UIKit code on macOS. Requires macOS Mojave Beta 4 | 5 | *Note*: You might need to disable SIP for this to work. 6 | 7 | # Usage: 8 | 9 | Modify main.m with your own code, run ./all.sh to build, patch and run. 10 | -------------------------------------------------------------------------------- /all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | killall VoiceMemos 3 | ./build.sh 4 | python patch.py 5 | ./run.sh 6 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -rf Hook.dylib 4 | clang -framework Foundation -F/System/iOSSupport/System/Library/Frameworks -framework UIKit -o Hook.dylib -dynamiclib main.m 5 | -------------------------------------------------------------------------------- /main.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // Forward Declare anything you might use. 6 | @class UIWindow; 7 | @class UIScreen; 8 | @class UIViewController; 9 | @class UIView; 10 | @class UIColor; 11 | @class UILabel; 12 | @class UIAlertController; 13 | 14 | static IMP sOriginalImp = NULL; 15 | 16 | @interface UILabel: NSObject 17 | @property (nonatomic, assign) CGRect frame; 18 | @end 19 | 20 | @interface Hook: NSObject 21 | 22 | @end 23 | 24 | @implementation Hook 25 | 26 | +(void)load 27 | { 28 | Class originalClass = NSClassFromString(@"RecorderAppDelegate"); 29 | Method originalMeth = class_getInstanceMethod(originalClass, @selector(applicationDidFinishLaunching:)); 30 | sOriginalImp = method_getImplementation(originalMeth); 31 | 32 | Method replacementMeth = class_getInstanceMethod(NSClassFromString(@"Hook"), @selector(applicationDidFinishLaunching:)); 33 | method_exchangeImplementations(originalMeth, replacementMeth); 34 | } 35 | 36 | -(void)applicationDidFinishLaunching:(id)sender 37 | { 38 | UILabel *label = [[UILabel alloc] init]; 39 | [label setValue:@"Hello World!" forKey:@"text"]; 40 | label.frame = CGRectMake(100, 100, 100, 100); 41 | 42 | UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Hello World" 43 | message:@"This is an alert view controller." 44 | preferredStyle:1]; 45 | 46 | UIViewController *vc = [[UIViewController alloc] init]; 47 | [vc setTitle: @"hello wwwdc"]; 48 | [[vc view] setValue:[UIColor redColor] forKey:@"backgroundColor"]; 49 | UIScreen *bounds = [UIScreen mainScreen]; 50 | 51 | [[vc view] addSubview:label]; 52 | 53 | UIWindow *window = [[UIWindow alloc] init]; 54 | [window setValue:vc forKey:@"rootViewController"]; 55 | [window makeKeyAndVisible]; 56 | 57 | [vc presentViewController:alert animated:YES completion:nil]; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /patch.py: -------------------------------------------------------------------------------- 1 | f = file('Hook.dylib') 2 | contents = f.read().replace("\x32\x00\x00\x00\x20\x00\x00\x00\x01\x00\x00\x00", "\x32\x00\x00\x00\x20\x00\x00\x00\x06\x00\x00\x00") 3 | f.close() 4 | f = file('Hook.dylib','wb') 5 | f.write(contents) 6 | f.close() 7 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DYLD_INSERT_LIBRARIES=Hook.dylib /Applications/VoiceMemos.app/Contents/MacOS/VoiceMemos & 4 | --------------------------------------------------------------------------------