tether 0.0.1
Loading...
Searching...
No Matches
diskimages_private.h
1//
2// diskimages_private.h
3//
4// Reverse-engineered declarations for the PRIVATE DiskImages.framework
5// (/System/Library/PrivateFrameworks/DiskImages.framework).
6//
7// These are NOT public API and have no Apple-provided header. Every symbol and signature here was
8// recovered from the macOS `hdiutil` binary:
9//
10// - Import table lists _DIInitialize, _DIDeinitialize, _DIHLDiskImageAttach.
11// - The call site in hdiutil decompiles to:
12// uVar3 = _DIHLDiskImageAttach(optionsDict, progressCb, 0, &outDict);
13// i.e. (CFDictionaryRef, callback, context, CFDictionaryRef *) -> int (0 == success).
14// - An independent GitHub reference shows the same call with nil callback and context:
15// _dihlDiskImageAttach((CFDictionaryRef)dict, nil, nil, (CFDictionaryRef *)&results);
16// confirming the callback and context may be NULL and the out-param is a CFDictionaryRef.
17// - Option-dictionary keys are literal CFStrings found verbatim in hdiutil's __cstring.
18//
19// Because the framework lives in the dyld shared cache (no on-disk .tbd stub on recent macOS), we
20// resolve these symbols at runtime via CFBundle -- CFBundleGetFunctionPointerForName -- exactly as
21// Apple's own libsecurity_filevault (FVDIHLInterface.cpp) does:
22//
23// CFURLRef url = CFURLCreateWithFileSystemPath(NULL,
24// CFSTR("/System/Library/PrivateFrameworks/DiskImages.framework"),
25// kCFURLPOSIXPathStyle, false);
26// CFBundleRef b = CFBundleCreate(NULL, url);
27// fp = (_proc *)CFBundleGetFunctionPointerForName(b, CFSTR("DIHLDiskImageAttach"));
28//
29// (hdiutil hard-links the framework, hence the direct _DIHL* imports; we cannot hard-link without a
30// stub, so we follow the filevault pattern.) See diskimages_private.c.
31//
32#ifndef DISKIMAGES_PRIVATE_H
33#define DISKIMAGES_PRIVATE_H
34
35#include <CoreFoundation/CoreFoundation.h>
36#include <MacTypes.h> // OSStatus
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42// Authoritative typedefs, transcribed verbatim from Apple's open-source Darwin
43// libsecurity_filevault (FVDIHLInterface.h):
44//
45// typedef OSStatus _dihlDiskImageAttachProc(CFDictionaryRef inOptions,
46// void *inStatusProc,
47// void *inContext,
48// CFDictionaryRef *outResults);
49// typedef int _dihlDIInitializeProc();
50// typedef void _dihlDIDeinitializeProc();
51//
52// OSStatus is SInt32 (== int32_t); 0 (noErr) means success. inStatusProc is a status callback
53// declared simply as void* in Apple's header and may be NULL (hdiutil passes a real one; filevault
54// passes nil). DIInitialize returns int; DIDeinitialize returns void.
55
56// Function-pointer types matching the authoritative signatures.
57typedef int (*DIInitialize_fn)(void);
58typedef void (*DIDeinitialize_fn)(void);
59typedef OSStatus (*DIHLDiskImageAttach_fn)(CFDictionaryRef inOptions,
60 void *inStatusProc,
61 void *inContext,
62 CFDictionaryRef *outResults);
63
64// Resolved entry points (populated by diskimages_loader_init).
65typedef struct {
66 CFBundleRef bundle; // DiskImages.framework bundle
67 DIInitialize_fn DIInitialize;
68 DIDeinitialize_fn DIDeinitialize;
69 DIHLDiskImageAttach_fn DIHLDiskImageAttach;
71
72// Load DiskImages.framework via CFBundle and resolve the symbols above. Returns 0 on success;
73// non-zero on failure with *err (if non-NULL) pointing at a static description. On success, also
74// calls DIInitialize() once.
75int diskimages_loader_init(diskimages_api *api, const char **err);
76
77// Release the bundle and zero the struct. Safe to call with a zeroed struct.
78void diskimages_loader_dispose(diskimages_api *api);
79
80// Option-dictionary keys for DIHLDiskImageAttach, exactly as hdiutil builds them. The values are
81// literal CFStrings found verbatim in hdiutil's __cstring. Verified __cstring addresses:
82// main-url 0x10002cdf1, shadow-url 0x10002ce16, read-only 0x10002c462, agent 0x10002c43b,
83// verbose 0x10002cdbc, quiet 0x10002cdca, skip-verify 0x10002c6a1,
84// skip-verify-locked 0x10002c6b5, skip-verify-remote 0x10002c6c8.
85// The "agent" key is set to the value "framework"; main-url and shadow-url are CFURLRef and the
86// rest are CFBoolean.
87#define kDIAttachKeyMainURL CFSTR("main-url")
88#define kDIAttachKeyShadowURL CFSTR("shadow-url")
89#define kDIAttachKeyReadOnly CFSTR("read-only")
90#define kDIAttachKeyAgent CFSTR("agent")
91#define kDIAttachValueFramework CFSTR("framework")
92#define kDIAttachKeyVerbose CFSTR("verbose")
93#define kDIAttachKeyQuiet CFSTR("quiet")
94#define kDIAttachKeySkipVerify CFSTR("skip-verify")
95#define kDIAttachKeySkipVerifyLckd CFSTR("skip-verify-locked")
96#define kDIAttachKeySkipVerifyRmt CFSTR("skip-verify-remote")
97
98// Result-dictionary keys returned via the out-param. The result is a CFDictionaryRef whose
99// kDIAttachResultSystemEntities entry is a CFArray of CFDictionary, each describing one attached
100// node. Verified __cstring addresses: system-entities 0x10002cf6d, image-path 0x1000320da,
101// dev-entry 0x10002cf9c (e.g. "/dev/diskNsM"), mount-point 0x10002ca1b (e.g. "/Volumes/..."),
102// content-hint 0x10002cfb1 (e.g. "Apple_HFS").
103#define kDIAttachResultSystemEntities CFSTR("system-entities")
104#define kDIAttachResultImagePath CFSTR("image-path")
105#define kDIEntityKeyDevEntry CFSTR("dev-entry")
106#define kDIEntityKeyMountPoint CFSTR("mount-point")
107#define kDIEntityKeyContentHint CFSTR("content-hint")
108
109#ifdef __cplusplus
110}
111#endif
112
113#endif // DISKIMAGES_PRIVATE_H
Definition diskimages_private.h:65