1#ifndef _KCTOOL_MAIN_H
2#define _KCTOOL_MAIN_H
3
4#include <CoreFoundation/CoreFoundation.h>
5#include <IOKit/kext/OSKext.h>
6
7#include <getopt.h>
8#include <sysexits.h>
9
10#include <IOKit/kext/OSKext.h>
11
12#include "kext_tools_util.h"
13#include "kernelcache.h"
14
15#pragma mark Basic Types & Constants
16/*******************************************************************************
17* Constants
18*******************************************************************************/
19
20enum {
21    kKctoolExitOK          = EX_OK,
22
23    // don't think we use it
24    kKctoolExitUnspecified = 11,
25
26    // don't actually exit with this, it's just a sentinel value
27    kKctoolExitHelp        = 33,
28};
29
30#pragma mark Command-line Option Definitions
31/*******************************************************************************
32* Command-line options. This data is used by getopt_long_only().
33*
34* Options common to all kext tools are in kext_tools_util.h.
35*******************************************************************************/
36
37#define kOptArch   'a'
38
39#define kOptChars  "a:h"
40
41int longopt = 0;
42
43struct option sOptInfo[] = {
44    { kOptNameHelp,                  no_argument,        NULL,     kOptHelp },
45    { kOptNameArch,                  required_argument,  NULL,     kOptArch },
46
47    { NULL, 0, NULL, 0 }  // sentinel to terminate list
48};
49
50typedef struct {
51    const NXArchInfo * archInfo;
52
53    char             * kernelcachePath;
54    CFStringRef        kextID;
55    const char       * segmentName;
56    const char       * sectionName;
57
58    const UInt8      * kernelcacheImageBytes;
59    CFPropertyListRef  kernelcacheInfoPlist;
60
61} KctoolArgs;
62
63#pragma mark Function Prototypes
64/*******************************************************************************
65* Function Prototypes
66*******************************************************************************/
67ExitStatus readArgs(
68    int            * argc,
69    char * const  ** argv,
70    KctoolArgs  * toolArgs);
71ExitStatus printKextInfo(KctoolArgs * toolArgs);
72Boolean getKextAddressAndSize(CFDictionaryRef infoDict, uint64_t *addr, uint64_t *size);
73
74void usage(UsageLevel usageLevel);
75
76#endif /* _KCTOOL_MAIN_H */
77