Skip to content

Commit

Permalink
Fix some issues where freezes could occur
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Apr 13, 2024
1 parent 2efaebd commit ebbdcfd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions shared/sdk/REManagedObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ struct RETypeDefinition;
}

namespace utility::re_managed_object {
// Exposed because these take forever to scan for
// Maybe we can just do some clever scanning through some reflected methods in the future.
namespace detail {
void resolve_add_ref();
void resolve_release();
}

// Forward declarations
struct ParamWrapper;
bool is_managed_object(Address address);
Expand Down
3 changes: 3 additions & 0 deletions shared/sdk/SDK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ void initialize_sdk() {

reframework::get_types();
reframework::get_globals();

utility::re_managed_object::detail::resolve_add_ref();
utility::re_managed_object::detail::resolve_release();
}
}
10 changes: 10 additions & 0 deletions src/REFramework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ using namespace std::literals;
std::unique_ptr<REFramework> g_framework{};

void REFramework::hook_monitor() {
if (!m_hook_monitor_mutex.try_lock()) {
// If this happens then we can assume execution is going as planned
// so we can just reset the times so we dont break something
m_last_present_time = std::chrono::steady_clock::now() + std::chrono::seconds(5);
m_last_chance_time = std::chrono::steady_clock::now() + std::chrono::seconds(1);
m_has_last_chance = true;
} else {
m_hook_monitor_mutex.unlock();
}

std::scoped_lock _{ m_hook_monitor_mutex };

if (g_framework == nullptr) {
Expand Down

0 comments on commit ebbdcfd

Please sign in to comment.