[*] Fix pointer alignment issue in NT sections

[*] Fix possible spinlocks
This commit is contained in:
Reece Wilson 2022-01-24 20:13:08 +00:00
parent e5e36bd887
commit 299a1c5312
2 changed files with 5 additions and 5 deletions

View File

@ -142,13 +142,15 @@ namespace Aurora::Process
auto pSection = IMAGE_FIRST_SECTION(nt); auto pSection = IMAGE_FIRST_SECTION(nt);
auto pSectionCur = pSection; auto pSectionCur = pSection;
auto imageBase = nt->OptionalHeader.ImageBase;
for (auto i = 0; i < nt->FileHeader.NumberOfSections; i++) for (auto i = 0; i < nt->FileHeader.NumberOfSections; i++)
{ {
auto cur = pSectionCur++; auto cur = pSectionCur++;
Segment seg; Segment seg;
seg.origVa = cur->VirtualAddress - reinterpret_cast<AuUInt>(mod) + offset; seg.origVa = cur->VirtualAddress + offset;
seg.baseVa = cur->VirtualAddress; seg.baseVa = cur->VirtualAddress + imageBase;
seg.size = cur->SizeOfRawData; seg.size = cur->SizeOfRawData;
seg.fsOff = cur->PointerToRawData; seg.fsOff = cur->PointerToRawData;

View File

@ -130,13 +130,11 @@ namespace Aurora::Process
static AuOptional<Segment> FindInCache(AuUInt pointer) static AuOptional<Segment> FindInCache(AuUInt pointer)
{ {
AU_LOCK_GUARD(gMutexUnique);
auto curPtr = ToLowestPageAlignment(pointer); auto curPtr = ToLowestPageAlignment(pointer);
auto temp = GetSegmentCache(curPtr); auto temp = GetSegmentCache(curPtr);
if (temp.has_value()) return temp; if (temp.has_value()) return temp;
for (int i = 0; i < kPageBufferPad; i++) for (int i = 0; i < kPageBufferPad + 1; i++)
{ {
curPtr -= kMinPageAlignment; curPtr -= kMinPageAlignment;
temp = GetSegmentCache(curPtr); // TODO: i dont want to start from the top of the tree, thats stupid temp = GetSegmentCache(curPtr); // TODO: i dont want to start from the top of the tree, thats stupid