Unverified Commit 52adb1af authored by PhoeniX's avatar PhoeniX

Process ASLR support

parent 219d5e40
......@@ -28,6 +28,7 @@ class Process {
List<ProcessSymbol> symbols;
uintptr_t entry;
void addPage(uintptr_t vaddr, void* paddr, uint8_t flags);
uintptr_t _aslrCode, _aslrStack;
public:
Process();
......
......@@ -10,6 +10,8 @@ Process::Process() {
id = -1;
pagetable = 0;
entry = 0;
_aslrCode = ((RAND::get<uintptr_t>() << 12) & 0x7FFFFFFF000) | 0x40000000000;
_aslrStack = ((RAND::get<uintptr_t>() << 12) & 0x7FFFFFFF000) | 0x80000000000;
}
Process::~Process() {
if (pagetable != 0) {
......@@ -92,9 +94,13 @@ uintptr_t Process::addSection(SectionType type, size_t size) {
if (size == 0)
return 0;
size_t pages = (size >> 12) + 1;
uintptr_t vaddr = 0xF000000000;
if (type == SectionTypeStack)
vaddr = 0xA000000000;
uintptr_t vaddr;
if (type != SectionTypeStack) {
vaddr = _aslrCode;
} else {
vaddr = _aslrStack;
}
for (uintptr_t caddr = vaddr; caddr < vaddr + size; caddr += 0x1000) {
if (getPhysicalAddress(vaddr) != 0) {
vaddr += 0x1000;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment