Chameleon

Chameleon Commit Details

Date:2010-11-26 17:59:54 (13 years 4 months ago)
Author:Evan Lojewski
Commit:649
Parents: 648
Message:Module changes
Changes:
M/branches/meklort/i386/boot2/boot.c
M/branches/meklort/i386/boot2/modules.c
M/branches/meklort/i386/boot2/Makefile
M/branches/meklort/i386/boot2/modules.h

File differences

branches/meklort/i386/boot2/boot.c
287287
288288
289289
290
290
291291
292292
293293
......
628628
629629
630630
631
631
632632
633633
634634
635
635
636636
637637
638638
// Load boot.plist config file
status = loadSystemConfig(&bootInfo->bootConfig);
if (getBoolForKey(kQuietBootKey, &quiet, &bootInfo->bootConfig) && quiet) {
gBootMode |= kBootModeQuiet;
}
const char *val;
int len;
if (!loadConfigFile("System/Library/CoreServices/SystemVersion.plist", &systemVersion))
if (!loadConfigFile("/System/Library/CoreServices/SystemVersion.plist", &systemVersion))
{
valid = true;
}
else if (!loadConfigFile("System/Library/CoreServices/ServerVersion.plist", &systemVersion))
else if (!loadConfigFile("/System/Library/CoreServices/ServerVersion.plist", &systemVersion))
{
valid = true;
}
branches/meklort/i386/boot2/modules.c
6161
6262
6363
64
64
65
66
67
68
69
70
71
72
73
6574
6675
6776
......
383392
384393
385394
395
386396
387397
388398
......
416426
417427
418428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
419454
420455
421456
......
447482
448483
449484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
450509
510
451511
452512
453513
......
12141274
12151275
12161276
1277
12171278
12181279
12191280
// Intialize module system
if(symbols_module_start == (void*)0xFFFFFFFF)
{
printf("Module system not compiled in\n");
DBG("Module system not compiled in\n");
load_module(SYMBOLS_MODULE);
lookup_symbol = (void*)lookup_all_symbols(SYMBOL_LOOKUP_SYMBOL);
if((UInt32)lookup_symbol != 0xFFFFFFFF)
{
return 1;
}
return 0;
}
switch ((loadCommand->cmd & 0x7FFFFFFF))
{
// TODO: sepeare function to handel appropriate sections
case LC_SYMTAB:
symtabCommand = binary + binaryIndex;
break;
}
}
}
else if(strcmp("__DATA", segCommand->segname) == 0)
{
UInt32 sectionIndex;
sectionIndex = sizeof(struct segment_command);
struct section *sect;
while(sectionIndex < segCommand->cmdsize)
{
sect = binary + binaryIndex + sectionIndex;
sectionIndex += sizeof(struct section);
if(strcmp("__bss", sect->sectname) == 0)
{
// __TEXT,__text found, save the offset and address for when looking for the calls.
//printf("__DATA,__bss found.\n"); getc();
break;
}
}
}
break;
case LC_SEGMENT_64:// 64bit macho's
segCommand64 = binary + binaryIndex;
}
}
}
else if(strcmp("__DATA", segCommand->segname) == 0)
{
UInt32 sectionIndex;
sectionIndex = sizeof(struct segment_command_64);
struct section_64 *sect;
while(sectionIndex < segCommand->cmdsize)
{
sect = binary + binaryIndex + sectionIndex;
sectionIndex += sizeof(struct section);
if(strcmp("__bss", sect->sectname) == 0)
{
// __TEXT,__text found, save the offset and address for when looking for the calls.
//printf("__DATA,__bss found.\n"); getc();
break;
}
}
}
break;
case LC_DYSYMTAB:
char* binary = (char*)addr;
if(addr != 0xFFFFFFFF)
{
DBG("Replacing %s to point to 0x%x\n", symbol, newAddress);
*binary++ = 0xFF;// Jump
*binary++ = 0x25;// Long Jump
*((UInt32*)binary) = (UInt32)jumpPointer;
branches/meklort/i386/boot2/modules.h
1616
1717
1818
19
20
21
22
23
24
25
26
27
28
29
30
1931
2032
2133
......
4860
4961
5062
51
5263
53
54
55
5664
57
58
59
60
61
6265
6366
6467
#ifndef __BOOT_MODULES_H
#define __BOOT_MODULES_H
#define SYMBOLS_MODULE "Symbols.dylib"
#define SYMBOL_DYLD_STUB_BINDER"dyld_stub_binder"
#define SYMBOL_LOOKUP_SYMBOL"_lookup_symbol"
#define STUB_ENTRY_SIZE6
#define SECT_NON_LAZY_SYMBOL_PTR"__nl_symbol_ptr"
#define SECT_SYMBOL_STUBS"__symbol_stub"
#define VALID_FUNCTION(__x__)(__x__ && (void*)__x__ != (void*)0xFFFFFFFF)
extern unsigned long long textAddress;
extern unsigned long long textSection;
struct moduleHook_t* next;
} moduleHook_t;
#define SYMBOLS_MODULE "Symbols.dylib"
#define SYMBOL_DYLD_STUB_BINDER"dyld_stub_binder"
#define SYMBOL_LOOKUP_SYMBOL"_lookup_symbol"
#define STUB_ENTRY_SIZE6
#define SECT_NON_LAZY_SYMBOL_PTR"__nl_symbol_ptr"
#define SECT_SYMBOL_STUBS"__symbol_stub"
int init_module_system();
void load_all_modules();
branches/meklort/i386/boot2/Makefile
8383
8484
8585
86
86
8787
8888
8989
......
102102
103103
104104
105
105
106106
107107
108108
@make embed_symbols# this is done in a sub process after boot.sys exists so the strings are populated correctly
${RM} $(SYMROOT)/${SYMBOLS_MODULE}
##${RM} $(SYMROOT)/${SYMBOLS_MODULE}
size $(SYMROOT)/boot.sys
ls -l $(SYMROOT)/boot
echo ******* Patching at $(PATCH_ADDR) ******
stat -f%z $(SYMROOT)/boot | perl -ane "print pack('V',@F[0]);" | dd conv=notrunc of=${SYMROOT}/boot_embeded.sys bs=1 count=4 seek=$(PATCH_ADDR)
machOconv $(SYMROOT)/boot_embeded.sys $(SYMROOT)/boot
machOconv $(SYMROOT)/boot_embeded.sys $(SYMROOT)/boot_embeded
prompt.o: vers.h

Archive Download the corresponding diff file

Revision: 649