From 7d8a2f2622dc05475359b88a033dcf01545eea8b Mon Sep 17 00:00:00 2001
From: Gliniak <Gliniak93@gmail.com>
Date: Sat, 22 Feb 2025 17:47:46 +0100
Subject: [PATCH] [Memory] Added allocation of 40k at the start of xex range.

Titles can access it and take value from it.
---
 src/xenia/memory.cc | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/xenia/memory.cc b/src/xenia/memory.cc
index fde0a13c8..bd92d29f7 100644
--- a/src/xenia/memory.cc
+++ b/src/xenia/memory.cc
@@ -234,6 +234,17 @@ bool Memory::Initialize() {
   heaps_.vA0000000.Alloc(0x340000, 64 * 1024, kMemoryAllocationReserve,
                          kMemoryProtectNoAccess, true, &unk_phys_alloc);
 
+  uint32_t unknown_xex_range;  // Probably hypervisor?
+  heaps_.v80000000.Alloc(0x40000, 4 * 1024, kMemoryAllocationCommit,
+                         kMemoryProtectRead | kMemoryProtectWrite, false,
+                         &unknown_xex_range);
+
+  // Value taken from 544307D5. Title explicitly access this address and this is
+  // a value underneath it (It's constant between multiple runs)
+  uint32_t value_to_write = xe::byte_swap(0x2a6e3f38);
+  memcpy(TranslateVirtual(0x80000000 + 0x1C), &value_to_write,
+         sizeof(uint32_t));
+
   return true;
 }