|
LIEF: Library to Instrument Executable Formats Version 1.0.0
|
This class exposes API to access and manage memory. More...
#include <Memory.hpp>
Classes | |
| class | Chunk |
| Represents a contiguous chunk of memory allocated or inspected by the runtime. More... | |
| class | ScopedPermissions |
| RAII interface to change the permission within a determined scope. More... | |
Public Types | |
| enum | MMAP_FLAGS : uint32_t { MP_NONE = 0 , MP_PRIVATE = 1 << 0 , MP_ANONYMOUS = 1 << 1 , MP_SHARED = 1 << 2 , MP_FIXED = 1 << 3 , MP_JIT = 1 << 4 } |
| Flags used when creating a memory map (mmap). More... | |
| enum | PERM : uint32_t { P_NONE = 0 , P_READ = 1 << 0 , P_WRITE = 1 << 1 , P_EXEC = 1 << 2 } |
Static Public Member Functions | |
| static optional< Chunk > | mmap (size_t size, uint32_t flags, uint32_t permissions=P_NONE) |
| Allocate a memory chunk through mmap-like function. | |
| static ok_error_t | munmap (Chunk &C) |
| Deallocate a mmaped memory chunk. | |
| static ok_error_t | mprotect (Chunk &C, uint32_t flags) |
| Sets the permission of the given memory chunk. | |
| static ok_error_t | write (const uint8_t *buffer, size_t size, uintptr_t addr) |
| Write the buffer at the address given in the third parameter. | |
| static ok_error_t | write (const std::vector< uint8_t > &buffer, uintptr_t addr) |
| Write the buffer at the address given in the third parameter. | |
| template<class T, typename = typename std::enable_if<std::is_standard_layout<T>::value && std::is_trivial<T>::value>::type> | |
| static ok_error_t | write (const T &value, uintptr_t addr) |
| Generic function to write a typed value. | |
| template<class T> | |
| static T | read (uintptr_t addr) |
| Generic function to read a typed value. | |
| static void | read (uintptr_t addr, std::vector< uint8_t > &out, size_t size) |
| Read the content at the address pointed by the first parameter and write the result in the std::vector provided in the second parameter. | |
| static void | read (uintptr_t addr, uint8_t *out, size_t size) |
| Read the content at the address pointed by the first parameter and write the result in the buffer provided in the second parameter. | |
| static std::string | perm_str (uint32_t flags) |
| static constexpr bool | support_rwx () |
This class exposes API to access and manage memory.
| enum LIEF::runtime::Memory::MMAP_FLAGS : uint32_t |
Flags used when creating a memory map (mmap).
| enum LIEF::runtime::Memory::PERM : uint32_t |
|
static |
Allocate a memory chunk through mmap-like function.
References P_NONE.
|
static |
Sets the permission of the given memory chunk.
Referenced by LIEF::runtime::Memory::Chunk::change_permissions().
|
static |
Deallocate a mmaped memory chunk.
Referenced by LIEF::runtime::Memory::Chunk::deallocate().
|
static |
|
inlinestatic |
Generic function to read a typed value.
Referenced by read().
|
inlinestatic |
Read the content at the address pointed by the first parameter and write the result in the std::vector provided in the second parameter.
References read().
|
inlinestatic |
Read the content at the address pointed by the first parameter and write the result in the buffer provided in the second parameter.
This function assumes that the buffer in the second parameter is large enough to contain the data being read.
|
inlinestaticconstexpr |
References LIEF::runtime::IOS.
|
inlinestatic |
Write the buffer at the address given in the third parameter.
This function assumes that the memory pointed by addr has the correct permission to write this buffer.
References write().
|
inlinestatic |
Generic function to write a typed value.
References write().
|
inlinestatic |
Write the buffer at the address given in the third parameter.
This function assumes that the memory pointed by addr has the correct permission to write this buffer.
References LIEF::ok().