PinCRT
|
Classes | |
struct | OS_MEMORY_AT_ADDR_INFORMATION |
Enumerations | |
enum | OS_PAGE_PROTECTION_TYPE { OS_PAGE_PROTECTION_TYPE_NOACCESS = 0, OS_PAGE_PROTECTION_TYPE_READ = (1<<0), OS_PAGE_PROTECTION_TYPE_WRITE = (1<<1), OS_PAGE_PROTECTION_TYPE_EXECUTE = (1<<2), OS_PAGE_PROTECTION_TYPE_GUARD = (1<<3) } |
enum | OS_MEMORY_FLAGS { OS_MEMORY_FLAGS_PRIVATE = 0, OS_MEMORY_FLAGS_FIXED_ADDRESS = (1<<0), OS_MEMORY_FLAGS_STACK = (1<<1), OS_MEMORY_FLAGS_SHARED = (1<<3) } |
Functions | |
OS_RETURN_CODE | OS_AllocateMemory (NATIVE_PID processId, UINT protectionType, USIZE size, OS_MEMORY_FLAGS flags, VOID **base) |
OS_RETURN_CODE | OS_MapFileToMemory (NATIVE_PID processId, UINT protectionType, USIZE size, OS_MEMORY_FLAGS flags, NATIVE_FD fd, UINT64 offset, VOID **base) |
OS_RETURN_CODE | OS_FreeMemory (NATIVE_PID processId, VOID *base, USIZE size) |
OS_RETURN_CODE | OS_GetPageSize (USIZE *size) |
OS_RETURN_CODE | OS_QueryMemory (NATIVE_PID processId, VOID *memoryAddr, OS_MEMORY_AT_ADDR_INFORMATION *info) |
OS_RETURN_CODE | OS_ProtectMemory (NATIVE_PID processId, VOID *base, USIZE size, UINT newProtectionType) |
enum OS_MEMORY_FLAGS |
Flags for memory mapping.
Page protection types
OS_RETURN_CODE OS_AllocateMemory | ( | NATIVE_PID | processId, |
UINT | protectionType, | ||
USIZE | size, | ||
OS_MEMORY_FLAGS | flags, | ||
VOID ** | base | ||
) |
Allocates size bytes of memory in the process identified by processId with protectionType protection.
[in] | processId | PID of the target process |
[in] | protectionType | or'ed protection options |
[in] | size | Size of memory to allocate |
[in] | flags | Properties of the region to allocate. This is a bitwise OR of the enum values in OS_MEMORY_FLAGS. |
[in,out] | base | in: Target memory address out: Where the memory was allocated |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_MEMORY_MAP_FAILED | If the operation Failed |
OS_RETURN_CODE OS_FreeMemory | ( | NATIVE_PID | processId, |
VOID * | base, | ||
USIZE | size | ||
) |
Free's size bytes of memory at base address in the process identified by processId.
[in] | processId | PID of the target process |
[in] | base | Target memory address |
[in] | size | Size in bytes of memory to free |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_MEMORY_FREE_FAILED | If the operation failed |
OS_RETURN_CODE OS_GetPageSize | ( | USIZE * | size | ) |
Query the system page size.
[out] | size | System page size |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_QUERY_FAILED | If the operation failed |
OS_RETURN_CODE OS_MapFileToMemory | ( | NATIVE_PID | processId, |
UINT | protectionType, | ||
USIZE | size, | ||
OS_MEMORY_FLAGS | flags, | ||
NATIVE_FD | fd, | ||
UINT64 | offset, | ||
VOID ** | base | ||
) |
Maps a file into memory, similar to mmap (see man page of mmap(2)).
[in] | processId | PID of the target process |
[in] | protectionType | or'ed protection options |
[in] | size | Size in bytes of memory to allocate |
[in] | flags | Properties of the region to allocate. This is a bitwise OR of the enum values in OS_MEMORY_FLAGS. |
[in] | fd | File descriptor of the file that we want to map to memory. This argument can be INVALID_NATIVE_FD if one wants to map an anonymous file. |
[in] | offset | Bytes offset in the file to start mapping from. |
[in,out] | base | in: Target memory address out: Where the memory was allocated |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_MEMORY_MAP_FAILED | If the operation Failed |
OS_RETURN_CODE OS_ProtectMemory | ( | NATIVE_PID | processId, |
VOID * | base, | ||
USIZE | size, | ||
UINT | newProtectionType | ||
) |
Changes protection for the target process's memory page(s) containing any part of the address range in the interval [base, base+size-1]. base must be aligned to a page boundary.
[in] | processId | PID of the target process |
[in] | base | The address of the starting page - must be page aligned. |
[in] | size | Size in bytes of the region to change protection - must be multiple of page size. |
[in] | newProtectionType | The new protection mode |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_MEMORY_PROTECT_FAILED | If the operation failed |
Unix:
The processId is irrelevant as it is only applicable on the current process.
On Unix system, memory protection can only be changed for the current process' memory space.
The given pid is expected to be that of the current process. Hence the behavior of this function in case 'processId' is not of the current process is not defined. Windows:
Windows supports memory protection change on a different process memory space.
OS_RETURN_CODE OS_QueryMemory | ( | NATIVE_PID | processId, |
VOID * | memoryAddr, | ||
OS_MEMORY_AT_ADDR_INFORMATION * | info | ||
) |
Retrieves the information on the memory block containing memoryAddr.
[in] | processId | PID of the target process |
[in] | memoryAddr | Target memory address. This memory address can reside inside the page. |
[out] | info | The address information On Unix, if there is no mapped memory block that contains memoryAddr the next mapped memory block will be returned. If no such mapped memory block exists, an empty memory block will be returned On Windows, we return the containing memory block regardless if it is mapped or not. |
OS_RETURN_CODE_NO_ERROR | If the operation succeeded |
OS_RETURN_CODE_QUERY_FAILED | If the operation failed |