Compare commits

..

21 Commits

Author SHA1 Message Date
Orbmu2k
84749fdf5f possible fix #27 #40 2020-01-11 01:10:00 +01:00
Orbmu2k
b651dae816 moved ansel setting to common group 2020-01-11 00:18:15 +01:00
Orbmu2k
0a27ce1c36 STRG+C will copy userdefined settings to clipboard 2020-01-11 00:10:16 +01:00
Orbmu2k
499cdde758 fixed drs db reset 2020-01-10 22:55:25 +01:00
Orbmu2k
cedcd4e2c6 fix #33 - using settings.xml in working folder if exists 2020-01-07 23:39:06 +01:00
Orbmu2k
5301c52c16 fixed "-disableScan" mode 2020-01-07 23:20:21 +01:00
Orbmu2k
bf8243adaf Updated Settings R441 2020-01-07 11:17:35 +01:00
Orbmu2k
854cc3d0ee fix #13 remember window size, fix crash on closing app while scanning 2019-03-23 16:13:08 +01:00
Orbmu2k
f1ecca7985 improved tempfile handling 2019-03-23 14:20:39 +01:00
Orbmu2k
1af9d1c4fb fixed game starter waiting until setting is stored (bit value editor) 2019-03-23 13:47:59 +01:00
Orbmu2k
2383de09ce xml constructor works again 2019-03-23 13:27:05 +01:00
Orbmu2k
210d5ea25f .NET 4.5 + async/await for setting scanner 2019-03-23 13:06:10 +01:00
Orbmu2k
0104d929e9 simplified version string in window title 2019-03-10 19:55:37 +01:00
Orbmu2k
786423f2d2 updated settings constants to R418 2019-03-07 09:29:42 +01:00
Orbmu2k
1152aeeae9 updated CustomSettingNames 2019-03-07 09:28:02 +01:00
Orbmu2k
c1a75b9a2f Release 2.3.0.0 2019-02-23 15:38:05 +01:00
Orbmu2k
ce1f79fd76 removed hotkey 2019-02-23 15:19:22 +01:00
Orbmu2k
d5f993b63a added opengl sli bits to custom settings 2019-02-22 23:10:30 +01:00
Orbmu2k
6e0c64bf42 import/export of all setting types 2019-02-22 22:50:08 +01:00
Orbmu2k
1f1841cb9f new custom settings, updated driver settings to R410 2019-02-22 20:59:03 +01:00
Orbmu2k
ef00e39885 hotkey 2018-03-18 13:35:04 +01:00
25 changed files with 4257 additions and 1987 deletions

View File

@@ -1,16 +1,16 @@
using System;
using nspector.Common.Helper;
using nspector.Native.NVAPI2;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using nspector.Native.NVAPI2;
namespace nspector.Common
{
internal class DrsDecrypterService : DrsSettingsServiceBase
{
private static readonly byte[] _InternalSettingsKey = new byte[] {
0x2f, 0x7c, 0x4f, 0x8b, 0x20, 0x24, 0x52, 0x8d, 0x26, 0x3c, 0x94, 0x77, 0xf3, 0x7c, 0x98, 0xa5,
0xfa, 0x71, 0xb6, 0x80, 0xdd, 0x35, 0x84, 0xba, 0xfd, 0xb6, 0xa6, 0x1b, 0x39, 0xc4, 0xcc, 0xb0,
@@ -31,9 +31,13 @@ namespace nspector.Common
public DrsDecrypterService(DrsSettingsMetaService metaService) : base(metaService)
{
CreateInternalSettingMap();
try
{
CreateInternalSettingMap();
}
catch { }
}
private uint GetDwordFromKey(uint offset)
{
var bytes = new byte[4];
@@ -82,7 +86,7 @@ namespace nspector.Common
}
}
}
private string FormatInternalSettingKey(string profileName, uint settingId)
{
return profileName + settingId.ToString("X8").ToLower();
@@ -97,40 +101,46 @@ namespace nspector.Common
private void CreateInternalSettingMap()
{
string tmpfile = Path.GetTempFileName();
DrsSession((hSession) =>
string tmpfile = TempFile.GetTempFileName();
try
{
SaveSettingsFileEx(hSession, tmpfile);
});
if (File.Exists(tmpfile))
{
var lines = File.ReadAllLines(tmpfile);
_InternalSettings = new HashSet<string>();
var paProfile = "Profile\\s\\\"(?<profileName>.*?)\\\"";
var rxProfile = new Regex(paProfile, RegexOptions.Compiled);
var paSetting = "ID_0x(?<sid>[0-9a-fA-F]+)\\s\\=.*?InternalSettingFlag\\=V0";
var rxSetting = new Regex(paSetting, RegexOptions.Compiled);
var currentProfileName = "";
for (int i = 0; i < lines.Length; i++)
DrsSession((hSession) =>
{
foreach (Match ms in rxProfile.Matches(lines[i]))
SaveSettingsFileEx(hSession, tmpfile);
});
if (File.Exists(tmpfile))
{
var lines = File.ReadAllLines(tmpfile);
_InternalSettings = new HashSet<string>();
var paProfile = "Profile\\s\\\"(?<profileName>.*?)\\\"";
var rxProfile = new Regex(paProfile, RegexOptions.Compiled);
var paSetting = "ID_0x(?<sid>[0-9a-fA-F]+)\\s\\=.*?InternalSettingFlag\\=V0";
var rxSetting = new Regex(paSetting, RegexOptions.Compiled);
var currentProfileName = "";
for (int i = 0; i < lines.Length; i++)
{
currentProfileName = ms.Result("${profileName}");
}
foreach (Match ms in rxSetting.Matches(lines[i]))
{
_InternalSettings.Add(currentProfileName + ms.Result("${sid}"));
foreach (Match ms in rxProfile.Matches(lines[i]))
{
currentProfileName = ms.Result("${profileName}");
}
foreach (Match ms in rxSetting.Matches(lines[i]))
{
_InternalSettings.Add(currentProfileName + ms.Result("${sid}"));
}
}
}
File.Delete(tmpfile);
}
finally
{
if (File.Exists(tmpfile))
File.Delete(tmpfile);
}
}
}
}
}

View File

