From 7d8db5a2cd06373aefba29dc019db74e78d6fb7d Mon Sep 17 00:00:00 2001 From: The-Little-Wolf <116989599+The-Little-Wolf@users.noreply.github.com> Date: Thu, 6 Aug 2026 12:16:28 -0700 Subject: [PATCH] [XBOXKRNL] - Replace lpvoid_t with pointer_t - Replace lpvoid_t with pointer_t - Use TypedGuestPointer for X_DEVICE_OBJECT struct --- src/xenia/kernel/xboxkrnl/xboxkrnl_io.cc | 60 +++++++++---------- src/xenia/kernel/xboxkrnl/xboxkrnl_rtl.cc | 6 +- .../kernel/xboxkrnl/xboxkrnl_threading.cc | 16 ++--- src/xenia/kernel/xobject.h | 1 - 4 files changed, 41 insertions(+), 42 deletions(-) diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_io.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_io.cc index c20496cfc..2e6ecf539 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_io.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_io.cc @@ -741,9 +741,9 @@ struct X_IRP_OVERLAY { X_LIST_ENTRY device_list_entry; // 0x0 sz:0x8 xe::be driver_context_ptr[4]; // 0x0 sz:0x10 }; - xe::be locked_buffer_length; // 0x10 sz:0x4 - xe::be thread_ptr; // 0x14 sz:0x4 - X_LIST_ENTRY list_entry; // 0x18 sz:0x8 + xe::be locked_buffer_length; // 0x10 sz:0x4 + TypedGuestPointer thread_ptr; // 0x14 sz:0x4 + X_LIST_ENTRY list_entry; // 0x18 sz:0x8 union { xe::be current_stack_location_ptr; // 0x20 sz:0x4, X_IO_STACK_LOCATION -> 0x24 @@ -761,37 +761,37 @@ union X_IRP_TAIL { }; struct X_IRP { - xe::be type; // 0x0 sz:0x2 - xe::be size; // 0x2 sz:0x2 - xe::be flags; // 0x4 sz:0x4 - X_LIST_ENTRY thread_list_entry; // 0x8 sz:0x8 - X_IO_STATUS_BLOCK io_status; // 0x10 sz:0x8 - xe::be stack_count; // 0x18 sz:0x1 - xe::be current_location; // 0x19 sz:0x1 - xe::be pending_returned; // 0x1A sz:0x1 - xe::be cancel; // 0x1B sz:0x1 - xe::be user_buffer_ptr; // 0x1C sz:0x4 - xe::be user_iosb_ptr; // 0x20 sz:0x4, X_IO_STATUS_BLOCK* - xe::be user_event_ptr; // 0x24 sz:0x4, X_KEVENT* - X_UNION_IRP_OVERLAY overlay; // 0x28 sz:0x8 - X_IRP_TAIL tail; // 0x30 sz:0x28 - xe::be cancel_routine_ptr; // 0x58 sz:0x4 + xe::be type; // 0x0 sz:0x2 + xe::be size; // 0x2 sz:0x2 + xe::be flags; // 0x4 sz:0x4 + X_LIST_ENTRY thread_list_entry; // 0x8 sz:0x8 + X_IO_STATUS_BLOCK io_status; // 0x10 sz:0x8 + xe::be stack_count; // 0x18 sz:0x1 + xe::be current_location; // 0x19 sz:0x1 + xe::be pending_returned; // 0x1A sz:0x1 + xe::be cancel; // 0x1B sz:0x1 + xe::be user_buffer_ptr; // 0x1C sz:0x4 + TypedGuestPointer user_iosb_ptr; // 0x20 sz:0x4 + TypedGuestPointer user_event_ptr; // 0x24 sz:0x4 + X_UNION_IRP_OVERLAY overlay; // 0x28 sz:0x8 + X_IRP_TAIL tail; // 0x30 sz:0x28 + xe::be cancel_routine_ptr; // 0x58 sz:0x4 }; static_assert_size(X_IRP, 0x60); struct X_DEVICE_OBJECT { - xe::be type; // 0x0 sz:0x2 - xe::be device_extension_size; // 0x2 sz:0x2 - xe::be reference_count; // 0x4 sz:0x4 - xe::be drive_object_ptr; // 0x8 sz:0x4, X_DRIVER_OBJECT* - xe::be mounted_or_self_device; // 0xC sz:0x4, X_DEVICE_OBJECT* - xe::be current_irp_ptr; // 0x10 sz:0x4, X_IRP* - xe::be flags; // 0x14 sz:0x4 - xe::be device_extension_ptr; // 0x18 sz:0x4 - xe::be device_type; // 0x1C sz:0x1 - xe::be start_io_flags; // 0x1D sz:0x1 - xe::be stack_size; // 0x1E sz:0x1 - xe::be delete_pending; // 0x1F sz:0x1 + xe::be type; // 0x0 sz:0x2 + xe::be device_extension_size; // 0x2 sz:0x2 + xe::be reference_count; // 0x4 sz:0x4 + TypedGuestPointer drive_object_ptr; // 0x8 sz:0x4 + TypedGuestPointer mounted_or_self_device; // 0xC sz:0x4 + TypedGuestPointer current_irp_ptr; // 0x10 sz:0x4 + xe::be flags; // 0x14 sz:0x4 + xe::be device_extension_ptr; // 0x18 sz:0x4 + xe::be device_type; // 0x1C sz:0x1 + xe::be start_io_flags; // 0x1D sz:0x1 + xe::be stack_size; // 0x1E sz:0x1 + xe::be delete_pending; // 0x1F sz:0x1 xe::be sector_size; // 0x20 sz:0x4, set by XamRamDriveCreate xe::be alignment; // 0x24 sz:0x4, NtQueryInformationFile called to verify diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_rtl.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_rtl.cc index 543b5bc61..ec1178f57 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_rtl.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_rtl.cc @@ -535,9 +535,9 @@ DECLARE_XBOXKRNL_EXPORT1(RtlImageXexHeaderField, kNone, kImplemented); #pragma pack(push, 1) struct X_RTL_CRITICAL_SECTION { X_DISPATCH_HEADER header; - int32_t lock_count; // 0x10 -1 -> 0 on first lock - xe::be recursion_count; // 0x14 0 -> 1 on first lock - xe::be owning_thread; // 0x18 PKTHREAD 0 unless locked + int32_t lock_count; // 0x10 -1 -> 0 on first lock + xe::be recursion_count; // 0x14 0 -> 1 on first lock + TypedGuestPointer owning_thread; // 0x18 PKTHREAD 0 unless locked }; #pragma pack(pop) static_assert_size(X_RTL_CRITICAL_SECTION, 28); diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_threading.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_threading.cc index 73340102b..7d2b388e7 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_threading.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_threading.cc @@ -773,9 +773,9 @@ dword_result_t KeReleaseSemaphore_entry(pointer_t semaphore_ptr, } DECLARE_XBOXKRNL_EXPORT1(KeReleaseSemaphore, kThreading, kImplemented); -dword_result_t NtCreateSemaphore_entry(lpdword_t handle_ptr, - lpvoid_t obj_attributes_ptr, - dword_t count, dword_t limit) { +dword_result_t NtCreateSemaphore_entry( + lpdword_t handle_ptr, pointer_t obj_attributes_ptr, + dword_t count, dword_t limit) { // Check for an existing semaphore with the same name. auto existing_object = LookupNamedObject(kernel_state(), obj_attributes_ptr); @@ -903,9 +903,9 @@ dword_result_t NtReleaseMutant_entry(dword_t mutant_handle, } DECLARE_XBOXKRNL_EXPORT1(NtReleaseMutant, kThreading, kImplemented); -dword_result_t NtCreateTimer_entry(lpdword_t handle_ptr, - lpvoid_t obj_attributes_ptr, - dword_t timer_type) { +dword_result_t NtCreateTimer_entry( + lpdword_t handle_ptr, pointer_t obj_attributes_ptr, + dword_t timer_type) { // timer_type = NotificationTimer (0) or SynchronizationTimer (1) // Check for an existing timer with the same name. @@ -1057,7 +1057,7 @@ DECLARE_XBOXKRNL_EXPORT3(NtWaitForSingleObjectEx, kThreading, kImplemented, dword_result_t KeWaitForMultipleObjects_entry( dword_t count, lpdword_t objects_ptr, dword_t wait_type, dword_t wait_reason, dword_t processor_mode, dword_t alertable, - lpqword_t timeout_ptr, lpvoid_t wait_block_array_ptr) { + lpqword_t timeout_ptr, pointer_t wait_block_array_ptr) { assert_true(wait_type <= X_KWAIT_REASON::WaitAny); assert_true(count <= 64); @@ -1531,7 +1531,7 @@ void xeKeInitializeApc(XAPC* apc, uint32_t thread_ptr, uint32_t kernel_routine, } apc->enqueued = 0; } -void KeInitializeApc_entry(pointer_t apc, lpvoid_t thread_ptr, +void KeInitializeApc_entry(pointer_t apc, pointer_t thread_ptr, lpvoid_t kernel_routine, lpvoid_t rundown_routine, lpvoid_t normal_routine, dword_t processor_mode, lpvoid_t normal_context) { diff --git a/src/xenia/kernel/xobject.h b/src/xenia/kernel/xobject.h index f2237d057..8dfd786d2 100644 --- a/src/xenia/kernel/xobject.h +++ b/src/xenia/kernel/xobject.h @@ -131,7 +131,6 @@ class XObject { case X_DISPATCHER_FLAGS::DISPATCHER_MANUAL_RESET_EVENT: case X_DISPATCHER_FLAGS::DISPATCHER_AUTO_RESET_EVENT: return Type::Event; - return Type::Mutant; case X_DISPATCHER_FLAGS::DISPATCHER_MUTANT: return Type::Mutant; case X_DISPATCHER_FLAGS::DISPATCHER_SEMAPHORE: