Skip to content

Commit

Permalink
Bring back original slUpgradeInterface and slGetNativeInterface imple…
Browse files Browse the repository at this point in the history
…mentation that could handle situations where sl.interposer.dll is loaded late
  • Loading branch information
Kaldaien committed Nov 30, 2024
1 parent 48a9e5d commit 401d0e0
Showing 1 changed file with 28 additions and 32 deletions.
60 changes: 28 additions & 32 deletions src/diagnostics/compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

0 comments on commit 401d0e0

Please sign in to comment.