@@ -15,12 +15,18 @@ namespace nspector.Common
private readonly DrsSettingsService _SettingService;
private readonly DrsScannerService _ScannerService;
private readonly DrsDecrypterService _DecrypterService;
public DrsImportService(DrsSettingsMetaService metaService, DrsSettingsService settingService, DrsScannerService scannerService)
public DrsImportService(
DrsSettingsMetaService metaService,
DrsSettingsService settingService,
DrsScannerService scannerService,
DrsDecrypterService decrypterService)
: base(metaService)
{
_SettingService = settingService;
_ScannerService = scannerService;
_DecrypterService = decrypterService;
}
internal void ExportAllProfilesToNvidiaTextFile(string filename)
@@ -37,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)
@@ -76,22 +82,18 @@ namespace nspector.Common
foreach (var setting in settings)
{
var isPredefined = setting.isCurrentPredefined == 1;
var isDwordSetting = setting.settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE;
var isCurrentProfile = setting.settingLocation ==
NVDRS_SETTING_LOCATION.NVDRS_CURRENT_PROFILE_LOCATION;
if (isDwordSetting && isCurrentProfile)
if (isCurrentProfile && (!isPredefined || includePredefined))
{
if (!isPredefined || includePredefined)
{
var profileSetting = new ProfileSetting()
{
SettingNameInfo = setting.settingName,
SettingId = setting.settingId,
SettingValue = setting.currentValue.dwordValue,
};
result.Settings.Add(profileSetting);
}
var exportSetting = setting;
_DecrypterService.DecryptSettingIfNeeded(profileName, ref exportSetting);
var profileSetting = ImportExportUitl
.ConvertDrsSettingToProfileSetting(exportSetting);
result.Settings.Add(profileSetting);
}
}
@@ -126,7 +128,7 @@ namespace nspector.Common
try
{
UpdateApplications(hSession, hProfile, profile);
UpdateSettings(hSession, hProfile, profile);
UpdateSettings(hSession, hProfile, profile, profile.ProfileName);
}
catch (NvapiException nex)
{
@@ -202,18 +204,24 @@ namespace nspector.Common
.FirstOrDefault(x => x.SettingId.Equals(settingId));
if (setting != null)
return setting.SettingValue;
return uint.Parse(setting.SettingValue);
return 0;
}
private ProfileSetting GetImportProfileSetting(uint settingId, Profile importProfile)
{
return importProfile.Settings
.FirstOrDefault(x => x.SettingId.Equals(settingId));
}
private bool ExistsImportValue(uint settingId, Profile importProfile)
{
return importProfile.Settings
.Any(x => x.SettingId.Equals(settingId));
}
private void UpdateSettings(IntPtr hSession, IntPtr hProfile, Profile importProfile)
private void UpdateSettings(IntPtr hSession, IntPtr hProfile, Profile importProfile, string profileName)
{
var alreadySet = new HashSet<uint>();
@@ -221,20 +229,24 @@ namespace nspector.Common
foreach (var setting in settings)
{
var isCurrentProfile = setting.settingLocation == NVDRS_SETTING_LOCATION.NVDRS_CURRENT_PROFILE_LOCATION;
var isDwordSetting = setting.settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE;
var isPredefined = setting.isCurrentPredefined == 1;
if (isCurrentProfile && isDwordSetting)
if (isCurrentProfile)
{
bool exitsValue = ExistsImportValue(setting.settingId, importProfile);
uint importValue = GetImportValue(setting.settingId, importProfile);
if (isPredefined && exitsValue && importValue == setting.currentValue.dwordValue)
bool exitsValueInImport = ExistsImportValue(setting.settingId, importProfile);
var importSetting = GetImportProfileSetting(setting.settingId, importProfile);
var decryptedSetting = setting;
_DecrypterService.DecryptSettingIfNeeded(profileName, ref decryptedSetting);
if (isPredefined && exitsValueInImport && ImportExportUitl.AreDrsSettingEqualToProfileSetting(decryptedSetting, importSetting))
{
alreadySet.Add(setting.settingId);
}
else if (exitsValue)
else if (exitsValueInImport)
{
StoreDwordValue(hSession, hProfile, setting.settingId, importValue);
var updatedSetting = ImportExportUitl.ConvertProfileSettingToDrsSetting(importSetting);
StoreSetting(hSession, hProfile, updatedSetting);
alreadySet.Add(setting.settingId);
}
else if (!isPredefined)
@@ -248,7 +260,8 @@ namespace nspector.Common
{
if (!alreadySet.Contains(setting.SettingId))
{
StoreDwordValue(hSession, hProfile, setting.SettingId, setting.SettingValue);
var newSetting = ImportExportUitl.ConvertProfileSettingToDrsSetting(setting);
StoreSetting(hSession, hProfile, newSetting);
}
}
}

View File

@@ -1,21 +1,17 @@
using System;
using nspector.Common.Helper;
using nspector.Native.NVAPI2;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using nspector.Common.Import;
using nspector.Native.NVAPI2;
using System.Threading.Tasks;
using nvw = nspector.Native.NVAPI2.NvapiDrsWrapper;
using nspector.Common.Helper;
namespace nspector.Common
{
internal delegate void SettingScanDoneEvent();
internal delegate void SettingScanProgressEvent(int percent);
internal class DrsScannerService : DrsSettingsServiceBase
{
@@ -24,9 +20,6 @@ namespace nspector.Common
: base(metaService, decrpterService)
{ }
public event SettingScanDoneEvent OnModifiedProfilesScanDone;
public event SettingScanDoneEvent OnPredefinedSettingsScanDone;
public event SettingScanProgressEvent OnSettingScanProgress;
internal List<CachedSettings> CachedSettings = new List<CachedSettings>();
internal List<string> ModifiedProfiles = new List<string>();
@@ -80,59 +73,62 @@ namespace nspector.Common
return false;
}
private void ReportProgress(int current, int max)
{
int percent = (current > 0) ? (int)Math.Round((current * 100f) / max) : 0;
if (OnSettingScanProgress != null)
OnSettingScanProgress(percent);
private int CalcPercent(int current, int max)
{
return (current > 0) ? (int)Math.Round((current * 100f) / max) : 0; ;
}
private void ScanForModifiedProfiles()
public async Task ScanForModifiedProfilesAsync(IProgress<int> progress, CancellationToken token = default(CancellationToken))
{
ModifiedProfiles = new List<string>();
UserProfiles = new HashSet<string>();
var knownPredefines = new List<uint>(_commonSettingIds);
DrsSession((hSession) =>
await Task.Run(() =>
{
IntPtr hBaseProfile = GetProfileHandle(hSession, "");
var profileHandles = EnumProfileHandles(hSession);
var maxProfileCount = profileHandles.Count;
int curProfilePos = 0;
ModifiedProfiles = new List<string>();
UserProfiles = new HashSet<string>();
var knownPredefines = new List<uint>(_commonSettingIds);
foreach (IntPtr hProfile in profileHandles)
DrsSession((hSession) =>
{
ReportProgress(curProfilePos++, maxProfileCount);
IntPtr hBaseProfile = GetProfileHandle(hSession, "");
var profileHandles = EnumProfileHandles(hSession);
var profile = GetProfileInfo(hSession, hProfile);
var maxProfileCount = profileHandles.Count;
int curProfilePos = 0;
int checkedSettingsCount = 0;
bool foundModifiedProfile = false;
if (profile.isPredefined == 0)
foreach (IntPtr hProfile in profileHandles)
{
ModifiedProfiles.Add(profile.profileName);
UserProfiles.Add(profile.profileName);
continue;
}
if (token.IsCancellationRequested) break;
if ((hBaseProfile == hProfile || profile.numOfApps > 0) && profile.numOfSettings > 0)
{
var alreadyChecked = new List<uint>();
progress?.Report(CalcPercent(curProfilePos++, maxProfileCount));
foreach (uint settingId in knownPredefines)
var profile = GetProfileInfo(hSession, hProfile);
int checkedSettingsCount = 0;
bool foundModifiedProfile = false;
if (profile.isPredefined == 0)
{
if (CheckCommonSetting(hSession, hProfile, profile,
ref checkedSettingsCount, settingId, false, ref alreadyChecked))
{
foundModifiedProfile = true;
ModifiedProfiles.Add(profile.profileName);
break;
}
ModifiedProfiles.Add(profile.profileName);
UserProfiles.Add(profile.profileName);
continue;
}
if ((hBaseProfile == hProfile || profile.numOfApps > 0) && profile.numOfSettings > 0)
{
var alreadyChecked = new List<uint>();
foreach (uint settingId in knownPredefines)
{
if (CheckCommonSetting(hSession, hProfile, profile,
ref checkedSettingsCount, settingId, false, ref alreadyChecked))
{
foundModifiedProfile = true;
ModifiedProfiles.Add(profile.profileName);
break;
}
}
// the detection if only applications has changed in a profile makes the scan process very slow, we leave it out!
//if (!foundModifiedProfile && profile.numOfApps > 0)
//{
@@ -149,6 +145,60 @@ namespace nspector.Common
//}
if (foundModifiedProfile || checkedSettingsCount >= profile.numOfSettings)
continue;
var settings = GetProfileSettings(hSession, hProfile);
foreach (var setting in settings)
{
if (knownPredefines.IndexOf(setting.settingId) < 0)
knownPredefines.Add(setting.settingId);
if (setting.isCurrentPredefined != 1)
{
ModifiedProfiles.Add(profile.profileName);
break;
}
}
}
}
});
});
}
public async Task ScanForPredefinedProfileSettingsAsync(IProgress<int> progress, CancellationToken token = default(CancellationToken))
{
await Task.Run(() =>
{
var knownPredefines = new List<uint>(_commonSettingIds);
DrsSession((hSession) =>
{
var profileHandles = EnumProfileHandles(hSession);
var maxProfileCount = profileHandles.Count;
int curProfilePos = 0;
foreach (IntPtr hProfile in profileHandles)
{
if (token.IsCancellationRequested) break;
progress?.Report(CalcPercent(curProfilePos++, maxProfileCount));
var profile = GetProfileInfo(hSession, hProfile);
int checkedSettingsCount = 0;
var alreadyChecked = new List<uint>();
foreach (uint kpd in knownPredefines)
{
CheckCommonSetting(hSession, hProfile, profile,
ref checkedSettingsCount, kpd, true, ref alreadyChecked);
}
if (checkedSettingsCount >= profile.numOfSettings)
continue;
var settings = GetProfileSettings(hSession, hProfile);
@@ -157,77 +207,16 @@ namespace nspector.Common
if (knownPredefines.IndexOf(setting.settingId) < 0)
knownPredefines.Add(setting.settingId);
if (setting.isCurrentPredefined != 1)
{
ModifiedProfiles.Add(profile.profileName);
break;
}
if (alreadyChecked.IndexOf(setting.settingId) < 0)
AddScannedSettingToCache(profile, setting);
}
}
}
});
});
if (OnModifiedProfilesScanDone != null)
OnModifiedProfilesScanDone();
}
private void ScanForPredefinedProfileSettings()
{
var knownPredefines = new List<uint>(_commonSettingIds);
DrsSession((hSession) =>
{
var profileHandles = EnumProfileHandles(hSession);
var maxProfileCount = profileHandles.Count;
int curProfilePos = 0;
foreach (IntPtr hProfile in profileHandles)
{
ReportProgress(curProfilePos++, maxProfileCount);
var profile = GetProfileInfo(hSession, hProfile);
int checkedSettingsCount = 0;
var alreadyChecked = new List<uint>();
foreach (uint kpd in knownPredefines)
{
CheckCommonSetting(hSession, hProfile, profile,
ref checkedSettingsCount, kpd, true, ref alreadyChecked);
}
if (checkedSettingsCount >= profile.numOfSettings)
continue;
var settings = GetProfileSettings(hSession, hProfile);
foreach (var setting in settings)
{
if (knownPredefines.IndexOf(setting.settingId) < 0)
knownPredefines.Add(setting.settingId);
if (alreadyChecked.IndexOf(setting.settingId) < 0)
AddScannedSettingToCache(profile, setting);
}
}
});
if (OnPredefinedSettingsScanDone != null)
OnPredefinedSettingsScanDone();
}
public void StartScanForModifiedProfilesAsync()
{
var thread = new Thread(ScanForModifiedProfiles);
thread.Start();
}
public void StartScanForPredefinedSettingsAsync()
{
var thread = new Thread(ScanForPredefinedProfileSettings);
thread.Start();
}
private void AddScannedSettingToCache(NVDRS_PROFILE profile, NVDRS_SETTING setting)
{
// Skip 3D Vision string values here for improved scan performance
@@ -262,39 +251,45 @@ namespace nspector.Common
}
}
public string FindProfilesUsingApplication(string applicationName)
{
string lowerApplicationName = applicationName.ToLower();
string tmpfile = Path.GetTempFileName();
var matchingProfiles = new List<string>();
string tmpfile = TempFile.GetTempFileName();
DrsSession((hSession) =>
try
{
SaveSettingsFileEx(hSession, tmpfile);
});
var matchingProfiles = new List<string>();
if (File.Exists(tmpfile))
{
string content = File.ReadAllText(tmpfile);
string pattern = "\\sProfile\\s\\\"(?<profile>.*?)\\\"(?<scope>.*?Executable.*?)EndProfile";
foreach (Match m in Regex.Matches(content, pattern, RegexOptions.Singleline))
DrsSession((hSession) =>
{
string scope = m.Result("${scope}");
foreach (Match ms in Regex.Matches(scope, "Executable\\s\\\"(?<app>.*?)\\\"", RegexOptions.Singleline))
SaveSettingsFileEx(hSession, tmpfile);
});
if (File.Exists(tmpfile))
{
string content = File.ReadAllText(tmpfile);
string pattern = "\\sProfile\\s\\\"(?<profile>.*?)\\\"(?<scope>.*?Executable.*?)EndProfile";
foreach (Match m in Regex.Matches(content, pattern, RegexOptions.Singleline))
{
if (ms.Result("${app}").ToLower() == lowerApplicationName)
string scope = m.Result("${scope}");
foreach (Match ms in Regex.Matches(scope, "Executable\\s\\\"(?<app>.*?)\\\"", RegexOptions.Singleline))
{
matchingProfiles.Add(m.Result("${profile}"));
if (ms.Result("${app}").ToLower() == lowerApplicationName)
{
matchingProfiles.Add(m.Result("${profile}"));
}
}
}
}
return string.Join(";", matchingProfiles);
}
finally
{
if (File.Exists(tmpfile))
File.Delete(tmpfile);
}
if (File.Exists(tmpfile))
File.Delete(tmpfile);
return string.Join(";", matchingProfiles);
}
}

View File

@@ -31,7 +31,7 @@ namespace nspector.Common
DecrypterService = new DrsDecrypterService(MetaService);
ScannerService = new DrsScannerService(MetaService, DecrypterService);
SettingService = new DrsSettingsService(MetaService, DecrypterService);
ImportService = new DrsImportService(MetaService, SettingService, ScannerService);
ImportService = new DrsImportService(MetaService, SettingService, ScannerService, DecrypterService);
}
private static CustomSettingNames LoadCustomSettings()

