mirror of
https://dev.lirent.ru/Vatrog/vm-introspection-engine.git
synced 2026-07-09 00:46:36 +03:00
Construct the memory source from a file descriptor
vmie_mem could only be built from a path. Add a second input: an
already-open file descriptor, dup()'d internally (borrowed - the
caller's fd stays valid, core owns and closes its copy).
- vmie_mem_from_fd / vmie_mem_from_fd_segs (read-write, as the path
constructors: PROT_RW, MAP_SHARED)
- vmie_mem_from_ro_fd / vmie_mem_from_ro_fd_segs (read-only: map
PROT_READ, mark the source ro; gpa_write/gva_write return -1, every
read path is unchanged; accepts an O_RDONLY fd)
- vmie_win32_open_fd (the win32 context over an fd backing file)
Factor the mmap/validate tail and the single-low segment map out of the
path constructors into shared helpers, so the path and fd inputs go
through one mmap site and one map builder each.
This commit is contained in:
@@ -83,6 +83,15 @@ typedef struct {
|
||||
* failure. Free with vmie_win32_close(). */
|
||||
vmie_win32* vmie_win32_open(const char* ram_path, uint64_t low);
|
||||
|
||||
/* As vmie_win32_open, but over an already-open file descriptor `fd` for the RAM
|
||||
* backing file instead of a path. `fd` is BORROWED: it is dup()'d internally, so
|
||||
* the context owns its own copy and the caller's `fd` stays open and valid after
|
||||
* this call AND after vmie_win32_close(). `fd` must reference an mmap-able,
|
||||
* read-write object (regular file / memfd_create / POSIX shm); its file position
|
||||
* is not read or changed. Returns a new context (call host_bootstrap() next), or
|
||||
* NULL on dup/fstat/mmap failure. Free with vmie_win32_close(). */
|
||||
vmie_win32* vmie_win32_open_fd(int fd, uint64_t low);
|
||||
|
||||
/* Unmap, close, and free a context. Safe on NULL. After this, every pointer
|
||||
* into guest memory obtained through this context is invalid. */
|
||||
void vmie_win32_close(vmie_win32* v);
|
||||
|
||||
Reference in New Issue
Block a user