mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +00:00
UserspaceEmulator+LibX86: Add support for 64-bit memory reads and writes (#3584)
This is useful for reading and writing doubles for #3329. It is also useful for emulating 64-bit binaries. MemoryOrRegisterReference assumes that 64-bit values are always memory references since that's enough for fpu support. If we ever want to emulate 64-bit binaries, that part will need minor updating.
This commit is contained in:
parent
1fa5a526e8
commit
f1c0f661f4
12 changed files with 156 additions and 0 deletions
|
@ -360,6 +360,7 @@ public:
|
|||
ValueWithShadow<u8> read_memory8(X86::LogicalAddress);
|
||||
ValueWithShadow<u16> read_memory16(X86::LogicalAddress);
|
||||
ValueWithShadow<u32> read_memory32(X86::LogicalAddress);
|
||||
ValueWithShadow<u64> read_memory64(X86::LogicalAddress);
|
||||
|
||||
template<typename T>
|
||||
ValueWithShadow<T> read_memory(X86::LogicalAddress address)
|
||||
|
@ -375,6 +376,7 @@ public:
|
|||
void write_memory8(X86::LogicalAddress, ValueWithShadow<u8>);
|
||||
void write_memory16(X86::LogicalAddress, ValueWithShadow<u16>);
|
||||
void write_memory32(X86::LogicalAddress, ValueWithShadow<u32>);
|
||||
void write_memory64(X86::LogicalAddress, ValueWithShadow<u64>);
|
||||
|
||||
template<typename T>
|
||||
void write_memory(X86::LogicalAddress address, ValueWithShadow<T> data)
|
||||
|
@ -456,6 +458,7 @@ public:
|
|||
virtual u8 read8() override;
|
||||
virtual u16 read16() override;
|
||||
virtual u32 read32() override;
|
||||
virtual u64 read64() override;
|
||||
|
||||
private:
|
||||
// ^X86::Interpreter
|
||||
|
@ -1154,4 +1157,15 @@ ALWAYS_INLINE u32 SoftCPU::read32()
|
|||
return value;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE u64 SoftCPU::read64()
|
||||
{
|
||||
if (!m_cached_code_ptr || (m_cached_code_ptr + 8) >= m_cached_code_end)
|
||||
update_code_cache();
|
||||
|
||||
u64 value = *reinterpret_cast<const u64*>(m_cached_code_ptr);
|
||||
m_cached_code_ptr += 8;
|
||||
m_eip += 8;
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue