diff --git a/src/xenia/kernel/xam_user.cc b/src/xenia/kernel/xam_user.cc index 4524d743a..300cbf07b 100644 --- a/src/xenia/kernel/xam_user.cc +++ b/src/xenia/kernel/xam_user.cc @@ -218,6 +218,46 @@ SHIM_CALL XamUserReadProfileSettings_shim( } +SHIM_CALL XamUserWriteProfileSettings_shim( + PPCContext* ppc_state, KernelState* state) { + uint32_t user_index = SHIM_GET_ARG_32(0); + uint32_t unknown = SHIM_GET_ARG_32(1); + uint32_t setting_count = SHIM_GET_ARG_32(2); + uint32_t settings_ptr = SHIM_GET_ARG_32(3); + uint32_t overlapped_ptr = SHIM_GET_ARG_32(4); + + XELOGD( + "XamUserWriteProfileSettings(%.8X, %d, %d, %d, %d, %.8X, %.8X(%d), %.8X, %.8X)", + user_index, unknown, setting_count, settings_ptr, overlapped_ptr); + + if (!setting_count || !settings_ptr) { + SHIM_SET_RETURN_32(X_ERROR_INVALID_PARAMETER); + } + + if (user_index == 255) { + user_index = 0; + } + + if (user_index) { + // Only support user 0. + SHIM_SET_RETURN_32(X_ERROR_NOT_FOUND); + return; + } + + const auto& user_profile = state->user_profile(); + + // TODO: Update and save settings. + + if (overlapped_ptr) { + state->CompleteOverlappedImmediate(overlapped_ptr, X_ERROR_SUCCESS); + SHIM_SET_RETURN_32(X_ERROR_IO_PENDING); + } + else { + SHIM_SET_RETURN_32(X_ERROR_SUCCESS); + } +} + + SHIM_CALL XamUserCheckPrivilege_shim( PPCContext* ppc_state, KernelState* state) { uint32_t user_index = SHIM_GET_ARG_32(0); @@ -310,6 +350,7 @@ void xe::kernel::xam::RegisterUserExports( SHIM_SET_MAPPING("xam.xex", XamUserGetSigninInfo, state); SHIM_SET_MAPPING("xam.xex", XamUserGetName, state); 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", XamShowSigninUI, state); SHIM_SET_MAPPING("xam.xex", XamUserCreateAchievementEnumerator, state); diff --git a/src/xenia/xbox.h b/src/xenia/xbox.h index 52bc8f31e..b3ca8dd24 100644 --- a/src/xenia/xbox.h +++ b/src/xenia/xbox.h @@ -68,6 +68,7 @@ typedef uint32_t X_RESULT; #define X_ERROR_ACCESS_DENIED X_HRESULT_FROM_WIN32(0x00000005L) #define X_ERROR_INVALID_HANDLE X_HRESULT_FROM_WIN32(0x00000006L) #define X_ERROR_NO_MORE_FILES X_HRESULT_FROM_WIN32(0x00000018L) +#define X_ERROR_INVALID_PARAMETER X_HRESULT_FROM_WIN32(0x00000057L) #define X_ERROR_IO_PENDING X_HRESULT_FROM_WIN32(0x000003E5L) #define X_ERROR_INSUFFICIENT_BUFFER X_HRESULT_FROM_WIN32(0x0000007AL) #define X_ERROR_BAD_ARGUMENTS X_HRESULT_FROM_WIN32(0x000000A0L)