Skip to content

Commit

Permalink
Add current game's relative executable path to DRS profile on NVIDIA …
Browse files Browse the repository at this point in the history
…GPUs if the fully-qualified path is not present when attempting to read a driver setting DWORD.
  • Loading branch information
Kaldaien committed Apr 19, 2024
1 parent 909cffd commit 3cf19a9
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
24.4.19.2
24.4.19.3
=========
+ Add current game's relative executable path to DRS profile on NVIDIA
GPUs if the fully-qualified path is not present when attempting to
read a driver setting DWORD.

24.4.19.2
=========
+ Added Resizable BAR status to Display menu on NVIDIA GPUs
>> Setting can be changed (per-game) by right-clicking it
Expand Down
4 changes: 2 additions & 2 deletions include/SpecialK/DLL_VERSION.H
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#define SK_YEAR 24
#define SK_MONTH 4
#define SK_DATE 19
#define SK_REV_N 2
#define SK_REV 2
#define SK_REV_N 3
#define SK_REV 3

#ifndef _A2
#define _A2(a) #a
Expand Down
46 changes: 43 additions & 3 deletions src/nvapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3191,10 +3191,50 @@ SK_NvAPI_DRS_GetDWORD (NvU32 setting_id)
&app ),
ret );

if (ret != NVAPI_OK)
// If no executable exists anywhere by this name, create a profile for it
// and then add the executable to it.
if (ret == NVAPI_EXECUTABLE_NOT_FOUND)
{
NVAPI_CALL (DRS_DestroySession (hSession));
return 0;
NVDRS_PROFILE custom_profile = { };

if (friendly_name.empty ()) // Avoid NVAPI failure: NVAPI_PROFILE_NAME_EMPTY
friendly_name = app_name;

custom_profile.isPredefined = FALSE;
lstrcpyW ((wchar_t *)custom_profile.profileName, friendly_name.c_str ());
custom_profile.version = NVDRS_PROFILE_VER;

// It's not necessarily wrong if this does not return NVAPI_OK, so don't
// raise a fuss if it happens.
NVAPI_SILENT ()
{
NVAPI_CALL2 (DRS_CreateProfile (hSession, &custom_profile, &hProfile), ret);
}
NVAPI_VERBOSE ()

// Add the application name to the profile, if a profile already exists
if (ret == NVAPI_PROFILE_NAME_IN_USE)
{
NVAPI_CALL2 ( DRS_FindProfileByName ( hSession,
(NvU16 *)friendly_name.c_str (),
&hProfile),
ret );
}

if (ret == NVAPI_OK)
{
RtlZeroMemory (app_ptr.get (), sizeof NVDRS_APPLICATION);

lstrcpyW ((wchar_t *)app.appName, app_name.c_str ());
lstrcpyW ((wchar_t *)app.userFriendlyName, friendly_name.c_str ());

app.version = NVDRS_APPLICATION_VER;
app.isPredefined = FALSE;
app.isMetro = FALSE;

NVAPI_CALL2 (DRS_CreateApplication (hSession, hProfile, &app), ret);
NVAPI_CALL2 (DRS_SaveSettings (hSession), ret);
}
}

NVDRS_SETTING get_val = { };
Expand Down

0 comments on commit 3cf19a9

Please sign in to comment.