Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/include/pexpert/i386/modules.h

1/*
2 * Module Loading functionality
3 * Copyright 2009 Evan Lojewski. All rights reserved.
4 *
5 */
6
7/*
8 * Copyright 2012 Cadet-petit Armel <armelcadetpetit@gmail.com>. All rights reserved.
9 *
10 * Cleaned, Added bundles support.
11 *
12 */
13
14// There is a bug with the module system / rebasing / binding
15// that causes static variables to be incorrectly rebased or bound
16// Disable static variables for the moment
17// #define static
18
19#ifndef _PEXPERT_MODULES_H
20#define _PEXPERT_MODULES_H
21
22#include <efi.h>
23
24#define DEFAULT_BUNDLE_SPEC_SIZE 4096
25#define macho_64 0
26
27extern unsigned long long textAddress;
28extern unsigned long long textSection;
29
30typedef struct symbolList_t
31{
32 char* module;
33char* symbol;
34unsigned int addr;
35struct symbolList_t* next;
36} symbolList_t;
37
38typedef struct callbackList_t
39{
40void(*callback)(void*, void*, void*, void*, void*, void*);
41struct callbackList_t* next;
42} callbackList_t;
43
44typedef struct moduleHook_t
45{
46const char* name;
47callbackList_t* callbacks;
48struct moduleHook_t* next;
49} moduleHook_t;
50
51#define SYMBOLS_BUNDLE "Symbols"
52
53#define SYMBOL_DYLD_STUB_BINDER"dyld_stub_binder"
54#define SYMBOL_LOOKUP_SYMBOL"_lookup_symbol"
55#define STUB_ENTRY_SIZE6
56
57#define SECT_NON_LAZY_SYMBOL_PTR"__nl_symbol_ptr"
58#define SECT_SYMBOL_STUBS"__symbol_stub"
59
60#define SYS_CLASS "SYMS"
61#define SYSLIB_CLASS "SYS_LIB"
62
63/*
64 * Modules Interface
65 * execute_hook
66 *Exexutes a registered hook. All callbaks are
67 *called in the same order that they were added
68 *
69 * register_hook_callback
70 *registers a void function to be executed when a
71 *hook is executed.
72 */
73EFI_STATUS execute_hook(const char* name, void*, void*, void*, void*, void*, void*);
74VOID register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*, void*, void*));
75VOID register_one_callback(const char* name, void(*callback)(void*, void*, void*, void*, void*, void*));
76
77void rebase_location(unsigned long* location, char* base, int type);
78void bind_location(unsigned long* location, char* value, unsigned long addend, int type);
79void rebase_macho(void* base, char* rebase_stream, unsigned long size);
80EFI_STATUS bind_macho(char* module, void* base, char* bind_stream, unsigned long size);
81
82#if macho_64
83long long add_symbol(char* module,char* symbol, long long addr, char is64);
84#else
85long long add_symbol(char* module,char* symbol, long long addr);
86#endif
87
88unsigned int lookup_all_symbols(const char* module, const char* name);
89
90EFI_STATUS replace_function(const char* module, const char* symbol, void* newAddress);
91EFI_STATUS replace_system_function(const char* symbol, void* newAddress);
92EFI_STATUS replace_function_any(const char* symbol, void* newAddress);
93
94extern unsigned int (*lookup_symbol)(const char*, int(*strcmp_callback)(const char*, const char*));
95
96
97long InitBundleSupport(void);
98long FileLoadBundles(char *dirSpec, long plugin);
99long LoadBundlePList(char *dirSpec, char *name, long bundleType);
100long LoadMatchedBundles(void);
101long MatchBundlesLibraries(void);
102long LoadBundles( char * dirSpec );
103void * GetBundleDict( char * bundle_id );
104void * GetBundlePersonality( char * bundle_id );
105char * GetBundlePath( char * bundle_id );
106
107#endif /* _PEXPERT_MODULES_H */

Archive Download this file

Revision: 2182