Orbmu2k/nvidiaProfileInspector · error · NvapiException

DRS_EnumSettings

Error message

DRS_EnumSettings

What it means

NvapiException wrapping the NVAPI status returned by DRS_EnumSettings when it is neither NVAPI_OK nor the benign NVAPI_END_ENUMERATION. DRS_EnumSettings enumerates the driver settings on a profile; a non-OK status means the enumeration call itself failed at the NVIDIA driver interface level. The exception is thrown by GetProfileSettings in DrsSettingsServiceBase before any per-setting decryption/processing.

Solutions

  1. Check that the NvapiException.Status is not NVAPI_END_ENUMERATION/expected value and log the exact status to identify the failure
  2. Ensure NVAPI_Initialize succeeded and DRS_CreateSession/DRS_OpenProfileSession returned NVAPI_OK before enumerating
  3. Re-create the DRS session and re-open the profile after driver updates or process changes
  4. Verify the app runs with the privileges NVAPI DRS requires (usually the same user, sometimes admin for system profile)
  5. Call NvapiDrsWrapper.Initialize once at startup and check its result instead of assuming it succeeded

Example fix

// before
var settings = GetProfileSettings(hSession, hProfile);
// after
try { var settings = GetProfileSettings(hSession, hProfile); }
catch (NvapiException ex) { Log.Warn($"DRS_EnumSettings failed: {ex.Status}"); settings = new List<NVDRS_SETTING>(); }
Defensive patterns

Strategy: try-catch

Validate before calling

if (hSession == IntPtr.Zero || hProfile == IntPtr.Zero) throw new InvalidOperationException("DRS session/profile not open");

Try / catch

try { settings = GetProfileSettings(hSession, hProfile); }
catch (NvapiException ex) { Log.Warn($"DRS_EnumSettings failed with {ex.Status}"); settings = new List<NVDRS_SETTING>(); }

Prevention

When it happens

Trigger: Calling GetProfileSettings with an invalid or already-closed hSession/hProfile handle; the profile handle was invalidated by a driver reload or DRS_DestroySession; an NVAPI call earlier in the flow failed silently (e.g. Initialize without admin rights on some driver versions); passing a session created without DRS_CreateSession returning OK.

Common situations: Reading settings right after the NVIDIA driver was updated (session/handle invalidation); using a profile handle obtained from a different session; running without sufficient privileges so DRS calls return NVAPI_ERROR/NVAPI_NO_IMPLEMENTATION; app running before NVAPI_Initialize succeeded.

Related errors


AI-assisted analysis of Orbmu2k/nvidiaProfileInspector@2f50c388b3 (2026-09-15). Data as JSON: /api/errors/c196e1c6ce671c6b. Report an issue: GitHub.

Appendix: source

Thrown at nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs:377

            if (nvRes != NvAPI_Status.NVAPI_END_ENUMERATION)
                throw new NvapiException("DRS_EnumProfiles", nvRes);

            return profileHandles;
        }

        protected List<NVDRS_SETTING> GetProfileSettings(IntPtr hSession, IntPtr hProfile, uint expectedCount = 512)
        {
            uint settingCount = expectedCount > 0 ? expectedCount : 1;
            var settings = new NVDRS_SETTING[settingCount];
            settings[0].version = NvapiDrsWrapper.NVDRS_SETTING_VER;

            var esRes = NvapiDrsWrapper.Instance.DRS_EnumSettings(hSession, hProfile, 0, ref settingCount, ref settings);

            if (esRes == NvAPI_Status.NVAPI_END_ENUMERATION)
                return new List<NVDRS_SETTING>();

            if (esRes != NvAPI_Status.NVAPI_OK)
                throw new NvapiException("DRS_EnumSettings", esRes);

            if (decrypter != null)
            {
                var profile = GetProfileInfo(hSession, hProfile);
                for (int i = 0; i < settingCount; i++)
                {
                    decrypter.DecryptSettingIfNeeded(profile.profileName, ref settings[i]);
                }
            }

            return settings.ToList();
        }

        protected List<NVDRS_APPLICATION_V4> GetProfileApplications(IntPtr hSession, IntPtr hProfile)
        {
            uint appCount = 512;
            var apps = new NVDRS_APPLICATION_V4[512];
            apps[0].version = NvapiDrsWrapper.NVDRS_APPLICATION_VER_V4;

View on GitHub (pinned to 2f50c388b3)