Beispiel #1
0
        protected NVDRS_PROFILE GetProfileInfo(IntPtr hSession, IntPtr hProfile)
        {
            var tmpProfile = new NVDRS_PROFILE();

            tmpProfile.version = nvw.NVDRS_PROFILE_VER;

            var gpRes = nvw.DRS_GetProfileInfo(hSession, hProfile, ref tmpProfile);

            if (gpRes != NvAPI_Status.NVAPI_OK)
            {
                throw new NvapiException("DRS_GetProfileInfo", gpRes);
            }

            return(tmpProfile);
        }
        private bool CheckCommonSetting(IntPtr hSession, IntPtr hProfile, NVDRS_PROFILE profile,
                                        ref int checkedSettingsCount, uint checkSettingId, bool addToScanResult,
                                        ref List <uint> alreadyCheckedSettingIds)
        {
            if (checkedSettingsCount >= profile.numOfSettings)
            {
                return(false);
            }

            var setting = new NVDRS_SETTING();

            setting.version = nvw.NVDRS_SETTING_VER;

            if (nvw.DRS_GetSetting(hSession, hProfile, checkSettingId, ref setting) != NvAPI_Status.NVAPI_OK)
            {
                return(false);
            }

            if (setting.settingLocation != NVDRS_SETTING_LOCATION.NVDRS_CURRENT_PROFILE_LOCATION)
            {
                return(false);
            }

            if (!addToScanResult && setting.isCurrentPredefined == 1)
            {
                checkedSettingsCount++;
            }
            else if (addToScanResult)
            {
                if (decrypter != null)
                {
                    decrypter.DecryptSettingIfNeeded(profile.profileName, ref setting);
                }

                checkedSettingsCount++;
                AddScannedSettingToCache(profile, setting);
                alreadyCheckedSettingIds.Add(setting.settingId);
                return(setting.isCurrentPredefined != 1);
            }
            else if (setting.isCurrentPredefined != 1)
            {
                return(true);
            }

            return(false);
        }
        private void AddScannedSettingToCache(NVDRS_PROFILE profile, NVDRS_SETTING setting)
        {
            // Skip 3D Vision string values here for improved scan performance
            bool allowAddValue = setting.settingId < 0x70000000 || setting.settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE;

            //bool allowAddValue = true;

            var cachedSetting = CachedSettings
                                .FirstOrDefault(x => x.SettingId.Equals(setting.settingId));

            bool cacheEntryExists = true;

            if (cachedSetting == null)
            {
                cacheEntryExists = false;
                cachedSetting    = new CachedSettings(setting.settingId, setting.settingType);
            }

            if (setting.isPredefinedValid == 1)
            {
                if (allowAddValue)
                {
                    if (setting.settingType == NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE)
                    {
                        cachedSetting.AddStringValue(setting.predefinedValue.stringValue, profile.profileName);
                    }
                    else if (setting.settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE)
                    {
                        cachedSetting.AddDwordValue(setting.predefinedValue.dwordValue, profile.profileName);
                    }
                    else if (setting.settingType == NVDRS_SETTING_TYPE.NVDRS_BINARY_TYPE)
                    {
                        cachedSetting.AddBinaryValue(setting.predefinedValue.binaryValue, profile.profileName);
                    }
                }
                else
                {
                    cachedSetting.ProfileCount++;
                }

                if (!cacheEntryExists)
                {
                    CachedSettings.Add(cachedSetting);
                }
            }
        }
Beispiel #4
0
        protected IntPtr CreateProfile(IntPtr hSession, string profileName)
        {
            if (string.IsNullOrEmpty(profileName))
            {
                throw new ArgumentNullException("profileName");
            }

            var hProfile = IntPtr.Zero;

            var newProfile = new NVDRS_PROFILE()
            {
                version     = nvw.NVDRS_PROFILE_VER,
                profileName = profileName,
            };

            var nvRes = nvw.DRS_CreateProfile(hSession, ref newProfile, ref hProfile);

            if (nvRes != NvAPI_Status.NVAPI_OK)
            {
                throw new NvapiException("DRS_CreateProfile", nvRes);
            }

            return(hProfile);
        }