Guest User

Untitled

a guest
Jul 17th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. char *copyBootHash(void) {
  2. unsigned char buf[1024];
  3. uint32_t length = 1024;
  4. io_registry_entry_t chosen = IORegistryEntryFromPath(kIOMasterPortDefault, "IODeviceTree:/chosen");
  5.  
  6. if (!MACH_PORT_VALID(chosen)) {
  7. printf("Unable to get IODeviceTree:/chosen port\n");
  8. return NULL;
  9. }
  10.  
  11. kern_return_t ret = IORegistryEntryGetProperty(chosen, "boot-manifest-hash", (void*)buf, &length);
  12.  
  13. IOObjectRelease(chosen);
  14.  
  15. if (ret != ERR_SUCCESS) {
  16. printf("Unable to read boot-manifest-hash\n");
  17. return NULL;
  18. }
  19.  
  20. // Make a hex string out of the hash
  21. char manifestHash[length*2+1];
  22. bzero(manifestHash, sizeof(manifestHash));
  23.  
  24. int i;
  25. for (i=0; i<length; i++) {
  26. sprintf(manifestHash+i*2, "%02X", buf[i]);
  27. }
  28.  
  29. printf("Hash: %s\n", manifestHash);
  30. return strdup(manifestHash);
  31. }
Add Comment
Please, Sign In to add comment