Chameleon

Chameleon Commit Details

Date:2010-08-31 06:20:07 (13 years 9 months ago)
Author:Evan Lojewski
Commit:458
Parents: 457
Message:Modified make file. Created initial module for patching kexts + associated hooks that may be needed. Subject to change and may be removed if deemed unusable / impractical. Untested.
Changes:
A/branches/meklort/i386/modules/KextPatcher/Makefile
A/branches/meklort/i386/modules/KextPatcher
A/branches/meklort/i386/modules/KextPatcher/kext_patcher.c
A/branches/meklort/i386/modules/KextPatcher/kext_patcher.h
M/branches/meklort/i386/modules/KernelPatcher/Makefile
M/branches/meklort/i386/boot2/drivers.c

File differences

branches/meklort/i386/boot2/drivers.c
3838
3939
4040
41
4142
43
4244
4345
4446
......
413415
414416
415417
418
419
420
421
416422
417423
418424
......
422428
423429
424430
431
425432
426433
427434
......
591598
592599
593600
601
602
603
594604
595605
596606
#include "bootstruct.h"
#include "xml.h"
#include "ramdisk.h"
#include "modules.h"
extern char gMacOSVersion;
extern intrecoveryMode;
length = LoadThinFatFile(fileSpec, (void **)&package);
if (length < sizeof (DriversPackage)) return -1;
// call hook to notify modules that the mkext has been loaded
execute_hook("LoadDriverMKext", (void*)fileSpec, (void*)package, (void*) length, NULL);
// Verify the MKext.
if (( GetPackageElement(signature1) != kDriverPackageSignature1) ||
( GetPackageElement(signature2) != kDriverPackageSignature2) ||
{
return -1;
}
// Make space for the MKext.
driversLength = GetPackageElement(length);
//}
// Make make in the image area.
execute_hook("LoadMatchedModules", module, &length, executableAddr, NULL);
driverLength = sizeof(DriverInfo) + module->plistLength + length + module->bundlePathLength;
driverAddr = AllocateKernelMemory(driverLength);
branches/meklort/i386/modules/KextPatcher/kext_patcher.c
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
/*
* Copyright (c) 2010 Evan Lojewski. All rights reserved.
*
*KextPather
*This is an experimental module that I'm looking into implimenting.
*The main purpose is to replace the need for programs such as
* NetbookInstaller's kext patching routines. THis way, Apple's kexts can be
* patched whe loaded instead. (eg: GMA950 kext, Bluetooth + Wifi kexts)
*/
#include "libsaio.h"
#include "kext_patcher.h"
//#include "platform.h"
#include "modules.h"
//extern PlatformInfo_t Platform;
/**
** KextPatcher_start -> module start
**Notified the module system that this module will hook into the
**LoadMatchedModules and LoadDriverMKext functions
**/
void KextPatcher_start()
{
// Hooks into the following:
//execute_hook("LoadDriverMKext", (void*)package, (void*) length, NULL, NULL);
// execute_hook("LoadMatchedModules", module, &length, executableAddr, NULL);
register_hook_callback("LoadMatchedModules", &kext_loaded);
register_hook_callback("LoadDriverMKext", &mkext_loaded);
}
/**
** kext_loaded -> Called whenever a kext is in read into memory
**This function will be used to patch kexts ( eg AppleInteIntegratedFramebuffer)
**and their plists when they are loaded into memmory
**/
void kext_loaded(void* module, void* length, void* executableAddr, void* arg3)
{
}
/**
** mkext_loaded -> Called whenever an mkext is in read into memory
**This function will be used to patch mkext. Matching kexts will be
**Extracted, modified, and then compressed again. Note: I need to determine
**what sort of slowdown this will cause and if it's worth implimenting.
**/
void mkext_loaded(void* filespec, void* package, void* lenght, void* arg3)
{
}
branches/meklort/i386/modules/KextPatcher/kext_patcher.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/*
* Copyright (c) 2009 Evan Lojewski. All rights reserved.
*
*/
#ifndef __BOOT2_KERNEL_PATCHER_H
#define __BOOT2_KERNEL_PATCHER_H
void KextPatcher_start();
void kext_loaded(void* module, void* length, void* executableAddr, void* arg3);
void mkext_loaded(void* filespec, void* package, void* lenght, void* arg3);
#endif /* !__BOOT2_KERNEL_PATCHER_H */
branches/meklort/i386/modules/KextPatcher/Makefile
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
MODULE_NAME = KextPatcher
MODULE_VERSION = "1.0.0"
MODULE_COMPAT_VERSION = "1.0.0"
MODULE_START = _$(MODULE_NAME)_start
MODULE_DEPENDENCIES =
DIR = KextPatcher
include ../../MakePaths.dir
OBJROOT=../../../obj/i386/modules/$(DIR)
SYMROOT=../../../sym/i386/modules/
DSTROOT=../../../dst/i386/modules/
UTILDIR = ../../util
LIBSADIR = ../../libsa
LIBSAIODIR = ../../libsaio
BOOT2DIR = ../../boot2
INSTALLDIR = $(DSTROOT)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/standalone
OPTIM = -Os -Oz
DEBUG = -DNOTHING
#DEBUG = -DDEBUG_HELLO_WORLD=1
CFLAGS= $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost \
-D__ARCHITECTURE__=\"i386\" -DSAIO_INTERNAL_USER \
-DRCZ_COMPRESSED_FILE_SUPPORT $(DEBUG) \
-fno-builtin $(OMIT_FRAME_POINTER_CFLAG) \
-mpreferred-stack-boundary=2 -fno-align-functions -fno-stack-protector \
-march=pentium4 -msse2 -mfpmath=sse -msoft-float -fno-common -mdynamic-no-pic
DEFINES=
CONFIG = hd
INC = -I. -I.. -I$(SYMROOT) -I$(UTILDIR) -I$(LIBSADIR) -I$(LIBSAIODIR) -I$(BOOT2DIR)
ifneq "" "$(wildcard /bin/mkdirs)"
MKDIRS = /bin/mkdirs
else
MKDIRS = /bin/mkdir -p
endif
AS = as
LD = ld
# LIBS= -lc_static
LIBS=
VPATH = $(OBJROOT):$(SYMROOT)
OBJS = kext_patcher.o
SFILES =
CFILES =
HFILES =
EXPORTED_HFILES =
INSTALLED_HFILES =
OTHERFILES = Makefile
ALLSRC = $(SFILES) $(CFILES) \
$(HFILES) $(OTHERFILES)
DIRS_NEEDED = $(OBJROOT) $(SYMROOT)
all embedtheme: ${OBJS} dylib
dylib: ${OBJS}
ld -flat_namespace -arch i386 \
-undefined suppress \
-alias $(MODULE_START) start \
-dylib -read_only_relocs suppress \
-S -x -dead_strip_dylibs \
-no_uuid \
-bind_at_load \
-current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \
-final_output $(MODULE_NAME) \
-weak_library $(SYMROOT)/Symbols.dylib \
$(OBJROOT)/kext_patcher.o -o $(SYMROOT)/$(MODULE_NAME).dylib
kext_patcher.o:
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "kext_patcher.c" $(INC) -o "$(OBJROOT)/kext_patcher.o"
include ../../MakeInc.dir
# dependencies
-include $(OBJROOT)/Makedep
branches/meklort/i386/modules/KernelPatcher/Makefile
55
66
77
8
8
99
1010
1111
......
7373
7474
7575
76
7776
7877
7978
MODULE_START = _$(MODULE_NAME)_start
MODULE_DEPENDENCIES =
DIR = HelloWorld
DIR = KernelPatcher
include ../../MakePaths.dir
-current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \
-final_output $(MODULE_NAME) \
-weak_library $(SYMROOT)/Symbols.dylib \
-weak_library $(SYMROOT)/HelloWorld.dylib \
$(OBJROOT)/kernel_patcher.o -o $(SYMROOT)/$(MODULE_NAME).dylib

Archive Download the corresponding diff file

Revision: 458