From 401d0e0b1408ac8f28c9605671f12e8830a21f3c Mon Sep 17 00:00:00 2001 From: Kaldaien Date: Fri, 29 Nov 2024 22:35:26 -0500 Subject: [PATCH] Bring back original slUpgradeInterface and slGetNativeInterface implementation that could handle situations where sl.interposer.dll is loaded late --- src/diagnostics/compatibility.cpp | 60 +++++++++++++++---------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/src/diagnostics/compatibility.cpp b/src/diagnostics/compatibility.cpp index 480bc11ba..2976a2926 100644 --- a/src/diagnostics/compatibility.cpp +++ b/src/diagnostics/compatibility.cpp @@ -1196,23 +1196,21 @@ SK_slGetNativeInterface (void *proxyInterface, void **baseInterface) if (FAILED (pUnk->QueryInterface (__uuidof (IStreamlineBaseInterface), baseInterface))) return sl::Result::eErrorUnsupportedInterface; #else - static bool has_streamline = - PathFileExistsW (L"sl.interposer.dll") || - GetModuleHandleW (L"sl.interposer.dll") != nullptr; - - if (has_streamline) - { - static slGetNativeInterface_pfn - slGetNativeInterface = - (slGetNativeInterface_pfn)SK_GetProcAddress (L"sl.interposer.dll", - "slGetNativeInterface"); - - if (slGetNativeInterface != nullptr) - return slGetNativeInterface (proxyInterface, baseInterface); - } + sl::Result result; + + static + slGetNativeInterface_pfn + slGetNativeInterface = nullptr; + if (slGetNativeInterface == nullptr && SK_GetFramesDrawn () < 240) + slGetNativeInterface = + (slGetNativeInterface_pfn)SK_GetProcAddress (L"sl.interposer.dll", + "slGetNativeInterface"); result = + slGetNativeInterface != nullptr ? + slGetNativeInterface (proxyInterface, baseInterface) : + sl::Result::eErrorNotInitialized ; + + return result; #endif - - return sl::Result::eErrorNotInitialized; } sl::Result @@ -1266,21 +1264,19 @@ SK_slUpgradeInterface (void **baseInterface) return result; } #else - static bool has_streamline = - PathFileExistsW (L"sl.interposer.dll") || - GetModuleHandleW (L"sl.interposer.dll") != nullptr; - - if (has_streamline) - { - static slUpgradeInterface_pfn - slUpgradeInterface = - (slUpgradeInterface_pfn)SK_GetProcAddress (L"sl.interposer.dll", - "slUpgradeInterface"); - - if (slUpgradeInterface != nullptr) - return slUpgradeInterface (baseInterface); - } + sl::Result result; + + static + slUpgradeInterface_pfn + slUpgradeInterface = nullptr; + if (slUpgradeInterface == nullptr && SK_GetFramesDrawn () < 240) + slUpgradeInterface = + (slUpgradeInterface_pfn)SK_GetProcAddress (L"sl.interposer.dll", + "slUpgradeInterface"); result = + slUpgradeInterface != nullptr ? + slUpgradeInterface (baseInterface) : + sl::Result::eErrorNotInitialized ; + + return result; #endif - - return sl::Result::eErrorNotInitialized; } \ No newline at end of file