Orbmu2k/nvidiaProfileInspector · error · NvapiException

DRS_GetCurrentGlobalProfile

Error message

DRS_GetCurrentGlobalProfile

What it means

Sentinel guard in GetProfileHandle for the empty/null profileName path: after DRS_GetCurrentGlobalProfile reports success, the code throws a manually constructed NvapiException ("DRS_GetCurrentGlobalProfile") when the returned hProfile is IntPtr.Zero. This is a generic null-handle guard, not a driver status: the driver succeeded but yielded no global profile handle, meaning the NVIDIA driver settings store has no usable global profile (driver missing, not loaded, or freshly reset). The input at fault is the empty profileName that triggers the global-profile lookup.

Solutions

  1. Treat a null global profile handle as "driver unavailable" and disable driver-settings operations gracefully.
  2. Catch NvapiException in DrsSession callers and surface a clear driver-missing message.
  3. Pass a concrete profile name to avoid the global-profile lookup when possible.
  4. Check driver installation state up front before opening any DRS session.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs:69 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs:69

        protected T DrsSession<T>(Func<IntPtr, T> action, bool forceDedicatedScope = false)
        {
            return DrsSessionScope.DrsSession<T>(action, forceDedicatedScope);
        }

        protected IntPtr GetProfileHandle(IntPtr hSession, string profileName)
        {
            var hProfile = IntPtr.Zero;

            if (string.IsNullOrEmpty(profileName))
            {
                var nvRes = nvw.Instance.DRS_GetCurrentGlobalProfile(hSession, ref hProfile);

                if (hProfile == IntPtr.Zero)
                    throw new NvapiException("DRS_GetCurrentGlobalProfile", NvAPI_Status.NVAPI_PROFILE_NOT_FOUND);

                if (nvRes != NvAPI_Status.NVAPI_OK)
                    throw new NvapiException("DRS_GetCurrentGlobalProfile", nvRes);
            }
            else
            {
                var nvRes = nvw.Instance.DRS_FindProfileByName(hSession, new StringBuilder(profileName), ref hProfile);

                if (nvRes == NvAPI_Status.NVAPI_PROFILE_NOT_FOUND)
                    return IntPtr.Zero;

                if (nvRes != NvAPI_Status.NVAPI_OK)
                    throw new NvapiException("DRS_FindProfileByName", nvRes);
            }
            return hProfile;
        }

        protected IntPtr CreateProfile(IntPtr hSession, string profileName)
        {
            if (string.IsNullOrEmpty(profileName))
                throw new ArgumentNullException("profileName");

View on GitHub (pinned to 2f50c388b3)