From 1bc2c416c1ac0716a974aacb39656e9d4d910686 Mon Sep 17 00:00:00 2001 From: Miran Date: Wed, 17 Apr 2024 03:59:54 +0200 Subject: [PATCH] More detailed error message box for invalid input string string params. --- cleo_sdk/CLEO_Utils.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cleo_sdk/CLEO_Utils.h b/cleo_sdk/CLEO_Utils.h index a978fbe5..98c41519 100644 --- a/cleo_sdk/CLEO_Utils.h +++ b/cleo_sdk/CLEO_Utils.h @@ -378,9 +378,20 @@ namespace CLEO auto str = CLEO_ReadStringPointerOpcodeParam(thread, buffer, bufferSize); // returns pointer to source data whenever possible - if (str == nullptr) // other error? + if (str == nullptr) // reading string failed { - SHOW_ERROR("Invalid input argument %s in script %s\nScript suspended.", GetParamInfo().c_str(), ScriptInfoStr(thread).c_str()); + auto isVariableInt = IsVariable(_lastParamType) && (_lastParamArrayType == eArrayDataType::ADT_NONE || _lastParamArrayType == eArrayDataType::ADT_INT); + if ((IsImmInteger(_lastParamType) || isVariableInt) && // pointer argument type? + CLEO_GetOpcodeParamsArray()->dwParam <= MinValidAddress) + { + SHOW_ERROR("Invalid '0x%X' pointer of input string argument %s in script %s", CLEO_GetOpcodeParamsArray()->dwParam, GetParamInfo().c_str(), ScriptInfoStr(thread).c_str()); + } + else + { + // other error + SHOW_ERROR("Invalid input argument %s in script %s\nScript suspended.", GetParamInfo().c_str(), ScriptInfoStr(thread).c_str()); + } + thread->Suspend(); _lastParamType = DT_INVALID; // mark error return nullptr;