Added "DoNotCreatePageTable" boolean to CreateProcess

This commit is contained in:
Alex 2023-01-09 17:19:06 +02:00
parent e1a11bba4c
commit 1297aecc8a
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
2 changed files with 16 additions and 9 deletions

View File

@ -597,12 +597,12 @@ namespace Tasking
{
int Status = var->Status;
printf("\e%s-> \eAABBCC%s\eCCCCCC[%d] \e00AAAA%s\n",
Statuses[Status], var->Name, Status, StatusesSign[Status]);
Statuses[Status], var->Name, Status, StatusesSign[Status]);
foreach (auto var2 in var->Threads)
{
Status = var2->Status;
printf(" \e%s-> \eAABBCC%s\eCCCCCC[%d] \e00AAAA%s\n\eAABBCC",
Statuses[Status], var2->Name, Status, StatusesSign[Status]);
Statuses[Status], var2->Name, Status, StatusesSign[Status]);
}
}
printf("%d - SOURCE: %s", sanity++, SuccessSourceStrings[SuccessSource]);
@ -1113,7 +1113,8 @@ namespace Tasking
PCB *Task::CreateProcess(PCB *Parent,
const char *Name,
TaskTrustLevel TrustLevel, void *Image)
TaskTrustLevel TrustLevel, void *Image,
bool DoNotCreatePageTable)
{
SmartCriticalSection(TaskingLock);
PCB *Process = new PCB;
@ -1141,7 +1142,8 @@ namespace Tasking
{
SecurityManager.TrustToken(Process->Security.UniqueToken, TokenTrustLevel::TrustedByKernel);
#if defined(__amd64__)
Process->PageTable = (Memory::PageTable4 *)CPU::x64::readcr3().raw;
if (!DoNotCreatePageTable)
Process->PageTable = (Memory::PageTable4 *)CPU::x64::readcr3().raw;
#elif defined(__i386__)
#elif defined(__aarch64__)
#endif
@ -1151,10 +1153,13 @@ namespace Tasking
{
SecurityManager.TrustToken(Process->Security.UniqueToken, TokenTrustLevel::Untrusted);
#if defined(__amd64__)
Process->PageTable = (Memory::PageTable4 *)KernelAllocator.RequestPages(TO_PAGES(PAGE_SIZE));
memcpy(Process->PageTable, (void *)UserspaceKernelOnlyPageTable, PAGE_SIZE);
for (size_t i = 0; i < TO_PAGES(PAGE_SIZE); i++)
Memory::Virtual(Process->PageTable).Map((void *)Process->PageTable, (void *)Process->PageTable, Memory::PTFlag::RW); // Make sure the page table is mapped.
if (!DoNotCreatePageTable)
{
Process->PageTable = (Memory::PageTable4 *)KernelAllocator.RequestPages(TO_PAGES(PAGE_SIZE));
memcpy(Process->PageTable, (void *)UserspaceKernelOnlyPageTable, PAGE_SIZE);
for (size_t i = 0; i < TO_PAGES(PAGE_SIZE); i++)
Memory::Virtual(Process->PageTable).Map((void *)Process->PageTable, (void *)Process->PageTable, Memory::PTFlag::RW); // Make sure the page table is mapped.
}
#elif defined(__i386__)
#elif defined(__aarch64__)
#endif

View File

@ -288,7 +288,9 @@ namespace Tasking
PCB *CreateProcess(PCB *Parent,
const char *Name,
TaskTrustLevel TrustLevel, void *Image = nullptr);
TaskTrustLevel TrustLevel,
void *Image = nullptr,
bool DoNotCreatePageTable = false);
TCB *CreateThread(PCB *Parent,
IP EntryPoint,