Chameleon

Chameleon Svn Source Tree

Root/branches/azimutz/Chazi/i386/boot2/modules.h

1/*
2 * Module Loading functionality
3 * Copyright 2009 Evan Lojewski. All rights reserved.
4 *
5 */
6
7#ifndef __BOOT_MODULES_H
8#define __BOOT_MODULES_H
9
10#include <saio_types.h>
11#include <mach-o/loader.h>
12#include <mach-o/nlist.h>
13
14
15#define MODULE_PATH"/Extra/modules/"
16
17#define SYMBOLS_MODULE "Symbols.dylib"
18#define SYMBOLS_AUTHOR "Chameleon"
19#define SYMBOLS_DESCRIPTION "Chameleon symbols for linking"
20#define SYMBOLS_VERSION 0
21#define SYMBOLS_COMPAT 0
22
23#define VOID_SYMBOL"dyld_void_start"
24extern UInt64 textAddress;
25extern UInt64 textSection;
26
27
28
29typedef struct symbolList_t
30{
31char* symbol;
32UInt64 addr;
33struct symbolList_t* next;
34} symbolList_t;
35
36
37typedef struct callbackList_t
38{
39void(*callback)(void*, void*, void*, void*);
40struct callbackList_t* next;
41} callbackList_t;
42
43typedef struct moduleHook_t
44{
45const char* name;
46callbackList_t* callbacks;
47struct moduleHook_t* next;
48} moduleHook_t;
49
50/*typedef struct moduleList_t //Azi: modules or module? see modules/include/modules
51{
52char*name;
53//UInt32version;
54//UInt32compat;
55struct moduleList_t*next;
56} moduleList_t; */
57
58typedef struct modulesList_t
59{
60const char*name;
61 const char* author;
62 const char* description;
63UInt32version;
64UInt32compat;
65struct modulesList_t* next;
66} moduleList_t;
67
68
69
70int init_module_system();
71void load_all_modules();
72
73void start_built_in_module(const char* name,
74 const char* author,
75 const char* description,
76 UInt32 version,
77 UInt32 compat,
78 void(*start_function)(void));
79
80int load_module(char* module);
81int is_module_loaded(const char* name);
82void module_loaded(const char* name, const char* author, const char* description, UInt32 version, UInt32 compat);
83
84
85
86
87/********************************************************************************/
88/*Symbol Functions*/
89/********************************************************************************/
90long longadd_symbol(char* symbol, long long addr, char is64);
91unsigned intlookup_all_symbols(const char* name);
92
93
94
95/********************************************************************************/
96/*Macho Parser*/
97/********************************************************************************/
98void*parse_mach(void* binary,
99int(*dylib_loader)(char*),
100long long(*symbol_handler)(char*, long long, char),
101 void (*section_handler)(char* section, char* segment, long long offset, long long address)
102 );
103unsigned inthandle_symtable(UInt32 base,
104 struct symtab_command* symtabCommand,
105 long long(*symbol_handler)(char*, long long, char),
106 char is64);
107voidrebase_macho(void* base, char* rebase_stream, UInt32 size);
108inline voidrebase_location(UInt32* location, char* base, int type);
109voidbind_macho(void* base, UInt8* bind_stream, UInt32 size);
110inline voidbind_location(UInt32* location, char* value, UInt32 addend, int type);
111
112
113
114
115/********************************************************************************/
116/*Module Interface*/
117/********************************************************************************/
118intreplace_function(const char* symbol, void* newAddress);
119intexecute_hook(const char* name, void*, void*, void*, void*);
120voidregister_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*));
121moduleHook_t*hook_exists(const char* name);
122
123#if DEBUG_MODULES
124voidprint_hook_list();
125#endif
126
127/********************************************************************************/
128/*dyld Interface*/
129/********************************************************************************/
130void dyld_stub_binder();
131
132#endif /* __BOOT_MODULES_H */

Archive Download this file

Revision: 1047