X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/b0d623f7f2ae71ed96e60569f61f9a9a27016e80..7ddcb079202367355dddccdfa4318e57d50318be:/libkern/kernel_mach_header.c diff --git a/libkern/kernel_mach_header.c b/libkern/kernel_mach_header.c index e0830d99d..0edc6b64d 100644 --- a/libkern/kernel_mach_header.c +++ b/libkern/kernel_mach_header.c @@ -68,6 +68,33 @@ getlastaddr(void) return last_addr; } +/* + * Find the UUID load command in the Mach-O headers, and return + * the address of the UUID blob and size in "*size". If the + * Mach-O image is missing a UUID, NULL is returned. + */ +void * +getuuidfromheader(kernel_mach_header_t *mhp, unsigned long *size) +{ + struct uuid_command *uuidp; + unsigned long i; + + uuidp = (struct uuid_command *) + ((uintptr_t)mhp + sizeof(kernel_mach_header_t)); + for(i = 0; i < mhp->ncmds; i++){ + if(uuidp->cmd == LC_UUID) { + if (size) + *size = sizeof(uuidp->uuid); + + return (void *)uuidp->uuid; + } + + uuidp = (struct uuid_command *)((uintptr_t)uuidp + uuidp->cmdsize); + } + + return NULL; +} + /* * This routine returns the a pointer to the data for the named section in the * named segment if it exist in the mach header passed to it. Also it returns