Root/
Source at commit 583 created 13 years 5 months ago. By meklort, Module updates, mostly bugfixes. | |
---|---|
1 | /*␊ |
2 | * Copyright (c) 2010 Evan Lojewski. All rights reserved.␊ |
3 | *␉␊ |
4 | *␉KextPather␊ |
5 | *␉This is an experimental module that I'm looking into implimenting.␊ |
6 | *␉The main purpose is to replace the need for programs such as ␊ |
7 | * NetbookInstaller's kext patching routines. THis way, Apple's kexts can be␊ |
8 | * patched whe loaded instead. (eg: GMA950 kext, Bluetooth + Wifi kexts)␊ |
9 | */␊ |
10 | ␊ |
11 | #include "libsaio.h"␊ |
12 | #include "kext_patcher.h"␊ |
13 | #include "pci.h"␊ |
14 | #include "drivers.h"␊ |
15 | #include "mkext.h"␊ |
16 | #include "modules.h"␊ |
17 | ␊ |
18 | ␊ |
19 | void KextPatcher_hook(void* current, void* arg2, void* arg3, void* arg4);␊ |
20 | ␊ |
21 | /**␊ |
22 | ** KextPatcher_start -> module start␊ |
23 | **␉␉Notified the module system that this module will hook into the ␊ |
24 | **␉␉LoadMatchedModules and LoadDriverMKext functions␊ |
25 | **/␊ |
26 | void KextPatcher_start()␊ |
27 | {␉␉␊ |
28 | ␉// Hooks into the following:␊ |
29 | ␉//␉execute_hook("LoadDriverMKext", (void*)package, (void*) length, NULL, NULL);␊ |
30 | ␉// execute_hook("LoadMatchedModules", module, &length, executableAddr, NULL);␊ |
31 | ␊ |
32 | ␉register_hook_callback("PCIDevice", &KextPatcher_hook);␊ |
33 | ␉register_hook_callback("LoadMatchedModules", &kext_loaded); ␊ |
34 | ␉register_hook_callback("LoadDriverMKext", &mkext_loaded); ␊ |
35 | ␊ |
36 | }␊ |
37 | ␊ |
38 | /**␊ |
39 | ** kext_loaded -> Called whenever a kext is in read into memory␊ |
40 | **␉␉This function will be used to patch kexts ( eg AppleInteIntegratedFramebuffer)␊ |
41 | **␉␉and their plists when they are loaded into memmory␊ |
42 | **/␊ |
43 | void kext_loaded(void* moduletmp, void* lengthprt, void* executableAddr, void* arg3)␊ |
44 | {␊ |
45 | ␉␊ |
46 | ␉ModulePtr module = moduletmp;␊ |
47 | ␉long length = *(long*)lengthprt;␊ |
48 | ␉//long length2 = strlen(module->plistAddr);␊ |
49 | ␉// *(long*)lengthprt = length2 + 5 * 1024 * 1024;␊ |
50 | ␊ |
51 | ␉printf("Loading %s, lenght is %d, executable is 0x%X\n", module->plistAddr, length, executableAddr);␊ |
52 | ␉getc();␊ |
53 | }␊ |
54 | ␊ |
55 | /**␊ |
56 | ** mkext_loaded -> Called whenever an mkext is in read into memory␊ |
57 | **␉␉This function will be used to patch mkext. Matching kexts will be␊ |
58 | **␉␉Extracted, modified, and then compressed again. Note: I need to determine␊ |
59 | **␉␉what sort of slowdown this will cause and if it's worth implimenting.␊ |
60 | **/␊ |
61 | ␊ |
62 | void mkext_loaded(void* filespec, void* packagetmp, void* length, void* arg3)␊ |
63 | {␊ |
64 | ␉␊ |
65 | ␉//DriversPackage * package = packagetmp;␊ |
66 | ␉printf("Loading %s, length %d\n", filespec, length);␊ |
67 | ␉getc();␊ |
68 | }␊ |
69 | ␊ |
70 | void KextPatcher_hook(void* arg1, void* arg2, void* arg3, void* arg4)␊ |
71 | {␊ |
72 | ␉//pci_dt_t* current = arg1;␊ |
73 | } |