Chameleon

Chameleon Svn Source Tree

Root/trunk/i386/boot2/modules.h

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
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"
24
25
26
27typedef struct symbolList_t
28{
29char* symbol;
30UInt64 addr;
31struct symbolList_t* next;
32} symbolList_t;
33
34typedef struct callbackList_t
35{
36void(*callback)(void*, void*, void*, void*);
37struct callbackList_t* next;
38} callbackList_t;
39
40typedef struct moduleHook_t
41{
42const char* name;
43callbackList_t* callbacks;
44struct moduleHook_t* next;
45} moduleHook_t;
46
47typedef struct modulesList_t
48{
49const char*name;
50const char* author;
51const char* description;
52UInt32version;
53UInt32compat;
54struct modulesList_t* next;
55} moduleList_t;
56
57
58
59int init_module_system();
60void load_all_modules();
61
62void start_built_in_module(const char* name,
63 const char* author,
64 const char* description,
65 UInt32 version,
66 UInt32 compat,
67 void(*start_function)(void));
68
69int load_module(char* module);
70int is_module_loaded(const char* name);
71void module_loaded(const char* name, const char* author, const char* description, UInt32 version, UInt32 compat);
72
73
74
75
76/********************************************************************************/
77/*Symbol Functions*/
78/********************************************************************************/
79long longadd_symbol(char* symbol, long long addr, char is64);
80unsigned intlookup_all_symbols(const char* name);
81
82
83
84/********************************************************************************/
85/*Macho Parser*/
86/********************************************************************************/
87void*parse_mach(void* binary,
88int(*dylib_loader)(char*),
89long long(*symbol_handler)(char*, long long, char),
90 void (*section_handler)(char* section, char* segment, void* cmd, UInt64 offset, UInt64 address)
91 );
92unsigned inthandle_symtable(UInt32 base,
93 struct symtab_command* symtabCommand,
94 long long(*symbol_handler)(char*, long long, char),
95 char is64);
96voidrebase_macho(void* base, char* rebase_stream, UInt32 size);
97
98voidbind_macho(void* base, UInt8* bind_stream, UInt32 size);
99
100
101/********************************************************************************/
102/*Module Interface*/
103/********************************************************************************/
104intreplace_function(const char* symbol, void* newAddress);
105intexecute_hook(const char* name, void*, void*, void*, void*);
106voidregister_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*));
107moduleHook_t*hook_exists(const char* name);
108
109#if DEBUG_MODULES
110voidprint_hook_list();
111#endif
112
113/********************************************************************************/
114/*dyld Interface*/
115/********************************************************************************/
116void dyld_stub_binder();
117
118#endif /* __BOOT_MODULES_H */
119

Archive Download this file

Revision: 2476