Repository navigation
Expand file tree
/
Copy pathkernelcache.h
More file actions
146 lines (132 loc) · 4.27 KB
/
Copy pathkernelcache.h
File metadata and controls
146 lines (132 loc) · 4.27 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
* kernelcache.h
* kext_tools
*
* Created by Nik Gervae on 2010 10 04.
* Copyright 2010, 2012 Apple Computer, Inc. All rights reserved.
*
*/
#ifndef _KERNELCACHE_H_
#define _KERNELCACHE_H_
#ifdef __APPLE__
#include <libc.h>
#endif
#include "kext_tools_util.h"
#define PLATFORM_NAME_LEN (64)
#define ROOT_PATH_LEN (256)
#define COMP_TYPE_LZSS 'lzss'
#define COMP_TYPE_FASTLIB 'lzvn'
// prelinkVersion value >= 1 means KASLR supported
typedef struct prelinked_kernel_header {
uint32_t signature;
uint32_t compressType;
uint32_t adler32;
uint32_t uncompressedSize;
uint32_t compressedSize;
uint32_t prelinkVersion;
uint32_t reserved[10];
char platformName[PLATFORM_NAME_LEN]; // unused
char rootPath[ROOT_PATH_LEN]; // unused
char data[0];
} PrelinkedKernelHeader;
typedef struct platform_info {
char platformName[PLATFORM_NAME_LEN];
char rootPath[ROOT_PATH_LEN];
} PlatformInfo;
/*******************************************************************************
*******************************************************************************/
ExitStatus
writeFatFileWithValidation(
const char * filePath,
boolean_t doValidation,
dev_t file_dev_t,
ino_t file_ino_t,
CFArrayRef fileSlices,
CFArrayRef fileArchs,
mode_t fileMode,
const struct timeval fileTimes[2]);
ExitStatus
writeFatFile(
const char * filePath,
CFArrayRef fileSlices,
CFArrayRef fileArchs,
mode_t fileMode,
const struct timeval fileTimes[2]);
void * mapAndSwapFatHeaderPage(
int fileDescriptor);
void unmapFatHeaderPage(
void *headerPage);
struct fat_arch * getFirstFatArch(
u_char *headerPage);
struct fat_arch * getNextFatArch(
u_char *headerPage,
struct fat_arch *lastArch);
struct fat_arch * getFatArchForArchInfo(
u_char *headerPage,
const NXArchInfo *archInfo);
const NXArchInfo *
getThinHeaderPageArch(
const void *headerPage);
ExitStatus
readFatFileArchsWith_fd(
int the_fd,
CFMutableArrayRef * archsOut);
ExitStatus readFatFileArchsWithPath(
const char * filePath,
CFMutableArrayRef * archsOut);
ExitStatus readFatFileArchsWithHeader(
u_char * headerPage,
CFMutableArrayRef * archsOut);
ExitStatus readMachOSlices(
const char * filePath,
CFMutableArrayRef * slicesOut,
CFMutableArrayRef * archsOut,
mode_t * modeOut,
struct timeval machOTimesOut[2]);
ExitStatus readMachOSlicesWith_fd(
int the_fd,
CFMutableArrayRef * slicesOut,
CFMutableArrayRef * archsOut,
mode_t * modeOut,
struct timeval machOTimesOut[2]);
CF_RETURNS_RETAINED
CFDataRef readMachOSliceForArch(
const char * filePath,
const NXArchInfo * archInfo,
Boolean checkArch);
CF_RETURNS_RETAINED
CFDataRef readMachOSliceForArchWith_fd(
int the_fd,
const NXArchInfo * archInfo,
Boolean checkArch);
CF_RETURNS_RETAINED
CFDataRef readMachOSlice(
int fileDescriptor,
off_t fileOffset,
size_t fileSliceSize);
int readFileAtOffset(
int fileDescriptor,
off_t fileOffset,
size_t fileSize,
u_char * buf);
int verifyMachOIsArch(
const UInt8 * fileBuf,
size_t size,
const NXArchInfo * archInfo);
Boolean supportsFastLibCompression(
void);
CF_RETURNS_RETAINED
CFDataRef uncompressPrelinkedSlice(
CFDataRef prelinkImage);
CF_RETURNS_RETAINED
CFDataRef compressPrelinkedSlice(
uint32_t compressionType,
CFDataRef prelinkImage,
Boolean hasRelocs);
ExitStatus writePrelinkedSymbols(
CFURLRef symbolDirURL,
CFArrayRef prelinkSymbols,
CFArrayRef prelinkArchs);
ExitStatus makeDirectoryWithURL(
CFURLRef dirURL);
#endif /* _KERNELCACHE_H_ */