-
Notifications
You must be signed in to change notification settings - Fork 0
/
kextstat_main.h
120 lines (98 loc) · 3.83 KB
/
kextstat_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
120
/*
* kextstat_main.h
* kext_tools
*
* Created by Nik Gervae on 5/03/08.
* Copyright 2008, 2014 Apple Inc. All rights reserved.
*
*/
#ifndef _KEXTSTAT_MAIN_H
#define _KEXTSTAT_MAIN_H
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/kext/OSKext.h>
#include <getopt.h>
#include <sysexits.h>
#include <mach-o/arch.h>
#include "kext_tools_util.h"
#pragma mark Basic Types & Constants
/*******************************************************************************
* Constants
*******************************************************************************/
enum {
kKextstatExitOK = EX_OK,
kKextstatExitError = 1,
// don't think we use it
kKextstatExitUnspecified = 11,
// don't actually exit with this, it's just a sentinel value
kKextstatExitHelp = 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 kOptNameNoKernelComponents "no-kernel"
#define kOptNameListOnly "list-only"
#define kOptNameArchitecture "arch"
#define kOptNoKernelComponents 'k'
#define kOptListOnly 'l'
#define kOptArchitecture 'a'
#if 0
// bundle-id,version,compatible-version,is-kernel,is-interface,retaincount,path,uuid,started,prelinked,index,address,size,wired,dependencies,classes,cputype,cpusubtype
CFBundleIdentifier
CFBundleVersion
kOSBundleCompatibleVersionKey
kOSKernelResourceKey
kOSBundleIsInterfaceKey
kOSBundlePathKey
kOSBundleUUIDKey
kOSBundleStartedKey
kOSBundlePrelinkedKey
kOSBundleLoadTagKey
kOSBundleLoadAddressKey
kOSBundleLoadSizeKey
kOSBundleWiredSizeKey
kOSBundleDependenciesKey
kOSBundleMetaClassesKey
#endif
#define kOptChars "b:hkla"
/* 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)
int longopt = 0;
struct option sOptInfo[] = {
{ kOptNameHelp, no_argument, NULL, kOptHelp },
{ kOptNameBundleIdentifier, required_argument, NULL, kOptBundleIdentifier },
{ kOptNameNoKernelComponents, no_argument, NULL, kOptNoKernelComponents },
{ kOptNameListOnly, no_argument, NULL, kOptListOnly },
{ kOptNameArch, no_argument, NULL, kOptArchitecture },
{ NULL, 0, NULL, 0 } // sentinel to terminate list
};
#pragma mark Tool Args Structure
/*******************************************************************************
* Tool Args Structure
*******************************************************************************/
typedef struct {
Boolean flagNoKernelComponents;
Boolean flagListOnly;
Boolean flagShowArchitecture;
CFMutableArrayRef bundleIDs; // must release
CFDictionaryRef loadedKextInfo; // must release
const NXArchInfo * runningKernelArch; // do not free
} KextstatArgs;
#pragma mark Function Prototypes
/*******************************************************************************
* Function Prototypes
*******************************************************************************/
ExitStatus readArgs(int argc, char * const * argv, KextstatArgs * toolArgs);
void printKextInfo(CFDictionaryRef kextInfo, KextstatArgs * toolArgs);
Boolean getNumValue(CFNumberRef aNumber, CFNumberType type, void * valueOut);
int compareKextInfo(const void * vKextInfo1, const void * vKextInfo2);
CFComparisonResult compareNumbers(
const void * val1,
const void * val2,
void * context);
static void usage(UsageLevel usageLevel);
#endif /* _KEXTSTAT_MAIN_H */