ReXGlue SDK
Loading...
Searching...
No Matches
xboxkrnl.h File Reference
#include <cstring>
#include <rex/platform.h>
#include <rex/types.h>
#include <rex/kernel/types/status.h>
#include <rex/kernel/types/thread.h>
#include <rex/ppc/context.h>
#include <rex/kernel/object/kernel_thread.h>
#include <rex/kernel/types/list.h>
#include <rex/memory.h>
#include <rex/title.h>

Go to the source code of this file.

Classes

struct  rex::kernel::X_VIDEO_MODE

Namespaces

namespace  rex
namespace  rex::kernel

Functions

void rex::kernel::xboxkrnl::RtlInitializeCriticalSection (X_RTL_CRITICAL_SECTION *cs)
X_STATUS rex::kernel::xboxkrnl::RtlInitializeCriticalSectionAndSpinCount (X_RTL_CRITICAL_SECTION *cs, u32 spin_count)
u32 rex::kernel::xboxkrnl::NtSetEvent (u32 handle, be_u32 *previous_state_ptr)
u32 rex::kernel::xboxkrnl::NtClearEvent (u32 handle)
u32 rex::kernel::xboxkrnl::NtWaitForMultipleObjectsEx (u32 count, be_u32 *handles, u32 wait_type, u32 wait_mode, u32 alertable, u64 *timeout_ptr)
u32 rex::kernel::xboxkrnl::KeWaitForSingleObject (u32 object_address, u32 wait_reason, u32 processor_mode, u32 alertable, u64 *timeout_ptr)
u32 rex::kernel::xboxkrnl::KeSetEvent (u32 event_address, u32 increment, u32 wait)
u32 rex::kernel::xboxkrnl::KeKfAcquireSpinLock (rex::kernel::GuestAddressSpace &memory, PPCContext *ctx, rex::kernel::X_KSPINLOCK *lock, bool change_irql=true)
void rex::kernel::xboxkrnl::KeKfReleaseSpinLock (rex::kernel::GuestAddressSpace &memory, PPCContext *ctx, rex::kernel::X_KSPINLOCK *lock, u32 old_irql, bool change_irql=true)
void rex::kernel::xboxkrnl::KeInitializeApc (rex::kernel::XAPC *apc, u32 thread_ptr, u32 kernel_routine, u32 rundown_routine, u32 normal_routine, u32 apc_mode, u32 normal_context)
u32 rex::kernel::xboxkrnl::KeInsertQueueApc (rex::kernel::GuestAddressSpace &memory, rex::kernel::XAPC *apc, u32 arg1, u32 arg2, u32 priority_increment, PPCContext *ctx)
void rex::kernel::FillXVideoMode (const VideoMode &mode, X_VIDEO_MODE &out)
void rex::kernel::xboxkrnl::VdQueryVideoMode (kernel::X_VIDEO_MODE *video_mode)

Detailed Description

Xenia : Xbox 360 Emulator Research Project *

Copyright 2013 Ben Vanik. All rights reserved. * Copyright 2015 Ben Vanik. All rights reserved. * Released under the BSD license - see LICENSE in the root for more details. *

Modified
Tom Clay, 2026 - Adapted for ReXGlue runtime
Remarks
Parts derived from Xenia (Ben Vanik, 2022).
Parts derived from Xenia (Ben Vanik, 2020).

Function Documentation

◆ KeInitializeApc()

void rex::kernel::xboxkrnl::KeInitializeApc ( rex::kernel::XAPC * apc,
u32 thread_ptr,
u32 kernel_routine,
u32 rundown_routine,
u32 normal_routine,
u32 apc_mode,
u32 normal_context )

Initializes an APC object in guest memory.

Parameters
apcThe APC to initialize.
normal_routineGuest address of the normal routine, or 0 for a kernel APC.
apc_modeThe processor mode, used only when a normal routine is given.
normal_contextContext passed to the normal routine, used only when one is given.

◆ KeInsertQueueApc()

u32 rex::kernel::xboxkrnl::KeInsertQueueApc ( rex::kernel::GuestAddressSpace & memory,
rex::kernel::XAPC * apc,
u32 arg1,
u32 arg2,
u32 priority_increment,
PPCContext * ctx )

Queues an APC on its target thread.

Parameters
apcThe APC to queue.
arg1First system argument passed to the APC routines.
arg2Second system argument passed to the APC routines.
priority_incrementPriority boost, ignored.
ctxCalling context. Its r13 holds the PCR address.
Returns
1 when queued, 0 when the APC has no thread, is already queued or its thread takes no APCs.

◆ KeKfAcquireSpinLock()

u32 rex::kernel::xboxkrnl::KeKfAcquireSpinLock ( rex::kernel::GuestAddressSpace & memory,
PPCContext * ctx,
rex::kernel::X_KSPINLOCK * lock,
bool change_irql = true )

Acquires a spinlock stored in guest memory.

Parameters
ctxCalling context. Its r13 holds the PCR address.
change_irqlTrue to raise the IRQL while the lock is held.
Returns
The previous IRQL.

◆ KeKfReleaseSpinLock()

void rex::kernel::xboxkrnl::KeKfReleaseSpinLock ( rex::kernel::GuestAddressSpace & memory,
PPCContext * ctx,
rex::kernel::X_KSPINLOCK * lock,
u32 old_irql,
bool change_irql = true )

Releases a spinlock stored in guest memory.

Parameters
ctxCalling context. Its r13 holds the PCR address.
old_irqlThe IRQL returned by KeKfAcquireSpinLock.
change_irqlTrue to restore the IRQL.

◆ KeSetEvent()

u32 rex::kernel::xboxkrnl::KeSetEvent ( u32 event_address,
u32 increment,
u32 wait )

Signals an event object in guest memory.

Parameters
incrementPriority boost, ignored.
waitWhether the caller waits next, ignored.
Returns
The previous signal state, or 0 when the address is not an event.

◆ KeWaitForSingleObject()

u32 rex::kernel::xboxkrnl::KeWaitForSingleObject ( u32 object_address,
u32 wait_reason,
u32 processor_mode,
u32 alertable,
u64 * timeout_ptr )

Waits on a kernel object in guest memory.

Parameters
alertableNonzero when a user APC can interrupt the wait.
timeout_ptrThe timeout in 100 ns units, or null to wait indefinitely.
Returns
The wait status, such as X_STATUS_SUCCESS or X_STATUS_TIMEOUT.

◆ NtClearEvent()

u32 rex::kernel::xboxkrnl::NtClearEvent ( u32 handle)

Sets an event to the nonsignaled state.

Returns
X_STATUS_SUCCESS, or X_STATUS_INVALID_HANDLE when the handle is not an event.

◆ NtSetEvent()

u32 rex::kernel::xboxkrnl::NtSetEvent ( u32 handle,
be_u32 * previous_state_ptr )

Signals an event.

Parameters
previous_state_ptrReceives the previous signal state, or null to skip.
Returns
X_STATUS_SUCCESS, or X_STATUS_INVALID_HANDLE when the handle is not an event.

◆ NtWaitForMultipleObjectsEx()

u32 rex::kernel::xboxkrnl::NtWaitForMultipleObjectsEx ( u32 count,
be_u32 * handles,
u32 wait_type,
u32 wait_mode,
u32 alertable,
u64 * timeout_ptr )

Waits on several handles at once.

Parameters
wait_type0 to wait for all handles, 1 to wait for any handle.
alertableNonzero when a user APC can interrupt the wait.
timeout_ptrThe timeout in 100 ns units, or null to wait indefinitely.
Returns
The wait status, such as the index of the signaled handle or X_STATUS_TIMEOUT.

◆ RtlInitializeCriticalSectionAndSpinCount()

X_STATUS rex::kernel::xboxkrnl::RtlInitializeCriticalSectionAndSpinCount ( X_RTL_CRITICAL_SECTION * cs,
u32 spin_count )

Initializes a critical section in guest memory with a spin count.

Parameters
spin_countThe spin count, stored in units of 256 and capped at 255 units.
Returns
X_STATUS_SUCCESS.

◆ VdQueryVideoMode()

void rex::kernel::xboxkrnl::VdQueryVideoMode ( kernel::X_VIDEO_MODE * video_mode)

Fills a video mode structure from the runtime display settings.

Parameters
video_modeReceives the video mode.