Skip to content

Commit

Permalink
Added protection against SteamAPI's internal exceptions being caught …
Browse files Browse the repository at this point in the history
…by NVIDIA Streamline's Interposer DLL and triggering NVIDIA's stupid any exception detected ==> minidump crap built-in to DLSS3
  • Loading branch information
Kaldaien committed Sep 18, 2024
1 parent 2a895a7 commit 99521b6
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 37 deletions.
21 changes: 20 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
24.9.18.6
24.9.19
=======
+ Added protection against SteamAPI's internal exceptions being caught by
NVIDIA Streamline's Interposer DLL and triggering NVIDIA's stupid
any exception detected ==> minidump crap built-in to DLSS3.

* Calling SteamAPI functions from overlay code is UNSAFE thanks to NVIDIA
and their non-defeatable and ill-advised exception handler built-in to
Streamline.

Streamline catches exceptions that ARE handled by the software, or are
continuable, and turns harmless exceptions into full crashes (gah!!).

sl.interposer.dll is pure evil when officially compiled by NVIDIA using
the release build configuration.

@ NVIDIA get that crap out of there please, and remove the codesigned DLL
DRM so users can at least bypass your boobytrap without losing DLSS3.

24.9.18.6
=========
+ Added sensible limits to DirectStorage thread count sliders
+ Reduced the DirectStorage queue length in FFXVI to reduce stutter
Expand Down
6 changes: 3 additions & 3 deletions include/SpecialK/DLL_VERSION.H
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#define SK_YEAR 24
#define SK_MONTH 9
#define SK_DATE 18
#define SK_REV_N 6
#define SK_REV 6
#define SK_DATE 19
#define SK_REV_N 0
#define SK_REV 0

#ifndef _A2
#define _A2(a) #a
Expand Down
1 change: 1 addition & 0 deletions include/SpecialK/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ struct sk_config_t
bool reuse_overlay_pause = false;// Use Steam's overlay pause mode for our own
// control panel
bool silent = false;
bool steam_is_b0rked = false; // Need to swallow some exceptions or Streamline may crash games
} platform;

struct epic_s {
Expand Down
2 changes: 1 addition & 1 deletion src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ SK_GetCurrentGameID (void)
// Streamline shenanigans
config.compatibility.init_sync_for_streamline = true;
config.render.dxgi.fake_fullscreen_mode = true;
config.steam.spoof_BLoggedOn = true;
config.render.dstorage.submit_threads = 2;

current_game = SK_GAME_ID::FinalFantasyXVI;
}
Expand Down
25 changes: 19 additions & 6 deletions src/control_panel/cfg_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,22 @@ SK::ControlPanel::Platform::Draw (void)
ImGui::PushStyleColor (ImGuiCol_HeaderActive, ImVec4 (0.14f, 0.78f, 0.87f, 0.80f));
ImGui::TreePush ("");

static bool
static bool bHasAchievements = false;

SK_RunOnce (
{
// Will test whether SteamAPI is going to throw an exception,
// we need to not make these API calls if it does or NVIDIA
// Streamline will cause games to crash!
SK_SteamAPI_GetNumPlayers ();

bool bSteamWorks =
(! config.platform.steam_is_b0rked);

bHasAchievements =
( bSteam && SK_SteamAPI_GetNumPossibleAchievements () > 0 ) ||
( bEpic && SK_EOS_GetNumPossibleAchievements () > 0 );
( bSteamWorks && SK_SteamAPI_GetNumPossibleAchievements () > 0 ) ||
( bEpic && SK_EOS_GetNumPossibleAchievements () > 0 );
});


if (bHasAchievements)
Expand Down Expand Up @@ -275,16 +287,17 @@ SK::ControlPanel::Platform::Draw (void)
}
}

else
else if (! config.platform.steam_is_b0rked)
{
// Handle late init situations
bHasAchievements =
( ( bSteam && SK_SteamAPI_GetNumPossibleAchievements () > 0 )
|| ( bEpic && SK_EOS_GetNumPossibleAchievements () > 0 ) );
}

