9d7ff0461f
Signed-off-by: Chloe M <chloe@mensia.org>
52 lines
1.0 KiB
C
52 lines
1.0 KiB
C
/*
|
|
* Copyright (c) 2026, Chloe M.
|
|
* Provided under the BSD-3 clause.
|
|
*
|
|
* Description: Process management
|
|
* Author: Chloe M.
|
|
*/
|
|
|
|
#include <ps/process.h>
|
|
#include <ex/pool.h>
|
|
#include <string.h>
|
|
#include <atomic.h>
|
|
|
|
static UQUAD ProcessId = 0;
|
|
|
|
PT_STATUS
|
|
PsCreateProcess(const CHAR *Name, ULONG Flags, PROCESS **Result)
|
|
{
|
|
USIZE NameLen;
|
|
PROCESS *Process;
|
|
|
|
if (Name == NULL || Result == NULL) {
|
|
return STATUS_INVALID_PARAM;
|
|
}
|
|
|
|
/* TODO: Support user-level processes */
|
|
if (ISSET(Flags, PS_USER)) {
|
|
return STATUS_NOT_SUPPORTED;
|
|
}
|
|
|
|
NameLen = RtlStrLen(Name);
|
|
if (NameLen >= PS_NAME_MAX - 1) {
|
|
return STATUS_NAME_TOO_LONG;
|
|
}
|
|
|
|
Process = ExAllocatePoolWithTag(
|
|
POOL_NON_PAGED,
|
|
sizeof(*Process),
|
|
PS_POOL_TAG
|
|
);
|
|
|
|
if (Process == NULL) {
|
|
return STATUS_NO_MEMORY;
|
|
}
|
|
|
|
RtlMemCpy(Process->Name, Name, NameLen);
|
|
Process->Pid = AtomicIncQuad(&ProcessId);
|
|
Process->Flags = Flags;
|
|
*Result = Process;
|
|
return STATUS_SUCCESS;
|
|
}
|