{"record":{"id":"2bf19f2ec25b61ba","repo":"Orbmu2k/nvidiaProfileInspector","slug":"drs-getcurrentglobalprofile","errorCode":null,"errorMessage":"DRS_GetCurrentGlobalProfile","messagePattern":"DRS_GetCurrentGlobalProfile","errorType":"exception","errorClass":"NvapiException","httpStatus":null,"severity":"error","filePath":"nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs","lineNumber":69,"sourceCode":"\n        protected T DrsSession<T>(Func<IntPtr, T> action, bool forceDedicatedScope = false)\n        {\n            return DrsSessionScope.DrsSession<T>(action, forceDedicatedScope);\n        }\n\n        protected IntPtr GetProfileHandle(IntPtr hSession, string profileName)\n        {\n            var hProfile = IntPtr.Zero;\n\n            if (string.IsNullOrEmpty(profileName))\n            {\n                var nvRes = nvw.Instance.DRS_GetCurrentGlobalProfile(hSession, ref hProfile);\n\n                if (hProfile == IntPtr.Zero)\n                    throw new NvapiException(\"DRS_GetCurrentGlobalProfile\", NvAPI_Status.NVAPI_PROFILE_NOT_FOUND);\n\n                if (nvRes != NvAPI_Status.NVAPI_OK)\n                    throw new NvapiException(\"DRS_GetCurrentGlobalProfile\", nvRes);\n            }\n            else\n            {\n                var nvRes = nvw.Instance.DRS_FindProfileByName(hSession, new StringBuilder(profileName), ref hProfile);\n\n                if (nvRes == NvAPI_Status.NVAPI_PROFILE_NOT_FOUND)\n                    return IntPtr.Zero;\n\n                if (nvRes != NvAPI_Status.NVAPI_OK)\n                    throw new NvapiException(\"DRS_FindProfileByName\", nvRes);\n            }\n            return hProfile;\n        }\n\n        protected IntPtr CreateProfile(IntPtr hSession, string profileName)\n        {\n            if (string.IsNullOrEmpty(profileName))\n                throw new ArgumentNullException(\"profileName\");","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/Orbmu2k/nvidiaProfileInspector/blob/2f50c388b3a4d661cade66b32746bec096d1eee1/nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs#L51-L87","documentation":"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.","triggerScenarios":"Thrown at nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs:69 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat a null global profile handle as \"driver unavailable\" and disable driver-settings operations gracefully.","Catch NvapiException in DrsSession callers and surface a clear driver-missing message.","Pass a concrete profile name to avoid the global-profile lookup when possible.","Check driver installation state up front before opening any DRS session."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2f50c388b3a4d661cade66b32746bec096d1eee1","analyzedAt":"2026-09-15T05:23:52.218Z","contentChangedAt":"2026-09-15T05:23:52.218Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}