Skip to content

Commit 7b77697

Browse files
committed
fix(Init): Don't force game to wait for UE4SS if manually injecting
1 parent f66507e commit 7b77697

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

UE4SS/src/main_ue4ss_rewritten.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ auto thread_dll_start(UE4SSProgram* program) -> unsigned long
4040
return 0;
4141
}
4242

43+
static bool s_wait_for_ue4ss{};
44+
4345
auto process_initialized(HMODULE moduleHandle) -> void
4446
{
4547
wchar_t moduleFilenameBuffer[1024]{'\0'};
@@ -51,7 +53,10 @@ auto process_initialized(HMODULE moduleHandle) -> void
5153
CloseHandle(handle);
5254
}
5355

54-
UE4SSProgram::cpp_mods_done_loading.wait(false, std::memory_order_relaxed);
56+
if (s_wait_for_ue4ss)
57+
{
58+
UE4SSProgram::cpp_mods_done_loading.wait(false, std::memory_order_relaxed);
59+
}
5560
}
5661

5762
auto get_main_thread_id() -> DWORD
@@ -109,10 +114,12 @@ auto dll_process_attached(HMODULE moduleHandle) -> void
109114
// injected through proxy
110115
if (GetCurrentThreadId() == get_main_thread_id())
111116
{
117+
s_wait_for_ue4ss = true;
112118
QueueUserAPC((PAPCFUNC)process_initialized, GetCurrentThread(), (ULONG_PTR)moduleHandle);
113119
}
114120
else // injected manually -> thread id different from main
115121
{
122+
s_wait_for_ue4ss = false;
116123
process_initialized(moduleHandle);
117124
}
118125
}

0 commit comments

Comments
 (0)