Root/
Source at commit 2740 created 8 years 11 months ago. By ifabio, sync with trunk. | |
---|---|
1 | /*␊ |
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_LICENSE_HEADER_START@␊ |
5 | * ␊ |
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights␊ |
7 | * Reserved. This file contains Original Code and/or Modifications of␊ |
8 | * Original Code as defined in and that are subject to the Apple Public␊ |
9 | * Source License Version 2.0 (the 'License'). You may not use this file␊ |
10 | * except in compliance with the License. Please obtain a copy of the␊ |
11 | * License at http://www.apple.com/publicsource and read it before using␊ |
12 | * this file.␊ |
13 | * ␊ |
14 | * The Original Code and all software distributed under the License are␊ |
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the␊ |
19 | * License for the specific language governing rights and limitations␊ |
20 | * under the License.␊ |
21 | * ␊ |
22 | * @APPLE_LICENSE_HEADER_END@␊ |
23 | */␊ |
24 | /*␊ |
25 | * drivers.c - Driver Loading Functions.␊ |
26 | *␊ |
27 | * Copyright (c) 2000 Apple Computer, Inc.␊ |
28 | *␊ |
29 | * DRI: Josh de Cesare␊ |
30 | */␊ |
31 | ␊ |
32 | #include <mach-o/fat.h>␊ |
33 | #include <libkern/OSByteOrder.h>␊ |
34 | #include <mach/machine.h>␊ |
35 | ␊ |
36 | #include "sl.h"␊ |
37 | #include "boot.h"␊ |
38 | #include "bootstruct.h"␊ |
39 | #include "xml.h"␊ |
40 | #include "ramdisk.h"␊ |
41 | #include "modules.h"␊ |
42 | ␊ |
43 | #if DEBUG␊ |
44 | #define DBG(x...)␉printf(x)␊ |
45 | #else␊ |
46 | #define DBG(x...)␉msglog(x)␊ |
47 | #endif␊ |
48 | ␊ |
49 | // extern char gMacOSVersion[8];␊ |
50 | ␊ |
51 | struct Module { ␊ |
52 | ␉struct Module *nextModule;␊ |
53 | ␉long willLoad;␊ |
54 | ␉TagPtr dict;␊ |
55 | ␉char *plistAddr;␊ |
56 | ␉long plistLength;␊ |
57 | ␉char *executablePath;␊ |
58 | ␉char *bundlePath;␊ |
59 | ␉long bundlePathLength;␊ |
60 | };␊ |
61 | typedef struct Module Module, *ModulePtr;␊ |
62 | ␊ |
63 | struct DriverInfo {␊ |
64 | ␉char *plistAddr;␊ |
65 | ␉long plistLength;␊ |
66 | ␉void *executableAddr;␊ |
67 | ␉long executableLength;␊ |
68 | ␉void *bundlePathAddr;␊ |
69 | ␉long bundlePathLength;␊ |
70 | };␊ |
71 | typedef struct DriverInfo DriverInfo, *DriverInfoPtr;␊ |
72 | ␊ |
73 | #define kDriverPackageSignature1 'MKXT'␊ |
74 | #define kDriverPackageSignature2 'MOSX'␊ |
75 | ␊ |
76 | struct DriversPackage {␊ |
77 | unsigned long signature1;␊ |
78 | unsigned long signature2;␊ |
79 | unsigned long length;␊ |
80 | unsigned long adler32;␊ |
81 | unsigned long version;␊ |
82 | unsigned long numDrivers;␊ |
83 | unsigned long reserved1;␊ |
84 | unsigned long reserved2;␊ |
85 | };␊ |
86 | typedef struct DriversPackage DriversPackage;␊ |
87 | ␊ |
88 | enum {␊ |
89 | ␉kCFBundleType2,␊ |
90 | ␉kCFBundleType3␊ |
91 | };␊ |
92 | ␊ |
93 | long (*LoadExtraDrivers_p)(FileLoadDrivers_t FileLoadDrivers_p);␊ |
94 | ␊ |
95 | /*static*/ unsigned long Adler32( unsigned char * buffer, long length );␊ |
96 | ␊ |
97 | long FileLoadDrivers(char *dirSpec, long plugin);␊ |
98 | long NetLoadDrivers(char *dirSpec);␊ |
99 | long LoadDriverMKext(char *fileSpec);␊ |
100 | long LoadDriverPList(char *dirSpec, char *name, long bundleType);␊ |
101 | long LoadMatchedModules(void);␊ |
102 | ␊ |
103 | static long MatchPersonalities(void);␊ |
104 | static long MatchLibraries(void);␊ |
105 | #ifdef NOTDEF␊ |
106 | static ModulePtr FindModule(char *name);␊ |
107 | static void ThinFatFile(void **loadAddrP, unsigned long *lengthP);␊ |
108 | #endif␊ |
109 | static long ParseXML(char *buffer, ModulePtr *module, TagPtr *personalities);␊ |
110 | static long InitDriverSupport(void);␊ |
111 | ␊ |
112 | ModulePtr gModuleHead, gModuleTail;␊ |
113 | static TagPtr gPersonalityHead, gPersonalityTail;␊ |
114 | static char * gExtensionsSpec;␊ |
115 | static char * gDriverSpec;␊ |
116 | static char * gFileSpec;␊ |
117 | static char * gTempSpec;␊ |
118 | static char * gFileName;␊ |
119 | ␊ |
120 | /*static*/ unsigned long␊ |
121 | Adler32( unsigned char * buffer, long length )␊ |
122 | {␊ |
123 | ␉long cnt;␊ |
124 | ␉unsigned long result, lowHalf, highHalf;␊ |
125 | ␊ |
126 | ␉lowHalf = 1;␊ |
127 | ␉highHalf = 0;␊ |
128 | ␊ |
129 | ␉for (cnt = 0; cnt < length; cnt++)␊ |
130 | ␉{␊ |
131 | ␉␉if ((cnt % 5000) == 0)␊ |
132 | ␉␉{␊ |
133 | ␉␉␉lowHalf %= 65521L;␊ |
134 | ␉␉␉highHalf %= 65521L;␊ |
135 | ␉␉}␊ |
136 | ␊ |
137 | ␉␉lowHalf += buffer[cnt];␊ |
138 | ␉␉highHalf += lowHalf;␊ |
139 | ␉}␊ |
140 | ␊ |
141 | ␉lowHalf %= 65521L;␊ |
142 | ␉highHalf %= 65521L;␊ |
143 | ␊ |
144 | ␉result = (highHalf << 16) | lowHalf;␊ |
145 | ␊ |
146 | ␉return result;␊ |
147 | }␊ |
148 | ␊ |
149 | ␊ |
150 | //==========================================================================␊ |
151 | // InitDriverSupport␊ |
152 | ␊ |
153 | static long␊ |
154 | InitDriverSupport( void )␊ |
155 | {␊ |
156 | ␉gExtensionsSpec = malloc( 4096 );␊ |
157 | ␉gDriverSpec = malloc( 4096 );␊ |
158 | ␉gFileSpec = malloc( 4096 );␊ |
159 | ␉gTempSpec = malloc( 4096 );␊ |
160 | ␉gFileName = malloc( 4096 );␊ |
161 | ␊ |
162 | ␉if ( !gExtensionsSpec || !gDriverSpec || !gFileSpec || !gTempSpec || !gFileName ) {␊ |
163 | ␉␉stop("InitDriverSupport error");␊ |
164 | ␉}␊ |
165 | ␊ |
166 | ␉return 0;␊ |
167 | }␊ |
168 | ␊ |
169 | //==========================================================================␊ |
170 | // LoadDrivers␊ |
171 | ␊ |
172 | long LoadDrivers( char * dirSpec )␊ |
173 | {␊ |
174 | ␉char dirSpecExtra[1024];␊ |
175 | ␊ |
176 | ␉if ( InitDriverSupport() != 0 ) {␊ |
177 | ␉␉return 0;␊ |
178 | ␉}␊ |
179 | ␊ |
180 | ␉// Load extra drivers if a hook has been installed.␊ |
181 | ␉if (LoadExtraDrivers_p != NULL)␊ |
182 | ␉{␊ |
183 | ␉␉(*LoadExtraDrivers_p)(&FileLoadDrivers);␊ |
184 | ␉}␊ |
185 | ␊ |
186 | ␉if ( gBootFileType == kNetworkDeviceType )␊ |
187 | ␉{␊ |
188 | ␉␉if (NetLoadDrivers(dirSpec) != 0)␊ |
189 | ␉␉{␊ |
190 | ␉␉␉error("Could not load drivers from the network\n");␊ |
191 | ␉␉␉return -1;␊ |
192 | ␉␉}␊ |
193 | ␉}␊ |
194 | ␉else if ( gBootFileType == kBlockDeviceType )␊ |
195 | ␉{␊ |
196 | ␉␉// First try to load Extra extensions from the ramdisk if isn't aliased as bt(0,0).␊ |
197 | ␉␉if (gRAMDiskVolume && !gRAMDiskBTAliased)␊ |
198 | ␉␉{␊ |
199 | ␉␉␉strcpy(dirSpecExtra, "rd(0,0)/Extra/");␊ |
200 | ␉␉␉FileLoadDrivers(dirSpecExtra, 0);␊ |
201 | ␉␉}␊ |
202 | ␊ |
203 | ␉␉// Next try to load Extra extensions from the selected root partition.␊ |
204 | ␉␉strcpy(dirSpecExtra, "/Extra/");␊ |
205 | ␉␉if (FileLoadDrivers(dirSpecExtra, 0) != 0) {␊ |
206 | ␉␉␉// If failed, then try to load Extra extensions from the boot partition␊ |
207 | ␉␉␉// in case we have a separate booter partition or a bt(0,0) aliased ramdisk.␊ |
208 | ␉␉␉if ( !(gBIOSBootVolume->biosdev == gBootVolume->biosdev && gBIOSBootVolume->part_no == gBootVolume->part_no)␊ |
209 | ␉␉␉␉|| (gRAMDiskVolume && gRAMDiskBTAliased) ) {␊ |
210 | ␉␉␉␉// Next try a specfic OS version folder ie 10.5␊ |
211 | ␉␉␉␉sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gMacOSVersion);␊ |
212 | ␉␉␉␉if (FileLoadDrivers(dirSpecExtra, 0) != 0) {␊ |
213 | ␉␉␉␉␉// Next we'll try the base␊ |
214 | ␉␉␉␉␉strcpy(dirSpecExtra, "bt(0,0)/Extra/");␊ |
215 | ␉␉␉␉␉FileLoadDrivers(dirSpecExtra, 0);␊ |
216 | ␉␉␉␉}␊ |
217 | ␉␉␉}␊ |
218 | ␉␉}␊ |
219 | ␉␉if(!gHaveKernelCache) {␊ |
220 | ␉␉␉// Don't load main driver (from /System/Library/Extentions) if gHaveKernelCache is set.␊ |
221 | ␉␉␉// since these drivers will already be in the kernel cache.␊ |
222 | ␉␉␉// NOTE: when gHaveKernelCache, xnu cannot (by default) load *any* extra kexts from the bootloader.␊ |
223 | ␉␉␉// The /Extra code is not disabled in this case due to a kernel patch that allows for this to happen.␊ |
224 | ␊ |
225 | ␉␉␉// Also try to load Extensions from boot helper partitions.␊ |
226 | ␉␉␉if (gBootVolume->flags & kBVFlagBooter) {␊ |
227 | ␉␉␉␉strcpy(dirSpecExtra, "/com.apple.boot.P/System/Library/");␊ |
228 | ␉␉␉␉if (FileLoadDrivers(dirSpecExtra, 0) != 0) {␊ |
229 | ␉␉␉␉␉strcpy(dirSpecExtra, "/com.apple.boot.R/System/Library/");␊ |
230 | ␉␉␉␉␉if (FileLoadDrivers(dirSpecExtra, 0) != 0) {␊ |
231 | ␉␉␉␉␉␉strcpy(dirSpecExtra, "/com.apple.boot.S/System/Library/");␊ |
232 | ␉␉␉␉␉␉FileLoadDrivers(dirSpecExtra, 0);␊ |
233 | ␉␉␉␉␉}␊ |
234 | ␉␉␉␉}␊ |
235 | ␉␉␉}␊ |
236 | ␊ |
237 | ␉␉␉if (gMKextName[0] != '\0') {␊ |
238 | ␉␉␉␉verbose("LoadDrivers: Loading from [%s]\n", gMKextName);␊ |
239 | ␉␉␉␉if ( LoadDriverMKext(gMKextName) != 0 ) {␊ |
240 | ␉␉␉␉␉error("Could not load %s\n", gMKextName);␊ |
241 | ␉␉␉␉␉return -1;␊ |
242 | ␉␉␉␉}␊ |
243 | ␉␉␉} else {␊ |
244 | ␉␉␉␉if (gMacOSVersion[3] == '9') {␊ |
245 | ␉␉␉␉␉strlcpy(gExtensionsSpec, dirSpec, 4087); /* 4096 - sizeof("Library/") */␊ |
246 | ␉␉␉␉␉strcat(gExtensionsSpec, "Library/");␊ |
247 | ␉␉␉␉␉FileLoadDrivers(gExtensionsSpec, 0);␊ |
248 | ␉␉␉␉}␊ |
249 | ␉␉␉␉strlcpy(gExtensionsSpec, dirSpec, 4080); /* 4096 - sizeof("System/Library/") */␊ |
250 | ␉␉␉␉strcat(gExtensionsSpec, "System/Library/");␊ |
251 | ␉␉␉␉FileLoadDrivers(gExtensionsSpec, 0);␊ |
252 | ␉␉␉}␊ |
253 | ␊ |
254 | ␉␉}␊ |
255 | ␉} else {␊ |
256 | ␉␉return 0;␊ |
257 | ␉}␊ |
258 | ␊ |
259 | ␉MatchPersonalities();␊ |
260 | ␊ |
261 | ␉MatchLibraries();␊ |
262 | ␊ |
263 | ␉LoadMatchedModules();␊ |
264 | ␊ |
265 | ␉return 0;␊ |
266 | }␊ |
267 | ␊ |
268 | //==========================================================================␊ |
269 | // FileLoadMKext␊ |
270 | ␊ |
271 | static long␊ |
272 | FileLoadMKext( const char * dirSpec, const char * extDirSpec )␊ |
273 | {␊ |
274 | ␉long␉ret, flags, time, time2;␊ |
275 | ␉char␉altDirSpec[512];␊ |
276 | ␉␊ |
277 | ␉snprintf(altDirSpec, sizeof(altDirSpec), "%s%s", dirSpec, extDirSpec);␊ |
278 | ␉ret = GetFileInfo(altDirSpec, "Extensions.mkext", &flags, &time);␊ |
279 | ␊ |
280 | ␉if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeFlat))␊ |
281 | ␉{␊ |
282 | ␉␉ret = GetFileInfo(dirSpec, "Extensions", &flags, &time2);␊ |
283 | ␊ |
284 | ␉␉if ((ret != 0)␊ |
285 | ␉␉␉|| ((flags & kFileTypeMask) != kFileTypeDirectory)␊ |
286 | ␉␉␉|| (((gBootMode & kBootModeSafe) == 0) && (time == (time2 + 1))))␊ |
287 | ␉␉{␊ |
288 | ␉␉␉snprintf(gDriverSpec, sizeof(altDirSpec) + 18, "%sExtensions.mkext", altDirSpec);␊ |
289 | ␉␉␉verbose("LoadDrivers: Loading from [%s]\n", gDriverSpec);␊ |
290 | ␊ |
291 | ␉␉␉if (LoadDriverMKext(gDriverSpec) == 0) {␊ |
292 | ␉␉␉␉return 0;␊ |
293 | ␉␉␉}␊ |
294 | ␉␉}␊ |
295 | ␉}␊ |
296 | ␉return -1;␊ |
297 | }␊ |
298 | ␊ |
299 | //==========================================================================␊ |
300 | // FileLoadDrivers␊ |
301 | ␊ |
302 | long␊ |
303 | FileLoadDrivers( char * dirSpec, long plugin )␊ |
304 | {␊ |
305 | ␉long ret, length, flags, time, bundleType;␊ |
306 | ␉long long␉ index;␊ |
307 | ␉long result = -1;␊ |
308 | ␉const char * name;␊ |
309 | ␊ |
310 | ␉if ( !plugin )␊ |
311 | ␉{␊ |
312 | ␉␉// First try 10.6's path for loading Extensions.mkext.␊ |
313 | ␉␉if (FileLoadMKext(dirSpec, "Caches/com.apple.kext.caches/Startup/") == 0) {␊ |
314 | ␉␉␉return 0;␊ |
315 | ␉␉}␊ |
316 | ␊ |
317 | ␉␉// Next try the legacy path.␊ |
318 | ␉␉else if (FileLoadMKext(dirSpec, "") == 0) {␊ |
319 | ␉␉␉return 0;␊ |
320 | ␉␉}␊ |
321 | ␊ |
322 | ␉␉strcat(dirSpec, "Extensions");␊ |
323 | ␉}␊ |
324 | ␊ |
325 | ␉index = 0;␊ |
326 | ␉while (1)␊ |
327 | ␉{␊ |
328 | ␉␉ret = GetDirEntry(dirSpec, &index, &name, &flags, &time);␊ |
329 | ␉␉if (ret == -1) {␊ |
330 | ␉␉␉break;␊ |
331 | ␉␉}␊ |
332 | ␊ |
333 | ␉␉// Make sure this is a directory.␊ |
334 | ␉␉if ((flags & kFileTypeMask) != kFileTypeDirectory) {␊ |
335 | ␉␉␉continue;␊ |
336 | ␉␉}␊ |
337 | ␊ |
338 | ␉␉// Make sure this is a kext.␊ |
339 | ␉␉length = strlen(name);␊ |
340 | ␉␉if (strcmp(name + length - 5, ".kext")) {␊ |
341 | ␉␉␉continue;␊ |
342 | ␉␉}␊ |
343 | ␊ |
344 | ␉␉// Save the file name.␊ |
345 | ␉␉strlcpy(gFileName, name, 4096);␊ |
346 | ␊ |
347 | ␉␉// Determine the bundle type.␊ |
348 | ␉␉snprintf(gTempSpec, 4096, "%s/%s", dirSpec, gFileName);␊ |
349 | ␉␉ret = GetFileInfo(gTempSpec, "Contents", &flags, &time);␊ |
350 | ␉␉if (ret == 0) {␊ |
351 | ␉␉␉bundleType = kCFBundleType2;␊ |
352 | ␉␉} else {␊ |
353 | ␉␉␉bundleType = kCFBundleType3;␊ |
354 | ␉␉}␊ |
355 | ␊ |
356 | ␉␉if (!plugin) {␊ |
357 | ␉␉␉snprintf(gDriverSpec, 4096, "%s/%s/%sPlugIns", dirSpec, gFileName, (bundleType == kCFBundleType2) ? "Contents/" : "");␊ |
358 | ␉␉}␊ |
359 | ␊ |
360 | ␉␉ret = LoadDriverPList(dirSpec, gFileName, bundleType);␊ |
361 | ␊ |
362 | ␉␉if (result != 0) {␊ |
363 | ␉␉␉result = ret;␊ |
364 | ␉␉}␊ |
365 | ␊ |
366 | ␉␉if (!plugin) {␊ |
367 | ␉␉␉FileLoadDrivers(gDriverSpec, 1);␊ |
368 | ␉␉}␊ |
369 | ␉}␊ |
370 | ␊ |
371 | ␉return result;␊ |
372 | }␊ |
373 | ␊ |
374 | ␊ |
375 | //==========================================================================␊ |
376 | // ␊ |
377 | ␊ |
378 | long␊ |
379 | NetLoadDrivers( char * dirSpec )␊ |
380 | {␊ |
381 | ␉long tries;␊ |
382 | ␊ |
383 | #if NODEF␊ |
384 | ␉long cnt;␊ |
385 | ␊ |
386 | ␉// Get the name of the kernel␊ |
387 | ␉cnt = strlen(gBootFile);␊ |
388 | ␉while (cnt--) {␊ |
389 | ␉␉if ((gBootFile[cnt] == '\\') || (gBootFile[cnt] == ',')) {␊ |
390 | ␉␉␉cnt++;␊ |
391 | ␉␉␉break;␊ |
392 | ␉␉}␊ |
393 | ␉}␊ |
394 | #endif␊ |
395 | ␊ |
396 | ␉// INTEL modification␊ |
397 | ␉snprintf(gDriverSpec, 4096, "%s%s.mkext", dirSpec, bootInfo->bootFile);␊ |
398 | ␊ |
399 | ␉verbose("NetLoadDrivers: Loading from [%s]\n", gDriverSpec);␊ |
400 | ␊ |
401 | ␉tries = 3;␊ |
402 | ␉while (tries--)␊ |
403 | ␉{␊ |
404 | ␉␉if (LoadDriverMKext(gDriverSpec) == 0) {␊ |
405 | ␉␉␉break;␊ |
406 | ␉␉}␊ |
407 | ␉}␊ |
408 | ␉if (tries == -1) {␊ |
409 | ␉␉return -1;␊ |
410 | ␉}␊ |
411 | ␊ |
412 | ␉return 0;␊ |
413 | }␊ |
414 | ␊ |
415 | //==========================================================================␊ |
416 | // loadDriverMKext␊ |
417 | ␊ |
418 | long␊ |
419 | LoadDriverMKext( char * fileSpec )␊ |
420 | {␊ |
421 | ␉unsigned long driversAddr, driversLength;␊ |
422 | ␉long length;␊ |
423 | ␉char segName[32];␊ |
424 | ␉DriversPackage * package;␊ |
425 | ␊ |
426 | #define GetPackageElement(e) OSSwapBigToHostInt32(package->e)␊ |
427 | ␊ |
428 | ␉// Load the MKext.␊ |
429 | ␉length = LoadThinFatFile(fileSpec, (void **)&package);␊ |
430 | ␉if (length < sizeof (DriversPackage)) {␊ |
431 | ␉␉return -1;␊ |
432 | ␉}␊ |
433 | ␊ |
434 | ␉// call hook to notify modules that the mkext has been loaded␊ |
435 | ␉execute_hook("LoadDriverMKext", (void*)fileSpec, (void*)package, (void*) &length, NULL);␊ |
436 | ␊ |
437 | ␉␊ |
438 | ␉// Verify the MKext.␊ |
439 | ␉if (( GetPackageElement(signature1) != kDriverPackageSignature1) ||␊ |
440 | ␉␉( GetPackageElement(signature2) != kDriverPackageSignature2) ||␊ |
441 | ␉␉( GetPackageElement(length) > kLoadSize ) ||␊ |
442 | ␉␉( GetPackageElement(adler32) !=␊ |
443 | ␉␉Adler32((unsigned char *)&package->version, GetPackageElement(length) - 0x10) ) )␊ |
444 | ␉{␊ |
445 | ␉␉return -1;␊ |
446 | ␉}␊ |
447 | ␊ |
448 | ␉// Make space for the MKext.␊ |
449 | ␉driversLength = GetPackageElement(length);␊ |
450 | ␉driversAddr = AllocateKernelMemory(driversLength);␊ |
451 | ␊ |
452 | ␉// Copy the MKext.␊ |
453 | ␉memcpy((void *)driversAddr, (void *)package, driversLength);␊ |
454 | ␊ |
455 | ␉// Add the MKext to the memory map.␊ |
456 | ␉snprintf(segName, sizeof(segName), "DriversPackage-%lx", driversAddr);␊ |
457 | ␉AllocateMemoryRange(segName, driversAddr, driversLength, kBootDriverTypeMKEXT);␊ |
458 | ␊ |
459 | ␉return 0;␊ |
460 | }␊ |
461 | ␊ |
462 | //==========================================================================␊ |
463 | // LoadDriverPList␊ |
464 | ␊ |
465 | long␊ |
466 | LoadDriverPList( char * dirSpec, char * name, long bundleType )␊ |
467 | {␊ |
468 | ␉long length, executablePathLength, bundlePathLength;␊ |
469 | ␉ModulePtr module;␊ |
470 | ␉TagPtr personalities;␊ |
471 | ␉char * buffer = 0;␊ |
472 | ␉char * tmpExecutablePath = 0;␊ |
473 | ␉char * tmpBundlePath = 0;␊ |
474 | ␉long ret = -1;␊ |
475 | ␊ |
476 | ␉do{␊ |
477 | ␉// Save the driver path.␊ |
478 | ␊ |
479 | ␉if(name) {␊ |
480 | ␉␉snprintf(gFileSpec, 4096, "%s/%s/%s", dirSpec, name, (bundleType == kCFBundleType2) ? "Contents/MacOS/" : "");␊ |
481 | ␉} else {␊ |
482 | ␉␉snprintf(gFileSpec, 4096, "%s/%s", dirSpec, (bundleType == kCFBundleType2) ? "Contents/MacOS/" : "");␊ |
483 | ␉}␊ |
484 | ␉executablePathLength = strlen(gFileSpec) + 1;␊ |
485 | ␊ |
486 | ␉tmpExecutablePath = malloc(executablePathLength);␊ |
487 | ␉if (tmpExecutablePath == 0) {␊ |
488 | ␉␉break;␊ |
489 | ␉}␊ |
490 | ␉strcpy(tmpExecutablePath, gFileSpec);␊ |
491 | ␊ |
492 | ␉if(name) {␊ |
493 | ␉␉snprintf(gFileSpec, 4096, "%s/%s", dirSpec, name);␊ |
494 | ␉} else ␉{␊ |
495 | ␉␉snprintf(gFileSpec, 4096, "%s", dirSpec);␊ |
496 | ␉}␊ |
497 | ␉bundlePathLength = strlen(gFileSpec) + 1;␊ |
498 | ␊ |
499 | ␉tmpBundlePath = malloc(bundlePathLength);␊ |
500 | ␉if (tmpBundlePath == 0) {␊ |
501 | ␉␉break;␊ |
502 | ␉}␊ |
503 | ␊ |
504 | ␉strcpy(tmpBundlePath, gFileSpec);␊ |
505 | ␊ |
506 | ␉// Construct the file spec to the plist, then load it.␊ |
507 | ␊ |
508 | ␉if(name) {␊ |
509 | ␉␉snprintf(gFileSpec, 4096, "%s/%s/%sInfo.plist", dirSpec, name, (bundleType == kCFBundleType2) ? "Contents/" : "");␊ |
510 | ␉} else {␊ |
511 | ␉␉snprintf(gFileSpec, 4096, "%s/%sInfo.plist", dirSpec, (bundleType == kCFBundleType2) ? "Contents/" : "");␊ |
512 | ␉}␊ |
513 | ␊ |
514 | ␉length = LoadFile(gFileSpec);␊ |
515 | ␉if (length == -1) {␊ |
516 | ␉␉break;␊ |
517 | ␉}␊ |
518 | ␉length = length + 1;␊ |
519 | ␉buffer = malloc(length);␊ |
520 | ␉if (buffer == 0) {␊ |
521 | ␉␉break;␊ |
522 | ␉}␊ |
523 | ␉strlcpy(buffer, (char *)kLoadAddr, length);␊ |
524 | ␊ |
525 | ␉// Parse the plist.␊ |
526 | ␊ |
527 | ␉ret = ParseXML(buffer, &module, &personalities);␊ |
528 | ␊ |
529 | ␉if (ret != 0) {␊ |
530 | ␉␉break;␊ |
531 | ␉}␊ |
532 | ␊ |
533 | ␉// Allocate memory for the driver path and the plist.␊ |
534 | ␊ |
535 | ␉module->executablePath = tmpExecutablePath;␊ |
536 | ␉module->bundlePath = tmpBundlePath;␊ |
537 | ␉module->bundlePathLength = bundlePathLength;␊ |
538 | ␉module->plistAddr = malloc(length);␊ |
539 | ␊ |
540 | ␉if ((module->executablePath == 0) || (module->bundlePath == 0) || (module->plistAddr == 0)) {␊ |
541 | ␉␉break;␊ |
542 | ␉}␊ |
543 | ␊ |
544 | ␉// Save the driver path in the module.␊ |
545 | ␉//strcpy(module->driverPath, tmpDriverPath);␊ |
546 | ␉tmpExecutablePath = 0;␊ |
547 | ␉tmpBundlePath = 0;␊ |
548 | ␊ |
549 | ␉// Add the plist to the module.␊ |
550 | ␊ |
551 | ␉strlcpy(module->plistAddr, (char *)kLoadAddr, length);␊ |
552 | ␉module->plistLength = length;␊ |
553 | ␊ |
554 | ␉// Add the module to the end of the module list.␊ |
555 | ␊ |
556 | ␉if (gModuleHead == 0) {␊ |
557 | ␉␉gModuleHead = module;␊ |
558 | ␉} else ␉{␊ |
559 | ␉␉gModuleTail->nextModule = module;␊ |
560 | ␉}␊ |
561 | ␉gModuleTail = module;␊ |
562 | ␊ |
563 | ␉// Add the persionalities to the personality list.␊ |
564 | ␊ |
565 | ␉if (personalities) {␊ |
566 | ␉␉personalities = personalities->tag;␊ |
567 | ␉}␊ |
568 | ␉while (personalities != 0)␊ |
569 | ␉{␊ |
570 | ␉␉if (gPersonalityHead == 0) {␊ |
571 | ␉␉␉gPersonalityHead = personalities->tag;␊ |
572 | ␉␉} else {␊ |
573 | ␉␉␉gPersonalityTail->tagNext = personalities->tag;␊ |
574 | ␉␉}␊ |
575 | ␊ |
576 | ␉␉gPersonalityTail = personalities->tag;␊ |
577 | ␉␉personalities = personalities->tagNext;␊ |
578 | ␉}␊ |
579 | ␊ |
580 | ␉ret = 0;␊ |
581 | ␉}␊ |
582 | ␉while (0);␊ |
583 | ␊ |
584 | ␉if ( buffer ) {␊ |
585 | ␉␉free( buffer );␊ |
586 | ␉}␊ |
587 | ␉if ( tmpExecutablePath ) {␊ |
588 | ␉␉free( tmpExecutablePath );␊ |
589 | ␉}␊ |
590 | ␉if ( tmpBundlePath ) {␊ |
591 | ␉␉free( tmpBundlePath );␊ |
592 | ␉}␊ |
593 | ␉return ret;␊ |
594 | }␊ |
595 | ␊ |
596 | ␊ |
597 | //==========================================================================␊ |
598 | // LoadMatchedModules␊ |
599 | ␊ |
600 | long␊ |
601 | LoadMatchedModules( void )␊ |
602 | {␊ |
603 | ␉TagPtr␉␉ prop;␊ |
604 | ␉ModulePtr␉ module;␊ |
605 | ␉char␉␉ *fileName, segName[32];␊ |
606 | ␉DriverInfoPtr driver;␊ |
607 | ␉long␉␉ length, driverAddr, driverLength;␊ |
608 | ␉void␉␉ *executableAddr = 0;␊ |
609 | ␊ |
610 | ␉module = gModuleHead;␊ |
611 | ␊ |
612 | ␉while (module != 0)␊ |
613 | ␉{␊ |
614 | ␉␉if (module->willLoad)␊ |
615 | ␉␉{␊ |
616 | ␉␉␉prop = XMLGetProperty(module->dict, kPropCFBundleExecutable);␊ |
617 | ␊ |
618 | ␉␉␉if (prop != 0)␊ |
619 | ␉␉␉{␊ |
620 | ␉␉␉␉fileName = prop->string;␊ |
621 | ␉␉␉␉snprintf(gFileSpec, 4096, "%s%s", module->executablePath, fileName);␊ |
622 | ␉␉␉␉length = LoadThinFatFile(gFileSpec, &executableAddr);␊ |
623 | ␉␉␉␉if (length == 0)␊ |
624 | ␉␉␉␉{␊ |
625 | ␉␉␉␉␉length = LoadFile(gFileSpec);␊ |
626 | ␉␉␉␉␉executableAddr = (void *)kLoadAddr;␊ |
627 | ␉␉␉␉}␊ |
628 | //␉␉␉␉printf("%s length = %d addr = 0x%x\n", gFileSpec, length, driverModuleAddr); getchar();␊ |
629 | ␉␉␉}␊ |
630 | ␉␉␉else␊ |
631 | ␉␉␉␉length = 0;␊ |
632 | ␊ |
633 | ␉␉␉if (length != -1)␊ |
634 | ␉␉␉{␊ |
635 | //␉␉␉␉driverModuleAddr = (void *)kLoadAddr;␊ |
636 | //␉␉␉␉if (length != 0)␊ |
637 | //␉␉␉␉{␊ |
638 | //␉␉␉␉␉ThinFatFile(&driverModuleAddr, &length);␊ |
639 | //␉␉␉␉}␊ |
640 | ␊ |
641 | ␉␉␉␉// Make make in the image area.␊ |
642 | ␊ |
643 | ␉␉␉␉execute_hook("LoadMatchedModules", module, &length, executableAddr, NULL);␊ |
644 | ␊ |
645 | ␉␉␉␉driverLength = sizeof(DriverInfo) + module->plistLength + length + module->bundlePathLength;␊ |
646 | ␉␉␉␉driverAddr = AllocateKernelMemory(driverLength);␊ |
647 | ␊ |
648 | ␉␉␉␉// Set up the DriverInfo.␊ |
649 | ␉␉␉␉driver = (DriverInfoPtr)driverAddr;␊ |
650 | ␉␉␉␉driver->plistAddr = (char *)(driverAddr + sizeof(DriverInfo));␊ |
651 | ␉␉␉␉driver->plistLength = module->plistLength;␊ |
652 | ␉␉␉␉if (length != 0)␊ |
653 | ␉␉␉␉{␊ |
654 | ␉␉␉␉␉driver->executableAddr = (void *)(driverAddr + sizeof(DriverInfo) +␊ |
655 | ␉␉␉␉␉␉␉␉␉␉ module->plistLength);␊ |
656 | ␉␉␉␉␉driver->executableLength = length;␊ |
657 | ␉␉␉␉}␊ |
658 | ␉␉␉␉else␊ |
659 | ␉␉␉␉{␊ |
660 | ␉␉␉␉␉driver->executableAddr␉ = 0;␊ |
661 | ␉␉␉␉␉driver->executableLength = 0;␊ |
662 | ␉␉␉␉}␊ |
663 | ␉␉␉␉driver->bundlePathAddr = (void *)(driverAddr + sizeof(DriverInfo) +␊ |
664 | ␉␉␉␉␉␉␉␉␉ module->plistLength + driver->executableLength);␊ |
665 | ␉␉␉␉driver->bundlePathLength = module->bundlePathLength;␊ |
666 | ␊ |
667 | ␉␉␉␉// Save the plist, module and bundle.␊ |
668 | ␉␉␉␉strcpy(driver->plistAddr, module->plistAddr);␊ |
669 | ␉␉␉␉if (length != 0)␊ |
670 | ␉␉␉␉{␊ |
671 | ␉␉␉␉␉memcpy(driver->executableAddr, executableAddr, length);␊ |
672 | ␉␉␉␉}␊ |
673 | ␉␉␉␉strcpy(driver->bundlePathAddr, module->bundlePath);␊ |
674 | ␊ |
675 | ␉␉␉␉// Add an entry to the memory map.␊ |
676 | ␉␉␉␉snprintf(segName, sizeof(segName), "Driver-%lx", (unsigned long)driver);␊ |
677 | ␉␉␉␉AllocateMemoryRange(segName, driverAddr, driverLength,␊ |
678 | ␉␉␉␉␉␉␉␉␉kBootDriverTypeKEXT);␊ |
679 | ␉␉␉}␊ |
680 | ␉␉}␊ |
681 | ␉␉module = module->nextModule;␊ |
682 | ␉}␊ |
683 | ␊ |
684 | ␉return 0;␊ |
685 | }␊ |
686 | ␊ |
687 | //==========================================================================␊ |
688 | // MatchPersonalities␊ |
689 | ␊ |
690 | static long␊ |
691 | MatchPersonalities( void )␊ |
692 | {␊ |
693 | ␉/* IONameMatch support not implemented */␊ |
694 | ␉return 0;␊ |
695 | }␊ |
696 | ␊ |
697 | //==========================================================================␊ |
698 | // MatchLibraries␊ |
699 | ␊ |
700 | static long␊ |
701 | MatchLibraries( void )␊ |
702 | {␊ |
703 | ␉TagPtr prop, prop2;␊ |
704 | ␉ModulePtr module, module2;␊ |
705 | ␉long done;␊ |
706 | ␊ |
707 | ␉do {␊ |
708 | ␉␉done = 1;␊ |
709 | ␉␉module = gModuleHead;␊ |
710 | ␊ |
711 | ␉␉while (module != 0)␊ |
712 | ␉␉{␊ |
713 | ␉␉␉if (module->willLoad == 1)␊ |
714 | ␉␉␉{␊ |
715 | ␉␉␉␉prop = XMLGetProperty(module->dict, kPropOSBundleLibraries);␊ |
716 | ␊ |
717 | ␉␉␉␉if (prop != 0)␊ |
718 | ␉␉␉␉{␊ |
719 | ␉␉␉␉␉prop = prop->tag;␊ |
720 | ␊ |
721 | ␉␉␉␉␉while (prop != 0)␊ |
722 | ␉␉␉␉␉{␊ |
723 | ␉␉␉␉␉␉module2 = gModuleHead;␊ |
724 | ␊ |
725 | ␉␉␉␉␉␉while (module2 != 0)␊ |
726 | ␉␉␉␉␉␉{␊ |
727 | ␉␉␉␉␉␉␉prop2 = XMLGetProperty(module2->dict, kPropCFBundleIdentifier);␊ |
728 | ␊ |
729 | ␉␉␉␉␉␉␉if ((prop2 != 0) && (!strcmp(prop->string, prop2->string)))␊ |
730 | ␉␉␉␉␉␉␉{␊ |
731 | ␉␉␉␉␉␉␉␉if (module2->willLoad == 0)␊ |
732 | ␉␉␉␉␉␉␉␉{␊ |
733 | ␉␉␉␉␉␉␉␉␉module2->willLoad = 1;␊ |
734 | ␉␉␉␉␉␉␉␉}␊ |
735 | ␉␉␉␉␉␉␉␉break;␊ |
736 | ␉␉␉␉␉␉␉}␊ |
737 | ␉␉␉␉␉␉␉module2 = module2->nextModule;␊ |
738 | ␉␉␉␉␉␉}␊ |
739 | ␉␉␉␉␉␉prop = prop->tagNext;␊ |
740 | ␉␉␉␉␉}␊ |
741 | ␉␉␉␉}␊ |
742 | ␉␉␉␉module->willLoad = 2;␊ |
743 | ␉␉␉␉done = 0;␊ |
744 | ␉␉␉}␊ |
745 | ␉␉␉module = module->nextModule;␊ |
746 | ␉␉}␊ |
747 | ␉}␊ |
748 | ␉while (!done);␊ |
749 | ␊ |
750 | ␉return 0;␊ |
751 | }␊ |
752 | ␊ |
753 | ␊ |
754 | //==========================================================================␊ |
755 | // FindModule␊ |
756 | ␊ |
757 | #if NOTDEF␊ |
758 | static ModulePtr␊ |
759 | FindModule( char * name )␊ |
760 | {␊ |
761 | ␉ModulePtr module;␊ |
762 | ␉TagPtr prop;␊ |
763 | ␊ |
764 | ␉module = gModuleHead;␊ |
765 | ␊ |
766 | ␉while (module != 0)␊ |
767 | ␉{␊ |
768 | ␉␉prop = GetProperty(module->dict, kPropCFBundleIdentifier);␊ |
769 | ␊ |
770 | ␉␉if ((prop != 0) && !strcmp(name, prop->string)) {␊ |
771 | ␉␉␉break;␊ |
772 | ␉␉}␊ |
773 | ␊ |
774 | ␉␉module = module->nextModule;␊ |
775 | ␉}␊ |
776 | ␊ |
777 | ␉return module;␊ |
778 | }␊ |
779 | #endif /* NOTDEF */␊ |
780 | ␊ |
781 | //==========================================================================␊ |
782 | // ParseXML␊ |
783 | ␊ |
784 | static long␊ |
785 | ParseXML( char * buffer, ModulePtr * module, TagPtr * personalities )␊ |
786 | {␊ |
787 | ␉long length, pos;␊ |
788 | ␉TagPtr moduleDict, required;␊ |
789 | ␉ModulePtr tmpModule;␊ |
790 | ␊ |
791 | ␉pos = 0;␊ |
792 | ␊ |
793 | ␉while (1)␊ |
794 | ␉{␊ |
795 | ␉␉length = XMLParseNextTag(buffer + pos, &moduleDict);␊ |
796 | ␉␉if (length == -1) {␊ |
797 | ␉␉␉break;␊ |
798 | ␉␉}␊ |
799 | ␊ |
800 | ␉␉pos += length;␊ |
801 | ␊ |
802 | ␉␉if (moduleDict == 0) {␊ |
803 | ␉␉␉continue;␊ |
804 | ␉␉}␊ |
805 | ␉␉if (moduleDict->type == kTagTypeDict) {␊ |
806 | ␉␉␉break;␊ |
807 | ␉␉}␊ |
808 | ␉␉XMLFreeTag(moduleDict);␊ |
809 | ␉}␊ |
810 | ␊ |
811 | ␉if (length == -1) {␊ |
812 | ␉␉return -1;␊ |
813 | ␉}␊ |
814 | ␊ |
815 | ␉required = XMLGetProperty(moduleDict, kPropOSBundleRequired);␊ |
816 | ␊ |
817 | ␉if ( (required == 0) || (required->type != kTagTypeString) || !strcmp(required->string, "Safe Boot"))␊ |
818 | ␉{␊ |
819 | ␉␉XMLFreeTag(moduleDict);␊ |
820 | ␉␉return -2;␊ |
821 | ␉}␊ |
822 | ␊ |
823 | ␉tmpModule = malloc(sizeof(Module));␊ |
824 | ␉if (tmpModule == 0) {␊ |
825 | ␉␉XMLFreeTag(moduleDict);␊ |
826 | ␉␉return -1;␊ |
827 | ␉}␊ |
828 | ␉tmpModule->dict = moduleDict;␊ |
829 | ␊ |
830 | ␉// For now, load any module that has OSBundleRequired != "Safe Boot".␊ |
831 | ␊ |
832 | ␉tmpModule->willLoad = 1;␊ |
833 | ␊ |
834 | ␉*module = tmpModule;␊ |
835 | ␊ |
836 | ␉// Get the personalities.␊ |
837 | ␊ |
838 | ␉*personalities = XMLGetProperty(moduleDict, kPropIOKitPersonalities);␊ |
839 | ␊ |
840 | ␉return 0;␊ |
841 | }␊ |
842 | ␊ |
843 | #if NOTDEF␊ |
844 | static char gPlatformName[64];␊ |
845 | #endif␊ |
846 | ␊ |
847 | char *gDarwinBuildVerStr = "Darwin Kernel Version"; // Bungo␊ |
848 | ␊ |
849 | long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize)␊ |
850 | {␊ |
851 | ␉long ret = 0;␊ |
852 | ␉compressed_kernel_header * kernel_header = (compressed_kernel_header *) binary;␊ |
853 | ␉u_int32_t uncompressed_size = 0, size = 0, adler32 = 0;␊ |
854 | ␉void *buffer = NULL;␊ |
855 | ␉unsigned long len = 0;␊ |
856 | ␉␊ |
857 | /*#if 0␊ |
858 | ␉printf("kernel header:\n");␊ |
859 | ␉printf("signature: 0x%x\n", kernel_header->signature);␊ |
860 | ␉printf("compress_type: 0x%x\n", kernel_header->compress_type);␊ |
861 | ␉printf("adler32: 0x%x\n", kernel_header->adler32);␊ |
862 | ␉printf("uncompressed_size: 0x%x\n", kernel_header->uncompressed_size);␊ |
863 | ␉printf("compressed_size: 0x%x\n", kernel_header->compressed_size);␊ |
864 | ␉getchar();␊ |
865 | #endif*/␊ |
866 | ␊ |
867 | ␉if (kernel_header->signature == OSSwapBigToHostConstInt32('comp'))␊ |
868 | ␉{␊ |
869 | ␉␉DBG("Decompressing Kernel: ");␊ |
870 | ␊ |
871 | ␉␉if ((kernel_header->compress_type != OSSwapBigToHostConstInt32('lzss')) &&␊ |
872 | ␉␉␉(kernel_header->compress_type != OSSwapBigToHostConstInt32('lzvn')))␊ |
873 | ␉␉{␊ |
874 | ␉␉␉error("ERROR: kernel compression is bad!\n");␊ |
875 | ␉␉␉return -1;␊ |
876 | ␉␉}␊ |
877 | #if NOTDEF␊ |
878 | ␉␉if (kernel_header->platform_name[0] && strcmp(gPlatformName, kernel_header->platform_name))␊ |
879 | ␉␉{␊ |
880 | ␉␉␉return -1;␊ |
881 | ␉␉}␊ |
882 | ␉␉if (kernel_header->root_path[0] && strcmp(gBootFile, kernel_header->root_path))␊ |
883 | ␉␉{␊ |
884 | ␉␉␉return -1;␊ |
885 | ␉␉}␊ |
886 | #endif␊ |
887 | ␉␉uncompressed_size = OSSwapBigToHostInt32(kernel_header->uncompressed_size);␊ |
888 | ␉␉binary = buffer = malloc(uncompressed_size);␊ |
889 | ␊ |
890 | ␉␉// MinusZwei␊ |
891 | ␉␉size = 0;␊ |
892 | ␉␉switch (kernel_header->compress_type)␊ |
893 | ␉␉{␊ |
894 | ␉␉␉case OSSwapBigToHostConstInt32('lzvn'):␊ |
895 | ␉␉␉␉size = decompress_lzvn( binary, uncompressed_size, &kernel_header->data[0], OSSwapBigToHostInt32(kernel_header->compressed_size));␊ |
896 | ␉␉␉␉break;␊ |
897 | ␊ |
898 | ␉␉␉case OSSwapBigToHostConstInt32('lzss'):␊ |
899 | ␉␉␉␉size = decompress_lzss( (u_int8_t *)binary, uncompressed_size, &kernel_header->data[0], OSSwapBigToHostInt32(kernel_header->compressed_size));␊ |
900 | ␉␉␉␉break;␊ |
901 | ␊ |
902 | ␉␉␉default:␊ |
903 | ␉␉␉␉break;␊ |
904 | ␉␉}␊ |
905 | ␉␉// MinusZwei␊ |
906 | ␊ |
907 | ␉␉if (uncompressed_size != size) {␊ |
908 | ␉␉␉error("ERROR: size mismatch from lzss (found: %x, expected: %x).\n", size, uncompressed_size);␊ |
909 | ␉␉␉return -1;␊ |
910 | ␉␉}␊ |
911 | ␊ |
912 | ␉␉adler32 = Adler32(binary, uncompressed_size);␊ |
913 | ␉␉if (OSSwapBigToHostInt32(kernel_header->adler32) != adler32)␊ |
914 | ␉␉{␊ |
915 | ␉␉␉error("ERROR: adler mismatch (found: %x, expected: %x).\n", adler32, OSSwapBigToHostInt32(kernel_header->adler32));␊ |
916 | ␉␉␉return -1;␊ |
917 | ␉␉}␊ |
918 | ␊ |
919 | ␉␉DBG("OK.\n");␊ |
920 | ␉}␊ |
921 | ␉␊ |
922 | ␉ret = ThinFatFile(&binary, &len);␊ |
923 | ␉if (ret == 0 && len == 0 && archCpuType==CPU_TYPE_X86_64)␊ |
924 | ␉{␊ |
925 | ␉␉archCpuType=CPU_TYPE_I386;␊ |
926 | ␉␉ret = ThinFatFile(&binary, &len);␊ |
927 | ␉}␊ |
928 | ␊ |
929 | ␉// Bungo: no range checking, sorry␊ |
930 | ␉size = 0;␊ |
931 | ␉while (memcmp((uint8_t *)binary + size, (uint8_t *)gDarwinBuildVerStr, 21)) {␊ |
932 | ␉␉size++;␊ |
933 | ␉}␊ |
934 | ␉gDarwinBuildVerStr = (char *)binary + size;␊ |
935 | ␊ |
936 | ␉// Notify modules that the kernel has been decompressed, thinned and is about to be decoded␊ |
937 | ␉execute_hook("DecodeKernel", (void*)binary, NULL, NULL, NULL);␊ |
938 | ␊ |
939 | ␉ret = DecodeMachO(binary, rentry, raddr, rsize);␊ |
940 | ␉if (ret < 0 && archCpuType == CPU_TYPE_X86_64)␊ |
941 | ␉{␊ |
942 | ␉␉archCpuType = CPU_TYPE_I386;␊ |
943 | ␉␉ret = DecodeMachO(binary, rentry, raddr, rsize);␊ |
944 | ␉}␊ |
945 | ␊ |
946 | ␉return ret;␊ |
947 | }␊ |
948 |