mirror of
https://github.com/Orbmu2k/nvidiaProfileInspector.git
synced 2026-01-14 01:38:11 -05:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84749fdf5f | ||
|
|
b651dae816 | ||
|
|
0a27ce1c36 | ||
|
|
499cdde758 | ||
|
|
cedcd4e2c6 | ||
|
|
5301c52c16 |
@@ -31,7 +31,11 @@ namespace nspector.Common
|
||||
|
||||
public DrsDecrypterService(DrsSettingsMetaService metaService) : base(metaService)
|
||||
{
|
||||
CreateInternalSettingMap();
|
||||
try
|
||||
{
|
||||
CreateInternalSettingMap();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private uint GetDwordFromKey(uint offset)
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace nspector.Common
|
||||
{
|
||||
LoadSettingsFileEx(hSession, filename);
|
||||
SaveSettings(hSession);
|
||||
});
|
||||
}, forceNonGlobalSession: true, preventLoadSettings: true);
|
||||
}
|
||||
|
||||
internal void ExportProfiles(List<string> profileNames, string filename, bool includePredefined)
|
||||
|
||||
@@ -14,12 +14,12 @@ namespace nspector.Common
|
||||
private static object _Sync = new object();
|
||||
|
||||
|
||||
public static T DrsSession<T>(Func<IntPtr, T> action, bool forceNonGlobalSession = false)
|
||||
public static T DrsSession<T>(Func<IntPtr, T> action, bool forceNonGlobalSession = false, bool preventLoadSettings = false)
|
||||
{
|
||||
lock (_Sync)
|
||||
{
|
||||
if (!HoldSession || forceNonGlobalSession)
|
||||
return NonGlobalDrsSession<T>(action);
|
||||
return NonGlobalDrsSession<T>(action, preventLoadSettings);
|
||||
|
||||
|
||||
if (GlobalSession == IntPtr.Zero)
|
||||
@@ -31,10 +31,13 @@ namespace nspector.Common
|
||||
|
||||
if (csRes != NvAPI_Status.NVAPI_OK)
|
||||
throw new NvapiException("DRS_CreateSession", csRes);
|
||||
|
||||
var nvRes = nvw.DRS_LoadSettings(GlobalSession);
|
||||
if (nvRes != NvAPI_Status.NVAPI_OK)
|
||||
throw new NvapiException("DRS_LoadSettings", nvRes);
|
||||
|
||||
if (!preventLoadSettings)
|
||||
{
|
||||
var nvRes = nvw.DRS_LoadSettings(GlobalSession);
|
||||
if (nvRes != NvAPI_Status.NVAPI_OK)
|
||||
throw new NvapiException("DRS_LoadSettings", nvRes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +61,7 @@ namespace nspector.Common
|
||||
}
|
||||
}
|
||||
|
||||
private static T NonGlobalDrsSession<T>(Func<IntPtr, T> action)
|
||||
private static T NonGlobalDrsSession<T>(Func<IntPtr, T> action, bool preventLoadSettings = false)
|
||||
{
|
||||
IntPtr hSession = IntPtr.Zero;
|
||||
var csRes = nvw.DRS_CreateSession(ref hSession);
|
||||
@@ -67,9 +70,12 @@ namespace nspector.Common
|
||||
|
||||
try
|
||||
{
|
||||
var nvRes = nvw.DRS_LoadSettings(hSession);
|
||||
if (nvRes != NvAPI_Status.NVAPI_OK)
|
||||
throw new NvapiException("DRS_LoadSettings", nvRes);
|
||||
if (!preventLoadSettings)
|
||||
{
|
||||
var nvRes = nvw.DRS_LoadSettings(hSession);
|
||||
if (nvRes != NvAPI_Status.NVAPI_OK)
|
||||
throw new NvapiException("DRS_LoadSettings", nvRes);
|
||||
}
|
||||
|
||||
return action(hSession);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,22 @@ namespace nspector.Common
|
||||
|
||||
private string GetDrsProgramPath()
|
||||
{
|
||||
var nvidiaInstallerFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"NVIDIA Corporation\Installer2");
|
||||
var driverFolders = Directory.EnumerateDirectories(nvidiaInstallerFolder, "Display.Driver.*");
|
||||
foreach (var folder in driverFolders)
|
||||
{
|
||||
var fiDbInstaller = new FileInfo(Path.Combine(folder, "dbInstaller.exe"));
|
||||
if (!fiDbInstaller.Exists) continue;
|
||||
|
||||
var fviDbInstaller = FileVersionInfo.GetVersionInfo(fiDbInstaller.FullName);
|
||||
|
||||
var fileversion = fviDbInstaller.FileVersion.Replace(".", "");
|
||||
var driverver = DriverVersion.ToString().Replace(",","").Replace(".","");
|
||||
|
||||
if (fileversion.EndsWith(driverver))
|
||||
return fiDbInstaller.DirectoryName;
|
||||
}
|
||||
|
||||
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
|
||||
@"NVIDIA Corporation\Drs");
|
||||
}
|
||||
|
||||
@@ -41,13 +41,13 @@ namespace nspector.Common
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void DrsSession(Action<IntPtr> action)
|
||||
protected void DrsSession(Action<IntPtr> action, bool forceNonGlobalSession = false, bool preventLoadSettings = false)
|
||||
{
|
||||
DrsSessionScope.DrsSession<bool>((hSession) =>
|
||||
{
|
||||
action(hSession);
|
||||
return true;
|
||||
});
|
||||
}, forceNonGlobalSession: forceNonGlobalSession, preventLoadSettings: preventLoadSettings);
|
||||
}
|
||||
|
||||
protected T DrsSession<T>(Func<IntPtr, T> action, bool forceDedicatedScope = false)
|
||||
|
||||
@@ -19,6 +19,9 @@ namespace nspector.Common.Helper
|
||||
|
||||
private static string GetSettingsFilename()
|
||||
{
|
||||
var fiPortalbleSettings = new FileInfo("settings.xml");
|
||||
if (fiPortalbleSettings.Exists) return fiPortalbleSettings.FullName;
|
||||
|
||||
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Application.ProductName);
|
||||
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
|
||||
return Path.Combine(path, "settings.xml"); ;
|
||||
|
||||
@@ -2,6 +2,22 @@
|
||||
<CustomSettingNames>
|
||||
<ShowCustomizedSettingNamesOnly>false</ShowCustomizedSettingNamesOnly>
|
||||
<Settings>
|
||||
<CustomSetting>
|
||||
<UserfriendlyName>Enable Ansel</UserfriendlyName>
|
||||
<HexSettingID>0x1075D972</HexSettingID>
|
||||
<Description />
|
||||
<GroupName>5 - Common</GroupName>
|
||||
<SettingValues>
|
||||
<CustomSettingValue>
|
||||
<UserfriendlyName>Off</UserfriendlyName>
|
||||
<HexValue>0x00000000</HexValue>
|
||||
</CustomSettingValue>
|
||||
<CustomSettingValue>
|
||||
<UserfriendlyName>On</UserfriendlyName>
|
||||
<HexValue>0x00000001</HexValue>
|
||||
</CustomSettingValue>
|
||||
</SettingValues>
|
||||
</CustomSetting>
|
||||
<CustomSetting>
|
||||
<UserfriendlyName>Sharpening Filter</UserfriendlyName>
|
||||
<HexSettingID>0x00598928</HexSettingID>
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("NVIDIA Profile Inspector")]
|
||||
[assembly: AssemblyCopyright("©2019 by Orbmu2k")]
|
||||
[assembly: AssemblyCopyright("©2020 by Orbmu2k")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
||||
1
nspector/frmDrvSettings.Designer.cs
generated
1
nspector/frmDrvSettings.Designer.cs
generated
@@ -515,6 +515,7 @@
|
||||
this.lvSettings.SelectedIndexChanged += new System.EventHandler(this.lvSettings_SelectedIndexChanged);
|
||||
this.lvSettings.DoubleClick += new System.EventHandler(this.lvSettings_DoubleClick);
|
||||
this.lvSettings.Resize += new System.EventHandler(this.lvSettings_Resize);
|
||||
this.lvSettings.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lvSettings_KeyDown);
|
||||
//
|
||||
// chSettingID
|
||||
//
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
@@ -667,7 +668,19 @@ namespace nspector
|
||||
private async Task ScanProfilesSilentAsync(bool scanPredefined, bool showProfileDialog)
|
||||
{
|
||||
if (_skipScan)
|
||||
{
|
||||
|
||||
if (scanPredefined && !_alreadyScannedForPredefinedSettings)
|
||||
{
|
||||
_alreadyScannedForPredefinedSettings = true;
|
||||
_meta.ResetMetaCache();
|
||||
tsbModifiedProfiles.Enabled = true;
|
||||
exportUserdefinedProfilesToolStripMenuItem.Enabled = false;
|
||||
RefreshCurrentProfile();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
tsbModifiedProfiles.Enabled = false;
|
||||
tsbRefreshProfile.Enabled = false;
|
||||
@@ -813,7 +826,7 @@ namespace nspector
|
||||
new Thread(SetTaskbarIcon).Start();
|
||||
await ScanProfilesSilentAsync(true, false);
|
||||
|
||||
if (!_scannerCancelationTokenSource.Token.IsCancellationRequested && WindowState != FormWindowState.Maximized)
|
||||
if (_scannerCancelationTokenSource != null && !_scannerCancelationTokenSource.Token.IsCancellationRequested && WindowState != FormWindowState.Maximized)
|
||||
{
|
||||
new MessageHelper().bringAppToFront((int)this.Handle);
|
||||
}
|
||||
@@ -1032,6 +1045,7 @@ namespace nspector
|
||||
{
|
||||
_import.ImportAllProfilesFromNvidiaTextFile(openDialog.FileName);
|
||||
MessageBox.Show("Profile(s) successfully imported!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DrsSessionScope.DestroyGlobalSession();
|
||||
RefreshAll();
|
||||
}
|
||||
catch (NvapiException)
|
||||
@@ -1184,6 +1198,39 @@ namespace nspector
|
||||
_scannerCancelationTokenSource?.Cancel();
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
private void lvSettings_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Control && e.KeyCode == Keys.C)
|
||||
{
|
||||
CopyModifiedSettingsToClipBoard();
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyModifiedSettingsToClipBoard()
|
||||
{
|
||||
var sbSettings = new StringBuilder();
|
||||
sbSettings.AppendFormat("{0,-40} {1}\r\n", "### NVIDIA Profile Inspector ###", _CurrentProfile);
|
||||
|
||||
foreach (ListViewGroup group in lvSettings.Groups)
|
||||
{
|
||||
bool groupTitleAdded = false;
|
||||
foreach (ListViewItem item in group.Items)
|
||||
{
|
||||
if (item.ImageIndex != 0) continue;
|
||||
|
||||
if(!groupTitleAdded)
|
||||
{
|
||||
sbSettings.AppendFormat("\r\n[{0}]\r\n", group.Header);
|
||||
groupTitleAdded = true;
|
||||
}
|
||||
sbSettings.AppendFormat("{0,-40} {1}\r\n", item.Text, item.SubItems[1].Text);
|
||||
}
|
||||
}
|
||||
|
||||
Clipboard.SetText(sbSettings.ToString());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user