View File

@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using nspector.Native.NVAPI2;
using nspector.Native.NVAPI2;
using System;
using nvw = nspector.Native.NVAPI2.NvapiDrsWrapper;
namespace nspector.Common
@@ -18,11 +14,15 @@ namespace nspector.Common
private static object _Sync = new object();
public static T DrsSession<T>(Func<IntPtr, T> action)
public static T DrsSession<T>(Func<IntPtr, T> action, bool forceNonGlobalSession = false, bool preventLoadSettings = false)
{
lock (_Sync)
{
if (HoldSession && (GlobalSession == IntPtr.Zero))
if (!HoldSession || forceNonGlobalSession)
return NonGlobalDrsSession<T>(action, preventLoadSettings);
if (GlobalSession == IntPtr.Zero)
{
#pragma warning disable CS0420
@@ -31,19 +31,22 @@ 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);
}
}
}
if (HoldSession && GlobalSession != IntPtr.Zero)
if (GlobalSession != IntPtr.Zero)
{
return action(GlobalSession);
}
return NonGlobalDrsSession<T>(action);
throw new Exception(nameof(GlobalSession) + " is Zero!");
}
public static void DestroyGlobalSession()
@@ -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);
}
@@ -82,6 +88,6 @@ namespace nspector.Common
}
}
}

View File

@@ -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");
}
@@ -59,45 +75,56 @@ namespace nspector.Common
public void DeleteAllProfilesHard()
{
var tmpFile = Path.GetTempFileName();
File.WriteAllText(tmpFile, "BaseProfile \"Base Profile\"\r\nProfile \"Base Profile\"\r\nShowOn All\r\nProfileType Global\r\nEndProfile\r\n");
DrsSession((hSession) =>
var tmpFile = TempFile.GetTempFileName();
try
{
LoadSettingsFileEx(hSession, tmpFile);
SaveSettings(hSession);
});
File.WriteAllText(tmpFile, "BaseProfile \"Base Profile\"\r\nProfile \"Base Profile\"\r\nShowOn All\r\nProfileType Global\r\nEndProfile\r\n");
if (File.Exists(tmpFile))
File.Delete(tmpFile);
DrsSession((hSession) =>
{
LoadSettingsFileEx(hSession, tmpFile);
SaveSettings(hSession);
});
}
finally
{
if (File.Exists(tmpFile))
File.Delete(tmpFile);
}
}
public void DeleteProfileHard(string profileName)
{
var tmpFileName = Path.GetTempFileName();
var tmpFileContent = "";
var tmpFileName = TempFile.GetTempFileName();
DrsSession((hSession) =>
try
{
SaveSettingsFileEx(hSession, tmpFileName);
tmpFileContent = File.ReadAllText(tmpFileName);
string pattern = "(?<rpl>\nProfile\\s\"" + Regex.Escape(profileName) + "\".*?EndProfile.*?\n)";
tmpFileContent = Regex.Replace(tmpFileContent, pattern, "", RegexOptions.Singleline);
File.WriteAllText(tmpFileName, tmpFileContent);
});
var tmpFileContent = "";
if (tmpFileContent != "")
{
DrsSession((hSession) =>
{
LoadSettingsFileEx(hSession, tmpFileName);
SaveSettings(hSession);
SaveSettingsFileEx(hSession, tmpFileName);
tmpFileContent = File.ReadAllText(tmpFileName);
string pattern = "(?<rpl>\nProfile\\s\"" + Regex.Escape(profileName) + "\".*?EndProfile.*?\n)";
tmpFileContent = Regex.Replace(tmpFileContent, pattern, "", RegexOptions.Singleline);
File.WriteAllText(tmpFileName, tmpFileContent);
});
}
if (File.Exists(tmpFileName))
File.Delete(tmpFileName);
if (tmpFileContent != "")
{
DrsSession((hSession) =>
{
LoadSettingsFileEx(hSession, tmpFileName);
SaveSettings(hSession);
});
}
}
finally
{
if (File.Exists(tmpFileName))
File.Delete(tmpFileName);
}
}
public void DeleteProfile(string profileName)
@@ -248,7 +275,7 @@ namespace nspector.Common
removeFromModified = tmpRemoveFromModified;
}
public uint GetDwordValueFromProfile(string profileName, uint settingId, bool returnDefaultValue = false)
public uint GetDwordValueFromProfile(string profileName, uint settingId, bool returnDefaultValue = false, bool forceDedicatedScope = false)
{
return DrsSession((hSession) =>
{

View File

@@ -41,18 +41,18 @@ 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)
protected T DrsSession<T>(Func<IntPtr, T> action, bool forceDedicatedScope = false)
{
return DrsSessionScope.DrsSession<T>(action);
return DrsSessionScope.DrsSession<T>(action, forceDedicatedScope);
}
protected IntPtr GetProfileHandle(IntPtr hSession, string profileName)
@@ -115,6 +115,13 @@ namespace nspector.Common
return tmpProfile;
}
protected void StoreSetting(IntPtr hSession, IntPtr hProfile, NVDRS_SETTING newSetting)
{
var ssRes = nvw.DRS_SetSetting(hSession, hProfile, ref newSetting);
if (ssRes != NvAPI_Status.NVAPI_OK)
throw new NvapiException("DRS_SetSetting", ssRes);
}
protected void StoreDwordValue(IntPtr hSession, IntPtr hProfile, uint settingId, uint dwordValue)
{
var newSetting = new NVDRS_SETTING()

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace nspector.Common.Helper
{
internal static class TempFile
{
public static string GetTempFileName()
{
while (true)
{
var tempFile = GenerateTempFileName();
if (!File.Exists(tempFile))
return tempFile;
}
}
private static string GenerateTempFileName()
{
return Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString().Replace("-", ""));
}
}
}

View File

@@ -0,0 +1,43 @@
using System;
using System.IO;
using System.Text;
using System.Windows.Forms;
namespace nspector.Common.Helper
{
public class UserSettings
{
public int WindowTop { get; set; }
public int WindowLeft { get; set; }
public int WindowWidth { get; set; }
public int WindowHeight { get; set; }
public FormWindowState WindowState { get; set; }
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"); ;
}
public void SaveSettings()
{
XMLHelper<UserSettings>.SerializeToXmlFile(this, GetSettingsFilename(), Encoding.Unicode, true);
}
public static UserSettings LoadSettings()
{
var filename = GetSettingsFilename();
if (!File.Exists(filename)) return new UserSettings();
return XMLHelper<UserSettings>.DeserializeFromXMLFile(GetSettingsFilename());
}
}
}

View File

@@ -11,9 +11,7 @@ namespace nspector.Common.Helper
static XMLHelper()
{
//TODO: Fix It!
//xmlSerializer = new XmlSerializer(typeof(T));
xmlSerializer = XmlSerializer.FromTypes(new[]{typeof(T)})[0];
xmlSerializer = new XmlSerializer(typeof(T));
}
internal static string SerializeToXmlString(T xmlObject, Encoding encoding, bool removeNamespace)

View File

@@ -0,0 +1,110 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using nspector.Native.NVAPI2;
namespace nspector.Common.Import
{
internal class ImportExportUitl
{
public static bool AreDrsSettingEqualToProfileSetting(NVDRS_SETTING drsSetting, ProfileSetting profileSetting)
{
var profileSettingCompare = ConvertDrsSettingToProfileSetting(drsSetting);
return profileSetting.SettingValue.Equals(profileSettingCompare.SettingValue);
}
public static ProfileSetting ConvertDrsSettingToProfileSetting(NVDRS_SETTING setting)
{
return new ProfileSetting
{
SettingId = setting.settingId,
SettingNameInfo = setting.settingName,
SettingValue = ConvertSettingValueToString(setting),
ValueType = MapValueType(setting.settingType),
};
}
private static string ConvertSettingValueToString(NVDRS_SETTING setting)
{
var settingUnion = setting.currentValue;
if (setting.isCurrentPredefined == 1)
{
settingUnion = setting.predefinedValue;
}
switch (setting.settingType)
{
case NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE:
return settingUnion.dwordValue.ToString();
case NVDRS_SETTING_TYPE.NVDRS_STRING_TYPE:
return settingUnion.ansiStringValue;
case NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE:
return settingUnion.stringValue;
case NVDRS_SETTING_TYPE.NVDRS_BINARY_TYPE:
return Convert.ToBase64String(settingUnion.binaryValue);
default:
throw new Exception("invalid setting type");
}
}
private static SettingValueType MapValueType(NVDRS_SETTING_TYPE input)
{
switch (input)
{
case NVDRS_SETTING_TYPE.NVDRS_BINARY_TYPE: return SettingValueType.Binary;
case NVDRS_SETTING_TYPE.NVDRS_STRING_TYPE: return SettingValueType.AnsiString;
case NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE: return SettingValueType.String;
default: return SettingValueType.Dword;
}
}
public static NVDRS_SETTING ConvertProfileSettingToDrsSetting(ProfileSetting setting)
{
var newSetting = new NVDRS_SETTING()
{
version = NvapiDrsWrapper.NVDRS_SETTING_VER,
settingId = setting.SettingId,
settingType = MapValueType(setting.ValueType),
settingLocation = NVDRS_SETTING_LOCATION.NVDRS_CURRENT_PROFILE_LOCATION,
currentValue = ConvertStringToSettingUnion(setting.ValueType, setting.SettingValue),
};
return newSetting;
}
private static NVDRS_SETTING_UNION ConvertStringToSettingUnion(SettingValueType valueType, string valueString)
{
var union = new NVDRS_SETTING_UNION();
switch (valueType)
{
case SettingValueType.Dword:
union.dwordValue = uint.Parse(valueString);
break;
case SettingValueType.String:
union.stringValue = valueString;
break;
case SettingValueType.AnsiString:
union.ansiStringValue = valueString;
break;
case SettingValueType.Binary:
union.binaryValue = Convert.FromBase64String(valueString);
break;
default:
throw new Exception("invalid value type");
}
return union;
}
private static NVDRS_SETTING_TYPE MapValueType(SettingValueType input)
{
switch (input)
{
case SettingValueType.Binary: return NVDRS_SETTING_TYPE.NVDRS_BINARY_TYPE;
case SettingValueType.AnsiString: return NVDRS_SETTING_TYPE.NVDRS_STRING_TYPE;
case SettingValueType.String: return NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE;
default: return NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE;
}
}
}
}

View File

@@ -11,6 +11,8 @@ namespace nspector.Common.Import
[XmlElement(ElementName = "SettingID")]
public uint SettingId = 0;
public uint SettingValue = 0;
public string SettingValue = "0";
public SettingValueType ValueType = SettingValueType.Dword;
}
}

View File

@@ -0,0 +1,10 @@
namespace nspector.Common.Import
{
public enum SettingValueType: int
{
Dword,
AnsiString,
String,
Binary
}
}

View File

File diff suppressed because it is too large Load Diff

View File

File diff suppressed because it is too large Load Diff

View File

File diff suppressed because it is too large Load Diff

View File

@@ -270,7 +270,7 @@ namespace nspector.Native.NVAPI2
{
get
{
return Encoding.Unicode.GetString(rawData).Trim('\0');
return Encoding.Unicode.GetString(rawData).Split(new[] { '\0' }, 2)[0];
}
set
@@ -281,6 +281,21 @@ namespace nspector.Native.NVAPI2
}
}
public string ansiStringValue
{
get
{
return Encoding.Default.GetString(rawData).Split(new[] { '\0' }, 2)[0];
}
set
{
rawData = new byte[4100];
var bytesRaw = Encoding.Default.GetBytes(value);
Buffer.BlockCopy(bytesRaw, 0, rawData, 0, bytesRaw.Length);
}
}
}
[StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Unicode)]

View File

