-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b83cb88
commit 31de5e1
Showing
5 changed files
with
90 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+5.92 KB
(140%)
...project.xcworkspace/xcuserdata/mykolagrymalyuk.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// Handler.h | ||
// MacStreamingPlayer | ||
// | ||
// Created by Collin Mistr on 1/19/22. | ||
// | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
@interface Handler : NSObject <NSApplicationDelegate> | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// Handler.m | ||
// MacStreamingPlayer | ||
// | ||
// Created by Collin Mistr on 1/19/22. | ||
// | ||
// | ||
|
||
#import "Handler.h" | ||
#import "STPrivilegedTask.h" | ||
|
||
|
||
@implementation Handler | ||
|
||
-(void)applicationDidFinishLaunching:(NSNotification *)notification { | ||
[self performSelectorInBackground:@selector(runProcess) withObject:nil]; | ||
} | ||
|
||
-(void)runProcess { | ||
int exitCode = 0; | ||
NSLog(@"Starting..."); | ||
|
||
STPrivilegedTask *privilegedTask = [[STPrivilegedTask alloc] init]; | ||
NSArray *components = [[NSProcessInfo processInfo] arguments]; | ||
NSMutableArray *arguments = [NSMutableArray arrayWithArray:components]; | ||
|
||
|
||
NSString *launchPath = arguments[1]; | ||
[arguments removeObjectAtIndex:0]; // Remove Binary Path | ||
[arguments removeObjectAtIndex:0]; // Remove Launch Path | ||
|
||
[privilegedTask setLaunchPath:launchPath]; | ||
[privilegedTask setArguments:arguments]; | ||
[privilegedTask setCurrentDirectoryPath:[[NSBundle mainBundle] resourcePath]]; | ||
|
||
OSStatus err = [privilegedTask launch]; | ||
if (err != errAuthorizationSuccess) { | ||
if (err == errAuthorizationCanceled) { | ||
NSLog(@"User cancelled"); | ||
exit(1); | ||
} else { | ||
NSLog(@"Something went wrong: %d", (int)err); | ||
// For error codes, see http://www.opensource.apple.com/source/libsecurity_authorization/libsecurity_authorization-36329/lib/Authorization.h | ||
} | ||
} | ||
|
||
// Success! Now, read the output file handle for data | ||
NSFileHandle *readHandle = [privilegedTask outputFileHandle]; | ||
NSData *outputData = [readHandle readDataToEndOfFile]; // Blocking call | ||
NSString *outputString = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding]; | ||
|
||
printf("%s", [outputString UTF8String]); | ||
|
||
exitCode = privilegedTask.terminationStatus; | ||
NSLog(@"Done"); | ||
exit(exitCode); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,20 @@ | ||
// | ||
// main.m | ||
// OCLP-Helper | ||
// Test | ||
// | ||
// Created by Collin Mistr on 1/19/22. | ||
// | ||
// Created by Mykola Grymalyuk on 2021-12-20. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "STPrivilegedTask.h" | ||
#import <Cocoa/Cocoa.h> | ||
#import "Handler.h" | ||
|
||
int main(int argc, const char * argv[]) { | ||
@autoreleasepool { | ||
printf("Starting OCLP-Helper\n"); | ||
} | ||
|
||
STPrivilegedTask *privilegedTask = [[STPrivilegedTask alloc] init]; | ||
|
||
NSArray *components = [[NSProcessInfo processInfo] arguments]; | ||
NSMutableArray *arguments = [NSMutableArray arrayWithArray:components]; | ||
|
||
|
||
NSString *launchPath = arguments[1]; | ||
[arguments removeObjectAtIndex:0]; // Remove Binary Path | ||
[arguments removeObjectAtIndex:0]; // Remove Launch Path | ||
|
||
[privilegedTask setLaunchPath:launchPath]; | ||
[privilegedTask setArguments:arguments]; | ||
[privilegedTask setCurrentDirectoryPath:[[NSBundle mainBundle] resourcePath]]; | ||
|
||
OSStatus err = [privilegedTask launch]; | ||
if (err != errAuthorizationSuccess) { | ||
if (err == errAuthorizationCanceled) { | ||
NSLog(@"User cancelled"); | ||
return 1; | ||
} else { | ||
NSLog(@"Something went wrong: %d", (int)err); | ||
// For error codes, see http://www.opensource.apple.com/source/libsecurity_authorization/libsecurity_authorization-36329/lib/Authorization.h | ||
} | ||
NSApplication * app = [NSApplication sharedApplication]; | ||
Handler *h = [[Handler alloc] init]; | ||
[app setDelegate:h]; | ||
[app run]; | ||
} | ||
|
||
[privilegedTask waitUntilExit]; | ||
|
||
// Success! Now, read the output file handle for data | ||
NSFileHandle *readHandle = [privilegedTask outputFileHandle]; | ||
NSData *outputData = [readHandle readDataToEndOfFile]; // Blocking call | ||
NSString *outputString = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding]; | ||
|
||
printf("%s", [outputString UTF8String]); | ||
|
||
return privilegedTask.terminationStatus; | ||
return 0; | ||
} |