Chameleon

Chameleon Svn Source Tree

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

Source at commit 561 created 13 years 6 months ago.
By meklort, Added missing gma files
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(pci_dt_t* 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{
45long length = *(long*)lengthprt;
46ModulePtr module = moduletmp;
47printf("Loading %s, lenght is %d\n", module->plistAddr, length);
48getc();
49}
50
51/**
52 ** mkext_loaded -> Called whenever an mkext is in read into memory
53 **This function will be used to patch mkext. Matching kexts will be
54 **Extracted, modified, and then compressed again. Note: I need to determine
55 **what sort of slowdown this will cause and if it's worth implimenting.
56 **/
57
58void mkext_loaded(void* filespec, void* packagetmp, void* length, void* arg3)
59{
60DriversPackage * package = packagetmp;
61printf("Loading %s, length %d\n", filespec, length);
62getc();
63}
64
65void KextPatcher_hook(pci_dt_t* current, void* arg2, void* arg3, void* arg4)
66{
67// Lets do some patching.
68}

Archive Download this file

Revision: 561