[Kernel] Suffix export functions with _entry.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -95,11 +95,12 @@ object_ref<T> LookupNamedObject(KernelState* kernel_state,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
dword_result_t ExCreateThread(lpdword_t handle_ptr, dword_t stack_size,
|
||||
lpdword_t thread_id_ptr,
|
||||
dword_t xapi_thread_startup,
|
||||
lpvoid_t start_address, lpvoid_t start_context,
|
||||
dword_t creation_flags) {
|
||||
dword_result_t ExCreateThread_entry(lpdword_t handle_ptr, dword_t stack_size,
|
||||
lpdword_t thread_id_ptr,
|
||||
dword_t xapi_thread_startup,
|
||||
lpvoid_t start_address,
|
||||
lpvoid_t start_context,
|
||||
dword_t creation_flags) {
|
||||
// http://jafile.com/uploads/scoop/main.cpp.txt
|
||||
// DWORD
|
||||
// LPHANDLE Handle,
|
||||
@@ -149,7 +150,7 @@ dword_result_t ExCreateThread(lpdword_t handle_ptr, dword_t stack_size,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ExCreateThread, kThreading, kImplemented);
|
||||
|
||||
dword_result_t ExTerminateThread(dword_t exit_code) {
|
||||
dword_result_t ExTerminateThread_entry(dword_t exit_code) {
|
||||
XThread* thread = XThread::GetCurrentThread();
|
||||
|
||||
// NOTE: this kills us right now. We won't return from it.
|
||||
@@ -157,7 +158,8 @@ dword_result_t ExTerminateThread(dword_t exit_code) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ExTerminateThread, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtResumeThread(dword_t handle, lpdword_t suspend_count_ptr) {
|
||||
dword_result_t NtResumeThread_entry(dword_t handle,
|
||||
lpdword_t suspend_count_ptr) {
|
||||
X_RESULT result = X_STATUS_INVALID_HANDLE;
|
||||
uint32_t suspend_count = 0;
|
||||
|
||||
@@ -173,7 +175,7 @@ dword_result_t NtResumeThread(dword_t handle, lpdword_t suspend_count_ptr) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtResumeThread, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KeResumeThread(lpvoid_t thread_ptr) {
|
||||
dword_result_t KeResumeThread_entry(lpvoid_t thread_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
auto thread = XObject::GetNativeObject<XThread>(kernel_state(), thread_ptr);
|
||||
if (thread) {
|
||||
@@ -186,7 +188,8 @@ dword_result_t KeResumeThread(lpvoid_t thread_ptr) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeResumeThread, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtSuspendThread(dword_t handle, lpdword_t suspend_count_ptr) {
|
||||
dword_result_t NtSuspendThread_entry(dword_t handle,
|
||||
lpdword_t suspend_count_ptr) {
|
||||
X_RESULT result = X_STATUS_SUCCESS;
|
||||
uint32_t suspend_count = 0;
|
||||
|
||||
@@ -205,9 +208,11 @@ dword_result_t NtSuspendThread(dword_t handle, lpdword_t suspend_count_ptr) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtSuspendThread, kThreading, kImplemented);
|
||||
|
||||
void KeSetCurrentStackPointers(lpvoid_t stack_ptr, pointer_t<X_KTHREAD> thread,
|
||||
lpvoid_t stack_alloc_base, lpvoid_t stack_base,
|
||||
lpvoid_t stack_limit) {
|
||||
void KeSetCurrentStackPointers_entry(lpvoid_t stack_ptr,
|
||||
pointer_t<X_KTHREAD> thread,
|
||||
lpvoid_t stack_alloc_base,
|
||||
lpvoid_t stack_base,
|
||||
lpvoid_t stack_limit) {
|
||||
auto current_thread = XThread::GetCurrentThread();
|
||||
auto context = current_thread->thread_state()->context();
|
||||
auto pcr = kernel_memory()->TranslateVirtual<X_KPCR*>(
|
||||
@@ -230,8 +235,8 @@ void KeSetCurrentStackPointers(lpvoid_t stack_ptr, pointer_t<X_KTHREAD> thread,
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeSetCurrentStackPointers, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t KeSetAffinityThread(lpvoid_t thread_ptr, dword_t affinity,
|
||||
lpdword_t previous_affinity_ptr) {
|
||||
dword_result_t KeSetAffinityThread_entry(lpvoid_t thread_ptr, dword_t affinity,
|
||||
lpdword_t previous_affinity_ptr) {
|
||||
// The Xbox 360, according to disassembly of KeSetAffinityThread, unlike
|
||||
// Windows NT, stores the previous affinity via the pointer provided as an
|
||||
// argument, not in the return value - the return value is used for the
|
||||
@@ -250,7 +255,7 @@ dword_result_t KeSetAffinityThread(lpvoid_t thread_ptr, dword_t affinity,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeSetAffinityThread, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KeQueryBasePriorityThread(lpvoid_t thread_ptr) {
|
||||
dword_result_t KeQueryBasePriorityThread_entry(lpvoid_t thread_ptr) {
|
||||
int32_t priority = 0;
|
||||
|
||||
auto thread = XObject::GetNativeObject<XThread>(kernel_state(), thread_ptr);
|
||||
@@ -262,7 +267,8 @@ dword_result_t KeQueryBasePriorityThread(lpvoid_t thread_ptr) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeQueryBasePriorityThread, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KeSetBasePriorityThread(lpvoid_t thread_ptr, dword_t increment) {
|
||||
dword_result_t KeSetBasePriorityThread_entry(lpvoid_t thread_ptr,
|
||||
dword_t increment) {
|
||||
int32_t prev_priority = 0;
|
||||
auto thread = XObject::GetNativeObject<XThread>(kernel_state(), thread_ptr);
|
||||
|
||||
@@ -275,7 +281,8 @@ dword_result_t KeSetBasePriorityThread(lpvoid_t thread_ptr, dword_t increment) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeSetBasePriorityThread, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KeSetDisableBoostThread(lpvoid_t thread_ptr, dword_t disabled) {
|
||||
dword_result_t KeSetDisableBoostThread_entry(lpvoid_t thread_ptr,
|
||||
dword_t disabled) {
|
||||
auto thread = XObject::GetNativeObject<XThread>(kernel_state(), thread_ptr);
|
||||
if (thread) {
|
||||
// Uhm?
|
||||
@@ -285,13 +292,13 @@ dword_result_t KeSetDisableBoostThread(lpvoid_t thread_ptr, dword_t disabled) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeSetDisableBoostThread, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KeGetCurrentProcessType() {
|
||||
dword_result_t KeGetCurrentProcessType_entry() {
|
||||
return kernel_state()->process_type();
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeGetCurrentProcessType, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
void KeSetCurrentProcessType(dword_t type) {
|
||||
void KeSetCurrentProcessType_entry(dword_t type) {
|
||||
// One of X_PROCTYPE_?
|
||||
|
||||
assert_true(type <= 2);
|
||||
@@ -300,15 +307,16 @@ void KeSetCurrentProcessType(dword_t type) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeSetCurrentProcessType, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KeQueryPerformanceFrequency() {
|
||||
dword_result_t KeQueryPerformanceFrequency_entry() {
|
||||
uint64_t result = Clock::guest_tick_frequency();
|
||||
return static_cast<uint32_t>(result);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeQueryPerformanceFrequency, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t KeDelayExecutionThread(dword_t processor_mode, dword_t alertable,
|
||||
lpqword_t interval_ptr) {
|
||||
dword_result_t KeDelayExecutionThread_entry(dword_t processor_mode,
|
||||
dword_t alertable,
|
||||
lpqword_t interval_ptr) {
|
||||
XThread* thread = XThread::GetCurrentThread();
|
||||
X_STATUS result = thread->Delay(processor_mode, alertable, *interval_ptr);
|
||||
|
||||
@@ -317,7 +325,7 @@ dword_result_t KeDelayExecutionThread(dword_t processor_mode, dword_t alertable,
|
||||
DECLARE_XBOXKRNL_EXPORT3(KeDelayExecutionThread, kThreading, kImplemented,
|
||||
kBlocking, kHighFrequency);
|
||||
|
||||
dword_result_t NtYieldExecution() {
|
||||
dword_result_t NtYieldExecution_entry() {
|
||||
auto thread = XThread::GetCurrentThread();
|
||||
thread->Delay(0, 0, 0);
|
||||
return 0;
|
||||
@@ -325,7 +333,7 @@ dword_result_t NtYieldExecution() {
|
||||
DECLARE_XBOXKRNL_EXPORT2(NtYieldExecution, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
void KeQuerySystemTime(lpqword_t time_ptr) {
|
||||
void KeQuerySystemTime_entry(lpqword_t time_ptr) {
|
||||
uint64_t time = Clock::QueryGuestSystemTime();
|
||||
if (time_ptr) {
|
||||
*time_ptr = time;
|
||||
@@ -334,7 +342,7 @@ void KeQuerySystemTime(lpqword_t time_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeQuerySystemTime, kThreading, kImplemented);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms686801
|
||||
dword_result_t KeTlsAlloc() {
|
||||
dword_result_t KeTlsAlloc_entry() {
|
||||
uint32_t slot = kernel_state()->AllocateTLS();
|
||||
XThread::GetCurrentThread()->SetTLSValue(slot, 0);
|
||||
|
||||
@@ -343,7 +351,7 @@ dword_result_t KeTlsAlloc() {
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeTlsAlloc, kThreading, kImplemented);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms686804
|
||||
dword_result_t KeTlsFree(dword_t tls_index) {
|
||||
dword_result_t KeTlsFree_entry(dword_t tls_index) {
|
||||
if (tls_index == X_TLS_OUT_OF_INDEXES) {
|
||||
return 0;
|
||||
}
|
||||
@@ -354,7 +362,7 @@ dword_result_t KeTlsFree(dword_t tls_index) {
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeTlsFree, kThreading, kImplemented);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms686812
|
||||
dword_result_t KeTlsGetValue(dword_t tls_index) {
|
||||
dword_result_t KeTlsGetValue_entry(dword_t tls_index) {
|
||||
// xboxkrnl doesn't actually have an error branch - it always succeeds, even
|
||||
// if it overflows the TLS.
|
||||
uint32_t value = 0;
|
||||
@@ -368,7 +376,7 @@ DECLARE_XBOXKRNL_EXPORT2(KeTlsGetValue, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms686818
|
||||
dword_result_t KeTlsSetValue(dword_t tls_index, dword_t tls_value) {
|
||||
dword_result_t KeTlsSetValue_entry(dword_t tls_index, dword_t tls_value) {
|
||||
// xboxkrnl doesn't actually have an error branch - it always succeeds, even
|
||||
// if it overflows the TLS.
|
||||
if (XThread::GetCurrentThread()->SetTLSValue(tls_index, tls_value)) {
|
||||
@@ -379,8 +387,8 @@ dword_result_t KeTlsSetValue(dword_t tls_index, dword_t tls_value) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeTlsSetValue, kThreading, kImplemented);
|
||||
|
||||
void KeInitializeEvent(pointer_t<X_KEVENT> event_ptr, dword_t event_type,
|
||||
dword_t initial_state) {
|
||||
void KeInitializeEvent_entry(pointer_t<X_KEVENT> event_ptr, dword_t event_type,
|
||||
dword_t initial_state) {
|
||||
event_ptr.Zero();
|
||||
event_ptr->header.type = event_type;
|
||||
event_ptr->header.signal_state = (uint32_t)initial_state;
|
||||
@@ -403,14 +411,14 @@ uint32_t xeKeSetEvent(X_KEVENT* event_ptr, uint32_t increment, uint32_t wait) {
|
||||
return ev->Set(increment, !!wait);
|
||||
}
|
||||
|
||||
dword_result_t KeSetEvent(pointer_t<X_KEVENT> event_ptr, dword_t increment,
|
||||
dword_t wait) {
|
||||
dword_result_t KeSetEvent_entry(pointer_t<X_KEVENT> event_ptr,
|
||||
dword_t increment, dword_t wait) {
|
||||
return xeKeSetEvent(event_ptr, increment, wait);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeSetEvent, kThreading, kImplemented, kHighFrequency);
|
||||
|
||||
dword_result_t KePulseEvent(pointer_t<X_KEVENT> event_ptr, dword_t increment,
|
||||
dword_t wait) {
|
||||
dword_result_t KePulseEvent_entry(pointer_t<X_KEVENT> event_ptr,
|
||||
dword_t increment, dword_t wait) {
|
||||
auto ev = XObject::GetNativeObject<XEvent>(kernel_state(), event_ptr);
|
||||
if (!ev) {
|
||||
assert_always();
|
||||
@@ -422,7 +430,7 @@ dword_result_t KePulseEvent(pointer_t<X_KEVENT> event_ptr, dword_t increment,
|
||||
DECLARE_XBOXKRNL_EXPORT2(KePulseEvent, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t KeResetEvent(pointer_t<X_KEVENT> event_ptr) {
|
||||
dword_result_t KeResetEvent_entry(pointer_t<X_KEVENT> event_ptr) {
|
||||
auto ev = XObject::GetNativeObject<XEvent>(kernel_state(), event_ptr);
|
||||
if (!ev) {
|
||||
assert_always();
|
||||
@@ -433,9 +441,9 @@ dword_result_t KeResetEvent(pointer_t<X_KEVENT> event_ptr) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeResetEvent, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtCreateEvent(lpdword_t handle_ptr,
|
||||
pointer_t<X_OBJECT_ATTRIBUTES> obj_attributes_ptr,
|
||||
dword_t event_type, dword_t initial_state) {
|
||||
dword_result_t NtCreateEvent_entry(
|
||||
lpdword_t handle_ptr, pointer_t<X_OBJECT_ATTRIBUTES> obj_attributes_ptr,
|
||||
dword_t event_type, dword_t initial_state) {
|
||||
// Check for an existing timer with the same name.
|
||||
auto existing_object =
|
||||
LookupNamedObject<XEvent>(kernel_state(), obj_attributes_ptr);
|
||||
@@ -482,12 +490,13 @@ uint32_t xeNtSetEvent(uint32_t handle, xe::be<uint32_t>* previous_state_ptr) {
|
||||
return result;
|
||||
}
|
||||
|
||||
dword_result_t NtSetEvent(dword_t handle, lpdword_t previous_state_ptr) {
|
||||
dword_result_t NtSetEvent_entry(dword_t handle, lpdword_t previous_state_ptr) {
|
||||
return xeNtSetEvent(handle, previous_state_ptr);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(NtSetEvent, kThreading, kImplemented, kHighFrequency);
|
||||
|
||||
dword_result_t NtPulseEvent(dword_t handle, lpdword_t previous_state_ptr) {
|
||||
dword_result_t NtPulseEvent_entry(dword_t handle,
|
||||
lpdword_t previous_state_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
auto ev = kernel_state()->object_table()->LookupObject<XEvent>(handle);
|
||||
@@ -518,13 +527,15 @@ uint32_t xeNtClearEvent(uint32_t handle) {
|
||||
return result;
|
||||
}
|
||||
|
||||
dword_result_t NtClearEvent(dword_t handle) { return xeNtClearEvent(handle); }
|
||||
dword_result_t NtClearEvent_entry(dword_t handle) {
|
||||
return xeNtClearEvent(handle);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(NtClearEvent, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff552150(v=vs.85).aspx
|
||||
void KeInitializeSemaphore(pointer_t<X_KSEMAPHORE> semaphore_ptr, dword_t count,
|
||||
dword_t limit) {
|
||||
void KeInitializeSemaphore_entry(pointer_t<X_KSEMAPHORE> semaphore_ptr,
|
||||
dword_t count, dword_t limit) {
|
||||
semaphore_ptr->header.type = 5; // SemaphoreObject
|
||||
semaphore_ptr->header.signal_state = (uint32_t)count;
|
||||
semaphore_ptr->limit = (uint32_t)limit;
|
||||
@@ -553,16 +564,16 @@ uint32_t xeKeReleaseSemaphore(X_KSEMAPHORE* semaphore_ptr, uint32_t increment,
|
||||
return sem->ReleaseSemaphore(adjustment);
|
||||
}
|
||||
|
||||
dword_result_t KeReleaseSemaphore(pointer_t<X_KSEMAPHORE> semaphore_ptr,
|
||||
dword_t increment, dword_t adjustment,
|
||||
dword_t wait) {
|
||||
dword_result_t KeReleaseSemaphore_entry(pointer_t<X_KSEMAPHORE> semaphore_ptr,
|
||||
dword_t increment, dword_t adjustment,
|
||||
dword_t wait) {
|
||||
return xeKeReleaseSemaphore(semaphore_ptr, increment, adjustment, wait);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeReleaseSemaphore, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtCreateSemaphore(lpdword_t handle_ptr,
|
||||
lpvoid_t obj_attributes_ptr, dword_t count,
|
||||
dword_t limit) {
|
||||
dword_result_t NtCreateSemaphore_entry(lpdword_t handle_ptr,
|
||||
lpvoid_t obj_attributes_ptr,
|
||||
dword_t count, dword_t limit) {
|
||||
// Check for an existing timer with the same name.
|
||||
auto existing_object =
|
||||
LookupNamedObject<XSemaphore>(kernel_state(), obj_attributes_ptr);
|
||||
@@ -594,8 +605,9 @@ dword_result_t NtCreateSemaphore(lpdword_t handle_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtCreateSemaphore, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtReleaseSemaphore(dword_t sem_handle, dword_t release_count,
|
||||
lpdword_t previous_count_ptr) {
|
||||
dword_result_t NtReleaseSemaphore_entry(dword_t sem_handle,
|
||||
dword_t release_count,
|
||||
lpdword_t previous_count_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
int32_t previous_count = 0;
|
||||
|
||||
@@ -612,11 +624,12 @@ dword_result_t NtReleaseSemaphore(dword_t sem_handle, dword_t release_count,
|
||||
|
||||
return result;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtReleaseSemaphore, kThreading, kImplemented);
|
||||
DECLARE_XBOXKRNL_EXPORT2(NtReleaseSemaphore, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t NtCreateMutant(lpdword_t handle_out,
|
||||
pointer_t<X_OBJECT_ATTRIBUTES> obj_attributes,
|
||||
dword_t initial_owner) {
|
||||
dword_result_t NtCreateMutant_entry(
|
||||
lpdword_t handle_out, pointer_t<X_OBJECT_ATTRIBUTES> obj_attributes,
|
||||
dword_t initial_owner) {
|
||||
// Check for an existing timer with the same name.
|
||||
auto existing_object = LookupNamedObject<XMutant>(
|
||||
kernel_state(), obj_attributes.guest_address());
|
||||
@@ -648,7 +661,7 @@ dword_result_t NtCreateMutant(lpdword_t handle_out,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtCreateMutant, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtReleaseMutant(dword_t mutant_handle, dword_t unknown) {
|
||||
dword_result_t NtReleaseMutant_entry(dword_t mutant_handle, dword_t unknown) {
|
||||
// This doesn't seem to be supported.
|
||||
// int32_t previous_count_ptr = SHIM_GET_ARG_32(2);
|
||||
|
||||
@@ -674,8 +687,9 @@ dword_result_t NtReleaseMutant(dword_t mutant_handle, dword_t unknown) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtReleaseMutant, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtCreateTimer(lpdword_t handle_ptr, lpvoid_t obj_attributes_ptr,
|
||||
dword_t timer_type) {
|
||||
dword_result_t NtCreateTimer_entry(lpdword_t handle_ptr,
|
||||
lpvoid_t obj_attributes_ptr,
|
||||
dword_t timer_type) {
|
||||
// timer_type = NotificationTimer (0) or SynchronizationTimer (1)
|
||||
|
||||
// Check for an existing timer with the same name.
|
||||
@@ -709,11 +723,11 @@ dword_result_t NtCreateTimer(lpdword_t handle_ptr, lpvoid_t obj_attributes_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtCreateTimer, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtSetTimerEx(dword_t timer_handle, lpqword_t due_time_ptr,
|
||||
lpvoid_t routine_ptr /*PTIMERAPCROUTINE*/,
|
||||
dword_t unk_one, lpvoid_t routine_arg,
|
||||
dword_t resume, dword_t period_ms,
|
||||
dword_t unk_zero) {
|
||||
dword_result_t NtSetTimerEx_entry(dword_t timer_handle, lpqword_t due_time_ptr,
|
||||
lpvoid_t routine_ptr /*PTIMERAPCROUTINE*/,
|
||||
dword_t unk_one, lpvoid_t routine_arg,
|
||||
dword_t resume, dword_t period_ms,
|
||||
dword_t unk_zero) {
|
||||
assert_true(unk_one == 1);
|
||||
assert_true(unk_zero == 0);
|
||||
|
||||
@@ -735,8 +749,8 @@ dword_result_t NtSetTimerEx(dword_t timer_handle, lpqword_t due_time_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtSetTimerEx, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtCancelTimer(dword_t timer_handle,
|
||||
lpdword_t current_state_ptr) {
|
||||
dword_result_t NtCancelTimer_entry(dword_t timer_handle,
|
||||
lpdword_t current_state_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
auto timer =
|
||||
@@ -771,9 +785,11 @@ uint32_t xeKeWaitForSingleObject(void* object_ptr, uint32_t wait_reason,
|
||||
return result;
|
||||
}
|
||||
|
||||
dword_result_t KeWaitForSingleObject(lpvoid_t object_ptr, dword_t wait_reason,
|
||||
dword_t processor_mode, dword_t alertable,
|
||||
lpqword_t timeout_ptr) {
|
||||
dword_result_t KeWaitForSingleObject_entry(lpvoid_t object_ptr,
|
||||
dword_t wait_reason,
|
||||
dword_t processor_mode,
|
||||
dword_t alertable,
|
||||
lpqword_t timeout_ptr) {
|
||||
uint64_t timeout = timeout_ptr ? static_cast<uint64_t>(*timeout_ptr) : 0u;
|
||||
return xeKeWaitForSingleObject(object_ptr, wait_reason, processor_mode,
|
||||
alertable, timeout_ptr ? &timeout : nullptr);
|
||||
@@ -781,9 +797,10 @@ dword_result_t KeWaitForSingleObject(lpvoid_t object_ptr, dword_t wait_reason,
|
||||
DECLARE_XBOXKRNL_EXPORT3(KeWaitForSingleObject, kThreading, kImplemented,
|
||||
kBlocking, kHighFrequency);
|
||||
|
||||
dword_result_t NtWaitForSingleObjectEx(dword_t object_handle, dword_t wait_mode,
|
||||
dword_t alertable,
|
||||
lpqword_t timeout_ptr) {
|
||||
dword_result_t NtWaitForSingleObjectEx_entry(dword_t object_handle,
|
||||
dword_t wait_mode,
|
||||
dword_t alertable,
|
||||
lpqword_t timeout_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
auto object =
|
||||
@@ -801,12 +818,10 @@ dword_result_t NtWaitForSingleObjectEx(dword_t object_handle, dword_t wait_mode,
|
||||
DECLARE_XBOXKRNL_EXPORT3(NtWaitForSingleObjectEx, kThreading, kImplemented,
|
||||
kBlocking, kHighFrequency);
|
||||
|
||||
dword_result_t KeWaitForMultipleObjects(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) {
|
||||
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) {
|
||||
assert_true(wait_type <= 1);
|
||||
|
||||
std::vector<object_ref<XObject>> objects;
|
||||
@@ -852,10 +867,9 @@ uint32_t xeNtWaitForMultipleObjectsEx(uint32_t count, xe::be<uint32_t>* handles,
|
||||
wait_type, 6, wait_mode, alertable, timeout_ptr);
|
||||
}
|
||||
|
||||
dword_result_t NtWaitForMultipleObjectsEx(dword_t count, lpdword_t handles,
|
||||
dword_t wait_type, dword_t wait_mode,
|
||||
dword_t alertable,
|
||||
lpqword_t timeout_ptr) {
|
||||
dword_result_t NtWaitForMultipleObjectsEx_entry(
|
||||
dword_t count, lpdword_t handles, dword_t wait_type, dword_t wait_mode,
|
||||
dword_t alertable, lpqword_t timeout_ptr) {
|
||||
uint64_t timeout = timeout_ptr ? static_cast<uint64_t>(*timeout_ptr) : 0u;
|
||||
return xeNtWaitForMultipleObjectsEx(count, handles, wait_type, wait_mode,
|
||||
alertable,
|
||||
@@ -864,10 +878,11 @@ dword_result_t NtWaitForMultipleObjectsEx(dword_t count, lpdword_t handles,
|
||||
DECLARE_XBOXKRNL_EXPORT3(NtWaitForMultipleObjectsEx, kThreading, kImplemented,
|
||||
kBlocking, kHighFrequency);
|
||||
|
||||
dword_result_t NtSignalAndWaitForSingleObjectEx(dword_t signal_handle,
|
||||
dword_t wait_handle,
|
||||
dword_t alertable, dword_t r6,
|
||||
lpqword_t timeout_ptr) {
|
||||
dword_result_t NtSignalAndWaitForSingleObjectEx_entry(dword_t signal_handle,
|
||||
dword_t wait_handle,
|
||||
dword_t alertable,
|
||||
dword_t r6,
|
||||
lpqword_t timeout_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
auto signal_object =
|
||||
@@ -907,7 +922,7 @@ uint32_t xeKeKfAcquireSpinLock(uint32_t* lock) {
|
||||
return old_irql;
|
||||
}
|
||||
|
||||
dword_result_t KfAcquireSpinLock(lpdword_t lock_ptr) {
|
||||
dword_result_t KfAcquireSpinLock_entry(lpdword_t lock_ptr) {
|
||||
auto lock = reinterpret_cast<uint32_t*>(lock_ptr.host_address());
|
||||
return xeKeKfAcquireSpinLock(lock);
|
||||
}
|
||||
@@ -923,14 +938,14 @@ void xeKeKfReleaseSpinLock(uint32_t* lock, dword_t old_irql) {
|
||||
xe::atomic_dec(lock);
|
||||
}
|
||||
|
||||
void KfReleaseSpinLock(lpdword_t lock_ptr, dword_t old_irql) {
|
||||
void KfReleaseSpinLock_entry(lpdword_t lock_ptr, dword_t old_irql) {
|
||||
auto lock = reinterpret_cast<uint32_t*>(lock_ptr.host_address());
|
||||
xeKeKfReleaseSpinLock(lock, old_irql);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KfReleaseSpinLock, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
void KeAcquireSpinLockAtRaisedIrql(lpdword_t lock_ptr) {
|
||||
void KeAcquireSpinLockAtRaisedIrql_entry(lpdword_t lock_ptr) {
|
||||
// Lock.
|
||||
auto lock = reinterpret_cast<uint32_t*>(lock_ptr.host_address());
|
||||
while (!xe::atomic_cas(0, 1, lock)) {
|
||||
@@ -941,7 +956,7 @@ void KeAcquireSpinLockAtRaisedIrql(lpdword_t lock_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT3(KeAcquireSpinLockAtRaisedIrql, kThreading,
|
||||
kImplemented, kBlocking, kHighFrequency);
|
||||
|
||||
dword_result_t KeTryToAcquireSpinLockAtRaisedIrql(lpdword_t lock_ptr) {
|
||||
dword_result_t KeTryToAcquireSpinLockAtRaisedIrql_entry(lpdword_t lock_ptr) {
|
||||
// Lock.
|
||||
auto lock = reinterpret_cast<uint32_t*>(lock_ptr.host_address());
|
||||
if (!xe::atomic_cas(0, 1, lock)) {
|
||||
@@ -952,7 +967,7 @@ dword_result_t KeTryToAcquireSpinLockAtRaisedIrql(lpdword_t lock_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT4(KeTryToAcquireSpinLockAtRaisedIrql, kThreading,
|
||||
kImplemented, kBlocking, kHighFrequency, kSketchy);
|
||||
|
||||
void KeReleaseSpinLockFromRaisedIrql(lpdword_t lock_ptr) {
|
||||
void KeReleaseSpinLockFromRaisedIrql_entry(lpdword_t lock_ptr) {
|
||||
// Unlock.
|
||||
auto lock = reinterpret_cast<uint32_t*>(lock_ptr.host_address());
|
||||
xe::atomic_dec(lock);
|
||||
@@ -960,26 +975,26 @@ void KeReleaseSpinLockFromRaisedIrql(lpdword_t lock_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeReleaseSpinLockFromRaisedIrql, kThreading,
|
||||
kImplemented, kHighFrequency);
|
||||
|
||||
void KeEnterCriticalRegion() {
|
||||
void KeEnterCriticalRegion_entry() {
|
||||
XThread::GetCurrentThread()->EnterCriticalRegion();
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeEnterCriticalRegion, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
void KeLeaveCriticalRegion() {
|
||||
void KeLeaveCriticalRegion_entry() {
|
||||
XThread::GetCurrentThread()->LeaveCriticalRegion();
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeLeaveCriticalRegion, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t KeRaiseIrqlToDpcLevel() {
|
||||
dword_result_t KeRaiseIrqlToDpcLevel_entry() {
|
||||
auto old_value = kernel_state()->processor()->RaiseIrql(cpu::Irql::DPC);
|
||||
return (uint32_t)old_value;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeRaiseIrqlToDpcLevel, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
void KfLowerIrql(dword_t old_value) {
|
||||
void KfLowerIrql_entry(dword_t old_value) {
|
||||
kernel_state()->processor()->LowerIrql(
|
||||
static_cast<cpu::Irql>((uint32_t)old_value));
|
||||
|
||||
@@ -987,9 +1002,9 @@ void KfLowerIrql(dword_t old_value) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KfLowerIrql, kThreading, kImplemented, kHighFrequency);
|
||||
|
||||
void NtQueueApcThread(dword_t thread_handle, lpvoid_t apc_routine,
|
||||
lpvoid_t apc_routine_context, lpvoid_t arg1,
|
||||
lpvoid_t arg2) {
|
||||
void NtQueueApcThread_entry(dword_t thread_handle, lpvoid_t apc_routine,
|
||||
lpvoid_t apc_routine_context, lpvoid_t arg1,
|
||||
lpvoid_t arg2) {
|
||||
auto thread =
|
||||
kernel_state()->object_table()->LookupObject<XThread>(thread_handle);
|
||||
|
||||
@@ -1007,10 +1022,10 @@ void NtQueueApcThread(dword_t thread_handle, lpvoid_t apc_routine,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtQueueApcThread, kThreading, kImplemented);
|
||||
|
||||
void KeInitializeApc(pointer_t<XAPC> apc, lpvoid_t thread_ptr,
|
||||
lpvoid_t kernel_routine, lpvoid_t rundown_routine,
|
||||
lpvoid_t normal_routine, dword_t processor_mode,
|
||||
lpvoid_t normal_context) {
|
||||
void KeInitializeApc_entry(pointer_t<XAPC> apc, lpvoid_t thread_ptr,
|
||||
lpvoid_t kernel_routine, lpvoid_t rundown_routine,
|
||||
lpvoid_t normal_routine, dword_t processor_mode,
|
||||
lpvoid_t normal_context) {
|
||||
apc->Initialize();
|
||||
apc->processor_mode = processor_mode;
|
||||
apc->thread_ptr = thread_ptr.guest_address();
|
||||
@@ -1022,8 +1037,9 @@ void KeInitializeApc(pointer_t<XAPC> apc, lpvoid_t thread_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeInitializeApc, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KeInsertQueueApc(pointer_t<XAPC> apc, lpvoid_t arg1,
|
||||
lpvoid_t arg2, dword_t priority_increment) {
|
||||
dword_result_t KeInsertQueueApc_entry(pointer_t<XAPC> apc, lpvoid_t arg1,
|
||||
lpvoid_t arg2,
|
||||
dword_t priority_increment) {
|
||||
auto thread = XObject::GetNativeObject<XThread>(
|
||||
kernel_state(),
|
||||
kernel_state()->memory()->TranslateVirtual(apc->thread_ptr));
|
||||
@@ -1057,7 +1073,7 @@ dword_result_t KeInsertQueueApc(pointer_t<XAPC> apc, lpvoid_t arg1,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeInsertQueueApc, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KeRemoveQueueApc(pointer_t<XAPC> apc) {
|
||||
dword_result_t KeRemoveQueueApc_entry(pointer_t<XAPC> apc) {
|
||||
bool result = false;
|
||||
|
||||
auto thread = XObject::GetNativeObject<XThread>(
|
||||
@@ -1087,8 +1103,8 @@ dword_result_t KeRemoveQueueApc(pointer_t<XAPC> apc) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeRemoveQueueApc, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KiApcNormalRoutineNop(dword_t unk0 /* output? */,
|
||||
dword_t unk1 /* 0x13 */) {
|
||||
dword_result_t KiApcNormalRoutineNop_entry(dword_t unk0 /* output? */,
|
||||
dword_t unk1 /* 0x13 */) {
|
||||
return 0;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KiApcNormalRoutineNop, kThreading, kStub);
|
||||
@@ -1103,7 +1119,8 @@ typedef struct {
|
||||
xe::be<uint32_t> arg2;
|
||||
} XDPC;
|
||||
|
||||
void KeInitializeDpc(pointer_t<XDPC> dpc, lpvoid_t routine, lpvoid_t context) {
|
||||
void KeInitializeDpc_entry(pointer_t<XDPC> dpc, lpvoid_t routine,
|
||||
lpvoid_t context) {
|
||||
// KDPC (maybe) 0x18 bytes?
|
||||
uint32_t type = 19; // DpcObject
|
||||
uint32_t importance = 0;
|
||||
@@ -1118,8 +1135,8 @@ void KeInitializeDpc(pointer_t<XDPC> dpc, lpvoid_t routine, lpvoid_t context) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeInitializeDpc, kThreading, kImplemented, kSketchy);
|
||||
|
||||
dword_result_t KeInsertQueueDpc(pointer_t<XDPC> dpc, dword_t arg1,
|
||||
dword_t arg2) {
|
||||
dword_result_t KeInsertQueueDpc_entry(pointer_t<XDPC> dpc, dword_t arg1,
|
||||
dword_t arg2) {
|
||||
assert_always("DPC does not dispatch yet; going to hang!");
|
||||
|
||||
uint32_t list_entry_ptr = dpc.guest_address() + 4;
|
||||
@@ -1143,7 +1160,7 @@ dword_result_t KeInsertQueueDpc(pointer_t<XDPC> dpc, dword_t arg1,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeInsertQueueDpc, kThreading, kStub, kSketchy);
|
||||
|
||||
dword_result_t KeRemoveQueueDpc(pointer_t<XDPC> dpc) {
|
||||
dword_result_t KeRemoveQueueDpc_entry(pointer_t<XDPC> dpc) {
|
||||
bool result = false;
|
||||
|
||||
uint32_t list_entry_ptr = dpc.guest_address() + 4;
|
||||
@@ -1171,18 +1188,18 @@ struct X_ERWLOCK {
|
||||
};
|
||||
static_assert_size(X_ERWLOCK, 0x38);
|
||||
|
||||
void ExInitializeReadWriteLock(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
void ExInitializeReadWriteLock_entry(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
lock_ptr->lock_count = -1;
|
||||
lock_ptr->writers_waiting_count = 0;
|
||||
lock_ptr->readers_waiting_count = 0;
|
||||
lock_ptr->readers_entry_count = 0;
|
||||
KeInitializeEvent(&lock_ptr->writer_event, 1, 0);
|
||||
KeInitializeSemaphore(&lock_ptr->reader_semaphore, 0, 0x7FFFFFFF);
|
||||
KeInitializeEvent_entry(&lock_ptr->writer_event, 1, 0);
|
||||
KeInitializeSemaphore_entry(&lock_ptr->reader_semaphore, 0, 0x7FFFFFFF);
|
||||
lock_ptr->spin_lock = 0;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ExInitializeReadWriteLock, kThreading, kImplemented);
|
||||
|
||||
void ExAcquireReadWriteLockExclusive(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
void ExAcquireReadWriteLockExclusive_entry(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
auto old_irql = xeKeKfAcquireSpinLock(&lock_ptr->spin_lock);
|
||||
|
||||
int32_t lock_count = ++lock_ptr->lock_count;
|
||||
@@ -1199,7 +1216,7 @@ void ExAcquireReadWriteLockExclusive(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT2(ExAcquireReadWriteLockExclusive, kThreading,
|
||||
kImplemented, kBlocking);
|
||||
|
||||
dword_result_t ExTryToAcquireReadWriteLockExclusive(
|
||||
dword_result_t ExTryToAcquireReadWriteLockExclusive_entry(
|
||||
pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
auto old_irql = xeKeKfAcquireSpinLock(&lock_ptr->spin_lock);
|
||||
|
||||
@@ -1217,7 +1234,7 @@ dword_result_t ExTryToAcquireReadWriteLockExclusive(
|
||||
DECLARE_XBOXKRNL_EXPORT1(ExTryToAcquireReadWriteLockExclusive, kThreading,
|
||||
kImplemented);
|
||||
|
||||
void ExAcquireReadWriteLockShared(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
void ExAcquireReadWriteLockShared_entry(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
auto old_irql = xeKeKfAcquireSpinLock(&lock_ptr->spin_lock);
|
||||
|
||||
int32_t lock_count = ++lock_ptr->lock_count;
|
||||
@@ -1236,7 +1253,7 @@ void ExAcquireReadWriteLockShared(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT2(ExAcquireReadWriteLockShared, kThreading, kImplemented,
|
||||
kBlocking);
|
||||
|
||||
dword_result_t ExTryToAcquireReadWriteLockShared(
|
||||
dword_result_t ExTryToAcquireReadWriteLockShared_entry(
|
||||
pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
auto old_irql = xeKeKfAcquireSpinLock(&lock_ptr->spin_lock);
|
||||
|
||||
@@ -1256,7 +1273,7 @@ dword_result_t ExTryToAcquireReadWriteLockShared(
|
||||
DECLARE_XBOXKRNL_EXPORT1(ExTryToAcquireReadWriteLockShared, kThreading,
|
||||
kImplemented);
|
||||
|
||||
void ExReleaseReadWriteLock(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
void ExReleaseReadWriteLock_entry(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
auto old_irql = xeKeKfAcquireSpinLock(&lock_ptr->spin_lock);
|
||||
|
||||
int32_t lock_count = --lock_ptr->lock_count;
|
||||
@@ -1292,7 +1309,7 @@ void ExReleaseReadWriteLock(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT1(ExReleaseReadWriteLock, kThreading, kImplemented);
|
||||
|
||||
// NOTE: This function is very commonly inlined, and probably won't be called!
|
||||
pointer_result_t InterlockedPushEntrySList(
|
||||
pointer_result_t InterlockedPushEntrySList_entry(
|
||||
pointer_t<X_SLIST_HEADER> plist_ptr, pointer_t<X_SINGLE_LIST_ENTRY> entry) {
|
||||
assert_not_null(plist_ptr);
|
||||
assert_not_null(entry);
|
||||
@@ -1317,7 +1334,8 @@ pointer_result_t InterlockedPushEntrySList(
|
||||
DECLARE_XBOXKRNL_EXPORT2(InterlockedPushEntrySList, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
pointer_result_t InterlockedPopEntrySList(pointer_t<X_SLIST_HEADER> plist_ptr) {
|
||||
pointer_result_t InterlockedPopEntrySList_entry(
|
||||
pointer_t<X_SLIST_HEADER> plist_ptr) {
|
||||
assert_not_null(plist_ptr);
|
||||
|
||||
uint32_t popped = 0;
|
||||
@@ -1344,7 +1362,8 @@ pointer_result_t InterlockedPopEntrySList(pointer_t<X_SLIST_HEADER> plist_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT2(InterlockedPopEntrySList, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
pointer_result_t InterlockedFlushSList(pointer_t<X_SLIST_HEADER> plist_ptr) {
|
||||
pointer_result_t InterlockedFlushSList_entry(
|
||||
pointer_t<X_SLIST_HEADER> plist_ptr) {
|
||||
assert_not_null(plist_ptr);
|
||||
|
||||
alignas(8) X_SLIST_HEADER old_hdr = *plist_ptr;
|
||||
|
||||
Reference in New Issue
Block a user