@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NVIDIA Profile Inspector")]
[assembly: AssemblyCopyright("©2017 by Orbmu2k")]
[assembly: AssemblyCopyright("©2020 by Orbmu2k")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -32,7 +32,7 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.3.0")]
[assembly: AssemblyFileVersion("2.1.3.0")]
[assembly: AssemblyVersion("2.3.0.0")]
[assembly: AssemblyFileVersion("2.3.0.0")]

View File

@@ -19,7 +19,7 @@ namespace nspector.Properties {
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
@@ -76,13 +76,14 @@ namespace nspector.Properties {
/// &lt;ShowCustomizedSettingNamesOnly&gt;false&lt;/ShowCustomizedSettingNamesOnly&gt;
/// &lt;Settings&gt;
/// &lt;CustomSetting&gt;
/// &lt;UserfriendlyName&gt;Enable Maxwell sample interleaving (MFAA)&lt;/UserfriendlyName&gt;
/// &lt;HexSettingID&gt;0x0098C1AC&lt;/HexSettingID&gt;
/// &lt;GroupName&gt;3 - Antialiasing&lt;/GroupName&gt;
/// &lt;MinRequiredDriverVersion&gt;344.11&lt;/MinRequiredDriverVersion&gt;
/// &lt;SettingValues&gt;
/// &lt;CustomSettingValue&gt;
/// &lt;UserfriendlyName&gt;Off&lt;/Userfrie [Rest der Zeichenfolge wurde abgeschnitten]&quot;; ähnelt.
/// &lt;UserfriendlyName&gt;NVLINK SLI Mode&lt;/UserfriendlyName&gt;
/// &lt;HexSettingID&gt;0x00A06948&lt;/HexSettingID&gt;
/// &lt;GroupName&gt;6 - SLI&lt;/GroupName&gt;
/// &lt;MinRequiredDriverVersion&gt;410.00&lt;/MinRequiredDriverVersion&gt;
/// &lt;/CustomSetting&gt;
/// &lt;CustomSetting&gt;
/// &lt;UserfriendlyName&gt;Texture filtering - Quality substitution&lt;/UserfriendlyName&gt;
/// [Rest der Zeichenfolge wurde abgeschnitten]&quot;; ähnelt.
/// </summary>
public static string CustomSettingNames {
get {

View File

@@ -1,3 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

View File

@@ -4,6 +4,7 @@ using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using nspector.Common;
using nspector.Common.CustomSettings;
@@ -210,24 +211,30 @@ namespace nspector
.SetDwordValueToProfile(_SettingsOwner._CurrentProfile, _Settingid, val);
}
private uint GetStoredValue()
{
return DrsServiceLocator
.SettingService
.GetDwordValueFromProfile(_SettingsOwner._CurrentProfile, _Settingid);
}
private void btnDirectApply_Click(object sender, EventArgs e)
private async void btnDirectApply_Click(object sender, EventArgs e)
{
ApplyValueToProfile(_CurrentValue);
while (GetStoredValue() != _CurrentValue)
Application.DoEvents();
await CheckIfSettingIsStored();
if (File.Exists(tbGamePath.Text))
{
Process.Start(tbGamePath.Text);
}
}
private async Task CheckIfSettingIsStored()
{
await Task.Run(async () =>
{
while (_CurrentValue != DrsServiceLocator.SettingService
.GetDwordValueFromProfile(_SettingsOwner._CurrentProfile, _Settingid, false, true))
{
await Task.Delay(50);
}
});
}
private void btnBrowseGame_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();

View File

@@ -91,10 +91,10 @@
//
this.pbMain.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.pbMain.Location = new System.Drawing.Point(12, 475);
this.pbMain.Margin = new System.Windows.Forms.Padding(4);
this.pbMain.Location = new System.Drawing.Point(16, 585);
this.pbMain.Margin = new System.Windows.Forms.Padding(5);
this.pbMain.Name = "pbMain";
this.pbMain.Size = new System.Drawing.Size(840, 9);
this.pbMain.Size = new System.Drawing.Size(1120, 11);
this.pbMain.TabIndex = 19;
//
// tsMain
@@ -132,10 +132,10 @@
this.tsSep6,
this.tsbApplyProfile});
this.tsMain.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow;
this.tsMain.Location = new System.Drawing.Point(12, 4);
this.tsMain.Location = new System.Drawing.Point(16, 5);
this.tsMain.Name = "tsMain";
this.tsMain.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
this.tsMain.Size = new System.Drawing.Size(840, 25);
this.tsMain.Size = new System.Drawing.Size(1120, 31);
this.tsMain.TabIndex = 24;
this.tsMain.Text = "toolStrip1";
//
@@ -144,7 +144,7 @@
this.tslProfiles.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
this.tslProfiles.Margin = new System.Windows.Forms.Padding(0, 5, 10, 2);
this.tslProfiles.Name = "tslProfiles";
this.tslProfiles.Size = new System.Drawing.Size(49, 18);
this.tslProfiles.Size = new System.Drawing.Size(61, 24);
this.tslProfiles.Text = "Profiles:";
//
// cbProfiles
@@ -156,7 +156,7 @@
this.cbProfiles.Margin = new System.Windows.Forms.Padding(1);
this.cbProfiles.MaxDropDownItems = 50;
this.cbProfiles.Name = "cbProfiles";
this.cbProfiles.Size = new System.Drawing.Size(290, 23);
this.cbProfiles.Size = new System.Drawing.Size(385, 28);
this.cbProfiles.SelectedIndexChanged += new System.EventHandler(this.cbProfiles_SelectedIndexChanged);
this.cbProfiles.TextChanged += new System.EventHandler(this.cbProfiles_TextChanged);
//
@@ -167,7 +167,7 @@
this.tsbModifiedProfiles.Image = global::nspector.Properties.Resources.home_sm;
this.tsbModifiedProfiles.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbModifiedProfiles.Name = "tsbModifiedProfiles";
this.tsbModifiedProfiles.Size = new System.Drawing.Size(36, 22);
this.tsbModifiedProfiles.Size = new System.Drawing.Size(39, 28);
this.tsbModifiedProfiles.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay;
this.tsbModifiedProfiles.ToolTipText = "Back to global profile (Home) / User modified profiles";
this.tsbModifiedProfiles.ButtonClick += new System.EventHandler(this.tsbModifiedProfiles_ButtonClick);
@@ -176,7 +176,7 @@
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 31);
//
// tsbRefreshProfile
//
@@ -184,7 +184,7 @@
this.tsbRefreshProfile.Image = ((System.Drawing.Image)(resources.GetObject("tsbRefreshProfile.Image")));
this.tsbRefreshProfile.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbRefreshProfile.Name = "tsbRefreshProfile";
this.tsbRefreshProfile.Size = new System.Drawing.Size(24, 22);
this.tsbRefreshProfile.Size = new System.Drawing.Size(24, 28);
this.tsbRefreshProfile.Text = "Refresh current profile.";
this.tsbRefreshProfile.Click += new System.EventHandler(this.tsbRefreshProfile_Click);
//
@@ -194,7 +194,7 @@
this.tsbRestoreProfile.Image = ((System.Drawing.Image)(resources.GetObject("tsbRestoreProfile.Image")));
this.tsbRestoreProfile.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbRestoreProfile.Name = "tsbRestoreProfile";
this.tsbRestoreProfile.Size = new System.Drawing.Size(24, 22);
this.tsbRestoreProfile.Size = new System.Drawing.Size(24, 28);
this.tsbRestoreProfile.Text = "Restore current profile to NVIDIA defaults.";
this.tsbRestoreProfile.Click += new System.EventHandler(this.tsbRestoreProfile_Click);
//
@@ -204,7 +204,7 @@
this.tsbCreateProfile.Image = ((System.Drawing.Image)(resources.GetObject("tsbCreateProfile.Image")));
this.tsbCreateProfile.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbCreateProfile.Name = "tsbCreateProfile";
this.tsbCreateProfile.Size = new System.Drawing.Size(24, 22);
this.tsbCreateProfile.Size = new System.Drawing.Size(24, 28);
this.tsbCreateProfile.Text = "Create new profile";
this.tsbCreateProfile.Click += new System.EventHandler(this.tsbCreateProfile_Click);
//
@@ -214,14 +214,14 @@
this.tsbDeleteProfile.Image = global::nspector.Properties.Resources.ieframe_1_18212;
this.tsbDeleteProfile.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbDeleteProfile.Name = "tsbDeleteProfile";
this.tsbDeleteProfile.Size = new System.Drawing.Size(24, 22);
this.tsbDeleteProfile.Size = new System.Drawing.Size(24, 28);
this.tsbDeleteProfile.Text = "Delete current Profile";
this.tsbDeleteProfile.Click += new System.EventHandler(this.tsbDeleteProfile_Click);
//
// tsSep2
//
this.tsSep2.Name = "tsSep2";
this.tsSep2.Size = new System.Drawing.Size(6, 25);
this.tsSep2.Size = new System.Drawing.Size(6, 31);
//
// tsbAddApplication
//
@@ -229,7 +229,7 @@
this.tsbAddApplication.Image = global::nspector.Properties.Resources.window_application_add;
this.tsbAddApplication.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbAddApplication.Name = "tsbAddApplication";
this.tsbAddApplication.Size = new System.Drawing.Size(24, 22);
this.tsbAddApplication.Size = new System.Drawing.Size(24, 28);
this.tsbAddApplication.Text = "Add application to current profile.";
this.tsbAddApplication.Click += new System.EventHandler(this.tsbAddApplication_Click);
//
@@ -239,7 +239,7 @@
this.tssbRemoveApplication.Image = global::nspector.Properties.Resources.window_application_delete;
this.tssbRemoveApplication.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tssbRemoveApplication.Name = "tssbRemoveApplication";
this.tssbRemoveApplication.Size = new System.Drawing.Size(36, 22);
this.tssbRemoveApplication.Size = new System.Drawing.Size(39, 28);
this.tssbRemoveApplication.Text = "Remove application from current profile";
this.tssbRemoveApplication.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.tssbRemoveApplication_DropDownItemClicked);
this.tssbRemoveApplication.Click += new System.EventHandler(this.tssbRemoveApplication_Click);
@@ -247,7 +247,7 @@
// tsSep3
//
this.tsSep3.Name = "tsSep3";
this.tsSep3.Size = new System.Drawing.Size(6, 25);
this.tsSep3.Size = new System.Drawing.Size(6, 31);
//
// tsbExportProfiles
//
@@ -260,35 +260,35 @@
this.tsbExportProfiles.Image = global::nspector.Properties.Resources.export1;
this.tsbExportProfiles.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbExportProfiles.Name = "tsbExportProfiles";
this.tsbExportProfiles.Size = new System.Drawing.Size(36, 22);
this.tsbExportProfiles.Size = new System.Drawing.Size(39, 28);
this.tsbExportProfiles.Text = "Export user defined profiles";
this.tsbExportProfiles.Click += new System.EventHandler(this.tsbExportProfiles_Click);
//
// exportCurrentProfileOnlyToolStripMenuItem
//
this.exportCurrentProfileOnlyToolStripMenuItem.Name = "exportCurrentProfileOnlyToolStripMenuItem";
this.exportCurrentProfileOnlyToolStripMenuItem.Size = new System.Drawing.Size(342, 22);
this.exportCurrentProfileOnlyToolStripMenuItem.Size = new System.Drawing.Size(422, 26);
this.exportCurrentProfileOnlyToolStripMenuItem.Text = "Export current profile only";
this.exportCurrentProfileOnlyToolStripMenuItem.Click += new System.EventHandler(this.exportCurrentProfileOnlyToolStripMenuItem_Click);
//
// exportCurrentProfileIncludingPredefinedSettingsToolStripMenuItem
//
this.exportCurrentProfileIncludingPredefinedSettingsToolStripMenuItem.Name = "exportCurrentProfileIncludingPredefinedSettingsToolStripMenuItem";
this.exportCurrentProfileIncludingPredefinedSettingsToolStripMenuItem.Size = new System.Drawing.Size(342, 22);
this.exportCurrentProfileIncludingPredefinedSettingsToolStripMenuItem.Size = new System.Drawing.Size(422, 26);
this.exportCurrentProfileIncludingPredefinedSettingsToolStripMenuItem.Text = "Export current profile including predefined settings";
this.exportCurrentProfileIncludingPredefinedSettingsToolStripMenuItem.Click += new System.EventHandler(this.exportCurrentProfileIncludingPredefinedSettingsToolStripMenuItem_Click);
//
// exportUserdefinedProfilesToolStripMenuItem
//
this.exportUserdefinedProfilesToolStripMenuItem.Name = "exportUserdefinedProfilesToolStripMenuItem";
this.exportUserdefinedProfilesToolStripMenuItem.Size = new System.Drawing.Size(342, 22);
this.exportUserdefinedProfilesToolStripMenuItem.Size = new System.Drawing.Size(422, 26);
this.exportUserdefinedProfilesToolStripMenuItem.Text = "Export all customized profiles";
this.exportUserdefinedProfilesToolStripMenuItem.Click += new System.EventHandler(this.exportUserdefinedProfilesToolStripMenuItem_Click);
//
// exportAllProfilesNVIDIATextFormatToolStripMenuItem
//
this.exportAllProfilesNVIDIATextFormatToolStripMenuItem.Name = "exportAllProfilesNVIDIATextFormatToolStripMenuItem";
this.exportAllProfilesNVIDIATextFormatToolStripMenuItem.Size = new System.Drawing.Size(342, 22);
this.exportAllProfilesNVIDIATextFormatToolStripMenuItem.Size = new System.Drawing.Size(422, 26);
this.exportAllProfilesNVIDIATextFormatToolStripMenuItem.Text = "Export all driver profiles (NVIDIA Text Format)";
this.exportAllProfilesNVIDIATextFormatToolStripMenuItem.Click += new System.EventHandler(this.exportAllProfilesNVIDIATextFormatToolStripMenuItem_Click);
//
@@ -301,28 +301,28 @@
this.tsbImportProfiles.Image = global::nspector.Properties.Resources.import1;
this.tsbImportProfiles.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbImportProfiles.Name = "tsbImportProfiles";
this.tsbImportProfiles.Size = new System.Drawing.Size(36, 22);
this.tsbImportProfiles.Size = new System.Drawing.Size(39, 28);
this.tsbImportProfiles.Text = "Import user defined profiles";
this.tsbImportProfiles.Click += new System.EventHandler(this.tsbImportProfiles_Click);
//
// importProfilesToolStripMenuItem
//
this.importProfilesToolStripMenuItem.Name = "importProfilesToolStripMenuItem";
this.importProfilesToolStripMenuItem.Size = new System.Drawing.Size(364, 22);
this.importProfilesToolStripMenuItem.Size = new System.Drawing.Size(453, 26);
this.importProfilesToolStripMenuItem.Text = "Import profile(s)";
this.importProfilesToolStripMenuItem.Click += new System.EventHandler(this.importProfilesToolStripMenuItem_Click);
//
// importAllProfilesNVIDIATextFormatToolStripMenuItem
//
this.importAllProfilesNVIDIATextFormatToolStripMenuItem.Name = "importAllProfilesNVIDIATextFormatToolStripMenuItem";
this.importAllProfilesNVIDIATextFormatToolStripMenuItem.Size = new System.Drawing.Size(364, 22);
this.importAllProfilesNVIDIATextFormatToolStripMenuItem.Size = new System.Drawing.Size(453, 26);
this.importAllProfilesNVIDIATextFormatToolStripMenuItem.Text = "Import (replace) all driver profiles (NVIDIA Text Format)";
this.importAllProfilesNVIDIATextFormatToolStripMenuItem.Click += new System.EventHandler(this.importAllProfilesNVIDIATextFormatToolStripMenuItem_Click);
//
// tsSep4
//
this.tsSep4.Name = "tsSep4";
this.tsSep4.Size = new System.Drawing.Size(6, 25);
this.tsSep4.Size = new System.Drawing.Size(6, 31);
//
// tscbShowCustomSettingNamesOnly
//
@@ -331,14 +331,14 @@
this.tscbShowCustomSettingNamesOnly.Image = global::nspector.Properties.Resources.filter_user;
this.tscbShowCustomSettingNamesOnly.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tscbShowCustomSettingNamesOnly.Name = "tscbShowCustomSettingNamesOnly";
this.tscbShowCustomSettingNamesOnly.Size = new System.Drawing.Size(24, 22);
this.tscbShowCustomSettingNamesOnly.Size = new System.Drawing.Size(24, 28);
this.tscbShowCustomSettingNamesOnly.Text = "Show the settings and values from CustomSettingNames file only.";
this.tscbShowCustomSettingNamesOnly.CheckedChanged += new System.EventHandler(this.cbCustomSettingsOnly_CheckedChanged);
//
// tsSep5
//
this.tsSep5.Name = "tsSep5";
this.tsSep5.Size = new System.Drawing.Size(6, 25);
this.tsSep5.Size = new System.Drawing.Size(6, 31);
//
// tscbShowScannedUnknownSettings
//
@@ -348,7 +348,7 @@
this.tscbShowScannedUnknownSettings.Image = global::nspector.Properties.Resources.find_set2;
this.tscbShowScannedUnknownSettings.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tscbShowScannedUnknownSettings.Name = "tscbShowScannedUnknownSettings";
this.tscbShowScannedUnknownSettings.Size = new System.Drawing.Size(24, 22);
this.tscbShowScannedUnknownSettings.Size = new System.Drawing.Size(24, 28);
this.tscbShowScannedUnknownSettings.Text = "Show unknown settings from NVIDIA predefined profiles";
this.tscbShowScannedUnknownSettings.Click += new System.EventHandler(this.tscbShowScannedUnknownSettings_Click);
//
@@ -358,14 +358,14 @@
this.tsbBitValueEditor.Image = global::nspector.Properties.Resources.text_binary;
this.tsbBitValueEditor.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbBitValueEditor.Name = "tsbBitValueEditor";
this.tsbBitValueEditor.Size = new System.Drawing.Size(24, 22);
this.tsbBitValueEditor.Size = new System.Drawing.Size(24, 28);
this.tsbBitValueEditor.Text = "Show bit value editor.";
this.tsbBitValueEditor.Click += new System.EventHandler(this.tsbBitValueEditor_Click);
//
// tsSep6
//
this.tsSep6.Name = "tsSep6";
this.tsSep6.Size = new System.Drawing.Size(6, 25);
this.tsSep6.Size = new System.Drawing.Size(6, 31);
//
// tsbApplyProfile
//
@@ -374,7 +374,7 @@
this.tsbApplyProfile.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbApplyProfile.Name = "tsbApplyProfile";
this.tsbApplyProfile.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never;
this.tsbApplyProfile.Size = new System.Drawing.Size(109, 22);
this.tsbApplyProfile.Size = new System.Drawing.Size(130, 28);
this.tsbApplyProfile.Text = "Apply changes";
this.tsbApplyProfile.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.tsbApplyProfile.Click += new System.EventHandler(this.tsbApplyProfile_Click);
@@ -384,10 +384,10 @@
this.btnResetValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnResetValue.Enabled = false;
this.btnResetValue.Image = global::nspector.Properties.Resources.nv_btn;
this.btnResetValue.Location = new System.Drawing.Point(732, 175);
this.btnResetValue.Location = new System.Drawing.Point(976, 215);
this.btnResetValue.Margin = new System.Windows.Forms.Padding(0, 1, 0, 0);
this.btnResetValue.Name = "btnResetValue";
this.btnResetValue.Size = new System.Drawing.Size(25, 19);
this.btnResetValue.Size = new System.Drawing.Size(33, 23);
this.btnResetValue.TabIndex = 7;
this.btnResetValue.UseVisualStyleBackColor = true;
this.btnResetValue.Click += new System.EventHandler(this.btnResetValue_Click);
@@ -399,10 +399,10 @@
this.lblApplications.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(118)))), ((int)(((byte)(185)))), ((int)(((byte)(0)))));
this.lblApplications.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lblApplications.ForeColor = System.Drawing.Color.White;
this.lblApplications.Location = new System.Drawing.Point(12, 32);
this.lblApplications.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblApplications.Location = new System.Drawing.Point(16, 39);
this.lblApplications.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.lblApplications.Name = "lblApplications";
this.lblApplications.Size = new System.Drawing.Size(840, 17);
this.lblApplications.Size = new System.Drawing.Size(1120, 21);
this.lblApplications.TabIndex = 25;
this.lblApplications.Text = "fsagame.exe, bond.exe, herozero.exe";
//
@@ -440,10 +440,10 @@
//
this.cbValues.BackColor = System.Drawing.SystemColors.Window;
this.cbValues.FormattingEnabled = true;
this.cbValues.Location = new System.Drawing.Point(524, 175);
this.cbValues.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.cbValues.Location = new System.Drawing.Point(699, 215);
this.cbValues.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.cbValues.Name = "cbValues";
this.cbValues.Size = new System.Drawing.Size(72, 21);
this.cbValues.Size = new System.Drawing.Size(95, 24);
this.cbValues.TabIndex = 5;
this.cbValues.Visible = false;
this.cbValues.SelectedValueChanged += new System.EventHandler(this.cbValues_SelectedValueChanged);
@@ -451,40 +451,40 @@
//
// lblWidth96
//
this.lblWidth96.Location = new System.Drawing.Point(77, 233);
this.lblWidth96.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblWidth96.Location = new System.Drawing.Point(103, 287);
this.lblWidth96.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.lblWidth96.Name = "lblWidth96";
this.lblWidth96.Size = new System.Drawing.Size(96, 18);
this.lblWidth96.Size = new System.Drawing.Size(128, 22);
this.lblWidth96.TabIndex = 77;
this.lblWidth96.Text = "96";
this.lblWidth96.Visible = false;
//
// lblWidth330
//
this.lblWidth330.Location = new System.Drawing.Point(77, 210);
this.lblWidth330.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblWidth330.Location = new System.Drawing.Point(103, 258);
this.lblWidth330.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.lblWidth330.Name = "lblWidth330";
this.lblWidth330.Size = new System.Drawing.Size(330, 22);
this.lblWidth330.Size = new System.Drawing.Size(440, 27);
this.lblWidth330.TabIndex = 78;
this.lblWidth330.Text = "330 (Helper Labels for DPI Scaling)";
this.lblWidth330.Visible = false;
//
// lblWidth16
//
this.lblWidth16.Location = new System.Drawing.Point(77, 269);
this.lblWidth16.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblWidth16.Location = new System.Drawing.Point(103, 331);
this.lblWidth16.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.lblWidth16.Name = "lblWidth16";
this.lblWidth16.Size = new System.Drawing.Size(16, 18);
this.lblWidth16.Size = new System.Drawing.Size(21, 22);
this.lblWidth16.TabIndex = 79;
this.lblWidth16.Text = "16";
this.lblWidth16.Visible = false;
//
// lblWidth30
//
this.lblWidth30.Location = new System.Drawing.Point(77, 251);
this.lblWidth30.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblWidth30.Location = new System.Drawing.Point(103, 309);
this.lblWidth30.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.lblWidth30.Name = "lblWidth30";
this.lblWidth30.Size = new System.Drawing.Size(30, 18);
this.lblWidth30.Size = new System.Drawing.Size(40, 22);
this.lblWidth30.TabIndex = 80;
this.lblWidth30.Text = "30";
this.lblWidth30.Visible = false;
@@ -501,12 +501,12 @@
this.lvSettings.FullRowSelect = true;
this.lvSettings.GridLines = true;
this.lvSettings.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.lvSettings.Location = new System.Drawing.Point(12, 51);
this.lvSettings.Margin = new System.Windows.Forms.Padding(4);
this.lvSettings.Location = new System.Drawing.Point(16, 63);
this.lvSettings.Margin = new System.Windows.Forms.Padding(5);
this.lvSettings.MultiSelect = false;
this.lvSettings.Name = "lvSettings";
this.lvSettings.ShowItemToolTips = true;
this.lvSettings.Size = new System.Drawing.Size(840, 418);
this.lvSettings.Size = new System.Drawing.Size(1119, 514);
this.lvSettings.SmallImageList = this.ilListView;
this.lvSettings.TabIndex = 2;
this.lvSettings.UseCompatibleStateImageBehavior = false;
@@ -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
//
@@ -533,9 +534,9 @@
//
// frmDrvSettings
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(864, 492);
this.ClientSize = new System.Drawing.Size(1152, 606);
this.Controls.Add(this.lblWidth30);
this.Controls.Add(this.lblWidth16);
this.Controls.Add(this.lblWidth330);
@@ -546,12 +547,13 @@
this.Controls.Add(this.pbMain);
this.Controls.Add(this.btnResetValue);
this.Controls.Add(this.cbValues);
this.Margin = new System.Windows.Forms.Padding(4);
this.MinimumSize = new System.Drawing.Size(880, 348);
this.Margin = new System.Windows.Forms.Padding(5);
this.MinimumSize = new System.Drawing.Size(1167, 417);
this.Name = "frmDrvSettings";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "nSpector - Driver Profile Settings";
this.Activated += new System.EventHandler(this.frmDrvSettings_Activated);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.frmDrvSettings_FormClosed);
this.Load += new System.EventHandler(this.frmDrvSettings_Load);
this.Shown += new System.EventHandler(this.frmDrvSettings_Shown);
this.tsMain.ResumeLayout(false);

