StrikerX3 / OpenXBOX

An experimental (Original) Xbox emulator
79 stars 6 forks source link

Create and use a lightweight mechanism for reading/writing structs in guest virtual memory #9

Closed StrikerX3 closed 6 years ago

StrikerX3 commented 6 years ago

As mentioned on this comment, using pointers into the memory array with virtual memory addresses is dangerous and will corrupt memory or cause crashes if the data being accessed crosses the boundary of two or more virtual pages that map to non-contiguous physical addresses.

The goal here is to create a mechanism that allows host code to manipulate guest data using virtual addresses as transparently and lightweight as possible, ideally reproducing the behavior of the CPU, including causing exceptions such as General Protection Faults if the code attempts to read from or write to inaccessible memory pages. The existing StructRef template class can be used as a starting point for research.

Pointers are still safe to use when the address is known to be physical. Most (if not all) Mm* functions and kernel initialization code can continue using ToPointer. Stack variables might be safe as well; this needs investigation.

StrikerX3 commented 6 years ago

11 may invalidate this depending on the approach taken.

StrikerX3 commented 6 years ago

Due to #16, this is no longer valid.