X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/13fec9890cf095cc781fdf7b8917cb03bf32dd4c..c0fea4742e91338fffdcf79f86a7c1d5e2b97eb1:/libsa/kld_patch.c diff --git a/libsa/kld_patch.c b/libsa/kld_patch.c index d73f1b2d0..18892a019 100644 --- a/libsa/kld_patch.c +++ b/libsa/kld_patch.c @@ -33,6 +33,7 @@ #include #if !KERNEL #include +#include #endif #if KERNEL @@ -626,13 +627,13 @@ kld_macho_swap(struct mach_header * mh) cmd < ncmds; cmd++, seg = (struct segment_command *)(((vm_offset_t)seg) + seg->cmdsize)) { - if (NXSwapLong(LC_SYMTAB) == seg->cmd) { + if (OSSwapConstInt32(LC_SYMTAB) == seg->cmd) { swap_symtab_command((struct symtab_command *) seg, hostOrder); swap_nlist((struct nlist *) (((vm_offset_t) mh) + ((struct symtab_command *) seg)->symoff), ((struct symtab_command *) seg)->nsyms, hostOrder); continue; } - if (NXSwapLong(LC_SEGMENT) != seg->cmd) { + if (OSSwapConstInt32(LC_SEGMENT) != seg->cmd) { swap_load_command((struct load_command *) seg, hostOrder); continue; } @@ -746,21 +747,21 @@ static Boolean findBestArch(struct fileRecord *file, const char *pathName) unsigned long i; struct fat_arch *arch; - fat->nfat_arch = NXSwapBigLongToHost(fat->nfat_arch); + fat->nfat_arch = OSSwapBigToHostInt32(fat->nfat_arch); return_if(file->fMapSize < sizeof(struct fat_header) + fat->nfat_arch * sizeof(struct fat_arch), false, ("%s is too fat\n", file->fPath)); arch = (struct fat_arch *) &fat[1]; for (i = 0; i < fat->nfat_arch; i++) { - arch[i].cputype = NXSwapBigLongToHost(arch[i].cputype); - arch[i].cpusubtype = NXSwapBigLongToHost(arch[i].cpusubtype); - arch[i].offset = NXSwapBigLongToHost(arch[i].offset); - arch[i].size = NXSwapBigLongToHost(arch[i].size); - arch[i].align = NXSwapBigLongToHost(arch[i].align); + arch[i].cputype = OSSwapBigToHostInt32(arch[i].cputype); + arch[i].cpusubtype = OSSwapBigToHostInt32(arch[i].cpusubtype); + arch[i].offset = OSSwapBigToHostInt32(arch[i].offset); + arch[i].size = OSSwapBigToHostInt32(arch[i].size); + arch[i].align = OSSwapBigToHostInt32(arch[i].align); } - magic = NXSwapBigLongToHost(fat->magic); + magic = OSSwapBigToHostInt32(fat->magic); } // Now see if we can find any valid architectures @@ -1297,7 +1298,7 @@ relocateSection(const struct fileRecord *file, struct sectionRecord *sectionRec) void * addr = *entry; #if !KERNEL if (file->fSwapped) - addr = (void *) NXSwapLong((long) addr); + addr = (void *) OSSwapInt32((uint32_t) addr); #endif symbol = findSymbolByAddress(file, addr); } @@ -1328,7 +1329,7 @@ findSymbolRefAtLocation(const struct fileRecord *file, void * addr = *loc; #if !KERNEL if (file->fSwapped) - addr = (void *) NXSwapLong((long) addr); + addr = (void *) OSSwapInt32((uint32_t) addr); #endif result = findSymbolByAddress(file, addr); if (!result) @@ -1728,7 +1729,7 @@ static Boolean resolveKernelVTable(struct metaClassRecord *metaClass) void * addr = *curEntry; #if !KERNEL if (file->fSwapped) - addr = (void *) NXSwapLong((long) addr); + addr = (void *) OSSwapInt32((uint32_t) addr); #endif curPatch->fSymbol = (struct nlist *) findSymbolByAddress(file, addr);