View File

@@ -1,30 +1,29 @@
using System;
using System.Collections;
using nspector.Common;
using nspector.Common.Helper;
using nspector.Native.NVAPI2;
using nspector.Native.WINAPI;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
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;
using nspector.Common;
using nspector.Common.Helper;
using nspector.Native.NVAPI2;
using nspector.Native.WINAPI;
using nvw = nspector.Native.NVAPI2.NvapiDrsWrapper;
using System.Text.RegularExpressions;
using System.Diagnostics;
namespace nspector
{
internal partial class frmDrvSettings : Form
{
readonly DrsSettingsMetaService _meta = DrsServiceLocator.MetaService;
readonly DrsSettingsService _drs = DrsServiceLocator.SettingService;
readonly DrsScannerService _scanner = DrsServiceLocator.ScannerService;
readonly DrsImportService _import = DrsServiceLocator.ImportService;
private readonly DrsSettingsMetaService _meta = DrsServiceLocator.MetaService;
private readonly DrsSettingsService _drs = DrsServiceLocator.SettingService;
private readonly DrsScannerService _scanner = DrsServiceLocator.ScannerService;
private readonly DrsImportService _import = DrsServiceLocator.ImportService;
private List<SettingItem> _currentProfileSettingItems = new List<SettingItem>();
private bool _alreadyScannedForPredefinedSettings = false;
@@ -32,7 +31,7 @@ namespace nspector
private bool _activated = false;
private bool _isStartup = true;
private bool _skipScan = false;
private string _baseProfileName = "";
private bool _isWin7TaskBar = false;
private int _lastComboRowIndex = -1;
@@ -50,6 +49,7 @@ namespace nspector
copyDataStruct = (MessageHelper.COPYDATASTRUCT)m.GetLParam(copyDataType);
if (copyDataStruct.lpData.Equals("ProfilesImported"))
{
DrsSessionScope.DestroyGlobalSession();
RefreshAll();
}
break;
@@ -224,7 +224,7 @@ namespace nspector
itm = v;
cbValues.Items.Add(itm);
}
}
@@ -268,7 +268,7 @@ namespace nspector
cbValues.Visible = true;
}
}
else
@@ -310,7 +310,7 @@ namespace nspector
{
var settingId = (uint)cbValues.Tag;
var activeImages = new[] { 0, 2 };
int idx = GetListViewIndexOfSetting(settingId);
if (idx != -1)
{
@@ -454,16 +454,7 @@ namespace nspector
var numberFormat = new NumberFormatInfo() { NumberDecimalSeparator = "." };
var version = Assembly.GetExecutingAssembly().GetName().Version;
var fileVersionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
var titleText = string.Format("{8} {0}.{1}{5}{2}{5}{4} - {6} Profile Settings {3}- {7}",
version.Major, version.Minor, version.Build, AdminHelper.IsAdmin ? "(Elevated) " : "",
(version.Revision > 0 ? version.Revision.ToString() : ""),
(version.Revision > 0 ? "." : ""),
(_drs.DriverVersion > 0) ? "GeForce " + _drs.DriverVersion.ToString("#.00", numberFormat) + " -" : "Driver",
fileVersionInfo.LegalCopyright,
Application.ProductName
);
Text = titleText;
Text = $"{Application.ProductName} {version} - Geforce {_drs.DriverVersion.ToString("#.00", numberFormat)} - Profile Settings - {fileVersionInfo.LegalCopyright}";
}
private static void InitMessageFilter(IntPtr handle)
@@ -481,14 +472,13 @@ namespace nspector
DragAcceptNativeHelper.ChangeWindowMessageFilter(DragAcceptNativeHelper.WM_COPYGLOBALDATA, DragAcceptNativeHelper.MSGFLT_ADD);
}
}
internal frmDrvSettings() : this(false, false) { }
internal frmDrvSettings(bool showCsnOnly, bool skipScan)
{
_skipScan = skipScan;
InitializeComponent();
InitTaskbarList();
InitScannerEvents();
SetupDropFilesNative();
SetupToolbar();
SetupDpiAdjustments();
@@ -524,7 +514,7 @@ namespace nspector
Height = Screen.GetWorkingArea(this).Height - 20;
}
}
private void RefreshModifiesProfilesDropDown()
{
tsbModifiedProfiles.DropDownItems.Clear();
@@ -547,6 +537,7 @@ namespace nspector
{
SetupLayout();
SetTitleVersion();
LoadSettings();
RefreshProfilesCombo();
cbProfiles.Text = GetBaseProfileName();
@@ -632,7 +623,7 @@ namespace nspector
catch { }
}
}
private void AddToModifiedProfiles(string profileName, bool userProfile = false)
{
if (!_scanner.UserProfiles.Contains(profileName) && profileName != _baseProfileName && userProfile)
@@ -661,134 +652,72 @@ namespace nspector
}
}
private void InvokeUi(Control invokeControl, Action action)
private void ShowExportProfiles()
{
MethodInvoker mi = () => action();
if (invokeControl.InvokeRequired)
invokeControl.BeginInvoke(mi);
if (_scanner.ModifiedProfiles.Count > 0)
{
var frmExport = new frmExportProfiles();
frmExport.ShowDialog(this);
}
else
mi.Invoke();
}
private void frmDrvSettings_OnModifiedScanDoneAndShowExport()
{
InvokeUi(this, () =>
{
pbMain.Value = 0;
pbMain.Enabled = false;
SetTaskbarProgress(0);
if (_scanner.ModifiedProfiles.Count > 0)
{
var frmExport = new frmExportProfiles();
frmExport.ShowDialog(this);
}
else
MessageBox.Show("No user modified profiles found! Nothing to export.", "Userprofile Search", MessageBoxButtons.OK, MessageBoxIcon.Information);
RefreshModifiesProfilesDropDown();
tsbRefreshProfile.Enabled = true;
});
MessageBox.Show("No user modified profiles found! Nothing to export.", "Userprofile Search", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void frmDrvSettings_OnPredefinedScanDoneAndStartModifiedProfileScan()
{
private CancellationTokenSource _scannerCancelationTokenSource;
InvokeUi(this, () =>
{
pbMain.Value = 0;
pbMain.Enabled = false;
SetTaskbarProgress(0);
tscbShowScannedUnknownSettings.Enabled = true;
});
StartModifiedProfilesScan(false);
}
private void frmDrvSettings_OnScanDoneDoNothing()
{
_meta.ResetMetaCache();
InvokeUi(this, () =>
{
pbMain.Value = 0;
pbMain.Enabled = false;
SetTaskbarProgress(0);
RefreshCurrentProfile();
RefreshModifiesProfilesDropDown();
tsbRefreshProfile.Enabled = true;
});
}
private void frmDrvSettings_OnSettingScanProgress(int percent)
{
InvokeUi(this, () =>
{
pbMain.Value = percent;
SetTaskbarProgress(percent);
});
}
private void InitScannerEvents()
{
_scanner.OnSettingScanProgress += new Common.SettingScanProgressEvent(frmDrvSettings_OnSettingScanProgress);
_scanner.OnPredefinedSettingsScanDone += new Common.SettingScanDoneEvent(frmDrvSettings_OnScanDoneDoNothing);
_scanner.OnModifiedProfilesScanDone += new Common.SettingScanDoneEvent(frmDrvSettings_OnScanDoneDoNothing);
}
private void StartModifiedProfilesScan(bool showProfilesDialog)
{
pbMain.Minimum = 0;
pbMain.Maximum = 100;
_scanner.OnModifiedProfilesScanDone -= new Common.SettingScanDoneEvent(frmDrvSettings_OnScanDoneDoNothing);
_scanner.OnModifiedProfilesScanDone -= new Common.SettingScanDoneEvent(frmDrvSettings_OnModifiedScanDoneAndShowExport);
if (showProfilesDialog)
_scanner.OnModifiedProfilesScanDone += new Common.SettingScanDoneEvent(frmDrvSettings_OnModifiedScanDoneAndShowExport);
else
_scanner.OnModifiedProfilesScanDone += new Common.SettingScanDoneEvent(frmDrvSettings_OnScanDoneDoNothing);
_scanner.StartScanForModifiedProfilesAsync();
}
private void StartPredefinedSettingsScan(bool startModifiedProfileScan)
{
pbMain.Minimum = 0;
pbMain.Maximum = 100;
_scanner.OnPredefinedSettingsScanDone -= new Common.SettingScanDoneEvent(frmDrvSettings_OnScanDoneDoNothing);
_scanner.OnPredefinedSettingsScanDone -= new Common.SettingScanDoneEvent(frmDrvSettings_OnPredefinedScanDoneAndStartModifiedProfileScan);
if (startModifiedProfileScan)
_scanner.OnPredefinedSettingsScanDone += new Common.SettingScanDoneEvent(frmDrvSettings_OnPredefinedScanDoneAndStartModifiedProfileScan);
else
_scanner.OnPredefinedSettingsScanDone += new Common.SettingScanDoneEvent(frmDrvSettings_OnScanDoneDoNothing);
_alreadyScannedForPredefinedSettings = true;
_scanner.StartScanForPredefinedSettingsAsync();
}
private void ScanProfilesSilent(bool scanPredefined, bool showProfileDialog)
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;
pbMain.Minimum = 0;
pbMain.Maximum = 100;
_scannerCancelationTokenSource = new CancellationTokenSource();
var progressHandler = new Progress<int>(value =>
{
pbMain.Value = value;
SetTaskbarProgress(value);
});
if (scanPredefined && !_alreadyScannedForPredefinedSettings)
StartPredefinedSettingsScan(true);
else
StartModifiedProfilesScan(showProfileDialog);
{
_alreadyScannedForPredefinedSettings = true;
await _scanner.ScanForPredefinedProfileSettingsAsync(progressHandler, _scannerCancelationTokenSource.Token);
_meta.ResetMetaCache();
tscbShowScannedUnknownSettings.Enabled = true;
}
await _scanner.ScanForModifiedProfilesAsync(progressHandler, _scannerCancelationTokenSource.Token);
RefreshModifiesProfilesDropDown();
tsbModifiedProfiles.Enabled = true;
pbMain.Value = 0;
pbMain.Enabled = false;
SetTaskbarProgress(0);
if (showProfileDialog)
{
ShowExportProfiles();
}
RefreshCurrentProfile();
tsbRefreshProfile.Enabled = true;
}
private void cbCustomSettingsOnly_CheckedChanged(object sender, EventArgs e)
@@ -805,7 +734,7 @@ namespace nspector
}
}
private void tsbRestoreProfile_Click(object sender, EventArgs e)
private async void tsbRestoreProfile_Click(object sender, EventArgs e)
{
if (Control.ModifierKeys == Keys.Control)
{
@@ -818,7 +747,7 @@ namespace nspector
RefreshProfilesCombo();
RefreshCurrentProfile();
ScanProfilesSilent(true, false);
await ScanProfilesSilentAsync(true, false);
cbProfiles.Text = GetBaseProfileName();
}
}
@@ -890,14 +819,14 @@ namespace nspector
}
}
private void frmDrvSettings_Shown(object sender, EventArgs e)
private async void frmDrvSettings_Shown(object sender, EventArgs e)
{
if (_isStartup)
{
new Thread(SetTaskbarIcon).Start();
ScanProfilesSilent(true, false);
await ScanProfilesSilentAsync(true, false);
if (WindowState != FormWindowState.Maximized)
if (_scannerCancelationTokenSource != null && !_scannerCancelationTokenSource.Token.IsCancellationRequested && WindowState != FormWindowState.Maximized)
{
new MessageHelper().bringAppToFront((int)this.Handle);
}
@@ -1025,9 +954,9 @@ namespace nspector
tsbImportProfiles.ShowDropDown();
}
private void exportUserdefinedProfilesToolStripMenuItem_Click(object sender, EventArgs e)
private async void exportUserdefinedProfilesToolStripMenuItem_Click(object sender, EventArgs e)
{
ScanProfilesSilent(false, true);
await ScanProfilesSilentAsync(false, true);
}
private void ExportCurrentProfile(bool includePredefined)
@@ -1091,10 +1020,10 @@ namespace nspector
}
}
private void RefreshAll()
private async void RefreshAll()
{
RefreshProfilesCombo();
ScanProfilesSilent(true, false);
await ScanProfilesSilentAsync(true, false);
int idx = cbProfiles.Items.IndexOf(_CurrentProfile);
if (idx == -1 || _CurrentProfile == _baseProfileName)
@@ -1116,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)
@@ -1146,7 +1076,7 @@ namespace nspector
cbProfiles.Select(cbProfiles.Text.Length, 0);
}
}
public static void ShowImportDoneMessage(string importReport)
{
@@ -1215,6 +1145,92 @@ namespace nspector
Clipboard.SetText(string.Format($"0x{settingId:X8} {settingName}"));
}
}
private void HandleScreenConstraints()
{
var workingArea = Screen.GetWorkingArea(this);
if (Left < workingArea.X)
Left = workingArea.X;
if (Top < workingArea.Y)
Top = workingArea.Y;
if ((Left + Width) > workingArea.X + workingArea.Width)
Left = (workingArea.X + workingArea.Width) - Width;
if ((Top + Height) > workingArea.Y + workingArea.Height)
Top = (workingArea.Y + workingArea.Height) - Height;
}
private void SaveSettings()
{
var settings = UserSettings.LoadSettings();
if (WindowState == FormWindowState.Normal)
{
settings.WindowTop = Top;
settings.WindowLeft = Left;
settings.WindowHeight = Height;
settings.WindowWidth = Width;
}
else
{
settings.WindowTop = RestoreBounds.Top;
settings.WindowLeft = RestoreBounds.Left;
settings.WindowHeight = RestoreBounds.Height;
settings.WindowWidth = RestoreBounds.Width;
}
settings.WindowState = WindowState;
settings.SaveSettings();
}
private void LoadSettings()
{
var settings = UserSettings.LoadSettings();
SetBounds(settings.WindowLeft, settings.WindowTop, settings.WindowWidth, settings.WindowHeight);
WindowState = settings.WindowState != FormWindowState.Minimized ? settings.WindowState : FormWindowState.Normal;
HandleScreenConstraints();
}
private void frmDrvSettings_FormClosed(object sender, FormClosedEventArgs e)
{
_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());
}
}
}

