Chameleon

Chameleon Commit Details

Date:2010-10-11 07:01:50 (13 years 6 months ago)
Author:Evan Lojewski
Commit:583
Parents: 582
Message:Module updates, mostly bugfixes.
Changes:
M/branches/meklort/i386/modules/GUI/GUI_module.c
M/branches/meklort/i386/modules/KernelPatcher/kernel_patcher.c
M/branches/meklort/i386/boot2/boot.c
M/branches/meklort/i386/modules/KextPatcher/kext_patcher.c
M/branches/meklort/i386/boot2/modules.c
M/branches/meklort/i386/modules/NetbookInstaller/NBI.c
M/branches/meklort/i386/modules/GUI/gui.c
M/branches/meklort/i386/boot2/drivers.c

File differences

branches/meklort/i386/boot2/boot.c
139139
140140
141141
142
143142
144143
145144
......
405404
406405
407406
408
409
410407
411408
412409
......
422419
423420
424421
422
423
424
425425
426426
427427
int ret;
bootArgs->kaddr = bootArgs->ksize = 0;
execute_hook("ExecKernel", (void*)binary, NULL, NULL, NULL);
ret = DecodeKernel(binary,
// Other status (e.g. 0) means that we should proceed with boot.
// Notify moduals that we are attempting to boot
execute_hook("PreBoot", NULL, NULL, NULL, NULL);
// Find out which version mac os we're booting.
getOSVersion(gMacOSVersion);
}
}
// Notify moduals that we are attempting to boot
execute_hook("PreBoot", NULL, NULL, NULL, NULL);
if (!getBoolForKey (kWake, &tryresume, &bootInfo->bootConfig)) {
tryresume = true;
tryresumedefault = true;
branches/meklort/i386/boot2/modules.c
134134
135135
136136
137
137
138138
139139
140140
......
331331
332332
333333
334
334
335335
336336
337337
338338
339339
340
340
341341
342342
343343
if (moduleSize && read(fh, module_base, moduleSize) == moduleSize)
{
//printf("Module %s read in.\n", modString);
DBG("Module %s read in.\n", modString);
// Module loaded into memory, parse it
module_start = parse_mach(module_base, &load_module, &add_symbol);
// Parse through the load commands
if(((struct mach_header*)binary)->magic == MH_MAGIC)
{
is64 = 0;
is64 = false;
binaryIndex += sizeof(struct mach_header);
}
else if(((struct mach_header_64*)binary)->magic == MH_MAGIC_64)
{
// NOTE: modules cannot be 64bit...
is64 = 1;
is64 = true;
binaryIndex += sizeof(struct mach_header_64);
}
else
branches/meklort/i386/boot2/drivers.c
160160
161161
162162
163
164
163
164
165
165166
166
167
168
169
167
168
169
170
171
172
173
174
170175
171
176
172177
173
178
174179
175
176
177
178
179
180
181
182
180
181
182
183
184
185
186
187
188
183189
184190
185
186
191
192
187193
188194
189195
FileLoadDrivers(dirSpecExtra, 0);
}
#endif
// Next try to load Extra extensions from the selected root partition.
strcpy(dirSpecExtra, "/Extra/");
// First try a specfic OS version folder ie 10.5
sprintf(dirSpecExtra, "/Extra/%s/", &gMacOSVersion);
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
// If failed, then try to load Extra extensions from the boot partition
// in case we have a separate booter partition or a bt(0,0) aliased ramdisk.
if ( !(gBIOSBootVolume->biosdev == gBootVolume->biosdev && gBIOSBootVolume->part_no == gBootVolume->part_no)
{
// Next try to load Extra extensions from the selected root partition.
strcpy(dirSpecExtra, "/Extra/");
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
// If failed, then try to load Extra extensions from the boot partition
// in case we have a separate booter partition or a bt(0,0) aliased ramdisk.
if ( !(gBIOSBootVolume->biosdev == gBootVolume->biosdev && gBIOSBootVolume->part_no == gBootVolume->part_no)
#ifndef OPTION_ROM
|| (gRAMDiskVolume && gRAMDiskBTAliased) )
|| (gRAMDiskVolume && gRAMDiskBTAliased) )
#else
)
)
#endif
{
// First try a specfic OS version folder ie 10.5
sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gMacOSVersion);
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
// Next we'll try the base
strcpy(dirSpecExtra, "bt(0,0)/Extra/");
FileLoadDrivers(dirSpecExtra, 0);
{
// First try a specfic OS version folder ie 10.5
sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gMacOSVersion);
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
// Next we'll try the base
strcpy(dirSpecExtra, "bt(0,0)/Extra/");
FileLoadDrivers(dirSpecExtra, 0);
}
}
}
}
}
// TODO: fix this, the order does matter, and it's not correct now.
// Also try to load Extensions from boot helper partitions.
if (gBootVolume->flags & kBVFlagBooter)
branches/meklort/i386/modules/NetbookInstaller/NBI.c
4949
5050
5151
52
5253
54
55
56
57
58
59
60
5361
5462
5563
......
8189
8290
8391
84
8592
8693
8794
......
103110
104111
105112
106
107113
108
109114
110
111
112
113
114
115
116
115
117116
118117
119118
120119
121120
122121
122
123123
124
125
126
124
125
126
127
128
129
130
131
127132
128133
129134
......
254259
255260
256261
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
void NetbookInstaller_start()
{
//else printf("Unable to locate Extra/SystemVersion.LastPatched.plist\n");
register_hook_callback("PreBoot", &NBI_PreBoot_hook);
}
void NBI_PreBoot_hook(void* arg1, void* arg2, void* arg3, void* arg4)
{
bool dummyVal = 0;
config_file_t systemVersion;
char valid = false;
)
{
runNetbookInstaller = 1;
archCpuType = CPU_TYPE_I386;
}
else
{
//else printf("Unable to locate Extra/SystemVersion.LastPatched.plist\n");
register_hook_callback("PreBoot", &NBI_PreBoot_hook);
}
void NBI_PreBoot_hook(void* arg1, void* arg2, void* arg3, void* arg4)
{
extern bool usePngImage;
bool dummyVal = 0;
if (getBoolForKey("recovery", &dummyVal, &bootInfo->bootConfig) && dummyVal)
if (!runNetbookInstaller && getBoolForKey("recovery", &dummyVal, &bootInfo->bootConfig) && dummyVal)
{
if(dummyVal) runNetbookInstaller = 2;
}
if(runNetbookInstaller)
{
replace_function("_LoadDrivers", &NBI_LoadDrivers);
replace_function("_md0Ramdisk", &NBI_md0Ramdisk);
replace_function("_loadBootGraphics", &NBI_loadBootGraphics);
usePngImage = true;
if(runNetbookInstaller == 1)
{
replace_function("_md0Ramdisk", &NBI_md0Ramdisk);
}
// Force arch=i386 + -v
archCpuType = CPU_TYPE_I386;
gVerboseMode = true;
}
}
return 0;
}
extern int loadPngImage(const char *filename, uint16_t *width, uint16_t *height, uint8_t **imageData);
//==========================================================================
// loadBootGraphics
void NBI_loadBootGraphics(void)
{
extern uint8_t *bootImageData;
extern uint16_t bootImageWidth;
extern uint16_t bootImageHeight;
extern const char* theme_name;
extern bool usePngImage;
if (bootImageData != NULL) {
return;
}
char dirspec[256];
if ((strlen(theme_name) + 24) > sizeof(dirspec)) {
usePngImage = false;
return;
}
sprintf(dirspec, "/Extra/Themes/%s/NBI.png", theme_name);
if (loadPngImage(dirspec, &bootImageWidth, &bootImageHeight, &bootImageData) != 0) {
#ifdef EMBED_THEME
if ((loadEmbeddedPngImage(__boot_png, __boot_png_len, &bootImageWidth, &bootImageHeight, &bootImageData)) != 0)
#endif
usePngImage = false;
}
}
branches/meklort/i386/modules/KextPatcher/kext_patcher.c
4242
4343
4444
45
45
4646
4747
4848
4949
5050
51
51
5252
53
5453
5554
5655
......
6261
6362
6463
65
66
64
65
6766
6867
69
7068
7169
7270
**/
void kext_loaded(void* moduletmp, void* lengthprt, void* executableAddr, void* arg3)
{
/*
ModulePtr module = moduletmp;
long length = *(long*)lengthprt;
//long length2 = strlen(module->plistAddr);
// *(long*)lengthprt = length2 + 5 * 1024 * 1024;
printf("Loading %s, lenght is %d (%d), executable is 0x%X\n", module->plistAddr, length, length2, executableAddr);
printf("Loading %s, lenght is %d, executable is 0x%X\n", module->plistAddr, length, executableAddr);
getc();
*/
}
/**
void mkext_loaded(void* filespec, void* packagetmp, void* length, void* arg3)
{
/*
DriversPackage * package = packagetmp;
//DriversPackage * package = packagetmp;
printf("Loading %s, length %d\n", filespec, length);
getc();
*/
}
void KextPatcher_hook(void* arg1, void* arg2, void* arg3, void* arg4)
branches/meklort/i386/modules/GUI/gui.c
18211821
18221822
18231823
1824
1824
18251825
18261826
18271827
......
18341834
18351835
18361836
1837
1837
18381838
18391839
18401840
......
18421842
18431843
18441844
1845
1845
18461846
18471847
18481848
......
18551855
18561856
18571857
1858
1859
1860
1861
1862
18581863
18591864
18601865
uint16_t bootImageWidth = 0;
uint16_t bootImageHeight = 0;
uint8_t *bootImageData = NULL;
bool usePngImage = true;
char usePngImage = 0;
//==========================================================================
// loadBootGraphics
char dirspec[256];
if ((strlen(theme_name) + 24) > sizeof(dirspec)) {
usePngImage = false;
usePngImage = 0;
return;
}
sprintf(dirspec, "/Extra/Themes/%s/boot.png", theme_name);
#ifdef EMBED_THEME
if ((loadEmbeddedPngImage(__boot_png, __boot_png_len, &bootImageWidth, &bootImageHeight, &bootImageData)) != 0)
#endif
usePngImage = false;
usePngImage = 0;
}
}
const char *dummyVal;
int oldScreenWidth, oldScreenHeight;
uint16_t x, y;
bool legacy_logo = false;
if (getBoolForKey("Legacy Logo", &legacy_logo, &bootInfo->bootConfig) && !legacy_logo)
{
usePngImage = 1;
}
if (usePngImage && bootImageData == NULL) {
loadBootGraphics();
branches/meklort/i386/modules/GUI/GUI_module.c
7575
7676
7777
78
78
7979
8080
8181
......
8484
8585
8686
87
88
87
8988
9089
9190
......
9594
9695
9796
98
97
9998
10099
101100
......
105104
106105
107106
108
109
110
111
112107
113108
114109
{
setVideoMode( GRAPHICS_MODE, 0 );
}
}
}
/**
void GUI_PreBoot_hook(void* arg1, void* arg2, void* arg3, void* arg4)
{
bool legacy_logo;
extern bool usePngImage;
// Turn off any GUI elements
if( bootArgs->Video.v_display == GRAPHICS_MODE )
{
gui.infobox.draw = false;
gui.logo.draw = false;
drawBackground();
updateVRAM();
//updateVRAM();
if(!gVerboseMode)
{
}
}
if (getBoolForKey("Legacy Logo", &legacy_logo, &bootInfo->bootConfig) && legacy_logo) {
usePngImage = false;
}
}
/**
branches/meklort/i386/modules/KernelPatcher/kernel_patcher.c
279279
280280
281281
282
282
283283
284284
285285
......
410410
411411
412412
413
413
414414
415415
416416
if(symbol == 0 || symbol->addr == 0)
{
printf("Unable to locate _cpuid_set_info\n");
verbose("Unable to locate _cpuid_set_info\n");
return;
}
if(symbol == 0 || symbol->addr == 0)
{
printf("Unable to locate _cpuid_set_info\n");
verbose("Unable to locate _cpuid_set_info\n");
return;
}

Archive Download the corresponding diff file

Revision: 583