Chameleon

Chameleon Svn Source Tree

Root/tags/2.0/i386/boot2/modules.h

Source at commit 1808 created 12 years 3 months ago.
By blackosx, Revise layout of package installer 'Welcome' file so it looks cleaner. Change the copyright notice to begin from 2009 as seen in the Chameleon 2.0 r431 installer. Should this date be set earlier?
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"
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
50typedef struct modulesList_t
51{
52const char*name;
53 const char* author;
54 const char* description;
55UInt32version;
56UInt32compat;
57struct modulesList_t* next;
58} moduleList_t;
59
60
61
62int init_module_system();
63void load_all_modules();
64
65void start_built_in_module(const char* name,
66 const char* author,
67 const char* description,
68 UInt32 version,
69 UInt32 compat,
70 void(*start_function)(void));
71
72int load_module(char* module);
73int is_module_loaded(const char* name);
74void module_loaded(const char* name, const char* author, const char* description, UInt32 version, UInt32 compat);
75
76
77
78
79/********************************************************************************/
80/*Symbol Functions*/
81/********************************************************************************/
82long longadd_symbol(char* symbol, long long addr, char is64);
83unsigned intlookup_all_symbols(const char* name);
84
85
86
87/********************************************************************************/
88/*Macho Parser*/
89/********************************************************************************/
90void*parse_mach(void* binary,
91int(*dylib_loader)(char*),
92long long(*symbol_handler)(char*, long long, char),
93 void (*section_handler)(char* section, char* segment, long long offset, long long address)
94 );
95unsigned inthandle_symtable(UInt32 base,
96 struct symtab_command* symtabCommand,
97 long long(*symbol_handler)(char*, long long, char),
98 char is64);
99voidrebase_macho(void* base, char* rebase_stream, UInt32 size);
100inline voidrebase_location(UInt32* location, char* base, int type);
101voidbind_macho(void* base, UInt8* bind_stream, UInt32 size);
102inline voidbind_location(UInt32* location, char* value, UInt32 addend, int type);
103
104
105
106
107/********************************************************************************/
108/*Module Interface*/
109/********************************************************************************/
110intreplace_function(const char* symbol, void* newAddress);
111intexecute_hook(const char* name, void*, void*, void*, void*);
112voidregister_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*));
113moduleHook_t*hook_exists(const char* name);
114
115#if DEBUG_MODULES
116voidprint_hook_list();
117#endif
118
119/********************************************************************************/
120/*dyld Interface*/
121/********************************************************************************/
122void dyld_stub_binder();
123
124#endif /* __BOOT_MODULES_H */

Archive Download this file

Revision: 1808