Chameleon

Chameleon Svn Source Tree

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

Source at commit 2381 created 10 years 21 days ago.
By ifabio, Apply patch: (Credits to Thomas Jansen aka tja) - Reading options from all devices during boot. The options for the boot menu are only read from the devices rd(0,0) or bt(0,0). Consequently, boot menu options (e.g. "Quiet Boot", "Timeout", etc.) in plists on other devices (like most users have) are ignored. This patch extends the list of paths to search for the options plist on all devices that can be found.
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
34
35typedef struct callbackList_t
36{
37void(*callback)(void*, void*, void*, void*);
38struct callbackList_t* next;
39} callbackList_t;
40
41typedef struct moduleHook_t
42{
43const char* name;
44callbackList_t* callbacks;
45struct moduleHook_t* next;
46} moduleHook_t;
47
48typedef struct modulesList_t
49{
50const char*name;
51 const char* author;
52 const char* description;
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 UInt32 version,
67 UInt32 compat,
68 void(*start_function)(void));
69
70int load_module(char* module);
71int is_module_loaded(const char* name);
72void module_loaded(const char* name, 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);
98inline voidrebase_location(UInt32* location, char* base, int type);
99voidbind_macho(void* base, UInt8* bind_stream, UInt32 size);
100inline voidbind_location(UInt32* location, char* value, UInt32 addend, int type);
101
102
103
104
105/********************************************************************************/
106/*Module Interface*/
107/********************************************************************************/
108intreplace_function(const char* symbol, void* newAddress);
109intexecute_hook(const char* name, void*, void*, void*, void*);
110voidregister_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*));
111moduleHook_t*hook_exists(const char* name);
112
113#if DEBUG_MODULES
114voidprint_hook_list();
115#endif
116
117/********************************************************************************/
118/*dyld Interface*/
119/********************************************************************************/
120void dyld_stub_binder();
121
122#endif /* __BOOT_MODULES_H */

Archive Download this file

Revision: 2381