Skip to content

Commit 535dc87

Browse files
wildcherry2UE4SS
andauthored
feat: EventViewerMod (#1164)
Created EventViewerMod, see PR for more details --------- Co-authored-by: UE4SS <[email protected]>
1 parent dd64245 commit 535dc87

27 files changed

+3076
-44
lines changed

UE4SS/include/UE4SSProgram.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,6 @@ namespace RC
361361
friend void* HookedLoadLibraryExA(const char* dll_name, void* file, int32_t flags);
362362
friend void* HookedLoadLibraryW(const wchar_t* dll_name);
363363
friend void* HookedLoadLibraryExW(const wchar_t* dll_name, void* file, int32_t flags);
364-
friend auto gui_render_thread_tick(Unreal::UObject*, float) -> void;
364+
friend auto gui_render_thread_tick() -> void;
365365
};
366366
} // namespace RC

UE4SS/src/GUI/UFunctionCallerWidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ namespace RC::GUI
136136
static FOutputDevice s_ar{};
137137
static UFunction* s_function{};
138138
static UObject* s_executor{};
139-
auto call_process_console_exec(UObject*, UFunction*, void*) -> void
139+
auto call_process_console_exec(Hook::TCallbackIterationData<void>&, UObject*, UFunction*, void*) -> void
140140
{
141141
if (s_do_call)
142142
{
@@ -173,7 +173,7 @@ namespace RC::GUI
173173
if (!s_is_hooked)
174174
{
175175
s_is_hooked = true;
176-
Hook::RegisterProcessEventPostCallback(call_process_console_exec);
176+
Hook::RegisterProcessEventPostCallback(call_process_console_exec, {false, false, STR("UE4SS"), STR("FunctionCallerWidgetHook")});
177177
}
178178
s_do_call = true;
179179
}

UE4SS/src/Mod/LuaMod.cpp

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3773,7 +3773,8 @@ No overload found for function 'IsInGameThread'.
37733773
});
37743774
}
37753775

