-
Notifications
You must be signed in to change notification settings - Fork 3
/
kextload_main.h
119 lines (90 loc) · 4.07 KB
/
kextload_main.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* kextload_main.h
* kext_tools
*
* Created by Nik Gervae on 11/08/08.
* Copyright 2008 Apple Inc. All rights reserved.
*
*/
#ifndef _KEXTLOAD_MAIN_H
#define _KEXTLOAD_MAIN_H
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/kext/OSKext.h>
#include <getopt.h>
#include <sysexits.h>
#include <IOKit/kext/OSKext.h>
#include "kext_tools_util.h"
#pragma mark Basic Types & Constants
/*******************************************************************************
* Constants
*******************************************************************************/
enum {
kKextloadExitOK = EX_OK,
kKextloadExitUnspecified = 10,
// don't actually exit with this, it's just a sentinel value
kKextloadExitHelp = 33,
};
#pragma mark Command-line Option Definitions
/*******************************************************************************
* Command-line options. This data is used by getopt_long_only().
*
* Options common to all kext tools are in kext_tools_util.h.
*******************************************************************************/
#define kOptNameDependency "dependency"
#define kOptNameTests "print-diagnostics"
// Obsolete options that might be used for a production load
#define kOptNameNoCaches "no-caches"
#define kOptNameNoLoadedCheck "no-loaded-check"
#define kOptNameTests "print-diagnostics"
#define kOptNameLongindexHack "________"
#define kOptDependency 'd'
#define kOptRepository 'r'
// Obsolete options that might be used for a production load
#define kOptNoCaches 'c'
#define kOptNoLoadedCheck 'D'
#define kOptTests 't'
/* Options with no single-letter variant. */
// Do not use -1, that's getopt() end-of-args return value
// and can cause confusion
#define kLongOptLongindexHack (-2)
#define kLongOptArch (-3)
#define kOptChars "b:cd:Dhqr:tv"
int longopt = 0;
struct option sOptInfo[] = {
{ kOptNameLongindexHack, no_argument, &longopt, kLongOptLongindexHack },
{ kOptNameHelp, no_argument, NULL, kOptHelp },
{ kOptNameBundleIdentifier, required_argument, NULL, kOptBundleIdentifier },
{ kOptNameDependency, required_argument, NULL, kOptDependency },
{ kOptNameRepository, required_argument, NULL, kOptRepository },
{ kOptNameQuiet, no_argument, NULL, kOptQuiet },
{ kOptNameVerbose, optional_argument, NULL, kOptVerbose },
{ kOptNameTests, no_argument, NULL, kOptTests },
// Obsolete options that might be used for a production load
{ kOptNameNoCaches, no_argument, NULL, kOptNoCaches },
{ kOptNameNoLoadedCheck, no_argument, NULL, kOptNoLoadedCheck },
{ kOptNameTests, no_argument, NULL, kOptTests },
{ NULL, 0, NULL, 0 } // sentinel to terminate list
};
typedef struct {
CFMutableArrayRef kextIDs; // -b; must release
CFMutableArrayRef dependencyURLs; // -d; must release
CFMutableArrayRef repositoryURLs; // -r; must release
CFMutableArrayRef kextURLs; // kext args; must release
CFMutableArrayRef scanURLs; // all URLs to scan
CFArrayRef allKexts; // all opened kexts
} KextloadArgs;
#pragma mark Function Prototypes
/*******************************************************************************
* Function Prototypes
*******************************************************************************/
ExitStatus readArgs(
int argc,
char * const * argv,
KextloadArgs * toolArgs);
ExitStatus checkArgs(KextloadArgs * toolArgs);
ExitStatus checkAccess(void);
ExitStatus loadKextsViaKextd(KextloadArgs * toolArgs);
ExitStatus loadKextsIntoKernel(KextloadArgs * toolArgs);
ExitStatus exitStatusForOSReturn(OSReturn osReturn);
static void usage(UsageLevel usageLevel);
#endif /* _KEXTLOAD_MAIN_H */