+SecStaticCode *GenericCode::identifyGuest(SecCode *guest, CFDataRef *cdhashOut)
+{
+ if (GenericCode *iguest = dynamic_cast<GenericCode *>(guest)) {
+ FilePathOut path;
+ CFRef<CFDataRef> cdhash;
+ CFDictionary attributes(errSecCSHostProtocolInvalidAttribute);
+ identifyGuest(iguest->guestRef(), path, cdhash.aref(), attributes.aref());
+ DiskRep::Context ctx;
+ if (CFNumberRef architecture = attributes.get<CFNumberRef>(kSecGuestAttributeArchitecture)) {
+ cpu_type_t cpu = cfNumber<cpu_type_t>(architecture);
+ if (CFNumberRef subarchitecture = attributes.get<CFNumberRef>(kSecGuestAttributeSubarchitecture))
+ ctx.arch = Architecture(cpu, cfNumber<cpu_subtype_t>(subarchitecture));
+ else
+ ctx.arch = Architecture(cpu);
+ }
+ SecPointer<GenericStaticCode> code = new GenericStaticCode(DiskRep::bestGuess(path, &ctx));
+ CODESIGN_GUEST_IDENTIFY_GENERIC(iguest, iguest->guestRef(), code);
+ if (cdhash) {
+ CODESIGN_GUEST_CDHASH_GENERIC(iguest, (void *)CFDataGetBytePtr(cdhash), CFDataGetLength(cdhash));
+ *cdhashOut = cdhash.yield();
+ }
+ return code.yield();
+ } else
+ MacOSError::throwMe(errSecCSNotAHost);
+}
+
+// helper to drive the identifyGuest hosting IPC and return results as CF objects
+void GenericCode::identifyGuest(SecGuestRef guest, char *path, CFDataRef &cdhash, CFDictionaryRef &attributes)