3776-
auto static process_event_hook([[maybe_unused]] Unreal::UObject* Context,
3776+
auto static process_event_hook([[maybe_unused]] Unreal::Hook::TCallbackIterationData<void>& CallbackIterationData,
3777+
[[maybe_unused]] Unreal::UObject* Context,
37773778
[[maybe_unused]] Unreal::UFunction* Function,
37783779
[[maybe_unused]] void* Parms) -> void
37793780
{
@@ -3783,7 +3784,10 @@ No overload found for function 'IsInGameThread'.
37833784
process_delayed_actions<GameThreadExecutionMethod::ProcessEvent>(LuaMod::m_delayed_game_thread_actions);
37843785
}
37853786

3786-
auto static engine_tick_hook([[maybe_unused]] Unreal::UEngine* Context, [[maybe_unused]] float DeltaSeconds) -> void
3787+
auto static engine_tick_hook([[maybe_unused]] Unreal::Hook::TCallbackIterationData<void>& CallbackIterationData,
3788+
[[maybe_unused]] Unreal::UEngine* Context,
3789+
[[maybe_unused]] float DeltaSeconds,
3790+
[[maybe_unused]] bool bIdle) -> void
37873791
{
37883792
std::lock_guard<std::recursive_mutex> guard{LuaMod::m_thread_actions_mutex};
37893793

@@ -3807,7 +3811,7 @@ No overload found for function 'IsInGameThread'.
38073811
{
38083812
if (!m_is_engine_tick_hooked)
38093813
{
3810-
Unreal::Hook::RegisterEngineTickPreCallback(&engine_tick_hook);
3814+
Unreal::Hook::RegisterEngineTickPreCallback(engine_tick_hook, {false, false, STR("UE4SS"), STR("LuaModImpl")});
38113815
m_is_engine_tick_hooked = true;
38123816
}
38133817
}
@@ -3817,7 +3821,7 @@ No overload found for function 'IsInGameThread'.
38173821
{
38183822
if (!mod->m_is_process_event_hooked)
38193823
{
3820-
Unreal::Hook::RegisterProcessEventPreCallback(&process_event_hook);
3824+
Unreal::Hook::RegisterProcessEventPreCallback(process_event_hook, {false, false, STR("UE4SS"), STR("LuaModImpl")});
38213825
mod->m_is_process_event_hooked = true;
38223826
}
38233827
}
@@ -5562,7 +5566,7 @@ No overload found for function 'FPackageName:IsValidLongPackageName'.
55625566
LuaStatics::console_executor_enabled = false;
55635567
}
55645568

5565-
static auto script_hook([[maybe_unused]] Unreal::UObject* Context, Unreal::FFrame& Stack, [[maybe_unused]] void* RESULT_DECL) -> void
5569+
static auto script_hook([[maybe_unused]] Unreal::Hook::TCallbackIterationData<void>& CallbackIterationData, [[maybe_unused]] Unreal::UObject* Context, Unreal::FFrame& Stack, [[maybe_unused]] void* RESULT_DECL) -> void
55665570
{
55675571
std::lock_guard<std::recursive_mutex> guard{LuaMod::m_thread_actions_mutex};
55685572

@@ -5699,12 +5703,10 @@ No overload found for function 'FPackageName:IsValidLongPackageName'.
56995703
auto LuaMod::on_program_start() -> void
57005704
{
57015705
Unreal::UObjectArray::AddUObjectDeleteListener(&LuaType::FLuaObjectDeleteListener::s_lua_object_delete_listener);
5702-
5706+
const Unreal::Hook::FCallbackOptions common_opts {false, false, STR("UE4SS"), STR("LuaModImpl")};
57035707
Unreal::Hook::RegisterLoadMapPreCallback(
5704-
[](Unreal::UEngine* Engine, Unreal::FWorldContext& WorldContext, Unreal::FURL URL, Unreal::UPendingNetGame* PendingGame, Unreal::FString& Error)
5705-
-> std::pair<bool, bool> {
5706-
return TRY([&] {
5707-
std::pair<bool, bool> return_value{};
5708+
[](Unreal::Hook::TCallbackIterationData<bool>& CallbackIterationData, Unreal::UEngine* Engine, Unreal::FWorldContext& WorldContext, Unreal::FURL URL, Unreal::UPendingNetGame* PendingGame, Unreal::FString& Error) {
5709+
TRY([&] {
57085710
for (const auto& callback_data : m_load_map_pre_callbacks)
57095711
{
57105712
for (const auto& [lua_ptr, registry_index] : callback_data.registry_indexes)
@@ -5722,7 +5724,6 @@ No overload found for function 'FPackageName:IsValidLongPackageName'.
57225724

57235725
if (callback_data.lua->is_nil())
57245726
{
5725-
return_value.first = false;
57265727
callback_data.lua->discard_value();
57275728
}
57285729
else if (!callback_data.lua->is_bool())
@@ -5731,20 +5732,16 @@ No overload found for function 'FPackageName:IsValidLongPackageName'.
57315732
}
57325733
else
57335734
{
5734-
return_value.first = true;
5735-
return_value.second = callback_data.lua->get_bool();
5735+
CallbackIterationData.TrySetReturnValue(callback_data.lua->get_bool());
57365736
}
57375737
}
57385738
}
5739-
return return_value;
57405739
});
5741-
});
5740+
}, common_opts);
57425741

57435742
Unreal::Hook::RegisterLoadMapPostCallback(
5744-
[](Unreal::UEngine* Engine, Unreal::FWorldContext& WorldContext, Unreal::FURL URL, Unreal::UPendingNetGame* PendingGame, Unreal::FString& Error)
5745-
-> std::pair<bool, bool> {
5746-
return TRY([&] {
5747-
std::pair<bool, bool> return_value{};
5743+
[](Unreal::Hook::TCallbackIterationData<bool>& CallbackIterationData, Unreal::UEngine* Engine, Unreal::FWorldContext& WorldContext, Unreal::FURL URL, Unreal::UPendingNetGame* PendingGame, Unreal::FString& Error) {
5744+
TRY([&] {
57485745
for (const auto& callback_data : m_load_map_post_callbacks)
57495746
{
57505747
for (const auto& [lua_ptr, registry_index] : callback_data.registry_indexes)
@@ -5762,7 +5759,6 @@ No overload found for function 'FPackageName:IsValidLongPackageName'.
57625759

57635760
if (callback_data.lua->is_nil())
57645761
{
5765-
return_value.first = false;
57665762
callback_data.lua->discard_value();
57675763
}
57685764
else if (!callback_data.lua->is_bool())
@@ -5771,16 +5767,14 @@ No overload found for function 'FPackageName:IsValidLongPackageName'.
57715767
}
57725768
else
57735769
{
5774-
return_value.first = true;
5775-
return_value.second = callback_data.lua->get_bool();
5770+
CallbackIterationData.TrySetReturnValue(callback_data.lua->get_bool());
57765771
}
57775772
}
57785773
}
5779-
return return_value;
57805774
});
5781-
});
5775+
}, common_opts);
57825776

5783-
Unreal::Hook::RegisterInitGameStatePreCallback([]([[maybe_unused]] Unreal::AGameModeBase* Context) {
5777+
Unreal::Hook::RegisterInitGameStatePreCallback([]([[maybe_unused]] Unreal::Hook::TCallbackIterationData<void>& CallbackIterationData, [[maybe_unused]] Unreal::AGameModeBase* Context) {
57845778
TRY([&] {
57855779
for (const auto& callback_data : m_init_game_state_pre_callbacks)
57865780
{
@@ -5795,9 +5789,9 @@ No overload found for function 'FPackageName:IsValidLongPackageName'.
57955789
}
57965790
}
57975791
});
5798-
});
5792+
}, common_opts);
57995793

