asinject

Number0x38
Signature(args*) -> 0 or -err
Groupmemory
Since1.0

Fill a frozen process’s address space from parsed ELF data. Second step of the three-step process spawn sequence:

  1. pspawn creates a new FROZEN process and returns its handle.
  2. asinject fills the new process’s address space with parsed ELF data.
  3. kickstart marks the process as schedulable. This is the privileged step between pspawn and kickstart. The asinject struct has the following form and is in spawn_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

RegisterNameDescription
r0argsPointer to the injection struct; its first field is a caller-set size

Returns

0 on success.

Errors

CodeCondition
ERR_NOPERMFor a non-privileged caller
ERR_BADPTR / ERR_BADARGFor a bad struct