[Kernel] Suffix export functions with _entry.

This commit is contained in:
gibbed 2022-01-09 11:14:40 -06:00 committed by Rick Gibbed
parent ce1a84375b
commit 3ad0a7dab2
40 changed files with 965 additions and 888 deletions

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2021 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. *
******************************************************************************
*/
@ -33,7 +33,7 @@ using PPCContext = xe::cpu::ppc::PPCContext;
#define SHIM_SET_MAPPING(library_name, export_name, shim_data) \
export_resolver->SetFunctionMapping( \
library_name, ordinals::export_name, \
(xe::cpu::xe_kernel_export_shim_fn)export_name##_shim);
(xe::cpu::xe_kernel_export_shim_fn)export_name##_entry);
#define SHIM_MEM_ADDR(a) \
((a) ? ppc_context->kernel_state->memory()->TranslateVirtual(a) : nullptr)
@ -559,7 +559,7 @@ using xe::cpu::ExportTag;
const auto EXPORT_##module_name##_##name = RegisterExport_##module_name( \
xe::kernel::shim::RegisterExport< \
xe::kernel::shim::KernelModuleId::module_name, ordinals::name>( \
&name, #name, \
&name##_entry, #name, \
tags | (static_cast<xe::cpu::ExportTag::type>( \
xe::cpu::ExportCategory::category) \
<< xe::cpu::ExportTag::CategoryShift)));

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2015 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. *
******************************************************************************
*/
@ -17,7 +17,7 @@ namespace xe {
namespace kernel {
namespace xam {
dword_result_t XamAvatarInitialize(
dword_result_t XamAvatarInitialize_entry(
dword_t unk1, // 1, 4, etc
dword_t unk2, // 0 or 1
dword_t processor_number, // for thread creation?
@ -30,7 +30,7 @@ dword_result_t XamAvatarInitialize(
}
DECLARE_XAM_EXPORT1(XamAvatarInitialize, kAvatars, kStub);
void XamAvatarShutdown() {
void XamAvatarShutdown_entry() {
// No-op.
}
DECLARE_XAM_EXPORT1(XamAvatarShutdown, kAvatars, kStub);

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2020 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. *
******************************************************************************
*/
@ -31,8 +31,8 @@ namespace xe {
namespace kernel {
namespace xam {
dword_result_t XamContentGetLicenseMask(lpdword_t mask_ptr,
lpunknown_t overlapped_ptr) {
dword_result_t XamContentGetLicenseMask_entry(lpdword_t mask_ptr,
lpunknown_t overlapped_ptr) {
// Each bit in the mask represents a granted license. Available licenses
// seems to vary from game to game, but most appear to use bit 0 to indicate
// if the game is purchased or not.
@ -48,9 +48,11 @@ dword_result_t XamContentGetLicenseMask(lpdword_t mask_ptr,
}
DECLARE_XAM_EXPORT2(XamContentGetLicenseMask, kContent, kStub, kHighFrequency);
dword_result_t XamContentResolve(dword_t user_index, lpvoid_t content_data_ptr,
lpunknown_t buffer_ptr, dword_t buffer_size,
dword_t unk1, dword_t unk2, dword_t unk3) {
dword_result_t XamContentResolve_entry(dword_t user_index,
lpvoid_t content_data_ptr,
lpunknown_t buffer_ptr,
dword_t buffer_size, dword_t unk1,
dword_t unk2, dword_t unk3) {
auto content_data = content_data_ptr.as<XCONTENT_DATA*>();
// Result of buffer_ptr is sent to RtlInitAnsiString.
@ -64,12 +66,10 @@ DECLARE_XAM_EXPORT1(XamContentResolve, kContent, kStub);
// https://github.com/MrColdbird/gameservice/blob/master/ContentManager.cpp
// https://github.com/LestaD/SourceEngine2007/blob/master/se2007/engine/xboxsystem.cpp#L499
dword_result_t XamContentCreateEnumerator(dword_t user_index, dword_t device_id,
dword_t content_type,
dword_t content_flags,
dword_t items_per_enumerate,
lpdword_t buffer_size_ptr,
lpdword_t handle_out) {
dword_result_t XamContentCreateEnumerator_entry(
dword_t user_index, dword_t device_id, dword_t content_type,
dword_t content_flags, dword_t items_per_enumerate,
lpdword_t buffer_size_ptr, lpdword_t handle_out) {
assert_not_null(handle_out);
auto device_info = device_id == 0 ? nullptr : GetDummyDeviceInfo(device_id);
@ -226,12 +226,10 @@ dword_result_t xeXamContentCreate(dword_t user_index, lpstring_t root_name,
}
}
dword_result_t XamContentCreateEx(dword_t user_index, lpstring_t root_name,
lpvoid_t content_data_ptr, dword_t flags,
lpdword_t disposition_ptr,
lpdword_t license_mask_ptr,
dword_t cache_size, qword_t content_size,
lpvoid_t overlapped_ptr) {
dword_result_t XamContentCreateEx_entry(
dword_t user_index, lpstring_t root_name, lpvoid_t content_data_ptr,
dword_t flags, lpdword_t disposition_ptr, lpdword_t license_mask_ptr,
dword_t cache_size, qword_t content_size, lpvoid_t overlapped_ptr) {
return xeXamContentCreate(user_index, root_name, content_data_ptr,
sizeof(XCONTENT_DATA), flags, disposition_ptr,
license_mask_ptr, cache_size, content_size,
@ -239,18 +237,18 @@ dword_result_t XamContentCreateEx(dword_t user_index, lpstring_t root_name,
}
DECLARE_XAM_EXPORT1(XamContentCreateEx, kContent, kImplemented);
dword_result_t XamContentCreate(dword_t user_index, lpstring_t root_name,
lpvoid_t content_data_ptr, dword_t flags,
lpdword_t disposition_ptr,
lpdword_t license_mask_ptr,
lpvoid_t overlapped_ptr) {
dword_result_t XamContentCreate_entry(dword_t user_index, lpstring_t root_name,
lpvoid_t content_data_ptr, dword_t flags,
lpdword_t disposition_ptr,
lpdword_t license_mask_ptr,
lpvoid_t overlapped_ptr) {
return xeXamContentCreate(user_index, root_name, content_data_ptr,
sizeof(XCONTENT_DATA), flags, disposition_ptr,
license_mask_ptr, 0, 0, overlapped_ptr);
}
DECLARE_XAM_EXPORT1(XamContentCreate, kContent, kImplemented);
dword_result_t XamContentCreateInternal(
dword_result_t XamContentCreateInternal_entry(
lpstring_t root_name, lpvoid_t content_data_ptr, dword_t flags,
lpdword_t disposition_ptr, lpdword_t license_mask_ptr, dword_t cache_size,
qword_t content_size, lpvoid_t overlapped_ptr) {
@ -261,18 +259,19 @@ dword_result_t XamContentCreateInternal(
}
DECLARE_XAM_EXPORT1(XamContentCreateInternal, kContent, kImplemented);
dword_result_t XamContentOpenFile(dword_t user_index, lpstring_t root_name,
lpstring_t path, dword_t flags,
lpdword_t disposition_ptr,
lpdword_t license_mask_ptr,
lpvoid_t overlapped_ptr) {
dword_result_t XamContentOpenFile_entry(dword_t user_index,
lpstring_t root_name, lpstring_t path,
dword_t flags,
lpdword_t disposition_ptr,
lpdword_t license_mask_ptr,
lpvoid_t overlapped_ptr) {
// TODO(gibbed): arguments assumed based on XamContentCreate.
return X_ERROR_FILE_NOT_FOUND;
}
DECLARE_XAM_EXPORT1(XamContentOpenFile, kContent, kStub);
dword_result_t XamContentFlush(lpstring_t root_name,
lpunknown_t overlapped_ptr) {
dword_result_t XamContentFlush_entry(lpstring_t root_name,
lpunknown_t overlapped_ptr) {
X_RESULT result = X_ERROR_SUCCESS;
if (overlapped_ptr) {
kernel_state()->CompleteOverlappedImmediate(overlapped_ptr, result);
@ -283,8 +282,8 @@ dword_result_t XamContentFlush(lpstring_t root_name,
}
DECLARE_XAM_EXPORT1(XamContentFlush, kContent, kStub);
dword_result_t XamContentClose(lpstring_t root_name,
lpunknown_t overlapped_ptr) {
dword_result_t XamContentClose_entry(lpstring_t root_name,
lpunknown_t overlapped_ptr) {
// Closes a previously opened root from XamContentCreate*.
auto result =
kernel_state()->content_manager()->CloseContent(root_name.value());
@ -298,11 +297,11 @@ dword_result_t XamContentClose(lpstring_t root_name,
}
DECLARE_XAM_EXPORT1(XamContentClose, kContent, kImplemented);
dword_result_t XamContentGetCreator(dword_t user_index,
lpvoid_t content_data_ptr,
lpdword_t is_creator_ptr,
lpqword_t creator_xuid_ptr,
lpunknown_t overlapped_ptr) {
dword_result_t XamContentGetCreator_entry(dword_t user_index,
lpvoid_t content_data_ptr,
lpdword_t is_creator_ptr,
lpqword_t creator_xuid_ptr,
lpunknown_t overlapped_ptr) {
auto result = X_ERROR_SUCCESS;
XCONTENT_AGGREGATE_DATA content_data = *content_data_ptr.as<XCONTENT_DATA*>();
@ -336,11 +335,11 @@ dword_result_t XamContentGetCreator(dword_t user_index,
}
DECLARE_XAM_EXPORT1(XamContentGetCreator, kContent, kImplemented);
dword_result_t XamContentGetThumbnail(dword_t user_index,
lpvoid_t content_data_ptr,
lpvoid_t buffer_ptr,
lpdword_t buffer_size_ptr,
lpunknown_t overlapped_ptr) {
dword_result_t XamContentGetThumbnail_entry(dword_t user_index,
lpvoid_t content_data_ptr,
lpvoid_t buffer_ptr,
lpdword_t buffer_size_ptr,
lpunknown_t overlapped_ptr) {
assert_not_null(buffer_size_ptr);
uint32_t buffer_size = *buffer_size_ptr;
XCONTENT_AGGREGATE_DATA content_data = *content_data_ptr.as<XCONTENT_DATA*>();
@ -375,10 +374,11 @@ dword_result_t XamContentGetThumbnail(dword_t user_index,
}
DECLARE_XAM_EXPORT1(XamContentGetThumbnail, kContent, kImplemented);
dword_result_t XamContentSetThumbnail(dword_t user_index,
lpvoid_t content_data_ptr,
lpvoid_t buffer_ptr, dword_t buffer_size,
lpunknown_t overlapped_ptr) {
dword_result_t XamContentSetThumbnail_entry(dword_t user_index,
lpvoid_t content_data_ptr,
lpvoid_t buffer_ptr,
dword_t buffer_size,
lpunknown_t overlapped_ptr) {
XCONTENT_AGGREGATE_DATA content_data = *content_data_ptr.as<XCONTENT_DATA*>();
// Buffer is PNG data.
@ -396,8 +396,9 @@ dword_result_t XamContentSetThumbnail(dword_t user_index,
}
DECLARE_XAM_EXPORT1(XamContentSetThumbnail, kContent, kImplemented);
dword_result_t XamContentDelete(dword_t user_index, lpvoid_t content_data_ptr,
lpunknown_t overlapped_ptr) {
dword_result_t XamContentDelete_entry(dword_t user_index,
lpvoid_t content_data_ptr,
lpunknown_t overlapped_ptr) {
XCONTENT_AGGREGATE_DATA content_data = *content_data_ptr.as<XCONTENT_DATA*>();
auto result = kernel_state()->content_manager()->DeleteContent(content_data);
@ -411,11 +412,11 @@ dword_result_t XamContentDelete(dword_t user_index, lpvoid_t content_data_ptr,
}
DECLARE_XAM_EXPORT1(XamContentDelete, kContent, kImplemented);
dword_result_t XamContentDeleteInternal(lpvoid_t content_data_ptr,
lpunknown_t overlapped_ptr) {
dword_result_t XamContentDeleteInternal_entry(lpvoid_t content_data_ptr,
lpunknown_t overlapped_ptr) {
// INFO: Analysis of xam.xex shows that "internal" functions are wrappers with
// 0xFE as user_index
return XamContentDelete(0xFE, content_data_ptr, overlapped_ptr);
return XamContentDelete_entry(0xFE, content_data_ptr, overlapped_ptr);
}
DECLARE_XAM_EXPORT1(XamContentDeleteInternal, kContent, kImplemented);

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2020 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. *
******************************************************************************
*/
@ -76,11 +76,11 @@ void AddODDContentTest(object_ref<XStaticEnumerator<XCONTENT_AGGREGATE_DATA>> e,
}
}
dword_result_t XamContentAggregateCreateEnumerator(qword_t xuid,
dword_t device_id,
dword_t content_type,
unknown_t unk3,
lpdword_t handle_out) {
dword_result_t XamContentAggregateCreateEnumerator_entry(qword_t xuid,
dword_t device_id,
dword_t content_type,
unknown_t unk3,
lpdword_t handle_out) {
assert_not_null(handle_out);
auto device_info = device_id == 0 ? nullptr : GetDummyDeviceInfo(device_id);

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2020 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. *
******************************************************************************
*/
@ -59,9 +59,9 @@ const DummyDeviceInfo* GetDummyDeviceInfo(uint32_t device_id) {
return it == end ? nullptr : *it;
}
dword_result_t XamContentGetDeviceName(dword_t device_id,
lpu16string_t name_buffer,
dword_t name_capacity) {
dword_result_t XamContentGetDeviceName_entry(dword_t device_id,
lpu16string_t name_buffer,
dword_t name_capacity) {
auto device_info = GetDummyDeviceInfo(device_id);
if (device_info == nullptr) {
return X_ERROR_DEVICE_NOT_CONNECTED;
@ -75,8 +75,8 @@ dword_result_t XamContentGetDeviceName(dword_t device_id,
}
DECLARE_XAM_EXPORT1(XamContentGetDeviceName, kContent, kImplemented);
dword_result_t XamContentGetDeviceState(dword_t device_id,
lpunknown_t overlapped_ptr) {
dword_result_t XamContentGetDeviceState_entry(dword_t device_id,
lpunknown_t overlapped_ptr) {
auto device_info = GetDummyDeviceInfo(device_id);
if (device_info == nullptr) {
if (overlapped_ptr) {
@ -110,7 +110,7 @@ typedef struct {
} X_CONTENT_DEVICE_DATA;
static_assert_size(X_CONTENT_DEVICE_DATA, 0x50);
dword_result_t XamContentGetDeviceData(
dword_result_t XamContentGetDeviceData_entry(
dword_t device_id, pointer_t<X_CONTENT_DEVICE_DATA> device_data) {
auto device_info = GetDummyDeviceInfo(device_id);
if (device_info == nullptr) {
@ -128,11 +128,11 @@ dword_result_t XamContentGetDeviceData(
}
DECLARE_XAM_EXPORT1(XamContentGetDeviceData, kContent, kImplemented);
dword_result_t XamContentCreateDeviceEnumerator(dword_t content_type,
dword_t content_flags,
dword_t max_count,
lpdword_t buffer_size_ptr,
lpdword_t handle_out) {
dword_result_t XamContentCreateDeviceEnumerator_entry(dword_t content_type,
dword_t content_flags,
dword_t max_count,
lpdword_t buffer_size_ptr,
lpdword_t handle_out) {
assert_not_null(handle_out);
if (buffer_size_ptr) {

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2021 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. *
******************************************************************************
*/
@ -69,9 +69,10 @@ uint32_t xeXamEnumerate(uint32_t handle, uint32_t flags, lpvoid_t buffer_ptr,
}
}
dword_result_t XamEnumerate(dword_t handle, dword_t flags, lpvoid_t buffer,
dword_t buffer_length, lpdword_t items_returned,
pointer_t<XAM_OVERLAPPED> overlapped) {
dword_result_t XamEnumerate_entry(dword_t handle, dword_t flags,
lpvoid_t buffer, dword_t buffer_length,
lpdword_t items_returned,
pointer_t<XAM_OVERLAPPED> overlapped) {
uint32_t dummy;
auto result = xeXamEnumerate(handle, flags, buffer, buffer_length,
!overlapped ? &dummy : nullptr, overlapped);
@ -82,16 +83,16 @@ dword_result_t XamEnumerate(dword_t handle, dword_t flags, lpvoid_t buffer,
}
DECLARE_XAM_EXPORT1(XamEnumerate, kNone, kImplemented);
dword_result_t XamCreateEnumeratorHandle(unknown_t unk1, unknown_t unk2,
unknown_t unk3, unknown_t unk4,
unknown_t unk5, unknown_t unk6,
unknown_t unk7, unknown_t unk8) {
dword_result_t XamCreateEnumeratorHandle_entry(unknown_t unk1, unknown_t unk2,
unknown_t unk3, unknown_t unk4,
unknown_t unk5, unknown_t unk6,
unknown_t unk7, unknown_t unk8) {
return X_ERROR_INVALID_PARAMETER;
}
DECLARE_XAM_EXPORT1(XamCreateEnumeratorHandle, kNone, kStub);
dword_result_t XamGetPrivateEnumStructureFromHandle(dword_t handle,
lpdword_t out_object_ptr) {
dword_result_t XamGetPrivateEnumStructureFromHandle_entry(
dword_t handle, lpdword_t out_object_ptr) {
auto e = kernel_state()->object_table()->LookupObject<XEnumerator>(handle);
if (!e) {
return X_STATUS_INVALID_HANDLE;

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2020 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. *
******************************************************************************
*/
@ -28,7 +28,7 @@ namespace xe {
namespace kernel {
namespace xam {
dword_result_t XamFeatureEnabled(dword_t unk) { return 0; }
dword_result_t XamFeatureEnabled_entry(dword_t unk) { return 0; }
DECLARE_XAM_EXPORT1(XamFeatureEnabled, kNone, kStub);
// Empty stub schema binary.
@ -39,7 +39,7 @@ uint8_t schema_bin[] = {
0x00, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
};
dword_result_t XamGetOnlineSchema() {
dword_result_t XamGetOnlineSchema_entry() {
static uint32_t schema_guest = 0;
if (!schema_guest) {
@ -70,8 +70,8 @@ static SYSTEMTIME xeGetLocalSystemTime(uint64_t filetime) {
}
#endif
void XamFormatDateString(dword_t unk, qword_t filetime, lpvoid_t output_buffer,
dword_t output_count) {
void XamFormatDateString_entry(dword_t unk, qword_t filetime,
lpvoid_t output_buffer, dword_t output_count) {
std::memset(output_buffer, 0, output_count * sizeof(char16_t));
// TODO: implement this for other platforms
@ -87,8 +87,8 @@ void XamFormatDateString(dword_t unk, qword_t filetime, lpvoid_t output_buffer,
}
DECLARE_XAM_EXPORT1(XamFormatDateString, kNone, kImplemented);
void XamFormatTimeString(dword_t unk, qword_t filetime, lpvoid_t output_buffer,
dword_t output_count) {
void XamFormatTimeString_entry(dword_t unk, qword_t filetime,
lpvoid_t output_buffer, dword_t output_count) {
std::memset(output_buffer, 0, output_count * sizeof(char16_t));
// TODO: implement this for other platforms
@ -124,18 +124,19 @@ dword_result_t keXamBuildResourceLocator(uint64_t module,
return 0;
}
dword_result_t XamBuildResourceLocator(qword_t module, lpu16string_t container,
lpu16string_t resource,
lpvoid_t buffer_ptr,
dword_t buffer_count) {
dword_result_t XamBuildResourceLocator_entry(qword_t module,
lpu16string_t container,
lpu16string_t resource,
lpvoid_t buffer_ptr,
dword_t buffer_count) {
return keXamBuildResourceLocator(module, container.value(), resource.value(),
buffer_ptr, buffer_count);
}
DECLARE_XAM_EXPORT1(XamBuildResourceLocator, kNone, kImplemented);
dword_result_t XamBuildGamercardResourceLocator(lpu16string_t filename,
lpvoid_t buffer_ptr,
dword_t buffer_count) {
dword_result_t XamBuildGamercardResourceLocator_entry(lpu16string_t filename,
lpvoid_t buffer_ptr,
dword_t buffer_count) {
// On an actual xbox these funcs would return a locator to xam.xex resources,
// but for Xenia we can return a locator to the resources as local files. (big
// thanks to MS for letting XamBuildResourceLocator return local file
@ -149,32 +150,32 @@ dword_result_t XamBuildGamercardResourceLocator(lpu16string_t filename,
}
DECLARE_XAM_EXPORT1(XamBuildGamercardResourceLocator, kNone, kImplemented);
dword_result_t XamBuildSharedSystemResourceLocator(lpu16string_t filename,
lpvoid_t buffer_ptr,
dword_t buffer_count) {
dword_result_t XamBuildSharedSystemResourceLocator_entry(lpu16string_t filename,
lpvoid_t buffer_ptr,
dword_t buffer_count) {
// see notes inside XamBuildGamercardResourceLocator above
return keXamBuildResourceLocator(0, u"shrdres", filename.value(), buffer_ptr,
buffer_count);
}
DECLARE_XAM_EXPORT1(XamBuildSharedSystemResourceLocator, kNone, kImplemented);
dword_result_t XamBuildLegacySystemResourceLocator(lpu16string_t filename,
lpvoid_t buffer_ptr,
dword_t buffer_count) {
return XamBuildSharedSystemResourceLocator(filename, buffer_ptr,
buffer_count);
dword_result_t XamBuildLegacySystemResourceLocator_entry(lpu16string_t filename,
lpvoid_t buffer_ptr,
dword_t buffer_count) {
return XamBuildSharedSystemResourceLocator_entry(filename, buffer_ptr,
buffer_count);
}
DECLARE_XAM_EXPORT1(XamBuildLegacySystemResourceLocator, kNone, kImplemented);
dword_result_t XamBuildXamResourceLocator(lpu16string_t filename,
lpvoid_t buffer_ptr,
dword_t buffer_count) {
dword_result_t XamBuildXamResourceLocator_entry(lpu16string_t filename,
lpvoid_t buffer_ptr,
dword_t buffer_count) {
return keXamBuildResourceLocator(0, u"xam", filename.value(), buffer_ptr,
buffer_count);
}
DECLARE_XAM_EXPORT1(XamBuildXamResourceLocator, kNone, kImplemented);
dword_result_t XamGetSystemVersion() {
dword_result_t XamGetSystemVersion_entry() {
// eh, just picking one. If we go too low we may break new games, but
// this value seems to be used for conditionally loading symbols and if
// we pretend to be old we have less to worry with implementing.
@ -184,12 +185,12 @@ dword_result_t XamGetSystemVersion() {
}
DECLARE_XAM_EXPORT1(XamGetSystemVersion, kNone, kStub);
void XCustomRegisterDynamicActions() {
void XCustomRegisterDynamicActions_entry() {
// ???
}
DECLARE_XAM_EXPORT1(XCustomRegisterDynamicActions, kNone, kStub);
dword_result_t XGetAVPack() {
dword_result_t XGetAVPack_entry() {
// DWORD
// Not sure what the values are for this, but 6 is VGA.
// Other likely values are 3/4/8 for HDMI or something.
@ -201,10 +202,10 @@ DECLARE_XAM_EXPORT1(XGetAVPack, kNone, kStub);
uint32_t xeXGetGameRegion() { return 0xFFFFu; }
dword_result_t XGetGameRegion() { return xeXGetGameRegion(); }
dword_result_t XGetGameRegion_entry() { return xeXGetGameRegion(); }
DECLARE_XAM_EXPORT1(XGetGameRegion, kNone, kStub);
dword_result_t XGetLanguage() {
dword_result_t XGetLanguage_entry() {
auto desired_language = XLanguage::kEnglish;
// Switch the language based on game region.
@ -221,7 +222,7 @@ dword_result_t XGetLanguage() {
}
DECLARE_XAM_EXPORT1(XGetLanguage, kNone, kImplemented);
dword_result_t XamGetExecutionId(lpdword_t info_ptr) {
dword_result_t XamGetExecutionId_entry(lpdword_t info_ptr) {
auto module = kernel_state()->GetExecutableModule();
assert_not_null(module);
@ -238,7 +239,7 @@ dword_result_t XamGetExecutionId(lpdword_t info_ptr) {
}
DECLARE_XAM_EXPORT1(XamGetExecutionId, kNone, kImplemented);
dword_result_t XamLoaderSetLaunchData(lpvoid_t data, dword_t size) {
dword_result_t XamLoaderSetLaunchData_entry(lpvoid_t data, dword_t size) {
auto xam = kernel_state()->GetKernelModule<XamModule>("xam.xex");
auto& loader_data = xam->loader_data();
loader_data.launch_data_present = size ? true : false;
@ -248,7 +249,7 @@ dword_result_t XamLoaderSetLaunchData(lpvoid_t data, dword_t size) {
}
DECLARE_XAM_EXPORT1(XamLoaderSetLaunchData, kNone, kSketchy);
dword_result_t XamLoaderGetLaunchDataSize(lpdword_t size_ptr) {
dword_result_t XamLoaderGetLaunchDataSize_entry(lpdword_t size_ptr) {
if (!size_ptr) {
return X_ERROR_INVALID_PARAMETER;
}
@ -265,8 +266,8 @@ dword_result_t XamLoaderGetLaunchDataSize(lpdword_t size_ptr) {
}
DECLARE_XAM_EXPORT1(XamLoaderGetLaunchDataSize, kNone, kSketchy);
dword_result_t XamLoaderGetLaunchData(lpvoid_t buffer_ptr,
dword_t buffer_size) {
dword_result_t XamLoaderGetLaunchData_entry(lpvoid_t buffer_ptr,
dword_t buffer_size) {
auto xam = kernel_state()->GetKernelModule<XamModule>("xam.xex");
auto& loader_data = xam->loader_data();
if (!loader_data.launch_data_present) {
@ -280,7 +281,7 @@ dword_result_t XamLoaderGetLaunchData(lpvoid_t buffer_ptr,
}
DECLARE_XAM_EXPORT1(XamLoaderGetLaunchData, kNone, kSketchy);
void XamLoaderLaunchTitle(lpstring_t raw_name_ptr, dword_t flags) {
void XamLoaderLaunchTitle_entry(lpstring_t raw_name_ptr, dword_t flags) {
auto xam = kernel_state()->GetKernelModule<XamModule>("xam.xex");
auto& loader_data = xam->loader_data();
@ -309,13 +310,13 @@ void XamLoaderLaunchTitle(lpstring_t raw_name_ptr, dword_t flags) {
}
DECLARE_XAM_EXPORT1(XamLoaderLaunchTitle, kNone, kSketchy);
void XamLoaderTerminateTitle() {
void XamLoaderTerminateTitle_entry() {
// This function does not return.
kernel_state()->TerminateTitle();
}
DECLARE_XAM_EXPORT1(XamLoaderTerminateTitle, kNone, kSketchy);
dword_result_t XamAlloc(dword_t unk, dword_t size, lpdword_t out_ptr) {
dword_result_t XamAlloc_entry(dword_t unk, dword_t size, lpdword_t out_ptr) {
assert_true(unk == 0);
// Allocate from the heap. Not sure why XAM does this specially, perhaps
@ -327,15 +328,16 @@ dword_result_t XamAlloc(dword_t unk, dword_t size, lpdword_t out_ptr) {
}
DECLARE_XAM_EXPORT1(XamAlloc, kMemory, kImplemented);
dword_result_t XamFree(lpdword_t ptr) {
dword_result_t XamFree_entry(lpdword_t ptr) {
kernel_state()->memory()->SystemHeapFree(ptr.guest_address());
return X_ERROR_SUCCESS;
}
DECLARE_XAM_EXPORT1(XamFree, kMemory, kImplemented);
dword_result_t XamQueryLiveHiveW(lpu16string_t name, lpvoid_t out_buf,
dword_t out_size, dword_t type /* guess */) {
dword_result_t XamQueryLiveHiveW_entry(lpu16string_t name, lpvoid_t out_buf,
dword_t out_size,
dword_t type /* guess */) {
return X_STATUS_INVALID_PARAMETER_1;
}
DECLARE_XAM_EXPORT1(XamQueryLiveHiveW, kNone, kStub);

View File

@ -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. *
******************************************************************************
*/
@ -28,19 +28,20 @@ using xe::hid::X_INPUT_VIBRATION;
constexpr uint32_t XINPUT_FLAG_GAMEPAD = 0x01;
constexpr uint32_t XINPUT_FLAG_ANY_USER = 1 << 30;
void XamResetInactivity() {
void XamResetInactivity_entry() {
// Do we need to do anything?
}
DECLARE_XAM_EXPORT1(XamResetInactivity, kInput, kStub);
dword_result_t XamEnableInactivityProcessing(dword_t unk, dword_t enable) {
dword_result_t XamEnableInactivityProcessing_entry(dword_t unk,
dword_t enable) {
return X_ERROR_SUCCESS;
}
DECLARE_XAM_EXPORT1(XamEnableInactivityProcessing, kInput, kStub);
// https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.reference.xinputgetcapabilities(v=vs.85).aspx
dword_result_t XamInputGetCapabilities(dword_t user_index, dword_t flags,
pointer_t<X_INPUT_CAPABILITIES> caps) {
dword_result_t XamInputGetCapabilities_entry(
dword_t user_index, dword_t flags, pointer_t<X_INPUT_CAPABILITIES> caps) {
if (!caps) {
return X_ERROR_BAD_ARGUMENTS;
}
@ -61,9 +62,9 @@ dword_result_t XamInputGetCapabilities(dword_t user_index, dword_t flags,
}
DECLARE_XAM_EXPORT1(XamInputGetCapabilities, kInput, kSketchy);
dword_result_t XamInputGetCapabilitiesEx(dword_t unk, dword_t user_index,
dword_t flags,
pointer_t<X_INPUT_CAPABILITIES> caps) {
dword_result_t XamInputGetCapabilitiesEx_entry(
dword_t unk, dword_t user_index, dword_t flags,
pointer_t<X_INPUT_CAPABILITIES> caps) {
if (!caps) {
return X_ERROR_BAD_ARGUMENTS;
}
@ -85,8 +86,8 @@ dword_result_t XamInputGetCapabilitiesEx(dword_t unk, dword_t user_index,
DECLARE_XAM_EXPORT1(XamInputGetCapabilitiesEx, kInput, kSketchy);
// https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.reference.xinputgetstate(v=vs.85).aspx
dword_result_t XamInputGetState(dword_t user_index, dword_t flags,
pointer_t<X_INPUT_STATE> input_state) {
dword_result_t XamInputGetState_entry(dword_t user_index, dword_t flags,
pointer_t<X_INPUT_STATE> input_state) {
// Games call this with a NULL state ptr, probably as a query.
if ((flags & 0xFF) && (flags & XINPUT_FLAG_GAMEPAD) == 0) {
@ -103,11 +104,11 @@ dword_result_t XamInputGetState(dword_t user_index, dword_t flags,
auto input_system = kernel_state()->emulator()->input_system();
return input_system->GetState(user_index, input_state);
}
DECLARE_XAM_EXPORT1(XamInputGetState, kInput, kImplemented);
DECLARE_XAM_EXPORT2(XamInputGetState, kInput, kImplemented, kHighFrequency);
// https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.reference.xinputsetstate(v=vs.85).aspx
dword_result_t XamInputSetState(dword_t user_index, dword_t unk,
pointer_t<X_INPUT_VIBRATION> vibration) {
dword_result_t XamInputSetState_entry(dword_t user_index, dword_t unk,
pointer_t<X_INPUT_VIBRATION> vibration) {
if (!vibration) {
return X_ERROR_BAD_ARGUMENTS;
}
@ -124,8 +125,8 @@ dword_result_t XamInputSetState(dword_t user_index, dword_t unk,
DECLARE_XAM_EXPORT1(XamInputSetState, kInput, kImplemented);
// https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.reference.xinputgetkeystroke(v=vs.85).aspx
dword_result_t XamInputGetKeystroke(dword_t user_index, dword_t flags,
pointer_t<X_INPUT_KEYSTROKE> keystroke) {
dword_result_t XamInputGetKeystroke_entry(
dword_t user_index, dword_t flags, pointer_t<X_INPUT_KEYSTROKE> keystroke) {
// https://github.com/CodeAsm/ffplay360/blob/master/Common/AtgXime.cpp
// user index = index or XUSER_INDEX_ANY
// flags = XINPUT_FLAG_GAMEPAD (| _ANYUSER | _ANYDEVICE)
@ -151,8 +152,9 @@ dword_result_t XamInputGetKeystroke(dword_t user_index, dword_t flags,
DECLARE_XAM_EXPORT1(XamInputGetKeystroke, kInput, kImplemented);
// Same as non-ex, just takes a pointer to user index.
dword_result_t XamInputGetKeystrokeEx(lpdword_t user_index_ptr, dword_t flags,
pointer_t<X_INPUT_KEYSTROKE> keystroke) {
dword_result_t XamInputGetKeystrokeEx_entry(
lpdword_t user_index_ptr, dword_t flags,
pointer_t<X_INPUT_KEYSTROKE> keystroke) {
if (!keystroke) {
return X_ERROR_BAD_ARGUMENTS;
}
@ -177,8 +179,9 @@ dword_result_t XamInputGetKeystrokeEx(lpdword_t user_index_ptr, dword_t flags,
}
DECLARE_XAM_EXPORT1(XamInputGetKeystrokeEx, kInput, kImplemented);
X_HRESULT_result_t XamUserGetDeviceContext(dword_t user_index, dword_t unk,
lpdword_t out_ptr) {
X_HRESULT_result_t XamUserGetDeviceContext_entry(dword_t user_index,
dword_t unk,
lpdword_t out_ptr) {
// Games check the result - usually with some masking.
// If this function fails they assume zero, so let's fail AND
// set zero just to be safe.

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2020 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. *
******************************************************************************
*/
@ -226,16 +226,19 @@ uint8_t xeXamGetLocale() { return xeXamGetLocaleEx(111, 43); }
// Exports.
dword_result_t XamGetLocale() { return xeXamGetLocale(); }
dword_result_t XamGetLocale_entry() {
return static_cast<uint8_t>(xeXamGetLocale());
}
DECLARE_XAM_EXPORT1(XamGetLocale, kLocale, kImplemented);
dword_result_t XamGetOnlineCountryFromLocale(dword_t id) {
dword_result_t XamGetOnlineCountryFromLocale_entry(dword_t id) {
return xeXamGetOnlineCountryFromLocale(id);
}
DECLARE_XAM_EXPORT1(XamGetOnlineCountryFromLocale, kLocale, kImplemented);
dword_result_t XamGetOnlineCountryString(dword_t id, dword_t buffer_length,
lpu16string_t buffer) {
dword_result_t XamGetOnlineCountryString_entry(dword_t id,
dword_t buffer_length,
lpu16string_t buffer) {
if (buffer_length >= 0x80000000u) {
return X_E_INVALIDARG;
}
@ -256,8 +259,8 @@ dword_result_t XamGetOnlineCountryString(dword_t id, dword_t buffer_length,
}
DECLARE_XAM_EXPORT1(XamGetOnlineCountryString, kLocale, kImplemented);
dword_result_t XamGetCountryString(dword_t id, dword_t buffer_length,
lpu16string_t buffer) {
dword_result_t XamGetCountryString_entry(dword_t id, dword_t buffer_length,
lpu16string_t buffer) {
if (buffer_length >= 0x80000000u) {
return X_E_INVALIDARG;
}
@ -278,8 +281,8 @@ dword_result_t XamGetCountryString(dword_t id, dword_t buffer_length,
}
DECLARE_XAM_EXPORT1(XamGetCountryString, kLocale, kImplemented);
dword_result_t XamGetLanguageString(dword_t id, dword_t buffer_length,
lpu16string_t buffer) {
dword_result_t XamGetLanguageString_entry(dword_t id, dword_t buffer_length,
lpu16string_t buffer) {
if (buffer_length >= 0x80000000u) {
return X_E_INVALIDARG;
}
@ -300,10 +303,10 @@ dword_result_t XamGetLanguageString(dword_t id, dword_t buffer_length,
}
DECLARE_XAM_EXPORT1(XamGetLanguageString, kLocale, kImplemented);
dword_result_t XamGetLanguageLocaleString(dword_t language_id,
dword_t locale_id,
dword_t buffer_length,
lpu16string_t buffer) {
dword_result_t XamGetLanguageLocaleString_entry(dword_t language_id,
dword_t locale_id,
dword_t buffer_length,
lpu16string_t buffer) {
if (buffer_length >= 0x80000000u) {
return X_E_INVALIDARG;
}
@ -330,10 +333,9 @@ dword_result_t XamGetLanguageLocaleString(dword_t language_id,
}
DECLARE_XAM_EXPORT1(XamGetLanguageLocaleString, kLocale, kImplemented);
dword_result_t XamGetOnlineLanguageAndCountryString(dword_t language_id,
dword_t country_id,
dword_t buffer_length,
lpu16string_t buffer) {
dword_result_t XamGetOnlineLanguageAndCountryString_entry(
dword_t language_id, dword_t country_id, dword_t buffer_length,
lpu16string_t buffer) {
if (buffer_length >= 0x80000000u) {
return X_E_INVALIDARG;
}
@ -363,8 +365,8 @@ dword_result_t XamGetOnlineLanguageAndCountryString(dword_t language_id,
DECLARE_XAM_EXPORT1(XamGetOnlineLanguageAndCountryString, kLocale,
kImplemented);
dword_result_t XamGetLocaleString(dword_t id, dword_t buffer_length,
lpu16string_t buffer) {
dword_result_t XamGetLocaleString_entry(dword_t id, dword_t buffer_length,
lpu16string_t buffer) {
if (buffer_length >= 0x80000000u) {
return X_E_INVALIDARG;
}
@ -385,18 +387,19 @@ dword_result_t XamGetLocaleString(dword_t id, dword_t buffer_length,
}
DECLARE_XAM_EXPORT1(XamGetLocaleString, kLocale, kImplemented);
dword_result_t XamGetLocaleFromOnlineCountry(dword_t id) {
dword_result_t XamGetLocaleFromOnlineCountry_entry(dword_t id) {
return xeXamGetLocaleFromOnlineCountry(static_cast<uint8_t>(id));
}
DECLARE_XAM_EXPORT1(XamGetLocaleFromOnlineCountry, kLocale, kImplemented);
dword_result_t XamGetLanguageFromOnlineLanguage(dword_t id) {
dword_result_t XamGetLanguageFromOnlineLanguage_entry(dword_t id) {
return xeXamGetLanguageFromOnlineLanguage(static_cast<uint8_t>(id));
}
DECLARE_XAM_EXPORT1(XamGetLanguageFromOnlineLanguage, kLocale, kImplemented);
dword_result_t XamGetOnlineLanguageString(dword_t id, dword_t buffer_length,
lpu16string_t buffer) {
dword_result_t XamGetOnlineLanguageString_entry(dword_t id,
dword_t buffer_length,
lpu16string_t buffer) {
if (buffer_length >= 0x80000000u) {
return X_E_INVALIDARG;
}
@ -417,12 +420,13 @@ dword_result_t XamGetOnlineLanguageString(dword_t id, dword_t buffer_length,
}
DECLARE_XAM_EXPORT1(XamGetOnlineLanguageString, kLocale, kImplemented);
dword_result_t XamGetCountryFromOnlineCountry(dword_t id) {
dword_result_t XamGetCountryFromOnlineCountry_entry(dword_t id) {
return xeXamGetCountryFromOnlineCountry(static_cast<uint8_t>(id));
}
DECLARE_XAM_EXPORT1(XamGetCountryFromOnlineCountry, kLocale, kImplemented);
dword_result_t XamGetLocaleEx(dword_t max_country_id, dword_t max_locale_id) {
dword_result_t XamGetLocaleEx_entry(dword_t max_country_id,
dword_t max_locale_id) {
return xeXamGetLocaleEx(static_cast<uint8_t>(max_country_id),
static_cast<uint8_t>(max_locale_id));
}

View File

@ -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. *
******************************************************************************
*/
@ -20,8 +20,8 @@ namespace xe {
namespace kernel {
namespace xam {
dword_result_t XMsgInProcessCall(dword_t app, dword_t message, dword_t arg1,
dword_t arg2) {
dword_result_t XMsgInProcessCall_entry(dword_t app, dword_t message,
dword_t arg1, dword_t arg2) {
auto result = kernel_state()->app_manager()->DispatchMessageSync(app, message,
arg1, arg2);
if (result == X_ERROR_NOT_FOUND) {
@ -31,8 +31,9 @@ dword_result_t XMsgInProcessCall(dword_t app, dword_t message, dword_t arg1,
}
DECLARE_XAM_EXPORT1(XMsgInProcessCall, kNone, kImplemented);
dword_result_t XMsgSystemProcessCall(dword_t app, dword_t message,
dword_t buffer, dword_t buffer_length) {
dword_result_t XMsgSystemProcessCall_entry(dword_t app, dword_t message,
dword_t buffer,
dword_t buffer_length) {
auto result = kernel_state()->app_manager()->DispatchMessageAsync(
app, message, buffer, buffer_length);
if (result == X_ERROR_NOT_FOUND) {
@ -68,7 +69,7 @@ X_HRESULT xeXMsgStartIORequestEx(uint32_t app, uint32_t message,
return result;
}
dword_result_t XMsgStartIORequestEx(
dword_result_t XMsgStartIORequestEx_entry(
dword_t app, dword_t message, pointer_t<XAM_OVERLAPPED> overlapped_ptr,
dword_t buffer_ptr, dword_t buffer_length,
pointer_t<XMSGSTARTIOREQUEST_UNKNOWNARG> unknown_ptr) {
@ -77,16 +78,16 @@ dword_result_t XMsgStartIORequestEx(
}
DECLARE_XAM_EXPORT1(XMsgStartIORequestEx, kNone, kImplemented);
dword_result_t XMsgStartIORequest(dword_t app, dword_t message,
pointer_t<XAM_OVERLAPPED> overlapped_ptr,
dword_t buffer_ptr, dword_t buffer_length) {
dword_result_t XMsgStartIORequest_entry(
dword_t app, dword_t message, pointer_t<XAM_OVERLAPPED> overlapped_ptr,
dword_t buffer_ptr, dword_t buffer_length) {
return xeXMsgStartIORequestEx(app, message, overlapped_ptr, buffer_ptr,
buffer_length, nullptr);
}
DECLARE_XAM_EXPORT1(XMsgStartIORequest, kNone, kImplemented);
dword_result_t XMsgCancelIORequest(pointer_t<XAM_OVERLAPPED> overlapped_ptr,
dword_t wait) {
dword_result_t XMsgCancelIORequest_entry(
pointer_t<XAM_OVERLAPPED> overlapped_ptr, dword_t wait) {
X_HANDLE event_handle = XOverlappedGetEvent(overlapped_ptr);
if (event_handle && wait) {
auto ev =
@ -100,17 +101,18 @@ dword_result_t XMsgCancelIORequest(pointer_t<XAM_OVERLAPPED> overlapped_ptr,
}
DECLARE_XAM_EXPORT1(XMsgCancelIORequest, kNone, kImplemented);
dword_result_t XMsgCompleteIORequest(pointer_t<XAM_OVERLAPPED> overlapped_ptr,
dword_t result, dword_t extended_error,
dword_t length) {
dword_result_t XMsgCompleteIORequest_entry(
pointer_t<XAM_OVERLAPPED> overlapped_ptr, dword_t result,
dword_t extended_error, dword_t length) {
kernel_state()->CompleteOverlappedImmediateEx(overlapped_ptr, result,
extended_error, length);
return X_ERROR_SUCCESS;
}
DECLARE_XAM_EXPORT2(XMsgCompleteIORequest, kNone, kImplemented, kSketchy);
dword_result_t XamGetOverlappedResult(pointer_t<XAM_OVERLAPPED> overlapped_ptr,
lpdword_t length_ptr, dword_t unknown) {
dword_result_t XamGetOverlappedResult_entry(
pointer_t<XAM_OVERLAPPED> overlapped_ptr, lpdword_t length_ptr,
dword_t unknown) {
uint32_t result;
if (overlapped_ptr->result != X_ERROR_IO_PENDING) {
result = overlapped_ptr->result;

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2021 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. *
******************************************************************************
*/
@ -169,8 +169,8 @@ struct XNetStartupParams {
XNetStartupParams xnet_startup_params = {0};
dword_result_t NetDll_XNetStartup(dword_t caller,
pointer_t<XNetStartupParams> params) {
dword_result_t NetDll_XNetStartup_entry(dword_t caller,
pointer_t<XNetStartupParams> params) {
if (params) {
assert_true(params->cfgSizeOfStruct == sizeof(XNetStartupParams));
std::memcpy(&xnet_startup_params, params, sizeof(XNetStartupParams));
@ -191,7 +191,7 @@ dword_result_t NetDll_XNetStartup(dword_t caller,
}
DECLARE_XAM_EXPORT1(NetDll_XNetStartup, kNetworking, kImplemented);
dword_result_t NetDll_XNetCleanup(dword_t caller, lpvoid_t params) {
dword_result_t NetDll_XNetCleanup_entry(dword_t caller, lpvoid_t params) {
auto xam = kernel_state()->GetKernelModule<XamModule>("xam.xex");
// auto xnet = xam->xnet();
// xam->set_xnet(nullptr);
@ -203,8 +203,9 @@ dword_result_t NetDll_XNetCleanup(dword_t caller, lpvoid_t params) {
}
DECLARE_XAM_EXPORT1(NetDll_XNetCleanup, kNetworking, kImplemented);
dword_result_t NetDll_XNetGetOpt(dword_t one, dword_t option_id,
lpvoid_t buffer_ptr, lpdword_t buffer_size) {
dword_result_t NetDll_XNetGetOpt_entry(dword_t one, dword_t option_id,
lpvoid_t buffer_ptr,
lpdword_t buffer_size) {
assert_true(one == 1);
switch (option_id) {
case 1:
@ -221,8 +222,8 @@ dword_result_t NetDll_XNetGetOpt(dword_t one, dword_t option_id,
}
DECLARE_XAM_EXPORT1(NetDll_XNetGetOpt, kNetworking, kSketchy);
dword_result_t NetDll_XNetRandom(dword_t caller, lpvoid_t buffer_ptr,
dword_t length) {
dword_result_t NetDll_XNetRandom_entry(dword_t caller, lpvoid_t buffer_ptr,
dword_t length) {
// For now, constant values.
// This makes replicating things easier.
std::memset(buffer_ptr, 0xBB, length);
@ -231,8 +232,8 @@ dword_result_t NetDll_XNetRandom(dword_t caller, lpvoid_t buffer_ptr,
}
DECLARE_XAM_EXPORT1(NetDll_XNetRandom, kNetworking, kStub);
dword_result_t NetDll_WSAStartup(dword_t caller, word_t version,
pointer_t<X_WSADATA> data_ptr) {
dword_result_t NetDll_WSAStartup_entry(dword_t caller, word_t version,
pointer_t<X_WSADATA> data_ptr) {
// TODO(benvanik): abstraction layer needed.
#ifdef XE_PLATFORM_WIN32
WSADATA wsaData;
@ -281,22 +282,22 @@ dword_result_t NetDll_WSAStartup(dword_t caller, word_t version,
}
DECLARE_XAM_EXPORT1(NetDll_WSAStartup, kNetworking, kImplemented);
dword_result_t NetDll_WSACleanup(dword_t caller) {
dword_result_t NetDll_WSACleanup_entry(dword_t caller) {
// This does nothing. Xenia needs WSA running.
return 0;
}
DECLARE_XAM_EXPORT1(NetDll_WSACleanup, kNetworking, kImplemented);
dword_result_t NetDll_WSAGetLastError() { return XThread::GetLastError(); }
dword_result_t NetDll_WSAGetLastError_entry() {
return XThread::GetLastError();
}
DECLARE_XAM_EXPORT1(NetDll_WSAGetLastError, kNetworking, kImplemented);
dword_result_t NetDll_WSARecvFrom(dword_t caller, dword_t socket,
pointer_t<XWSABUF> buffers_ptr,
dword_t buffer_count,
lpdword_t num_bytes_recv, lpdword_t flags_ptr,
pointer_t<XSOCKADDR_IN> from_addr,
pointer_t<XWSAOVERLAPPED> overlapped_ptr,
lpvoid_t completion_routine_ptr) {
dword_result_t NetDll_WSARecvFrom_entry(
dword_t caller, dword_t socket, pointer_t<XWSABUF> buffers_ptr,
dword_t buffer_count, lpdword_t num_bytes_recv, lpdword_t flags_ptr,
pointer_t<XSOCKADDR_IN> from_addr, pointer_t<XWSAOVERLAPPED> overlapped_ptr,
lpvoid_t completion_routine_ptr) {
if (overlapped_ptr) {
// auto evt = kernel_state()->object_table()->LookupObject<XEvent>(
// overlapped_ptr->event_handle);
@ -314,12 +315,11 @@ DECLARE_XAM_EXPORT2(NetDll_WSARecvFrom, kNetworking, kStub, kHighFrequency);
// If the socket is a VDP socket, buffer 0 is the game data length, and buffer 1
// is the unencrypted game data.
dword_result_t NetDll_WSASendTo(dword_t caller, dword_t socket_handle,
pointer_t<XWSABUF> buffers, dword_t num_buffers,
lpdword_t num_bytes_sent, dword_t flags,
pointer_t<XSOCKADDR_IN> to_ptr, dword_t to_len,
pointer_t<XWSAOVERLAPPED> overlapped,
lpvoid_t completion_routine) {
dword_result_t NetDll_WSASendTo_entry(
dword_t caller, dword_t socket_handle, pointer_t<XWSABUF> buffers,
dword_t num_buffers, lpdword_t num_bytes_sent, dword_t flags,
pointer_t<XSOCKADDR_IN> to_ptr, dword_t to_len,
pointer_t<XWSAOVERLAPPED> overlapped, lpvoid_t completion_routine) {
assert(!overlapped);
assert(!completion_routine);
@ -357,11 +357,11 @@ dword_result_t NetDll_WSASendTo(dword_t caller, dword_t socket_handle,
}
DECLARE_XAM_EXPORT1(NetDll_WSASendTo, kNetworking, kImplemented);
dword_result_t NetDll_WSAWaitForMultipleEvents(dword_t num_events,
lpdword_t events,
dword_t wait_all,
dword_t timeout,
dword_t alertable) {
dword_result_t NetDll_WSAWaitForMultipleEvents_entry(dword_t num_events,
lpdword_t events,
dword_t wait_all,
dword_t timeout,
dword_t alertable) {
if (num_events > 64) {
XThread::SetLastError(87); // ERROR_INVALID_PARAMETER
return ~0u;
@ -386,14 +386,14 @@ dword_result_t NetDll_WSAWaitForMultipleEvents(dword_t num_events,
DECLARE_XAM_EXPORT2(NetDll_WSAWaitForMultipleEvents, kNetworking, kImplemented,
kBlocking);
dword_result_t NetDll_WSACreateEvent() {
dword_result_t NetDll_WSACreateEvent_entry() {
XEvent* ev = new XEvent(kernel_state());
ev->Initialize(true, false);
return ev->handle();
}
DECLARE_XAM_EXPORT1(NetDll_WSACreateEvent, kNetworking, kImplemented);
dword_result_t NetDll_WSACloseEvent(dword_t event_handle) {
dword_result_t NetDll_WSACloseEvent_entry(dword_t event_handle) {
X_STATUS result = kernel_state()->object_table()->ReleaseHandle(event_handle);
if (XFAILED(result)) {
uint32_t error = xboxkrnl::xeRtlNtStatusToDosError(result);
@ -404,7 +404,7 @@ dword_result_t NetDll_WSACloseEvent(dword_t event_handle) {
}
DECLARE_XAM_EXPORT1(NetDll_WSACloseEvent, kNetworking, kImplemented);
dword_result_t NetDll_WSAResetEvent(dword_t event_handle) {
dword_result_t NetDll_WSAResetEvent_entry(dword_t event_handle) {
X_STATUS result = xboxkrnl::xeNtClearEvent(event_handle);
if (XFAILED(result)) {
uint32_t error = xboxkrnl::xeRtlNtStatusToDosError(result);
@ -415,7 +415,7 @@ dword_result_t NetDll_WSAResetEvent(dword_t event_handle) {
}
DECLARE_XAM_EXPORT1(NetDll_WSAResetEvent, kNetworking, kImplemented);
dword_result_t NetDll_WSASetEvent(dword_t event_handle) {
dword_result_t NetDll_WSASetEvent_entry(dword_t event_handle) {
X_STATUS result = xboxkrnl::xeNtSetEvent(event_handle, nullptr);
if (XFAILED(result)) {
uint32_t error = xboxkrnl::xeRtlNtStatusToDosError(result);
@ -449,8 +449,8 @@ struct XnAddrStatus {
static const uint32_t XNET_GET_XNADDR_TROUBLESHOOT = 0x00008000;
};
dword_result_t NetDll_XNetGetTitleXnAddr(dword_t caller,
pointer_t<XNADDR> addr_ptr) {
dword_result_t NetDll_XNetGetTitleXnAddr_entry(dword_t caller,
pointer_t<XNADDR> addr_ptr) {
// Just return a loopback address atm.
addr_ptr->ina.s_addr = htonl(INADDR_LOOPBACK);
addr_ptr->inaOnline.s_addr = 0;
@ -475,8 +475,8 @@ dword_result_t NetDll_XNetGetTitleXnAddr(dword_t caller,
}
DECLARE_XAM_EXPORT1(NetDll_XNetGetTitleXnAddr, kNetworking, kStub);
dword_result_t NetDll_XNetGetDebugXnAddr(dword_t caller,
pointer_t<XNADDR> addr_ptr) {
dword_result_t NetDll_XNetGetDebugXnAddr_entry(dword_t caller,
pointer_t<XNADDR> addr_ptr) {
addr_ptr.Zero();
// XNET_GET_XNADDR_NONE causes caller to gracefully return.
@ -484,41 +484,43 @@ dword_result_t NetDll_XNetGetDebugXnAddr(dword_t caller,
}
DECLARE_XAM_EXPORT1(NetDll_XNetGetDebugXnAddr, kNetworking, kStub);
dword_result_t NetDll_XNetXnAddrToMachineId(dword_t caller,
pointer_t<XNADDR> addr_ptr,
lpdword_t id_ptr) {
dword_result_t NetDll_XNetXnAddrToMachineId_entry(dword_t caller,
pointer_t<XNADDR> addr_ptr,
lpdword_t id_ptr) {
// Tell the caller we're not signed in to live (non-zero ret)
return 1;
}
DECLARE_XAM_EXPORT1(NetDll_XNetXnAddrToMachineId, kNetworking, kStub);
void NetDll_XNetInAddrToString(dword_t caller, dword_t in_addr,
lpstring_t string_out, dword_t string_size) {
void NetDll_XNetInAddrToString_entry(dword_t caller, dword_t in_addr,
lpstring_t string_out,
dword_t string_size) {
strncpy(string_out, "666.666.666.666", string_size);
}
DECLARE_XAM_EXPORT1(NetDll_XNetInAddrToString, kNetworking, kStub);
// This converts a XNet address to an IN_ADDR. The IN_ADDR is used for
// subsequent socket calls (like a handle to a XNet address)
dword_result_t NetDll_XNetXnAddrToInAddr(dword_t caller,
pointer_t<XNADDR> xn_addr,
lpvoid_t xid, lpvoid_t in_addr) {
dword_result_t NetDll_XNetXnAddrToInAddr_entry(dword_t caller,
pointer_t<XNADDR> xn_addr,
lpvoid_t xid, lpvoid_t in_addr) {
return 1;
}
DECLARE_XAM_EXPORT1(NetDll_XNetXnAddrToInAddr, kNetworking, kStub);
// Does the reverse of the above.
// FIXME: Arguments may not be correct.
dword_result_t NetDll_XNetInAddrToXnAddr(dword_t caller, lpvoid_t in_addr,
pointer_t<XNADDR> xn_addr,
lpvoid_t xid) {
dword_result_t NetDll_XNetInAddrToXnAddr_entry(dword_t caller, lpvoid_t in_addr,
pointer_t<XNADDR> xn_addr,
lpvoid_t xid) {
return 1;
}
DECLARE_XAM_EXPORT1(NetDll_XNetInAddrToXnAddr, kNetworking, kStub);
// https://www.google.com/patents/WO2008112448A1?cl=en
// Reserves a port for use by system link
dword_result_t NetDll_XNetSetSystemLinkPort(dword_t caller, dword_t port) {
dword_result_t NetDll_XNetSetSystemLinkPort_entry(dword_t caller,
dword_t port) {
return 1;
}
DECLARE_XAM_EXPORT1(NetDll_XNetSetSystemLinkPort, kNetworking, kStub);
@ -532,11 +534,14 @@ struct XEthernetStatus {
static const uint32_t XNET_ETHERNET_LINK_HALF_DUPLEX = 0x10;
};
dword_result_t NetDll_XNetGetEthernetLinkStatus(dword_t caller) { return 0; }
dword_result_t NetDll_XNetGetEthernetLinkStatus_entry(dword_t caller) {
return 0;
}
DECLARE_XAM_EXPORT1(NetDll_XNetGetEthernetLinkStatus, kNetworking, kStub);
dword_result_t NetDll_XNetDnsLookup(dword_t caller, lpstring_t host,
dword_t event_handle, lpdword_t pdns) {
dword_result_t NetDll_XNetDnsLookup_entry(dword_t caller, lpstring_t host,
dword_t event_handle,
lpdword_t pdns) {
// TODO(gibbed): actually implement this
if (pdns) {
auto dns_guest = kernel_memory()->SystemHeapAlloc(sizeof(XNDNS));
@ -554,7 +559,8 @@ dword_result_t NetDll_XNetDnsLookup(dword_t caller, lpstring_t host,
}
DECLARE_XAM_EXPORT1(NetDll_XNetDnsLookup, kNetworking, kStub);
dword_result_t NetDll_XNetDnsRelease(dword_t caller, pointer_t<XNDNS> dns) {
dword_result_t NetDll_XNetDnsRelease_entry(dword_t caller,
pointer_t<XNDNS> dns) {
if (!dns) {
return X_STATUS_INVALID_PARAMETER;
}
@ -563,9 +569,9 @@ dword_result_t NetDll_XNetDnsRelease(dword_t caller, pointer_t<XNDNS> dns) {
}
DECLARE_XAM_EXPORT1(NetDll_XNetDnsRelease, kNetworking, kStub);
dword_result_t NetDll_XNetQosServiceLookup(dword_t caller, dword_t flags,
dword_t event_handle,
lpdword_t pqos) {
dword_result_t NetDll_XNetQosServiceLookup_entry(dword_t caller, dword_t flags,
dword_t event_handle,
lpdword_t pqos) {
// Set pqos as some games will try accessing it despite non-successful result
if (pqos) {
auto qos_guest = kernel_memory()->SystemHeapAlloc(sizeof(XNQOS));
@ -583,7 +589,8 @@ dword_result_t NetDll_XNetQosServiceLookup(dword_t caller, dword_t flags,
}
DECLARE_XAM_EXPORT1(NetDll_XNetQosServiceLookup, kNetworking, kStub);
dword_result_t NetDll_XNetQosRelease(dword_t caller, pointer_t<XNQOS> qos) {
dword_result_t NetDll_XNetQosRelease_entry(dword_t caller,
pointer_t<XNQOS> qos) {
if (!qos) {
return X_STATUS_INVALID_PARAMETER;
}
@ -592,14 +599,14 @@ dword_result_t NetDll_XNetQosRelease(dword_t caller, pointer_t<XNQOS> qos) {
}
DECLARE_XAM_EXPORT1(NetDll_XNetQosRelease, kNetworking, kStub);
dword_result_t NetDll_XNetQosListen(dword_t caller, lpvoid_t id, lpvoid_t data,
dword_t data_size, dword_t r7,
dword_t flags) {
dword_result_t NetDll_XNetQosListen_entry(dword_t caller, lpvoid_t id,
lpvoid_t data, dword_t data_size,
dword_t r7, dword_t flags) {
return X_ERROR_FUNCTION_FAILED;
}
DECLARE_XAM_EXPORT1(NetDll_XNetQosListen, kNetworking, kStub);
dword_result_t NetDll_inet_addr(lpstring_t addr_ptr) {
dword_result_t NetDll_inet_addr_entry(lpstring_t addr_ptr) {
if (!addr_ptr) {
return -1;
}
@ -616,8 +623,8 @@ dword_result_t NetDll_inet_addr(lpstring_t addr_ptr) {
}
DECLARE_XAM_EXPORT1(NetDll_inet_addr, kNetworking, kImplemented);
dword_result_t NetDll_socket(dword_t caller, dword_t af, dword_t type,
dword_t protocol) {
dword_result_t NetDll_socket_entry(dword_t caller, dword_t af, dword_t type,
dword_t protocol) {
XSocket* socket = new XSocket(kernel_state());
X_STATUS result = socket->Initialize(XSocket::AddressFamily((uint32_t)af),
XSocket::Type((uint32_t)type),
@ -635,7 +642,7 @@ dword_result_t NetDll_socket(dword_t caller, dword_t af, dword_t type,
}
DECLARE_XAM_EXPORT1(NetDll_socket, kNetworking, kImplemented);
dword_result_t NetDll_closesocket(dword_t caller, dword_t socket_handle) {
dword_result_t NetDll_closesocket_entry(dword_t caller, dword_t socket_handle) {
auto socket =
kernel_state()->object_table()->LookupObject<XSocket>(socket_handle);
if (!socket) {
@ -652,7 +659,8 @@ dword_result_t NetDll_closesocket(dword_t caller, dword_t socket_handle) {
}
DECLARE_XAM_EXPORT1(NetDll_closesocket, kNetworking, kImplemented);
int_result_t NetDll_shutdown(dword_t caller, dword_t socket_handle, int_t how) {
int_result_t NetDll_shutdown_entry(dword_t caller, dword_t socket_handle,
int_t how) {
auto socket =
kernel_state()->object_table()->LookupObject<XSocket>(socket_handle);
if (!socket) {
@ -674,9 +682,9 @@ int_result_t NetDll_shutdown(dword_t caller, dword_t socket_handle, int_t how) {
}
DECLARE_XAM_EXPORT1(NetDll_shutdown, kNetworking, kImplemented);
dword_result_t NetDll_setsockopt(dword_t caller, dword_t socket_handle,
dword_t level, dword_t optname,
lpvoid_t optval_ptr, dword_t optlen) {
dword_result_t NetDll_setsockopt_entry(dword_t caller, dword_t socket_handle,
dword_t level, dword_t optname,
lpvoid_t optval_ptr, dword_t optlen) {
auto socket =
kernel_state()->object_table()->LookupObject<XSocket>(socket_handle);
if (!socket) {
@ -690,8 +698,8 @@ dword_result_t NetDll_setsockopt(dword_t caller, dword_t socket_handle,
}
DECLARE_XAM_EXPORT1(NetDll_setsockopt, kNetworking, kImplemented);
dword_result_t NetDll_ioctlsocket(dword_t caller, dword_t socket_handle,
dword_t cmd, lpvoid_t arg_ptr) {
dword_result_t NetDll_ioctlsocket_entry(dword_t caller, dword_t socket_handle,
dword_t cmd, lpvoid_t arg_ptr) {
auto socket =
kernel_state()->object_table()->LookupObject<XSocket>(socket_handle);
if (!socket) {
@ -711,8 +719,9 @@ dword_result_t NetDll_ioctlsocket(dword_t caller, dword_t socket_handle,
}
DECLARE_XAM_EXPORT1(NetDll_ioctlsocket, kNetworking, kImplemented);
dword_result_t NetDll_bind(dword_t caller, dword_t socket_handle,
pointer_t<XSOCKADDR_IN> name, dword_t namelen) {
dword_result_t NetDll_bind_entry(dword_t caller, dword_t socket_handle,
pointer_t<XSOCKADDR_IN> name,
dword_t namelen) {
auto socket =
kernel_state()->object_table()->LookupObject<XSocket>(socket_handle);
if (!socket) {
@ -732,8 +741,9 @@ dword_result_t NetDll_bind(dword_t caller, dword_t socket_handle,
}
DECLARE_XAM_EXPORT1(NetDll_bind, kNetworking, kImplemented);
dword_result_t NetDll_connect(dword_t caller, dword_t socket_handle,
pointer_t<XSOCKADDR> name, dword_t namelen) {
dword_result_t NetDll_connect_entry(dword_t caller, dword_t socket_handle,
pointer_t<XSOCKADDR> name,
dword_t namelen) {
auto socket =
kernel_state()->object_table()->LookupObject<XSocket>(socket_handle);
if (!socket) {
@ -753,8 +763,8 @@ dword_result_t NetDll_connect(dword_t caller, dword_t socket_handle,
}
DECLARE_XAM_EXPORT1(NetDll_connect, kNetworking, kImplemented);
dword_result_t NetDll_listen(dword_t caller, dword_t socket_handle,
int_t backlog) {
dword_result_t NetDll_listen_entry(dword_t caller, dword_t socket_handle,
int_t backlog) {
auto socket =
kernel_state()->object_table()->LookupObject<XSocket>(socket_handle);
if (!socket) {
@ -773,9 +783,9 @@ dword_result_t NetDll_listen(dword_t caller, dword_t socket_handle,
}
DECLARE_XAM_EXPORT1(NetDll_listen, kNetworking, kImplemented);
dword_result_t NetDll_accept(dword_t caller, dword_t socket_handle,
pointer_t<XSOCKADDR> addr_ptr,
lpdword_t addrlen_ptr) {
dword_result_t NetDll_accept_entry(dword_t caller, dword_t socket_handle,
pointer_t<XSOCKADDR> addr_ptr,
lpdword_t addrlen_ptr) {
if (!addr_ptr) {
// WSAEFAULT
XThread::SetLastError(0x271E);
@ -858,11 +868,11 @@ struct host_set {
}
};
int_result_t NetDll_select(int_t caller, int_t nfds,
pointer_t<x_fd_set> readfds,
pointer_t<x_fd_set> writefds,
pointer_t<x_fd_set> exceptfds,
lpvoid_t timeout_ptr) {
int_result_t NetDll_select_entry(int_t caller, int_t nfds,
pointer_t<x_fd_set> readfds,
pointer_t<x_fd_set> writefds,
pointer_t<x_fd_set> exceptfds,
lpvoid_t timeout_ptr) {
host_set host_readfds = {0};
fd_set native_readfds = {0};
if (readfds) {
@ -912,8 +922,9 @@ int_result_t NetDll_select(int_t caller, int_t nfds,
}
DECLARE_XAM_EXPORT1(NetDll_select, kNetworking, kImplemented);
dword_result_t NetDll_recv(dword_t caller, dword_t socket_handle,
lpvoid_t buf_ptr, dword_t buf_len, dword_t flags) {
dword_result_t NetDll_recv_entry(dword_t caller, dword_t socket_handle,
lpvoid_t buf_ptr, dword_t buf_len,
dword_t flags) {
auto socket =
kernel_state()->object_table()->LookupObject<XSocket>(socket_handle);
if (!socket) {
@ -926,10 +937,11 @@ dword_result_t NetDll_recv(dword_t caller, dword_t socket_handle,
}
DECLARE_XAM_EXPORT1(NetDll_recv, kNetworking, kImplemented);
dword_result_t NetDll_recvfrom(dword_t caller, dword_t socket_handle,
lpvoid_t buf_ptr, dword_t buf_len, dword_t flags,
pointer_t<XSOCKADDR_IN> from_ptr,
lpdword_t fromlen_ptr) {
dword_result_t NetDll_recvfrom_entry(dword_t caller, dword_t socket_handle,
lpvoid_t buf_ptr, dword_t buf_len,
dword_t flags,
pointer_t<XSOCKADDR_IN> from_ptr,
lpdword_t fromlen_ptr) {
auto socket =
kernel_state()->object_table()->LookupObject<XSocket>(socket_handle);
if (!socket) {
@ -970,8 +982,9 @@ dword_result_t NetDll_recvfrom(dword_t caller, dword_t socket_handle,
}
DECLARE_XAM_EXPORT1(NetDll_recvfrom, kNetworking, kImplemented);
dword_result_t NetDll_send(dword_t caller, dword_t socket_handle,
lpvoid_t buf_ptr, dword_t buf_len, dword_t flags) {
dword_result_t NetDll_send_entry(dword_t caller, dword_t socket_handle,
lpvoid_t buf_ptr, dword_t buf_len,
dword_t flags) {
auto socket =
kernel_state()->object_table()->LookupObject<XSocket>(socket_handle);
if (!socket) {
@ -984,9 +997,11 @@ dword_result_t NetDll_send(dword_t caller, dword_t socket_handle,
}
DECLARE_XAM_EXPORT1(NetDll_send, kNetworking, kImplemented);
dword_result_t NetDll_sendto(dword_t caller, dword_t socket_handle,
lpvoid_t buf_ptr, dword_t buf_len, dword_t flags,
pointer_t<XSOCKADDR_IN> to_ptr, dword_t to_len) {
dword_result_t NetDll_sendto_entry(dword_t caller, dword_t socket_handle,
lpvoid_t buf_ptr, dword_t buf_len,
dword_t flags,
pointer_t<XSOCKADDR_IN> to_ptr,
dword_t to_len) {
auto socket =
kernel_state()->object_table()->LookupObject<XSocket>(socket_handle);
if (!socket) {
@ -1000,8 +1015,8 @@ dword_result_t NetDll_sendto(dword_t caller, dword_t socket_handle,
}
DECLARE_XAM_EXPORT1(NetDll_sendto, kNetworking, kImplemented);
dword_result_t NetDll___WSAFDIsSet(dword_t socket_handle,
pointer_t<x_fd_set> fd_set) {
dword_result_t NetDll___WSAFDIsSet_entry(dword_t socket_handle,
pointer_t<x_fd_set> fd_set) {
for (uint32_t i = 0; i < fd_set->fd_count.value; i++) {
if (fd_set->fd_array[i] == socket_handle) {
return 1;
@ -1011,7 +1026,7 @@ dword_result_t NetDll___WSAFDIsSet(dword_t socket_handle,
}
DECLARE_XAM_EXPORT1(NetDll___WSAFDIsSet, kNetworking, kImplemented);
void NetDll_WSASetLastError(dword_t error_code) {
void NetDll_WSASetLastError_entry(dword_t error_code) {
XThread::SetLastError(error_code);
}
DECLARE_XAM_EXPORT1(NetDll_WSASetLastError, kNetworking, kImplemented);

View File

@ -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. *
******************************************************************************
*/
@ -36,20 +36,22 @@ uint32_t xeXamNotifyCreateListener(uint64_t mask, uint32_t is_system,
return handle;
}
dword_result_t XamNotifyCreateListener(qword_t mask, dword_t max_version) {
dword_result_t XamNotifyCreateListener_entry(qword_t mask,
dword_t max_version) {
return xeXamNotifyCreateListener(mask, 0, max_version);
}
DECLARE_XAM_EXPORT1(XamNotifyCreateListener, kNone, kImplemented);
dword_result_t XamNotifyCreateListenerInternal(qword_t mask, dword_t is_system,
dword_t max_version) {
dword_result_t XamNotifyCreateListenerInternal_entry(qword_t mask,
dword_t is_system,
dword_t max_version) {
return xeXamNotifyCreateListener(mask, is_system, max_version);
}
DECLARE_XAM_EXPORT1(XamNotifyCreateListenerInternal, kNone, kImplemented);
// https://github.com/CodeAsm/ffplay360/blob/master/Common/AtgSignIn.cpp
dword_result_t XNotifyGetNext(dword_t handle, dword_t match_id,
lpdword_t id_ptr, lpdword_t param_ptr) {
dword_result_t XNotifyGetNext_entry(dword_t handle, dword_t match_id,
lpdword_t id_ptr, lpdword_t param_ptr) {
if (param_ptr) {
*param_ptr = 0;
}
@ -89,13 +91,13 @@ dword_result_t XNotifyGetNext(dword_t handle, dword_t match_id,
}
DECLARE_XAM_EXPORT2(XNotifyGetNext, kNone, kImplemented, kHighFrequency);
dword_result_t XNotifyDelayUI(dword_t delay_ms) {
dword_result_t XNotifyDelayUI_entry(dword_t delay_ms) {
// Ignored.
return 0;
}
DECLARE_XAM_EXPORT1(XNotifyDelayUI, kNone, kStub);
void XNotifyPositionUI(dword_t position) {
void XNotifyPositionUI_entry(dword_t position) {
// Ignored.
}
DECLARE_XAM_EXPORT1(XNotifyPositionUI, kNone, kStub);

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2015 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. *
******************************************************************************
*/
@ -34,14 +34,14 @@ struct X_NUI_DEVICE_STATUS {
};
static_assert(sizeof(X_NUI_DEVICE_STATUS) == 24, "Size matters");
void XamNuiGetDeviceStatus(pointer_t<X_NUI_DEVICE_STATUS> status_ptr) {
void XamNuiGetDeviceStatus_entry(pointer_t<X_NUI_DEVICE_STATUS> status_ptr) {
status_ptr.Zero();
status_ptr->status = 0; // Not connected.
}
DECLARE_XAM_EXPORT1(XamNuiGetDeviceStatus, kNone, kStub);
dword_result_t XamShowNuiTroubleshooterUI(unknown_t unk1, unknown_t unk2,
unknown_t unk3) {
dword_result_t XamShowNuiTroubleshooterUI_entry(unknown_t unk1, unknown_t unk2,
unknown_t unk3) {
// unk1 is 0xFF - possibly user index?
// unk2, unk3 appear to always be zero.

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2021 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. *
******************************************************************************
*/
@ -16,24 +16,26 @@ namespace xe {
namespace kernel {
namespace xam {
dword_result_t XamPartyGetUserList(dword_t player_count, lpdword_t party_list) {
dword_result_t XamPartyGetUserList_entry(dword_t player_count,
lpdword_t party_list) {
// 5345085D wants specifically this code to skip loading party data.
// This code is not documented in NT_STATUS code list
return 0x807D0003;
}
DECLARE_XAM_EXPORT1(XamPartyGetUserList, kNone, kStub);
dword_result_t XamPartySendGameInvites(dword_t r3, dword_t r4, dword_t r5) {
dword_result_t XamPartySendGameInvites_entry(dword_t r3, dword_t r4,
dword_t r5) {
return X_ERROR_FUNCTION_FAILED;
}
DECLARE_XAM_EXPORT1(XamPartySendGameInvites, kNone, kStub);
dword_result_t XamPartySetCustomData(dword_t r3, dword_t r4, dword_t r5) {
dword_result_t XamPartySetCustomData_entry(dword_t r3, dword_t r4, dword_t r5) {
return X_ERROR_FUNCTION_FAILED;
}
DECLARE_XAM_EXPORT1(XamPartySetCustomData, kNone, kStub);
dword_result_t XamPartyGetBandwidth(dword_t r3, dword_t r4) {
dword_result_t XamPartyGetBandwidth_entry(dword_t r3, dword_t r4) {
return X_ERROR_FUNCTION_FAILED;
}
DECLARE_XAM_EXPORT1(XamPartyGetBandwidth, kNone, kStub);

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2020 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. *
******************************************************************************
*/
@ -39,9 +39,9 @@ struct XTASK_MESSAGE {
};
static_assert_size(XTASK_MESSAGE, 0x1C);
dword_result_t XamTaskSchedule(lpvoid_t callback,
pointer_t<XTASK_MESSAGE> message,
lpdword_t unknown, lpdword_t handle_ptr) {
dword_result_t XamTaskSchedule_entry(lpvoid_t callback,
pointer_t<XTASK_MESSAGE> message,
lpdword_t unknown, lpdword_t handle_ptr) {
// TODO(gibbed): figure out what this is for
*handle_ptr = 12345;
@ -69,7 +69,7 @@ dword_result_t XamTaskSchedule(lpvoid_t callback,
}
DECLARE_XAM_EXPORT2(XamTaskSchedule, kNone, kImplemented, kSketchy);
dword_result_t XamTaskShouldExit(dword_t r3) { return 0; }
dword_result_t XamTaskShouldExit_entry(dword_t r3) { return 0; }
DECLARE_XAM_EXPORT2(XamTaskShouldExit, kNone, kStub, kSketchy);
void RegisterTaskExports(xe::cpu::ExportResolver* export_resolver,

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2020 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. *
******************************************************************************
*/
@ -201,7 +201,7 @@ X_RESULT xeXamDispatchHeadlessEx(
}
}
dword_result_t XamIsUIActive() { return xeXamIsUIActive(); }
dword_result_t XamIsUIActive_entry() { return xeXamIsUIActive(); }
DECLARE_XAM_EXPORT2(XamIsUIActive, kUI, kImplemented, kHighFrequency);
class MessageBoxDialog : public XamDialog {
@ -263,11 +263,10 @@ class MessageBoxDialog : public XamDialog {
};
// https://www.se7ensins.com/forums/threads/working-xshowmessageboxui.844116/
dword_result_t XamShowMessageBoxUI(dword_t user_index, lpu16string_t title_ptr,
lpu16string_t text_ptr, dword_t button_count,
lpdword_t button_ptrs, dword_t active_button,
dword_t flags, lpdword_t result_ptr,
pointer_t<XAM_OVERLAPPED> overlapped) {
dword_result_t XamShowMessageBoxUI_entry(
dword_t user_index, lpu16string_t title_ptr, lpu16string_t text_ptr,
dword_t button_count, lpdword_t button_ptrs, dword_t active_button,
dword_t flags, lpdword_t result_ptr, pointer_t<XAM_OVERLAPPED> overlapped) {
std::string title;
if (title_ptr) {
title = xe::to_utf8(title_ptr.value());
@ -404,11 +403,10 @@ class KeyboardInputDialog : public XamDialog {
};
// https://www.se7ensins.com/forums/threads/release-how-to-use-xshowkeyboardui-release.906568/
dword_result_t XamShowKeyboardUI(dword_t user_index, dword_t flags,
lpu16string_t default_text,
lpu16string_t title, lpu16string_t description,
lpu16string_t buffer, dword_t buffer_length,
pointer_t<XAM_OVERLAPPED> overlapped) {
dword_result_t XamShowKeyboardUI_entry(
dword_t user_index, dword_t flags, lpu16string_t default_text,
lpu16string_t title, lpu16string_t description, lpu16string_t buffer,
dword_t buffer_length, pointer_t<XAM_OVERLAPPED> overlapped) {
if (!buffer) {
return X_ERROR_INVALID_PARAMETER;
}
@ -461,11 +459,10 @@ dword_result_t XamShowKeyboardUI(dword_t user_index, dword_t flags,
}
DECLARE_XAM_EXPORT1(XamShowKeyboardUI, kUI, kImplemented);
dword_result_t XamShowDeviceSelectorUI(dword_t user_index, dword_t content_type,
dword_t content_flags,
qword_t total_requested,
lpdword_t device_id_ptr,
pointer_t<XAM_OVERLAPPED> overlapped) {
dword_result_t XamShowDeviceSelectorUI_entry(
dword_t user_index, dword_t content_type, dword_t content_flags,
qword_t total_requested, lpdword_t device_id_ptr,
pointer_t<XAM_OVERLAPPED> overlapped) {
return xeXamDispatchHeadless(
[device_id_ptr]() -> X_RESULT {
// NOTE: 0x00000001 is our dummy device ID from xam_content.cc
@ -476,7 +473,7 @@ dword_result_t XamShowDeviceSelectorUI(dword_t user_index, dword_t content_type,
}
DECLARE_XAM_EXPORT1(XamShowDeviceSelectorUI, kUI, kImplemented);
void XamShowDirtyDiscErrorUI(dword_t user_index) {
void XamShowDirtyDiscErrorUI_entry(dword_t user_index) {
if (cvars::headless) {
assert_always();
exit(1);
@ -496,12 +493,12 @@ void XamShowDirtyDiscErrorUI(dword_t user_index) {
}
DECLARE_XAM_EXPORT1(XamShowDirtyDiscErrorUI, kUI, kImplemented);
dword_result_t XamShowPartyUI(unknown_t r3, unknown_t r4) {
dword_result_t XamShowPartyUI_entry(unknown_t r3, unknown_t r4) {
return X_ERROR_FUNCTION_FAILED;
}
DECLARE_XAM_EXPORT1(XamShowPartyUI, kNone, kStub);
dword_result_t XamShowCommunitySessionsUI(unknown_t r3, unknown_t r4) {
dword_result_t XamShowCommunitySessionsUI_entry(unknown_t r3, unknown_t r4) {
return X_ERROR_FUNCTION_FAILED;
}
DECLARE_XAM_EXPORT1(XamShowCommunitySessionsUI, kNone, kStub);

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2021 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. *
******************************************************************************
*/
@ -23,8 +23,8 @@ namespace xe {
namespace kernel {
namespace xam {
X_HRESULT_result_t XamUserGetXUID(dword_t user_index, dword_t type_mask,
lpqword_t xuid_ptr) {
X_HRESULT_result_t XamUserGetXUID_entry(dword_t user_index, dword_t type_mask,
lpqword_t xuid_ptr) {
assert_true(type_mask == 1 || type_mask == 2 || type_mask == 3 ||
type_mask == 4 || type_mask == 7);
if (!xuid_ptr) {
@ -54,7 +54,7 @@ X_HRESULT_result_t XamUserGetXUID(dword_t user_index, dword_t type_mask,
}
DECLARE_XAM_EXPORT1(XamUserGetXUID, kUserProfiles, kImplemented);
dword_result_t XamUserGetSigninState(dword_t user_index) {
dword_result_t XamUserGetSigninState_entry(dword_t user_index) {
// Yield, as some games spam this.
xe::threading::MaybeYield();
uint32_t signin_state = 0;
@ -79,8 +79,8 @@ typedef struct {
} X_USER_SIGNIN_INFO;
static_assert_size(X_USER_SIGNIN_INFO, 40);
X_HRESULT_result_t XamUserGetSigninInfo(dword_t user_index, dword_t flags,
pointer_t<X_USER_SIGNIN_INFO> info) {
X_HRESULT_result_t XamUserGetSigninInfo_entry(
dword_t user_index, dword_t flags, pointer_t<X_USER_SIGNIN_INFO> info) {
if (!info) {
return X_E_INVALIDARG;
}
@ -99,8 +99,8 @@ X_HRESULT_result_t XamUserGetSigninInfo(dword_t user_index, dword_t flags,
}
DECLARE_XAM_EXPORT1(XamUserGetSigninInfo, kUserProfiles, kImplemented);
dword_result_t XamUserGetName(dword_t user_index, lpstring_t buffer,
dword_t buffer_len) {
dword_result_t XamUserGetName_entry(dword_t user_index, lpstring_t buffer,
dword_t buffer_len) {
if (user_index >= 4) {
return X_E_INVALIDARG;
}
@ -117,8 +117,9 @@ dword_result_t XamUserGetName(dword_t user_index, lpstring_t buffer,
}
DECLARE_XAM_EXPORT1(XamUserGetName, kUserProfiles, kImplemented);
dword_result_t XamUserGetGamerTag(dword_t user_index, lpu16string_t buffer,
dword_t buffer_len) {
dword_result_t XamUserGetGamerTag_entry(dword_t user_index,
lpu16string_t buffer,
dword_t buffer_len) {
if (user_index >= 4) {
return X_E_INVALIDARG;
}
@ -304,7 +305,7 @@ uint32_t xeXamUserReadProfileSettingsEx(uint32_t title_id, uint32_t user_index,
return X_ERROR_SUCCESS;
}
dword_result_t XamUserReadProfileSettings(
dword_result_t XamUserReadProfileSettings_entry(
dword_t title_id, dword_t user_index, dword_t xuid_count, lpqword_t xuids,
dword_t setting_count, lpdword_t setting_ids, lpdword_t buffer_size_ptr,
lpvoid_t buffer_ptr, dword_t overlapped_ptr) {
@ -314,7 +315,7 @@ dword_result_t XamUserReadProfileSettings(
}
DECLARE_XAM_EXPORT1(XamUserReadProfileSettings, kUserProfiles, kImplemented);
dword_result_t XamUserReadProfileSettingsEx(
dword_result_t XamUserReadProfileSettingsEx_entry(
dword_t title_id, dword_t user_index, dword_t xuid_count, lpqword_t xuids,
dword_t setting_count, lpdword_t setting_ids, lpdword_t buffer_size_ptr,
dword_t unk_2, lpvoid_t buffer_ptr, dword_t overlapped_ptr) {
@ -347,7 +348,7 @@ typedef struct {
};
} X_USER_WRITE_PROFILE_SETTING;
dword_result_t XamUserWriteProfileSettings(
dword_result_t XamUserWriteProfileSettings_entry(
dword_t title_id, dword_t user_index, dword_t setting_count,
pointer_t<X_USER_WRITE_PROFILE_SETTING> settings, dword_t overlapped_ptr) {
if (!setting_count || !settings) {
@ -423,8 +424,8 @@ dword_result_t XamUserWriteProfileSettings(
}
DECLARE_XAM_EXPORT1(XamUserWriteProfileSettings, kUserProfiles, kImplemented);
dword_result_t XamUserCheckPrivilege(dword_t user_index, dword_t mask,
lpdword_t out_value) {
dword_result_t XamUserCheckPrivilege_entry(dword_t user_index, dword_t mask,
lpdword_t out_value) {
// checking all users?
if (user_index != 0xFF) {
if (user_index >= 4) {
@ -442,8 +443,8 @@ dword_result_t XamUserCheckPrivilege(dword_t user_index, dword_t mask,
}
DECLARE_XAM_EXPORT1(XamUserCheckPrivilege, kUserProfiles, kStub);
dword_result_t XamUserContentRestrictionGetFlags(dword_t user_index,
lpdword_t out_flags) {
dword_result_t XamUserContentRestrictionGetFlags_entry(dword_t user_index,
lpdword_t out_flags) {
if (user_index) {
return X_ERROR_NO_SUCH_USER;
}
@ -454,10 +455,10 @@ dword_result_t XamUserContentRestrictionGetFlags(dword_t user_index,
}
DECLARE_XAM_EXPORT1(XamUserContentRestrictionGetFlags, kUserProfiles, kStub);
dword_result_t XamUserContentRestrictionGetRating(dword_t user_index,
dword_t unk1,
lpdword_t out_unk2,
lpdword_t out_unk3) {
dword_result_t XamUserContentRestrictionGetRating_entry(dword_t user_index,
dword_t unk1,
lpdword_t out_unk2,
lpdword_t out_unk3) {
if (user_index) {
return X_ERROR_NO_SUCH_USER;
}
@ -470,11 +471,9 @@ dword_result_t XamUserContentRestrictionGetRating(dword_t user_index,
}
DECLARE_XAM_EXPORT1(XamUserContentRestrictionGetRating, kUserProfiles, kStub);
dword_result_t XamUserContentRestrictionCheckAccess(dword_t user_index,
dword_t unk1, dword_t unk2,
dword_t unk3, dword_t unk4,
lpdword_t out_unk5,
dword_t overlapped_ptr) {
dword_result_t XamUserContentRestrictionCheckAccess_entry(
dword_t user_index, dword_t unk1, dword_t unk2, dword_t unk3, dword_t unk4,
lpdword_t out_unk5, dword_t overlapped_ptr) {
*out_unk5 = 1;
if (overlapped_ptr) {
@ -487,10 +486,10 @@ dword_result_t XamUserContentRestrictionCheckAccess(dword_t user_index,
}
DECLARE_XAM_EXPORT1(XamUserContentRestrictionCheckAccess, kUserProfiles, kStub);
dword_result_t XamUserIsOnlineEnabled(dword_t user_index) { return 1; }
dword_result_t XamUserIsOnlineEnabled_entry(dword_t user_index) { return 1; }
DECLARE_XAM_EXPORT1(XamUserIsOnlineEnabled, kUserProfiles, kStub);
dword_result_t XamUserGetMembershipTier(dword_t user_index) {
dword_result_t XamUserGetMembershipTier_entry(dword_t user_index) {
if (user_index >= 4) {
return X_ERROR_INVALID_PARAMETER;
}
@ -501,9 +500,9 @@ dword_result_t XamUserGetMembershipTier(dword_t user_index) {
}
DECLARE_XAM_EXPORT1(XamUserGetMembershipTier, kUserProfiles, kStub);
dword_result_t XamUserAreUsersFriends(dword_t user_index, dword_t unk1,
dword_t unk2, lpdword_t out_value,
dword_t overlapped_ptr) {
dword_result_t XamUserAreUsersFriends_entry(dword_t user_index, dword_t unk1,
dword_t unk2, lpdword_t out_value,
dword_t overlapped_ptr) {
uint32_t are_friends = 0;
X_RESULT result;
@ -545,7 +544,7 @@ dword_result_t XamUserAreUsersFriends(dword_t user_index, dword_t unk1,
}
DECLARE_XAM_EXPORT1(XamUserAreUsersFriends, kUserProfiles, kStub);
dword_result_t XamShowSigninUI(dword_t unk, dword_t unk_mask) {
dword_result_t XamShowSigninUI_entry(dword_t unk, dword_t unk_mask) {
// Mask values vary. Probably matching user types? Local/remote?
// To fix game modes that display a 4 profile signin UI (even if playing
@ -676,12 +675,10 @@ class XStaticAchievementEnumerator : public XEnumerator {
size_t current_item_ = 0;
};
dword_result_t XamUserCreateAchievementEnumerator(dword_t title_id,
dword_t user_index,
dword_t xuid, dword_t flags,
dword_t offset, dword_t count,
lpdword_t buffer_size_ptr,
lpdword_t handle_ptr) {
dword_result_t XamUserCreateAchievementEnumerator_entry(
dword_t title_id, dword_t user_index, dword_t xuid, dword_t flags,
dword_t offset, dword_t count, lpdword_t buffer_size_ptr,
lpdword_t handle_ptr) {
if (!count || !buffer_size_ptr || !handle_ptr) {
return X_ERROR_INVALID_PARAMETER;
}
@ -727,8 +724,9 @@ dword_result_t XamUserCreateAchievementEnumerator(dword_t title_id,
DECLARE_XAM_EXPORT1(XamUserCreateAchievementEnumerator, kUserProfiles,
kSketchy);
dword_result_t XamParseGamerTileKey(lpdword_t key_ptr, lpdword_t out1_ptr,
lpdword_t out2_ptr, lpdword_t out3_ptr) {
dword_result_t XamParseGamerTileKey_entry(lpdword_t key_ptr, lpdword_t out1_ptr,
lpdword_t out2_ptr,
lpdword_t out3_ptr) {
*out1_ptr = 0xC0DE0001;
*out2_ptr = 0xC0DE0002;
*out3_ptr = 0xC0DE0003;
@ -736,10 +734,11 @@ dword_result_t XamParseGamerTileKey(lpdword_t key_ptr, lpdword_t out1_ptr,
}
DECLARE_XAM_EXPORT1(XamParseGamerTileKey, kUserProfiles, kStub);
dword_result_t XamReadTileToTexture(dword_t unknown, dword_t title_id,
qword_t tile_id, dword_t user_index,
lpvoid_t buffer_ptr, dword_t stride,
dword_t height, dword_t overlapped_ptr) {
dword_result_t XamReadTileToTexture_entry(dword_t unknown, dword_t title_id,
qword_t tile_id, dword_t user_index,
lpvoid_t buffer_ptr, dword_t stride,
dword_t height,
dword_t overlapped_ptr) {
// TODO(gibbed): unknown=0,2,3,9
if (!tile_id) {
return X_ERROR_INVALID_PARAMETER;
@ -757,9 +756,9 @@ dword_result_t XamReadTileToTexture(dword_t unknown, dword_t title_id,
}
DECLARE_XAM_EXPORT1(XamReadTileToTexture, kUserProfiles, kStub);
dword_result_t XamWriteGamerTile(dword_t arg1, dword_t arg2, dword_t arg3,
dword_t arg4, dword_t arg5,
dword_t overlapped_ptr) {
dword_result_t XamWriteGamerTile_entry(dword_t arg1, dword_t arg2, dword_t arg3,
dword_t arg4, dword_t arg5,
dword_t overlapped_ptr) {
if (overlapped_ptr) {
kernel_state()->CompleteOverlappedImmediate(overlapped_ptr,
X_ERROR_SUCCESS);
@ -769,13 +768,14 @@ dword_result_t XamWriteGamerTile(dword_t arg1, dword_t arg2, dword_t arg3,
}
DECLARE_XAM_EXPORT1(XamWriteGamerTile, kUserProfiles, kStub);
dword_result_t XamSessionCreateHandle(lpdword_t handle_ptr) {
dword_result_t XamSessionCreateHandle_entry(lpdword_t handle_ptr) {
*handle_ptr = 0xCAFEDEAD;
return X_ERROR_SUCCESS;
}
DECLARE_XAM_EXPORT1(XamSessionCreateHandle, kUserProfiles, kStub);
dword_result_t XamSessionRefObjByHandle(dword_t handle, lpdword_t obj_ptr) {
dword_result_t XamSessionRefObjByHandle_entry(dword_t handle,
lpdword_t obj_ptr) {
assert_true(handle == 0xCAFEDEAD);
// TODO(PermaNull): Implement this properly,
// For the time being returning 0xDEADF00D will prevent crashing.

View File

@ -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. *
******************************************************************************
*/
@ -18,13 +18,13 @@ namespace xe {
namespace kernel {
namespace xam {
void XGetVideoMode(pointer_t<X_VIDEO_MODE> video_mode) {
void XGetVideoMode_entry(pointer_t<X_VIDEO_MODE> video_mode) {
// TODO(benvanik): actually check to see if these are the same.
xboxkrnl::VdQueryVideoMode(std::move(video_mode));
}
DECLARE_XAM_EXPORT1(XGetVideoMode, kVideo, ExportTag::kSketchy);
dword_result_t XGetVideoCapabilities() { return 0; }
dword_result_t XGetVideoCapabilities_entry() { return 0; }
DECLARE_XAM_EXPORT1(XGetVideoCapabilities, kVideo, kStub);
void RegisterVideoExports(xe::cpu::ExportResolver* export_resolver,

View File

@ -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. *
******************************************************************************
*/
@ -17,25 +17,25 @@ namespace xe {
namespace kernel {
namespace xam {
dword_result_t XamVoiceIsActiveProcess() {
dword_result_t XamVoiceIsActiveProcess_entry() {
// Returning 0 here will short-circuit a bunch of voice stuff.
return 0;
}
DECLARE_XAM_EXPORT1(XamVoiceIsActiveProcess, kNone, kStub);
dword_result_t XamVoiceCreate(unknown_t unk1, // 0
unknown_t unk2, // 0xF
lpdword_t out_voice_ptr) {
dword_result_t XamVoiceCreate_entry(unknown_t unk1, // 0
unknown_t unk2, // 0xF
lpdword_t out_voice_ptr) {
// Null out the ptr.
out_voice_ptr.Zero();
return X_ERROR_ACCESS_DENIED;
}
DECLARE_XAM_EXPORT1(XamVoiceCreate, kNone, kStub);
dword_result_t XamVoiceClose(lpunknown_t voice_ptr) { return 0; }
dword_result_t XamVoiceClose_entry(lpunknown_t voice_ptr) { return 0; }
DECLARE_XAM_EXPORT1(XamVoiceClose, kNone, kStub);
dword_result_t XamVoiceHeadsetPresent(lpunknown_t voice_ptr) { return 0; }
dword_result_t XamVoiceHeadsetPresent_entry(lpunknown_t voice_ptr) { return 0; }
DECLARE_XAM_EXPORT1(XamVoiceHeadsetPresent, kNone, kStub);
void RegisterVoiceExports(xe::cpu::ExportResolver* export_resolver,

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2020 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. *
******************************************************************************
*/
@ -18,22 +18,22 @@ namespace xe {
namespace kernel {
namespace xbdm {
#define MAKE_DUMMY_STUB_PTR(x) \
dword_result_t x() { return 0; } \
#define MAKE_DUMMY_STUB_PTR(x) \
dword_result_t x##_entry() { return 0; } \
DECLARE_XBDM_EXPORT1(x, kDebug, kStub)
#define MAKE_DUMMY_STUB_STATUS(x) \
dword_result_t x() { return X_STATUS_INVALID_PARAMETER; } \
#define MAKE_DUMMY_STUB_STATUS(x) \
dword_result_t x##_entry() { return X_STATUS_INVALID_PARAMETER; } \
DECLARE_XBDM_EXPORT1(x, kDebug, kStub)
MAKE_DUMMY_STUB_PTR(DmAllocatePool);
void DmCloseLoadedModules(lpdword_t unk0_ptr) {}
void DmCloseLoadedModules_entry(lpdword_t unk0_ptr) {}
DECLARE_XBDM_EXPORT1(DmCloseLoadedModules, kDebug, kStub);
MAKE_DUMMY_STUB_STATUS(DmFreePool);
dword_result_t DmGetXbeInfo() {
dword_result_t DmGetXbeInfo_entry() {
// TODO(gibbed): 4D5307DC appears to expect this as success?
// Unknown arguments -- let's hope things don't explode.
return 0x02DA0000;
@ -42,17 +42,17 @@ DECLARE_XBDM_EXPORT1(DmGetXbeInfo, kDebug, kStub);
MAKE_DUMMY_STUB_STATUS(DmGetXboxName);
dword_result_t DmIsDebuggerPresent() { return 0; }
dword_result_t DmIsDebuggerPresent_entry() { return 0; }
DECLARE_XBDM_EXPORT1(DmIsDebuggerPresent, kDebug, kStub);
MAKE_DUMMY_STUB_STATUS(DmRegisterCommandProcessor);
void DmSendNotificationString(lpdword_t unk0_ptr) {}
void DmSendNotificationString_entry(lpdword_t unk0_ptr) {}
DECLARE_XBDM_EXPORT1(DmSendNotificationString, kDebug, kStub);
dword_result_t DmRegisterCommandProcessorEx(lpdword_t name_ptr,
lpdword_t handler_fn,
dword_t unk3) {
dword_result_t DmRegisterCommandProcessorEx_entry(lpdword_t name_ptr,
lpdword_t handler_fn,
dword_t unk3) {
// Return success to prevent some games from stalling
return X_STATUS_SUCCESS;
}
@ -61,7 +61,8 @@ DECLARE_XBDM_EXPORT1(DmRegisterCommandProcessorEx, kDebug, kStub);
MAKE_DUMMY_STUB_STATUS(DmStartProfiling);
MAKE_DUMMY_STUB_STATUS(DmStopProfiling);
dword_result_t DmCaptureStackBackTrace(lpdword_t unk0_ptr, lpdword_t unk1_ptr) {
dword_result_t DmCaptureStackBackTrace_entry(lpdword_t unk0_ptr,
lpdword_t unk1_ptr) {
return X_STATUS_INVALID_PARAMETER;
}
DECLARE_XBDM_EXPORT1(DmCaptureStackBackTrace, kDebug, kStub);
@ -69,16 +70,18 @@ DECLARE_XBDM_EXPORT1(DmCaptureStackBackTrace, kDebug, kStub);
MAKE_DUMMY_STUB_STATUS(DmGetThreadInfoEx);
MAKE_DUMMY_STUB_STATUS(DmSetProfilingOptions);
dword_result_t DmWalkLoadedModules(lpdword_t unk0_ptr, lpdword_t unk1_ptr) {
dword_result_t DmWalkLoadedModules_entry(lpdword_t unk0_ptr,
lpdword_t unk1_ptr) {
// Some games will loop forever unless this code is returned
return 0x82DA0104;
}
DECLARE_XBDM_EXPORT1(DmWalkLoadedModules, kDebug, kStub);
void DmMapDevkitDrive() {}
void DmMapDevkitDrive_entry() {}
DECLARE_XBDM_EXPORT1(DmMapDevkitDrive, kDebug, kStub);
dword_result_t DmFindPdbSignature(lpdword_t unk0_ptr, lpdword_t unk1_ptr) {
dword_result_t DmFindPdbSignature_entry(lpdword_t unk0_ptr,
lpdword_t unk1_ptr) {
return X_STATUS_INVALID_PARAMETER;
}
DECLARE_XBDM_EXPORT1(DmFindPdbSignature, kDebug, kStub);

View File

@ -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. *
******************************************************************************
*/
@ -19,14 +19,14 @@ namespace xe {
namespace kernel {
namespace xboxkrnl {
dword_result_t XAudioGetSpeakerConfig(lpdword_t config_ptr) {
dword_result_t XAudioGetSpeakerConfig_entry(lpdword_t config_ptr) {
*config_ptr = 0x00010001;
return X_ERROR_SUCCESS;
}
DECLARE_XBOXKRNL_EXPORT1(XAudioGetSpeakerConfig, kAudio, kImplemented);
dword_result_t XAudioGetVoiceCategoryVolumeChangeMask(lpunknown_t driver_ptr,
lpdword_t out_ptr) {
dword_result_t XAudioGetVoiceCategoryVolumeChangeMask_entry(
lpunknown_t driver_ptr, lpdword_t out_ptr) {
assert_true((driver_ptr.guest_address() & 0xFFFF0000) == 0x41550000);
xe::threading::MaybeYield();
@ -39,7 +39,8 @@ dword_result_t XAudioGetVoiceCategoryVolumeChangeMask(lpunknown_t driver_ptr,
DECLARE_XBOXKRNL_EXPORT2(XAudioGetVoiceCategoryVolumeChangeMask, kAudio, kStub,
kHighFrequency);
dword_result_t XAudioGetVoiceCategoryVolume(dword_t unk, lpfloat_t out_ptr) {
dword_result_t XAudioGetVoiceCategoryVolume_entry(dword_t unk,
lpfloat_t out_ptr) {
// Expects a floating point single. Volume %?
*out_ptr = 1.0f;
@ -48,11 +49,11 @@ dword_result_t XAudioGetVoiceCategoryVolume(dword_t unk, lpfloat_t out_ptr) {
DECLARE_XBOXKRNL_EXPORT2(XAudioGetVoiceCategoryVolume, kAudio, kStub,
kHighFrequency);
dword_result_t XAudioEnableDucker(dword_t unk) { return X_ERROR_SUCCESS; }
dword_result_t XAudioEnableDucker_entry(dword_t unk) { return X_ERROR_SUCCESS; }
DECLARE_XBOXKRNL_EXPORT1(XAudioEnableDucker, kAudio, kStub);
dword_result_t XAudioRegisterRenderDriverClient(lpdword_t callback_ptr,
lpdword_t driver_ptr) {
dword_result_t XAudioRegisterRenderDriverClient_entry(lpdword_t callback_ptr,
lpdword_t driver_ptr) {
uint32_t callback = callback_ptr[0];
uint32_t callback_arg = callback_ptr[1];
@ -71,7 +72,8 @@ dword_result_t XAudioRegisterRenderDriverClient(lpdword_t callback_ptr,
DECLARE_XBOXKRNL_EXPORT1(XAudioRegisterRenderDriverClient, kAudio,
kImplemented);
dword_result_t XAudioUnregisterRenderDriverClient(lpunknown_t driver_ptr) {
dword_result_t XAudioUnregisterRenderDriverClient_entry(
lpunknown_t driver_ptr) {
assert_true((driver_ptr.guest_address() & 0xFFFF0000) == 0x41550000);
auto audio_system = kernel_state()->emulator()->audio_system();
@ -81,8 +83,8 @@ dword_result_t XAudioUnregisterRenderDriverClient(lpunknown_t driver_ptr) {
DECLARE_XBOXKRNL_EXPORT1(XAudioUnregisterRenderDriverClient, kAudio,
kImplemented);
dword_result_t XAudioSubmitRenderDriverFrame(lpunknown_t driver_ptr,
lpunknown_t samples_ptr) {
dword_result_t XAudioSubmitRenderDriverFrame_entry(lpunknown_t driver_ptr,
lpunknown_t samples_ptr) {
assert_true((driver_ptr.guest_address() & 0xFFFF0000) == 0x41550000);
auto audio_system = kernel_state()->emulator()->audio_system();

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2015 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. *
******************************************************************************
*/
@ -58,7 +58,7 @@ using xe::apu::XMA_CONTEXT_DATA;
// restrictions of frame/subframe/etc:
// https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.xaudio2.xaudio2_buffer(v=vs.85).aspx
dword_result_t XMACreateContext(lpdword_t context_out_ptr) {
dword_result_t XMACreateContext_entry(lpdword_t context_out_ptr) {
auto xma_decoder = kernel_state()->emulator()->audio_system()->xma_decoder();
uint32_t context_ptr = xma_decoder->AllocateContext();
*context_out_ptr = context_ptr;
@ -70,7 +70,7 @@ dword_result_t XMACreateContext(lpdword_t context_out_ptr) {
DECLARE_XBOXKRNL_EXPORT2(XMACreateContext, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMAReleaseContext(lpvoid_t context_ptr) {
dword_result_t XMAReleaseContext_entry(lpvoid_t context_ptr) {
auto xma_decoder = kernel_state()->emulator()->audio_system()->xma_decoder();
xma_decoder->ReleaseContext(context_ptr);
return 0;
@ -117,8 +117,8 @@ struct XMA_CONTEXT_INIT {
};
static_assert_size(XMA_CONTEXT_INIT, 56);
dword_result_t XMAInitializeContext(lpvoid_t context_ptr,
pointer_t<XMA_CONTEXT_INIT> context_init) {
dword_result_t XMAInitializeContext_entry(
lpvoid_t context_ptr, pointer_t<XMA_CONTEXT_INIT> context_init) {
// Input buffers may be null (buffer 1 in 415607D4).
// Convert to host endianness.
uint32_t input_buffer_0_guest_ptr = context_init->input_buffer_0_ptr;
@ -193,8 +193,8 @@ dword_result_t XMAInitializeContext(lpvoid_t context_ptr,
DECLARE_XBOXKRNL_EXPORT2(XMAInitializeContext, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMASetLoopData(lpvoid_t context_ptr,
pointer_t<XMA_CONTEXT_DATA> loop_data) {
dword_result_t XMASetLoopData_entry(lpvoid_t context_ptr,
pointer_t<XMA_CONTEXT_DATA> loop_data) {
XMA_CONTEXT_DATA context(context_ptr);
context.loop_start = loop_data->loop_start;
@ -209,15 +209,15 @@ dword_result_t XMASetLoopData(lpvoid_t context_ptr,
}
DECLARE_XBOXKRNL_EXPORT2(XMASetLoopData, kAudio, kImplemented, kHighFrequency);
dword_result_t XMAGetInputBufferReadOffset(lpvoid_t context_ptr) {
dword_result_t XMAGetInputBufferReadOffset_entry(lpvoid_t context_ptr) {
XMA_CONTEXT_DATA context(context_ptr);
return context.input_buffer_read_offset;
}
DECLARE_XBOXKRNL_EXPORT2(XMAGetInputBufferReadOffset, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMASetInputBufferReadOffset(lpvoid_t context_ptr,
dword_t value) {
dword_result_t XMASetInputBufferReadOffset_entry(lpvoid_t context_ptr,
dword_t value) {
XMA_CONTEXT_DATA context(context_ptr);
context.input_buffer_read_offset = value;
context.Store(context_ptr);
@ -227,8 +227,8 @@ dword_result_t XMASetInputBufferReadOffset(lpvoid_t context_ptr,
DECLARE_XBOXKRNL_EXPORT2(XMASetInputBufferReadOffset, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMASetInputBuffer0(lpvoid_t context_ptr, lpvoid_t buffer,
dword_t packet_count) {
dword_result_t XMASetInputBuffer0_entry(lpvoid_t context_ptr, lpvoid_t buffer,
dword_t packet_count) {
uint32_t buffer_physical_address =
kernel_memory()->GetPhysicalAddress(buffer.guest_address());
assert_true(buffer_physical_address != UINT32_MAX);
@ -251,14 +251,14 @@ dword_result_t XMASetInputBuffer0(lpvoid_t context_ptr, lpvoid_t buffer,
DECLARE_XBOXKRNL_EXPORT2(XMASetInputBuffer0, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMAIsInputBuffer0Valid(lpvoid_t context_ptr) {
dword_result_t XMAIsInputBuffer0Valid_entry(lpvoid_t context_ptr) {
XMA_CONTEXT_DATA context(context_ptr);
return context.input_buffer_0_valid;
}
DECLARE_XBOXKRNL_EXPORT2(XMAIsInputBuffer0Valid, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMASetInputBuffer0Valid(lpvoid_t context_ptr) {
dword_result_t XMASetInputBuffer0Valid_entry(lpvoid_t context_ptr) {
XMA_CONTEXT_DATA context(context_ptr);
context.input_buffer_0_valid = 1;
context.Store(context_ptr);
@ -268,8 +268,8 @@ dword_result_t XMASetInputBuffer0Valid(lpvoid_t context_ptr) {
DECLARE_XBOXKRNL_EXPORT2(XMASetInputBuffer0Valid, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMASetInputBuffer1(lpvoid_t context_ptr, lpvoid_t buffer,
dword_t packet_count) {
dword_result_t XMASetInputBuffer1_entry(lpvoid_t context_ptr, lpvoid_t buffer,
dword_t packet_count) {
uint32_t buffer_physical_address =
kernel_memory()->GetPhysicalAddress(buffer.guest_address());
assert_true(buffer_physical_address != UINT32_MAX);
@ -292,14 +292,14 @@ dword_result_t XMASetInputBuffer1(lpvoid_t context_ptr, lpvoid_t buffer,
DECLARE_XBOXKRNL_EXPORT2(XMASetInputBuffer1, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMAIsInputBuffer1Valid(lpvoid_t context_ptr) {
dword_result_t XMAIsInputBuffer1Valid_entry(lpvoid_t context_ptr) {
XMA_CONTEXT_DATA context(context_ptr);
return context.input_buffer_1_valid;
}
DECLARE_XBOXKRNL_EXPORT2(XMAIsInputBuffer1Valid, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMASetInputBuffer1Valid(lpvoid_t context_ptr) {
dword_result_t XMASetInputBuffer1Valid_entry(lpvoid_t context_ptr) {
XMA_CONTEXT_DATA context(context_ptr);
context.input_buffer_1_valid = 1;
context.Store(context_ptr);
@ -309,14 +309,14 @@ dword_result_t XMASetInputBuffer1Valid(lpvoid_t context_ptr) {
DECLARE_XBOXKRNL_EXPORT2(XMASetInputBuffer1Valid, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMAIsOutputBufferValid(lpvoid_t context_ptr) {
dword_result_t XMAIsOutputBufferValid_entry(lpvoid_t context_ptr) {
XMA_CONTEXT_DATA context(context_ptr);
return context.output_buffer_valid;
}
DECLARE_XBOXKRNL_EXPORT2(XMAIsOutputBufferValid, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMASetOutputBufferValid(lpvoid_t context_ptr) {
dword_result_t XMASetOutputBufferValid_entry(lpvoid_t context_ptr) {
XMA_CONTEXT_DATA context(context_ptr);
context.output_buffer_valid = 1;
context.Store(context_ptr);
@ -326,15 +326,15 @@ dword_result_t XMASetOutputBufferValid(lpvoid_t context_ptr) {
DECLARE_XBOXKRNL_EXPORT2(XMASetOutputBufferValid, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMAGetOutputBufferReadOffset(lpvoid_t context_ptr) {
dword_result_t XMAGetOutputBufferReadOffset_entry(lpvoid_t context_ptr) {
XMA_CONTEXT_DATA context(context_ptr);
return context.output_buffer_read_offset;
}
DECLARE_XBOXKRNL_EXPORT2(XMAGetOutputBufferReadOffset, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMASetOutputBufferReadOffset(lpvoid_t context_ptr,
dword_t value) {
dword_result_t XMASetOutputBufferReadOffset_entry(lpvoid_t context_ptr,
dword_t value) {
XMA_CONTEXT_DATA context(context_ptr);
context.output_buffer_read_offset = value;
context.Store(context_ptr);
@ -344,27 +344,27 @@ dword_result_t XMASetOutputBufferReadOffset(lpvoid_t context_ptr,
DECLARE_XBOXKRNL_EXPORT2(XMASetOutputBufferReadOffset, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMAGetOutputBufferWriteOffset(lpvoid_t context_ptr) {
dword_result_t XMAGetOutputBufferWriteOffset_entry(lpvoid_t context_ptr) {
XMA_CONTEXT_DATA context(context_ptr);
return context.output_buffer_write_offset;
}
DECLARE_XBOXKRNL_EXPORT2(XMAGetOutputBufferWriteOffset, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMAGetPacketMetadata(lpvoid_t context_ptr) {
dword_result_t XMAGetPacketMetadata_entry(lpvoid_t context_ptr) {
XMA_CONTEXT_DATA context(context_ptr);
return context.packet_metadata;
}
DECLARE_XBOXKRNL_EXPORT1(XMAGetPacketMetadata, kAudio, kImplemented);
dword_result_t XMAEnableContext(lpvoid_t context_ptr) {
dword_result_t XMAEnableContext_entry(lpvoid_t context_ptr) {
StoreXmaContextIndexedRegister(kernel_state(), 0x1940, context_ptr);
return 0;
}
DECLARE_XBOXKRNL_EXPORT2(XMAEnableContext, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMADisableContext(lpvoid_t context_ptr, dword_t wait) {
dword_result_t XMADisableContext_entry(lpvoid_t context_ptr, dword_t wait) {
X_HRESULT result = X_E_SUCCESS;
StoreXmaContextIndexedRegister(kernel_state(), 0x1A40, context_ptr);
if (!kernel_state()
@ -379,7 +379,7 @@ dword_result_t XMADisableContext(lpvoid_t context_ptr, dword_t wait) {
DECLARE_XBOXKRNL_EXPORT2(XMADisableContext, kAudio, kImplemented,
kHighFrequency);
dword_result_t XMABlockWhileInUse(lpvoid_t context_ptr) {
dword_result_t XMABlockWhileInUse_entry(lpvoid_t context_ptr) {
do {
XMA_CONTEXT_DATA context(context_ptr);
if (!context.input_buffer_0_valid && !context.input_buffer_1_valid) {

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2015 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. *
******************************************************************************
*/
@ -43,8 +43,8 @@ typedef struct {
} XECRYPT_RC4_STATE;
static_assert_size(XECRYPT_RC4_STATE, 0x102);
void XeCryptRc4Key(pointer_t<XECRYPT_RC4_STATE> rc4_ctx, lpvoid_t key,
dword_t key_size) {
void XeCryptRc4Key_entry(pointer_t<XECRYPT_RC4_STATE> rc4_ctx, lpvoid_t key,
dword_t key_size) {
// Setup RC4 state
rc4_ctx->i = rc4_ctx->j = 0;
for (uint32_t x = 0; x < 0x100; x++) {
@ -61,8 +61,8 @@ void XeCryptRc4Key(pointer_t<XECRYPT_RC4_STATE> rc4_ctx, lpvoid_t key,
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptRc4Key, kNone, kImplemented);
void XeCryptRc4Ecb(pointer_t<XECRYPT_RC4_STATE> rc4_ctx, lpvoid_t data,
dword_t size) {
void XeCryptRc4Ecb_entry(pointer_t<XECRYPT_RC4_STATE> rc4_ctx, lpvoid_t data,
dword_t size) {
// Crypt data
for (uint32_t idx = 0; idx < size; idx++) {
rc4_ctx->i = (rc4_ctx->i + 1) % 0x100;
@ -79,10 +79,11 @@ void XeCryptRc4Ecb(pointer_t<XECRYPT_RC4_STATE> rc4_ctx, lpvoid_t data,
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptRc4Ecb, kNone, kImplemented);
void XeCryptRc4(lpvoid_t key, dword_t key_size, lpvoid_t data, dword_t size) {
void XeCryptRc4_entry(lpvoid_t key, dword_t key_size, lpvoid_t data,
dword_t size) {
XECRYPT_RC4_STATE rc4_ctx;
XeCryptRc4Key(&rc4_ctx, key, key_size);
XeCryptRc4Ecb(&rc4_ctx, data, size);
XeCryptRc4Key_entry(&rc4_ctx, key, key_size);
XeCryptRc4Ecb_entry(&rc4_ctx, data, size);
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptRc4, kNone, kImplemented);
@ -107,7 +108,7 @@ void StoreSha1(const sha1::SHA1* sha, XECRYPT_SHA_STATE* state) {
std::copy_n(sha->getBlock(), sha->getBlockByteIndex(), state->buffer);
}
void XeCryptShaInit(pointer_t<XECRYPT_SHA_STATE> sha_state) {
void XeCryptShaInit_entry(pointer_t<XECRYPT_SHA_STATE> sha_state) {
sha_state.Zero();
sha_state->state[0] = 0x67452301;
@ -118,8 +119,8 @@ void XeCryptShaInit(pointer_t<XECRYPT_SHA_STATE> sha_state) {
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptShaInit, kNone, kImplemented);
void XeCryptShaUpdate(pointer_t<XECRYPT_SHA_STATE> sha_state, lpvoid_t input,
dword_t input_size) {
void XeCryptShaUpdate_entry(pointer_t<XECRYPT_SHA_STATE> sha_state,
lpvoid_t input, dword_t input_size) {
sha1::SHA1 sha;
InitSha1(&sha, sha_state);
@ -129,8 +130,8 @@ void XeCryptShaUpdate(pointer_t<XECRYPT_SHA_STATE> sha_state, lpvoid_t input,
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptShaUpdate, kNone, kImplemented);
void XeCryptShaFinal(pointer_t<XECRYPT_SHA_STATE> sha_state,
pointer_t<uint8_t> out, dword_t out_size) {
void XeCryptShaFinal_entry(pointer_t<XECRYPT_SHA_STATE> sha_state,
pointer_t<uint8_t> out, dword_t out_size) {
sha1::SHA1 sha;
InitSha1(&sha, sha_state);
@ -143,9 +144,10 @@ void XeCryptShaFinal(pointer_t<XECRYPT_SHA_STATE> sha_state,
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptShaFinal, kNone, kImplemented);
void XeCryptSha(lpvoid_t input_1, dword_t input_1_size, lpvoid_t input_2,
dword_t input_2_size, lpvoid_t input_3, dword_t input_3_size,
lpvoid_t output, dword_t output_size) {
void XeCryptSha_entry(lpvoid_t input_1, dword_t input_1_size, lpvoid_t input_2,
dword_t input_2_size, lpvoid_t input_3,
dword_t input_3_size, lpvoid_t output,
dword_t output_size) {
sha1::SHA1 sha;
if (input_1 && input_1_size) {
@ -172,7 +174,7 @@ typedef struct {
uint8_t buffer[64]; // 0x24
} XECRYPT_SHA256_STATE;
void XeCryptSha256Init(pointer_t<XECRYPT_SHA256_STATE> sha_state) {
void XeCryptSha256Init_entry(pointer_t<XECRYPT_SHA256_STATE> sha_state) {
sha_state.Zero();
sha_state->state[0] = 0x6a09e667;
@ -186,8 +188,8 @@ void XeCryptSha256Init(pointer_t<XECRYPT_SHA256_STATE> sha_state) {
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptSha256Init, kNone, kImplemented);
void XeCryptSha256Update(pointer_t<XECRYPT_SHA256_STATE> sha_state,
lpvoid_t input, dword_t input_size) {
void XeCryptSha256Update_entry(pointer_t<XECRYPT_SHA256_STATE> sha_state,
lpvoid_t input, dword_t input_size) {
sha256::SHA256 sha;
std::copy(std::begin(sha_state->state), std::end(sha_state->state),
sha.getHashValues());
@ -205,8 +207,8 @@ void XeCryptSha256Update(pointer_t<XECRYPT_SHA256_STATE> sha_state,
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptSha256Update, kNone, kImplemented);
void XeCryptSha256Final(pointer_t<XECRYPT_SHA256_STATE> sha_state,
pointer_t<uint8_t> out, dword_t out_size) {
void XeCryptSha256Final_entry(pointer_t<XECRYPT_SHA256_STATE> sha_state,
pointer_t<uint8_t> out, dword_t out_size) {
sha256::SHA256 sha;
std::copy(std::begin(sha_state->state), std::end(sha_state->state),
sha.getHashValues());
@ -224,8 +226,8 @@ void XeCryptSha256Final(pointer_t<XECRYPT_SHA256_STATE> sha_state,
DECLARE_XBOXKRNL_EXPORT1(XeCryptSha256Final, kNone, kImplemented);
// Byteswaps each 8 bytes
void XeCryptBnQw_SwapDwQwLeBe(pointer_t<uint64_t> qw_inp,
pointer_t<uint64_t> qw_out, dword_t size) {
void XeCryptBnQw_SwapDwQwLeBe_entry(pointer_t<uint64_t> qw_inp,
pointer_t<uint64_t> qw_out, dword_t size) {
xe::copy_and_swap<uint64_t>(qw_out, qw_inp, size);
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptBnQw_SwapDwQwLeBe, kNone, kImplemented);
@ -239,9 +241,9 @@ typedef struct {
} XECRYPT_RSA;
static_assert_size(XECRYPT_RSA, 0x10);
dword_result_t XeCryptBnQwNeRsaPubCrypt(pointer_t<uint64_t> qw_a,
pointer_t<uint64_t> qw_b,
pointer_t<XECRYPT_RSA> rsa) {
dword_result_t XeCryptBnQwNeRsaPubCrypt_entry(pointer_t<uint64_t> qw_a,
pointer_t<uint64_t> qw_b,
pointer_t<XECRYPT_RSA> rsa) {
// 0 indicates failure (but not a BOOL return value)
#ifndef XE_PLATFORM_WIN32
XELOGE(
@ -342,14 +344,14 @@ DECLARE_XBOXKRNL_EXPORT1(XeCryptBnQwNeRsaPubCrypt, kNone, kImplemented);
DECLARE_XBOXKRNL_EXPORT1(XeCryptBnQwNeRsaPubCrypt, kNone, kStub);
#endif
dword_result_t XeCryptBnDwLePkcs1Verify(lpvoid_t hash, lpvoid_t sig,
dword_t size) {
dword_result_t XeCryptBnDwLePkcs1Verify_entry(lpvoid_t hash, lpvoid_t sig,
dword_t size) {
// BOOL return value
return 1;
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptBnDwLePkcs1Verify, kNone, kStub);
void XeCryptRandom(lpvoid_t buf, dword_t buf_size) {
void XeCryptRandom_entry(lpvoid_t buf, dword_t buf_size) {
std::memset(buf, 0xFD, buf_size);
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptRandom, kNone, kStub);
@ -359,7 +361,7 @@ struct XECRYPT_DES_STATE {
};
// Sets bit 0 to make the parity odd
void XeCryptDesParity(lpvoid_t inp, dword_t inp_size, lpvoid_t out_ptr) {
void XeCryptDesParity_entry(lpvoid_t inp, dword_t inp_size, lpvoid_t out_ptr) {
DES::set_parity(inp, inp_size, out_ptr);
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptDesParity, kNone, kImplemented);
@ -368,7 +370,8 @@ struct XECRYPT_DES3_STATE {
XECRYPT_DES_STATE des_state[3];
};
void XeCryptDes3Key(pointer_t<XECRYPT_DES3_STATE> state_ptr, lpqword_t key) {
void XeCryptDes3Key_entry(pointer_t<XECRYPT_DES3_STATE> state_ptr,
lpqword_t key) {
DES3 des3(key[0], key[1], key[2]);
DES* des = des3.getDES();
@ -379,8 +382,8 @@ void XeCryptDes3Key(pointer_t<XECRYPT_DES3_STATE> state_ptr, lpqword_t key) {
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptDes3Key, kNone, kImplemented);
void XeCryptDes3Ecb(pointer_t<XECRYPT_DES3_STATE> state_ptr, lpqword_t inp,
lpqword_t out, dword_t encrypt) {
void XeCryptDes3Ecb_entry(pointer_t<XECRYPT_DES3_STATE> state_ptr,
lpqword_t inp, lpqword_t out, dword_t encrypt) {
DES3 des3((ui64*)state_ptr->des_state[0].keytab,
(ui64*)state_ptr->des_state[1].keytab,
(ui64*)state_ptr->des_state[2].keytab);
@ -393,9 +396,9 @@ void XeCryptDes3Ecb(pointer_t<XECRYPT_DES3_STATE> state_ptr, lpqword_t inp,
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptDes3Ecb, kNone, kImplemented);
void XeCryptDes3Cbc(pointer_t<XECRYPT_DES3_STATE> state_ptr, lpqword_t inp,
dword_t inp_size, lpqword_t out, lpqword_t feed,
dword_t encrypt) {
void XeCryptDes3Cbc_entry(pointer_t<XECRYPT_DES3_STATE> state_ptr,
lpqword_t inp, dword_t inp_size, lpqword_t out,
lpqword_t feed, dword_t encrypt) {
DES3 des3((ui64*)state_ptr->des_state[0].keytab,
(ui64*)state_ptr->des_state[1].keytab,
(ui64*)state_ptr->des_state[2].keytab);
@ -429,7 +432,7 @@ static inline uint8_t xeXeCryptAesMul2(uint8_t a) {
return (a & 0x80) ? ((a << 1) ^ 0x1B) : (a << 1);
}
void XeCryptAesKey(pointer_t<XECRYPT_AES_STATE> state_ptr, lpvoid_t key) {
void XeCryptAesKey_entry(pointer_t<XECRYPT_AES_STATE> state_ptr, lpvoid_t key) {
aes_key_schedule_128(key, reinterpret_cast<uint8_t*>(state_ptr->keytabenc));
// Decryption key schedule not needed by openluopworld/aes_128, but generated
// to fill the context structure properly.
@ -494,8 +497,8 @@ void XeCryptAesKey(pointer_t<XECRYPT_AES_STATE> state_ptr, lpvoid_t key) {
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptAesKey, kNone, kImplemented);
void XeCryptAesEcb(pointer_t<XECRYPT_AES_STATE> state_ptr, lpvoid_t inp_ptr,
lpvoid_t out_ptr, dword_t encrypt) {
void XeCryptAesEcb_entry(pointer_t<XECRYPT_AES_STATE> state_ptr,
lpvoid_t inp_ptr, lpvoid_t out_ptr, dword_t encrypt) {
const uint8_t* keytab =
reinterpret_cast<const uint8_t*>(state_ptr->keytabenc);
if (encrypt) {
@ -506,9 +509,9 @@ void XeCryptAesEcb(pointer_t<XECRYPT_AES_STATE> state_ptr, lpvoid_t inp_ptr,
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptAesEcb, kNone, kImplemented);
void XeCryptAesCbc(pointer_t<XECRYPT_AES_STATE> state_ptr, lpvoid_t inp_ptr,
dword_t inp_size, lpvoid_t out_ptr, lpvoid_t feed_ptr,
dword_t encrypt) {
void XeCryptAesCbc_entry(pointer_t<XECRYPT_AES_STATE> state_ptr,
lpvoid_t inp_ptr, dword_t inp_size, lpvoid_t out_ptr,
lpvoid_t feed_ptr, dword_t encrypt) {
const uint8_t* keytab =
reinterpret_cast<const uint8_t*>(state_ptr->keytabenc);
const uint8_t* inp = inp_ptr.as<const uint8_t*>();
@ -541,10 +544,10 @@ void XeCryptAesCbc(pointer_t<XECRYPT_AES_STATE> state_ptr, lpvoid_t inp_ptr,
}
DECLARE_XBOXKRNL_EXPORT1(XeCryptAesCbc, kNone, kImplemented);
void XeCryptHmacSha(lpvoid_t key, dword_t key_size_in, lpvoid_t inp_1,
dword_t inp_1_size, lpvoid_t inp_2, dword_t inp_2_size,
lpvoid_t inp_3, dword_t inp_3_size, lpvoid_t out,
dword_t out_size) {
void XeCryptHmacSha_entry(lpvoid_t key, dword_t key_size_in, lpvoid_t inp_1,
dword_t inp_1_size, lpvoid_t inp_2,
dword_t inp_2_size, lpvoid_t inp_3,
dword_t inp_3_size, lpvoid_t out, dword_t out_size) {
uint32_t key_size = key_size_in;
sha1::SHA1 sha;
uint8_t kpad_i[0x40];
@ -605,19 +608,19 @@ DECLARE_XBOXKRNL_EXPORT1(XeCryptHmacSha, kNone, kImplemented);
static const uint8_t key19[] = {0xE1, 0xBC, 0x15, 0x9C, 0x73, 0xB1, 0xEA, 0xE9,
0xAB, 0x31, 0x70, 0xF3, 0xAD, 0x47, 0xEB, 0xF3};
dword_result_t XeKeysHmacSha(dword_t key_num, lpvoid_t inp_1,
dword_t inp_1_size, lpvoid_t inp_2,
dword_t inp_2_size, lpvoid_t inp_3,
dword_t inp_3_size, lpvoid_t out,
dword_t out_size) {
dword_result_t XeKeysHmacSha_entry(dword_t key_num, lpvoid_t inp_1,
dword_t inp_1_size, lpvoid_t inp_2,
dword_t inp_2_size, lpvoid_t inp_3,
dword_t inp_3_size, lpvoid_t out,
dword_t out_size) {
const uint8_t* key = nullptr;
if (key_num == 0x19) {
key = key19;
}
if (key) {
XeCryptHmacSha((void*)key, 0x10, inp_1, inp_1_size, inp_2, inp_2_size,
inp_3, inp_3_size, out, out_size);
XeCryptHmacSha_entry((void*)key, 0x10, inp_1, inp_1_size, inp_2, inp_2_size,
inp_3, inp_3_size, out, out_size);
return X_STATUS_SUCCESS;
}
@ -630,41 +633,42 @@ static const uint8_t xe_key_obfuscation_key[16] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
dword_result_t XeKeysAesCbcUsingKey(lpvoid_t obscured_key, lpvoid_t inp_ptr,
dword_t inp_size, lpvoid_t out_ptr,
lpvoid_t feed_ptr, dword_t encrypt) {
dword_result_t XeKeysAesCbcUsingKey_entry(lpvoid_t obscured_key,
lpvoid_t inp_ptr, dword_t inp_size,
lpvoid_t out_ptr, lpvoid_t feed_ptr,
dword_t encrypt) {
uint8_t key[16];
// Deobscure key
XECRYPT_AES_STATE aes;
XeCryptAesKey(&aes, (uint8_t*)xe_key_obfuscation_key);
XeCryptAesEcb(&aes, obscured_key, key, 0);
XeCryptAesKey_entry(&aes, (uint8_t*)xe_key_obfuscation_key);
XeCryptAesEcb_entry(&aes, obscured_key, key, 0);
// Run CBC using deobscured key
XeCryptAesKey(&aes, key);
XeCryptAesCbc(&aes, inp_ptr, inp_size, out_ptr, feed_ptr, encrypt);
XeCryptAesKey_entry(&aes, key);
XeCryptAesCbc_entry(&aes, inp_ptr, inp_size, out_ptr, feed_ptr, encrypt);
return X_STATUS_SUCCESS;
}
DECLARE_XBOXKRNL_EXPORT1(XeKeysAesCbcUsingKey, kNone, kImplemented);
dword_result_t XeKeysObscureKey(lpvoid_t input, lpvoid_t output) {
dword_result_t XeKeysObscureKey_entry(lpvoid_t input, lpvoid_t output) {
// Based on HvxKeysObscureKey
// Seems to encrypt input with per-console KEY_OBFUSCATION_KEY (key 0x18)
XECRYPT_AES_STATE aes;
XeCryptAesKey(&aes, (uint8_t*)xe_key_obfuscation_key);
XeCryptAesEcb(&aes, input, output, 1);
XeCryptAesKey_entry(&aes, (uint8_t*)xe_key_obfuscation_key);
XeCryptAesEcb_entry(&aes, input, output, 1);
return X_STATUS_SUCCESS;
}
DECLARE_XBOXKRNL_EXPORT1(XeKeysObscureKey, kNone, kImplemented);
dword_result_t XeKeysHmacShaUsingKey(lpvoid_t obscured_key, lpvoid_t inp_1,
dword_t inp_1_size, lpvoid_t inp_2,
dword_t inp_2_size, lpvoid_t inp_3,
dword_t inp_3_size, lpvoid_t out,
dword_t out_size) {
dword_result_t XeKeysHmacShaUsingKey_entry(lpvoid_t obscured_key,
lpvoid_t inp_1, dword_t inp_1_size,
lpvoid_t inp_2, dword_t inp_2_size,
lpvoid_t inp_3, dword_t inp_3_size,
lpvoid_t out, dword_t out_size) {
if (!obscured_key) {
return X_STATUS_INVALID_PARAMETER;
}
@ -673,11 +677,11 @@ dword_result_t XeKeysHmacShaUsingKey(lpvoid_t obscured_key, lpvoid_t inp_1,
// Deobscure key
XECRYPT_AES_STATE aes;
XeCryptAesKey(&aes, (uint8_t*)xe_key_obfuscation_key);
XeCryptAesEcb(&aes, obscured_key, key, 0);
XeCryptAesKey_entry(&aes, (uint8_t*)xe_key_obfuscation_key);
XeCryptAesEcb_entry(&aes, obscured_key, key, 0);
XeCryptHmacSha(key, 0x10, inp_1, inp_1_size, inp_2, inp_2_size, inp_3,
inp_3_size, out, out_size);
XeCryptHmacSha_entry(key, 0x10, inp_1, inp_1_size, inp_2, inp_2_size, inp_3,
inp_3_size, out, out_size);
return X_STATUS_SUCCESS;
}
DECLARE_XBOXKRNL_EXPORT1(XeKeysHmacShaUsingKey, kNone, kImplemented);

View File

@ -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. *
******************************************************************************
*/
@ -19,7 +19,7 @@ namespace xe {
namespace kernel {
namespace xboxkrnl {
void DbgBreakPoint() { xe::debugging::Break(); }
void DbgBreakPoint_entry() { xe::debugging::Break(); }
DECLARE_XBOXKRNL_EXPORT2(DbgBreakPoint, kDebug, kStub, kImportant);
// https://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
@ -123,7 +123,7 @@ void HandleCppException(pointer_t<X_EXCEPTION_RECORD> record) {
xe::debugging::Break();
}
void RtlRaiseException(pointer_t<X_EXCEPTION_RECORD> record) {
void RtlRaiseException_entry(pointer_t<X_EXCEPTION_RECORD> record) {
switch (record->exception_code) {
case 0x406D1388: {
HandleSetThreadName(record);
@ -141,8 +141,8 @@ void RtlRaiseException(pointer_t<X_EXCEPTION_RECORD> record) {
}
DECLARE_XBOXKRNL_EXPORT2(RtlRaiseException, kDebug, kStub, kImportant);
void KeBugCheckEx(dword_t code, dword_t param1, dword_t param2, dword_t param3,
dword_t param4) {
void KeBugCheckEx_entry(dword_t code, dword_t param1, dword_t param2,
dword_t param3, dword_t param4) {
XELOGD("*** STOP: 0x{:08X} (0x{:08X}, 0x{:08X}, 0x{:08X}, 0x{:08X})", code,
param1, param2, param3, param4);
fflush(stdout);
@ -151,7 +151,7 @@ void KeBugCheckEx(dword_t code, dword_t param1, dword_t param2, dword_t param3,
}
DECLARE_XBOXKRNL_EXPORT2(KeBugCheckEx, kDebug, kStub, kImportant);
void KeBugCheck(dword_t code) { KeBugCheckEx(code, 0, 0, 0, 0); }
void KeBugCheck_entry(dword_t code) { KeBugCheckEx_entry(code, 0, 0, 0, 0); }
DECLARE_XBOXKRNL_EXPORT2(KeBugCheck, kDebug, kImplemented, kImportant);
void RegisterDebugExports(xe::cpu::ExportResolver* export_resolver,

View File

@ -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. *
******************************************************************************
*/
@ -1011,7 +1011,7 @@ uint32_t xeRtlNtStatusToDosError(uint32_t source_status) {
return 317; // ERROR_MR_MID_NOT_FOUND
}
dword_result_t RtlNtStatusToDosError(dword_t source_status) {
dword_result_t RtlNtStatusToDosError_entry(dword_t source_status) {
return xeRtlNtStatusToDosError(source_status);
}
DECLARE_XBOXKRNL_EXPORT3(RtlNtStatusToDosError, kNone, kImportant,

View File

@ -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. *
******************************************************************************
*/
@ -17,7 +17,7 @@ namespace xe {
namespace kernel {
namespace xboxkrnl {
void HalReturnToFirmware(dword_t routine) {
void HalReturnToFirmware_entry(dword_t routine) {
// void
// IN FIRMWARE_REENTRY Routine

View File

@ -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. *
******************************************************************************
*/
@ -17,7 +17,7 @@ namespace xe {
namespace kernel {
namespace xboxkrnl {
dword_result_t HidReadKeys(dword_t unk1, unknown_t unk2, unknown_t unk3) {
dword_result_t HidReadKeys_entry(dword_t unk1, unknown_t unk2, unknown_t unk3) {
/* TODO(gibbed):
* Games check for the following errors:
* 0xC000009D - translated to 0x48F - ERROR_DEVICE_NOT_CONNECTED

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2020 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,13 +95,13 @@ static bool IsValidPath(const std::string_view s, bool is_pattern) {
return true;
}
dword_result_t NtCreateFile(lpdword_t handle_out, dword_t desired_access,
pointer_t<X_OBJECT_ATTRIBUTES> object_attrs,
pointer_t<X_IO_STATUS_BLOCK> io_status_block,
lpqword_t allocation_size_ptr,
dword_t file_attributes, dword_t share_access,
dword_t creation_disposition,
dword_t create_options) {
dword_result_t NtCreateFile_entry(lpdword_t handle_out, dword_t desired_access,
pointer_t<X_OBJECT_ATTRIBUTES> object_attrs,
pointer_t<X_IO_STATUS_BLOCK> io_status_block,
lpqword_t allocation_size_ptr,
dword_t file_attributes, dword_t share_access,
dword_t creation_disposition,
dword_t create_options) {
uint64_t allocation_size = 0; // is this correct???
if (allocation_size_ptr) {
allocation_size = *allocation_size_ptr;
@ -170,22 +170,22 @@ dword_result_t NtCreateFile(lpdword_t handle_out, dword_t desired_access,
}
DECLARE_XBOXKRNL_EXPORT1(NtCreateFile, kFileSystem, kImplemented);
dword_result_t NtOpenFile(lpdword_t handle_out, dword_t desired_access,
pointer_t<X_OBJECT_ATTRIBUTES> object_attributes,
pointer_t<X_IO_STATUS_BLOCK> io_status_block,
dword_t open_options) {
return NtCreateFile(handle_out, desired_access, object_attributes,
io_status_block, nullptr, 0, 0,
static_cast<uint32_t>(xe::vfs::FileDisposition::kOpen),
open_options);
dword_result_t NtOpenFile_entry(
lpdword_t handle_out, dword_t desired_access,
pointer_t<X_OBJECT_ATTRIBUTES> object_attributes,
pointer_t<X_IO_STATUS_BLOCK> io_status_block, dword_t open_options) {
return NtCreateFile_entry(
handle_out, desired_access, object_attributes, io_status_block, nullptr,
0, 0, static_cast<uint32_t>(xe::vfs::FileDisposition::kOpen),
open_options);
}
DECLARE_XBOXKRNL_EXPORT1(NtOpenFile, kFileSystem, kImplemented);
dword_result_t NtReadFile(dword_t file_handle, dword_t event_handle,
lpvoid_t apc_routine_ptr, lpvoid_t apc_context,
pointer_t<X_IO_STATUS_BLOCK> io_status_block,
lpvoid_t buffer, dword_t buffer_length,
lpqword_t byte_offset_ptr) {
dword_result_t NtReadFile_entry(dword_t file_handle, dword_t event_handle,
lpvoid_t apc_routine_ptr, lpvoid_t apc_context,
pointer_t<X_IO_STATUS_BLOCK> io_status_block,
lpvoid_t buffer, dword_t buffer_length,
lpqword_t byte_offset_ptr) {
X_STATUS result = X_STATUS_SUCCESS;
bool signal_event = false;
@ -265,11 +265,10 @@ dword_result_t NtReadFile(dword_t file_handle, dword_t event_handle,
}
DECLARE_XBOXKRNL_EXPORT2(NtReadFile, kFileSystem, kImplemented, kHighFrequency);
dword_result_t NtReadFileScatter(dword_t file_handle, dword_t event_handle,
lpvoid_t apc_routine_ptr, lpvoid_t apc_context,
pointer_t<X_IO_STATUS_BLOCK> io_status_block,
lpdword_t segment_array, dword_t length,
lpqword_t byte_offset_ptr) {
dword_result_t NtReadFileScatter_entry(
dword_t file_handle, dword_t event_handle, lpvoid_t apc_routine_ptr,
lpvoid_t apc_context, pointer_t<X_IO_STATUS_BLOCK> io_status_block,
lpdword_t segment_array, dword_t length, lpqword_t byte_offset_ptr) {
X_STATUS result = X_STATUS_SUCCESS;
bool signal_event = false;
@ -352,11 +351,11 @@ dword_result_t NtReadFileScatter(dword_t file_handle, dword_t event_handle,
}
DECLARE_XBOXKRNL_EXPORT1(NtReadFileScatter, kFileSystem, kImplemented);
dword_result_t NtWriteFile(dword_t file_handle, dword_t event_handle,
function_t apc_routine, lpvoid_t apc_context,
pointer_t<X_IO_STATUS_BLOCK> io_status_block,
lpvoid_t buffer, dword_t buffer_length,
lpqword_t byte_offset_ptr) {
dword_result_t NtWriteFile_entry(dword_t file_handle, dword_t event_handle,
function_t apc_routine, lpvoid_t apc_context,
pointer_t<X_IO_STATUS_BLOCK> io_status_block,
lpvoid_t buffer, dword_t buffer_length,
lpqword_t byte_offset_ptr) {
X_STATUS result = X_STATUS_SUCCESS;
// Grab event to signal.
@ -430,10 +429,10 @@ dword_result_t NtWriteFile(dword_t file_handle, dword_t event_handle,
}
DECLARE_XBOXKRNL_EXPORT1(NtWriteFile, kFileSystem, kImplemented);
dword_result_t NtCreateIoCompletion(lpdword_t out_handle,
dword_t desired_access,
lpvoid_t object_attribs,
dword_t num_concurrent_threads) {
dword_result_t NtCreateIoCompletion_entry(lpdword_t out_handle,
dword_t desired_access,
lpvoid_t object_attribs,
dword_t num_concurrent_threads) {
auto completion = new XIOCompletion(kernel_state());
if (out_handle) {
*out_handle = completion->handle();
@ -443,9 +442,10 @@ dword_result_t NtCreateIoCompletion(lpdword_t out_handle,
}
DECLARE_XBOXKRNL_EXPORT1(NtCreateIoCompletion, kFileSystem, kImplemented);
dword_result_t NtSetIoCompletion(dword_t handle, dword_t key_context,
dword_t apc_context, dword_t completion_status,
dword_t num_bytes) {
dword_result_t NtSetIoCompletion_entry(dword_t handle, dword_t key_context,
dword_t apc_context,
dword_t completion_status,
dword_t num_bytes) {
auto port =
kernel_state()->object_table()->LookupObject<XIOCompletion>(handle);
if (!port) {
@ -465,7 +465,7 @@ DECLARE_XBOXKRNL_EXPORT2(NtSetIoCompletion, kFileSystem, kImplemented,
kHighFrequency);
// Dequeues a packet from the completion port.
dword_result_t NtRemoveIoCompletion(
dword_result_t NtRemoveIoCompletion_entry(
dword_t handle, lpdword_t key_context, lpdword_t apc_context,
pointer_t<X_IO_STATUS_BLOCK> io_status_block, lpqword_t timeout) {
X_STATUS status = X_STATUS_SUCCESS;
@ -502,7 +502,7 @@ dword_result_t NtRemoveIoCompletion(
DECLARE_XBOXKRNL_EXPORT2(NtRemoveIoCompletion, kFileSystem, kImplemented,
kHighFrequency);
dword_result_t NtQueryFullAttributesFile(
dword_result_t NtQueryFullAttributesFile_entry(
pointer_t<X_OBJECT_ATTRIBUTES> obj_attribs,
pointer_t<X_FILE_NETWORK_OPEN_INFORMATION> file_info) {
auto object_name =
@ -544,7 +544,7 @@ dword_result_t NtQueryFullAttributesFile(
}
DECLARE_XBOXKRNL_EXPORT1(NtQueryFullAttributesFile, kFileSystem, kImplemented);
dword_result_t NtQueryDirectoryFile(
dword_result_t NtQueryDirectoryFile_entry(
dword_t file_handle, dword_t event_handle, function_t apc_routine,
lpvoid_t apc_context, pointer_t<X_IO_STATUS_BLOCK> io_status_block,
pointer_t<X_FILE_DIRECTORY_INFORMATION> file_info_ptr, dword_t length,
@ -588,7 +588,7 @@ dword_result_t NtQueryDirectoryFile(
}
DECLARE_XBOXKRNL_EXPORT1(NtQueryDirectoryFile, kFileSystem, kImplemented);
dword_result_t NtFlushBuffersFile(
dword_result_t NtFlushBuffersFile_entry(
dword_t file_handle, pointer_t<X_IO_STATUS_BLOCK> io_status_block_ptr) {
auto result = X_STATUS_SUCCESS;
@ -602,7 +602,7 @@ dword_result_t NtFlushBuffersFile(
DECLARE_XBOXKRNL_EXPORT1(NtFlushBuffersFile, kFileSystem, kStub);
// https://docs.microsoft.com/en-us/windows/win32/devnotes/ntopensymboliclinkobject
dword_result_t NtOpenSymbolicLinkObject(
dword_result_t NtOpenSymbolicLinkObject_entry(
lpdword_t handle_out, pointer_t<X_OBJECT_ATTRIBUTES> object_attrs) {
if (!object_attrs) {
return X_STATUS_INVALID_PARAMETER;
@ -646,8 +646,8 @@ dword_result_t NtOpenSymbolicLinkObject(
DECLARE_XBOXKRNL_EXPORT1(NtOpenSymbolicLinkObject, kFileSystem, kImplemented);
// https://docs.microsoft.com/en-us/windows/win32/devnotes/ntquerysymboliclinkobject
dword_result_t NtQuerySymbolicLinkObject(dword_t handle,
pointer_t<X_ANSI_STRING> target) {
dword_result_t NtQuerySymbolicLinkObject_entry(
dword_t handle, pointer_t<X_ANSI_STRING> target) {
auto symlink =
kernel_state()->object_table()->LookupObject<XSymbolicLink>(handle);
if (!symlink) {
@ -664,17 +664,17 @@ dword_result_t NtQuerySymbolicLinkObject(dword_t handle,
}
DECLARE_XBOXKRNL_EXPORT1(NtQuerySymbolicLinkObject, kFileSystem, kImplemented);
dword_result_t FscGetCacheElementCount(dword_t r3) { return 0; }
dword_result_t FscGetCacheElementCount_entry(dword_t r3) { return 0; }
DECLARE_XBOXKRNL_EXPORT1(FscGetCacheElementCount, kFileSystem, kStub);
dword_result_t FscSetCacheElementCount(dword_t unk_0, dword_t unk_1) {
dword_result_t FscSetCacheElementCount_entry(dword_t unk_0, dword_t unk_1) {
// unk_0 = 0
// unk_1 looks like a count? in what units? 256 is a common value
return X_STATUS_SUCCESS;
}
DECLARE_XBOXKRNL_EXPORT1(FscSetCacheElementCount, kFileSystem, kStub);
dword_result_t NtDeviceIoControlFile(
dword_result_t NtDeviceIoControlFile_entry(
dword_t handle, dword_t event_handle, dword_t apc_routine,
dword_t apc_context, dword_t io_status_block, dword_t io_control_code,
lpvoid_t input_buffer, dword_t input_buffer_len, lpvoid_t output_buffer,
@ -712,8 +712,9 @@ dword_result_t NtDeviceIoControlFile(
}
DECLARE_XBOXKRNL_EXPORT1(NtDeviceIoControlFile, kFileSystem, kStub);
dword_result_t IoCreateDevice(dword_t device_struct, dword_t r4, dword_t r5,
dword_t r6, dword_t r7, lpdword_t out_struct) {
dword_result_t IoCreateDevice_entry(dword_t device_struct, dword_t r4,
dword_t r5, dword_t r6, dword_t r7,
lpdword_t out_struct) {
// Called from XMountUtilityDrive XAM-task code
// That code tries writing things to a pointer at out_struct+0x18
// We'll alloc some scratch space for it so it doesn't cause any exceptions

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2020 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. *
******************************************************************************
*/
@ -54,7 +54,7 @@ uint32_t GetQueryFileInfoMinimumLength(uint32_t info_class) {
}
}
dword_result_t NtQueryInformationFile(
dword_result_t NtQueryInformationFile_entry(
dword_t file_handle, pointer_t<X_IO_STATUS_BLOCK> io_status_block_ptr,
lpvoid_t info_ptr, dword_t info_length, dword_t info_class) {
uint32_t minimum_length = GetQueryFileInfoMinimumLength(info_class);
@ -179,7 +179,7 @@ uint32_t GetSetFileInfoMinimumLength(uint32_t info_class) {
}
}
dword_result_t NtSetInformationFile(
dword_result_t NtSetInformationFile_entry(
dword_t file_handle, pointer_t<X_IO_STATUS_BLOCK> io_status_block,
lpvoid_t info_ptr, dword_t info_length, dword_t info_class) {
uint32_t minimum_length = GetSetFileInfoMinimumLength(info_class);
@ -277,7 +277,7 @@ uint32_t GetQueryVolumeInfoMinimumLength(uint32_t info_class) {
}
}
dword_result_t NtQueryVolumeInformationFile(
dword_result_t NtQueryVolumeInformationFile_entry(
dword_t file_handle, pointer_t<X_IO_STATUS_BLOCK> io_status_block_ptr,
lpvoid_t info_ptr, dword_t info_length, dword_t info_class) {
uint32_t minimum_length = GetQueryVolumeInfoMinimumLength(info_class);

View File

@ -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. *
******************************************************************************
*/
@ -57,10 +57,11 @@ uint32_t FromXdkProtectFlags(uint32_t protect) {
return result;
}
dword_result_t NtAllocateVirtualMemory(lpdword_t base_addr_ptr,
lpdword_t region_size_ptr,
dword_t alloc_type, dword_t protect_bits,
dword_t debug_memory) {
dword_result_t NtAllocateVirtualMemory_entry(lpdword_t base_addr_ptr,
lpdword_t region_size_ptr,
dword_t alloc_type,
dword_t protect_bits,
dword_t debug_memory) {
// NTSTATUS
// _Inout_ PVOID *BaseAddress,
// _Inout_ PSIZE_T RegionSize,
@ -189,11 +190,11 @@ dword_result_t NtAllocateVirtualMemory(lpdword_t base_addr_ptr,
}
DECLARE_XBOXKRNL_EXPORT1(NtAllocateVirtualMemory, kMemory, kImplemented);
dword_result_t NtProtectVirtualMemory(lpdword_t base_addr_ptr,
lpdword_t region_size_ptr,
dword_t protect_bits,
lpdword_t old_protect,
dword_t debug_memory) {
dword_result_t NtProtectVirtualMemory_entry(lpdword_t base_addr_ptr,
lpdword_t region_size_ptr,
dword_t protect_bits,
lpdword_t old_protect,
dword_t debug_memory) {
// Set to TRUE when this memory refers to devkit memory area.
assert_true(debug_memory == 0);
@ -239,9 +240,10 @@ dword_result_t NtProtectVirtualMemory(lpdword_t base_addr_ptr,
}
DECLARE_XBOXKRNL_EXPORT1(NtProtectVirtualMemory, kMemory, kImplemented);
dword_result_t NtFreeVirtualMemory(lpdword_t base_addr_ptr,
lpdword_t region_size_ptr, dword_t free_type,
dword_t debug_memory) {
dword_result_t NtFreeVirtualMemory_entry(lpdword_t base_addr_ptr,
lpdword_t region_size_ptr,
dword_t free_type,
dword_t debug_memory) {
uint32_t base_addr_value = *base_addr_ptr;
uint32_t region_size_value = *region_size_ptr;
// X_MEM_DECOMMIT | X_MEM_RELEASE
@ -293,7 +295,7 @@ struct X_MEMORY_BASIC_INFORMATION {
be<uint32_t> type;
};
dword_result_t NtQueryVirtualMemory(
dword_result_t NtQueryVirtualMemory_entry(
dword_t base_address,
pointer_t<X_MEMORY_BASIC_INFORMATION> memory_basic_information_ptr) {
auto heap = kernel_state()->memory()->LookupHeap(base_address);
@ -328,11 +330,9 @@ dword_result_t NtQueryVirtualMemory(
}
DECLARE_XBOXKRNL_EXPORT1(NtQueryVirtualMemory, kMemory, kImplemented);
dword_result_t MmAllocatePhysicalMemoryEx(dword_t flags, dword_t region_size,
dword_t protect_bits,
dword_t min_addr_range,
dword_t max_addr_range,
dword_t alignment) {
dword_result_t MmAllocatePhysicalMemoryEx_entry(
dword_t flags, dword_t region_size, dword_t protect_bits,
dword_t min_addr_range, dword_t max_addr_range, dword_t alignment) {
// Type will usually be 0 (user request?), where 1 and 2 are sometimes made
// by D3D/etc.
@ -392,14 +392,15 @@ dword_result_t MmAllocatePhysicalMemoryEx(dword_t flags, dword_t region_size,
}
DECLARE_XBOXKRNL_EXPORT1(MmAllocatePhysicalMemoryEx, kMemory, kImplemented);
dword_result_t MmAllocatePhysicalMemory(dword_t flags, dword_t region_size,
dword_t protect_bits) {
return MmAllocatePhysicalMemoryEx(flags, region_size, protect_bits, 0,
0xFFFFFFFFu, 0);
dword_result_t MmAllocatePhysicalMemory_entry(dword_t flags,
dword_t region_size,
dword_t protect_bits) {
return MmAllocatePhysicalMemoryEx_entry(flags, region_size, protect_bits, 0,
0xFFFFFFFFu, 0);
}
DECLARE_XBOXKRNL_EXPORT1(MmAllocatePhysicalMemory, kMemory, kImplemented);
void MmFreePhysicalMemory(dword_t type, dword_t base_address) {
void MmFreePhysicalMemory_entry(dword_t type, dword_t base_address) {
// base_address = result of MmAllocatePhysicalMemory.
assert_true((base_address & 0x1F) == 0);
@ -409,7 +410,7 @@ void MmFreePhysicalMemory(dword_t type, dword_t base_address) {
}
DECLARE_XBOXKRNL_EXPORT1(MmFreePhysicalMemory, kMemory, kImplemented);
dword_result_t MmQueryAddressProtect(dword_t base_address) {
dword_result_t MmQueryAddressProtect_entry(dword_t base_address) {
auto heap = kernel_state()->memory()->LookupHeap(base_address);
uint32_t access;
if (!heap->QueryProtect(base_address, &access)) {
@ -422,8 +423,8 @@ dword_result_t MmQueryAddressProtect(dword_t base_address) {
DECLARE_XBOXKRNL_EXPORT2(MmQueryAddressProtect, kMemory, kImplemented,
kHighFrequency);
void MmSetAddressProtect(lpvoid_t base_address, dword_t region_size,
dword_t protect_bits) {
void MmSetAddressProtect_entry(lpvoid_t base_address, dword_t region_size,
dword_t protect_bits) {
if (!protect_bits) {
XELOGE("MmSetAddressProtect: Failed due to incorrect protect_bits");
return;
@ -435,7 +436,7 @@ void MmSetAddressProtect(lpvoid_t base_address, dword_t region_size,
}
DECLARE_XBOXKRNL_EXPORT1(MmSetAddressProtect, kMemory, kImplemented);
dword_result_t MmQueryAllocationSize(lpvoid_t base_address) {
dword_result_t MmQueryAllocationSize_entry(lpvoid_t base_address) {
auto heap = kernel_state()->memory()->LookupHeap(base_address);
uint32_t size;
if (!heap->QuerySize(base_address, &size)) {
@ -471,7 +472,7 @@ struct X_MM_QUERY_STATISTICS_RESULT {
};
static_assert_size(X_MM_QUERY_STATISTICS_RESULT, 104);
dword_result_t MmQueryStatistics(
dword_result_t MmQueryStatistics_entry(
pointer_t<X_MM_QUERY_STATISTICS_RESULT> stats_ptr) {
if (!stats_ptr) {
return X_STATUS_INVALID_PARAMETER;
@ -550,7 +551,7 @@ dword_result_t MmQueryStatistics(
DECLARE_XBOXKRNL_EXPORT1(MmQueryStatistics, kMemory, kImplemented);
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff554547(v=vs.85).aspx
dword_result_t MmGetPhysicalAddress(dword_t base_address) {
dword_result_t MmGetPhysicalAddress_entry(dword_t base_address) {
// PHYSICAL_ADDRESS MmGetPhysicalAddress(
// _In_ PVOID BaseAddress
// );
@ -564,8 +565,8 @@ dword_result_t MmGetPhysicalAddress(dword_t base_address) {
}
DECLARE_XBOXKRNL_EXPORT1(MmGetPhysicalAddress, kMemory, kImplemented);
dword_result_t MmMapIoSpace(dword_t unk0, lpvoid_t src_address, dword_t size,
dword_t flags) {
dword_result_t MmMapIoSpace_entry(dword_t unk0, lpvoid_t src_address,
dword_t size, dword_t flags) {
// I've only seen this used to map XMA audio contexts.
// The code seems fine with taking the src address, so this just returns that.
// If others start using it there could be problems.
@ -577,8 +578,8 @@ dword_result_t MmMapIoSpace(dword_t unk0, lpvoid_t src_address, dword_t size,
}
DECLARE_XBOXKRNL_EXPORT1(MmMapIoSpace, kMemory, kImplemented);
dword_result_t ExAllocatePoolTypeWithTag(dword_t size, dword_t tag,
dword_t zero) {
dword_result_t ExAllocatePoolTypeWithTag_entry(dword_t size, dword_t tag,
dword_t zero) {
uint32_t alignment = 8;
uint32_t adjusted_size = size;
if (adjusted_size < 4 * 1024) {
@ -594,33 +595,33 @@ dword_result_t ExAllocatePoolTypeWithTag(dword_t size, dword_t tag,
}
DECLARE_XBOXKRNL_EXPORT1(ExAllocatePoolTypeWithTag, kMemory, kImplemented);
dword_result_t ExAllocatePool(dword_t size) {
dword_result_t ExAllocatePool_entry(dword_t size) {
const uint32_t none = 0x656E6F4E; // 'None'
return ExAllocatePoolTypeWithTag(size, none, 0);
return ExAllocatePoolTypeWithTag_entry(size, none, 0);
}
DECLARE_XBOXKRNL_EXPORT1(ExAllocatePool, kMemory, kImplemented);
void ExFreePool(lpvoid_t base_address) {
void ExFreePool_entry(lpvoid_t base_address) {
kernel_state()->memory()->SystemHeapFree(base_address);
}
DECLARE_XBOXKRNL_EXPORT1(ExFreePool, kMemory, kImplemented);
dword_result_t KeGetImagePageTableEntry(lpvoid_t address) {
dword_result_t KeGetImagePageTableEntry_entry(lpvoid_t address) {
// Unknown
return 1;
}
DECLARE_XBOXKRNL_EXPORT1(KeGetImagePageTableEntry, kMemory, kStub);
dword_result_t KeLockL2() {
dword_result_t KeLockL2_entry() {
// TODO
return 0;
}
DECLARE_XBOXKRNL_EXPORT1(KeLockL2, kMemory, kStub);
void KeUnlockL2() {}
void KeUnlockL2_entry() {}
DECLARE_XBOXKRNL_EXPORT1(KeUnlockL2, kMemory, kStub);
dword_result_t MmCreateKernelStack(dword_t stack_size, dword_t r4) {
dword_result_t MmCreateKernelStack_entry(dword_t stack_size, dword_t r4) {
assert_zero(r4); // Unknown argument.
auto stack_size_aligned = (stack_size + 0xFFF) & 0xFFFFF000;
@ -637,7 +638,8 @@ dword_result_t MmCreateKernelStack(dword_t stack_size, dword_t r4) {
}
DECLARE_XBOXKRNL_EXPORT1(MmCreateKernelStack, kMemory, kImplemented);
dword_result_t MmDeleteKernelStack(lpvoid_t stack_base, lpvoid_t stack_end) {
dword_result_t MmDeleteKernelStack_entry(lpvoid_t stack_base,
lpvoid_t stack_end) {
// Release the stack (where stack_end is the low address)
if (kernel_memory()->LookupHeap(0x70000000)->Release(stack_end)) {
return X_STATUS_SUCCESS;

View File

@ -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. *
******************************************************************************
*/
@ -18,7 +18,7 @@ namespace xe {
namespace kernel {
namespace xboxkrnl {
void KeEnableFpuExceptions(dword_t enabled) {
void KeEnableFpuExceptions_entry(dword_t enabled) {
// TODO(benvanik): can we do anything about exceptions?
}
DECLARE_XBOXKRNL_EXPORT1(KeEnableFpuExceptions, kNone, kStub);

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2020 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. *
******************************************************************************
*/
@ -19,7 +19,7 @@ namespace xe {
namespace kernel {
namespace xboxkrnl {
dword_result_t XexCheckExecutablePrivilege(dword_t privilege) {
dword_result_t XexCheckExecutablePrivilege_entry(dword_t privilege) {
// BOOL
// DWORD Privilege
@ -39,8 +39,8 @@ dword_result_t XexCheckExecutablePrivilege(dword_t privilege) {
}
DECLARE_XBOXKRNL_EXPORT1(XexCheckExecutablePrivilege, kModules, kImplemented);
dword_result_t XexGetModuleHandle(lpstring_t module_name,
lpdword_t hmodule_ptr) {
dword_result_t XexGetModuleHandle_entry(lpstring_t module_name,
lpdword_t hmodule_ptr) {
object_ref<XModule> module;
if (!module_name) {
@ -61,8 +61,9 @@ dword_result_t XexGetModuleHandle(lpstring_t module_name,
}
DECLARE_XBOXKRNL_EXPORT1(XexGetModuleHandle, kModules, kImplemented);
dword_result_t XexGetModuleSection(lpvoid_t hmodule, lpstring_t name,
lpdword_t data_ptr, lpdword_t size_ptr) {
dword_result_t XexGetModuleSection_entry(lpvoid_t hmodule, lpstring_t name,
lpdword_t data_ptr,
lpdword_t size_ptr) {
X_STATUS result = X_STATUS_SUCCESS;
auto module = XModule::GetFromHModule(kernel_state(), hmodule);
@ -82,8 +83,8 @@ dword_result_t XexGetModuleSection(lpvoid_t hmodule, lpstring_t name,
}
DECLARE_XBOXKRNL_EXPORT1(XexGetModuleSection, kModules, kImplemented);
dword_result_t XexLoadImage(lpstring_t module_name, dword_t module_flags,
dword_t min_version, lpdword_t hmodule_ptr) {
dword_result_t XexLoadImage_entry(lpstring_t module_name, dword_t module_flags,
dword_t min_version, lpdword_t hmodule_ptr) {
X_STATUS result = X_STATUS_NO_SUCH_FILE;
uint32_t hmodule = 0;
@ -117,7 +118,7 @@ dword_result_t XexLoadImage(lpstring_t module_name, dword_t module_flags,
}
DECLARE_XBOXKRNL_EXPORT1(XexLoadImage, kModules, kImplemented);
dword_result_t XexUnloadImage(lpvoid_t hmodule) {
dword_result_t XexUnloadImage_entry(lpvoid_t hmodule) {
auto module = XModule::GetFromHModule(kernel_state(), hmodule);
if (!module) {
return X_STATUS_INVALID_HANDLE;
@ -138,8 +139,8 @@ dword_result_t XexUnloadImage(lpvoid_t hmodule) {
}
DECLARE_XBOXKRNL_EXPORT1(XexUnloadImage, kModules, kImplemented);
dword_result_t XexGetProcedureAddress(lpvoid_t hmodule, dword_t ordinal,
lpdword_t out_function_ptr) {
dword_result_t XexGetProcedureAddress_entry(lpvoid_t hmodule, dword_t ordinal,
lpdword_t out_function_ptr) {
// May be entry point?
assert_not_zero(ordinal);
@ -184,7 +185,7 @@ dword_result_t XexGetProcedureAddress(lpvoid_t hmodule, dword_t ordinal,
}
DECLARE_XBOXKRNL_EXPORT1(XexGetProcedureAddress, kModules, kImplemented);
void ExRegisterTitleTerminateNotification(
void ExRegisterTitleTerminateNotification_entry(
pointer_t<X_EX_TITLE_TERMINATE_REGISTRATION> reg, dword_t create) {
if (create) {
// Adding.

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2020 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. *
******************************************************************************
*/
@ -20,9 +20,9 @@ namespace xe {
namespace kernel {
namespace xboxkrnl {
dword_result_t ObOpenObjectByName(lpunknown_t obj_attributes_ptr,
lpunknown_t object_type_ptr, dword_t unk,
lpdword_t handle_ptr) {
dword_result_t ObOpenObjectByName_entry(lpunknown_t obj_attributes_ptr,
lpunknown_t object_type_ptr,
dword_t unk, lpdword_t handle_ptr) {
// r3 = ptr to info?
// +0 = -4
// +4 = name ptr
@ -47,8 +47,8 @@ dword_result_t ObOpenObjectByName(lpunknown_t obj_attributes_ptr,
}
DECLARE_XBOXKRNL_EXPORT1(ObOpenObjectByName, kNone, kImplemented);
dword_result_t ObOpenObjectByPointer(lpvoid_t object_ptr,
lpdword_t out_handle_ptr) {
dword_result_t ObOpenObjectByPointer_entry(lpvoid_t object_ptr,
lpdword_t out_handle_ptr) {
auto object = XObject::GetNativeObject<XObject>(kernel_state(), object_ptr);
if (!object) {
return X_STATUS_UNSUCCESSFUL;
@ -61,8 +61,8 @@ dword_result_t ObOpenObjectByPointer(lpvoid_t object_ptr,
}
DECLARE_XBOXKRNL_EXPORT1(ObOpenObjectByPointer, kNone, kImplemented);
dword_result_t ObLookupThreadByThreadId(dword_t thread_id,
lpdword_t out_object_ptr) {
dword_result_t ObLookupThreadByThreadId_entry(dword_t thread_id,
lpdword_t out_object_ptr) {
auto thread = kernel_state()->GetThreadByID(thread_id);
if (!thread) {
return X_STATUS_NOT_FOUND;
@ -75,9 +75,9 @@ dword_result_t ObLookupThreadByThreadId(dword_t thread_id,
}
DECLARE_XBOXKRNL_EXPORT1(ObLookupThreadByThreadId, kNone, kImplemented);
dword_result_t ObReferenceObjectByHandle(dword_t handle,
dword_t object_type_ptr,
lpdword_t out_object_ptr) {
dword_result_t ObReferenceObjectByHandle_entry(dword_t handle,
dword_t object_type_ptr,
lpdword_t out_object_ptr) {
// These values come from how Xenia handles uninitialized kernel data exports.
// D###BEEF where ### is the ordinal.
const static std::unordered_map<XObject::Type, uint32_t> object_types = {
@ -109,22 +109,24 @@ dword_result_t ObReferenceObjectByHandle(dword_t handle,
}
DECLARE_XBOXKRNL_EXPORT1(ObReferenceObjectByHandle, kNone, kImplemented);
dword_result_t ObReferenceObjectByName(lpstring_t name, dword_t attributes,
dword_t object_type_ptr,
lpvoid_t parse_context,
lpdword_t out_object_ptr) {
dword_result_t ObReferenceObjectByName_entry(lpstring_t name,
dword_t attributes,
dword_t object_type_ptr,
lpvoid_t parse_context,
lpdword_t out_object_ptr) {
X_HANDLE handle = X_INVALID_HANDLE_VALUE;
X_STATUS result =
kernel_state()->object_table()->GetObjectByName(name.value(), &handle);
if (XSUCCEEDED(result)) {
return ObReferenceObjectByHandle(handle, object_type_ptr, out_object_ptr);
return ObReferenceObjectByHandle_entry(handle, object_type_ptr,
out_object_ptr);
}
return result;
}
DECLARE_XBOXKRNL_EXPORT1(ObReferenceObjectByName, kNone, kImplemented);
dword_result_t ObDereferenceObject(dword_t native_ptr) {
dword_result_t ObDereferenceObject_entry(dword_t native_ptr) {
// Check if a dummy value from ObReferenceObjectByHandle.
if (native_ptr == 0xDEADF00D) {
return 0;
@ -140,8 +142,8 @@ dword_result_t ObDereferenceObject(dword_t native_ptr) {
}
DECLARE_XBOXKRNL_EXPORT1(ObDereferenceObject, kNone, kImplemented);
dword_result_t ObCreateSymbolicLink(pointer_t<X_ANSI_STRING> path_ptr,
pointer_t<X_ANSI_STRING> target_ptr) {
dword_result_t ObCreateSymbolicLink_entry(pointer_t<X_ANSI_STRING> path_ptr,
pointer_t<X_ANSI_STRING> target_ptr) {
auto path = util::TranslateAnsiString(kernel_memory(), path_ptr);
auto target = util::TranslateAnsiString(kernel_memory(), target_ptr);
path = xe::utf8::canonicalize_guest_path(path);
@ -159,7 +161,7 @@ dword_result_t ObCreateSymbolicLink(pointer_t<X_ANSI_STRING> path_ptr,
}
DECLARE_XBOXKRNL_EXPORT1(ObCreateSymbolicLink, kNone, kImplemented);
dword_result_t ObDeleteSymbolicLink(pointer_t<X_ANSI_STRING> path_ptr) {
dword_result_t ObDeleteSymbolicLink_entry(pointer_t<X_ANSI_STRING> path_ptr) {
auto path = util::TranslateAnsiString(kernel_memory(), path_ptr);
if (!kernel_state()->file_system()->UnregisterSymbolicLink(path)) {
return X_STATUS_UNSUCCESSFUL;
@ -169,8 +171,8 @@ dword_result_t ObDeleteSymbolicLink(pointer_t<X_ANSI_STRING> path_ptr) {
}
DECLARE_XBOXKRNL_EXPORT1(ObDeleteSymbolicLink, kNone, kImplemented);
dword_result_t NtDuplicateObject(dword_t handle, lpdword_t new_handle_ptr,
dword_t options) {
dword_result_t NtDuplicateObject_entry(dword_t handle, lpdword_t new_handle_ptr,
dword_t options) {
// NOTE: new_handle_ptr can be zero to just close a handle.
// NOTE: this function seems to be used to get the current thread handle
// (passed handle=-2).
@ -194,7 +196,7 @@ dword_result_t NtDuplicateObject(dword_t handle, lpdword_t new_handle_ptr,
}
DECLARE_XBOXKRNL_EXPORT1(NtDuplicateObject, kNone, kImplemented);
dword_result_t NtClose(dword_t handle) {
dword_result_t NtClose_entry(dword_t handle) {
return kernel_state()->object_table()->ReleaseHandle(handle);
}
DECLARE_XBOXKRNL_EXPORT1(NtClose, kNone, kImplemented);

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2020 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. *
******************************************************************************
*/
@ -30,8 +30,8 @@ namespace kernel {
namespace xboxkrnl {
// https://msdn.microsoft.com/en-us/library/ff561778
dword_result_t RtlCompareMemory(lpvoid_t source1, lpvoid_t source2,
dword_t length) {
dword_result_t RtlCompareMemory_entry(lpvoid_t source1, lpvoid_t source2,
dword_t length) {
uint8_t* p1 = source1;
uint8_t* p2 = source2;
@ -51,8 +51,8 @@ dword_result_t RtlCompareMemory(lpvoid_t source1, lpvoid_t source2,
DECLARE_XBOXKRNL_EXPORT1(RtlCompareMemory, kMemory, kImplemented);
// https://msdn.microsoft.com/en-us/library/ff552123
dword_result_t RtlCompareMemoryUlong(lpvoid_t source, dword_t length,
dword_t pattern) {
dword_result_t RtlCompareMemoryUlong_entry(lpvoid_t source, dword_t length,
dword_t pattern) {
// Return 0 if source/length not aligned
if (source.guest_address() % 4 || length % 4) {
return 0;
@ -72,7 +72,8 @@ dword_result_t RtlCompareMemoryUlong(lpvoid_t source, dword_t length,
DECLARE_XBOXKRNL_EXPORT1(RtlCompareMemoryUlong, kMemory, kImplemented);
// https://msdn.microsoft.com/en-us/library/ff552263
void RtlFillMemoryUlong(lpvoid_t destination, dword_t length, dword_t pattern) {
void RtlFillMemoryUlong_entry(lpvoid_t destination, dword_t length,
dword_t pattern) {
// NOTE: length must be % 4, so we can work on uint32s.
uint32_t count = length >> 2;
@ -84,7 +85,7 @@ void RtlFillMemoryUlong(lpvoid_t destination, dword_t length, dword_t pattern) {
}
DECLARE_XBOXKRNL_EXPORT1(RtlFillMemoryUlong, kMemory, kImplemented);
dword_result_t RtlUpperChar(dword_t in) {
dword_result_t RtlUpperChar_entry(dword_t in) {
char c = in & 0xFF;
if (c >= 'a' && c <= 'z') {
return c ^ 0x20;
@ -94,7 +95,7 @@ dword_result_t RtlUpperChar(dword_t in) {
}
DECLARE_XBOXKRNL_EXPORT1(RtlUpperChar, kNone, kImplemented);
dword_result_t RtlLowerChar(dword_t in) {
dword_result_t RtlLowerChar_entry(dword_t in) {
char c = in & 0xFF;
if (c >= 'A' && c <= 'Z') {
return c ^ 0x20;
@ -104,8 +105,8 @@ dword_result_t RtlLowerChar(dword_t in) {
}
DECLARE_XBOXKRNL_EXPORT1(RtlLowerChar, kNone, kImplemented);
dword_result_t RtlCompareString(lpstring_t string_1, lpstring_t string_2,
dword_t case_insensitive) {
dword_result_t RtlCompareString_entry(lpstring_t string_1, lpstring_t string_2,
dword_t case_insensitive) {
int ret = case_insensitive ? strcasecmp(string_1, string_2)
: std::strcmp(string_1, string_2);
@ -113,9 +114,11 @@ dword_result_t RtlCompareString(lpstring_t string_1, lpstring_t string_2,
}
DECLARE_XBOXKRNL_EXPORT1(RtlCompareString, kNone, kImplemented);
dword_result_t RtlCompareStringN(lpstring_t string_1, dword_t string_1_len,
lpstring_t string_2, dword_t string_2_len,
dword_t case_insensitive) {
dword_result_t RtlCompareStringN_entry(lpstring_t string_1,
dword_t string_1_len,
lpstring_t string_2,
dword_t string_2_len,
dword_t case_insensitive) {
uint32_t len1 = string_1_len;
uint32_t len2 = string_2_len;
@ -135,8 +138,8 @@ dword_result_t RtlCompareStringN(lpstring_t string_1, dword_t string_1_len,
DECLARE_XBOXKRNL_EXPORT1(RtlCompareStringN, kNone, kImplemented);
// https://msdn.microsoft.com/en-us/library/ff561918
void RtlInitAnsiString(pointer_t<X_ANSI_STRING> destination,
lpstring_t source) {
void RtlInitAnsiString_entry(pointer_t<X_ANSI_STRING> destination,
lpstring_t source) {
if (source) {
uint16_t length = (uint16_t)strlen(source);
destination->length = length;
@ -150,7 +153,7 @@ void RtlInitAnsiString(pointer_t<X_ANSI_STRING> destination,
DECLARE_XBOXKRNL_EXPORT1(RtlInitAnsiString, kNone, kImplemented);
// https://msdn.microsoft.com/en-us/library/ff561899
void RtlFreeAnsiString(pointer_t<X_ANSI_STRING> string) {
void RtlFreeAnsiString_entry(pointer_t<X_ANSI_STRING> string) {
if (string->pointer) {
kernel_memory()->SystemHeapFree(string->pointer);
}
@ -160,8 +163,8 @@ void RtlFreeAnsiString(pointer_t<X_ANSI_STRING> string) {
DECLARE_XBOXKRNL_EXPORT1(RtlFreeAnsiString, kNone, kImplemented);
// https://msdn.microsoft.com/en-us/library/ff561934
void RtlInitUnicodeString(pointer_t<X_UNICODE_STRING> destination,
lpu16string_t source) {
void RtlInitUnicodeString_entry(pointer_t<X_UNICODE_STRING> destination,
lpu16string_t source) {
if (source) {
destination->length = (uint16_t)source.value().size() * 2;
destination->maximum_length = (uint16_t)(source.value().size() + 1) * 2;
@ -173,7 +176,7 @@ void RtlInitUnicodeString(pointer_t<X_UNICODE_STRING> destination,
DECLARE_XBOXKRNL_EXPORT1(RtlInitUnicodeString, kNone, kImplemented);
// https://msdn.microsoft.com/en-us/library/ff561903
void RtlFreeUnicodeString(pointer_t<X_UNICODE_STRING> string) {
void RtlFreeUnicodeString_entry(pointer_t<X_UNICODE_STRING> string) {
if (string->pointer) {
kernel_memory()->SystemHeapFree(string->pointer);
}
@ -182,8 +185,8 @@ void RtlFreeUnicodeString(pointer_t<X_UNICODE_STRING> string) {
}
DECLARE_XBOXKRNL_EXPORT1(RtlFreeUnicodeString, kNone, kImplemented);
void RtlCopyString(pointer_t<X_ANSI_STRING> destination,
pointer_t<X_ANSI_STRING> source) {
void RtlCopyString_entry(pointer_t<X_ANSI_STRING> destination,
pointer_t<X_ANSI_STRING> source) {
if (!source) {
destination->length = 0;
return;
@ -199,8 +202,8 @@ void RtlCopyString(pointer_t<X_ANSI_STRING> destination,
}
DECLARE_XBOXKRNL_EXPORT1(RtlCopyString, kNone, kImplemented);
void RtlCopyUnicodeString(pointer_t<X_UNICODE_STRING> destination,
pointer_t<X_UNICODE_STRING> source) {
void RtlCopyUnicodeString_entry(pointer_t<X_UNICODE_STRING> destination,
pointer_t<X_UNICODE_STRING> source) {
if (!source) {
destination->length = 0;
return;
@ -217,7 +220,7 @@ void RtlCopyUnicodeString(pointer_t<X_UNICODE_STRING> destination,
DECLARE_XBOXKRNL_EXPORT1(RtlCopyUnicodeString, kNone, kImplemented);
// https://msdn.microsoft.com/en-us/library/ff562969
dword_result_t RtlUnicodeStringToAnsiString(
dword_result_t RtlUnicodeStringToAnsiString_entry(
pointer_t<X_ANSI_STRING> destination_ptr,
pointer_t<X_UNICODE_STRING> source_ptr, dword_t alloc_dest) {
// NTSTATUS
@ -261,11 +264,11 @@ dword_result_t RtlUnicodeStringToAnsiString(
DECLARE_XBOXKRNL_EXPORT1(RtlUnicodeStringToAnsiString, kNone, kImplemented);
// https://msdn.microsoft.com/en-us/library/ff553113
dword_result_t RtlMultiByteToUnicodeN(lpword_t destination_ptr,
dword_t destination_len,
lpdword_t written_ptr,
pointer_t<uint8_t> source_ptr,
dword_t source_len) {
dword_result_t RtlMultiByteToUnicodeN_entry(lpword_t destination_ptr,
dword_t destination_len,
lpdword_t written_ptr,
pointer_t<uint8_t> source_ptr,
dword_t source_len) {
uint32_t copy_len = destination_len >> 1;
copy_len = copy_len < source_len ? copy_len : source_len.value();
@ -286,10 +289,11 @@ DECLARE_XBOXKRNL_EXPORT3(RtlMultiByteToUnicodeN, kNone, kImplemented,
kHighFrequency, kSketchy);
// https://msdn.microsoft.com/en-us/library/ff553261
dword_result_t RtlUnicodeToMultiByteN(pointer_t<uint8_t> destination_ptr,
dword_t destination_len,
lpdword_t written_ptr,
lpword_t source_ptr, dword_t source_len) {
dword_result_t RtlUnicodeToMultiByteN_entry(pointer_t<uint8_t> destination_ptr,
dword_t destination_len,
lpdword_t written_ptr,
lpword_t source_ptr,
dword_t source_len) {
uint32_t copy_len = source_len >> 1;
copy_len = copy_len < destination_len ? copy_len : destination_len.value();
@ -302,14 +306,13 @@ dword_result_t RtlUnicodeToMultiByteN(pointer_t<uint8_t> destination_ptr,
if (written_ptr.guest_address() != 0) {
*written_ptr = copy_len;
}
return 0;
}
DECLARE_XBOXKRNL_EXPORT3(RtlUnicodeToMultiByteN, kNone, kImplemented,
kHighFrequency, kSketchy);
// https://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/Executable%20Images/RtlImageNtHeader.html
pointer_result_t RtlImageNtHeader(lpvoid_t module) {
pointer_result_t RtlImageNtHeader_entry(lpvoid_t module) {
if (!module) {
return 0;
}
@ -332,8 +335,8 @@ pointer_result_t RtlImageNtHeader(lpvoid_t module) {
}
DECLARE_XBOXKRNL_EXPORT1(RtlImageNtHeader, kNone, kImplemented);
pointer_result_t RtlImageXexHeaderField(pointer_t<xex2_header> xex_header,
dword_t field_dword) {
pointer_result_t RtlImageXexHeaderField_entry(pointer_t<xex2_header> xex_header,
dword_t field_dword) {
uint32_t field_value = 0;
uint32_t field = field_dword; // VS acts weird going from dword_t -> enum
@ -382,7 +385,7 @@ void xeRtlInitializeCriticalSection(X_RTL_CRITICAL_SECTION* cs,
cs->owning_thread = 0;
}
void RtlInitializeCriticalSection(pointer_t<X_RTL_CRITICAL_SECTION> cs) {
void RtlInitializeCriticalSection_entry(pointer_t<X_RTL_CRITICAL_SECTION> cs) {
xeRtlInitializeCriticalSection(cs, cs.guest_address());
}
DECLARE_XBOXKRNL_EXPORT1(RtlInitializeCriticalSection, kNone, kImplemented);
@ -407,7 +410,7 @@ X_STATUS xeRtlInitializeCriticalSectionAndSpinCount(X_RTL_CRITICAL_SECTION* cs,
return X_STATUS_SUCCESS;
}
dword_result_t RtlInitializeCriticalSectionAndSpinCount(
dword_result_t RtlInitializeCriticalSectionAndSpinCount_entry(
pointer_t<X_RTL_CRITICAL_SECTION> cs, dword_t spin_count) {
return xeRtlInitializeCriticalSectionAndSpinCount(cs, cs.guest_address(),
spin_count);
@ -415,7 +418,7 @@ dword_result_t RtlInitializeCriticalSectionAndSpinCount(
DECLARE_XBOXKRNL_EXPORT1(RtlInitializeCriticalSectionAndSpinCount, kNone,
kImplemented);
void RtlEnterCriticalSection(pointer_t<X_RTL_CRITICAL_SECTION> cs) {
void RtlEnterCriticalSection_entry(pointer_t<X_RTL_CRITICAL_SECTION> cs) {
uint32_t cur_thread = XThread::GetCurrentThread()->guest_object();
uint32_t spin_count = cs->header.absolute * 256;
@ -449,7 +452,7 @@ void RtlEnterCriticalSection(pointer_t<X_RTL_CRITICAL_SECTION> cs) {
DECLARE_XBOXKRNL_EXPORT2(RtlEnterCriticalSection, kNone, kImplemented,
kHighFrequency);
dword_result_t RtlTryEnterCriticalSection(
dword_result_t RtlTryEnterCriticalSection_entry(
pointer_t<X_RTL_CRITICAL_SECTION> cs) {
uint32_t thread = XThread::GetCurrentThread()->guest_object();
@ -471,7 +474,7 @@ dword_result_t RtlTryEnterCriticalSection(
DECLARE_XBOXKRNL_EXPORT2(RtlTryEnterCriticalSection, kNone, kImplemented,
kHighFrequency);
void RtlLeaveCriticalSection(pointer_t<X_RTL_CRITICAL_SECTION> cs) {
void RtlLeaveCriticalSection_entry(pointer_t<X_RTL_CRITICAL_SECTION> cs) {
assert_true(cs->owning_thread == XThread::GetCurrentThread()->guest_object());
// Drop recursion count - if it isn't zero we still have the lock.
@ -506,8 +509,8 @@ struct X_TIME_FIELDS {
static_assert_size(X_TIME_FIELDS, 16);
// https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtltimetotimefields
void RtlTimeToTimeFields(lpqword_t time_ptr,
pointer_t<X_TIME_FIELDS> time_fields_ptr) {
void RtlTimeToTimeFields_entry(lpqword_t time_ptr,
pointer_t<X_TIME_FIELDS> time_fields_ptr) {
auto tp = XClock::to_sys(XClock::from_file_time(time_ptr.value()));
auto dp = date::floor<date::days>(tp);
auto year_month_day = date::year_month_day{dp};
@ -526,8 +529,8 @@ void RtlTimeToTimeFields(lpqword_t time_ptr,
DECLARE_XBOXKRNL_EXPORT1(RtlTimeToTimeFields, kNone, kImplemented);
// https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtltimefieldstotime
dword_result_t RtlTimeFieldsToTime(pointer_t<X_TIME_FIELDS> time_fields_ptr,
lpqword_t time_ptr) {
dword_result_t RtlTimeFieldsToTime_entry(
pointer_t<X_TIME_FIELDS> time_fields_ptr, lpqword_t time_ptr) {
if (time_fields_ptr->year < 1601 || time_fields_ptr->month < 1 ||
time_fields_ptr->month > 12 || time_fields_ptr->day < 1 ||
time_fields_ptr->day > 31 || time_fields_ptr->hour > 23 ||
@ -608,7 +611,8 @@ static uint32_t crc32_table[256] = {
0x2D02EF8Du,
};
dword_result_t RtlComputeCrc32(dword_t seed, lpvoid_t buffer, dword_t length) {
dword_result_t RtlComputeCrc32_entry(dword_t seed, lpvoid_t buffer,
dword_t length) {
if (!length) {
return seed.value();
}

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2020 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. *
******************************************************************************
*/
@ -824,7 +824,7 @@ class WideCountFormatData : public FormatData {
int32_t count_;
};
SHIM_CALL DbgPrint_shim(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL DbgPrint_entry(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t format_ptr = SHIM_GET_ARG_32(0);
if (!format_ptr) {
SHIM_SET_RETURN_32(X_STATUS_INVALID_PARAMETER);
@ -854,7 +854,7 @@ SHIM_CALL DbgPrint_shim(PPCContext* ppc_context, KernelState* kernel_state) {
}
// https://msdn.microsoft.com/en-us/library/2ts7cx93.aspx
SHIM_CALL _snprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL _snprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
int32_t buffer_count = SHIM_GET_ARG_32(1);
uint32_t format_ptr = SHIM_GET_ARG_32(2);
@ -894,7 +894,7 @@ SHIM_CALL _snprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
}
// https://msdn.microsoft.com/en-us/library/ybk95axf.aspx
SHIM_CALL sprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL sprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
uint32_t format_ptr = SHIM_GET_ARG_32(1);
@ -925,7 +925,7 @@ SHIM_CALL sprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
}
// https://msdn.microsoft.com/en-us/library/2ts7cx93.aspx
SHIM_CALL _snwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL _snwprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
int32_t buffer_count = SHIM_GET_ARG_32(1);
uint32_t format_ptr = SHIM_GET_ARG_32(2);
@ -966,7 +966,7 @@ SHIM_CALL _snwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
}
// https://msdn.microsoft.com/en-us/library/ybk95axf.aspx
SHIM_CALL swprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL swprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
uint32_t format_ptr = SHIM_GET_ARG_32(1);
@ -998,7 +998,7 @@ SHIM_CALL swprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
}
// https://msdn.microsoft.com/en-us/library/1kt27hek.aspx
SHIM_CALL _vsnprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL _vsnprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
int32_t buffer_count = SHIM_GET_ARG_32(1);
uint32_t format_ptr = SHIM_GET_ARG_32(2);
@ -1041,7 +1041,8 @@ SHIM_CALL _vsnprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
}
// https://msdn.microsoft.com/en-us/library/1kt27hek.aspx
SHIM_CALL _vsnwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL _vsnwprintf_entry(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
int32_t buffer_count = SHIM_GET_ARG_32(1);
uint32_t format_ptr = SHIM_GET_ARG_32(2);
@ -1086,7 +1087,7 @@ SHIM_CALL _vsnwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
}
// https://msdn.microsoft.com/en-us/library/28d5ce15.aspx
SHIM_CALL vsprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL vsprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
uint32_t format_ptr = SHIM_GET_ARG_32(1);
uint32_t arg_ptr = SHIM_GET_ARG_32(2);
@ -1118,7 +1119,8 @@ SHIM_CALL vsprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
}
// https://msdn.microsoft.com/en-us/library/w05tbk72.aspx
SHIM_CALL _vscwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL _vscwprintf_entry(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t format_ptr = SHIM_GET_ARG_32(0);
uint32_t arg_ptr = SHIM_GET_ARG_32(1);
@ -1145,7 +1147,7 @@ SHIM_CALL _vscwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
}
// https://msdn.microsoft.com/en-us/library/28d5ce15.aspx
SHIM_CALL vswprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_CALL vswprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
uint32_t format_ptr = SHIM_GET_ARG_32(1);
uint32_t arg_ptr = SHIM_GET_ARG_32(2);

View File

@ -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;

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2014 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. *
******************************************************************************
*/
@ -17,9 +17,9 @@ namespace xe {
namespace kernel {
namespace xboxkrnl {
dword_result_t XUsbcamCreate(dword_t buffer,
dword_t buffer_size, // 0x4B000 640x480?
lpunknown_t unk3_ptr) {
dword_result_t XUsbcamCreate_entry(dword_t buffer,
dword_t buffer_size, // 0x4B000 640x480?
lpunknown_t unk3_ptr) {
// This function should return success.
// It looks like it only allocates space for usbcam support.
// returning error code might cause games to initialize incorrectly.
@ -31,7 +31,7 @@ dword_result_t XUsbcamCreate(dword_t buffer,
}
DECLARE_XBOXKRNL_EXPORT1(XUsbcamCreate, kNone, kStub);
dword_result_t XUsbcamGetState() {
dword_result_t XUsbcamGetState_entry() {
// 0 = not connected.
return 0;
}

View File

@ -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. *
******************************************************************************
*/
@ -48,7 +48,7 @@ namespace xboxkrnl {
// https://www.microsoft.com/en-za/download/details.aspx?id=5313 -- "Stripped
// Down Direct3D: Xbox 360 Command Buffer and Resource Management"
void VdGetCurrentDisplayGamma(lpdword_t type_ptr, lpfloat_t power_ptr) {
void VdGetCurrentDisplayGamma_entry(lpdword_t type_ptr, lpfloat_t power_ptr) {
// 1 - sRGB.
// 2 - TV (BT.709).
// 3 - use the power written to *power_ptr.
@ -104,9 +104,8 @@ struct X_DISPLAY_INFO {
};
static_assert_size(X_DISPLAY_INFO, 0x58);
void VdQueryVideoMode(pointer_t<X_VIDEO_MODE> video_mode);
void VdGetCurrentDisplayInformation(pointer_t<X_DISPLAY_INFO> display_info) {
void VdGetCurrentDisplayInformation_entry(
pointer_t<X_DISPLAY_INFO> display_info) {
X_VIDEO_MODE mode;
VdQueryVideoMode(&mode);
@ -132,9 +131,9 @@ void VdGetCurrentDisplayInformation(pointer_t<X_DISPLAY_INFO> display_info) {
}
DECLARE_XBOXKRNL_EXPORT1(VdGetCurrentDisplayInformation, kVideo, kStub);
void VdQueryVideoMode(pointer_t<X_VIDEO_MODE> video_mode) {
void VdQueryVideoMode(X_VIDEO_MODE* video_mode) {
// TODO(benvanik): get info from actual display.
video_mode.Zero();
std::memset(video_mode, 0, sizeof(X_VIDEO_MODE));
video_mode->display_width = 1280;
video_mode->display_height = 720;
video_mode->is_interlaced = 0;
@ -145,9 +144,13 @@ void VdQueryVideoMode(pointer_t<X_VIDEO_MODE> video_mode) {
video_mode->unknown_0x8a = 0x4A;
video_mode->unknown_0x01 = 0x01;
}
void VdQueryVideoMode_entry(pointer_t<X_VIDEO_MODE> video_mode) {
VdQueryVideoMode(video_mode);
}
DECLARE_XBOXKRNL_EXPORT1(VdQueryVideoMode, kVideo, kStub);
dword_result_t VdQueryVideoFlags() {
dword_result_t VdQueryVideoFlags_entry() {
X_VIDEO_MODE mode;
VdQueryVideoMode(&mode);
@ -160,7 +163,7 @@ dword_result_t VdQueryVideoFlags() {
}
DECLARE_XBOXKRNL_EXPORT1(VdQueryVideoFlags, kVideo, kStub);
dword_result_t VdSetDisplayMode(dword_t flags) {
dword_result_t VdSetDisplayMode_entry(dword_t flags) {
// Often 0x40000000.
// 0?ccf000 00000000 00000000 000000r0
@ -179,17 +182,17 @@ dword_result_t VdSetDisplayMode(dword_t flags) {
}
DECLARE_XBOXKRNL_EXPORT1(VdSetDisplayMode, kVideo, kStub);
dword_result_t VdSetDisplayModeOverride(unknown_t unk0, unknown_t unk1,
double_t refresh_rate, unknown_t unk3,
unknown_t unk4) {
dword_result_t VdSetDisplayModeOverride_entry(unknown_t unk0, unknown_t unk1,
double_t refresh_rate,
unknown_t unk3, unknown_t unk4) {
// refresh_rate = 0, 50, 59.9, etc.
return 0;
}
DECLARE_XBOXKRNL_EXPORT1(VdSetDisplayModeOverride, kVideo, kStub);
dword_result_t VdInitializeEngines(unknown_t unk0, function_t callback,
lpvoid_t arg, lpdword_t pfp_ptr,
lpdword_t me_ptr) {
dword_result_t VdInitializeEngines_entry(unknown_t unk0, function_t callback,
lpvoid_t arg, lpdword_t pfp_ptr,
lpdword_t me_ptr) {
// r3 = 0x4F810000
// r4 = function ptr (cleanup callback?)
// r5 = function arg
@ -199,27 +202,28 @@ dword_result_t VdInitializeEngines(unknown_t unk0, function_t callback,
}
DECLARE_XBOXKRNL_EXPORT1(VdInitializeEngines, kVideo, kStub);
void VdShutdownEngines() {
void VdShutdownEngines_entry() {
// Ignored for now.
// Games seem to call an Initialize/Shutdown pair to query info, then
// re-initialize.
}
DECLARE_XBOXKRNL_EXPORT1(VdShutdownEngines, kVideo, kStub);
dword_result_t VdGetGraphicsAsicID() {
dword_result_t VdGetGraphicsAsicID_entry() {
// Games compare for < 0x10 and do VdInitializeEDRAM, else other
// (retrain/etc).
return 0x11;
}
DECLARE_XBOXKRNL_EXPORT1(VdGetGraphicsAsicID, kVideo, kStub);
dword_result_t VdEnableDisableClockGating(dword_t enabled) {
dword_result_t VdEnableDisableClockGating_entry(dword_t enabled) {
// Ignored, as it really doesn't matter.
return 0;
}
DECLARE_XBOXKRNL_EXPORT1(VdEnableDisableClockGating, kVideo, kStub);
void VdSetGraphicsInterruptCallback(function_t callback, lpvoid_t user_data) {
void VdSetGraphicsInterruptCallback_entry(function_t callback,
lpvoid_t user_data) {
// callback takes 2 params
// r3 = bool 0/1 - 0 is normal interrupt, 1 is some acquire/lock mumble
// r4 = user_data (r4 of VdSetGraphicsInterruptCallback)
@ -228,7 +232,7 @@ void VdSetGraphicsInterruptCallback(function_t callback, lpvoid_t user_data) {
}
DECLARE_XBOXKRNL_EXPORT1(VdSetGraphicsInterruptCallback, kVideo, kImplemented);
void VdInitializeRingBuffer(lpvoid_t ptr, int_t size_log2) {
void VdInitializeRingBuffer_entry(lpvoid_t ptr, int_t size_log2) {
// r3 = result of MmGetPhysicalAddress
// r4 = log2(size)
// Buffer pointers are from MmAllocatePhysicalMemory with WRITE_COMBINE.
@ -237,21 +241,22 @@ void VdInitializeRingBuffer(lpvoid_t ptr, int_t size_log2) {
}
DECLARE_XBOXKRNL_EXPORT1(VdInitializeRingBuffer, kVideo, kImplemented);
void VdEnableRingBufferRPtrWriteBack(lpvoid_t ptr, int_t block_size_log2) {
void VdEnableRingBufferRPtrWriteBack_entry(lpvoid_t ptr,
int_t block_size_log2) {
// r4 = log2(block size), 6, usually --- <=19
auto graphics_system = kernel_state()->emulator()->graphics_system();
graphics_system->EnableReadPointerWriteBack(ptr, block_size_log2);
}
DECLARE_XBOXKRNL_EXPORT1(VdEnableRingBufferRPtrWriteBack, kVideo, kImplemented);
void VdGetSystemCommandBuffer(lpunknown_t p0_ptr, lpunknown_t p1_ptr) {
void VdGetSystemCommandBuffer_entry(lpunknown_t p0_ptr, lpunknown_t p1_ptr) {
p0_ptr.Zero(0x94);
xe::store_and_swap<uint32_t>(p0_ptr, 0xBEEF0000);
xe::store_and_swap<uint32_t>(p1_ptr, 0xBEEF0001);
}
DECLARE_XBOXKRNL_EXPORT1(VdGetSystemCommandBuffer, kVideo, kStub);
void VdSetSystemCommandBufferGpuIdentifierAddress(lpunknown_t unk) {
void VdSetSystemCommandBufferGpuIdentifierAddress_entry(lpunknown_t unk) {
// r3 = 0x2B10(d3d?) + 8
}
DECLARE_XBOXKRNL_EXPORT1(VdSetSystemCommandBufferGpuIdentifierAddress, kVideo,
@ -262,7 +267,7 @@ DECLARE_XBOXKRNL_EXPORT1(VdSetSystemCommandBufferGpuIdentifierAddress, kVideo,
// r4 = 19
// no op?
dword_result_t VdInitializeScalerCommandBuffer(
dword_result_t VdInitializeScalerCommandBuffer_entry(
dword_t scaler_source_xy, // ((uint16_t)y << 16) | (uint16_t)x
dword_t scaler_source_wh, // ((uint16_t)h << 16) | (uint16_t)w
dword_t scaled_output_xy, // ((uint16_t)y << 16) | (uint16_t)x
@ -302,7 +307,7 @@ void AppendParam(StringBuffer* string_buffer, pointer_t<BufferScaling> param) {
uint16_t(param->fb_width), uint16_t(param->fb_height));
}
dword_result_t VdCallGraphicsNotificationRoutines(
dword_result_t VdCallGraphicsNotificationRoutines_entry(
unknown_t unk0, pointer_t<BufferScaling> args_ptr) {
assert_true(unk0 == 1);
@ -313,13 +318,13 @@ dword_result_t VdCallGraphicsNotificationRoutines(
DECLARE_XBOXKRNL_EXPORT2(VdCallGraphicsNotificationRoutines, kVideo,
kImplemented, kSketchy);
dword_result_t VdIsHSIOTrainingSucceeded() {
dword_result_t VdIsHSIOTrainingSucceeded_entry() {
// BOOL return value
return 1;
}
DECLARE_XBOXKRNL_EXPORT1(VdIsHSIOTrainingSucceeded, kVideo, kStub);
dword_result_t VdPersistDisplay(unknown_t unk0, lpdword_t unk1_ptr) {
dword_result_t VdPersistDisplay_entry(unknown_t unk0, lpdword_t unk1_ptr) {
// unk1_ptr needs to be populated with a pointer passed to
// MmFreePhysicalMemory(1, *unk1_ptr).
if (unk1_ptr) {
@ -334,23 +339,25 @@ dword_result_t VdPersistDisplay(unknown_t unk0, lpdword_t unk1_ptr) {
}
DECLARE_XBOXKRNL_EXPORT2(VdPersistDisplay, kVideo, kImplemented, kSketchy);
dword_result_t VdRetrainEDRAMWorker(unknown_t unk0) { return 0; }
dword_result_t VdRetrainEDRAMWorker_entry(unknown_t unk0) { return 0; }
DECLARE_XBOXKRNL_EXPORT1(VdRetrainEDRAMWorker, kVideo, kStub);
dword_result_t VdRetrainEDRAM(unknown_t unk0, unknown_t unk1, unknown_t unk2,
unknown_t unk3, unknown_t unk4, unknown_t unk5) {
dword_result_t VdRetrainEDRAM_entry(unknown_t unk0, unknown_t unk1,
unknown_t unk2, unknown_t unk3,
unknown_t unk4, unknown_t unk5) {
return 0;
}
DECLARE_XBOXKRNL_EXPORT1(VdRetrainEDRAM, kVideo, kStub);
void VdSwap(lpvoid_t buffer_ptr, // ptr into primary ringbuffer
lpvoid_t fetch_ptr, // frontbuffer Direct3D 9 texture header fetch
lpunknown_t unk2, // system writeback ptr
lpunknown_t unk3, // buffer from VdGetSystemCommandBuffer
lpunknown_t unk4, // from VdGetSystemCommandBuffer (0xBEEF0001)
lpdword_t frontbuffer_ptr, // ptr to frontbuffer address
lpdword_t texture_format_ptr, lpdword_t color_space_ptr,
lpdword_t width, lpdword_t height) {
void VdSwap_entry(
lpvoid_t buffer_ptr, // ptr into primary ringbuffer
lpvoid_t fetch_ptr, // frontbuffer Direct3D 9 texture header fetch
lpunknown_t unk2, // system writeback ptr
lpunknown_t unk3, // buffer from VdGetSystemCommandBuffer
lpunknown_t unk4, // from VdGetSystemCommandBuffer (0xBEEF0001)
lpdword_t frontbuffer_ptr, // ptr to frontbuffer address
lpdword_t texture_format_ptr, lpdword_t color_space_ptr, lpdword_t width,
lpdword_t height) {
// All of these parameters are REQUIRED.
assert(buffer_ptr);
assert(fetch_ptr);

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2015 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. *
******************************************************************************
*/
@ -17,7 +17,7 @@ namespace xe {
namespace kernel {
namespace xboxkrnl {
void VdQueryVideoMode(pointer_t<X_VIDEO_MODE> video_mode);
void VdQueryVideoMode(X_VIDEO_MODE* video_mode);
} // namespace xboxkrnl
} // namespace kernel

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2019 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. *
******************************************************************************
*/
@ -122,9 +122,10 @@ X_STATUS xeExGetXConfigSetting(uint16_t category, uint16_t setting,
return X_STATUS_SUCCESS;
}
dword_result_t ExGetXConfigSetting(word_t category, word_t setting,
lpdword_t buffer_ptr, word_t buffer_size,
lpword_t required_size_ptr) {
dword_result_t ExGetXConfigSetting_entry(word_t category, word_t setting,
lpvoid_t buffer_ptr,
word_t buffer_size,
lpword_t required_size_ptr) {
uint16_t required_size = 0;
X_STATUS result = xeExGetXConfigSetting(category, setting, buffer_ptr,
buffer_size, &required_size);