Skip to content

Commit

Permalink
FFakeStereoRenderingHook: Fix crash when there are multiple string refs
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Feb 15, 2025
1 parent 1a3d792 commit 0bd1bf1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/mods/vr/FFakeStereoRenderingHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6176,6 +6176,8 @@ void VRRenderTargetManager_Base::pre_texture_hook_callback(safetyhook::Context&
rtm->texture_hook_ref = (FTexture2DRHIRef*)ctx.r8;
}
} else { // most common version.
SPDLOG_INFO("Calling common version of texture create (several arguments)");

void (*func)(
uintptr_t rhi,
FTexture2DRHIRef* out,
Expand Down Expand Up @@ -6995,15 +6997,14 @@ bool VRRenderTargetManager_Base::allocate_render_target_texture(uintptr_t return
str_addr.has_value();
str_addr = utility::scan_string(*str_addr + 1, (module_end - (*str_addr + 1)), str.data(), true))
{
const auto string_ref = utility::scan_displacement_reference(*addr_module, (uintptr_t)*str_addr);

if (string_ref) {
// Scan for ALL references to this string
for (auto string_ref = utility::scan_displacement_reference(*addr_module, (uintptr_t)*str_addr);
string_ref.has_value();
string_ref = utility::scan_displacement_reference(*string_ref + 1, (module_end - (*string_ref + 1)), (uintptr_t)*str_addr))
{
const auto string_ref_func_start = utility::find_function_start((uintptr_t)*string_ref);
const auto return_addr_func_start = utility::find_function_start(addr);

SPDLOG_INFO("String ref func start: {:x}", (uintptr_t)*string_ref_func_start);
SPDLOG_INFO("Return addr func start: {:x}", (uintptr_t)*return_addr_func_start);

if (string_ref_func_start && return_addr_func_start && *string_ref_func_start == *return_addr_func_start) {
return true;
}
Expand Down

0 comments on commit 0bd1bf1

Please sign in to comment.