[Kernel] More TranslateVirtual/HostToGuestVirtual usage
This commit is contained in:
@@ -33,8 +33,8 @@ using PPCContext = xe::cpu::ppc::PPCContext;
|
||||
library_name, ordinals::export_name, \
|
||||
(xe::cpu::xe_kernel_export_shim_fn)export_name##_shim);
|
||||
|
||||
#define SHIM_MEM_BASE ppc_context->virtual_membase
|
||||
#define SHIM_MEM_ADDR(a) (a ? (ppc_context->virtual_membase + a) : nullptr)
|
||||
#define SHIM_MEM_ADDR(a) \
|
||||
((a) ? ppc_context->kernel_state->memory()->TranslateVirtual(a) : nullptr)
|
||||
|
||||
#define SHIM_MEM_8(a) xe::load_and_swap<uint8_t>(SHIM_MEM_ADDR(a))
|
||||
#define SHIM_MEM_16(a) xe::load_and_swap<uint16_t>(SHIM_MEM_ADDR(a))
|
||||
|
||||
@@ -243,8 +243,8 @@ dword_result_t XexGetProcedureAddress(lpvoid_t hmodule, dword_t ordinal,
|
||||
assert_not_zero(ordinal);
|
||||
|
||||
bool is_string_name = (ordinal & 0xFFFF0000) != 0;
|
||||
auto string_name = reinterpret_cast<const char*>(
|
||||
kernel_memory()->virtual_membase() + ordinal);
|
||||
auto string_name =
|
||||
reinterpret_cast<const char*>(kernel_memory()->TranslateVirtual(ordinal));
|
||||
|
||||
X_STATUS result = X_STATUS_INVALID_HANDLE;
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ dword_result_t ObDereferenceObject(dword_t native_ptr) {
|
||||
}
|
||||
|
||||
auto object = XObject::GetNativeObject<XObject>(
|
||||
kernel_state(), kernel_memory()->virtual_membase() + native_ptr);
|
||||
kernel_state(), kernel_memory()->TranslateVirtual(native_ptr));
|
||||
if (object) {
|
||||
object->Release();
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ dword_result_t RtlUnicodeStringToAnsiString(
|
||||
uint32_t buffer_ptr =
|
||||
kernel_memory()->SystemHeapAlloc(uint32_t(ansi_str.size() + 1));
|
||||
|
||||
memcpy(kernel_memory()->virtual_membase() + buffer_ptr, ansi_str.data(),
|
||||
memcpy(kernel_memory()->TranslateVirtual(buffer_ptr), ansi_str.data(),
|
||||
ansi_str.size() + 1);
|
||||
destination_ptr->length = static_cast<uint16_t>(ansi_str.size());
|
||||
destination_ptr->maximum_length =
|
||||
@@ -250,7 +250,7 @@ dword_result_t RtlUnicodeStringToAnsiString(
|
||||
} else {
|
||||
uint32_t buffer_capacity = destination_ptr->maximum_length;
|
||||
auto buffer_ptr =
|
||||
kernel_memory()->virtual_membase() + destination_ptr->pointer;
|
||||
kernel_memory()->TranslateVirtual(destination_ptr->pointer);
|
||||
if (buffer_capacity < ansi_str.size() + 1) {
|
||||
// Too large - we just write what we can.
|
||||
result = X_STATUS_BUFFER_OVERFLOW;
|
||||
@@ -332,7 +332,7 @@ pointer_result_t RtlImageNtHeader(lpvoid_t module) {
|
||||
if (nt_magic != 0x4550) { // 'PE'
|
||||
return 0;
|
||||
}
|
||||
return static_cast<uint32_t>(nt_header - kernel_memory()->virtual_membase());
|
||||
return kernel_memory()->HostToGuestVirtual(nt_header);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlImageNtHeader, kNone, kImplemented);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user