Created
February 1, 2018 22:03
-
-
Save stek29/c55beb8540534bc0d9d46b87ff0ceeac to your computer and use it in GitHub Desktop.
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
#include <mach/mach.h> | |
#include <IOKit/IOKitLib.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
const static uint32_t SELpurgeCachedValidationResults = 4; | |
int main(void) { | |
int rv = EXIT_FAILURE; | |
io_service_t amfi = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("AppleMobileFileIntegrity")); | |
if (!MACH_PORT_VALID(amfi)) { | |
printf("Cant get service matching amfi\n"); | |
return rv; | |
} | |
io_connect_t amfiuc = MACH_PORT_NULL; | |
kern_return_t ret = 0; | |
ret = IOServiceOpen(amfi, mach_task_self_, 0, &amfiuc); | |
if (ret != KERN_SUCCESS) { | |
printf("Cant open amfi userclient: 0x%x (%s)\n", ret, mach_error_string(ret)); | |
IOServiceClose(amfi); | |
return rv; | |
} | |
ret = IOConnectCallMethod(amfiuc, SELpurgeCachedValidationResults, NULL, 0, NULL, 0, NULL, 0, NULL, 0); | |
if (ret != KERN_SUCCESS) { | |
printf("purgeCachedValidationResults failed: 0x%x (%s)\n", ret, mach_error_string(ret)); | |
} else { | |
rv = EXIT_SUCCESS; | |
} | |
IOConnectRelease(amfiuc); | |
IOServiceClose(amfi); | |
return rv; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment