Chameleon

Chameleon Svn Source Tree

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

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

Archive Download this file

Revision: 867