static bool bSteamOverlayEnabled = steam_ctx.Utils () != nullptr
&& steam_ctx.Utils ()->IsOverlayEnabled ();
static bool bSteamOverlayEnabled = config.platform.steam_is_b0rked == false &&
steam_ctx.Utils () != nullptr &&
steam_ctx.Utils ()->IsOverlayEnabled ();

bool bOverlayEnabled =
( bSteamOverlayEnabled || SK::EOS::GetTicksRetired () > 0 );
Expand Down
4 changes: 2 additions & 2 deletions src/control_panel/cfg_steam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ SK::ControlPanel::Steam::Draw (void)
{
if (SK::SteamAPI::AppID () != 0)
{
auto* pRemote =
steam_ctx.RemoteStorage ();// SK_SteamAPI_RemoteStorage ();
auto* pRemote = (! config.platform.steam_is_b0rked) ?
steam_ctx.RemoteStorage () : nullptr;

static BOOL app_has_cloud_storage = -1 /* Unknown */;

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/ffxvi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ SK_FFXVI_InitPlugin (void)

// Avoid Steam Offline Warnings
config.platform.achievements.pull_friend_stats = false;
config.steam.spoof_BLoggedOn = true;
config.steam.spoof_BLoggedOn = false;

SK_FFXVI_JXLMaxThreads =
config.screenshots.avif.max_threads;
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/reshade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,11 @@ SK_ReShadeAddOn_ActivateOverlay (bool activate)
{
std::ignore = activate;

// Early-out if ReShade's not relevant to avoid acquiring and
// immediately releasing a reference on the SwapChain.
if (ReShadeRuntimes.empty ())
return;

#if 1
const SK_RenderBackend &rb =
SK_GetCurrentRenderBackend ();
Expand Down
2 changes: 2 additions & 0 deletions src/render/d3d11/d3d11_screenshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,7 @@ SK_D3D11_ProcessScreenshotQueueEx ( SK_ScreenshotStage stage_,
_TRUNCATE );

if ( config.steam.screenshots.enable_hook &&
!config.platform.steam_is_b0rked &&
steam_ctx.Screenshots () != nullptr )
{
PathAppendW (wszAbsolutePathToScreenshot, L"SK_SteamScreenshotImport.jpg");
Expand Down Expand Up @@ -1728,6 +1729,7 @@ SK_D3D11_ProcessScreenshotQueueEx ( SK_ScreenshotStage stage_,
#endif

if ( config.steam.screenshots.enable_hook &&
!config.platform.steam_is_b0rked &&
steam_ctx.Screenshots () != nullptr )
{
wchar_t wszAbsolutePathToThumbnail [ MAX_PATH + 2 ] = { };
Expand Down
2 changes: 2 additions & 0 deletions src/render/d3d12/d3d12_screenshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,7 @@ SK_D3D12_ProcessScreenshotQueueEx ( SK_ScreenshotStage stage_ = SK_ScreenshotSta
_TRUNCATE );

if ( config.steam.screenshots.enable_hook &&
!config.platform.steam_is_b0rked &&
steam_ctx.Screenshots () != nullptr )
{
PathAppendW (wszAbsolutePathToScreenshot, L"SK_SteamScreenshotImport.jpg");
Expand Down Expand Up @@ -1692,6 +1693,7 @@ SK_D3D12_ProcessScreenshotQueueEx ( SK_ScreenshotStage stage_ = SK_ScreenshotSta
#endif

if ( config.steam.screenshots.enable_hook &&
!config.platform.steam_is_b0rked &&
steam_ctx.Screenshots () != nullptr )
{
wchar_t wszAbsolutePathToThumbnail [ MAX_PATH + 2 ] = { };
Expand Down
Loading

0 comments on commit 99521b6

Please sign in to comment.