Skip to content

Commit

Permalink
SDK: Fix undefined behavior in UGameViewportClient::Draw scan
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Oct 24, 2023
1 parent c8a194d commit f07365c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion shared/sdk/UGameViewportClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
#include <utility/Scan.hpp>
#include <utility/Module.hpp>

#include <tracy/Tracy.hpp>

#include "EngineModule.hpp"

#include "UGameViewportClient.hpp"

namespace sdk {
std::optional<uintptr_t> UGameViewportClient::get_draw_function() {
static auto result = []() -> std::optional<uintptr_t> {
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);

Expand Down Expand Up @@ -84,7 +87,7 @@ std::optional<uintptr_t> 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;
Expand Down

0 comments on commit f07365c

Please sign in to comment.