Reworking the memory system to not commit 3gb and to properly alloc data.
Now only 512MB is committed on startup. Loaded XEXs are placed into their required addresses in the 0x8... range. Kernel structures are allocated from the normal heap like other data. There should no longer be any magical pointers.
This commit is contained in:
@@ -58,30 +58,29 @@ XboxkrnlModule::XboxkrnlModule(Runtime* runtime) :
|
||||
RegisterThreadingExports(resolver, kernel_state_.get());
|
||||
RegisterVideoExports(resolver, kernel_state_.get());
|
||||
|
||||
// TODO(benvanik): alloc heap memory somewhere in user space
|
||||
// TODO(benvanik): tools for reading/writing to heap memory
|
||||
|
||||
uint8_t* mem = xe_memory_addr(memory_, 0);
|
||||
uint8_t* mem = xe_memory_addr(memory_);
|
||||
|
||||
// KeDebugMonitorData (?*)
|
||||
// Set to a valid value when a remote debugger is attached.
|
||||
// Offset 0x18 is a 4b pointer to a handler function that seems to take two
|
||||
// arguments. If we wanted to see what would happen we could fake that.
|
||||
uint32_t pKeDebugMonitorData = xe_memory_heap_alloc(memory_, 0, 256, 0);
|
||||
resolver->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::KeDebugMonitorData,
|
||||
0x80102100);
|
||||
XESETUINT32BE(mem + 0x80102100, 0);
|
||||
pKeDebugMonitorData);
|
||||
XESETUINT32BE(mem + pKeDebugMonitorData, 0);
|
||||
|
||||
// XboxHardwareInfo (XboxHardwareInfo_t, 16b)
|
||||
// flags cpu# ? ? ? ? ? ?
|
||||
// 0x00000000, 0x06, 0x00, 0x00, 0x00, 0x00000000, 0x0000, 0x0000
|
||||
// Games seem to check if bit 26 (0x20) is set, which at least for xbox1
|
||||
// was whether an HDD was present. Not sure what the other flags are.
|
||||
uint32_t pXboxHardwareInfo = xe_memory_heap_alloc(memory_, 0, 16, 0);
|
||||
resolver->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::XboxHardwareInfo,
|
||||
0x80100FED);
|
||||
XESETUINT32BE(mem + 0x80100FED, 0x00000000); // flags
|
||||
XESETUINT8BE(mem + 0x80100FEE, 0x06); // cpu count
|
||||
pXboxHardwareInfo);
|
||||
XESETUINT32BE(mem + pXboxHardwareInfo + 0, 0x00000000); // flags
|
||||
XESETUINT8BE (mem + pXboxHardwareInfo + 4, 0x06); // cpu count
|
||||
// Remaining 11b are zeroes?
|
||||
|
||||
// XexExecutableModuleHandle (?**)
|
||||
@@ -93,21 +92,26 @@ XboxkrnlModule::XboxkrnlModule(Runtime* runtime) :
|
||||
// 0x80101000 <- our module structure
|
||||
// 0x80101058 <- pointer to xex header
|
||||
// 0x80101100 <- xex header base
|
||||
uint32_t ppXexExecutableModuleHandle =
|
||||
xe_memory_heap_alloc(memory_, 0, 4, 0);
|
||||
resolver->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::XexExecutableModuleHandle,
|
||||
0x80100FFC);
|
||||
XESETUINT32BE(mem + 0x80100FFC, 0x80101000);
|
||||
XESETUINT32BE(mem + 0x80101058, 0x80101100);
|
||||
ppXexExecutableModuleHandle);
|
||||
uint32_t pXexExecutableModuleHandle =
|
||||
xe_memory_heap_alloc(memory_, 0, 256, 0);
|
||||
XESETUINT32BE(mem + ppXexExecutableModuleHandle, pXexExecutableModuleHandle);
|
||||
XESETUINT32BE(mem + pXexExecutableModuleHandle + 0x58, 0x80101100);
|
||||
|
||||
// ExLoadedCommandLine (char*)
|
||||
// The name of the xex. Not sure this is ever really used on real devices.
|
||||
// Perhaps it's how swap disc/etc data is sent?
|
||||
// Always set to "default.xex" (with quotes) for now.
|
||||
uint32_t pExLoadedCommandLine = xe_memory_heap_alloc(memory_, 0, 1024, 0);
|
||||
resolver->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::ExLoadedCommandLine,
|
||||
0x80102000);
|
||||
pExLoadedCommandLine);
|
||||
char command_line[] = "\"default.xex\"";
|
||||
xe_copy_memory(mem + 0x80102000, 1024,
|
||||
xe_copy_memory(mem + pExLoadedCommandLine, 1024,
|
||||
command_line, XECOUNT(command_line) + 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -159,6 +159,12 @@ SHIM_CALL VdSetGraphicsInterruptCallback_shim(
|
||||
// no op?
|
||||
|
||||
|
||||
// VdCallGraphicsNotificationRoutines
|
||||
// r3 = 1
|
||||
// r4 = ?
|
||||
// callbacks get 0, r3, r4
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
Reference in New Issue
Block a user