Chameleon Applications

Chameleon Applications Svn Source Tree

Root/branches/iFabio/Chameleon/i386/boot2/modules.h

Source at commit 307 created 12 years 10 months ago.
By ifabio, merge changes from trunk (929). Also merge the module changes from Azimutz branche (fix compile error) Also edited the info.plist into AHCIPortInjector.kext: http://forum.voodooprojects.org/index.php/topic,1170.0.html
1/*
2 * Module Loading functionality
3 * Copyright 2009 Evan Lojewski. All rights reserved.
4 *
5 */
6
7#include <saio_types.h>
8#include <mach-o/loader.h>
9#include <mach-o/nlist.h>
10
11
12#ifndef __BOOT_MODULES_H
13#define __BOOT_MODULES_H
14
15#define MODULE_PATH"/Extra/modules/"
16#define SYMBOLS_MODULE "Symbols.dylib"
17#define VOID_SYMBOL"dyld_void_start"
18extern UInt64 textAddress;
19extern UInt64 textSection;
20
21
22
23typedef struct symbolList_t
24{
25char* symbol;
26UInt64 addr;
27struct symbolList_t* next;
28} symbolList_t;
29
30
31typedef struct callbackList_t
32{
33void(*callback)(void*, void*, void*, void*);
34struct callbackList_t* next;
35} callbackList_t;
36
37typedef struct moduleHook_t
38{
39const char* name;
40callbackList_t* callbacks;
41struct moduleHook_t* next;
42} moduleHook_t;
43
44typedef struct moduleList_t //Azi: modules or module? see modules/include/modules
45{
46char*name;
47//UInt32version;
48//UInt32compat;
49struct moduleList_t*next;
50} moduleList_t;
51
52
53
54int init_module_system();
55void load_all_modules();
56
57void start_built_in_module(char* name, void(*start_function)(void));
58
59
60int load_module(char* module);
61int is_module_loaded(const char* name);
62void module_loaded(const char* name/*, UInt32 version, UInt32 compat*/);
63
64
65
66
67/********************************************************************************/
68/*Symbol Functions*/
69/********************************************************************************/
70long longadd_symbol(char* symbol, long long addr, char is64);
71unsigned intlookup_all_symbols(const char* name);
72
73
74
75/********************************************************************************/
76/*Macho Parser*/
77/********************************************************************************/
78void*parse_mach(void* binary,
79int(*dylib_loader)(char*),
80long long(*symbol_handler)(char*, long long, char),
81 void (*section_handler)(char* section, char* segment, long long offset, long long address)
82 );
83unsigned inthandle_symtable(UInt32 base,
84 struct symtab_command* symtabCommand,
85 long long(*symbol_handler)(char*, long long, char),
86 char is64);
87voidrebase_macho(void* base, char* rebase_stream, UInt32 size);
88inline voidrebase_location(UInt32* location, char* base, int type);
89voidbind_macho(void* base, UInt8* bind_stream, UInt32 size);
90inline voidbind_location(UInt32* location, char* value, UInt32 addend, int type);
91
92
93
94
95/********************************************************************************/
96/*Module Interface*/
97/********************************************************************************/
98intreplace_function(const char* symbol, void* newAddress);
99intexecute_hook(const char* name, void*, void*, void*, void*);
100voidregister_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*));
101moduleHook_t*hook_exists(const char* name);
102
103#if DEBUG_MODULES
104voidprint_hook_list();
105#endif
106
107/********************************************************************************/
108/*dyld Interface*/
109/********************************************************************************/
110void dyld_stub_binder();
111
112#endif /* __BOOT_MODULES_H */
113

Archive Download this file

Revision: 307