X-Git-Url: https://git.saurik.com/ldid.git/blobdiff_plain/c1f7096708df36a73b1f2b4769ea46dc483b5852..422bad37a8c2fef85a857d6ee9707057879d3231:/ldid.cpp diff --git a/ldid.cpp b/ldid.cpp index 32fd2d9..1f9287c 100644 --- a/ldid.cpp +++ b/ldid.cpp @@ -85,6 +85,8 @@ #ifndef LDID_NOPLIST #include +#elif __APPLE__ +#include #endif #include "ldid.hpp" @@ -1218,9 +1220,11 @@ static void Allocate(const void *idata, size_t isize, std::streambuf &output, co if (symtab != NULL) { auto end(mach_header.Swap(symtab->stroff) + mach_header.Swap(symtab->strsize)); - _assert(end <= size); - _assert(end >= size - 0x10); - size = end; + if (symtab->stroff != 0 || symtab->strsize != 0) { + _assert(end <= size); + _assert(end >= size - 0x10); + size = end; + } } size_t alloc(allocate(mach_header, size)); @@ -1970,11 +1974,21 @@ Hash Sign(const void *idata, size_t isize, std::streambuf &output, const std::st #ifndef LDID_NOSMIME if (!key.empty()) { +#ifdef LDID_NOPLIST + auto plist(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); + _scope({ CFRelease(plist); }); + + auto cdhashes(CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); + _scope({ CFRelease(cdhashes); }); + + CFDictionarySetValue(plist, CFSTR("cdhashes"), cdhashes); +#else auto plist(plist_new_dict()); _scope({ plist_free(plist); }); auto cdhashes(plist_new_array()); plist_dict_set_item(plist, "cdhashes", cdhashes); +#endif unsigned total(0); for (Algorithm *pointer : GetAlgorithms()) { @@ -1988,13 +2002,26 @@ Hash Sign(const void *idata, size_t isize, std::streambuf &output, const std::st algorithm(hash, blob.data(), blob.size()); hash.resize(20); +#ifdef LDID_NOPLIST + auto value(CFDataCreate(kCFAllocatorDefault, reinterpret_cast(hash.data()), hash.size())); + _scope({ CFRelease(value); }); + CFArrayAppendValue(cdhashes, value); +#else plist_array_append_item(cdhashes, plist_new_data(hash.data(), hash.size())); +#endif } +#ifdef LDID_NOPLIST + auto created(CFPropertyListCreateXMLData(kCFAllocatorDefault, plist)); + _scope({ CFRelease(created); }); + auto xml(reinterpret_cast(CFDataGetBytePtr(created))); + auto size(CFDataGetLength(created)); +#else char *xml(NULL); uint32_t size; plist_to_xml(plist, &xml, &size); _scope({ free(xml); }); +#endif std::stringbuf data; const std::string &sign(blobs[CSSLOT_CODEDIRECTORY]);