asinject
| Number | 0x38 |
|---|---|
| Signature | (args*) -> 0 or -err |
| Group | memory |
| Since | 1.0 |
Fill a frozen process’s address space from parsed ELF data. Second step of the three-step process spawn sequence:
pspawncreates a new FROZEN process and returns its handle.asinjectfills the new process’s address space with parsed ELF data.kickstartmarks the process as schedulable. This is the privileged step betweenpspawnandkickstart. The asinject struct has the following form and is inspawn_args.h:
typedef struct
{
uint32_t size; /* sizeof(asinject_args_t); wrapper sets it */
handle_t task_handle; // handle of the target task
uintptr_t dst_va; // destination virtual address in the target task's address space
const void *src_buf; // pointer to the source buffer in the current task's address space
size_t len; // length of the source buffer in bytes
uint32_t prot; // memory protection flags for the destination mapping (e.g., VM_PROT_READ | VM_PROT_WRITE)
} asinject_args_t;
Pitfalls
Only the init process may call this. Ordinary processes spawn children by messaging init, not by calling asinject directly. The init process is granted the permission via the PROCESS_FLAG_INIT in the PCB.
Arguments
| Register | Name | Description |
|---|---|---|
r0 | args | Pointer to the injection struct; its first field is a caller-set size |
Returns
0 on success.
Errors
| Code | Condition |
|---|---|
ERR_NOPERM | For a non-privileged caller |
ERR_BADPTR / ERR_BADARG | For a bad struct |