Skip to content

MemInjectObj

Maps part of a memory object into another space, typically one being set up.

Number Selector Blocking Since
0x0B SVC_MANAGEMEMORY MNGMEM_INJECTOBJ (3) no 2.0
Err MemInjectObj(Handle kitten_space_handle, Handle mem_handle, VirtAddr dest_vaddr, size_t offset, size_t size, MemProt prot);

Registers: (space, &args) -> r0 status

The mapping holds its own reference, so the handle can be closed afterwards. Pass HANDLE_ANON as mem_handle for demand-zero memory.

Parameters

Name Direction Description
kitten_space_handle in Target space with PERM_CNTL.
mem_handle in Memory object in the caller's space, or HANDLE_ANON.
dest_vaddr in Page-aligned address in the target space.
offset in Byte offset into the object; ignored for HANDLE_ANON.
size in Bytes to map.
prot in Protection of the target mapping, never writable and executable. It also becomes the ceiling MemProtect() cannot raise in the target space.

Returns

ZUZU_OK, or an error code.

Errors

Error Condition
ERR_BADHANDLE A handle is not live.
ERR_BADTYPE kitten_space_handle is not a space, or mem_handle is not memory.
ERR_NOPERM Missing PERM_CNTL on the space or PERM_MAP on the object, or prot needs a PERM_WRITE / PERM_EXEC the object handle lacks.
ERR_DEAD The target space has been torn down.
ERR_BADARG Misaligned or out-of-range addresses, offset or size.
ERR_BUSY The target range is already mapped.
ERR_NOMEM Out of memory or page tables.