1 /* 2 * Copyright (c) 2020 Apple Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. The rights granted to you under the License 10 * may not be used to create, or enable the creation or redistribution of, 11 * unlawful or unlicensed copies of an Apple operating system, or to 12 * circumvent, violate, or enable the circumvention or violation of, any 13 * terms of an Apple operating system software license agreement. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 18 * The Original Code and all software distributed under the License are 19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 * Please see the License for the specific language governing rights and 24 * limitations under the License. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28 29 #ifndef __AMFI_H 30 #define __AMFI_H 31 32 #include <os/base.h> 33 #include <sys/cdefs.h> 34 #include <sys/types.h> 35 #include <kern/cs_blobs.h> 36 37 #define KERN_AMFI_INTERFACE_VERSION 5 38 #define KERN_AMFI_SUPPORTS_DATA_ALLOC 1 39 40 #if XNU_KERNEL_PRIVATE 41 #define CORE_ENTITLEMENTS_I_KNOW_WHAT_IM_DOING 42 #include <CoreEntitlements/CoreEntitlementsPriv.h> 43 #endif 44 45 typedef void (*amfi_OSEntitlements_invalidate)(void* osentitlements); 46 typedef void* (*amfi_OSEntitlements_asDict)(void* osentitlements); 47 typedef CEError_t (*amfi_OSEntitlements_query)(void* osentitlements, uint8_t cdhash[CS_CDHASH_LEN], CEQuery_t query, size_t queryLength); 48 typedef bool (*amfi_OSEntitlements_get_transmuted_blob)(void* osentitlements, const CS_GenericBlob **blob); 49 typedef bool (*amfi_OSEntitlements_get_xml_blob)(void* osentitlements, CS_GenericBlob **blob); 50 typedef bool (*amfi_get_legacy_profile_exemptions)(const uint8_t **profile, size_t *profileLength); 51 typedef bool (*amfi_get_udid)(const uint8_t **udid, size_t *udidLength); 52 typedef void* (*amfi_query_context_to_object)(CEQueryContext_t ctx); 53 54 typedef struct _amfi { 55 amfi_OSEntitlements_invalidate OSEntitlements_invalidate; 56 amfi_OSEntitlements_asDict OSEntitlements_asdict; 57 amfi_OSEntitlements_query OSEntitlements_query; 58 amfi_OSEntitlements_get_transmuted_blob OSEntitlements_get_transmuted; 59 amfi_OSEntitlements_get_xml_blob OSEntitlements_get_xml; 60 coreentitlements_t CoreEntitlements; 61 amfi_get_legacy_profile_exemptions get_legacy_profile_exemptions; 62 amfi_get_udid get_udid; 63 amfi_query_context_to_object query_context_to_object; 64 } amfi_t; 65 66 __BEGIN_DECLS 67 68 /*! 69 * @const amfi 70 * The AMFI interface that was registered. 71 */ 72 extern const amfi_t *amfi; 73 74 /*! 75 * @function amfi_interface_register 76 * Registers the AMFI kext interface for use within the kernel proper. 77 * 78 * @param mfi 79 * The interface to register. 80 * 81 * @discussion 82 * This routine may only be called once and must be called before late-const has 83 * been applied to kernel memory. 84 */ 85 OS_EXPORT OS_NONNULL1 86 void 87 amfi_interface_register(const amfi_t *mfi); 88 89 __END_DECLS 90 91 #endif // __AMFI_H 92