From 3b83e223d8a421c0a7268c0e16c9476901004f8a Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 30 Dec 2018 22:27:37 +0100 Subject: [PATCH] cellOskDialog: add some param checks --- rpcs3/Emu/Cell/Modules/cellOskDialog.cpp | 40 ++++++++++++++++++------ 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp b/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp index 8d43acefde..219a4bccf1 100644 --- a/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp +++ b/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp @@ -18,7 +18,19 @@ s32 cellOskDialogLoadAsync(u32 container, vm::ptr dialogPara { cellOskDialog.warning("cellOskDialogLoadAsync(container=0x%x, dialogParam=*0x%x, inputFieldInfo=*0x%x)", container, dialogParam, inputFieldInfo); - u32 maxLength = (inputFieldInfo->limit_length >= 512) ? 511 : (u32)inputFieldInfo->limit_length; + if (!inputFieldInfo || !inputFieldInfo->message || !inputFieldInfo->init_text || inputFieldInfo->limit_length > CELL_OSKDIALOG_STRING_SIZE) + { + return CELL_OSKDIALOG_ERROR_PARAM; + } + + const auto osk = fxm::import(Emu.GetCallbacks().get_msg_dialog); + + if (!osk) + { + return CELL_SYSUTIL_ERROR_BUSY; + } + + u32 maxLength = (inputFieldInfo->limit_length >= CELL_OSKDIALOG_STRING_SIZE) ? 511 : (u32)inputFieldInfo->limit_length; s_osk_input_result = CELL_OSKDIALOG_INPUT_FIELD_RESULT_OK; std::memset(s_osk_text, 0, sizeof(s_osk_text)); @@ -33,13 +45,6 @@ s32 cellOskDialogLoadAsync(u32 container, vm::ptr dialogPara } } - const auto osk = fxm::import(Emu.GetCallbacks().get_msg_dialog); - - if (!osk) - { - return CELL_SYSUTIL_ERROR_BUSY; - } - bool result = false; osk->on_close = [wptr = std::weak_ptr(osk)](s32 status) @@ -128,11 +133,26 @@ s32 cellOskDialogUnloadAsync(vm::ptr OutputInf return getText(OutputInfo, true); } -s32 cellOskDialogGetSize(vm::ptr width, vm::ptr height, vm::ptr dialogType) +s32 cellOskDialogGetSize(vm::ptr width, vm::ptr height, u32 /*CellOskDialogType*/ dialogType) { cellOskDialog.warning("cellOskDialogGetSize(width=*0x%x, height=*0x%x, dialogType=*0x%x)", width, height, dialogType); - *width = 1; + + if (!width || !height) + { + return CELL_OSKDIALOG_ERROR_PARAM; + } + + if (dialogType >= CELL_OSKDIALOG_TYPE_SEPARATE_SINGLELINE_TEXT_WINDOW) + { + *width = 0; + } + else + { + *width = 1; + } + *height = 1; + return CELL_OK; }