5800-
Unreal::Hook::RegisterInitGameStatePostCallback([]([[maybe_unused]] Unreal::AGameModeBase* Context) {
5794+
Unreal::Hook::RegisterInitGameStatePostCallback([]([[maybe_unused]] Unreal::Hook::TCallbackIterationData<void>& CallbackIterationData, [[maybe_unused]] Unreal::AGameModeBase* Context) {
58015795
TRY([&] {
58025796
for (const auto& callback_data : m_init_game_state_post_callbacks)
58035797
{
@@ -5812,9 +5806,9 @@ No overload found for function 'FPackageName:IsValidLongPackageName'.
58125806
}
58135807
}
58145808
});
5815-
});
5809+
}, common_opts);
58165810

5817-
Unreal::Hook::RegisterBeginPlayPreCallback([]([[maybe_unused]] Unreal::AActor* Context) {
5811+
Unreal::Hook::RegisterBeginPlayPreCallback([]([[maybe_unused]] Unreal::Hook::TCallbackIterationData<void>& CallbackIterationData, [[maybe_unused]] Unreal::AActor* Context) {
58185812
TRY([&] {
58195813
for (const auto& callback_data : m_begin_play_pre_callbacks)
58205814
{
@@ -5829,9 +5823,9 @@ No overload found for function 'FPackageName:IsValidLongPackageName'.
58295823
}
58305824
}
58315825
});
5832-
});
5826+
}, common_opts);
58335827

5834-
Unreal::Hook::RegisterBeginPlayPostCallback([]([[maybe_unused]] Unreal::AActor* Context) {
5828+
Unreal::Hook::RegisterBeginPlayPostCallback([]([[maybe_unused]] Unreal::Hook::TCallbackIterationData<void>& CallbackIterationData, [[maybe_unused]] Unreal::AActor* Context) {
58355829
TRY([&] {
58365830
for (const auto& callback_data : m_begin_play_post_callbacks)
58375831
{
@@ -5846,9 +5840,9 @@ No overload found for function 'FPackageName:IsValidLongPackageName'.
58465840
}
58475841
}
58485842
});
5849-
});
5843+
}, common_opts);
58505844

5851-
Unreal::Hook::RegisterEndPlayPreCallback([]([[maybe_unused]] Unreal::AActor* Context, Unreal::EEndPlayReason EndPlayReason) {
5845+
Unreal::Hook::RegisterEndPlayPreCallback([]([[maybe_unused]] Unreal::Hook::TCallbackIterationData<void>& CallbackIterationData, [[maybe_unused]] Unreal::AActor* Context, Unreal::EEndPlayReason EndPlayReason) {
58525846
TRY([&] {
58535847
for (const auto& callback_data : m_end_play_pre_callbacks)
58545848
{
@@ -5865,9 +5859,9 @@ No overload found for function 'FPackageName:IsValidLongPackageName'.
58655859
}
58665860
}
58675861
});
5868-
});
5862+
}, common_opts);
58695863

5870-
Unreal::Hook::RegisterEndPlayPostCallback([]([[maybe_unused]] Unreal::AActor* Context, Unreal::EEndPlayReason EndPlayReason) {
5864+
Unreal::Hook::RegisterEndPlayPostCallback([]([[maybe_unused]] Unreal::Hook::TCallbackIterationData<void>& CallbackIterationData, [[maybe_unused]] Unreal::AActor* Context, Unreal::EEndPlayReason EndPlayReason) {
58715865
TRY([&] {
58725866
for (const auto& callback_data : m_end_play_post_callbacks)
58735867
{
@@ -5884,7 +5878,7 @@ No overload found for function 'FPackageName:IsValidLongPackageName'.
58845878
}
58855879
}
58865880
});
5887-
});
5881+
}, common_opts);
58885882

