Skip to content

Commit

Permalink
Safety
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jun 13, 2023
1 parent 226f54d commit 3b3aeb8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions shared/sdk/UEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ std::optional<uintptr_t> UEngine::get_initialize_hmd_device_address() {
const auto engine = UGameEngine::get();

// Verify that the result lands within the vtable.
if (engine != nullptr && !IsBadReadPtr(*(void**)engine, sizeof(void*))) {
if (engine != nullptr && !IsBadReadPtr(*(void**)engine, 200 * sizeof(void*))) {
const auto vtable = *(uintptr_t*)engine;
auto vtable_within = utility::scan_ptr(vtable, 200 * sizeof(void*), *result);

Expand All @@ -311,7 +311,7 @@ std::optional<uintptr_t> UEngine::get_initialize_hmd_device_address() {
}
}

if (!result) {
if (!result) try {
SPDLOG_ERROR("Failed to find InitializeHMDDevice function, falling back to vtable walk.");

const auto engine = UGameEngine::get();
Expand Down Expand Up @@ -352,6 +352,9 @@ std::optional<uintptr_t> UEngine::get_initialize_hmd_device_address() {
});
}
}
} catch(...) {
SPDLOG_ERROR("Exception occurred while attempting to find InitializeHMDDevice function.");
result = std::nullopt;
}

return result;
Expand Down

0 comments on commit 3b3aeb8

Please sign in to comment.