Chameleon

Chameleon Svn Source Tree

Root/branches/meklort/i386/modules/KextPatcher/kext_patcher.c

Source at commit 564 created 9 years 6 months ago.
By meklort, Removed warnings.
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
19void 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 **/
26void 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
32register_hook_callback("PCIDevice", &KextPatcher_hook);
33register_hook_callback("LoadMatchedModules", &kext_loaded);
34register_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 **/
43void kext_loaded(void* moduletmp, void* lengthprt, void* executableAddr, void* arg3)
44{
45/*
46ModulePtr module = moduletmp;
47long length = *(long*)lengthprt;
48//long length2 = strlen(module->plistAddr);
49// *(long*)lengthprt = length2 + 5 * 1024 * 1024;
50
51printf("Loading %s, lenght is %d (%d), executable is 0x%X\n", module->plistAddr, length, length2, executableAddr);
52getc();
53 */
54}
55
56/**
57 ** mkext_loaded -> Called whenever an mkext is in read into memory
58 **This function will be used to patch mkext. Matching kexts will be
59 **Extracted, modified, and then compressed again. Note: I need to determine
60 **what sort of slowdown this will cause and if it's worth implimenting.
61 **/
62
63void mkext_loaded(void* filespec, void* packagetmp, void* length, void* arg3)
64{
65/*
66DriversPackage * package = packagetmp;
67printf("Loading %s, length %d\n", filespec, length);
68getc();
69 */
70}
71
72void KextPatcher_hook(void* arg1, void* arg2, void* arg3, void* arg4)
73{
74//pci_dt_t* current = arg1;
75}

Archive Download this file

Revision: 564