From 87094b825741731c174772d3ab95aaabda2ae406 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 30 Aug 2015 15:00:04 -0700 Subject: [PATCH] Adding XamUserContentRestriction* functions. --- src/xenia/cpu/xex_module.cc | 1 - src/xenia/kernel/xam_table.inc | 3 ++ src/xenia/kernel/xam_user.cc | 60 ++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/xenia/cpu/xex_module.cc b/src/xenia/cpu/xex_module.cc index d536e4a67..b9c420f2a 100644 --- a/src/xenia/cpu/xex_module.cc +++ b/src/xenia/cpu/xex_module.cc @@ -434,7 +434,6 @@ bool XexModule::SetupLibraryImports(const char* name, import_name.GetString()); handler = UndefinedImport; } - static_cast(function)->SetupExtern(handler); } else if (user_export_addr) { // Rewrite PPC code to set r11 to the target address diff --git a/src/xenia/kernel/xam_table.inc b/src/xenia/kernel/xam_table.inc index e6d215245..9e73663ef 100644 --- a/src/xenia/kernel/xam_table.inc +++ b/src/xenia/kernel/xam_table.inc @@ -962,6 +962,9 @@ XE_EXPORT(xam, 0x00000497, XamVoiceIsActiveProcess, XE_EXPORT(xam, 0x0000049E, XGetVideoCapabilities, kFunction), XE_EXPORT(xam, 0x000004A5, XamUserGetAgeGroup, kFunction), XE_EXPORT(xam, 0x000004B0, XMPRegisterCodec, kFunction), +XE_EXPORT(xam, 0x000004B6, XamUserContentRestrictionGetFlags, kFunction), +XE_EXPORT(xam, 0x000004B7, XamUserContentRestrictionGetRating, kFunction), +XE_EXPORT(xam, 0x000004B8, XamUserContentRestrictionCheckAccess, kFunction), XE_EXPORT(xam, 0x000004BC, XampXAuthStartup, kFunction), XE_EXPORT(xam, 0x000004BD, XampXAuthShutdown, kFunction), XE_EXPORT(xam, 0x000004BE, XamGetToken, kFunction), diff --git a/src/xenia/kernel/xam_user.cc b/src/xenia/kernel/xam_user.cc index 96cb0f5a4..87ec02dee 100644 --- a/src/xenia/kernel/xam_user.cc +++ b/src/xenia/kernel/xam_user.cc @@ -312,6 +312,63 @@ SHIM_CALL XamUserCheckPrivilege_shim(PPCContext* ppc_context, SHIM_SET_RETURN_32(X_ERROR_SUCCESS); } +SHIM_CALL XamUserContentRestrictionGetFlags_shim(PPCContext* ppc_context, + KernelState* kernel_state) { + uint32_t user_index = SHIM_GET_ARG_32(0); + uint32_t out_flags_ptr = SHIM_GET_ARG_32(1); + + XELOGD("XamUserContentRestrictionGetFlags(%d, %.8X)", user_index, + out_flags_ptr); + + // No restrictions? + SHIM_SET_MEM_32(out_flags_ptr, 0); + + SHIM_SET_RETURN_32(X_ERROR_SUCCESS); +} + +SHIM_CALL XamUserContentRestrictionGetRating_shim(PPCContext* ppc_context, + KernelState* kernel_state) { + uint32_t user_index = SHIM_GET_ARG_32(0); + uint32_t unk1 = SHIM_GET_ARG_32(1); + uint32_t out_unk2_ptr = SHIM_GET_ARG_32(2); + uint32_t out_unk3_ptr = SHIM_GET_ARG_32(3); + + XELOGD("XamUserContentRestrictionGetRating(%d, %.8X, %.8X, %.8X)", user_index, + unk1, out_unk2_ptr, out_unk3_ptr); + + // Some games have special case paths for 3F that differ from the failure + // path, so my guess is that's 'don't care'. + SHIM_SET_MEM_32(out_unk2_ptr, 0x3F); + SHIM_SET_MEM_32(out_unk3_ptr, 0); + + SHIM_SET_RETURN_32(X_ERROR_SUCCESS); +} + +SHIM_CALL XamUserContentRestrictionCheckAccess_shim(PPCContext* ppc_context, + KernelState* kernel_state) { + uint32_t user_index = SHIM_GET_ARG_32(0); + uint32_t unk1 = SHIM_GET_ARG_32(1); + uint32_t unk2 = SHIM_GET_ARG_32(2); + uint32_t unk3 = SHIM_GET_ARG_32(3); + uint32_t unk4 = SHIM_GET_ARG_32(4); + uint32_t out_unk5_ptr = SHIM_GET_ARG_32(5); + uint32_t overlapped_ptr = SHIM_GET_ARG_32(6); + + XELOGD( + "XamUserContentRestrictionCheckAccess(%d, %.8X, %.8X, %.8X, %.8X, %.8X, " + "%.8X)", + user_index, unk1, unk2, unk3, unk4, out_unk5_ptr, overlapped_ptr); + + SHIM_SET_MEM_32(out_unk5_ptr, 1); + + if (overlapped_ptr) { + // TODO(benvanik): does this need the access arg on it? + kernel_state->CompleteOverlappedImmediate(overlapped_ptr, X_ERROR_SUCCESS); + } + + SHIM_SET_RETURN_32(X_ERROR_SUCCESS); +} + SHIM_CALL XamUserAreUsersFriends_shim(PPCContext* ppc_context, KernelState* kernel_state) { uint32_t user_index = SHIM_GET_ARG_32(0); @@ -493,6 +550,9 @@ void xe::kernel::xam::RegisterUserExports( SHIM_SET_MAPPING("xam.xex", XamUserReadProfileSettings, state); SHIM_SET_MAPPING("xam.xex", XamUserWriteProfileSettings, state); SHIM_SET_MAPPING("xam.xex", XamUserCheckPrivilege, state); + SHIM_SET_MAPPING("xam.xex", XamUserContentRestrictionGetFlags, state); + SHIM_SET_MAPPING("xam.xex", XamUserContentRestrictionGetRating, state); + SHIM_SET_MAPPING("xam.xex", XamUserContentRestrictionCheckAccess, state); SHIM_SET_MAPPING("xam.xex", XamUserAreUsersFriends, state); SHIM_SET_MAPPING("xam.xex", XamShowSigninUI, state); SHIM_SET_MAPPING("xam.xex", XamUserCreateAchievementEnumerator, state);