mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
feat: delay main thread continuation until GameFixes are applied
This is a temporary workaround until we have infrastructure to intercept winapi in C++
This commit is contained in:
parent
28102b405b
commit
d2335274ee
8 changed files with 67 additions and 18 deletions
|
|
@ -59,7 +59,7 @@ bool is_full_dumps()
|
|||
return check_env_var("DALAMUD_IS_VEH_FULL");
|
||||
}
|
||||
|
||||
DllExport DWORD WINAPI Initialize(LPVOID lpParam)
|
||||
DllExport DWORD WINAPI Initialize(LPVOID lpParam, HANDLE hMainThreadContinue)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
ConsoleSetup(L"Dalamud Boot");
|
||||
|
|
@ -97,7 +97,7 @@ DllExport DWORD WINAPI Initialize(LPVOID lpParam)
|
|||
if (result != 0)
|
||||
return result;
|
||||
|
||||
typedef void (CORECLR_DELEGATE_CALLTYPE* custom_component_entry_point_fn)(LPVOID);
|
||||
typedef void (CORECLR_DELEGATE_CALLTYPE* custom_component_entry_point_fn)(LPVOID, HANDLE);
|
||||
custom_component_entry_point_fn entrypoint_fn = reinterpret_cast<custom_component_entry_point_fn>(entrypoint_vfn);
|
||||
|
||||
// ============================== VEH ======================================== //
|
||||
|
|
@ -121,7 +121,7 @@ DllExport DWORD WINAPI Initialize(LPVOID lpParam)
|
|||
// ============================== Dalamud ==================================== //
|
||||
|
||||
printf("Initializing Dalamud... ");
|
||||
entrypoint_fn(lpParam);
|
||||
entrypoint_fn(lpParam, hMainThreadContinue);
|
||||
printf("Done!\n");
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "pch.h"
|
||||
|
||||
DllExport DWORD WINAPI Initialize(LPVOID lpParam);
|
||||
DllExport DWORD WINAPI Initialize(LPVOID lpParam, HANDLE hMainThreadContinue);
|
||||
|
||||
struct RewrittenEntryPointParameters {
|
||||
void* pAllocation;
|
||||
|
|
@ -379,8 +379,9 @@ DllExport void WINAPI RewrittenEntryPoint(RewrittenEntryPointParameters& params)
|
|||
params.hMainThread = CreateThread(nullptr, 0, [](void* p) -> DWORD {
|
||||
try {
|
||||
std::string loadInfo;
|
||||
auto& params = *reinterpret_cast<RewrittenEntryPointParameters*>(p);
|
||||
{
|
||||
auto& params = *reinterpret_cast<RewrittenEntryPointParameters*>(p);
|
||||
|
||||
|
||||
// Restore original entry point.
|
||||
// Use WriteProcessMemory instead of memcpy to avoid having to fiddle with VirtualProtect.
|
||||
|
|
@ -390,12 +391,12 @@ DllExport void WINAPI RewrittenEntryPoint(RewrittenEntryPointParameters& params)
|
|||
loadInfo = params.pLoadInfo;
|
||||
|
||||
// Let the game initialize.
|
||||
SetEvent(params.hMainThreadContinue);
|
||||
//SetEvent(params.hMainThreadContinue);
|
||||
}
|
||||
|
||||
wait_for_game_window();
|
||||
//wait_for_game_window();
|
||||
|
||||
Initialize(&loadInfo[0]);
|
||||
Initialize(&loadInfo[0], params.hMainThreadContinue);
|
||||
return 0;
|
||||
} catch (const std::exception& e) {
|
||||
MessageBoxA(nullptr, std::format("Failed to load Dalamud.\n\nError: {}", e.what()).c_str(), "Dalamud.Boot", MB_OK | MB_ICONERROR);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue