From f07365cf13c5712146fcc7c6607c96762e83c281 Mon Sep 17 00:00:00 2001 From: praydog Date: Tue, 24 Oct 2023 12:22:01 -0700 Subject: [PATCH] SDK: Fix undefined behavior in UGameViewportClient::Draw scan --- shared/sdk/UGameViewportClient.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shared/sdk/UGameViewportClient.cpp b/shared/sdk/UGameViewportClient.cpp index 16433003..dab9b9ef 100644 --- a/shared/sdk/UGameViewportClient.cpp +++ b/shared/sdk/UGameViewportClient.cpp @@ -6,6 +6,8 @@ #include #include +#include + #include "EngineModule.hpp" #include "UGameViewportClient.hpp" @@ -13,6 +15,7 @@ namespace sdk { std::optional UGameViewportClient::get_draw_function() { static auto result = []() -> std::optional { + ZoneScopedN("sdk::UGameViewportClient::get_draw_function static init"); const auto engine_module = sdk::get_ue_module(L"Engine"); const auto canvas_object_strings = utility::scan_strings(engine_module, L"CanvasObject", true); @@ -84,7 +87,7 @@ std::optional UGameViewportClient::get_draw_function() { }*/ if (ix.BranchInfo.IsBranch && !ix.BranchInfo.IsConditional) { - if (auto resolved = utility::resolve_displacement(ip); *resolved == possible_function) { + if (auto resolved = utility::resolve_displacement(ip); resolved.has_value() && *resolved == possible_function) { impossible_functions.insert(other_function); SPDLOG_INFO("Found possible function within function at {:x} (insn {:x})", (uintptr_t)other_function, ip); return utility::ExhaustionResult::BREAK;