+/*
+ * I think this function was ripped from the iHaxGamez project, so it
+ * remains licensed under the GPL.
+ */
+void authMe(char * FullPathToMe)
+{
+ // get authorization as root
+
+ OSStatus myStatus;
+
+ // set up Authorization Item
+ AuthorizationItem myItems[1];
+ myItems[0].name = kAuthorizationRightExecute;
+ myItems[0].valueLength = 0;
+ myItems[0].value = NULL;
+ myItems[0].flags = 0;
+
+ // Set up Authorization Rights
+ AuthorizationRights myRights;
+ myRights.count = sizeof (myItems) / sizeof (myItems[0]);
+ myRights.items = myItems;
+
+ // set up Authorization Flags
+ AuthorizationFlags myFlags;
+ myFlags =
+ kAuthorizationFlagDefaults |
+ kAuthorizationFlagInteractionAllowed |
+ kAuthorizationFlagExtendRights;
+
+ // Create an Authorization Ref using Objects above. NOTE: Login bod comes up with this call.
+ AuthorizationRef myAuthorizationRef;
+ myStatus = AuthorizationCreate (&myRights, kAuthorizationEmptyEnvironment, myFlags, &myAuthorizationRef);
+
+ if (myStatus == errAuthorizationSuccess)
+ {
+ // prepare communication path - used to signal that process is loaded
+ FILE *myCommunicationsPipe = NULL;
+ char myReadBuffer[] = " ";
+
+ // run this app in GOD mode by passing authorization ref and comm pipe (asynchoronous call to external application)
+ myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef,FullPathToMe,kAuthorizationFlagDefaults,nil,&myCommunicationsPipe);