Chameleon Applications

Chameleon Applications Svn Source Tree

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

Source at commit 303 created 12 years 10 months ago.
By ifabio, Latest Chameleon trunk changes.
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 modulesList_t
45{
46char*name;
47//UInt32version;
48//UInt32compat;
49struct modulesList_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));
81unsigned inthandle_symtable(UInt32 base,
82 struct symtab_command* symtabCommand,
83 long long(*symbol_handler)(char*, long long, char),
84 char is64);
85voidrebase_macho(void* base, char* rebase_stream, UInt32 size);
86inline voidrebase_location(UInt32* location, char* base, int type);
87voidbind_macho(void* base, UInt8* bind_stream, UInt32 size);
88inline voidbind_location(UInt32* location, char* value, UInt32 addend, int type);
89
90
91
92
93/********************************************************************************/
94/*Module Interface*/
95/********************************************************************************/
96intreplace_function(const char* symbol, void* newAddress);
97intexecute_hook(const char* name, void*, void*, void*, void*);
98voidregister_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*));
99moduleHook_t*hook_exists(const char* name);
100
101#if DEBUG_MODULES
102voidprint_hook_list();
103#endif
104
105/********************************************************************************/
106/*dyld Interface*/
107/********************************************************************************/
108void dyld_stub_binder();
109
110#endif /* __BOOT_MODULES_H */
111

Archive Download this file

Revision: 303