58895883
Unreal::Hook::RegisterStaticConstructObjectPostCallback([](const Unreal::FStaticConstructObjectParameters&, Unreal::UObject* constructed_object) {
58905884
return TRY([&] {
@@ -6412,12 +6406,12 @@ No overload found for function 'FPackageName:IsValidLongPackageName'.
64126406
if (Unreal::UObject::ProcessLocalScriptFunctionInternal.is_ready() && Unreal::Version::IsAtLeast(4, 22))
64136407
{
64146408
Output::send(STR("Enabling custom events\n"));
6415-
Unreal::Hook::RegisterProcessLocalScriptFunctionPostCallback(script_hook);
6409+
Unreal::Hook::RegisterProcessLocalScriptFunctionPostCallback(script_hook, {false, false, STR("UE4SS"), STR("LuaModImplScriptHook")});
64166410
}
64176411
else if (Unreal::UObject::ProcessInternalInternal.is_ready() && Unreal::Version::IsBelow(4, 22))
64186412
{
64196413
Output::send(STR("Enabling custom events\n"));
6420-
Unreal::Hook::RegisterProcessInternalPostCallback(script_hook);
6414+
Unreal::Hook::RegisterProcessInternalPostCallback(script_hook, {false, false, STR("UE4SS"), STR("LuaModImplScriptHook")});
64216415
}
64226416
}
64236417

UE4SS/src/UE4SSProgram.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ namespace RC
900900

901901
static bool s_gui_initialized_for_game_thread{};
902902
static bool s_gui_initializing_for_game_thread{};
903-
auto gui_render_thread_tick(Unreal::UObject*, float) -> void
903+
auto gui_render_thread_tick() -> void
904904
{
905905
if (UE4SSProgram::settings_manager.Debug.RenderMode == GUI::RenderMode::ExternalThread)
906906
{
@@ -941,11 +941,11 @@ namespace RC
941941

942942
if (settings_manager.Debug.RenderMode == GUI::RenderMode::EngineTick)
943943
{
944-
Hook::RegisterEngineTickPostCallback(gui_render_thread_tick);
944+
Hook::RegisterEngineTickPostCallback([](auto&,...){gui_render_thread_tick(); }, {false, false, STR("UE4SS"), STR("ImGuiRenderHook")});
945945
}
946946
else if (settings_manager.Debug.RenderMode == GUI::RenderMode::GameViewportClientTick)
947947
{
948-
Hook::RegisterGameViewportClientTickPostCallback(gui_render_thread_tick);
948+
Hook::RegisterGameViewportClientTickPostCallback([](auto&,...){gui_render_thread_tick(); }, {false, false, STR("UE4SS"), STR("ImGuiRenderHook")});
949949
}
950950

951951
if (settings_manager.Debug.DebugConsoleEnabled)

cppmods/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
33

44
# Add C++ mods
55
add_subdirectory("KismetDebuggerMod")
6+
add_subdirectory("EventViewerMod")
67

78
# Organize targets in the "mods" folder
89
get_property(TARGETS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cmake_minimum_required(VERSION 3.22)
2+
set(TARGET EventViewerMod)
3+
project(${TARGET})
4+
5+
include(FetchContent)
6+
7+
FetchContent_Declare(
8+
concurrentqueue
9+
GIT_REPOSITORY [email protected]:cameron314/concurrentqueue.git
10+
GIT_TAG c68072129c8a5b4025122ca5a0c82ab14b30cb03
11+
)
12+
FetchContent_MakeAvailable(concurrentqueue)
13+
14+
add_library(${TARGET} SHARED
15+
src/dllmain.cpp
16+
src/EventViewer.cpp
17+
src/Middleware.cpp
18+
src/Client.cpp
19+
src/Structs.cpp
20+
src/StringPool.cpp
21+
src/EntryCallStackRenderer.cpp
22+
src/FilterCountRenderer.cpp
23+
)
24+
25+
target_include_directories(${TARGET} PRIVATE "include")
26+
target_link_libraries(${TARGET} PRIVATE ImGui)
27+
target_link_libraries(${TARGET} PRIVATE concurrentqueue)
28+
target_link_libraries(${TARGET} PUBLIC UE4SS)

0 commit comments

Comments
 (0)