├── .gitignore ├── LICENSE ├── LICENSE.txt ├── README.md ├── npi_screenshot.png ├── nspector ├── Common │ ├── Cache │ │ ├── CachedSettingValue.cs │ │ └── CachedSettings.cs │ ├── CustomSettings │ │ ├── CustomSetting.cs │ │ ├── CustomSettingNames.cs │ │ └── CustomSettingValue.cs │ ├── DrsDecrypterService.cs │ ├── DrsImportService.cs │ ├── DrsScannerService.cs │ ├── DrsServiceLocator.cs │ ├── DrsSessionScope.cs │ ├── DrsSettingsMetaService.cs │ ├── DrsSettingsService.cs │ ├── DrsSettingsServiceBase.cs │ ├── DrsUtil.cs │ ├── Helper │ │ ├── AdminHelper.cs │ │ ├── DropDownMenuScrollWheelHandler.cs │ │ ├── InputBox.cs │ │ ├── ListSort.cs │ │ ├── ListViewGroupSorter.cs │ │ ├── NoBorderRenderer.cs │ │ ├── ShortcutResolver.cs │ │ ├── SteamAppResolver.cs │ │ ├── TempFile.cs │ │ ├── UserSettings.cs │ │ └── XMLHelper.cs │ ├── Import │ │ ├── ImportExportUitl.cs │ │ ├── Profile.cs │ │ ├── ProfileSetting.cs │ │ ├── Profiles.cs │ │ └── SettingValueType.cs │ ├── Meta │ │ ├── ConstantSettingMetaService.cs │ │ ├── CustomSettingMetaService.cs │ │ ├── DriverSettingMetaService.cs │ │ ├── ISettingMetaService.cs │ │ ├── MetaServiceItem.cs │ │ ├── ScannedSettingMetaService.cs │ │ ├── SettingMeta.cs │ │ ├── SettingMetaSource.cs │ │ └── SettingValue.cs │ ├── NvapiException.cs │ ├── SettingItem.cs │ └── SettingViewMode.cs ├── CustomSettingNames.xml ├── Images │ ├── 0_gear2.png │ ├── 1_gear2_2.png │ ├── 4_gear_nv2.png │ ├── 6_gear_inherit.png │ ├── PortableDeviceStatus_3_16-011.png │ ├── apply.png │ ├── export1.png │ ├── filter_user.png │ ├── find_set2.png │ ├── home_sm.png │ ├── ieframe_1_18212.png │ ├── ieframe_1_31073-002.png │ ├── import1.png │ ├── n1-016.png │ ├── nv_btn.png │ ├── shield.png │ ├── shield16.ico │ ├── text_binary.png │ ├── transparent16.png │ ├── window_application_add.png │ └── window_application_delete.png ├── ListViewEx.cs ├── Native │ ├── NVAPI │ │ ├── NvApiDriverSettings.cs │ │ ├── NvApiDriverSettings.h │ │ ├── NvApiDriverSettings.tt │ │ └── NvapiDrsWrapper.cs │ ├── NativeArrayHelper.cs │ └── WINAPI │ │ ├── DragAcceptNativeHelper.cs │ │ ├── MessageHelper.cs │ │ ├── SafeNativeMethods.cs │ │ ├── ShellLink.cs │ │ └── TaskBarList3.cs ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── Reference.xml ├── app.config ├── app.manifest ├── frmBitEditor.Designer.cs ├── frmBitEditor.cs ├── frmBitEditor.resx ├── frmDrvSettings.Designer.cs ├── frmDrvSettings.cs ├── frmDrvSettings.resx ├── frmExportProfiles.Designer.cs ├── frmExportProfiles.cs ├── frmExportProfiles.resx ├── n1.ico └── nvidiaProfileInspector.csproj └── nvidiaProfileInspector.sln /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | 24 | # Visual Studio 2015 cache/options directory 25 | .vs/ 26 | # Uncomment if you have tasks that create the project's static files in wwwroot 27 | #wwwroot/ 28 | 29 | # MSTest test Results 30 | [Tt]est[Rr]esult*/ 31 | [Bb]uild[Ll]og.* 32 | 33 | # NUNIT 34 | *.VisualState.xml 35 | TestResult.xml 36 | 37 | # Build Results of an ATL Project 38 | [Dd]ebugPS/ 39 | [Rr]eleasePS/ 40 | dlldata.c 41 | 42 | # DNX 43 | project.lock.json 44 | artifacts/ 45 | 46 | *_i.c 47 | *_p.c 48 | *_i.h 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.tmp_proj 63 | *.log 64 | *.vspscc 65 | *.vssscc 66 | .builds 67 | *.pidb 68 | *.svclog 69 | *.scc 70 | 71 | # Chutzpah Test files 72 | _Chutzpah* 73 | 74 | # Visual C++ cache files 75 | ipch/ 76 | *.aps 77 | *.ncb 78 | *.opendb 79 | *.opensdf 80 | *.sdf 81 | *.cachefile 82 | 83 | # Visual Studio profiler 84 | *.psess 85 | *.vsp 86 | *.vspx 87 | *.sap 88 | 89 | # TFS 2012 Local Workspace 90 | $tf/ 91 | 92 | # Guidance Automation Toolkit 93 | *.gpState 94 | 95 | # ReSharper is a .NET coding add-in 96 | _ReSharper*/ 97 | *.[Rr]e[Ss]harper 98 | *.DotSettings.user 99 | 100 | # JustCode is a .NET coding add-in 101 | .JustCode 102 | 103 | # TeamCity is a build add-in 104 | _TeamCity* 105 | 106 | # DotCover is a Code Coverage Tool 107 | *.dotCover 108 | 109 | # NCrunch 110 | _NCrunch_* 111 | .*crunch*.local.xml 112 | nCrunchTemp_* 113 | 114 | # MightyMoose 115 | *.mm.* 116 | AutoTest.Net/ 117 | 118 | # Web workbench (sass) 119 | .sass-cache/ 120 | 121 | # Installshield output folder 122 | [Ee]xpress/ 123 | 124 | # DocProject is a documentation generator add-in 125 | DocProject/buildhelp/ 126 | DocProject/Help/*.HxT 127 | DocProject/Help/*.HxC 128 | DocProject/Help/*.hhc 129 | DocProject/Help/*.hhk 130 | DocProject/Help/*.hhp 131 | DocProject/Help/Html2 132 | DocProject/Help/html 133 | 134 | # Click-Once directory 135 | publish/ 136 | 137 | # Publish Web Output 138 | *.[Pp]ublish.xml 139 | *.azurePubxml 140 | # TODO: Comment the next line if you want to checkin your web deploy settings 141 | # but database connection strings (with potential passwords) will be unencrypted 142 | *.pubxml 143 | *.publishproj 144 | 145 | # NuGet Packages 146 | *.nupkg 147 | # The packages folder can be ignored because of Package Restore 148 | **/packages/* 149 | # except build/, which is used as an MSBuild target. 150 | !**/packages/build/ 151 | # Uncomment if necessary however generally it will be regenerated when needed 152 | #!**/packages/repositories.config 153 | # NuGet v3's project.json files produces more ignoreable files 154 | *.nuget.props 155 | *.nuget.targets 156 | 157 | # Microsoft Azure Build Output 158 | csx/ 159 | *.build.csdef 160 | 161 | # Microsoft Azure Emulator 162 | ecf/ 163 | rcf/ 164 | 165 | # Microsoft Azure ApplicationInsights config file 166 | ApplicationInsights.config 167 | 168 | # Windows Store app package directory 169 | AppPackages/ 170 | BundleArtifacts/ 171 | 172 | # Visual Studio cache files 173 | # files ending in .cache can be ignored 174 | *.[Cc]ache 175 | # but keep track of directories ending in .cache 176 | !*.[Cc]ache/ 177 | 178 | # Others 179 | ClientBin/ 180 | ~$* 181 | *~ 182 | *.dbmdl 183 | *.dbproj.schemaview 184 | *.pfx 185 | *.publishsettings 186 | node_modules/ 187 | orleans.codegen.cs 188 | 189 | # RIA/Silverlight projects 190 | Generated_Code/ 191 | 192 | # Backup & report files from converting an old project file 193 | # to a newer Visual Studio version. Backup files are not needed, 194 | # because we have git ;-) 195 | _UpgradeReport_Files/ 196 | Backup*/ 197 | UpgradeLog*.XML 198 | UpgradeLog*.htm 199 | 200 | # SQL Server files 201 | *.mdf 202 | *.ldf 203 | 204 | # Business Intelligence projects 205 | *.rdl.data 206 | *.bim.layout 207 | *.bim_*.settings 208 | 209 | # Microsoft Fakes 210 | FakesAssemblies/ 211 | 212 | # GhostDoc plugin setting file 213 | *.GhostDoc.xml 214 | 215 | # Node.js Tools for Visual Studio 216 | .ntvs_analysis.dat 217 | 218 | # Visual Studio 6 build log 219 | *.plg 220 | 221 | # Visual Studio 6 workspace options file 222 | *.opt 223 | 224 | # Visual Studio LightSwitch build output 225 | **/*.HTMLClient/GeneratedArtifacts 226 | **/*.DesktopClient/GeneratedArtifacts 227 | **/*.DesktopClient/ModelManifest.xml 228 | **/*.Server/GeneratedArtifacts 229 | **/*.Server/ModelManifest.xml 230 | _Pvt_Extensions 231 | 232 | # Paket dependency manager 233 | .paket/paket.exe 234 | 235 | # FAKE - F# Make 236 | .fake/ 237 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Orbmu2k 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | nvidiaProfileInspector is licensed under MIT license. 2 | 3 | ---------------- 4 | 5 | Copyright (c) 2016 Orbmu2k 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](/nspector/Images/n1-016.png) **NVIDIA Profile Inspector** 2 | 3 | This tool is used for modifying game profiles inside the internal driver database of the nvidia driver. 4 | All game profiles are provided by the nvidia driver, but you can add your own profiles for games missing in the driver database. 5 | You also have access to hidden and undocumented settings, which are not provided by the drivers control panel. 6 | 7 | For more information how to use this tool, you can find some very good wikis here: 8 | * https://wiki.step-project.com/Guide:NVIDIA_Inspector 9 | * https://www.pcgamingwiki.com/wiki/Nvidia_Profile_Inspector 10 | 11 | ![](npi_screenshot.png) -------------------------------------------------------------------------------- /npi_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/npi_screenshot.png -------------------------------------------------------------------------------- /nspector/Common/Cache/CachedSettingValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace nspector.Common 5 | { 6 | internal class CachedSettingValue 7 | { 8 | 9 | internal CachedSettingValue() { } 10 | 11 | internal CachedSettingValue(uint Value, string ProfileNames) 12 | { 13 | this.Value = Value; 14 | this.ProfileNames = new StringBuilder(ProfileNames); 15 | this.ValueProfileCount = 1; 16 | } 17 | 18 | internal CachedSettingValue(string ValueStr, string ProfileNames) 19 | { 20 | this.ValueStr = ValueStr; 21 | this.ProfileNames = new StringBuilder(ProfileNames); 22 | this.ValueProfileCount = 1; 23 | } 24 | 25 | internal CachedSettingValue(byte[] ValueBin, string ProfileNames) 26 | { 27 | this.ValueBin = ValueBin; 28 | this.ProfileNames = new StringBuilder(ProfileNames); 29 | this.ValueProfileCount = 1; 30 | } 31 | 32 | internal string ValueStr = ""; 33 | internal uint Value = 0; 34 | internal byte[] ValueBin = new byte[0]; 35 | internal StringBuilder ProfileNames; 36 | internal uint ValueProfileCount; 37 | } 38 | } -------------------------------------------------------------------------------- /nspector/Common/Cache/CachedSettings.cs: -------------------------------------------------------------------------------- 1 | using nspector.Native.NVAPI2; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace nspector.Common 6 | { 7 | internal class CachedSettings 8 | { 9 | internal CachedSettings() { } 10 | 11 | internal CachedSettings(uint settingId, NVDRS_SETTING_TYPE settingType) 12 | { 13 | SettingId = settingId; 14 | SettingType = settingType; 15 | } 16 | 17 | internal uint SettingId; 18 | 19 | internal List SettingValues = new List(); 20 | 21 | internal uint ProfileCount = 0; 22 | 23 | internal NVDRS_SETTING_TYPE SettingType = NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE; 24 | 25 | internal void AddDwordValue(uint valueDword, string Profile) 26 | { 27 | var setting = SettingValues.FirstOrDefault(s => s.Value == valueDword); 28 | if (setting == null) 29 | { 30 | SettingValues.Add(new CachedSettingValue(valueDword, Profile)); 31 | } 32 | else 33 | { 34 | setting.ProfileNames.Append(", " + Profile); 35 | setting.ValueProfileCount++; 36 | } 37 | ProfileCount++; 38 | } 39 | 40 | internal void AddStringValue(string valueStr, string Profile) 41 | { 42 | 43 | var setting = SettingValues.FirstOrDefault(s => s.ValueStr == valueStr); 44 | if (setting == null) 45 | { 46 | SettingValues.Add(new CachedSettingValue(valueStr, Profile)); 47 | } 48 | else 49 | { 50 | setting.ProfileNames.Append(", " + Profile); 51 | setting.ValueProfileCount++; 52 | } 53 | ProfileCount++; 54 | } 55 | 56 | internal void AddBinaryValue(byte[] valueBin, string Profile) 57 | { 58 | 59 | var setting = SettingValues.FirstOrDefault(s => s.ValueBin.SequenceEqual(valueBin)); 60 | if (setting == null) 61 | { 62 | SettingValues.Add(new CachedSettingValue(valueBin, Profile)); 63 | } 64 | else 65 | { 66 | setting.ProfileNames.Append(", " + Profile); 67 | setting.ValueProfileCount++; 68 | } 69 | ProfileCount++; 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /nspector/Common/CustomSettings/CustomSetting.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Xml.Serialization; 4 | 5 | namespace nspector.Common.CustomSettings 6 | { 7 | [Serializable] 8 | public class CustomSetting 9 | { 10 | 11 | public string UserfriendlyName { get; set; } 12 | [XmlElement(ElementName = "HexSettingID")] 13 | public string HexSettingId { get; set; } 14 | public string Description { get; set; } 15 | public string GroupName { get; set; } 16 | public string OverrideDefault { get; set; } 17 | public float MinRequiredDriverVersion { get; set; } 18 | public bool Hidden { get; set; } 19 | public bool HasConstraints { get; set; } 20 | public string DataType { get; set; } 21 | 22 | public List SettingValues { get; set; } 23 | 24 | internal uint SettingId 25 | { 26 | get { return Convert.ToUInt32(HexSettingId.Trim(), 16); } 27 | } 28 | 29 | internal uint? DefaultValue 30 | { 31 | get { return string.IsNullOrEmpty(OverrideDefault) ? null : (uint?)Convert.ToUInt32(OverrideDefault.Trim(), 16); } 32 | } 33 | 34 | } 35 | } -------------------------------------------------------------------------------- /nspector/Common/CustomSettings/CustomSettingNames.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using nspector.Common.Helper; 5 | 6 | namespace nspector.Common.CustomSettings 7 | { 8 | [Serializable] 9 | public class CustomSettingNames 10 | { 11 | public List Settings = new List(); 12 | 13 | public void StoreToFile(string filename) 14 | { 15 | XMLHelper.SerializeToXmlFile(this, filename, Encoding.Unicode, true); 16 | } 17 | 18 | public static CustomSettingNames FactoryLoadFromFile(string filename) 19 | { 20 | return XMLHelper.DeserializeFromXMLFile(filename); 21 | } 22 | 23 | public static CustomSettingNames FactoryLoadFromString(string xml) 24 | { 25 | return XMLHelper.DeserializeFromXmlString(xml); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /nspector/Common/CustomSettings/CustomSettingValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace nspector.Common.CustomSettings 4 | { 5 | [Serializable] 6 | public class CustomSettingValue 7 | { 8 | internal uint SettingValue 9 | { 10 | get { return Convert.ToUInt32(HexValue.Trim(), 16); } 11 | } 12 | 13 | public string UserfriendlyName { get; set; } 14 | 15 | public string HexValue { get; set; } 16 | 17 | } 18 | } -------------------------------------------------------------------------------- /nspector/Common/DrsDecrypterService.cs: -------------------------------------------------------------------------------- 1 | using nspector.Common.Helper; 2 | using nspector.Native.NVAPI2; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Text; 7 | using System.Text.RegularExpressions; 8 | 9 | namespace nspector.Common 10 | { 11 | internal class DrsDecrypterService : DrsSettingsServiceBase 12 | { 13 | 14 | private static readonly byte[] _InternalSettingsKey = new byte[] { 15 | 0x2f, 0x7c, 0x4f, 0x8b, 0x20, 0x24, 0x52, 0x8d, 0x26, 0x3c, 0x94, 0x77, 0xf3, 0x7c, 0x98, 0xa5, 16 | 0xfa, 0x71, 0xb6, 0x80, 0xdd, 0x35, 0x84, 0xba, 0xfd, 0xb6, 0xa6, 0x1b, 0x39, 0xc4, 0xcc, 0xb0, 17 | 0x7e, 0x95, 0xd9, 0xee, 0x18, 0x4b, 0x9c, 0xf5, 0x2d, 0x4e, 0xd0, 0xc1, 0x55, 0x17, 0xdf, 0x18, 18 | 0x1e, 0x0b, 0x18, 0x8b, 0x88, 0x58, 0x86, 0x5a, 0x1e, 0x03, 0xed, 0x56, 0xfb, 0x16, 0xfe, 0x8a, 19 | 0x01, 0x32, 0x9c, 0x8d, 0xf2, 0xe8, 0x4a, 0xe6, 0x90, 0x8e, 0x15, 0x68, 0xe8, 0x2d, 0xf4, 0x40, 20 | 0x37, 0x9a, 0x72, 0xc7, 0x02, 0x0c, 0xd1, 0xd3, 0x58, 0xea, 0x62, 0xd1, 0x98, 0x36, 0x2b, 0xb2, 21 | 0x16, 0xd5, 0xde, 0x93, 0xf1, 0xba, 0x74, 0xe3, 0x32, 0xc4, 0x9f, 0xf6, 0x12, 0xfe, 0x18, 0xc0, 22 | 0xbb, 0x35, 0x79, 0x9c, 0x6b, 0x7a, 0x23, 0x7f, 0x2b, 0x15, 0x9b, 0x42, 0x07, 0x1a, 0xff, 0x69, 23 | 0xfb, 0x9c, 0xbd, 0x23, 0x97, 0xa8, 0x22, 0x63, 0x8f, 0x32, 0xc8, 0xe9, 0x9b, 0x63, 0x1c, 0xee, 24 | 0x2c, 0xd9, 0xed, 0x8d, 0x3a, 0x35, 0x9c, 0xb1, 0x60, 0xae, 0x5e, 0xf5, 0x97, 0x6b, 0x9f, 0x20, 25 | 0x8c, 0xf7, 0x98, 0x2c, 0x43, 0x79, 0x95, 0x1d, 0xcd, 0x46, 0x36, 0x6c, 0xd9, 0x67, 0x20, 0xab, 26 | 0x41, 0x22, 0x21, 0xe5, 0x55, 0x82, 0xf5, 0x27, 0x20, 0xf5, 0x08, 0x07, 0x3f, 0x6d, 0x69, 0xd9, 27 | 0x1c, 0x4b, 0xf8, 0x26, 0x03, 0x6e, 0xb2, 0x3f, 0x1e, 0xe6, 0xca, 0x3d, 0x61, 0x44, 0xb0, 0x92, 28 | 0xaf, 0xf0, 0x88, 0xca, 0xe0, 0x5f, 0x5d, 0xf4, 0xdf, 0xc6, 0x4c, 0xa4, 0xe0, 0xca, 0xb0, 0x20, 29 | 0x5d, 0xc0, 0xfa, 0xdd, 0x9a, 0x34, 0x8f, 0x50, 0x79, 0x5a, 0x5f, 0x7c, 0x19, 0x9e, 0x40, 0x70, 30 | 0x71, 0xb5, 0x45, 0x19, 0xb8, 0x53, 0xfc, 0xdf, 0x24, 0xbe, 0x22, 0x1c, 0x79, 0xbf, 0x42, 0x89 }; 31 | 32 | public DrsDecrypterService(DrsSettingsMetaService metaService) : base(metaService) 33 | { 34 | try 35 | { 36 | CreateInternalSettingMap(); 37 | } 38 | catch { } 39 | } 40 | 41 | private uint GetDwordFromKey(uint offset) 42 | { 43 | var bytes = new byte[4]; 44 | bytes[0] = _InternalSettingsKey[(offset + 0) % 256]; 45 | bytes[1] = _InternalSettingsKey[(offset + 1) % 256]; 46 | bytes[2] = _InternalSettingsKey[(offset + 2) % 256]; 47 | bytes[3] = _InternalSettingsKey[(offset + 3) % 256]; 48 | return BitConverter.ToUInt32(bytes, 0); 49 | } 50 | 51 | public uint DecryptDwordValue(uint orgValue, uint settingId) 52 | { 53 | var keyOffset = (settingId << 1); 54 | var key = GetDwordFromKey(keyOffset); 55 | return orgValue ^ key; 56 | } 57 | 58 | public string DecryptStringValue(byte[] rawData, uint settingId) 59 | { 60 | var keyOffset = (settingId << 1); 61 | for (uint i = 0; i < (uint)rawData.Length; i++) 62 | { 63 | rawData[i] ^= _InternalSettingsKey[(keyOffset + i) % 256]; 64 | } 65 | return Encoding.Unicode.GetString(rawData).Trim('\0'); 66 | } 67 | 68 | public void DecryptSettingIfNeeded(string profileName, ref NVDRS_SETTING setting) 69 | { 70 | if (setting.isPredefinedValid == 1) 71 | { 72 | if (IsInternalSetting(profileName, setting.settingId)) 73 | { 74 | if (setting.settingType == NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE) 75 | { 76 | setting.predefinedValue.stringValue = DecryptStringValue(setting.predefinedValue.rawData, setting.settingId); 77 | if (setting.isCurrentPredefined == 1) 78 | setting.currentValue.stringValue = DecryptStringValue(setting.currentValue.rawData, setting.settingId); 79 | } 80 | else if (setting.settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE) 81 | { 82 | setting.predefinedValue.dwordValue = DecryptDwordValue(setting.predefinedValue.dwordValue, setting.settingId); 83 | if (setting.isCurrentPredefined == 1) 84 | setting.currentValue.dwordValue = DecryptDwordValue(setting.currentValue.dwordValue, setting.settingId); 85 | } 86 | } 87 | } 88 | } 89 | 90 | private string FormatInternalSettingKey(string profileName, uint settingId) 91 | { 92 | return profileName + settingId.ToString("X8").ToLowerInvariant(); 93 | } 94 | 95 | public bool IsInternalSetting(string profileName, uint settingId) 96 | { 97 | return _InternalSettings.Contains(FormatInternalSettingKey(profileName, settingId)); 98 | } 99 | 100 | private HashSet _InternalSettings = new HashSet(); 101 | 102 | private void CreateInternalSettingMap() 103 | { 104 | string tmpfile = TempFile.GetTempFileName(); 105 | 106 | try 107 | { 108 | DrsSession((hSession) => 109 | { 110 | SaveSettingsFileEx(hSession, tmpfile); 111 | }); 112 | 113 | if (File.Exists(tmpfile)) 114 | { 115 | var lines = File.ReadAllLines(tmpfile); 116 | 117 | _InternalSettings = new HashSet(); 118 | 119 | var paProfile = "Profile\\s\\\"(?.*?)\\\""; 120 | var rxProfile = new Regex(paProfile, RegexOptions.Compiled); 121 | 122 | var paSetting = "ID_0x(?[0-9a-fA-F]+)\\s\\=.*?InternalSettingFlag\\=V0"; 123 | var rxSetting = new Regex(paSetting, RegexOptions.Compiled); 124 | 125 | var currentProfileName = ""; 126 | for (int i = 0; i < lines.Length; i++) 127 | { 128 | foreach (Match ms in rxProfile.Matches(lines[i])) 129 | { 130 | currentProfileName = ms.Result("${profileName}"); 131 | } 132 | foreach (Match ms in rxSetting.Matches(lines[i])) 133 | { 134 | _InternalSettings.Add(currentProfileName + ms.Result("${sid}")); 135 | } 136 | } 137 | } 138 | } 139 | finally 140 | { 141 | if (File.Exists(tmpfile)) 142 | File.Delete(tmpfile); 143 | } 144 | } 145 | } 146 | } -------------------------------------------------------------------------------- /nspector/Common/DrsImportService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using nspector.Common.Import; 6 | using nspector.Native.NVAPI2; 7 | using nvw = nspector.Native.NVAPI2.NvapiDrsWrapper; 8 | using nspector.Common.Helper; 9 | 10 | namespace nspector.Common 11 | { 12 | internal class DrsImportService : DrsSettingsServiceBase 13 | { 14 | 15 | private readonly DrsSettingsService _SettingService; 16 | private readonly DrsScannerService _ScannerService; 17 | private readonly DrsDecrypterService _DecrypterService; 18 | 19 | public DrsImportService( 20 | DrsSettingsMetaService metaService, 21 | DrsSettingsService settingService, 22 | DrsScannerService scannerService, 23 | DrsDecrypterService decrypterService) 24 | : base(metaService) 25 | { 26 | _SettingService = settingService; 27 | _ScannerService = scannerService; 28 | _DecrypterService = decrypterService; 29 | } 30 | 31 | internal void ExportAllProfilesToNvidiaTextFile(string filename) 32 | { 33 | DrsSession((hSession) => 34 | { 35 | SaveSettingsFileEx(hSession, filename); 36 | }); 37 | } 38 | 39 | internal void ImportAllProfilesFromNvidiaTextFile(string filename) 40 | { 41 | DrsSession((hSession) => 42 | { 43 | LoadSettingsFileEx(hSession, filename); 44 | SaveSettings(hSession); 45 | }, forceNonGlobalSession: true, preventLoadSettings: true); 46 | } 47 | 48 | internal void ExportProfiles(List profileNames, string filename, bool includePredefined) 49 | { 50 | var exports = new Profiles(); 51 | 52 | DrsSession((hSession) => 53 | { 54 | foreach (var profileName in profileNames) 55 | { 56 | var profile = CreateProfileForExport(hSession, profileName, includePredefined); 57 | exports.Add(profile); 58 | } 59 | }); 60 | 61 | XMLHelper.SerializeToXmlFile(exports, filename, Encoding.Unicode, true); 62 | } 63 | 64 | private Profile CreateProfileForExport(IntPtr hSession, string profileName, bool includePredefined) 65 | { 66 | var result = new Profile(); 67 | 68 | var hProfile = GetProfileHandle(hSession, profileName); 69 | if (hProfile != IntPtr.Zero) 70 | { 71 | 72 | result.ProfileName = profileName; 73 | 74 | var apps = GetProfileApplications(hSession, hProfile); 75 | foreach (var app in apps) 76 | { 77 | result.Executeables.Add(app.appName); 78 | } 79 | 80 | var settings = GetProfileSettings(hSession, hProfile); 81 | foreach (var setting in settings) 82 | { 83 | var isPredefined = setting.isCurrentPredefined == 1; 84 | var isCurrentProfile = setting.settingLocation == 85 | NVDRS_SETTING_LOCATION.NVDRS_CURRENT_PROFILE_LOCATION; 86 | 87 | if (isCurrentProfile && (!isPredefined || includePredefined)) 88 | { 89 | var exportSetting = setting; 90 | _DecrypterService.DecryptSettingIfNeeded(profileName, ref exportSetting); 91 | 92 | var profileSetting = ImportExportUitl 93 | .ConvertDrsSettingToProfileSetting(exportSetting); 94 | 95 | result.Settings.Add(profileSetting); 96 | } 97 | } 98 | 99 | } 100 | 101 | return result; 102 | } 103 | 104 | internal string ImportProfiles(string filename) 105 | { 106 | var sbFailedProfilesMessage = new StringBuilder(); 107 | var appInUseHint = false; 108 | var profiles = XMLHelper.DeserializeFromXMLFile(filename); 109 | 110 | DrsSession((hSession) => 111 | { 112 | foreach (Profile profile in profiles) 113 | { 114 | var profileCreated = false; 115 | var hProfile = GetProfileHandle(hSession, profile.ProfileName); 116 | if (hProfile == IntPtr.Zero) 117 | { 118 | hProfile = CreateProfile(hSession, profile.ProfileName); 119 | nvw.DRS_SaveSettings(hSession); 120 | profileCreated = true; 121 | } 122 | 123 | if (hProfile != IntPtr.Zero) 124 | { 125 | var modified = false; 126 | _SettingService.ResetProfile(profile.ProfileName, out modified); 127 | try 128 | { 129 | UpdateApplications(hSession, hProfile, profile); 130 | UpdateSettings(hSession, hProfile, profile, profile.ProfileName); 131 | } 132 | catch (NvapiException nex) 133 | { 134 | if (profileCreated) 135 | { 136 | nvw.DRS_DeleteProfile(hSession, hProfile); 137 | } 138 | 139 | sbFailedProfilesMessage.AppendLine(string.Format("Failed to import profile '{0}'", profile.ProfileName)); 140 | var appEx = nex as NvapiAddApplicationException; 141 | if (appEx != null) 142 | { 143 | var profilesWithThisApp = _ScannerService.FindProfilesUsingApplication(appEx.ApplicationName); 144 | sbFailedProfilesMessage.AppendLine(string.Format("- application '{0}' is already in use by profile '{1}'", appEx.ApplicationName, profilesWithThisApp)); 145 | appInUseHint = true; 146 | } 147 | else 148 | { 149 | sbFailedProfilesMessage.AppendLine(string.Format("- {0}", nex.Message)); 150 | } 151 | sbFailedProfilesMessage.AppendLine(""); 152 | } 153 | nvw.DRS_SaveSettings(hSession); 154 | } 155 | } 156 | }); 157 | 158 | if (appInUseHint) 159 | { 160 | sbFailedProfilesMessage.AppendLine("Hint: If just the profile name has been changed by nvidia, consider to manually modify the profile name inside the import file using a text editor."); 161 | } 162 | 163 | return sbFailedProfilesMessage.ToString(); 164 | } 165 | 166 | private bool ExistsImportApp(string appName, Profile importProfile) 167 | { 168 | return importProfile.Executeables.Any(x => x.Equals(appName)); 169 | } 170 | 171 | private void UpdateApplications(IntPtr hSession, IntPtr hProfile, Profile importProfile) 172 | { 173 | var alreadySet = new HashSet(); 174 | 175 | var apps = GetProfileApplications(hSession, hProfile); 176 | foreach (var app in apps) 177 | { 178 | if (ExistsImportApp(app.appName, importProfile) && !alreadySet.Contains(app.appName)) 179 | alreadySet.Add(app.appName); 180 | else 181 | nvw.DRS_DeleteApplication(hSession, hProfile, new StringBuilder(app.appName)); 182 | } 183 | 184 | foreach (string appName in importProfile.Executeables) 185 | { 186 | if (!alreadySet.Contains(appName)) 187 | { 188 | try 189 | { 190 | AddApplication(hSession, hProfile, appName); 191 | } 192 | catch (NvapiException) 193 | { 194 | throw new NvapiAddApplicationException(appName); 195 | } 196 | } 197 | } 198 | } 199 | 200 | private uint GetImportValue(uint settingId, Profile importProfile) 201 | { 202 | var setting = importProfile.Settings 203 | .FirstOrDefault(x => x.SettingId.Equals(settingId)); 204 | 205 | if (setting != null) 206 | return uint.Parse(setting.SettingValue); 207 | 208 | return 0; 209 | } 210 | 211 | private ProfileSetting GetImportProfileSetting(uint settingId, Profile importProfile) 212 | { 213 | return importProfile.Settings 214 | .FirstOrDefault(x => x.SettingId.Equals(settingId)); 215 | } 216 | 217 | private bool ExistsImportValue(uint settingId, Profile importProfile) 218 | { 219 | return importProfile.Settings 220 | .Any(x => x.SettingId.Equals(settingId)); 221 | } 222 | 223 | private void UpdateSettings(IntPtr hSession, IntPtr hProfile, Profile importProfile, string profileName) 224 | { 225 | var alreadySet = new HashSet(); 226 | 227 | var settings = GetProfileSettings(hSession, hProfile); 228 | foreach (var setting in settings) 229 | { 230 | var isCurrentProfile = setting.settingLocation == NVDRS_SETTING_LOCATION.NVDRS_CURRENT_PROFILE_LOCATION; 231 | var isPredefined = setting.isCurrentPredefined == 1; 232 | 233 | if (isCurrentProfile) 234 | { 235 | bool exitsValueInImport = ExistsImportValue(setting.settingId, importProfile); 236 | var importSetting = GetImportProfileSetting(setting.settingId, importProfile); 237 | 238 | var decryptedSetting = setting; 239 | _DecrypterService.DecryptSettingIfNeeded(profileName, ref decryptedSetting); 240 | 241 | if (isPredefined && exitsValueInImport && ImportExportUitl.AreDrsSettingEqualToProfileSetting(decryptedSetting, importSetting)) 242 | { 243 | alreadySet.Add(setting.settingId); 244 | } 245 | else if (exitsValueInImport) 246 | { 247 | var updatedSetting = ImportExportUitl.ConvertProfileSettingToDrsSetting(importSetting); 248 | StoreSetting(hSession, hProfile, updatedSetting); 249 | alreadySet.Add(setting.settingId); 250 | } 251 | else if (!isPredefined) 252 | { 253 | nvw.DRS_DeleteProfileSetting(hSession, hProfile, setting.settingId); 254 | } 255 | } 256 | } 257 | 258 | foreach (var setting in importProfile.Settings) 259 | { 260 | if (!alreadySet.Contains(setting.SettingId)) 261 | { 262 | var newSetting = ImportExportUitl.ConvertProfileSettingToDrsSetting(setting); 263 | try 264 | { 265 | StoreSetting(hSession, hProfile, newSetting); 266 | } 267 | catch (NvapiException ex) 268 | { 269 | if (ex.Status != NvAPI_Status.NVAPI_SETTING_NOT_FOUND) 270 | throw; 271 | } 272 | } 273 | } 274 | } 275 | 276 | } 277 | } 278 | -------------------------------------------------------------------------------- /nspector/Common/DrsScannerService.cs: -------------------------------------------------------------------------------- 1 | using nspector.Common.Helper; 2 | using nspector.Native.NVAPI2; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text.RegularExpressions; 8 | using System.Threading; 9 | using System.Threading.Tasks; 10 | using nvw = nspector.Native.NVAPI2.NvapiDrsWrapper; 11 | 12 | namespace nspector.Common 13 | { 14 | 15 | 16 | internal class DrsScannerService : DrsSettingsServiceBase 17 | { 18 | 19 | public DrsScannerService(DrsSettingsMetaService metaService, DrsDecrypterService decrpterService) 20 | : base(metaService, decrpterService) 21 | { } 22 | 23 | 24 | internal List CachedSettings = new List(); 25 | internal List ModifiedProfiles = new List(); 26 | internal HashSet UserProfiles = new HashSet(); 27 | 28 | // most common setting ids as start pattern for the heuristic scan 29 | private readonly uint[] _commonSettingIds = new uint[] { 0x1095DEF8, 0x1033DCD2, 0x1033CEC1, 30 | 0x10930F46, 0x00A06946, 0x10ECDB82, 0x20EBD7B8, 0x0095DEF9, 0x00D55F7D, 31 | 0x1033DCD3, 0x1033CEC2, 0x2072F036, 0x00664339, 0x002C7F45, 0x209746C1, 32 | 0x0076E164, 0x20FF7493, 0x204CFF7B }; 33 | 34 | 35 | private bool CheckCommonSetting(IntPtr hSession, IntPtr hProfile, NVDRS_PROFILE profile, 36 | ref int checkedSettingsCount, uint checkSettingId, bool addToScanResult, 37 | ref List alreadyCheckedSettingIds) 38 | { 39 | 40 | if (checkedSettingsCount >= profile.numOfSettings) 41 | return false; 42 | 43 | var setting = new NVDRS_SETTING(); 44 | setting.version = nvw.NVDRS_SETTING_VER; 45 | 46 | if (nvw.DRS_GetSetting(hSession, hProfile, checkSettingId, ref setting) != NvAPI_Status.NVAPI_OK) 47 | return false; 48 | 49 | if (setting.settingLocation != NVDRS_SETTING_LOCATION.NVDRS_CURRENT_PROFILE_LOCATION) 50 | return false; 51 | 52 | if (!addToScanResult && setting.isCurrentPredefined == 1) 53 | { 54 | checkedSettingsCount++; 55 | } 56 | else if (addToScanResult) 57 | { 58 | if (decrypter != null) 59 | { 60 | decrypter.DecryptSettingIfNeeded(profile.profileName, ref setting); 61 | } 62 | 63 | checkedSettingsCount++; 64 | AddScannedSettingToCache(profile, setting); 65 | alreadyCheckedSettingIds.Add(setting.settingId); 66 | return (setting.isCurrentPredefined != 1); 67 | } 68 | else if (setting.isCurrentPredefined != 1) 69 | { 70 | return true; 71 | } 72 | 73 | return false; 74 | } 75 | 76 | 77 | private int CalcPercent(int current, int max) 78 | { 79 | return (current > 0) ? (int)Math.Round((current * 100f) / max) : 0; ; 80 | } 81 | 82 | public async Task ScanProfileSettingsAsync(bool justModified, IProgress progress, CancellationToken token = default(CancellationToken)) 83 | { 84 | await Task.Run(() => 85 | { 86 | ModifiedProfiles = new List(); 87 | UserProfiles = new HashSet(); 88 | var knownPredefines = new List(_commonSettingIds); 89 | 90 | DrsSession((hSession) => 91 | { 92 | IntPtr hBaseProfile = GetProfileHandle(hSession, ""); 93 | var profileHandles = EnumProfileHandles(hSession); 94 | 95 | var maxProfileCount = profileHandles.Count; 96 | int curProfilePos = 0; 97 | 98 | foreach (IntPtr hProfile in profileHandles) 99 | { 100 | if (token.IsCancellationRequested) break; 101 | 102 | progress?.Report(CalcPercent(curProfilePos++, maxProfileCount)); 103 | 104 | var profile = GetProfileInfo(hSession, hProfile); 105 | 106 | int checkedSettingsCount = 0; 107 | var alreadyChecked = new List(); 108 | 109 | bool foundModifiedProfile = false; 110 | if (profile.isPredefined == 0) 111 | { 112 | ModifiedProfiles.Add(profile.profileName); 113 | UserProfiles.Add(profile.profileName); 114 | foundModifiedProfile = true; 115 | if (justModified) continue; 116 | } 117 | 118 | 119 | foreach (uint kpd in knownPredefines) 120 | { 121 | if (CheckCommonSetting(hSession, hProfile, profile, 122 | ref checkedSettingsCount, kpd, !justModified, ref alreadyChecked)) 123 | { 124 | if (!foundModifiedProfile) 125 | { 126 | foundModifiedProfile = true; 127 | ModifiedProfiles.Add(profile.profileName); 128 | if (justModified) break; 129 | } 130 | } 131 | } 132 | 133 | if ((foundModifiedProfile && justModified) || checkedSettingsCount >= profile.numOfSettings) 134 | continue; 135 | 136 | var settings = GetProfileSettings(hSession, hProfile); 137 | foreach (var setting in settings) 138 | { 139 | if (knownPredefines.IndexOf(setting.settingId) < 0) 140 | knownPredefines.Add(setting.settingId); 141 | 142 | if (!justModified && alreadyChecked.IndexOf(setting.settingId) < 0) 143 | AddScannedSettingToCache(profile, setting); 144 | 145 | if (setting.isCurrentPredefined != 1) 146 | { 147 | if (!foundModifiedProfile) 148 | { 149 | foundModifiedProfile = true; 150 | ModifiedProfiles.Add(profile.profileName); 151 | if (justModified) break; 152 | } 153 | } 154 | } 155 | } 156 | }); 157 | 158 | }); 159 | } 160 | 161 | 162 | private void AddScannedSettingToCache(NVDRS_PROFILE profile, NVDRS_SETTING setting) 163 | { 164 | // 3D Vision is dead so dont bother scanning those values for improved scan performance 165 | bool allowAddValue = !((setting.settingId & 0x70000000) == 0x70000000); 166 | //bool allowAddValue = true; 167 | 168 | var cachedSetting = CachedSettings 169 | .FirstOrDefault(x => x.SettingId.Equals(setting.settingId)); 170 | 171 | bool cacheEntryExists = true; 172 | if (cachedSetting == null) 173 | { 174 | cacheEntryExists = false; 175 | cachedSetting = new CachedSettings(setting.settingId, setting.settingType); 176 | } 177 | 178 | if (setting.isPredefinedValid == 1) 179 | { 180 | if (allowAddValue) 181 | { 182 | if (setting.settingType == NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE) 183 | cachedSetting.AddStringValue(setting.predefinedValue.stringValue, profile.profileName); 184 | else if (setting.settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE) 185 | cachedSetting.AddDwordValue(setting.predefinedValue.dwordValue, profile.profileName); 186 | else if (setting.settingType == NVDRS_SETTING_TYPE.NVDRS_BINARY_TYPE) 187 | cachedSetting.AddBinaryValue(setting.predefinedValue.binaryValue, profile.profileName); 188 | 189 | } 190 | else 191 | cachedSetting.ProfileCount++; 192 | 193 | if (!cacheEntryExists) 194 | CachedSettings.Add(cachedSetting); 195 | } 196 | 197 | } 198 | 199 | public string FindProfilesUsingApplication(string applicationName) 200 | { 201 | string lowerApplicationName = applicationName.ToLowerInvariant(); 202 | string tmpfile = TempFile.GetTempFileName(); 203 | 204 | try 205 | { 206 | var matchingProfiles = new List(); 207 | 208 | DrsSession((hSession) => 209 | { 210 | SaveSettingsFileEx(hSession, tmpfile); 211 | }); 212 | 213 | if (File.Exists(tmpfile)) 214 | { 215 | string content = File.ReadAllText(tmpfile); 216 | string pattern = "\\sProfile\\s\\\"(?.*?)\\\"(?.*?Executable.*?)EndProfile"; 217 | foreach (Match m in Regex.Matches(content, pattern, RegexOptions.Singleline)) 218 | { 219 | string scope = m.Result("${scope}"); 220 | foreach (Match ms in Regex.Matches(scope, "Executable\\s\\\"(?.*?)\\\"", RegexOptions.Singleline)) 221 | { 222 | if (ms.Result("${app}").ToLowerInvariant() == lowerApplicationName) 223 | { 224 | matchingProfiles.Add(m.Result("${profile}")); 225 | } 226 | } 227 | } 228 | } 229 | 230 | return string.Join(";", matchingProfiles); 231 | } 232 | finally 233 | { 234 | if (File.Exists(tmpfile)) 235 | File.Delete(tmpfile); 236 | } 237 | } 238 | 239 | } 240 | } 241 | -------------------------------------------------------------------------------- /nspector/Common/DrsServiceLocator.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Reflection; 3 | using nspector.Common.CustomSettings; 4 | 5 | namespace nspector.Common 6 | { 7 | internal class DrsServiceLocator 8 | { 9 | private static readonly CustomSettingNames CustomSettings; 10 | public static readonly CustomSettingNames ReferenceSettings; 11 | public static readonly DrsSettingsMetaService MetaService; 12 | public static readonly DrsSettingsService SettingService; 13 | public static readonly DrsImportService ImportService; 14 | public static readonly DrsScannerService ScannerService; 15 | public static readonly DrsDecrypterService DecrypterService; 16 | 17 | public static bool IsExternalCustomSettings { get; private set; } = false; 18 | 19 | static DrsServiceLocator() 20 | { 21 | CustomSettings = LoadCustomSettings(); 22 | ReferenceSettings = LoadReferenceSettings(); 23 | 24 | MetaService = new DrsSettingsMetaService(CustomSettings, ReferenceSettings); 25 | DecrypterService = new DrsDecrypterService(MetaService); 26 | ScannerService = new DrsScannerService(MetaService, DecrypterService); 27 | SettingService = new DrsSettingsService(MetaService, DecrypterService); 28 | ImportService = new DrsImportService(MetaService, SettingService, ScannerService, DecrypterService); 29 | } 30 | 31 | private static CustomSettingNames LoadCustomSettings() 32 | { 33 | string csnDefaultPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\CustomSettingNames.xml"; 34 | 35 | if (File.Exists(csnDefaultPath)) 36 | { 37 | try 38 | { 39 | var externalSettings = CustomSettingNames.FactoryLoadFromFile(csnDefaultPath); 40 | IsExternalCustomSettings = true; 41 | return externalSettings; 42 | } 43 | catch 44 | { 45 | return CustomSettingNames.FactoryLoadFromString(Properties.Resources.CustomSettingNames); 46 | } 47 | } 48 | else 49 | return CustomSettingNames.FactoryLoadFromString(Properties.Resources.CustomSettingNames); 50 | } 51 | 52 | private static CustomSettingNames LoadReferenceSettings() 53 | { 54 | string csnDefaultPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Reference.xml"; 55 | 56 | try 57 | { 58 | if (File.Exists(csnDefaultPath)) 59 | return CustomSettingNames.FactoryLoadFromFile(csnDefaultPath); 60 | } 61 | catch { } 62 | 63 | return null; 64 | } 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /nspector/Common/DrsSessionScope.cs: -------------------------------------------------------------------------------- 1 | using nspector.Native.NVAPI2; 2 | using System; 3 | using nvw = nspector.Native.NVAPI2.NvapiDrsWrapper; 4 | 5 | namespace nspector.Common 6 | { 7 | public class DrsSessionScope 8 | { 9 | 10 | public static volatile IntPtr GlobalSession; 11 | 12 | public static volatile bool HoldSession = true; 13 | 14 | private static object _Sync = new object(); 15 | 16 | 17 | public static T DrsSession(Func action, bool forceNonGlobalSession = false, bool preventLoadSettings = false) 18 | { 19 | lock (_Sync) 20 | { 21 | if (!HoldSession || forceNonGlobalSession) 22 | return NonGlobalDrsSession(action, preventLoadSettings); 23 | 24 | 25 | if (GlobalSession == IntPtr.Zero) 26 | { 27 | 28 | #pragma warning disable CS0420 29 | var csRes = nvw.DRS_CreateSession(ref GlobalSession); 30 | #pragma warning restore CS0420 31 | 32 | if (csRes != NvAPI_Status.NVAPI_OK) 33 | throw new NvapiException("DRS_CreateSession", csRes); 34 | 35 | if (!preventLoadSettings) 36 | { 37 | var nvRes = nvw.DRS_LoadSettings(GlobalSession); 38 | if (nvRes != NvAPI_Status.NVAPI_OK) 39 | throw new NvapiException("DRS_LoadSettings", nvRes); 40 | } 41 | } 42 | } 43 | 44 | if (GlobalSession != IntPtr.Zero) 45 | { 46 | return action(GlobalSession); 47 | } 48 | 49 | throw new Exception(nameof(GlobalSession) + " is Zero!"); 50 | } 51 | 52 | public static void DestroyGlobalSession() 53 | { 54 | lock (_Sync) 55 | { 56 | if (GlobalSession != IntPtr.Zero) 57 | { 58 | var csRes = nvw.DRS_DestroySession(GlobalSession); 59 | GlobalSession = IntPtr.Zero; 60 | } 61 | } 62 | } 63 | 64 | private static T NonGlobalDrsSession(Func action, bool preventLoadSettings = false) 65 | { 66 | IntPtr hSession = IntPtr.Zero; 67 | var csRes = nvw.DRS_CreateSession(ref hSession); 68 | if (csRes != NvAPI_Status.NVAPI_OK) 69 | throw new NvapiException("DRS_CreateSession", csRes); 70 | 71 | try 72 | { 73 | if (!preventLoadSettings) 74 | { 75 | var nvRes = nvw.DRS_LoadSettings(hSession); 76 | if (nvRes != NvAPI_Status.NVAPI_OK) 77 | throw new NvapiException("DRS_LoadSettings", nvRes); 78 | } 79 | 80 | return action(hSession); 81 | } 82 | finally 83 | { 84 | var nvRes = nvw.DRS_DestroySession(hSession); 85 | if (nvRes != NvAPI_Status.NVAPI_OK) 86 | throw new NvapiException("DRS_DestroySession", nvRes); 87 | } 88 | 89 | } 90 | 91 | 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /nspector/Common/DrsUtil.cs: -------------------------------------------------------------------------------- 1 | using nspector.Common.Meta; 2 | using System; 3 | using System.Globalization; 4 | using System.Linq; 5 | 6 | namespace nspector.Common 7 | { 8 | public static class DrsUtil 9 | { 10 | public static string StringValueRaw = "Text"; 11 | 12 | public static string GetDwordString(uint dword) 13 | { 14 | return string.Format("0x{0:X8}", dword); 15 | } 16 | 17 | public static uint ParseDwordByInputSafe(string input) 18 | { 19 | uint result = 0; 20 | if (input.ToLowerInvariant().StartsWith("0x")) 21 | { 22 | try 23 | { 24 | int blankPos = input.IndexOf(' '); 25 | int parseLen = blankPos > 2 ? blankPos - 2 : input.Length - 2; 26 | result = uint.Parse(input.Substring(2, parseLen), NumberStyles.AllowHexSpecifier); 27 | } 28 | catch { } 29 | } 30 | else 31 | try { result = uint.Parse(input); } 32 | catch { } 33 | 34 | return result; 35 | } 36 | 37 | internal static uint ParseDwordSettingValue(SettingMeta meta, string text) 38 | { 39 | var valueByName = meta.DwordValues.FirstOrDefault(x => x.ValueName != null && x.ValueName.Equals(text)); 40 | if (valueByName != null) 41 | return valueByName.Value; 42 | 43 | return ParseDwordByInputSafe(text); 44 | } 45 | 46 | internal static string GetDwordSettingValueName(SettingMeta meta, uint dwordValue) 47 | { 48 | var settingValue = meta.DwordValues 49 | .FirstOrDefault(x => x.Value.Equals(dwordValue)); 50 | 51 | return settingValue == null ? GetDwordString(dwordValue) : settingValue.ValueName; 52 | } 53 | 54 | internal static string ParseStringSettingValue(SettingMeta meta, string text) 55 | { 56 | var valueByName = meta.StringValues?.FirstOrDefault(x => x.ValueName != null && x.ValueName.Equals(text)); 57 | if (valueByName != null) 58 | return valueByName.Value; 59 | 60 | return text; 61 | } 62 | 63 | internal static string GetStringSettingValueName(SettingMeta meta, string stringValue) 64 | { 65 | var settingValue = meta.StringValues 66 | .FirstOrDefault(x => x.Value.Equals(stringValue)); 67 | 68 | return settingValue == null ? stringValue : settingValue.ValueName; 69 | } 70 | 71 | public static string GetBinaryString(byte[] binaryValue) 72 | { 73 | if (binaryValue == null) 74 | return ""; 75 | 76 | if (binaryValue.Length == 8) 77 | return string.Format("0x{0:X16}", BitConverter.ToUInt64(binaryValue, 0)); 78 | 79 | return BitConverter.ToString(binaryValue); 80 | } 81 | 82 | internal static string GetBinarySettingValueName(SettingMeta meta, byte[] binaryValue) 83 | { 84 | var settingValue = meta.BinaryValues? 85 | .FirstOrDefault(x => x.Value.Equals(binaryValue)); 86 | 87 | return settingValue == null ? GetBinaryString(binaryValue) : settingValue.ValueName; 88 | } 89 | 90 | internal static byte[] ParseBinarySettingValue(SettingMeta meta, string text) 91 | { 92 | var valueByName = meta.BinaryValues.FirstOrDefault(x => x.ValueName != null && x.ValueName.Equals(text)); 93 | if (valueByName != null) 94 | return valueByName.Value; 95 | 96 | return ParseBinaryByInputSafe(text); 97 | } 98 | 99 | public static byte[] ParseBinaryByInputSafe(string input) 100 | { 101 | if (string.IsNullOrWhiteSpace(input)) 102 | return null; 103 | 104 | if (input.StartsWith("0x")) 105 | { 106 | int blankPos = input.IndexOf(' '); 107 | int parseLen = blankPos > 2 ? blankPos - 2 : input.Length - 2; 108 | var qword = ulong.Parse(input.Substring(2, parseLen), NumberStyles.AllowHexSpecifier); 109 | return BitConverter.GetBytes(qword); 110 | } 111 | 112 | if (input.Contains("-")) 113 | return Array.ConvertAll(input.Split('-'), s => Convert.ToByte(s, 16)); 114 | 115 | return null; 116 | } 117 | 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /nspector/Common/Helper/AdminHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Principal; 2 | 3 | namespace nspector.Common.Helper 4 | { 5 | public static class AdminHelper 6 | { 7 | private static bool isAdmin = false; 8 | static AdminHelper() 9 | { 10 | var identity = WindowsIdentity.GetCurrent(); 11 | var principal = new WindowsPrincipal(identity); 12 | isAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator); 13 | } 14 | 15 | public static bool IsAdmin 16 | { 17 | get { return isAdmin; } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /nspector/Common/Helper/DropDownMenuScrollWheelHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace nspector.Common.Helper 5 | { 6 | 7 | //by Bryce Wagner https://stackoverflow.com/questions/13139074/mouse-wheel-scrolling-toolstrip-menu-items 8 | 9 | public class DropDownMenuScrollWheelHandler : IMessageFilter 10 | { 11 | private static DropDownMenuScrollWheelHandler Instance; 12 | public static void Enable(bool enabled) 13 | { 14 | if (enabled) 15 | { 16 | if (Instance == null) 17 | { 18 | Instance = new DropDownMenuScrollWheelHandler(); 19 | Application.AddMessageFilter(Instance); 20 | } 21 | } 22 | else 23 | { 24 | if (Instance != null) 25 | { 26 | Application.RemoveMessageFilter(Instance); 27 | Instance = null; 28 | } 29 | } 30 | } 31 | private IntPtr activeHwnd; 32 | private ToolStripDropDown activeMenu; 33 | 34 | public bool PreFilterMessage(ref Message m) 35 | { 36 | if (m.Msg == 0x200 && activeHwnd != m.HWnd) // WM_MOUSEMOVE 37 | { 38 | activeHwnd = m.HWnd; 39 | this.activeMenu = Control.FromHandle(m.HWnd) as ToolStripDropDown; 40 | } 41 | else if (m.Msg == 0x20A && this.activeMenu != null) // WM_MOUSEWHEEL 42 | { 43 | int delta = (short)(ushort)(((uint)(ulong)m.WParam) >> 16); 44 | HandleDelta(this.activeMenu, delta); 45 | return true; 46 | } 47 | return false; 48 | } 49 | 50 | private static readonly Action ScrollInternal 51 | = (Action)Delegate.CreateDelegate(typeof(Action), 52 | typeof(ToolStrip).GetMethod("ScrollInternal", 53 | System.Reflection.BindingFlags.NonPublic 54 | | System.Reflection.BindingFlags.Instance)); 55 | 56 | private void HandleDelta(ToolStripDropDown ts, int delta) 57 | { 58 | if (ts.Items.Count == 0) 59 | return; 60 | 61 | var firstItem = ts.Items[0]; 62 | var lastItem = ts.Items[ts.Items.Count - 1]; 63 | 64 | if (lastItem.Bounds.Bottom < ts.Height && firstItem.Bounds.Top > 0) 65 | return; 66 | 67 | delta = delta / -4; 68 | 69 | if (delta < 0 && firstItem.Bounds.Top - delta > 9) 70 | { 71 | delta = firstItem.Bounds.Top - 9; 72 | } 73 | else if (delta > 0 && delta > lastItem.Bounds.Bottom - ts.Height + 9) 74 | { 75 | delta = lastItem.Bounds.Bottom - ts.Height + 9; 76 | } 77 | 78 | if (delta != 0) 79 | ScrollInternal(ts, delta); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /nspector/Common/Helper/InputBox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.IO; 5 | using System.Text.RegularExpressions; 6 | using System.Windows.Forms; 7 | 8 | namespace nspector.Common.Helper 9 | { 10 | internal class InputBox 11 | { 12 | 13 | internal static DialogResult Show(string title, string promptText, ref string value, List invalidInputs, string mandatoryFormatRegExPattern, int maxLength, bool allowExeBrowse = false) 14 | { 15 | var form = new Form(); 16 | var label = new Label(); 17 | var textBox = new TextBox(); 18 | var buttonOk = new Button(); 19 | var buttonCancel = new Button(); 20 | var buttonBrowse = new Button(); 21 | var imageBox = new PictureBox(); 22 | 23 | EventHandler textchanged = delegate (object sender, EventArgs e) 24 | { 25 | bool mandatory_success = Regex.IsMatch(textBox.Text, mandatoryFormatRegExPattern); 26 | 27 | if (textBox.Text == "" || textBox.Text.Length > maxLength || !mandatory_success) 28 | { 29 | imageBox.Image = nspector.Properties.Resources.ieframe_1_18212; 30 | buttonOk.Enabled = false; 31 | return; 32 | } 33 | 34 | foreach (string invStr in invalidInputs) 35 | { 36 | if (textBox.Text.ToUpper() == invStr.ToUpper()) 37 | { 38 | imageBox.Image = Properties.Resources.ieframe_1_18212; 39 | buttonOk.Enabled = false; 40 | return; 41 | } 42 | } 43 | 44 | imageBox.Image = Properties.Resources.ieframe_1_31073_002; 45 | buttonOk.Enabled = true; 46 | }; 47 | 48 | EventHandler buttonBrowse_Click = delegate (object sender, EventArgs e) 49 | { 50 | var openDialog = new OpenFileDialog(); 51 | openDialog.DefaultExt = "*.exe"; 52 | openDialog.Filter = "Application EXE Name|*.exe|Application Absolute Path|*.exe"; 53 | 54 | if (openDialog.ShowDialog() == DialogResult.OK) 55 | { 56 | string applicationName = new FileInfo(openDialog.FileName).Name; 57 | if (openDialog.FilterIndex == 2) 58 | applicationName = openDialog.FileName; 59 | textBox.Text = applicationName; 60 | } 61 | }; 62 | 63 | textBox.TextChanged += textchanged; 64 | 65 | form.Text = title; 66 | label.Text = promptText; 67 | textBox.Text = value; 68 | textBox.MaxLength = maxLength; 69 | imageBox.Image = Properties.Resources.ieframe_1_18212; 70 | 71 | buttonOk.Text = "OK"; 72 | buttonCancel.Text = "Cancel"; 73 | buttonBrowse.Text = "Browse..."; 74 | buttonOk.DialogResult = DialogResult.OK; 75 | buttonCancel.DialogResult = DialogResult.Cancel; 76 | 77 | buttonOk.Enabled = false; 78 | 79 | label.SetBounds(Dpi(9), Dpi(20), Dpi(372), Dpi(13)); 80 | textBox.SetBounds(Dpi(12), Dpi(44), Dpi(352), Dpi(20)); 81 | buttonOk.SetBounds(Dpi(224), Dpi(72), Dpi(75), Dpi(23)); 82 | buttonCancel.SetBounds(Dpi(305), Dpi(72), Dpi(75), Dpi(23)); 83 | 84 | if (allowExeBrowse) 85 | { 86 | textBox.SetBounds(Dpi(12), Dpi(44), Dpi(286), Dpi(20)); 87 | buttonBrowse.SetBounds(Dpi(305), Dpi(39), Dpi(75), Dpi(23)); 88 | buttonBrowse.Click += buttonBrowse_Click; 89 | } 90 | 91 | imageBox.SetBounds(Dpi(368), Dpi(44), Dpi(16), Dpi(16)); 92 | 93 | label.AutoSize = true; 94 | label.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; 95 | imageBox.Anchor = AnchorStyles.Top | AnchorStyles.Right; 96 | textBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; 97 | buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; 98 | buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; 99 | buttonBrowse.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; 100 | 101 | form.ClientSize = new Size(Dpi(396), Dpi(107)); 102 | form.ClientSize = new Size(Math.Max(Dpi(300), label.Right + Dpi(10)), form.ClientSize.Height); 103 | form.MinimumSize = form.Size; 104 | form.MaximumSize = new Size(form.MinimumSize.Width * 2, form.MinimumSize.Height); 105 | 106 | form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel }); 107 | if (!allowExeBrowse) 108 | form.Controls.Add(imageBox); 109 | else 110 | form.Controls.Add(buttonBrowse); 111 | 112 | form.ShowIcon = false; 113 | form.FormBorderStyle = FormBorderStyle.Sizable; 114 | form.StartPosition = FormStartPosition.CenterParent; 115 | form.MinimizeBox = false; 116 | form.MaximizeBox = false; 117 | form.AcceptButton = buttonOk; 118 | form.CancelButton = buttonCancel; 119 | 120 | textchanged(form, new EventArgs()); 121 | 122 | DialogResult dialogResult = form.ShowDialog(); 123 | value = textBox.Text; 124 | return dialogResult; 125 | } 126 | 127 | private static int Dpi(int input) 128 | { 129 | return (int)Math.Round(input * frmDrvSettings.ScaleFactor); 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /nspector/Common/Helper/ListSort.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | 3 | namespace nspector.Common.Helper 4 | { 5 | internal class ListSort : IComparer 6 | { 7 | public int Compare(object x, object y) 8 | { 9 | try 10 | { 11 | return System.String.CompareOrdinal(x.ToString(), y.ToString()); 12 | } 13 | catch 14 | { 15 | return 0; 16 | } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /nspector/Common/Helper/ListViewGroupSorter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows.Forms; 3 | 4 | namespace nspector.Common.Helper 5 | { 6 | 7 | public class ListViewGroupHeaderSorter : IComparer 8 | { 9 | private bool _ascending = true; 10 | public ListViewGroupHeaderSorter(bool ascending) 11 | { 12 | _ascending = ascending; 13 | } 14 | 15 | #region IComparer Members 16 | 17 | public int Compare(ListViewGroup x, ListViewGroup y) 18 | { 19 | if (_ascending) 20 | return string.Compare(((ListViewGroup)x).Header, ((ListViewGroup)y).Header); 21 | else 22 | return string.Compare(((ListViewGroup)y).Header, ((ListViewGroup)x).Header); 23 | } 24 | #endregion 25 | } 26 | 27 | public class ListViewGroupSorter 28 | { 29 | internal ListView _listview; 30 | 31 | public static bool operator ==(ListView listview, ListViewGroupSorter sorter) 32 | { 33 | return listview == sorter._listview; 34 | } 35 | public static bool operator !=(ListView listview, ListViewGroupSorter sorter) 36 | { 37 | return listview != sorter._listview; 38 | } 39 | 40 | public static implicit operator ListView(ListViewGroupSorter sorter) 41 | { 42 | return sorter._listview; 43 | } 44 | public static implicit operator ListViewGroupSorter(ListView listview) 45 | { 46 | return new ListViewGroupSorter(listview); 47 | } 48 | 49 | internal ListViewGroupSorter(ListView listview) 50 | { 51 | _listview = listview; 52 | } 53 | 54 | public void SortGroups(bool ascending) 55 | { 56 | _listview.BeginUpdate(); 57 | List lvgs = new List(); 58 | foreach (ListViewGroup lvg in _listview.Groups) 59 | lvgs.Add(lvg); 60 | _listview.Groups.Clear(); 61 | lvgs.Sort(new ListViewGroupHeaderSorter(ascending)); 62 | _listview.Groups.AddRange(lvgs.ToArray()); 63 | _listview.EndUpdate(); 64 | } 65 | 66 | #region overridden methods 67 | 68 | public override bool Equals(object obj) 69 | { 70 | return _listview.Equals(obj); 71 | } 72 | 73 | public override int GetHashCode() 74 | { 75 | return _listview.GetHashCode(); 76 | } 77 | 78 | public override string ToString() 79 | { 80 | return _listview.ToString(); 81 | } 82 | 83 | #endregion 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /nspector/Common/Helper/NoBorderRenderer.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Forms; 2 | 3 | namespace nspector.Common.Helper 4 | { 5 | internal class NoBorderRenderer : ToolStripProfessionalRenderer 6 | { 7 | protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) {} 8 | 9 | protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) {} 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /nspector/Common/Helper/ShortcutResolver.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using nspector.Native.WINAPI; 3 | 4 | namespace nspector.Common.Helper 5 | { 6 | public class ShortcutResolver 7 | { 8 | 9 | public static string GetUrlFromInternetShortcut(string filePath) 10 | { 11 | var lines = File.ReadAllLines(filePath); 12 | foreach (var line in lines) 13 | { 14 | if (line.StartsWith("URL=")) 15 | { 16 | string[] splitLine = line.Split('='); 17 | if (splitLine.Length > 0) 18 | { 19 | return splitLine[1]; 20 | } 21 | } 22 | } 23 | return ""; 24 | } 25 | 26 | public static string ResolveExecuteable(string filename, out string profileName) 27 | { 28 | var fileInfo = new FileInfo(filename); 29 | profileName = fileInfo.Name.Substring(0, fileInfo.Name.Length - fileInfo.Extension.Length); 30 | 31 | try 32 | { 33 | switch (fileInfo.Extension.ToLowerInvariant()) 34 | { 35 | case ".lnk": return ResolveFromShellLinkFile(fileInfo.FullName); 36 | case ".url": return ResolveFromUrlFile(fileInfo.FullName); 37 | case ".exe": return fileInfo.Name; 38 | default: return ""; 39 | } 40 | } 41 | catch 42 | { 43 | return ""; 44 | } 45 | } 46 | 47 | private static string ResolveFromShellLinkFile(string filename) 48 | { 49 | var shellLink = new ShellLink(filename); 50 | if (shellLink.Arguments.StartsWith(SteamAppResolver.SteamUrlPattern)) 51 | { 52 | var resolver = new SteamAppResolver(); 53 | return resolver.ResolveExeFromSteamUrl(shellLink.Arguments); 54 | } 55 | 56 | var targetInfo = new FileInfo(shellLink.Target); 57 | if (targetInfo.Name.ToLowerInvariant() == SteamAppResolver.SteamExeName) 58 | { 59 | if (shellLink.Arguments.Contains(SteamAppResolver.SteamArgumentPattern)) 60 | { 61 | var resolver = new SteamAppResolver(); 62 | return resolver.ResolveExeFromSteamArguments(shellLink.Arguments); 63 | } 64 | } 65 | 66 | if (targetInfo.Extension.ToLowerInvariant().Equals(".exe")) 67 | { 68 | return targetInfo.Name; 69 | } 70 | return ""; 71 | } 72 | 73 | private static string ResolveFromUrlFile(string filename) 74 | { 75 | var url = GetUrlFromInternetShortcut(filename); 76 | if (url.StartsWith(SteamAppResolver.SteamUrlPattern)) 77 | { 78 | var resolver = new SteamAppResolver(); 79 | return resolver.ResolveExeFromSteamUrl(url); 80 | } 81 | return ""; 82 | } 83 | 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /nspector/Common/Helper/SteamAppResolver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Text; 5 | using System.Text.RegularExpressions; 6 | using Microsoft.Win32; 7 | 8 | namespace nspector.Common.Helper 9 | { 10 | public class SteamAppResolver 11 | { 12 | 13 | public const string SteamExeName = "steam.exe"; 14 | public const string SteamUrlPattern = "steam://rungameid/"; 15 | public const string SteamArgumentPattern = "-applaunch"; 16 | 17 | private byte[] _appinfoBytes; 18 | 19 | public SteamAppResolver() 20 | { 21 | var appInfoLocation = GetSteamAppInfoLocation(); 22 | if (File.Exists(appInfoLocation)) 23 | _appinfoBytes = File.ReadAllBytes(appInfoLocation); 24 | else 25 | _appinfoBytes = null; 26 | } 27 | 28 | private string GetSteamAppInfoLocation() 29 | { 30 | var reg = Registry.CurrentUser.OpenSubKey(@"Software\Valve\Steam", false); 31 | 32 | if (reg != null) 33 | { 34 | string steamPath = (string)reg.GetValue("SteamPath", null); 35 | if (steamPath != null) 36 | return Path.Combine(steamPath, @"appcache\appinfo.vdf"); 37 | } 38 | 39 | return ""; 40 | } 41 | 42 | public string ResolveExeFromSteamUrl(string url) 43 | { 44 | if (url.StartsWith(SteamUrlPattern)) 45 | { 46 | var appIdStr = url.Substring(SteamUrlPattern.Length); 47 | int appid = 0; 48 | if (int.TryParse(appIdStr, out appid)) 49 | { 50 | return FindCommonExecutableForApp(appid); 51 | } 52 | } 53 | return ""; 54 | } 55 | 56 | public string ResolveExeFromSteamArguments(string arguments) 57 | { 58 | if (arguments.Contains(SteamArgumentPattern)) 59 | { 60 | var rxRungame = new Regex(SteamArgumentPattern + @"\s+(?\d+)"); 61 | foreach (Match m in rxRungame.Matches(arguments)) 62 | { 63 | var appIdStr = m.Result("${appid}"); 64 | int appid = 0; 65 | if (int.TryParse(appIdStr, out appid)) 66 | { 67 | return FindCommonExecutableForApp(appid); 68 | } 69 | } 70 | 71 | } 72 | return ""; 73 | } 74 | 75 | private string FindCommonExecutableForApp(int appid) 76 | { 77 | var apps = FindAllExecutablesForApp(appid); 78 | if (apps.Count > 0) 79 | { 80 | return new FileInfo(apps[0]).Name; 81 | } 82 | return ""; 83 | } 84 | 85 | private List FindAllExecutablesForApp(int appid) 86 | { 87 | if (_appinfoBytes == null) 88 | return new List(); 89 | 90 | var bid = BitConverter.GetBytes(appid); 91 | int offset = 0; 92 | 93 | var appidPattern = new byte[] { 0x08, bid[0], bid[1], bid[2], bid[3] }; 94 | var launchPattern = new byte[] { 0x00, 0x6C, 0x61, 0x75, 0x6E, 0x63, 0x68, 0x00 }; 95 | 96 | var appidOffset = FindOffset(_appinfoBytes, appidPattern, offset); 97 | if (appidOffset == -1) 98 | return new List(); 99 | else 100 | offset = appidOffset + appidPattern.Length; 101 | 102 | var launchOffset = FindOffset(_appinfoBytes, launchPattern, offset); 103 | if (launchOffset == -1) 104 | return new List(); 105 | else 106 | offset = launchOffset; 107 | 108 | var executables = new List(); 109 | FindExecutables(_appinfoBytes, ref offset, ref executables); 110 | return executables; 111 | } 112 | 113 | 114 | private void FindExecutables(byte[] bytes, ref int offset, ref List executables) 115 | { 116 | while (true) 117 | { 118 | var valueType = ReadByte(bytes, ref offset); 119 | if (valueType == 0x08) 120 | { 121 | break; 122 | } 123 | 124 | var valueName = ReadCString(bytes, ref offset); 125 | var valueString = ""; 126 | switch (valueType) 127 | { 128 | case 0: 129 | { 130 | FindExecutables(bytes, ref offset, ref executables); 131 | break; 132 | } 133 | case 1: 134 | { 135 | valueString = ReadCString(bytes, ref offset); 136 | 137 | if (valueName == "executable" && valueString.EndsWith(".exe")) 138 | { 139 | executables.Add(valueString); 140 | } 141 | 142 | break; 143 | } 144 | case 2: 145 | { 146 | offset += 4; 147 | break; 148 | } 149 | 150 | case 7: 151 | { 152 | offset += 8; 153 | break; 154 | } 155 | default: break; 156 | } 157 | } 158 | } 159 | 160 | private static int FindOffset(byte[] bytes, byte[] pattern, int offset = 0, byte? wildcard = null) 161 | { 162 | for (int i = offset; i < bytes.Length; i++) 163 | { 164 | if (pattern[0] == bytes[i] && bytes.Length - i >= pattern.Length) 165 | { 166 | bool ismatch = true; 167 | for (int j = 1; j < pattern.Length && ismatch == true; j++) 168 | { 169 | if (bytes[i + j] != pattern[j] && ((wildcard.HasValue && wildcard != pattern[j]) || !wildcard.HasValue)) 170 | { 171 | ismatch = false; 172 | break; 173 | } 174 | } 175 | if (ismatch) 176 | return i; 177 | 178 | } 179 | } 180 | return -1; 181 | } 182 | 183 | private static byte ReadByte(byte[] bytes, ref int offset) 184 | { 185 | offset += 1; 186 | return bytes[offset - 1]; 187 | } 188 | 189 | private static string ReadCString(byte[] bytes, ref int offset) 190 | { 191 | var tmpOffset = offset; 192 | while (bytes[tmpOffset] != 0) 193 | { 194 | tmpOffset++; 195 | } 196 | 197 | var start = offset; 198 | var length = tmpOffset - offset; 199 | offset += length + 1; 200 | 201 | return Encoding.UTF8.GetString(bytes, start, length); 202 | 203 | } 204 | 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /nspector/Common/Helper/TempFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace nspector.Common.Helper 5 | { 6 | internal static class TempFile 7 | { 8 | public static string GetTempFileName() 9 | { 10 | while (true) 11 | { 12 | var tempFile = GenerateTempFileName(); 13 | if (!File.Exists(tempFile)) 14 | return tempFile; 15 | } 16 | } 17 | 18 | private static string GenerateTempFileName() 19 | { 20 | return Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString().Replace("-", "")); 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /nspector/Common/Helper/UserSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Text; 4 | using System.Windows.Forms; 5 | 6 | namespace nspector.Common.Helper 7 | { 8 | public class UserSettings 9 | { 10 | public int WindowTop { get; set; } 11 | 12 | public int WindowLeft { get; set; } 13 | 14 | public int WindowWidth { get; set; } 15 | 16 | public int WindowHeight { get; set; } 17 | 18 | public FormWindowState WindowState { get; set; } 19 | 20 | public bool ShowCustomizedSettingNamesOnly { get; set; } = false; 21 | 22 | public bool ShowScannedUnknownSettings { get; set; } = false; 23 | 24 | private static string GetSettingsFilename() 25 | { 26 | var fiPortalbleSettings = new FileInfo("settings.xml"); 27 | if (fiPortalbleSettings.Exists) return fiPortalbleSettings.FullName; 28 | 29 | var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Application.ProductName); 30 | if (!Directory.Exists(path)) Directory.CreateDirectory(path); 31 | return Path.Combine(path, "settings.xml"); ; 32 | } 33 | 34 | public void SaveSettings() 35 | { 36 | XMLHelper.SerializeToXmlFile(this, GetSettingsFilename(), Encoding.Unicode, true); 37 | } 38 | 39 | public static UserSettings LoadSettings() 40 | { 41 | var filename = GetSettingsFilename(); 42 | if (!File.Exists(filename)) return new UserSettings(); 43 | 44 | try 45 | { 46 | return XMLHelper.DeserializeFromXMLFile(GetSettingsFilename()); 47 | } 48 | catch 49 | { 50 | return new UserSettings(); 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /nspector/Common/Helper/XMLHelper.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text; 3 | using System.Xml; 4 | using System.Xml.Serialization; 5 | 6 | namespace nspector.Common.Helper 7 | { 8 | internal static class XMLHelper where T : new() 9 | { 10 | static XmlSerializer xmlSerializer; 11 | 12 | static XMLHelper() 13 | { 14 | xmlSerializer = new XmlSerializer(typeof(T)); 15 | } 16 | 17 | internal static string SerializeToXmlString(T xmlObject, Encoding encoding, bool removeNamespace) 18 | { 19 | var memoryStream = new MemoryStream(); 20 | var xmlWriter = new XmlTextWriter(memoryStream, encoding) { Formatting = Formatting.Indented }; 21 | 22 | if (removeNamespace) 23 | { 24 | var xs = new XmlSerializerNamespaces(); 25 | xs.Add("", ""); 26 | xmlSerializer.Serialize(xmlWriter, xmlObject, xs); 27 | } 28 | else 29 | xmlSerializer.Serialize(xmlWriter, xmlObject); 30 | 31 | return encoding.GetString(memoryStream.ToArray()); 32 | } 33 | 34 | internal static void SerializeToXmlFile(T xmlObject, string filename, Encoding encoding, bool removeNamespace) 35 | { 36 | File.WriteAllText(filename, SerializeToXmlString(xmlObject, encoding, removeNamespace)); 37 | } 38 | 39 | internal static T DeserializeFromXmlString(string xml) 40 | { 41 | var reader = new StringReader(xml); 42 | var xmlObject = (T)xmlSerializer.Deserialize(reader); 43 | return xmlObject; 44 | } 45 | 46 | internal static T DeserializeFromXMLFile(string filename) 47 | { 48 | return DeserializeFromXmlString(File.ReadAllText(filename)); 49 | } 50 | 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /nspector/Common/Import/ImportExportUitl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using nspector.Native.NVAPI2; 3 | 4 | namespace nspector.Common.Import 5 | { 6 | internal class ImportExportUitl 7 | { 8 | public static bool AreDrsSettingEqualToProfileSetting(NVDRS_SETTING drsSetting, ProfileSetting profileSetting) 9 | { 10 | var profileSettingCompare = ConvertDrsSettingToProfileSetting(drsSetting); 11 | return profileSetting.SettingValue.Equals(profileSettingCompare.SettingValue); 12 | } 13 | 14 | public static ProfileSetting ConvertDrsSettingToProfileSetting(NVDRS_SETTING setting) 15 | { 16 | return new ProfileSetting 17 | { 18 | SettingId = setting.settingId, 19 | SettingNameInfo = setting.settingName, 20 | SettingValue = ConvertSettingValueToString(setting), 21 | ValueType = MapValueType(setting.settingType), 22 | }; 23 | } 24 | 25 | private static string ConvertSettingValueToString(NVDRS_SETTING setting) 26 | { 27 | var settingUnion = setting.currentValue; 28 | if (setting.isCurrentPredefined == 1) 29 | { 30 | settingUnion = setting.predefinedValue; 31 | } 32 | 33 | switch (setting.settingType) 34 | { 35 | case NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE: 36 | return settingUnion.dwordValue.ToString(); 37 | case NVDRS_SETTING_TYPE.NVDRS_STRING_TYPE: 38 | return settingUnion.ansiStringValue; 39 | case NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE: 40 | return settingUnion.stringValue; 41 | case NVDRS_SETTING_TYPE.NVDRS_BINARY_TYPE: 42 | return Convert.ToBase64String(settingUnion.binaryValue); 43 | default: 44 | throw new Exception("invalid setting type"); 45 | } 46 | } 47 | 48 | private static SettingValueType MapValueType(NVDRS_SETTING_TYPE input) 49 | { 50 | switch (input) 51 | { 52 | case NVDRS_SETTING_TYPE.NVDRS_BINARY_TYPE: return SettingValueType.Binary; 53 | case NVDRS_SETTING_TYPE.NVDRS_STRING_TYPE: return SettingValueType.AnsiString; 54 | case NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE: return SettingValueType.String; 55 | default: return SettingValueType.Dword; 56 | } 57 | } 58 | 59 | public static NVDRS_SETTING ConvertProfileSettingToDrsSetting(ProfileSetting setting) 60 | { 61 | var newSetting = new NVDRS_SETTING() 62 | { 63 | version = NvapiDrsWrapper.NVDRS_SETTING_VER, 64 | settingId = setting.SettingId, 65 | settingType = MapValueType(setting.ValueType), 66 | settingLocation = NVDRS_SETTING_LOCATION.NVDRS_CURRENT_PROFILE_LOCATION, 67 | currentValue = ConvertStringToSettingUnion(setting.ValueType, setting.SettingValue), 68 | }; 69 | return newSetting; 70 | } 71 | 72 | private static NVDRS_SETTING_UNION ConvertStringToSettingUnion(SettingValueType valueType, string valueString) 73 | { 74 | var union = new NVDRS_SETTING_UNION(); 75 | switch (valueType) 76 | { 77 | case SettingValueType.Dword: 78 | union.dwordValue = uint.Parse(valueString); 79 | break; 80 | case SettingValueType.String: 81 | union.stringValue = valueString; 82 | break; 83 | case SettingValueType.AnsiString: 84 | union.ansiStringValue = valueString; 85 | break; 86 | case SettingValueType.Binary: 87 | union.binaryValue = Convert.FromBase64String(valueString); 88 | break; 89 | default: 90 | throw new Exception("invalid value type"); 91 | } 92 | return union; 93 | } 94 | 95 | private static NVDRS_SETTING_TYPE MapValueType(SettingValueType input) 96 | { 97 | switch (input) 98 | { 99 | case SettingValueType.Binary: return NVDRS_SETTING_TYPE.NVDRS_BINARY_TYPE; 100 | case SettingValueType.AnsiString: return NVDRS_SETTING_TYPE.NVDRS_STRING_TYPE; 101 | case SettingValueType.String: return NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE; 102 | default: return NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE; 103 | } 104 | } 105 | 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /nspector/Common/Import/Profile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace nspector.Common.Import 5 | { 6 | [Serializable] 7 | public class Profile 8 | { 9 | public string ProfileName = ""; 10 | public List Executeables = new List(); 11 | public List Settings = new List(); 12 | } 13 | } -------------------------------------------------------------------------------- /nspector/Common/Import/ProfileSetting.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml.Serialization; 3 | 4 | namespace nspector.Common.Import 5 | { 6 | [Serializable] 7 | public class ProfileSetting 8 | { 9 | public string SettingNameInfo = ""; 10 | 11 | [XmlElement(ElementName = "SettingID")] 12 | public uint SettingId = 0; 13 | 14 | public string SettingValue = "0"; 15 | 16 | public SettingValueType ValueType = SettingValueType.Dword; 17 | } 18 | } -------------------------------------------------------------------------------- /nspector/Common/Import/Profiles.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace nspector.Common.Import 5 | { 6 | [Serializable] 7 | public class Profiles : List 8 | { 9 | 10 | } 11 | } -------------------------------------------------------------------------------- /nspector/Common/Import/SettingValueType.cs: -------------------------------------------------------------------------------- 1 | namespace nspector.Common.Import 2 | { 3 | public enum SettingValueType : int 4 | { 5 | Dword, 6 | AnsiString, 7 | String, 8 | Binary 9 | } 10 | } -------------------------------------------------------------------------------- /nspector/Common/Meta/ConstantSettingMetaService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using nspector.Native.NvApi.DriverSettings; 6 | using nspector.Native.NVAPI2; 7 | 8 | namespace nspector.Common.Meta 9 | { 10 | internal class ConstantSettingMetaService : ISettingMetaService 11 | { 12 | 13 | public ConstantSettingMetaService() 14 | { 15 | settingEnumTypeCache = CreateSettingEnumTypeCache(); 16 | GetSettingIds(); 17 | } 18 | 19 | private readonly Dictionary settingEnumTypeCache; 20 | 21 | private string[] ignoreSettingNames = new[] { "TOTAL_DWORD_SETTING_NUM", "TOTAL_WSTRING_SETTING_NUM", 22 | "TOTAL_SETTING_NUM", "INVALID_SETTING_ID" }; 23 | 24 | private Dictionary CreateSettingEnumTypeCache() 25 | { 26 | var result = new Dictionary(); 27 | 28 | var drsEnumTypes = Assembly.GetExecutingAssembly().GetTypes() 29 | .Where(t => t.Namespace == "nspector.Native.NvApi.DriverSettings" 30 | && t.IsEnum && t.Name.StartsWith("EValues_")).ToList(); 31 | 32 | var settingIdNames = Enum.GetNames(typeof(ESetting)).Distinct().ToList(); 33 | 34 | foreach (var settingIdName in settingIdNames) 35 | { 36 | if (ignoreSettingNames.Contains(settingIdName)) 37 | continue; 38 | 39 | var enumType = drsEnumTypes 40 | .FirstOrDefault(x => settingIdName 41 | .Substring(0, settingIdName.Length - 3) 42 | .Equals(x.Name.Substring(8)) 43 | ); 44 | 45 | if (enumType != null) 46 | { 47 | var settingIdVal = (ESetting)Enum.Parse(typeof(ESetting), settingIdName); 48 | result.Add(settingIdVal, enumType); 49 | } 50 | } 51 | 52 | return result; 53 | } 54 | 55 | public Type GetSettingEnumType(uint settingId) 56 | { 57 | if (settingEnumTypeCache.ContainsKey((ESetting)settingId)) 58 | return settingEnumTypeCache[(ESetting)settingId]; 59 | 60 | return null; 61 | } 62 | 63 | public NVDRS_SETTING_TYPE? GetSettingValueType(uint settingId) 64 | { 65 | return null; 66 | } 67 | 68 | public string GetSettingName(uint settingId) 69 | { 70 | if (settingIds.Contains(settingId)) 71 | return ((ESetting)settingId).ToString(); 72 | 73 | return null; 74 | } 75 | 76 | public uint? GetDwordDefaultValue(uint settingId) 77 | { 78 | if (settingEnumTypeCache.ContainsKey((ESetting)settingId)) 79 | { 80 | var enumType = settingEnumTypeCache[(ESetting)settingId]; 81 | 82 | var defaultName = Enum.GetNames(enumType).FirstOrDefault(x => x.EndsWith("_DEFAULT")); 83 | if (defaultName != null) 84 | return (uint)Enum.Parse(enumType, defaultName); 85 | } 86 | return null; 87 | } 88 | 89 | public string GetStringDefaultValue(uint settingId) 90 | { 91 | return null; 92 | } 93 | 94 | public List> GetStringValues(uint settingId) 95 | { 96 | return null; 97 | } 98 | 99 | private uint ParseEnumValue(Type enumType, string enumText) 100 | { 101 | try 102 | { 103 | return (uint)Enum.Parse(enumType, enumText); 104 | } 105 | catch (InvalidCastException) 106 | { 107 | var intValue = (int)Enum.Parse(enumType, enumText); 108 | var bytes = BitConverter.GetBytes(intValue); 109 | return BitConverter.ToUInt32(bytes, 0); 110 | } 111 | } 112 | 113 | public List> GetDwordValues(uint settingId) 114 | { 115 | if (settingEnumTypeCache.ContainsKey((ESetting)settingId)) 116 | { 117 | var enumType = settingEnumTypeCache[(ESetting)settingId]; 118 | 119 | var validNames = Enum.GetNames(enumType) 120 | .Where(x => 1 == 1 121 | && !x.EndsWith("_DEFAULT") 122 | && !x.EndsWith("_NUM_VALUES") 123 | //&& !x.EndsWith("_NUM") 124 | //&& !x.EndsWith("_MASK") 125 | //&& (!x.EndsWith("_MIN") || x.Equals("PREFERRED_PSTATE_PREFER_MIN")) 126 | //&& (!x.EndsWith("_MAX") || x.Equals("PREFERRED_PSTATE_PREFER_MAX")) 127 | ).ToList(); 128 | 129 | return validNames.Select(x => new SettingValue(Source) 130 | { 131 | Value = ParseEnumValue(enumType, x), 132 | ValueName = DrsUtil.GetDwordString(ParseEnumValue(enumType, x)) + " " + x 133 | }).ToList(); 134 | 135 | } 136 | return null; 137 | } 138 | 139 | private HashSet settingIds; 140 | public List GetSettingIds() 141 | { 142 | if (settingIds == null) 143 | settingIds = new HashSet( 144 | Enum.GetValues(typeof(ESetting)) 145 | .Cast() 146 | .Where(x => !ignoreSettingNames.Contains(x.ToString())) 147 | .Cast() 148 | .Distinct() 149 | .ToList()); 150 | 151 | return settingIds.ToList(); 152 | } 153 | 154 | 155 | public string GetGroupName(uint settingId) 156 | { 157 | return null; 158 | } 159 | 160 | public byte[] GetBinaryDefaultValue(uint settingId) 161 | { 162 | return null; 163 | } 164 | 165 | public List> GetBinaryValues(uint settingId) 166 | { 167 | return null; 168 | } 169 | 170 | public SettingMetaSource Source 171 | { 172 | get { return SettingMetaSource.ConstantSettings; } 173 | } 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /nspector/Common/Meta/CustomSettingMetaService.cs: -------------------------------------------------------------------------------- 1 | using nspector.Common.CustomSettings; 2 | using nspector.Native.NVAPI2; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace nspector.Common.Meta 8 | { 9 | internal class CustomSettingMetaService : ISettingMetaService 10 | { 11 | 12 | private readonly CustomSettingNames customSettings; 13 | private readonly SettingMetaSource _source; 14 | 15 | public CustomSettingMetaService(CustomSettingNames customSettings, SettingMetaSource sourceOverride = SettingMetaSource.CustomSettings) 16 | { 17 | this.customSettings = customSettings; 18 | _source = sourceOverride; 19 | } 20 | 21 | public NVDRS_SETTING_TYPE? GetSettingValueType(uint settingId) 22 | { 23 | var setting = customSettings.Settings 24 | .FirstOrDefault(x => x.SettingId.Equals(settingId)); 25 | 26 | return MapType(setting?.DataType); 27 | } 28 | 29 | private NVDRS_SETTING_TYPE? MapType(string type) 30 | { 31 | if (string.IsNullOrEmpty(type)) return null; 32 | 33 | switch(type.ToLowerInvariant()) 34 | { 35 | case "dword": 36 | return NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE; 37 | case "string": 38 | return NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE; 39 | case "binary": 40 | return NVDRS_SETTING_TYPE.NVDRS_BINARY_TYPE; 41 | default: throw new ArgumentOutOfRangeException(type); 42 | } 43 | } 44 | 45 | public string GetSettingName(uint settingId) 46 | { 47 | var setting = customSettings.Settings 48 | .FirstOrDefault(x => x.SettingId.Equals(settingId)); 49 | 50 | if (setting != null) 51 | return setting.UserfriendlyName; 52 | 53 | return null; 54 | } 55 | 56 | public uint? GetDwordDefaultValue(uint settingId) 57 | { 58 | var setting = customSettings.Settings 59 | .FirstOrDefault(x => x.SettingId.Equals(settingId)); 60 | 61 | if (setting != null) 62 | return setting.DefaultValue; 63 | 64 | return null; 65 | } 66 | 67 | public string GetStringDefaultValue(uint settingId) 68 | { 69 | return null; 70 | } 71 | 72 | public List> GetStringValues(uint settingId) 73 | { 74 | return null; 75 | } 76 | 77 | public List> GetDwordValues(uint settingId) 78 | { 79 | var setting = customSettings.Settings 80 | .FirstOrDefault(x => x.SettingId.Equals(settingId)); 81 | 82 | if (setting != null) 83 | { 84 | var i = 0; 85 | return setting.SettingValues.Select(x => new SettingValue(Source) 86 | { 87 | ValuePos = i++, 88 | Value = x.SettingValue, 89 | ValueName = _source == SettingMetaSource.CustomSettings ? x.UserfriendlyName : DrsUtil.GetDwordString(x.SettingValue) + " " + x.UserfriendlyName, 90 | }).ToList(); 91 | } 92 | 93 | return null; 94 | } 95 | 96 | public List GetSettingIds() 97 | { 98 | return customSettings.Settings 99 | .Select(x => x.SettingId).ToList(); 100 | } 101 | 102 | 103 | public string GetGroupName(uint settingId) 104 | { 105 | var setting = customSettings.Settings 106 | .FirstOrDefault(x => x.SettingId.Equals(settingId)); 107 | 108 | if (setting != null && !string.IsNullOrWhiteSpace(setting.GroupName)) 109 | return setting.GroupName; 110 | 111 | return null; 112 | } 113 | 114 | public byte[] GetBinaryDefaultValue(uint settingId) 115 | { 116 | return null; 117 | } 118 | 119 | public List> GetBinaryValues(uint settingId) 120 | { 121 | return null; 122 | } 123 | 124 | public bool IsSettingHidden(uint settingId) 125 | { 126 | var setting = customSettings.Settings 127 | .FirstOrDefault(x => x.SettingId.Equals(settingId)); 128 | 129 | return setting?.Hidden ?? false; 130 | } 131 | 132 | public string GetDescription(uint settingId) 133 | { 134 | var setting = customSettings.Settings 135 | .FirstOrDefault(x => x.SettingId.Equals(settingId)); 136 | 137 | return setting?.Description; 138 | } 139 | 140 | public SettingMetaSource Source 141 | { 142 | get { return _source; } 143 | } 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /nspector/Common/Meta/DriverSettingMetaService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text; 3 | using nspector.Native.NVAPI2; 4 | using nvw = nspector.Native.NVAPI2.NvapiDrsWrapper; 5 | 6 | namespace nspector.Common.Meta 7 | { 8 | 9 | internal class DriverSettingMetaService : ISettingMetaService 10 | { 11 | 12 | private readonly Dictionary _settingMetaCache = new Dictionary(); 13 | private readonly List _settingIds; 14 | 15 | public DriverSettingMetaService() 16 | { 17 | _settingIds = InitSettingIds(); 18 | } 19 | 20 | private List InitSettingIds() 21 | { 22 | var settingIds = new List(); 23 | 24 | var nvRes = nvw.DRS_EnumAvailableSettingIds(out settingIds, 512); 25 | if (nvRes != NvAPI_Status.NVAPI_OK) 26 | throw new NvapiException("DRS_EnumAvailableSettingIds", nvRes); 27 | 28 | return settingIds; 29 | } 30 | 31 | private SettingMeta GetDriverSettingMetaInternal(uint settingId) 32 | { 33 | // temporary fix for 571.96 overflow bug by emoose 34 | if ((settingId & 0xFFFFF000) == 0x10c7d000) 35 | return null; 36 | 37 | 38 | var values = new NVDRS_SETTING_VALUES(); 39 | values.version = nvw.NVDRS_SETTING_VALUES_VER; 40 | uint valueCount = 255; 41 | 42 | var nvRes = nvw.DRS_EnumAvailableSettingValues(settingId, ref valueCount, ref values); 43 | 44 | if (nvRes == NvAPI_Status.NVAPI_SETTING_NOT_FOUND) 45 | return null; 46 | 47 | if (nvRes != NvAPI_Status.NVAPI_OK) 48 | throw new NvapiException("DRS_EnumAvailableSettingValues", nvRes); 49 | 50 | 51 | var sbSettingName = new StringBuilder((int)NvapiDrsWrapper.NVAPI_UNICODE_STRING_MAX); 52 | nvRes = nvw.DRS_GetSettingNameFromId(settingId, sbSettingName); 53 | if (nvRes != NvAPI_Status.NVAPI_OK) 54 | throw new NvapiException("DRS_GetSettingNameFromId", nvRes); 55 | 56 | var settingName = sbSettingName.ToString(); 57 | if (string.IsNullOrWhiteSpace(settingName)) 58 | settingName = DrsUtil.GetDwordString(settingId); 59 | 60 | var result = new SettingMeta 61 | { 62 | SettingType = values.settingType, 63 | SettingName = settingName, 64 | }; 65 | 66 | 67 | if (values.settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE) 68 | { 69 | result.DefaultDwordValue = values.defaultValue.dwordValue; 70 | result.DwordValues = new List>(); 71 | for (int i = 0; i < values.numSettingValues; i++) 72 | { 73 | result.DwordValues.Add( 74 | new SettingValue(Source) 75 | { 76 | Value = values.settingValues[i].dwordValue, 77 | ValueName = DrsUtil.GetDwordString(values.settingValues[i].dwordValue), 78 | }); 79 | } 80 | } 81 | 82 | if (values.settingType == NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE) 83 | { 84 | result.DefaultStringValue = values.defaultValue.stringValue; 85 | result.StringValues = new List>(); 86 | for (int i = 0; i < values.numSettingValues; i++) 87 | { 88 | var strValue = values.settingValues[i].stringValue; 89 | if (strValue != null) 90 | { 91 | result.StringValues.Add( 92 | new SettingValue(Source) 93 | { 94 | Value = strValue, 95 | ValueName = strValue, 96 | }); 97 | } 98 | } 99 | } 100 | 101 | if (values.settingType == NVDRS_SETTING_TYPE.NVDRS_BINARY_TYPE) 102 | { 103 | result.DefaultBinaryValue = values.defaultValue.binaryValue; 104 | result.BinaryValues = new List>(); 105 | for (int i = 0; i < values.numSettingValues; i++) 106 | { 107 | var binValue = values.settingValues[i].binaryValue; 108 | if (binValue != null) 109 | { 110 | result.BinaryValues.Add( 111 | new SettingValue(Source) 112 | { 113 | Value = binValue, 114 | ValueName = DrsUtil.GetBinaryString(binValue), 115 | }); 116 | } 117 | } 118 | } 119 | return result; 120 | 121 | } 122 | 123 | private SettingMeta GetSettingsMeta(uint settingId) 124 | { 125 | if (_settingMetaCache.ContainsKey(settingId)) 126 | return _settingMetaCache[settingId]; 127 | else 128 | { 129 | var settingMeta = GetDriverSettingMetaInternal(settingId); 130 | if (settingMeta != null) 131 | { 132 | _settingMetaCache.Add(settingId, settingMeta); 133 | return settingMeta; 134 | } 135 | 136 | return null; 137 | } 138 | } 139 | 140 | public string GetSettingName(uint settingId) 141 | { 142 | var settingMeta = GetSettingsMeta(settingId); 143 | if (settingMeta != null) 144 | return settingMeta.SettingName; 145 | 146 | return null; 147 | } 148 | 149 | public uint? GetDwordDefaultValue(uint settingId) 150 | { 151 | var settingMeta = GetSettingsMeta(settingId); 152 | if (settingMeta != null) 153 | return settingMeta.DefaultDwordValue; 154 | 155 | return null; 156 | } 157 | 158 | public string GetStringDefaultValue(uint settingId) 159 | { 160 | var settingMeta = GetSettingsMeta(settingId); 161 | if (settingMeta != null) 162 | return settingMeta.DefaultStringValue; 163 | 164 | return null; 165 | } 166 | 167 | public List> GetStringValues(uint settingId) 168 | { 169 | var settingMeta = GetSettingsMeta(settingId); 170 | if (settingMeta != null) 171 | return settingMeta.StringValues; 172 | 173 | return null; 174 | } 175 | 176 | public List> GetDwordValues(uint settingId) 177 | { 178 | var settingMeta = GetSettingsMeta(settingId); 179 | if (settingMeta != null) 180 | return settingMeta.DwordValues; 181 | 182 | return null; 183 | } 184 | 185 | public List GetSettingIds() 186 | { 187 | return _settingIds; 188 | } 189 | 190 | public NVDRS_SETTING_TYPE? GetSettingValueType(uint settingId) 191 | { 192 | var settingMeta = GetSettingsMeta(settingId); 193 | if (settingMeta != null) 194 | return settingMeta.SettingType; 195 | 196 | return null; 197 | } 198 | 199 | public string GetGroupName(uint settingId) 200 | { 201 | return null; 202 | } 203 | 204 | public byte[] GetBinaryDefaultValue(uint settingId) 205 | { 206 | var settingMeta = GetSettingsMeta(settingId); 207 | if (settingMeta != null) 208 | return settingMeta.DefaultBinaryValue; 209 | 210 | return null; 211 | } 212 | 213 | public List> GetBinaryValues(uint settingId) 214 | { 215 | var settingMeta = GetSettingsMeta(settingId); 216 | if (settingMeta != null) 217 | return settingMeta.BinaryValues; 218 | 219 | return null; 220 | } 221 | 222 | public SettingMetaSource Source 223 | { 224 | get { return SettingMetaSource.DriverSettings; } 225 | } 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /nspector/Common/Meta/ISettingMetaService.cs: -------------------------------------------------------------------------------- 1 | using nspector.Native.NVAPI2; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace nspector.Common.Meta 8 | { 9 | internal interface ISettingMetaService 10 | { 11 | SettingMetaSource Source { get; } 12 | 13 | NVDRS_SETTING_TYPE? GetSettingValueType(uint settingId); 14 | 15 | string GetSettingName(uint settingId); 16 | 17 | string GetGroupName(uint settingId); 18 | 19 | uint? GetDwordDefaultValue(uint settingId); 20 | 21 | string GetStringDefaultValue(uint settingId); 22 | 23 | byte[] GetBinaryDefaultValue(uint settingId); 24 | 25 | List> GetStringValues(uint settingId); 26 | 27 | List> GetDwordValues(uint settingId); 28 | 29 | List> GetBinaryValues(uint settingId); 30 | 31 | List GetSettingIds(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /nspector/Common/Meta/MetaServiceItem.cs: -------------------------------------------------------------------------------- 1 | namespace nspector.Common.Meta 2 | { 3 | internal class MetaServiceItem 4 | { 5 | public ISettingMetaService Service { get; set; } 6 | public uint ValueNamePrio { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /nspector/Common/Meta/ScannedSettingMetaService.cs: -------------------------------------------------------------------------------- 1 | using nspector.Native.NVAPI2; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace nspector.Common.Meta 8 | { 9 | internal class ScannedSettingMetaService : ISettingMetaService 10 | { 11 | private readonly List CachedSettings; 12 | 13 | public ScannedSettingMetaService(List cachedSettings) 14 | { 15 | CachedSettings = cachedSettings; 16 | } 17 | 18 | public SettingMetaSource Source 19 | { 20 | get { return SettingMetaSource.ScannedSettings; } 21 | } 22 | 23 | public NVDRS_SETTING_TYPE? GetSettingValueType(uint settingId) 24 | { 25 | var cached = CachedSettings.FirstOrDefault(x => x.SettingId.Equals(settingId)); 26 | if (cached != null) 27 | return cached.SettingType; 28 | 29 | return null; 30 | } 31 | 32 | public string GetSettingName(uint settingId) 33 | { 34 | var cached = CachedSettings.FirstOrDefault(x => x.SettingId.Equals(settingId)); 35 | if (cached != null) 36 | return string.Format("0x{0:X8} ({1} Profiles)", settingId, cached.ProfileCount); 37 | 38 | return null; 39 | } 40 | 41 | public string GetGroupName(uint settingId) 42 | { 43 | return null; 44 | } 45 | 46 | public uint? GetDwordDefaultValue(uint settingId) 47 | { 48 | return null; 49 | } 50 | 51 | public string GetStringDefaultValue(uint settingId) 52 | { 53 | return null; 54 | } 55 | 56 | public List> GetStringValues(uint settingId) 57 | { 58 | var cached = CachedSettings.FirstOrDefault(x => x.SettingId.Equals(settingId)); 59 | if (cached != null) 60 | return cached.SettingValues.Select(s => new SettingValue(Source) 61 | { 62 | Value = s.ValueStr, 63 | ValueName = string.Format("'{0}' ({1})", s.ValueStr.Trim(), s.ProfileNames), 64 | 65 | }).ToList(); 66 | 67 | return null; 68 | } 69 | 70 | public List> GetDwordValues(uint settingId) 71 | { 72 | var cached = CachedSettings.FirstOrDefault(x => x.SettingId.Equals(settingId)); 73 | if (cached != null) 74 | return cached.SettingValues.Select(s => new SettingValue(Source) 75 | { 76 | Value = s.Value, 77 | ValueName = string.Format("0x{0:X8} ({1})", s.Value, s.ProfileNames), 78 | 79 | }).ToList(); 80 | 81 | return null; 82 | } 83 | 84 | public List GetSettingIds() 85 | { 86 | return CachedSettings.Select(c => c.SettingId).ToList(); 87 | } 88 | 89 | public byte[] GetBinaryDefaultValue(uint settingId) 90 | { 91 | return null; 92 | } 93 | 94 | public List> GetBinaryValues(uint settingId) 95 | { 96 | var cached = CachedSettings.FirstOrDefault(x => x.SettingId.Equals(settingId)); 97 | if (cached != null) 98 | return cached.SettingValues.Select(s => new SettingValue(Source) 99 | { 100 | Value = s.ValueBin, 101 | ValueName = string.Format("{0} ({1})", DrsUtil.GetBinaryString(s.ValueBin), s.ProfileNames), 102 | 103 | }).ToList(); 104 | 105 | return null; 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /nspector/Common/Meta/SettingMeta.cs: -------------------------------------------------------------------------------- 1 | using nspector.Native.NVAPI2; 2 | using System.Collections.Generic; 3 | 4 | namespace nspector.Common.Meta 5 | { 6 | internal class SettingMeta 7 | { 8 | public NVDRS_SETTING_TYPE? SettingType { get; set; } 9 | 10 | public string GroupName { get; set; } 11 | 12 | public string SettingName { get; set; } 13 | 14 | public string DefaultStringValue { get; set; } 15 | 16 | public uint DefaultDwordValue { get; set; } 17 | 18 | public byte[] DefaultBinaryValue { get; set; } 19 | 20 | public bool IsApiExposed { get; set; } 21 | 22 | public bool IsSettingHidden { get; set; } 23 | 24 | public string Description { get; set; } 25 | 26 | public List> StringValues { get; set; } 27 | 28 | public List> DwordValues { get; set; } 29 | 30 | public List> BinaryValues { get; set; } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /nspector/Common/Meta/SettingMetaSource.cs: -------------------------------------------------------------------------------- 1 | namespace nspector.Common.Meta 2 | { 3 | public enum SettingMetaSource 4 | { 5 | CustomSettings = 10, 6 | DriverSettings = 20, 7 | ConstantSettings = 30, 8 | ReferenceSettings = 40, 9 | ScannedSettings = 50, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /nspector/Common/Meta/SettingValue.cs: -------------------------------------------------------------------------------- 1 | namespace nspector.Common.Meta 2 | { 3 | internal class SettingValue 4 | { 5 | 6 | public SettingMetaSource ValueSource; 7 | 8 | public SettingValue(SettingMetaSource source) 9 | { 10 | ValueSource = source; 11 | } 12 | 13 | public int ValuePos { get; set; } 14 | public string ValueName { get; set; } 15 | public T Value { get; set; } 16 | 17 | public override string ToString() 18 | { 19 | if (typeof(T) == typeof(uint)) 20 | return string.Format("Value=0x{0:X8}; ValueName={1}; Source={2};", Value, ValueName, ValueSource); 21 | 22 | return string.Format("Value={0}; ValueName={1};", Value, ValueName); 23 | } 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /nspector/Common/NvapiException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using nspector.Native.NVAPI2; 3 | 4 | namespace nspector.Common 5 | { 6 | public class NvapiException : Exception 7 | { 8 | public readonly NvAPI_Status Status; 9 | 10 | public NvapiException(string function, NvAPI_Status status) 11 | : base(function + " failed: " + status) 12 | { 13 | Status = status; 14 | } 15 | 16 | } 17 | 18 | public class NvapiAddApplicationException : NvapiException 19 | { 20 | public readonly string ApplicationName; 21 | 22 | public NvapiAddApplicationException(string applicationName) 23 | : base("DRS_CreateApplication", NvAPI_Status.NVAPI_EXECUTABLE_ALREADY_IN_USE) 24 | { 25 | ApplicationName = applicationName; 26 | } 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /nspector/Common/SettingItem.cs: -------------------------------------------------------------------------------- 1 | namespace nspector.Common 2 | { 3 | 4 | internal enum SettingState 5 | { 6 | NotAssiged, 7 | GlobalSetting, 8 | UserdefinedSetting, 9 | NvidiaSetting, 10 | } 11 | 12 | internal class SettingItem 13 | { 14 | public uint SettingId { get; set; } 15 | 16 | public string SettingText { get; set; } 17 | 18 | public string ValueText { get; set; } 19 | 20 | public string ValueRaw { get; set; } 21 | 22 | public string GroupName { get; set; } 23 | 24 | public SettingState State { get; set; } 25 | 26 | public bool IsStringValue { get; set; } 27 | 28 | public bool IsApiExposed { get; set; } 29 | 30 | public bool IsSettingHidden { get; set; } 31 | 32 | public override string ToString() 33 | { 34 | return string.Format("{0}; 0x{1:X8}; {2}; {3}; {4};", State, SettingId, SettingText, ValueText, ValueRaw); 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /nspector/Common/SettingViewMode.cs: -------------------------------------------------------------------------------- 1 | namespace nspector.Common 2 | { 3 | public enum SettingViewMode 4 | { 5 | Normal, 6 | IncludeScannedSetttings, 7 | CustomSettingsOnly, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /nspector/Images/0_gear2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/0_gear2.png -------------------------------------------------------------------------------- /nspector/Images/1_gear2_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/1_gear2_2.png -------------------------------------------------------------------------------- /nspector/Images/4_gear_nv2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/4_gear_nv2.png -------------------------------------------------------------------------------- /nspector/Images/6_gear_inherit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/6_gear_inherit.png -------------------------------------------------------------------------------- /nspector/Images/PortableDeviceStatus_3_16-011.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/PortableDeviceStatus_3_16-011.png -------------------------------------------------------------------------------- /nspector/Images/apply.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/apply.png -------------------------------------------------------------------------------- /nspector/Images/export1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/export1.png -------------------------------------------------------------------------------- /nspector/Images/filter_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/filter_user.png -------------------------------------------------------------------------------- /nspector/Images/find_set2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/find_set2.png -------------------------------------------------------------------------------- /nspector/Images/home_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/home_sm.png -------------------------------------------------------------------------------- /nspector/Images/ieframe_1_18212.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/ieframe_1_18212.png -------------------------------------------------------------------------------- /nspector/Images/ieframe_1_31073-002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/ieframe_1_31073-002.png -------------------------------------------------------------------------------- /nspector/Images/import1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/import1.png -------------------------------------------------------------------------------- /nspector/Images/n1-016.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/n1-016.png -------------------------------------------------------------------------------- /nspector/Images/nv_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/nv_btn.png -------------------------------------------------------------------------------- /nspector/Images/shield.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/shield.png -------------------------------------------------------------------------------- /nspector/Images/shield16.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/shield16.ico -------------------------------------------------------------------------------- /nspector/Images/text_binary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/text_binary.png -------------------------------------------------------------------------------- /nspector/Images/transparent16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/transparent16.png -------------------------------------------------------------------------------- /nspector/Images/window_application_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/window_application_add.png -------------------------------------------------------------------------------- /nspector/Images/window_application_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/Images/window_application_delete.png -------------------------------------------------------------------------------- /nspector/ListViewEx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Drawing; 6 | using System.Runtime.InteropServices; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace nspector 11 | { 12 | internal delegate void DropFilesNativeHandler(string[] files); 13 | 14 | internal class ListViewEx : ListView 15 | { 16 | 17 | public event DropFilesNativeHandler OnDropFilesNative; 18 | 19 | [DllImport("user32.dll")] 20 | private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wPar, IntPtr lPar); 21 | 22 | private const int LVM_FIRST = 0x1000; 23 | private const int LVM_GETCOLUMNORDERARRAY = (LVM_FIRST + 59); 24 | 25 | private const int WM_PAINT = 0x000F; 26 | private const int WM_VSCROLL = 0x0115; 27 | private const int WM_HSCROLL = 0x0114; 28 | private const int WM_MOUSEWHEEL = 0x020A; 29 | 30 | private struct EmbeddedControl 31 | { 32 | internal Control Control; 33 | internal int Column; 34 | internal int Row; 35 | internal DockStyle Dock; 36 | internal ListViewItem Item; 37 | } 38 | 39 | private ArrayList _embeddedControls = new ArrayList(); 40 | 41 | public ListViewEx() 42 | { 43 | this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); 44 | this.SetStyle(ControlStyles.EnableNotifyMessage, true); 45 | } 46 | 47 | protected override void OnNotifyMessage(Message m) 48 | { 49 | if (m.Msg != 0x14) 50 | { 51 | base.OnNotifyMessage(m); 52 | } 53 | } 54 | 55 | protected int[] GetColumnOrder() 56 | { 57 | IntPtr lPar = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)) * Columns.Count); 58 | 59 | IntPtr res = SendMessage(Handle, LVM_GETCOLUMNORDERARRAY, new IntPtr(Columns.Count), lPar); 60 | if (res.ToInt32() == 0) 61 | { 62 | Marshal.FreeHGlobal(lPar); 63 | return null; 64 | } 65 | 66 | int [] order = new int[Columns.Count]; 67 | Marshal.Copy(lPar, order, 0, Columns.Count); 68 | 69 | Marshal.FreeHGlobal(lPar); 70 | 71 | return order; 72 | } 73 | 74 | protected Rectangle GetSubItemBounds(ListViewItem Item, int SubItem) 75 | { 76 | Rectangle subItemRect = Rectangle.Empty; 77 | 78 | if (Item == null) 79 | throw new ArgumentNullException("Item"); 80 | 81 | int[] order = GetColumnOrder(); 82 | if (order == null) // No Columns 83 | return subItemRect; 84 | 85 | if (SubItem >= order.Length) 86 | throw new IndexOutOfRangeException("SubItem "+SubItem+" out of range"); 87 | 88 | Rectangle lviBounds = Item.GetBounds(ItemBoundsPortion.Entire); 89 | int subItemX = lviBounds.Left; 90 | 91 | ColumnHeader col; 92 | int i; 93 | for (i=0; i=Columns.Count || row>=Items.Count) 116 | throw new ArgumentOutOfRangeException(); 117 | 118 | EmbeddedControl ec; 119 | ec.Control = c; 120 | ec.Column = col; 121 | ec.Row = row; 122 | ec.Dock = dock; 123 | ec.Item = Items[row]; 124 | 125 | _embeddedControls.Add(ec); 126 | 127 | c.Click += new EventHandler(_embeddedControl_Click); 128 | 129 | this.Controls.Add(c); 130 | } 131 | 132 | internal void RemoveEmbeddedControl(Control c) 133 | { 134 | if (c == null) 135 | throw new ArgumentNullException(); 136 | 137 | for (int i=0; i<_embeddedControls.Count; i++) 138 | { 139 | EmbeddedControl ec = (EmbeddedControl)_embeddedControls[i]; 140 | if (ec.Control == c) 141 | { 142 | c.Click -= new EventHandler(_embeddedControl_Click); 143 | this.Controls.Remove(c); 144 | _embeddedControls.RemoveAt(i); 145 | return; 146 | } 147 | } 148 | } 149 | 150 | internal Control GetEmbeddedControl(int col, int row) 151 | { 152 | foreach (EmbeddedControl ec in _embeddedControls) 153 | if (ec.Row == row && ec.Column == col) 154 | return ec.Control; 155 | 156 | return null; 157 | } 158 | 159 | [DefaultValue(View.LargeIcon)] 160 | internal new View View 161 | { 162 | get 163 | { 164 | return base.View; 165 | } 166 | set 167 | { 168 | foreach (EmbeddedControl ec in _embeddedControls) 169 | ec.Control.Visible = (value == View.Details); 170 | 171 | base.View = value; 172 | } 173 | } 174 | 175 | [DllImport("shell32.dll", CharSet = CharSet.Auto)] 176 | public static extern int DragQueryFile(IntPtr hDrop, uint iFile, [Out] StringBuilder lpszFile, int cch); 177 | private const int WM_DROPFILES = 0x233; 178 | 179 | protected override void WndProc(ref Message m) 180 | { 181 | switch (m.Msg) 182 | { 183 | case WM_PAINT: 184 | if (View != View.Details) 185 | break; 186 | 187 | foreach (EmbeddedControl ec in _embeddedControls) 188 | { 189 | // Skip repositioning if the control is a dropped-down ComboBox, prevents it from immediately closing on first click 190 | if (ec.Control is ComboBox comboBox && comboBox.DroppedDown) 191 | continue; 192 | 193 | Rectangle rc = this.GetSubItemBounds(ec.Item, ec.Column); 194 | 195 | if ((this.HeaderStyle != ColumnHeaderStyle.None) && 196 | (rc.Top 0) 259 | { 260 | var files = new List(); 261 | 262 | for (uint i = 0; i < dropped; i++) 263 | { 264 | var size = DragQueryFile(m.WParam, i, null, 0); 265 | if (size > 0) 266 | { 267 | var sb = new StringBuilder(size + 1); 268 | var result = DragQueryFile(m.WParam, i, sb, size + 1); 269 | files.Add(sb.ToString()); 270 | } 271 | } 272 | 273 | OnDropFilesNative(files.ToArray()); 274 | } 275 | } 276 | 277 | base.WndProc(ref m); 278 | break; 279 | } 280 | base.WndProc(ref m); 281 | } 282 | 283 | private void _embeddedControl_Click(object sender, EventArgs e) 284 | { 285 | foreach (EmbeddedControl ec in _embeddedControls) 286 | { 287 | if (ec.Control == (Control)sender) 288 | { 289 | this.SelectedItems.Clear(); 290 | ec.Item.Selected = true; 291 | } 292 | } 293 | } 294 | } 295 | } 296 | -------------------------------------------------------------------------------- /nspector/Native/NVAPI/NvApiDriverSettings.tt: -------------------------------------------------------------------------------- 1 | <#@ template debug="false" hostspecific="true" language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ import namespace="System.IO" #> 7 | <#@ import namespace="System.Text.RegularExpressions" #> 8 | <#@ output extension=".cs" #> 9 | namespace nspector.Native.NvApi.DriverSettings 10 | { 11 | <# 12 | string absolutePath = Host.ResolvePath("NvApiDriverSettings.h"); 13 | string contents = File.ReadAllText(absolutePath); 14 | 15 | string pattern = "enum\\s+(?.*?)\\{(?.*?)\\}"; 16 | var rx = new Regex(pattern, RegexOptions.Singleline); 17 | foreach (Match m in rx.Matches(contents)) 18 | { 19 | PushIndent("\t"); 20 | 21 | string enumSrc = m.Result("${enums}").Trim(); 22 | string enumType = ""; 23 | 24 | if (Regex.IsMatch(enumSrc, "0x[A-Fa-f0-9]{8}L")) 25 | enumType = " : ulong"; 26 | else if (Regex.IsMatch(enumSrc, @".*?=\s+-.*?")) 27 | enumType = " : int"; 28 | else 29 | enumType = " : uint"; 30 | 31 | WriteLine("public enum " + m.Result("${name}").Trim() + enumType + " {"); 32 | 33 | WriteLine("\t" + enumSrc); 34 | 35 | WriteLine("}"); 36 | 37 | PopIndent(); 38 | WriteLine(""); 39 | } 40 | 41 | #> 42 | } -------------------------------------------------------------------------------- /nspector/Native/NativeArrayHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace nspector.Native 6 | { 7 | internal class NativeArrayHelper 8 | { 9 | public static T GetArrayItemData(IntPtr sourcePointer) 10 | { 11 | return (T)Marshal.PtrToStructure(sourcePointer, typeof(T)); 12 | } 13 | 14 | public static T[] GetArrayData(IntPtr sourcePointer, int itemCount) 15 | { 16 | var lstResult = new List(); 17 | if (sourcePointer != IntPtr.Zero && itemCount > 0) 18 | { 19 | var sizeOfItem = Marshal.SizeOf(typeof(T)); 20 | for (int i = 0; i < itemCount; i++) 21 | { 22 | lstResult.Add(GetArrayItemData(sourcePointer + (sizeOfItem * i))); 23 | } 24 | } 25 | return lstResult.ToArray(); 26 | } 27 | 28 | public static void SetArrayData(T[] items, out IntPtr targetPointer) 29 | { 30 | if (items != null && items.Length > 0) 31 | { 32 | var sizeOfItem = Marshal.SizeOf(typeof(T)); 33 | targetPointer = Marshal.AllocHGlobal(sizeOfItem * items.Length); 34 | for (int i = 0; i < items.Length; i++) 35 | { 36 | Marshal.StructureToPtr(items[i], targetPointer + (sizeOfItem * i), true); 37 | } 38 | } 39 | else 40 | { 41 | targetPointer = IntPtr.Zero; 42 | } 43 | 44 | } 45 | 46 | public static void SetArrayItemData(T item, out IntPtr targetPointer) 47 | { 48 | var sizeOfItem = Marshal.SizeOf(typeof(T)); 49 | targetPointer = Marshal.AllocHGlobal(sizeOfItem); 50 | Marshal.StructureToPtr(item, targetPointer, true); 51 | } 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /nspector/Native/WINAPI/DragAcceptNativeHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace nspector.Native.WINAPI 5 | { 6 | internal static class DragAcceptNativeHelper 7 | { 8 | /// 9 | /// Modifies the User Interface Privilege Isolation (UIPI) message filter for whole process. (Vista only) 10 | /// 11 | /// 12 | /// 13 | /// 14 | [DllImport("user32.dll", SetLastError = true)] 15 | internal static extern IntPtr ChangeWindowMessageFilter(int message, int dwFlag); 16 | 17 | /// 18 | /// Modifies the User Interface Privilege Isolation (UIPI) message filter for a specified window. (Win7 or higher) 19 | /// 20 | /// 21 | /// 22 | /// 23 | /// 24 | [DllImport("user32.dll", SetLastError = true)] 25 | internal static extern IntPtr ChangeWindowMessageFilterEx(IntPtr handle, int message, int action, IntPtr pChangeFilterStruct); 26 | 27 | //ChangeWindowMessageFilter 28 | internal const int MSGFLT_ADD = 1; 29 | internal const int MSGFLT_REMOVE = 2; 30 | 31 | //ChangeWindowMessageFilterEx 32 | internal const int MSGFLT_ALLOW = 1; 33 | internal const int MSGFLT_DISALLOW = 2; 34 | internal const int MSGFLT_RESET = 3; 35 | 36 | 37 | [DllImport("shell32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)] 38 | public static extern void DragAcceptFiles(IntPtr hWnd, bool fAccept); 39 | 40 | internal const int WM_DROPFILES = 0x233; 41 | internal const int WM_COPYDATA = 0x004A; 42 | internal const int WM_COPYGLOBALDATA = 0x0049; 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /nspector/Native/WINAPI/SafeNativeMethods.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace nspector.Native.WINAPI 4 | { 5 | static class SafeNativeMethods 6 | { 7 | [DllImport("kernel32", CharSet = CharSet.Unicode, SetLastError = true)] 8 | [return: MarshalAs(UnmanagedType.Bool)] 9 | internal static extern bool DeleteFile(string name); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /nspector/Native/WINAPI/TaskBarList3.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace nspector.Native.WINAPI 6 | { 7 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 8 | internal struct THUMBBUTTON 9 | { 10 | Int32 dwMask; 11 | uint iId; 12 | uint iBitmap; 13 | IntPtr hIcon; 14 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] 15 | string szTip; 16 | Int32 dwFlags; 17 | } 18 | 19 | [Flags] 20 | internal enum THBF 21 | { 22 | THBF_ENABLED = 0x0000, 23 | THBF_DISABLED = 0x0001, 24 | THBF_DISMISSONCLICK = 0x0002, 25 | THBF_NOBACKGROUND = 0x0004, 26 | THBF_HIDDEN = 0x0008 27 | } 28 | 29 | [Flags] 30 | internal enum THB 31 | { 32 | THB_BITMAP = 0x0001, 33 | THB_ICON = 0x0002, 34 | THB_TOOLTIP = 0x0004, 35 | THB_FLAGS = 0x0008, 36 | THBN_CLICKED = 0x1800 37 | } 38 | 39 | internal enum TBPFLAG 40 | { 41 | TBPF_NOPROGRESS = 0, 42 | TBPF_INDETERMINATE = 0x1, 43 | TBPF_NORMAL = 0x2, 44 | TBPF_ERROR = 0x4, 45 | TBPF_PAUSED = 0x8 46 | } 47 | 48 | internal enum TBATFLAG 49 | { 50 | TBATF_USEMDITHUMBNAIL = 0x1, 51 | TBATF_USEMDILIVEPREVIEW = 0x2 52 | } 53 | 54 | [ComImport, 55 | Guid("EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF"), 56 | InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 57 | internal interface ITaskbarList3 58 | { 59 | 60 | [MethodImpl(MethodImplOptions.InternalCall, 61 | MethodCodeType = MethodCodeType.Runtime)] 62 | void HrInit(); 63 | 64 | [MethodImpl(MethodImplOptions.InternalCall, 65 | MethodCodeType = MethodCodeType.Runtime)] 66 | void AddTab([In] IntPtr hwnd); 67 | 68 | [MethodImpl(MethodImplOptions.InternalCall, 69 | MethodCodeType = MethodCodeType.Runtime)] 70 | void DeleteTab([In] IntPtr hwnd); 71 | 72 | [MethodImpl(MethodImplOptions.InternalCall, 73 | MethodCodeType = MethodCodeType.Runtime)] 74 | void ActivateTab([In] IntPtr hwnd); 75 | 76 | [MethodImpl(MethodImplOptions.InternalCall, 77 | MethodCodeType = MethodCodeType.Runtime)] 78 | void SetActiveAlt([In] IntPtr hwnd); 79 | 80 | [MethodImpl(MethodImplOptions.InternalCall, 81 | MethodCodeType = MethodCodeType.Runtime)] 82 | void MarkFullscreenWindow([In] IntPtr hwnd, 83 | [In, MarshalAs(UnmanagedType.Bool)] bool fFullscreen); 84 | 85 | [MethodImpl(MethodImplOptions.InternalCall, 86 | MethodCodeType = MethodCodeType.Runtime)] 87 | void SetProgressValue([In] IntPtr hwnd, 88 | [In] ulong ullCompleted, 89 | [In] ulong ullTotal); 90 | 91 | [MethodImpl(MethodImplOptions.InternalCall, 92 | MethodCodeType = MethodCodeType.Runtime)] 93 | void SetProgressState([In] IntPtr hwnd, 94 | [In] TBPFLAG tbpFlags); 95 | 96 | [MethodImpl(MethodImplOptions.InternalCall, 97 | MethodCodeType = MethodCodeType.Runtime)] 98 | void RegisterTab([In] IntPtr hwndTab, 99 | [In] IntPtr hwndMDI); 100 | 101 | [MethodImpl(MethodImplOptions.InternalCall, 102 | MethodCodeType = MethodCodeType.Runtime)] 103 | void UnregisterTab([In] IntPtr hwndTab); 104 | 105 | [MethodImpl(MethodImplOptions.InternalCall, 106 | MethodCodeType = MethodCodeType.Runtime)] 107 | void SetTabOrder([In] IntPtr hwndTab, 108 | [In] IntPtr hwndInsertBefore); 109 | 110 | [MethodImpl(MethodImplOptions.InternalCall, 111 | MethodCodeType = MethodCodeType.Runtime)] 112 | void SetTabActive([In] IntPtr hwndTab, 113 | [In] IntPtr hwndMDI, 114 | [In] TBATFLAG tbatFlags); 115 | 116 | //preliminary 117 | [MethodImpl(MethodImplOptions.InternalCall, 118 | MethodCodeType = MethodCodeType.Runtime)] 119 | void ThumbBarAddButtons([In] IntPtr hwnd, 120 | [In] uint cButtons, 121 | [In] IntPtr pButton); 122 | ///* [size_is][in] */ __RPC__in_ecount_full(cButtons) LPTHUMBBUTTON pButton); 123 | 124 | //preliminary 125 | [MethodImpl(MethodImplOptions.InternalCall, 126 | MethodCodeType = MethodCodeType.Runtime)] 127 | void ThumbBarUpdateButtons([In] IntPtr hwnd, 128 | [In] uint cButtons, 129 | [In] IntPtr pButton); 130 | ///* [size_is][in] */ __RPC__in_ecount_full(cButtons) LPTHUMBBUTTON pButton); 131 | 132 | [MethodImpl(MethodImplOptions.InternalCall, 133 | MethodCodeType = MethodCodeType.Runtime)] 134 | void ThumbBarSetImageList([In] IntPtr hwnd, 135 | [In] IntPtr himl); 136 | 137 | [MethodImpl(MethodImplOptions.InternalCall, 138 | MethodCodeType = MethodCodeType.Runtime)] 139 | void SetOverlayIcon([In] IntPtr hwnd, 140 | [In] IntPtr hIcon, 141 | [In, MarshalAs(UnmanagedType.LPWStr)] string pszDescription); 142 | 143 | [MethodImpl(MethodImplOptions.InternalCall, 144 | MethodCodeType = MethodCodeType.Runtime)] 145 | void SetThumbnailTooltip([In] IntPtr hwnd, 146 | [In, MarshalAs(UnmanagedType.LPWStr)] string pszTip); 147 | 148 | //preliminary 149 | [MethodImpl(MethodImplOptions.InternalCall, 150 | MethodCodeType = MethodCodeType.Runtime)] 151 | void SetThumbnailClip([In] IntPtr hwnd, 152 | [In] IntPtr prcClip); 153 | 154 | } 155 | 156 | 157 | [ComImport] 158 | [Guid("56FDF344-FD6D-11d0-958A-006097C9A090")] 159 | internal class TaskbarList { } 160 | 161 | } 162 | -------------------------------------------------------------------------------- /nspector/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using System.Threading; 5 | using System.Windows.Forms; 6 | using nspector.Common; 7 | using nspector.Common.Helper; 8 | using nspector.Native.WINAPI; 9 | 10 | namespace nspector 11 | { 12 | static class Program 13 | { 14 | /// 15 | /// The main entry point for the application. 16 | /// 17 | [STAThread] 18 | static void Main(string[] args) 19 | { 20 | try 21 | { 22 | // Remove Zone.Identifier from Alternate Data Stream 23 | SafeNativeMethods.DeleteFile(Application.ExecutablePath + ":Zone.Identifier"); 24 | } 25 | catch { } 26 | #if RELEASE 27 | try 28 | { 29 | #endif 30 | Application.EnableVisualStyles(); 31 | Application.SetCompatibleTextRenderingDefault(false); 32 | DropDownMenuScrollWheelHandler.Enable(true); 33 | 34 | var argFileIndex = ArgFileIndex(args); 35 | if (argFileIndex != -1) 36 | { 37 | 38 | if (new FileInfo(args[argFileIndex]).Extension.ToLowerInvariant() == ".nip") 39 | { 40 | try 41 | { 42 | var import = DrsServiceLocator.ImportService; 43 | var importReport = import.ImportProfiles(args[argFileIndex]); 44 | GC.Collect(); 45 | Process current = Process.GetCurrentProcess(); 46 | foreach ( 47 | Process process in 48 | Process.GetProcessesByName(current.ProcessName.Replace(".vshost", ""))) 49 | { 50 | if (process.Id != current.Id && process.MainWindowTitle.Contains("Settings")) 51 | { 52 | MessageHelper mh = new MessageHelper(); 53 | mh.sendWindowsStringMessage((int)process.MainWindowHandle, 0, "ProfilesImported"); 54 | } 55 | } 56 | 57 | if (string.IsNullOrEmpty(importReport) && !ArgExists(args, "-silentImport") && !ArgExists(args, "-silent")) 58 | { 59 | frmDrvSettings.ShowImportDoneMessage(importReport); 60 | } 61 | } 62 | catch (Exception ex) 63 | { 64 | MessageBox.Show("Import Error: " + ex.Message, Application.ProductName + " Error", 65 | MessageBoxButtons.OK, MessageBoxIcon.Error); 66 | } 67 | } 68 | } 69 | 70 | else if (ArgExists(args, "-createCSN")) 71 | { 72 | File.WriteAllText("CustomSettingNames.xml", Properties.Resources.CustomSettingNames); 73 | } 74 | else 75 | { 76 | 77 | bool createdNew = true; 78 | using (Mutex mutex = new Mutex(true, Application.ProductName, out createdNew)) 79 | { 80 | if (createdNew) 81 | { 82 | Application.Run(new frmDrvSettings(ArgExists(args, "-showOnlyCSN"), ArgExists(args, "-disableScan"))); 83 | } 84 | else 85 | { 86 | Process current = Process.GetCurrentProcess(); 87 | foreach ( 88 | Process process in 89 | Process.GetProcessesByName(current.ProcessName.Replace(".vshost", ""))) 90 | { 91 | if (process.Id != current.Id && process.MainWindowTitle.Contains("Settings")) 92 | { 93 | MessageHelper mh = new MessageHelper(); 94 | mh.bringAppToFront((int)process.MainWindowHandle); 95 | } 96 | } 97 | } 98 | } 99 | } 100 | #if RELEASE 101 | 102 | } 103 | catch (Exception ex) 104 | { 105 | MessageBox.Show(ex.Message + "\r\n\r\n" + ex.StackTrace ,"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 106 | } 107 | #endif 108 | 109 | } 110 | 111 | static bool ArgExists(string[] args, string arg) 112 | { 113 | foreach (string a in args) 114 | { 115 | if (a.ToUpper() == arg.ToUpper()) 116 | return true; 117 | } 118 | return false; 119 | } 120 | 121 | static int ArgFileIndex(string[] args) 122 | { 123 | for (int i = 0; i < args.Length; i++) 124 | { 125 | if (File.Exists(args[i])) 126 | return i; 127 | } 128 | 129 | return -1; 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /nspector/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("nvidiaProfileInspector")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NVIDIA Profile Inspector")] 13 | [assembly: AssemblyCopyright("©2025 by Orbmu2k")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c2fe2861-54c5-4d63-968e-30472019bed3")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("2.4.0.1")] 36 | [assembly: AssemblyFileVersion("2.4.0.1")] 37 | 38 | 39 | -------------------------------------------------------------------------------- /nspector/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Dieser Code wurde von einem Tool generiert. 4 | // Laufzeitversion:4.0.30319.42000 5 | // 6 | // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn 7 | // der Code erneut generiert wird. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace nspector.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. 17 | /// 18 | // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert 19 | // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. 20 | // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen 21 | // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | public class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | public static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("nspector.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle 51 | /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | public static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. 65 | /// 66 | public static System.Drawing.Bitmap apply { 67 | get { 68 | object obj = ResourceManager.GetObject("apply", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// Sucht eine lokalisierte Zeichenfolge, die <?xml version="1.0" encoding="utf-8"?> 75 | ///<CustomSettingNames> 76 | /// <Settings> 77 | /// <CustomSetting> 78 | /// <UserfriendlyName>DLSS - Enable DLL Override</UserfriendlyName> 79 | /// <HexSettingID>0x10E41E01</HexSettingID> 80 | /// <GroupName>5 - Common</GroupName> 81 | /// <MinRequiredDriverVersion>0</MinRequiredDriverVersion> 82 | /// <SettingValues> 83 | /// <CustomSettingValue> 84 | /// <UserfriendlyName>Off</UserfriendlyName> 85 | /// <HexValue>0x00000000</HexValue> 86 | /// </CustomSettingValue> 87 | /// <CustomSettingValue> 88 | /// <UserfriendlyName>On [Rest der Zeichenfolge wurde abgeschnitten]"; ähnelt. 89 | /// 90 | public static string CustomSettingNames { 91 | get { 92 | return ResourceManager.GetString("CustomSettingNames", resourceCulture); 93 | } 94 | } 95 | 96 | /// 97 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. 98 | /// 99 | public static System.Drawing.Bitmap export1 { 100 | get { 101 | object obj = ResourceManager.GetObject("export1", resourceCulture); 102 | return ((System.Drawing.Bitmap)(obj)); 103 | } 104 | } 105 | 106 | /// 107 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. 108 | /// 109 | public static System.Drawing.Bitmap filter_user { 110 | get { 111 | object obj = ResourceManager.GetObject("filter_user", resourceCulture); 112 | return ((System.Drawing.Bitmap)(obj)); 113 | } 114 | } 115 | 116 | /// 117 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. 118 | /// 119 | public static System.Drawing.Bitmap find_set2 { 120 | get { 121 | object obj = ResourceManager.GetObject("find_set2", resourceCulture); 122 | return ((System.Drawing.Bitmap)(obj)); 123 | } 124 | } 125 | 126 | /// 127 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. 128 | /// 129 | public static System.Drawing.Bitmap home_sm { 130 | get { 131 | object obj = ResourceManager.GetObject("home_sm", resourceCulture); 132 | return ((System.Drawing.Bitmap)(obj)); 133 | } 134 | } 135 | 136 | /// 137 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol). 138 | /// 139 | public static System.Drawing.Icon Icon1 { 140 | get { 141 | object obj = ResourceManager.GetObject("Icon1", resourceCulture); 142 | return ((System.Drawing.Icon)(obj)); 143 | } 144 | } 145 | 146 | /// 147 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. 148 | /// 149 | public static System.Drawing.Bitmap ieframe_1_18212 { 150 | get { 151 | object obj = ResourceManager.GetObject("ieframe_1_18212", resourceCulture); 152 | return ((System.Drawing.Bitmap)(obj)); 153 | } 154 | } 155 | 156 | /// 157 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. 158 | /// 159 | public static System.Drawing.Bitmap ieframe_1_31073_002 { 160 | get { 161 | object obj = ResourceManager.GetObject("ieframe_1_31073_002", resourceCulture); 162 | return ((System.Drawing.Bitmap)(obj)); 163 | } 164 | } 165 | 166 | /// 167 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. 168 | /// 169 | public static System.Drawing.Bitmap import1 { 170 | get { 171 | object obj = ResourceManager.GetObject("import1", resourceCulture); 172 | return ((System.Drawing.Bitmap)(obj)); 173 | } 174 | } 175 | 176 | /// 177 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. 178 | /// 179 | public static System.Drawing.Bitmap n1_016 { 180 | get { 181 | object obj = ResourceManager.GetObject("n1-016", resourceCulture); 182 | return ((System.Drawing.Bitmap)(obj)); 183 | } 184 | } 185 | 186 | /// 187 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. 188 | /// 189 | public static System.Drawing.Bitmap nv_btn { 190 | get { 191 | object obj = ResourceManager.GetObject("nv_btn", resourceCulture); 192 | return ((System.Drawing.Bitmap)(obj)); 193 | } 194 | } 195 | 196 | /// 197 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. 198 | /// 199 | public static System.Drawing.Bitmap PortableDeviceStatus_3_16_011 { 200 | get { 201 | object obj = ResourceManager.GetObject("PortableDeviceStatus_3_16_011", resourceCulture); 202 | return ((System.Drawing.Bitmap)(obj)); 203 | } 204 | } 205 | 206 | /// 207 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol). 208 | /// 209 | public static System.Drawing.Icon shield16 { 210 | get { 211 | object obj = ResourceManager.GetObject("shield16", resourceCulture); 212 | return ((System.Drawing.Icon)(obj)); 213 | } 214 | } 215 | 216 | /// 217 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. 218 | /// 219 | public static System.Drawing.Bitmap text_binary { 220 | get { 221 | object obj = ResourceManager.GetObject("text_binary", resourceCulture); 222 | return ((System.Drawing.Bitmap)(obj)); 223 | } 224 | } 225 | 226 | /// 227 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. 228 | /// 229 | public static System.Drawing.Bitmap transparent16 { 230 | get { 231 | object obj = ResourceManager.GetObject("transparent16", resourceCulture); 232 | return ((System.Drawing.Bitmap)(obj)); 233 | } 234 | } 235 | 236 | /// 237 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. 238 | /// 239 | public static System.Drawing.Bitmap window_application_add { 240 | get { 241 | object obj = ResourceManager.GetObject("window_application_add", resourceCulture); 242 | return ((System.Drawing.Bitmap)(obj)); 243 | } 244 | } 245 | 246 | /// 247 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. 248 | /// 249 | public static System.Drawing.Bitmap window_application_delete { 250 | get { 251 | object obj = ResourceManager.GetObject("window_application_delete", resourceCulture); 252 | return ((System.Drawing.Bitmap)(obj)); 253 | } 254 | } 255 | } 256 | } 257 | -------------------------------------------------------------------------------- /nspector/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /nspector/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | true 13 | 14 | 15 | -------------------------------------------------------------------------------- /nspector/frmBitEditor.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace nspector 2 | { 3 | partial class frmBitEditor 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.btnClose = new System.Windows.Forms.Button(); 32 | this.lValue = new System.Windows.Forms.Label(); 33 | this.lFilter = new System.Windows.Forms.Label(); 34 | this.tbFilter = new System.Windows.Forms.TextBox(); 35 | this.textBox1 = new System.Windows.Forms.TextBox(); 36 | this.btnDirectApplyStart = new System.Windows.Forms.Button(); 37 | this.gbDirectTest = new System.Windows.Forms.GroupBox(); 38 | this.btnBrowseGame = new System.Windows.Forms.Button(); 39 | this.tbGamePath = new System.Windows.Forms.TextBox(); 40 | this.lblGamePath = new System.Windows.Forms.Label(); 41 | this.clbBits = new nspector.ListViewEx(); 42 | this.chBit = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 43 | this.chName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 44 | this.chProfileCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 45 | this.chProfileNames = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 46 | this.gbDirectTest.SuspendLayout(); 47 | this.SuspendLayout(); 48 | // 49 | // btnClose 50 | // 51 | this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 52 | this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; 53 | this.btnClose.Location = new System.Drawing.Point(731, 645); 54 | this.btnClose.Name = "btnClose"; 55 | this.btnClose.Size = new System.Drawing.Size(106, 23); 56 | this.btnClose.TabIndex = 1; 57 | this.btnClose.Text = "Apply && Close"; 58 | this.btnClose.UseVisualStyleBackColor = true; 59 | this.btnClose.Click += new System.EventHandler(this.btnClose_Click); 60 | // 61 | // lValue 62 | // 63 | this.lValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 64 | this.lValue.AutoSize = true; 65 | this.lValue.Location = new System.Drawing.Point(17, 650); 66 | this.lValue.Name = "lValue"; 67 | this.lValue.Size = new System.Drawing.Size(37, 13); 68 | this.lValue.TabIndex = 2; 69 | this.lValue.Text = "Value:"; 70 | // 71 | // lFilter 72 | // 73 | this.lFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 74 | this.lFilter.AutoSize = true; 75 | this.lFilter.Location = new System.Drawing.Point(150, 650); 76 | this.lFilter.Name = "lFilter"; 77 | this.lFilter.Size = new System.Drawing.Size(64, 13); 78 | this.lFilter.TabIndex = 23; 79 | this.lFilter.Text = "Profile Filter:"; 80 | // 81 | // tbFilter 82 | // 83 | this.tbFilter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 84 | | System.Windows.Forms.AnchorStyles.Right))); 85 | this.tbFilter.Location = new System.Drawing.Point(219, 647); 86 | this.tbFilter.Name = "tbFilter"; 87 | this.tbFilter.Size = new System.Drawing.Size(506, 20); 88 | this.tbFilter.TabIndex = 24; 89 | this.tbFilter.TextChanged += new System.EventHandler(this.tbFilter_TextChanged); 90 | // 91 | // textBox1 92 | // 93 | this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 94 | this.textBox1.Location = new System.Drawing.Point(59, 647); 95 | this.textBox1.Name = "textBox1"; 96 | this.textBox1.Size = new System.Drawing.Size(70, 20); 97 | this.textBox1.TabIndex = 31; 98 | this.textBox1.Text = "0x00FF00FF"; 99 | this.textBox1.Leave += new System.EventHandler(this.textBox1_Leave); 100 | this.textBox1.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.textBox1_PreviewKeyDown); 101 | // 102 | // btnDirectApplyStart 103 | // 104 | this.btnDirectApplyStart.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 105 | this.btnDirectApplyStart.Location = new System.Drawing.Point(5, 15); 106 | this.btnDirectApplyStart.Name = "btnDirectApplyStart"; 107 | this.btnDirectApplyStart.Size = new System.Drawing.Size(84, 34); 108 | this.btnDirectApplyStart.TabIndex = 32; 109 | this.btnDirectApplyStart.Text = "GO!"; 110 | this.btnDirectApplyStart.UseVisualStyleBackColor = true; 111 | this.btnDirectApplyStart.Click += new System.EventHandler(this.btnDirectApply_Click); 112 | // 113 | // gbDirectTest 114 | // 115 | this.gbDirectTest.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 116 | | System.Windows.Forms.AnchorStyles.Right))); 117 | this.gbDirectTest.Controls.Add(this.btnBrowseGame); 118 | this.gbDirectTest.Controls.Add(this.tbGamePath); 119 | this.gbDirectTest.Controls.Add(this.lblGamePath); 120 | this.gbDirectTest.Controls.Add(this.btnDirectApplyStart); 121 | this.gbDirectTest.Location = new System.Drawing.Point(14, 586); 122 | this.gbDirectTest.Name = "gbDirectTest"; 123 | this.gbDirectTest.Size = new System.Drawing.Size(823, 53); 124 | this.gbDirectTest.TabIndex = 33; 125 | this.gbDirectTest.TabStop = false; 126 | this.gbDirectTest.Text = "Quick Bit Value Tester (stores this setting value to the current profile and imme" + 127 | "diately starts the game when successful)"; 128 | // 129 | // btnBrowseGame 130 | // 131 | this.btnBrowseGame.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 132 | this.btnBrowseGame.Location = new System.Drawing.Point(777, 19); 133 | this.btnBrowseGame.Name = "btnBrowseGame"; 134 | this.btnBrowseGame.Size = new System.Drawing.Size(33, 23); 135 | this.btnBrowseGame.TabIndex = 35; 136 | this.btnBrowseGame.Text = "..."; 137 | this.btnBrowseGame.UseVisualStyleBackColor = true; 138 | this.btnBrowseGame.Click += new System.EventHandler(this.btnBrowseGame_Click); 139 | // 140 | // tbGamePath 141 | // 142 | this.tbGamePath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 143 | | System.Windows.Forms.AnchorStyles.Right))); 144 | this.tbGamePath.Location = new System.Drawing.Point(174, 21); 145 | this.tbGamePath.Name = "tbGamePath"; 146 | this.tbGamePath.Size = new System.Drawing.Size(597, 20); 147 | this.tbGamePath.TabIndex = 34; 148 | // 149 | // lblGamePath 150 | // 151 | this.lblGamePath.AutoSize = true; 152 | this.lblGamePath.Location = new System.Drawing.Point(95, 23); 153 | this.lblGamePath.Name = "lblGamePath"; 154 | this.lblGamePath.Size = new System.Drawing.Size(73, 13); 155 | this.lblGamePath.TabIndex = 33; 156 | this.lblGamePath.Text = "Game to start:"; 157 | // 158 | // clbBits 159 | // 160 | this.clbBits.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 161 | | System.Windows.Forms.AnchorStyles.Left) 162 | | System.Windows.Forms.AnchorStyles.Right))); 163 | this.clbBits.CheckBoxes = true; 164 | this.clbBits.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { 165 | this.chBit, 166 | this.chName, 167 | this.chProfileCount, 168 | this.chProfileNames}); 169 | this.clbBits.FullRowSelect = true; 170 | this.clbBits.GridLines = true; 171 | this.clbBits.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; 172 | this.clbBits.HideSelection = false; 173 | this.clbBits.Location = new System.Drawing.Point(10, 10); 174 | this.clbBits.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 175 | this.clbBits.MultiSelect = false; 176 | this.clbBits.Name = "clbBits"; 177 | this.clbBits.ShowGroups = false; 178 | this.clbBits.Size = new System.Drawing.Size(829, 572); 179 | this.clbBits.TabIndex = 34; 180 | this.clbBits.UseCompatibleStateImageBehavior = false; 181 | this.clbBits.View = System.Windows.Forms.View.Details; 182 | this.clbBits.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.clbBits_ItemCheck); 183 | // 184 | // chBit 185 | // 186 | this.chBit.Text = "Bit"; 187 | // 188 | // chName 189 | // 190 | this.chName.Text = "Name"; 191 | this.chName.Width = 200; 192 | // 193 | // chProfileCount 194 | // 195 | this.chProfileCount.Text = "Count"; 196 | // 197 | // chProfileNames 198 | // 199 | this.chProfileNames.Text = "Profiles"; 200 | this.chProfileNames.Width = 4000; 201 | // 202 | // frmBitEditor 203 | // 204 | this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); 205 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; 206 | this.ClientSize = new System.Drawing.Size(847, 678); 207 | this.Controls.Add(this.clbBits); 208 | this.Controls.Add(this.gbDirectTest); 209 | this.Controls.Add(this.textBox1); 210 | this.Controls.Add(this.tbFilter); 211 | this.Controls.Add(this.lFilter); 212 | this.Controls.Add(this.lValue); 213 | this.Controls.Add(this.btnClose); 214 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; 215 | this.MinimumSize = new System.Drawing.Size(686, 495); 216 | this.Name = "frmBitEditor"; 217 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 218 | this.Text = "Bit Value Editor"; 219 | this.Load += new System.EventHandler(this.frmBitEditor_Load); 220 | this.gbDirectTest.ResumeLayout(false); 221 | this.gbDirectTest.PerformLayout(); 222 | this.ResumeLayout(false); 223 | this.PerformLayout(); 224 | 225 | } 226 | 227 | #endregion 228 | private System.Windows.Forms.Button btnClose; 229 | private System.Windows.Forms.Label lValue; 230 | private System.Windows.Forms.Label lFilter; 231 | private System.Windows.Forms.TextBox tbFilter; 232 | private System.Windows.Forms.TextBox textBox1; 233 | private System.Windows.Forms.Button btnDirectApplyStart; 234 | private System.Windows.Forms.GroupBox gbDirectTest; 235 | private System.Windows.Forms.Button btnBrowseGame; 236 | private System.Windows.Forms.TextBox tbGamePath; 237 | private System.Windows.Forms.Label lblGamePath; 238 | private ListViewEx clbBits; 239 | private System.Windows.Forms.ColumnHeader chBit; 240 | private System.Windows.Forms.ColumnHeader chProfileCount; 241 | private System.Windows.Forms.ColumnHeader chName; 242 | private System.Windows.Forms.ColumnHeader chProfileNames; 243 | } 244 | } -------------------------------------------------------------------------------- /nspector/frmBitEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Drawing; 4 | using System.Globalization; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | using System.Windows.Forms; 9 | using nspector.Common; 10 | using nspector.Common.CustomSettings; 11 | 12 | namespace nspector 13 | { 14 | internal partial class frmBitEditor : Form 15 | { 16 | private uint _Settingid = 0; 17 | private frmDrvSettings _SettingsOwner = null; 18 | private uint _InitValue = 0; 19 | private uint _CurrentValue = 0; 20 | 21 | 22 | internal frmBitEditor() 23 | { 24 | InitializeComponent(); 25 | this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); 26 | this.DoubleBuffered = true; 27 | } 28 | 29 | internal void ShowDialog(frmDrvSettings SettingsOwner, uint SettingId, uint InitValue, string SettingName) 30 | { 31 | _Settingid = SettingId; 32 | _SettingsOwner = SettingsOwner; 33 | _InitValue = InitValue; 34 | Text = string.Format("Bit Value Editor - {0}", SettingName); 35 | this.ShowDialog(SettingsOwner); 36 | } 37 | 38 | private void frmBitEditor_Load(object sender, EventArgs e) 39 | { 40 | SplitBitsFromUnknownSettings(); 41 | clbBits.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); 42 | SetValue(_InitValue); 43 | } 44 | 45 | private void SplitBitsFromUnknownSettings() 46 | { 47 | uint lastValue = 0; 48 | lastValue = _CurrentValue; 49 | string[] filters = tbFilter.Text.Split(','); 50 | clbBits.Items.Clear(); 51 | 52 | var referenceSettings = DrsServiceLocator.ReferenceSettings?.Settings.FirstOrDefault(s => s.SettingId == _Settingid); 53 | 54 | var settingsCache = DrsServiceLocator.ScannerService.CachedSettings.FirstOrDefault(x => x.SettingId == _Settingid); 55 | 56 | for (int bit = 0; bit < 32; bit++) 57 | { 58 | string profileNames = ""; 59 | uint profileCount = 0; 60 | 61 | if (settingsCache != null) 62 | { 63 | 64 | for (int i = 0; i < settingsCache.SettingValues.Count; i++) 65 | { 66 | if (((settingsCache.SettingValues[i].Value >> bit) & 0x1) == 0x1) 67 | { 68 | if (filters.Length == 0) 69 | { 70 | profileNames += settingsCache.SettingValues[i].ProfileNames + ","; 71 | } 72 | else 73 | { 74 | string[] settingProfileNames = settingsCache.SettingValues[i].ProfileNames.ToString().Split(','); 75 | for (int p = 0; p < settingProfileNames.Length; p++) 76 | { 77 | for (int f = 0; f < filters.Length; f++) 78 | { 79 | if (settingProfileNames[p].ToLowerInvariant().Contains(filters[f].ToLower())) 80 | { 81 | profileNames += settingProfileNames[p] + ","; 82 | } 83 | } 84 | } 85 | } 86 | profileCount += settingsCache.SettingValues[i].ValueProfileCount; 87 | } 88 | } 89 | } 90 | 91 | uint mask = (uint)1 << bit; 92 | string maskStr = ""; 93 | 94 | if (referenceSettings != null) 95 | { 96 | var maskValue = referenceSettings.SettingValues.FirstOrDefault(v => v.SettingValue == mask); 97 | if (maskValue != null) 98 | { 99 | maskStr = maskValue.UserfriendlyName; 100 | if (maskStr.Contains("(")) 101 | { 102 | maskStr = maskStr.Substring(0, maskStr.IndexOf("(") - 1); 103 | } 104 | } 105 | } 106 | 107 | clbBits.Items.Add(new ListViewItem(new string[] { 108 | string.Format("#{0:00}",bit), 109 | maskStr, 110 | profileCount.ToString(), 111 | profileNames, 112 | })); 113 | 114 | 115 | } 116 | 117 | SetValue(lastValue); 118 | } 119 | 120 | private void updateValue(bool changeState, int changedIndex) 121 | { 122 | uint val = 0; 123 | for (int b = 0; b < clbBits.Items.Count; b++) 124 | { 125 | if (((clbBits.Items[b].Checked) && changedIndex != b) || (changeState && (changedIndex == b))) 126 | { 127 | val = (uint)((uint)val | (uint)(1 << b)); 128 | } 129 | } 130 | 131 | UpdateCurrent(val); 132 | } 133 | 134 | private void UpdateValue() 135 | { 136 | uint val = 0; 137 | for (int b = 0; b < clbBits.Items.Count; b++) 138 | { 139 | if (clbBits.Items[b].Checked) 140 | { 141 | val = (uint)((uint)val | (uint)(1 << b)); 142 | } 143 | } 144 | 145 | UpdateCurrent(val); 146 | } 147 | 148 | 149 | private void SetValue(uint val) 150 | { 151 | for (int b = 0; b < clbBits.Items.Count; b++) 152 | { 153 | if (((val >> b) & 0x1) == 0x1) 154 | clbBits.Items[b].Checked = true; 155 | else 156 | clbBits.Items[b].Checked = false; 157 | } 158 | 159 | UpdateValue(); 160 | } 161 | 162 | private void UpdateCurrent(uint val) 163 | { 164 | _CurrentValue = val; 165 | textBox1.Text = "0x" + (val).ToString("X8"); 166 | } 167 | 168 | private void UpdateCurrent(string text) 169 | { 170 | uint val = DrsUtil.ParseDwordByInputSafe(text); 171 | UpdateCurrent(val); 172 | SetValue(val); 173 | } 174 | 175 | private void clbBits_ItemCheck(object sender, ItemCheckEventArgs e) 176 | { 177 | updateValue(e.NewValue == CheckState.Checked, e.Index); 178 | } 179 | 180 | private void btnClose_Click(object sender, EventArgs e) 181 | { 182 | _SettingsOwner.SetSelectedDwordValue(_CurrentValue); 183 | Close(); 184 | } 185 | 186 | private void tbFilter_TextChanged(object sender, EventArgs e) 187 | { 188 | SplitBitsFromUnknownSettings(); 189 | } 190 | 191 | private void numericUpDown1_ValueChanged(object sender, EventArgs e) 192 | { 193 | SplitBitsFromUnknownSettings(); 194 | } 195 | 196 | private void textBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) 197 | { 198 | if (e.KeyValue == 13) 199 | { 200 | UpdateCurrent(textBox1.Text); 201 | } 202 | } 203 | 204 | private void textBox1_Leave(object sender, EventArgs e) 205 | { 206 | UpdateCurrent(textBox1.Text); 207 | } 208 | 209 | 210 | private void ApplyValueToProfile(uint val) 211 | { 212 | DrsServiceLocator 213 | .SettingService 214 | .SetDwordValueToProfile(_SettingsOwner._CurrentProfile, _Settingid, val); 215 | } 216 | 217 | private async void btnDirectApply_Click(object sender, EventArgs e) 218 | { 219 | ApplyValueToProfile(_CurrentValue); 220 | 221 | await CheckIfSettingIsStored(); 222 | 223 | if (File.Exists(tbGamePath.Text)) 224 | { 225 | Process.Start(tbGamePath.Text); 226 | } 227 | } 228 | 229 | private async Task CheckIfSettingIsStored() 230 | { 231 | await Task.Run(async () => 232 | { 233 | while (_CurrentValue != DrsServiceLocator.SettingService 234 | .GetDwordValueFromProfile(_SettingsOwner._CurrentProfile, _Settingid, false, true)) 235 | { 236 | await Task.Delay(50); 237 | } 238 | }); 239 | } 240 | 241 | private void btnBrowseGame_Click(object sender, EventArgs e) 242 | { 243 | OpenFileDialog ofd = new OpenFileDialog(); 244 | ofd.DefaultExt = "*.exe"; 245 | ofd.Filter = "Applications|*.exe"; 246 | ofd.DereferenceLinks = false; 247 | 248 | if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) 249 | { 250 | tbGamePath.Text = ofd.FileName; 251 | } 252 | } 253 | 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /nspector/frmBitEditor.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /nspector/frmExportProfiles.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace nspector 2 | { 3 | partial class frmExportProfiles 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.lvProfiles = new System.Windows.Forms.ListView(); 32 | this.chProfileName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 33 | this.lProfiles = new System.Windows.Forms.Label(); 34 | this.btnExport = new System.Windows.Forms.Button(); 35 | this.btnCancel = new System.Windows.Forms.Button(); 36 | this.btnSelAll = new System.Windows.Forms.Button(); 37 | this.btnSelNone = new System.Windows.Forms.Button(); 38 | this.btnInvertSelection = new System.Windows.Forms.Button(); 39 | this.cbIncludePredefined = new System.Windows.Forms.CheckBox(); 40 | this.SuspendLayout(); 41 | // 42 | // lvProfiles 43 | // 44 | this.lvProfiles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 45 | | System.Windows.Forms.AnchorStyles.Left) 46 | | System.Windows.Forms.AnchorStyles.Right))); 47 | this.lvProfiles.CheckBoxes = true; 48 | this.lvProfiles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { 49 | this.chProfileName}); 50 | this.lvProfiles.FullRowSelect = true; 51 | this.lvProfiles.GridLines = true; 52 | this.lvProfiles.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; 53 | this.lvProfiles.Location = new System.Drawing.Point(12, 40); 54 | this.lvProfiles.MultiSelect = false; 55 | this.lvProfiles.Name = "lvProfiles"; 56 | this.lvProfiles.Size = new System.Drawing.Size(492, 382); 57 | this.lvProfiles.Sorting = System.Windows.Forms.SortOrder.Ascending; 58 | this.lvProfiles.TabIndex = 0; 59 | this.lvProfiles.UseCompatibleStateImageBehavior = false; 60 | this.lvProfiles.View = System.Windows.Forms.View.Details; 61 | this.lvProfiles.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.lvProfiles_ItemChecked); 62 | // 63 | // chProfileName 64 | // 65 | this.chProfileName.Text = "ProfileName"; 66 | this.chProfileName.Width = 420; 67 | // 68 | // lProfiles 69 | // 70 | this.lProfiles.AutoSize = true; 71 | this.lProfiles.Location = new System.Drawing.Point(9, 12); 72 | this.lProfiles.Name = "lProfiles"; 73 | this.lProfiles.Size = new System.Drawing.Size(184, 13); 74 | this.lProfiles.TabIndex = 1; 75 | this.lProfiles.Text = "Select the profiles you want to export:"; 76 | // 77 | // btnExport 78 | // 79 | this.btnExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 80 | this.btnExport.Enabled = false; 81 | this.btnExport.Location = new System.Drawing.Point(429, 451); 82 | this.btnExport.Name = "btnExport"; 83 | this.btnExport.Size = new System.Drawing.Size(75, 23); 84 | this.btnExport.TabIndex = 2; 85 | this.btnExport.Text = "Export"; 86 | this.btnExport.UseVisualStyleBackColor = true; 87 | this.btnExport.Click += new System.EventHandler(this.btnExport_Click); 88 | // 89 | // btnCancel 90 | // 91 | this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 92 | this.btnCancel.Location = new System.Drawing.Point(348, 451); 93 | this.btnCancel.Name = "btnCancel"; 94 | this.btnCancel.Size = new System.Drawing.Size(75, 23); 95 | this.btnCancel.TabIndex = 3; 96 | this.btnCancel.Text = "Cancel"; 97 | this.btnCancel.UseVisualStyleBackColor = true; 98 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); 99 | // 100 | // btnSelAll 101 | // 102 | this.btnSelAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 103 | this.btnSelAll.Location = new System.Drawing.Point(12, 451); 104 | this.btnSelAll.Name = "btnSelAll"; 105 | this.btnSelAll.Size = new System.Drawing.Size(75, 23); 106 | this.btnSelAll.TabIndex = 4; 107 | this.btnSelAll.Text = "Select All"; 108 | this.btnSelAll.UseVisualStyleBackColor = true; 109 | this.btnSelAll.Click += new System.EventHandler(this.btnSelAll_Click); 110 | // 111 | // btnSelNone 112 | // 113 | this.btnSelNone.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 114 | this.btnSelNone.Location = new System.Drawing.Point(93, 451); 115 | this.btnSelNone.Name = "btnSelNone"; 116 | this.btnSelNone.Size = new System.Drawing.Size(75, 23); 117 | this.btnSelNone.TabIndex = 4; 118 | this.btnSelNone.Text = "Select None"; 119 | this.btnSelNone.UseVisualStyleBackColor = true; 120 | this.btnSelNone.Click += new System.EventHandler(this.btnSelNone_Click); 121 | // 122 | // btnInvertSelection 123 | // 124 | this.btnInvertSelection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 125 | this.btnInvertSelection.Location = new System.Drawing.Point(174, 451); 126 | this.btnInvertSelection.Name = "btnInvertSelection"; 127 | this.btnInvertSelection.Size = new System.Drawing.Size(100, 23); 128 | this.btnInvertSelection.TabIndex = 4; 129 | this.btnInvertSelection.Text = "Invert Selection"; 130 | this.btnInvertSelection.UseVisualStyleBackColor = true; 131 | this.btnInvertSelection.Click += new System.EventHandler(this.btnInvertSelection_Click); 132 | // 133 | // cbIncludePredefined 134 | // 135 | this.cbIncludePredefined.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 136 | this.cbIncludePredefined.AutoSize = true; 137 | this.cbIncludePredefined.Location = new System.Drawing.Point(12, 428); 138 | this.cbIncludePredefined.Name = "cbIncludePredefined"; 139 | this.cbIncludePredefined.Size = new System.Drawing.Size(153, 17); 140 | this.cbIncludePredefined.TabIndex = 5; 141 | this.cbIncludePredefined.Text = "Include predefined settings"; 142 | this.cbIncludePredefined.UseVisualStyleBackColor = true; 143 | // 144 | // frmExportProfiles 145 | // 146 | this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); 147 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; 148 | this.ClientSize = new System.Drawing.Size(516, 487); 149 | this.Controls.Add(this.cbIncludePredefined); 150 | this.Controls.Add(this.btnInvertSelection); 151 | this.Controls.Add(this.btnSelNone); 152 | this.Controls.Add(this.btnSelAll); 153 | this.Controls.Add(this.btnCancel); 154 | this.Controls.Add(this.btnExport); 155 | this.Controls.Add(this.lProfiles); 156 | this.Controls.Add(this.lvProfiles); 157 | this.MaximizeBox = false; 158 | this.MinimizeBox = false; 159 | this.MinimumSize = new System.Drawing.Size(464, 319); 160 | this.Name = "frmExportProfiles"; 161 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 162 | this.Text = "frmExportProfiles"; 163 | this.ResumeLayout(false); 164 | this.PerformLayout(); 165 | 166 | } 167 | 168 | #endregion 169 | 170 | private System.Windows.Forms.ListView lvProfiles; 171 | private System.Windows.Forms.ColumnHeader chProfileName; 172 | private System.Windows.Forms.Label lProfiles; 173 | private System.Windows.Forms.Button btnExport; 174 | private System.Windows.Forms.Button btnCancel; 175 | private System.Windows.Forms.Button btnSelAll; 176 | private System.Windows.Forms.Button btnSelNone; 177 | private System.Windows.Forms.Button btnInvertSelection; 178 | private System.Windows.Forms.CheckBox cbIncludePredefined; 179 | } 180 | } -------------------------------------------------------------------------------- /nspector/frmExportProfiles.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Text; 5 | using System.Windows.Forms; 6 | using nspector.Common; 7 | using nspector.Common.Helper; 8 | using nspector.Common.Import; 9 | 10 | namespace nspector 11 | { 12 | internal partial class frmExportProfiles : Form 13 | { 14 | frmDrvSettings settingsOwner = null; 15 | 16 | internal frmExportProfiles() 17 | { 18 | InitializeComponent(); 19 | this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); 20 | this.DoubleBuffered = true; 21 | } 22 | 23 | internal void ShowDialog(frmDrvSettings SettingsOwner) 24 | { 25 | settingsOwner = SettingsOwner; 26 | Text = "Profile Export"; 27 | updateProfileList(); 28 | this.ShowDialog(); 29 | } 30 | 31 | 32 | private void updateProfileList() 33 | { 34 | lvProfiles.Items.Clear(); 35 | 36 | if (settingsOwner != null) 37 | { 38 | foreach(string mp in DrsServiceLocator.ScannerService.ModifiedProfiles) 39 | { 40 | lvProfiles.Items.Add(mp); 41 | } 42 | } 43 | } 44 | 45 | 46 | private void btnCancel_Click(object sender, EventArgs e) 47 | { 48 | Close(); 49 | } 50 | 51 | private void btnSelAll_Click(object sender, EventArgs e) 52 | { 53 | for(int i=0;i(); 83 | for (int i = 0; i < lvProfiles.Items.Count; i++) 84 | { 85 | if (lvProfiles.Items[i].Checked) 86 | { 87 | profileNamesToExport.Add(lvProfiles.Items[i].Text); 88 | } 89 | } 90 | 91 | DrsServiceLocator.ImportService.ExportProfiles(profileNamesToExport, sfd.FileName, cbIncludePredefined.Checked); 92 | 93 | if (profileNamesToExport.Count > 0) 94 | { 95 | if (MessageBox.Show("Export succeeded.\r\n\r\nWould you like to continue exporting profiles?", "Profiles Export", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No) 96 | Close(); 97 | } 98 | else 99 | MessageBox.Show("Nothing to export"); 100 | } 101 | } 102 | 103 | private void lvProfiles_ItemChecked(object sender, ItemCheckedEventArgs e) 104 | { 105 | int cc = 0; 106 | for (int i = 0; i < lvProfiles.Items.Count;i++ ) 107 | if (lvProfiles.Items[i].Checked) 108 | cc++; 109 | 110 | if (cc > 0) 111 | btnExport.Enabled = true; 112 | else 113 | btnExport.Enabled = false; 114 | } 115 | 116 | 117 | 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /nspector/frmExportProfiles.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /nspector/n1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orbmu2k/nvidiaProfileInspector/0cbafd18a3480f65c98bc39c480bd16ab34ba1eb/nspector/n1.ico -------------------------------------------------------------------------------- /nvidiaProfileInspector.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32929.385 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nvidiaProfileInspector", "nspector\nvidiaProfileInspector.csproj", "{27B20027-E783-4ADC-AF16-40A49463F4BF}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {27B20027-E783-4ADC-AF16-40A49463F4BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {27B20027-E783-4ADC-AF16-40A49463F4BF}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {27B20027-E783-4ADC-AF16-40A49463F4BF}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {27B20027-E783-4ADC-AF16-40A49463F4BF}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {7FB061B1-515F-4B0E-B49F-552DFCA05527} 24 | EndGlobalSection 25 | EndGlobal 26 | --------------------------------------------------------------------------------