-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmodule.h
50 lines (44 loc) · 1.07 KB
/
module.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// libembryo
//
// Copyright Stanley Cen 2013
// Released under the MIT License
//
#ifndef libembryo_module_h
#define libembryo_module_h
#include <string>
#include <sys/types.h>
#include <mach/error.h>
#include <mach/vm_types.h>
#include <mach-o/dyld.h>
#include <mach-o/getsect.h>
#include <mach/mach.h>
#include <sys/stat.h>
#include <dlfcn.h>
namespace embryo
{
class module
{
public:
module(const std::string &name);
void *start() const { return m_start; }
unsigned int size() const { return m_size; }
std::string name() const { return m_name; }
std::string path() const { return m_path; }
mach_header *machHeader() const { return m_header; }
void *handle() const { return m_handle; }
template<typename Fn>
Fn getSymbol(const char *name) const
{
return (Fn)dlsym(handle(), name);
}
private:
void *m_start;
unsigned int m_size;
std::string m_name;
std::string m_path;
mach_header *m_header;
void *m_handle;
};
}
#endif