View File

@@ -125,7 +125,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADI
DAAAAk1TRnQBSQFMAgEBBAEAAZABBwGQAQcBEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA
DAAAAk1TRnQBSQFMAgEBBAEAAagBBwGoAQcBEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA
AwABIAMAAQEBAAEYBgABGP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/ADMAAcgBvQGvAacBkQF5BgAD/iEA
A+QD2gYAA/4hAAGXAcMBqwFMAZwBcAYAA/4hAAOmA2gGAAP+FQAB8gHxAfABqQGPAXQBzwHHAbwD/wG6
AaUBjAGuAZQBeAHxAe8B7QHvAe0B6wGhAYgBbQHkAeAB2xIAA/UD3QPmA/8D4APeA/QD8wPaA+4SAAHt
@@ -195,7 +195,7 @@
<data name="tsbRefreshProfile.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGgSURBVDhPrZPLSsNAFIb7BoKP4Upw5UoQBHfmMrG1olCa
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAGgSURBVDhPrZPLSsNAFIb7BoKP4Upw5UoQBHfmMrG1olCa
pFoExY2KiHcRERFEwYUKglSQesFeQK2rFkFr0Y26MRAKpa2+QS+/MzGpaS114wdhQv7/nDknZ8bx7xDi
a+FFeYvnFU2QFHCcRxdEOcQTmTctjWHB4UgM2Wwe5XIZ+fwnko/PWF3bhiAqJzRRp2mtD0/U7oWlTbAK
Bj1jYO/vmo5SqYR44gG9fcPgiNpu2uvDkrCVEG+zIMkqcfqQuEuiWCwidhsHJ8qHhtEOLX2H9cxW81MF
@@ -208,7 +208,7 @@
<data name="tsbRestoreProfile.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAFcSURBVDhP3VFNK0RhFL4/wNbM3PdcCgsfsbHDgkJKWPgD
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAFcSURBVDhP3VFNK0RhFL4/wNbM3PdcCgsfsbHDgkJKWPgD
ilJGNN73XEs/gbKUmvITuPc9d5iwYKfZyULZ26BkhTjnnXs1TWTNqafOx/M895z3ev84FsrwigQfvyGl
1yNM1IyO4cQNrUKdqGFj1awmuGgWZnDC9Wouz8U1xnATkj+oE78HLVyWKPeAlH9EUkOa1FyzWOAxeVIS
JuxtRoVeERhS51zviLlsIHNjYRltW1ejWOChDdbqhEIfRoVbE0PZbXXoP3G/ygZFNyeYZ4xlwgzC9fAI
@@ -220,7 +220,7 @@
<data name="tsbCreateProfile.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEgSURBVDhP3Y/PKwRhHIf3f5g/wMWUlIuDUk5y5MCB3Dk4
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAEgSURBVDhP3Y/PKwRhHIf3f5g/wMWUlIuDUk5y5MCB3Dk4
7EUbBwdXJ3EXsksjidlk2x27NrXt5kdjlTQXbSFK2iaGaX7s491Zjppx5FNP7/et9/n0fmP/PFwu8JGd
5OsaLdxpNIyVQPL1GcyDwWDmVsEx1sLLGvdHeLtduKVh/GIPTlbGPRvF3mmjXm0Vh8a9SEBGAl1gCMoS
j2p/uOyX5/AK4/i5bqgI8UrQPFUJO9mOr43gHk/9XOToy9QLCd4O+yAvxCb7gg0JK9WJqcWxTubDf+Kd
@@ -237,7 +237,7 @@
<data name="toolStripButton5.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
@@ -252,7 +252,7 @@
<data name="toolStripButton6.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc

View File

@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>nspector</RootNamespace>
<AssemblyName>nvidiaProfileInspector</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<PlatformTarget>x86</PlatformTarget>
<TargetFrameworkProfile />
@@ -138,6 +138,10 @@
<Compile Include="Common\Helper\ListViewGroupSorter.cs" />
<Compile Include="Common\Helper\ShortcutResolver.cs" />
<Compile Include="Common\Helper\SteamAppResolver.cs" />
<Compile Include="Common\Helper\TempFile.cs" />
<Compile Include="Common\Helper\UserSettings.cs" />
<Compile Include="Common\Import\ImportExportUitl.cs" />
<Compile Include="Common\Import\SettingValueType.cs" />
<Compile Include="Common\Meta\NvD3dUmxSettingMetaService.cs" />
<Compile Include="Common\Meta\MetaServiceItem.cs" />
<Compile Include="Common\Meta\ConstantSettingMetaService.cs" />
@@ -222,9 +226,6 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="app.manifest">
<SubType>Designer</SubType>
</None>