-
Notifications
You must be signed in to change notification settings - Fork 2
/
ElfMemoryFile64.h
69 lines (49 loc) · 1.58 KB
/
ElfMemoryFile64.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* ElfMemoryFile64.h
*
* Created on: Dec 8, 2013
* Author: tyler
*/
#ifndef ELFMEMORYFILE64_H_
#define ELFMEMORYFILE64_H_
#include <memory>
#include <vector>
#include <cstdint>
#include <unordered_map>
#include <elf.h>
#include "MemoryRegion.h"
#include "ElfMemorySection64.h"
class Process;
namespace Elf
{
struct ElfExport64
{
uintptr_t offset;
int sectionIndex;
};
class ElfMemoryFile64
{
public:
ElfMemoryFile64(const std::vector<MemoryRegion>& memoryRegions, const Process& process);
~ElfMemoryFile64();
ElfMemoryFile64(const ElfMemoryFile64&) = delete;
ElfMemoryFile64(ElfMemoryFile64&&) = delete;
ElfMemoryFile64& operator =(const ElfMemoryFile64&) = delete;
ElfMemoryFile64& operator =(ElfMemoryFile64&&) = delete;
uintptr_t getMemoryPointerFromFileOffset(uintptr_t offset) const;
uint8_t* getMemoryDataPointerFromOffset(uintptr_t offset) const;
const std::vector<ElfMemorySection64>& getSections() const {return m_sections;}
const ElfMemorySection64* getSectionByName(const std::string& name) const;
const ElfMemorySection64* getSectionByIndex(int index) const {return &m_sections[index];}
ElfExport64 getExport(const std::string& name) const {return m_exports.at(name);}
const std::unordered_map<std::string, ElfExport64> getExports() const {return m_exports;}
protected:
Elf64_Ehdr m_header;
std::vector<MemoryRegion> m_memoryRegions;
std::vector<std::unique_ptr<uint8_t []>> m_memoryData;
std::vector<ElfMemorySection64> m_sections;
std::unordered_map<std::string, ElfExport64> m_exports;
const Process* m_process;
};
}
#endif /* ELFMEMORYFILE64_H_ */