Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Enoch/i386/boot2/modules.h

1/*
2 * Module Loading functionality
3 * Copyright 2009-2015 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_VERSION0
21#define SYMBOLS_COMPAT0
22
23#define VOID_SYMBOL"dyld_void_start"
24
25
26
27typedef struct symbolList_t
28{
29char*symbol;
30UInt64addr;
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;
52//const void*base;
53UInt32version;
54UInt32compat;
55struct modulesList_t*next;
56} moduleList_t;
57
58
59
60int init_module_system();
61void load_all_modules();
62
63void start_built_in_module(const char*name,
64 const char*author,
65 const char*description,
66 UInt32version,
67 UInt32compat,
68 void(*start_function)(void));
69
70int load_module(char* module);
71int is_module_loaded(const char* name);
72void module_loaded(const char* name, void* start, const char* author, const char* description, UInt32 version, UInt32 compat);
73
74
75
76
77/********************************************************************************/
78/*Symbol Functions*/
79/********************************************************************************/
80long longadd_symbol(char* symbol, long long addr, char is64);
81unsigned intlookup_all_symbols(const char* name);
82
83
84
85/********************************************************************************/
86/*Macho Parser*/
87/********************************************************************************/
88void*parse_mach(void* binary,
89int(*dylib_loader)(char*),
90long long(*symbol_handler)(char*, long long, char),
91 void (*section_handler)(char* section, char* segment, void* cmd, UInt64 offset, UInt64 address)
92 );
93unsigned inthandle_symtable(UInt32 base,
94 struct symtab_command* symtabCommand,
95 long long(*symbol_handler)(char*, long long, char),
96 char is64);
97voidrebase_macho(void* base, char* rebase_stream, UInt32 size);
98
99voidbind_macho(void* base, UInt8* bind_stream, UInt32 size);
100
101
102/********************************************************************************/
103/*Module Interface*/
104/********************************************************************************/
105intreplace_function(const char* symbol, void* newAddress);
106intexecute_hook(const char* name, void*, void*, void*, void*);
107voidregister_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*));
108moduleHook_t*hook_exists(const char* name);
109
110#if DEBUG_MODULES
111voidprint_hook_list();
112#endif
113
114/********************************************************************************/
115/*dyld Interface*/
116/********************************************************************************/
117void dyld_stub_binder();
118
119#endif /* __BOOT_MODULES_H */
120

Archive Download this file

Revision: 2570