12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- /*
- * memory.h
- *
- * Copyright (C) 2017 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #ifndef __MONOLITIHUM_MEMORY_H__
- #define __MONOLITIHUM_MEMORY_H__
- #include "defs.h"
- #include "object.h"
- /* Set by the client */
- #define MEMORY_FLAG_ACCESSIBLE (1 << 0)
- #define MEMORY_FLAG_WRITABLE (1 << 1)
- #define MEMORY_FLAG_EXECUTABLE (1 << 2)
- #define MEMORY_FLAG_USERMODE (1 << 3)
- #define MEMORY_FLAG_STICKY (1 << 4)
- #define MEMORY_FLAG_EVICTABLE (1 << 5)
- /* Set by the system */
- #define MEMORY_FLAG_EVICTED (1 << 29)
- #define MEMORY_FLAG_COPY_ON_WRITE (1 << 30)
- #define MEMORY_FLAG_FREE (1 << 31)
- #define MEMORY_SECTION_WRITABLE (1 << 0)
- #define MEMORY_SECTION_DIRECT_WRITE (1 << 1)
- typedef dword_t memory_flags_t;
- typedef struct
- {
- uintptr_t used_virtual;
- uintptr_t committed;
- uintptr_t evicted;
- uintptr_t shared;
- } memory_stats_t;
- typedef struct
- {
- qword_t address;
- qword_t size;
- dword_t flags;
- } memory_block_info_t;
- sysret_t syscall_alloc_memory(handle_t process, void **address, size_t size, dword_t block_flags);
- sysret_t syscall_free_memory(handle_t process, void *address);
- sysret_t syscall_commit_memory(handle_t process, void *address, dword_t size);
- sysret_t syscall_uncommit_memory(handle_t process, void *address, dword_t size);
- sysret_t syscall_protect_memory(handle_t process, void *address, size_t size, memory_flags_t flags);
- sysret_t syscall_query_memory(handle_t process, void *address, memory_block_info_t *info);
- sysret_t syscall_read_memory(handle_t process, void *address, void *buffer, dword_t size);
- sysret_t syscall_write_memory(handle_t process, void *address, void *buffer, dword_t size);
- sysret_t syscall_create_memory_section(const char *name, handle_t file, size_t size, dword_t flags, handle_t *handle);
- sysret_t syscall_open_memory_section(const char *name, handle_t *handle);
- sysret_t syscall_map_memory_section(handle_t process, handle_t section, void **address, qword_t offset, size_t size, dword_t flags);
- sysret_t syscall_flush_memory_section(handle_t process, void *address);
- #endif
|