From b99f18dacc21e6237008fb5e0cb787da4c7e88d3 Mon Sep 17 00:00:00 2001 From: Isaac0-dev <62234577+Isaac0-dev@users.noreply.github.com> Date: Fri, 6 Jun 2025 09:34:23 +1000 Subject: [PATCH] check texInfo so mods can't spoof it in smlua_to_texture_info --- src/pc/lua/smlua_utils.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/pc/lua/smlua_utils.c b/src/pc/lua/smlua_utils.c index 51169721b..5f3240752 100644 --- a/src/pc/lua/smlua_utils.c +++ b/src/pc/lua/smlua_utils.c @@ -270,21 +270,15 @@ struct TextureInfo *smlua_to_texture_info(lua_State *L, int index) { lua_pushstring(L, "texture"); lua_gettable(L, top + 1); - tmpTexInfo.texture = smlua_to_cpointer(L, lua_gettop(L), LVT_U8_P); + const u8 *texPtr = smlua_to_cpointer(L, lua_gettop(L), LVT_U8_P); lua_pop(L, 1); if (!gSmLuaConvertSuccess) { return NULL; } - tmpTexInfo.bitSize = smlua_get_integer_field(top + 1, "bitSize"); - if (!gSmLuaConvertSuccess) { return NULL; } - - tmpTexInfo.width = smlua_get_integer_field(top + 1, "width"); - if (!gSmLuaConvertSuccess) { return NULL; } - - tmpTexInfo.height = smlua_get_integer_field(top + 1, "height"); - if (!gSmLuaConvertSuccess) { return NULL; } - - tmpTexInfo.name = smlua_get_string_field(top + 1, "name"); - if (!gSmLuaConvertSuccess) { return NULL; } + // Get the texInfo from DynOS so mods can't spoof it + if (!texPtr || !dynos_texture_get_from_data(texPtr, texInfo)) { + gSmLuaConvertSuccess = false; + return NULL; + } lua_settop(L, top); }