mirror of
https://github.com/Orbmu2k/nvidiaProfileInspector.git
synced 2026-01-03 04:18:08 -05:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f1d636fae | ||
|
|
acb5607a6d | ||
|
|
b6ec45a334 | ||
|
|
75c99ea6c7 | ||
|
|
5aed1a0051 | ||
|
|
128efcdb86 | ||
|
|
d4ce1c9018 | ||
|
|
abef5e1eb1 | ||
|
|
c2f71c5d1e | ||
|
|
a4ea01dfd1 | ||
|
|
9adc3b9cb9 |
@@ -6,7 +6,7 @@ namespace nspector.Common
|
||||
internal class CachedSettingValue
|
||||
{
|
||||
|
||||
internal CachedSettingValue() { }
|
||||
internal CachedSettingValue() { }
|
||||
|
||||
internal CachedSettingValue(uint Value, string ProfileNames)
|
||||
{
|
||||
|
||||
@@ -6,14 +6,14 @@ namespace nspector.Common
|
||||
{
|
||||
internal class CachedSettings
|
||||
{
|
||||
internal CachedSettings() { }
|
||||
internal CachedSettings() { }
|
||||
|
||||
internal CachedSettings(uint settingId, NVDRS_SETTING_TYPE settingType)
|
||||
{
|
||||
SettingId = settingId;
|
||||
SettingType = settingType;
|
||||
}
|
||||
|
||||
|
||||
internal uint SettingId;
|
||||
|
||||
internal List<CachedSettingValue> SettingValues = new List<CachedSettingValue>();
|
||||
@@ -21,7 +21,7 @@ namespace nspector.Common
|
||||
internal uint ProfileCount = 0;
|
||||
|
||||
internal NVDRS_SETTING_TYPE SettingType = NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE;
|
||||
|
||||
|
||||
internal void AddDwordValue(uint valueDword, string Profile)
|
||||
{
|
||||
var setting = SettingValues.FirstOrDefault(s => s.Value == valueDword);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace nspector.Common.CustomSettings
|
||||
@@ -16,6 +15,7 @@ namespace nspector.Common.CustomSettings
|
||||
public string GroupName { get; set; }
|
||||
public string OverrideDefault { get; set; }
|
||||
public float MinRequiredDriverVersion { get; set; }
|
||||
public bool Hidden { get; set; }
|
||||
|
||||
public List<CustomSettingValue> SettingValues { get; set; }
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace nspector.Common.CustomSettings
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using nspector.Common.Import;
|
||||
using nspector.Native.NVAPI2;
|
||||
@@ -18,8 +17,8 @@ namespace nspector.Common
|
||||
private readonly DrsDecrypterService _DecrypterService;
|
||||
|
||||
public DrsImportService(
|
||||
DrsSettingsMetaService metaService,
|
||||
DrsSettingsService settingService,
|
||||
DrsSettingsMetaService metaService,
|
||||
DrsSettingsService settingService,
|
||||
DrsScannerService scannerService,
|
||||
DrsDecrypterService decrypterService)
|
||||
: base(metaService)
|
||||
@@ -77,7 +76,7 @@ namespace nspector.Common
|
||||
{
|
||||
result.Executeables.Add(app.appName);
|
||||
}
|
||||
|
||||
|
||||
var settings = GetProfileSettings(hSession, hProfile);
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
@@ -239,7 +238,7 @@ namespace nspector.Common
|
||||
var decryptedSetting = setting;
|
||||
_DecrypterService.DecryptSettingIfNeeded(profileName, ref decryptedSetting);
|
||||
|
||||
if (isPredefined && exitsValueInImport && ImportExportUitl.AreDrsSettingEqualToProfileSetting(decryptedSetting, importSetting))
|
||||
if (isPredefined && exitsValueInImport && ImportExportUitl.AreDrsSettingEqualToProfileSetting(decryptedSetting, importSetting))
|
||||
{
|
||||
alreadySet.Add(setting.settingId);
|
||||
}
|
||||
@@ -261,7 +260,15 @@ namespace nspector.Common
|
||||
if (!alreadySet.Contains(setting.SettingId))
|
||||
{
|
||||
var newSetting = ImportExportUitl.ConvertProfileSettingToDrsSetting(setting);
|
||||
StoreSetting(hSession, hProfile, newSetting);
|
||||
try
|
||||
{
|
||||
StoreSetting(hSession, hProfile, newSetting);
|
||||
}
|
||||
catch (NvapiException ex)
|
||||
{
|
||||
if (ex.Status != NvAPI_Status.NVAPI_SETTING_NOT_FOUND)
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,8 +118,8 @@ namespace nspector.Common
|
||||
|
||||
foreach (uint kpd in knownPredefines)
|
||||
{
|
||||
if (CheckCommonSetting(hSession, hProfile, profile,
|
||||
ref checkedSettingsCount, kpd, !justModified, ref alreadyChecked))
|
||||
if (CheckCommonSetting(hSession, hProfile, profile,
|
||||
ref checkedSettingsCount, kpd, !justModified, ref alreadyChecked))
|
||||
{
|
||||
if (!foundModifiedProfile)
|
||||
{
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using nspector.Common.CustomSettings;
|
||||
|
||||
using nvw = nspector.Native.NVAPI2.NvapiDrsWrapper;
|
||||
|
||||
namespace nspector.Common
|
||||
{
|
||||
internal class DrsServiceLocator
|
||||
@@ -53,6 +45,6 @@ namespace nspector.Common
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace nspector.Common
|
||||
|
||||
if (csRes != NvAPI_Status.NVAPI_OK)
|
||||
throw new NvapiException("DRS_CreateSession", csRes);
|
||||
|
||||
|
||||
if (!preventLoadSettings)
|
||||
{
|
||||
var nvRes = nvw.DRS_LoadSettings(GlobalSession);
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using nspector.Common.Meta;
|
||||
using nspector.Common.CustomSettings;
|
||||
using nspector.Native.NVAPI2;
|
||||
using nspector.Native.NvApi.DriverSettings;
|
||||
|
||||
namespace nspector.Common
|
||||
{
|
||||
internal class DrsSettingsMetaService
|
||||
{
|
||||
|
||||
|
||||
private ISettingMetaService ConstantMeta;
|
||||
private ISettingMetaService CustomMeta;
|
||||
public ISettingMetaService DriverMeta;
|
||||
@@ -38,7 +35,7 @@ namespace nspector.Common
|
||||
{
|
||||
settingMetaCache = new Dictionary<uint, SettingMeta>();
|
||||
MetaServices = new List<MetaServiceItem>();
|
||||
|
||||
|
||||
CustomMeta = new CustomSettingMetaService(_customSettings);
|
||||
MetaServices.Add(new MetaServiceItem() { ValueNamePrio = 1, Service = CustomMeta });
|
||||
|
||||
@@ -64,7 +61,7 @@ namespace nspector.Common
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private NVDRS_SETTING_TYPE? GetSettingValueType(uint settingId)
|
||||
{
|
||||
foreach (var service in MetaServices.OrderBy(x => x.Service.Source))
|
||||
@@ -76,12 +73,12 @@ namespace nspector.Common
|
||||
|
||||
return NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE;
|
||||
}
|
||||
|
||||
|
||||
private string GetSettingName(uint settingId)
|
||||
{
|
||||
string hexCandidate = null;
|
||||
|
||||
foreach (var service in MetaServices.OrderBy(x=>x.Service.Source))
|
||||
foreach (var service in MetaServices.OrderBy(x => x.Service.Source))
|
||||
{
|
||||
var settingName = service.Service.GetSettingName(settingId);
|
||||
|
||||
@@ -129,7 +126,7 @@ namespace nspector.Common
|
||||
if (settingDefault != null)
|
||||
return settingDefault;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -159,7 +156,7 @@ namespace nspector.Common
|
||||
else
|
||||
{
|
||||
var currentNonScannedValues = a.Where(xa => xa.ValueSource != SettingMetaSource.ScannedSettings).Select(xa => xa.Value).ToList();
|
||||
|
||||
|
||||
var newNonScannedValues = b.Where(xb => !currentNonScannedValues.Contains(xb.Value)).ToList();
|
||||
a.AddRange(newNonScannedValues);
|
||||
|
||||
@@ -177,7 +174,7 @@ namespace nspector.Common
|
||||
|
||||
var atmp = a.FirstOrDefault();
|
||||
if (atmp != null && atmp is IComparable)
|
||||
return a.OrderBy(x=>x.Value).ToList();
|
||||
return a.OrderBy(x => x.Value).ToList();
|
||||
else
|
||||
return a.ToList();
|
||||
}
|
||||
@@ -202,7 +199,7 @@ namespace nspector.Common
|
||||
{
|
||||
result = MergeSettingValues(result, service.Service.GetStringValues(settingId));
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -217,15 +214,15 @@ namespace nspector.Common
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
result = (from v in result.Where(x=> 1==1
|
||||
result = (from v in result.Where(x => 1 == 1
|
||||
&& !x.ValueName.EndsWith("_NUM")
|
||||
&& !x.ValueName.EndsWith("_MASK")
|
||||
&& (!x.ValueName.EndsWith("_MIN") || x.ValueName.Equals("PREFERRED_PSTATE_PREFER_MIN"))
|
||||
&& (!x.ValueName.EndsWith("_MAX") || x.ValueName.Equals("PREFERRED_PSTATE_PREFER_MAX"))
|
||||
|
||||
)
|
||||
group v by v.ValueName into g
|
||||
select g.First(t => t.ValueName == g.Key))
|
||||
|
||||
)
|
||||
group v by v.ValueName into g
|
||||
select g.First(t => t.ValueName == g.Key))
|
||||
.OrderBy(v => v.ValueSource)
|
||||
.ThenBy(v => v.ValuePos)
|
||||
.ThenBy(v => v.ValueName).ToList();
|
||||
@@ -234,7 +231,7 @@ namespace nspector.Common
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public List<uint> GetSettingIds(SettingViewMode viewMode)
|
||||
{
|
||||
var settingIds = new List<uint>();
|
||||
@@ -255,21 +252,21 @@ namespace nspector.Common
|
||||
switch (viewMode)
|
||||
{
|
||||
case SettingViewMode.CustomSettingsOnly:
|
||||
return new [] {
|
||||
SettingMetaSource.CustomSettings
|
||||
return new[] {
|
||||
SettingMetaSource.CustomSettings
|
||||
};
|
||||
case SettingViewMode.IncludeScannedSetttings:
|
||||
return new [] {
|
||||
return new[] {
|
||||
SettingMetaSource.ConstantSettings,
|
||||
SettingMetaSource.ScannedSettings,
|
||||
SettingMetaSource.CustomSettings,
|
||||
SettingMetaSource.ScannedSettings,
|
||||
SettingMetaSource.CustomSettings,
|
||||
SettingMetaSource.DriverSettings,
|
||||
SettingMetaSource.ReferenceSettings,
|
||||
};
|
||||
default:
|
||||
return new [] {
|
||||
SettingMetaSource.CustomSettings,
|
||||
SettingMetaSource.DriverSettings,
|
||||
return new[] {
|
||||
SettingMetaSource.CustomSettings,
|
||||
SettingMetaSource.DriverSettings,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -300,21 +297,26 @@ namespace nspector.Common
|
||||
var settingType = GetSettingValueType(settingId);
|
||||
var settingName = GetSettingName(settingId);
|
||||
var groupName = GetGroupName(settingId);
|
||||
|
||||
|
||||
if (groupName == null)
|
||||
groupName = GetLegacyGroupName(settingId, settingName);
|
||||
|
||||
|
||||
|
||||
var result = new SettingMeta()
|
||||
{
|
||||
SettingType = settingType,
|
||||
SettingName = settingName,
|
||||
GroupName = groupName,
|
||||
|
||||
DefaultDwordValue =
|
||||
settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE
|
||||
IsApiExposed = GetIsApiExposed(settingId),
|
||||
IsSettingHidden = GetIsSettingHidden(settingId),
|
||||
|
||||
DefaultDwordValue =
|
||||
settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE
|
||||
? GetDwordDefaultValue(settingId) : 0,
|
||||
|
||||
DefaultStringValue =
|
||||
DefaultStringValue =
|
||||
settingType == NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE
|
||||
? GetStringDefaultValue(settingId) : null,
|
||||
|
||||
@@ -348,6 +350,8 @@ namespace nspector.Common
|
||||
SettingName = settingMeta.SettingName,
|
||||
SettingType = settingMeta.SettingType,
|
||||
GroupName = settingMeta.GroupName,
|
||||
IsApiExposed = settingMeta.IsApiExposed,
|
||||
IsSettingHidden = settingMeta.IsSettingHidden,
|
||||
};
|
||||
|
||||
if (string.IsNullOrEmpty(newMeta.SettingName))
|
||||
@@ -406,5 +410,16 @@ namespace nspector.Common
|
||||
return "Other";
|
||||
|
||||
}
|
||||
private bool GetIsApiExposed(uint settingId)
|
||||
{
|
||||
var driverMeta = MetaServices.FirstOrDefault(m => m.Service.Source == SettingMetaSource.DriverSettings);
|
||||
return (driverMeta != null && driverMeta.Service.GetSettingIds().Contains(settingId));
|
||||
}
|
||||
|
||||
private bool GetIsSettingHidden(uint settingId)
|
||||
{
|
||||
var csnMeta = MetaServices.FirstOrDefault(m => m.Service.Source == SettingMetaSource.CustomSettings);
|
||||
return (csnMeta != null && ((CustomSettingMetaService)csnMeta.Service).IsSettingHidden(settingId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using nspector.Common.Helper;
|
||||
using nspector.Common.Meta;
|
||||
using nspector.Native.NVAPI2;
|
||||
@@ -46,14 +43,14 @@ namespace nspector.Common
|
||||
if (!fiDbInstaller.Exists) continue;
|
||||
|
||||
var fviDbInstaller = FileVersionInfo.GetVersionInfo(fiDbInstaller.FullName);
|
||||
|
||||
|
||||
var fileversion = fviDbInstaller.FileVersion.Replace(".", "");
|
||||
var driverver = DriverVersion.ToString().Replace(",","").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");
|
||||
}
|
||||
@@ -78,13 +75,13 @@ namespace nspector.Common
|
||||
var tmpFile = TempFile.GetTempFileName();
|
||||
try
|
||||
{
|
||||
File.WriteAllText(tmpFile, "BaseProfile \"Base Profile\"\r\nProfile \"Base Profile\"\r\nShowOn All\r\nProfileType Global\r\nEndProfile\r\n");
|
||||
File.WriteAllText(tmpFile, "BaseProfile \"Base Profile\"\r\nSelectedGlobalProfile \"Base Profile\"\r\nProfile \"Base Profile\"\r\nShowOn All\r\nProfileType Global\r\nEndProfile\r\n");
|
||||
|
||||
DrsSession((hSession) =>
|
||||
{
|
||||
LoadSettingsFileEx(hSession, tmpFile);
|
||||
SaveSettings(hSession);
|
||||
});
|
||||
}, forceNonGlobalSession: true, preventLoadSettings: true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -137,13 +134,13 @@ namespace nspector.Common
|
||||
var nvRes = nvw.DRS_DeleteProfile(hSession, hProfile);
|
||||
if (nvRes != NvAPI_Status.NVAPI_OK)
|
||||
throw new NvapiException("DRS_DeleteProfile", nvRes);
|
||||
|
||||
|
||||
SaveSettings(hSession);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<string> GetProfileNames(ref string baseProfileName)
|
||||
{
|
||||
var lstResult = new List<string>();
|
||||
@@ -154,7 +151,7 @@ namespace nspector.Common
|
||||
var hBase = GetProfileHandle(hSession, null);
|
||||
var baseProfile = GetProfileInfo(hSession, hBase);
|
||||
tmpBaseProfileName = baseProfile.profileName;
|
||||
|
||||
|
||||
lstResult.Add("_GLOBAL_DRIVER_PROFILE (" + tmpBaseProfileName + ")");
|
||||
|
||||
var profileHandles = EnumProfileHandles(hSession);
|
||||
@@ -178,7 +175,7 @@ namespace nspector.Common
|
||||
DrsSession((hSession) =>
|
||||
{
|
||||
var hProfile = CreateProfile(hSession, profileName);
|
||||
|
||||
|
||||
if (applicationName != null)
|
||||
AddApplication(hSession, hProfile, applicationName);
|
||||
|
||||
@@ -255,7 +252,7 @@ namespace nspector.Common
|
||||
var nvRes = nvw.DRS_RestoreProfileDefaultSetting(hSession, hProfile, settingId);
|
||||
if (nvRes != NvAPI_Status.NVAPI_OK)
|
||||
throw new NvapiException("DRS_RestoreProfileDefaultSetting", nvRes);
|
||||
|
||||
|
||||
SaveSettings(hSession);
|
||||
|
||||
var modifyCount = 0;
|
||||
@@ -282,7 +279,7 @@ namespace nspector.Common
|
||||
var hProfile = GetProfileHandle(hSession, profileName);
|
||||
|
||||
var dwordValue = ReadDwordValue(hSession, hProfile, settingId);
|
||||
|
||||
|
||||
if (dwordValue != null)
|
||||
return dwordValue.Value;
|
||||
else if (returnDefaultValue)
|
||||
@@ -302,7 +299,7 @@ namespace nspector.Common
|
||||
});
|
||||
}
|
||||
|
||||
public int StoreSettingsToProfile(string profileName, List<KeyValuePair<uint,string>> settings)
|
||||
public int StoreSettingsToProfile(string profileName, List<KeyValuePair<uint, string>> settings)
|
||||
{
|
||||
DrsSession((hSession) =>
|
||||
{
|
||||
@@ -335,7 +332,7 @@ namespace nspector.Common
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private SettingItem CreateSettingItem(NVDRS_SETTING setting, bool useDefault = false)
|
||||
{
|
||||
@@ -445,9 +442,11 @@ namespace nspector.Common
|
||||
ValueText = valueText,
|
||||
State = settingState,
|
||||
IsStringValue = settingMeta.SettingType == NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE,
|
||||
IsApiExposed = settingMeta.IsApiExposed,
|
||||
IsSettingHidden = settingMeta.IsSettingHidden,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<SettingItem> GetSettingsForProfile(string profileName, SettingViewMode viewMode, ref Dictionary<string, string> applications)
|
||||
{
|
||||
@@ -459,7 +458,7 @@ namespace nspector.Common
|
||||
applications = DrsSession((hSession) =>
|
||||
{
|
||||
var hProfile = GetProfileHandle(hSession, profileName);
|
||||
|
||||
|
||||
var profileSettings = GetProfileSettings(hSession, hProfile);
|
||||
foreach (var profileSetting in profileSettings)
|
||||
{
|
||||
@@ -471,6 +470,8 @@ namespace nspector.Common
|
||||
|
||||
foreach (var settingId in settingIds)
|
||||
{
|
||||
if (settingId == 0) continue;
|
||||
|
||||
var setting = ReadSetting(hSession, hProfile, settingId);
|
||||
if (setting != null)
|
||||
result.Add(CreateSettingItem(setting.Value));
|
||||
@@ -482,11 +483,11 @@ namespace nspector.Common
|
||||
}
|
||||
|
||||
return GetProfileApplications(hSession, hProfile)
|
||||
.Select(x => Tuple.Create(x.appName,GetApplicationFingerprint(x))).ToDictionary(x=> x.Item2, x=> x.Item1);
|
||||
.Select(x => Tuple.Create(x.appName, GetApplicationFingerprint(x))).ToDictionary(x => x.Item2, x => x.Item1);
|
||||
|
||||
});
|
||||
|
||||
return result.OrderBy(x=>x.SettingText).ThenBy(x=>x.GroupName).ToList();
|
||||
return result.OrderBy(x => x.SettingText).ThenBy(x => x.GroupName).ToList();
|
||||
}
|
||||
|
||||
public void AddApplication(string profileName, string applicationName)
|
||||
@@ -519,7 +520,7 @@ namespace nspector.Common
|
||||
{
|
||||
return $"{application.appName}|{application.fileInFolder}|{application.userFriendlyName}|{application.launcher}";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ namespace nspector.Common
|
||||
protected List<NVDRS_SETTING> GetProfileSettings(IntPtr hSession, IntPtr hProfile)
|
||||
{
|
||||
uint settingCount = 512;
|
||||
var settings = new NVDRS_SETTING[512];
|
||||
var settings = new NVDRS_SETTING[settingCount];
|
||||
settings[0].version = NvapiDrsWrapper.NVDRS_SETTING_VER;
|
||||
|
||||
var esRes = NvapiDrsWrapper.DRS_EnumSettings(hSession, hProfile, 0, ref settingCount, ref settings);
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
using nspector.Common.Meta;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace nspector.Common
|
||||
{
|
||||
public static class DrsUtil
|
||||
{
|
||||
public static string StringValueRaw = "Text";
|
||||
|
||||
|
||||
public static string GetDwordString(uint dword)
|
||||
{
|
||||
return string.Format("0x{0:X8}", dword);
|
||||
@@ -50,7 +48,7 @@ namespace nspector.Common
|
||||
var settingValue = meta.DwordValues
|
||||
.FirstOrDefault(x => x.Value.Equals(dwordValue));
|
||||
|
||||
return settingValue == null ? GetDwordString(dwordValue): settingValue.ValueName;
|
||||
return settingValue == null ? GetDwordString(dwordValue) : settingValue.ValueName;
|
||||
}
|
||||
|
||||
internal static string ParseStringSettingValue(SettingMeta meta, string text)
|
||||
|
||||
@@ -9,9 +9,9 @@ namespace nspector.Common.Helper
|
||||
{
|
||||
var identity = WindowsIdentity.GetCurrent();
|
||||
var principal = new WindowsPrincipal(identity);
|
||||
isAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
isAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
}
|
||||
|
||||
|
||||
public static bool IsAdmin
|
||||
{
|
||||
get { return isAdmin; }
|
||||
|
||||
82
nspector/Common/Helper/DropDownMenuScrollWheelHandler.cs
Normal file
82
nspector/Common/Helper/DropDownMenuScrollWheelHandler.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace nspector.Common.Helper
|
||||
{
|
||||
|
||||
//by Bryce Wagner https://stackoverflow.com/questions/13139074/mouse-wheel-scrolling-toolstrip-menu-items
|
||||
|
||||
public class DropDownMenuScrollWheelHandler : IMessageFilter
|
||||
{
|
||||
private static DropDownMenuScrollWheelHandler Instance;
|
||||
public static void Enable(bool enabled)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = new DropDownMenuScrollWheelHandler();
|
||||
Application.AddMessageFilter(Instance);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Instance != null)
|
||||
{
|
||||
Application.RemoveMessageFilter(Instance);
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
private IntPtr activeHwnd;
|
||||
private ToolStripDropDown activeMenu;
|
||||
|
||||
public bool PreFilterMessage(ref Message m)
|
||||
{
|
||||
if (m.Msg == 0x200 && activeHwnd != m.HWnd) // WM_MOUSEMOVE
|
||||
{
|
||||
activeHwnd = m.HWnd;
|
||||
this.activeMenu = Control.FromHandle(m.HWnd) as ToolStripDropDown;
|
||||
}
|
||||
else if (m.Msg == 0x20A && this.activeMenu != null) // WM_MOUSEWHEEL
|
||||
{
|
||||
int delta = (short)(ushort)(((uint)(ulong)m.WParam) >> 16);
|
||||
HandleDelta(this.activeMenu, delta);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static readonly Action<ToolStrip, int> ScrollInternal
|
||||
= (Action<ToolStrip, int>)Delegate.CreateDelegate(typeof(Action<ToolStrip, int>),
|
||||
typeof(ToolStrip).GetMethod("ScrollInternal",
|
||||
System.Reflection.BindingFlags.NonPublic
|
||||
| System.Reflection.BindingFlags.Instance));
|
||||
|
||||
private void HandleDelta(ToolStripDropDown ts, int delta)
|
||||
{
|
||||
if (ts.Items.Count == 0)
|
||||
return;
|
||||
|
||||
var firstItem = ts.Items[0];
|
||||
var lastItem = ts.Items[ts.Items.Count - 1];
|
||||
|
||||
if (lastItem.Bounds.Bottom < ts.Height && firstItem.Bounds.Top > 0)
|
||||
return;
|
||||
|
||||
delta = delta / -4;
|
||||
|
||||
if (delta < 0 && firstItem.Bounds.Top - delta > 9)
|
||||
{
|
||||
delta = firstItem.Bounds.Top - 9;
|
||||
}
|
||||
else if (delta > 0 && delta > lastItem.Bounds.Bottom - ts.Height + 9)
|
||||
{
|
||||
delta = lastItem.Bounds.Bottom - ts.Height + 9;
|
||||
}
|
||||
|
||||
if (delta != 0)
|
||||
ScrollInternal(ts, delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace nspector.Common.Helper
|
||||
var buttonCancel = new Button();
|
||||
var imageBox = new PictureBox();
|
||||
|
||||
EventHandler textchanged = delegate(object sender, EventArgs e)
|
||||
EventHandler textchanged = delegate (object sender, EventArgs e)
|
||||
{
|
||||
bool mandatory_success = Regex.IsMatch(textBox.Text, mandatoryFormatRegExPattern);
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace nspector.Common.Helper
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using nspector.Native.WINAPI;
|
||||
|
||||
namespace nspector.Common.Helper
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.Win32;
|
||||
@@ -36,7 +35,7 @@ namespace nspector.Common.Helper
|
||||
if (steamPath != null)
|
||||
return Path.Combine(steamPath, @"appcache\appinfo.vdf");
|
||||
}
|
||||
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -90,7 +89,7 @@ namespace nspector.Common.Helper
|
||||
|
||||
var bid = BitConverter.GetBytes(appid);
|
||||
int offset = 0;
|
||||
|
||||
|
||||
var appidPattern = new byte[] { 0x08, bid[0], bid[1], bid[2], bid[3] };
|
||||
var launchPattern = new byte[] { 0x00, 0x6C, 0x61, 0x75, 0x6E, 0x63, 0x68, 0x00 };
|
||||
|
||||
@@ -157,7 +156,7 @@ namespace nspector.Common.Helper
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static int FindOffset(byte[] bytes, byte[] pattern, int offset = 0, byte? wildcard = null)
|
||||
{
|
||||
for (int i = offset; i < bytes.Length; i++)
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace nspector.Common.Helper
|
||||
{
|
||||
@@ -16,7 +12,7 @@ namespace nspector.Common.Helper
|
||||
var tempFile = GenerateTempFileName();
|
||||
if (!File.Exists(tempFile))
|
||||
return tempFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string GenerateTempFileName()
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace nspector.Common.Helper
|
||||
{
|
||||
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"); ;
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using nspector.Native.NVAPI2;
|
||||
|
||||
namespace nspector.Common.Import
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace nspector.Common.Import
|
||||
|
||||
[XmlElement(ElementName = "SettingID")]
|
||||
public uint SettingId = 0;
|
||||
|
||||
|
||||
public string SettingValue = "0";
|
||||
|
||||
public SettingValueType ValueType = SettingValueType.Dword;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace nspector.Common.Import
|
||||
{
|
||||
public enum SettingValueType: int
|
||||
public enum SettingValueType : int
|
||||
{
|
||||
Dword,
|
||||
AnsiString,
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using nspector.Native.NvApi.DriverSettings;
|
||||
using nspector.Native.NVAPI2;
|
||||
|
||||
@@ -19,7 +18,7 @@ namespace nspector.Common.Meta
|
||||
|
||||
private readonly Dictionary<ESetting, Type> settingEnumTypeCache;
|
||||
|
||||
private string[] ignoreSettingNames = new[] { "TOTAL_DWORD_SETTING_NUM", "TOTAL_WSTRING_SETTING_NUM",
|
||||
private string[] ignoreSettingNames = new[] { "TOTAL_DWORD_SETTING_NUM", "TOTAL_WSTRING_SETTING_NUM",
|
||||
"TOTAL_SETTING_NUM", "INVALID_SETTING_ID" };
|
||||
|
||||
private Dictionary<ESetting, Type> CreateSettingEnumTypeCache()
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using nspector.Common.CustomSettings;
|
||||
using nspector.Native.NVAPI2;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace nspector.Common.Meta
|
||||
{
|
||||
@@ -74,11 +72,11 @@ namespace nspector.Common.Meta
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public List<uint> GetSettingIds()
|
||||
{
|
||||
return customSettings.Settings
|
||||
.Select(x => x.SettingId).ToList();
|
||||
return customSettings.Settings
|
||||
.Select(x => x.SettingId).ToList();
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +101,14 @@ namespace nspector.Common.Meta
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsSettingHidden(uint settingId)
|
||||
{
|
||||
var setting = customSettings.Settings
|
||||
.FirstOrDefault(x => x.SettingId.Equals(settingId));
|
||||
|
||||
return setting?.Hidden ?? false;
|
||||
}
|
||||
|
||||
public SettingMetaSource Source
|
||||
{
|
||||
get { return _source; }
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using nspector.Common.CustomSettings;
|
||||
|
||||
using nspector.Native.NvApi.DriverSettings;
|
||||
using nspector.Native.NVAPI2;
|
||||
using nvw = nspector.Native.NVAPI2.NvapiDrsWrapper;
|
||||
using nvw = nspector.Native.NVAPI2.NvapiDrsWrapper;
|
||||
|
||||
namespace nspector.Common.Meta
|
||||
{
|
||||
@@ -26,14 +20,14 @@ namespace nspector.Common.Meta
|
||||
private List<uint> InitSettingIds()
|
||||
{
|
||||
var settingIds = new List<uint>();
|
||||
|
||||
|
||||
var nvRes = nvw.DRS_EnumAvailableSettingIds(out settingIds, 512);
|
||||
if (nvRes != NvAPI_Status.NVAPI_OK)
|
||||
throw new NvapiException("DRS_EnumAvailableSettingIds", nvRes);
|
||||
|
||||
return settingIds;
|
||||
}
|
||||
|
||||
|
||||
private SettingMeta GetDriverSettingMetaInternal(uint settingId)
|
||||
{
|
||||
var values = new NVDRS_SETTING_VALUES();
|
||||
@@ -44,10 +38,10 @@ namespace nspector.Common.Meta
|
||||
|
||||
if (nvRes == NvAPI_Status.NVAPI_SETTING_NOT_FOUND)
|
||||
return null;
|
||||
|
||||
|
||||
if (nvRes != NvAPI_Status.NVAPI_OK)
|
||||
throw new NvapiException("DRS_EnumAvailableSettingValues", nvRes);
|
||||
|
||||
|
||||
|
||||
var sbSettingName = new StringBuilder((int)NvapiDrsWrapper.NVAPI_UNICODE_STRING_MAX);
|
||||
nvRes = nvw.DRS_GetSettingNameFromId(settingId, sbSettingName);
|
||||
@@ -58,11 +52,12 @@ namespace nspector.Common.Meta
|
||||
if (string.IsNullOrWhiteSpace(settingName))
|
||||
settingName = DrsUtil.GetDwordString(settingId);
|
||||
|
||||
var result = new SettingMeta {
|
||||
var result = new SettingMeta
|
||||
{
|
||||
SettingType = values.settingType,
|
||||
SettingName = settingName,
|
||||
};
|
||||
|
||||
|
||||
|
||||
if (values.settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE)
|
||||
{
|
||||
@@ -71,13 +66,14 @@ namespace nspector.Common.Meta
|
||||
for (int i = 0; i < values.numSettingValues; i++)
|
||||
{
|
||||
result.DwordValues.Add(
|
||||
new SettingValue<uint> (Source) {
|
||||
new SettingValue<uint>(Source)
|
||||
{
|
||||
Value = values.settingValues[i].dwordValue,
|
||||
ValueName = DrsUtil.GetDwordString(values.settingValues[i].dwordValue),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (values.settingType == NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE)
|
||||
{
|
||||
result.DefaultStringValue = values.defaultValue.stringValue;
|
||||
@@ -116,7 +112,7 @@ namespace nspector.Common.Meta
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private SettingMeta GetSettingsMeta(uint settingId)
|
||||
@@ -135,13 +131,13 @@ namespace nspector.Common.Meta
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string GetSettingName(uint settingId)
|
||||
{
|
||||
var settingMeta = GetSettingsMeta(settingId);
|
||||
if (settingMeta != null)
|
||||
return settingMeta.SettingName;
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -180,7 +176,7 @@ namespace nspector.Common.Meta
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public List<uint> GetSettingIds()
|
||||
{
|
||||
return _settingIds;
|
||||
@@ -194,7 +190,7 @@ namespace nspector.Common.Meta
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public string GetGroupName(uint settingId)
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace nspector.Common.Meta
|
||||
{
|
||||
internal interface ISettingMetaService
|
||||
{
|
||||
SettingMetaSource Source {get; }
|
||||
SettingMetaSource Source { get; }
|
||||
|
||||
NVDRS_SETTING_TYPE? GetSettingValueType(uint settingId);
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace nspector.Common.Meta
|
||||
|
||||
public string GetSettingName(uint settingId)
|
||||
{
|
||||
var cached = CachedSettings.FirstOrDefault(x=>x.SettingId.Equals(settingId));
|
||||
var cached = CachedSettings.FirstOrDefault(x => x.SettingId.Equals(settingId));
|
||||
if (cached != null)
|
||||
return string.Format("0x{0:X8} ({1} Profiles)", settingId, cached.ProfileCount);
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace nspector.Common.Meta
|
||||
|
||||
public List<SettingValue<uint>> GetDwordValues(uint settingId)
|
||||
{
|
||||
var cached = CachedSettings.FirstOrDefault(x=>x.SettingId.Equals(settingId));
|
||||
var cached = CachedSettings.FirstOrDefault(x => x.SettingId.Equals(settingId));
|
||||
if (cached != null)
|
||||
return cached.SettingValues.Select(s => new SettingValue<uint>(Source)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using nspector.Native.NVAPI2;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace nspector.Common.Meta
|
||||
{
|
||||
@@ -20,6 +17,10 @@ namespace nspector.Common.Meta
|
||||
|
||||
public byte[] DefaultBinaryValue { get; set; }
|
||||
|
||||
public bool IsApiExposed { get; set; }
|
||||
|
||||
public bool IsSettingHidden { get; set; }
|
||||
|
||||
public List<SettingValue<string>> StringValues { get; set; }
|
||||
|
||||
public List<SettingValue<uint>> DwordValues { get; set; }
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace nspector.Common.Meta
|
||||
namespace nspector.Common.Meta
|
||||
{
|
||||
public enum SettingMetaSource
|
||||
{
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace nspector.Common.Meta
|
||||
namespace nspector.Common.Meta
|
||||
{
|
||||
internal class SettingValue<T>
|
||||
{
|
||||
@@ -14,7 +9,7 @@ namespace nspector.Common.Meta
|
||||
{
|
||||
ValueSource = source;
|
||||
}
|
||||
|
||||
|
||||
public int ValuePos { get; set; }
|
||||
public string ValueName { get; set; }
|
||||
public T Value { get; set; }
|
||||
@@ -26,6 +21,6 @@ namespace nspector.Common.Meta
|
||||
|
||||
return string.Format("Value={0}; ValueName={1};", Value, ValueName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using nspector.Native.NVAPI2;
|
||||
|
||||
namespace nspector.Common
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace nspector.Common
|
||||
namespace nspector.Common
|
||||
{
|
||||
|
||||
internal enum SettingState
|
||||
@@ -17,7 +12,7 @@ namespace nspector.Common
|
||||
internal class SettingItem
|
||||
{
|
||||
public uint SettingId { get; set; }
|
||||
|
||||
|
||||
public string SettingText { get; set; }
|
||||
|
||||
public string ValueText { get; set; }
|
||||
@@ -30,6 +25,10 @@ namespace nspector.Common
|
||||
|
||||
public bool IsStringValue { get; set; }
|
||||
|
||||
public bool IsApiExposed { get; set; }
|
||||
|
||||
public bool IsSettingHidden { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0}; 0x{1:X8}; {2}; {3}; {4};", State, SettingId, SettingText, ValueText, ValueRaw);
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace nspector.Common
|
||||
namespace nspector.Common
|
||||
{
|
||||
public enum SettingViewMode
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -586,13 +586,24 @@ namespace nspector.Native.NVAPI2
|
||||
public delegate NvAPI_Status DRS_FindApplicationByNameDelegate(IntPtr hSession, [MarshalAs(UnmanagedType.LPWStr, SizeConst = (int)NvapiDrsWrapper.NVAPI_UNICODE_STRING_MAX)]StringBuilder appName, ref IntPtr phProfile, ref NVDRS_APPLICATION_V3 pApplication);
|
||||
public static readonly DRS_FindApplicationByNameDelegate DRS_FindApplicationByName;
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate NvAPI_Status DRS_SetSettingDelegate(IntPtr hSession, IntPtr hProfile, ref NVDRS_SETTING pSetting);
|
||||
public static readonly DRS_SetSettingDelegate DRS_SetSetting;
|
||||
public static NvAPI_Status DRS_SetSetting(IntPtr hSession, IntPtr hProfile, ref NVDRS_SETTING pSetting)
|
||||
{
|
||||
return _DRS_SetSetting(hSession, hProfile, ref pSetting, 0, 0);
|
||||
}
|
||||
|
||||
public static NvAPI_Status DRS_GetSetting(IntPtr hSession, IntPtr hProfile, uint settingId, ref NVDRS_SETTING pSetting)
|
||||
{
|
||||
uint x = 0;
|
||||
return _DRS_GetSetting(hSession, hProfile, settingId, ref pSetting, ref x);
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate NvAPI_Status DRS_GetSettingDelegate(IntPtr hSession, IntPtr hProfile, uint settingId, ref NVDRS_SETTING pSetting);
|
||||
public static readonly DRS_GetSettingDelegate DRS_GetSetting;
|
||||
public delegate NvAPI_Status DRS_SetSettingDelegate(IntPtr hSession, IntPtr hProfile, ref NVDRS_SETTING pSetting, uint x, uint y);
|
||||
private static readonly DRS_SetSettingDelegate _DRS_SetSetting;
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate NvAPI_Status DRS_GetSettingDelegate(IntPtr hSession, IntPtr hProfile, uint settingId, ref NVDRS_SETTING pSetting, ref uint x);
|
||||
private static readonly DRS_GetSettingDelegate _DRS_GetSetting;
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate NvAPI_Status DRS_EnumSettingsDelegate(IntPtr hSession, IntPtr hProfile, uint startIndex, ref uint settingsCount, IntPtr pSetting);
|
||||
@@ -728,17 +739,17 @@ namespace nspector.Native.NVAPI2
|
||||
GetDelegate(0xED1F8C69, out DRS_GetApplicationInfo);
|
||||
GetDelegate(0x7FA2173A, out DRS_EnumApplicationsInternal);
|
||||
GetDelegate(0xEEE566B2, out DRS_FindApplicationByName);
|
||||
GetDelegate(0x577DD202, out DRS_SetSetting);
|
||||
GetDelegate(0x73BF8338, out DRS_GetSetting);
|
||||
GetDelegate(0xAE3039DA, out DRS_EnumSettingsInternal);
|
||||
GetDelegate(0xF020614A, out DRS_EnumAvailableSettingIdsInternal);
|
||||
GetDelegate(0x8A2CF5F5, out _DRS_SetSetting);
|
||||
GetDelegate(0xEA99498D, out _DRS_GetSetting);
|
||||
GetDelegate(0xCFD6983E, out DRS_EnumSettingsInternal);
|
||||
GetDelegate(0xE5DE48E5, out DRS_EnumAvailableSettingIdsInternal);
|
||||
GetDelegate(0x2EC39F90, out DRS_EnumAvailableSettingValuesInternal);
|
||||
GetDelegate(0xCB7309CD, out DRS_GetSettingIdFromName);
|
||||
GetDelegate(0xD61CBE6E, out DRS_GetSettingNameFromId);
|
||||
GetDelegate(0x1EB13791, out DRS_GetSettingNameFromId);
|
||||
GetDelegate(0xE4A26362, out DRS_DeleteProfileSetting);
|
||||
GetDelegate(0x5927B094, out DRS_RestoreAllDefaults);
|
||||
GetDelegate(0xFA5F6134, out DRS_RestoreProfileDefault);
|
||||
GetDelegate(0x53F0381E, out DRS_RestoreProfileDefaultSetting);
|
||||
GetDelegate(0x7DD5B261, out DRS_RestoreProfileDefaultSetting);
|
||||
GetDelegate(0xDA8466A0, out DRS_GetBaseProfile);
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace nspector.Native
|
||||
{
|
||||
@@ -51,6 +49,6 @@ namespace nspector.Native
|
||||
targetPointer = Marshal.AllocHGlobal(sizeOfItem);
|
||||
Marshal.StructureToPtr(item, targetPointer, true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ namespace nspector.Native.WINAPI
|
||||
internal string lpData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
internal struct WINDOWPLACEMENT
|
||||
{
|
||||
internal int length;
|
||||
@@ -301,7 +301,7 @@ namespace nspector.Native.WINAPI
|
||||
internal bool bringAppToFront(int hWnd)
|
||||
{
|
||||
WINDOWPLACEMENT param = new WINDOWPLACEMENT();
|
||||
if (GetWindowPlacement(hWnd,ref param))
|
||||
if (GetWindowPlacement(hWnd, ref param))
|
||||
{
|
||||
if (param.showCmd != SW_NORMAL)
|
||||
{
|
||||
@@ -312,7 +312,7 @@ namespace nspector.Native.WINAPI
|
||||
}
|
||||
return SetForegroundWindow(hWnd);
|
||||
}
|
||||
|
||||
|
||||
internal int sendWindowsStringMessage(int hWnd, int wParam, string msg)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
@@ -241,7 +241,7 @@ namespace nspector.Native.WINAPI
|
||||
private class NativeMethods
|
||||
{
|
||||
[DllImport("Shell32", CharSet = CharSet.Auto)]
|
||||
internal extern static int ExtractIconEx([MarshalAs(UnmanagedType.LPTStr)]
|
||||
internal extern static int ExtractIconEx([MarshalAs(UnmanagedType.LPTStr)]
|
||||
string lpszFile,
|
||||
int nIconIndex,
|
||||
IntPtr[] phIconLarge,
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace nspector.Native.WINAPI
|
||||
THBF_NOBACKGROUND = 0x0004,
|
||||
THBF_HIDDEN = 0x0008
|
||||
}
|
||||
|
||||
|
||||
[Flags]
|
||||
internal enum THB
|
||||
{
|
||||
@@ -37,18 +37,18 @@ namespace nspector.Native.WINAPI
|
||||
}
|
||||
|
||||
internal enum TBPFLAG
|
||||
{
|
||||
TBPF_NOPROGRESS = 0,
|
||||
TBPF_INDETERMINATE = 0x1,
|
||||
TBPF_NORMAL = 0x2,
|
||||
TBPF_ERROR = 0x4,
|
||||
TBPF_PAUSED = 0x8
|
||||
{
|
||||
TBPF_NOPROGRESS = 0,
|
||||
TBPF_INDETERMINATE = 0x1,
|
||||
TBPF_NORMAL = 0x2,
|
||||
TBPF_ERROR = 0x4,
|
||||
TBPF_PAUSED = 0x8
|
||||
}
|
||||
|
||||
internal enum TBATFLAG
|
||||
{
|
||||
TBATF_USEMDITHUMBNAIL = 0x1,
|
||||
TBATF_USEMDILIVEPREVIEW = 0x2
|
||||
{
|
||||
TBATF_USEMDITHUMBNAIL = 0x1,
|
||||
TBATF_USEMDILIVEPREVIEW = 0x2
|
||||
}
|
||||
|
||||
[ComImport,
|
||||
@@ -57,7 +57,7 @@ namespace nspector.Native.WINAPI
|
||||
internal interface ITaskbarList3
|
||||
{
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall,
|
||||
[MethodImpl(MethodImplOptions.InternalCall,
|
||||
MethodCodeType = MethodCodeType.Runtime)]
|
||||
void HrInit();
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace nspector.Native.WINAPI
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall,
|
||||
MethodCodeType = MethodCodeType.Runtime)]
|
||||
void MarkFullscreenWindow([In] IntPtr hwnd,
|
||||
void MarkFullscreenWindow([In] IntPtr hwnd,
|
||||
[In, MarshalAs(UnmanagedType.Bool)] bool fFullscreen);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall,
|
||||
@@ -87,8 +87,8 @@ namespace nspector.Native.WINAPI
|
||||
void SetProgressValue([In] IntPtr hwnd,
|
||||
[In] ulong ullCompleted,
|
||||
[In] ulong ullTotal);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall,
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall,
|
||||
MethodCodeType = MethodCodeType.Runtime)]
|
||||
void SetProgressState([In] IntPtr hwnd,
|
||||
[In] TBPFLAG tbpFlags);
|
||||
@@ -120,7 +120,7 @@ namespace nspector.Native.WINAPI
|
||||
[In] uint cButtons,
|
||||
[In] IntPtr pButton);
|
||||
///* [size_is][in] */ __RPC__in_ecount_full(cButtons) LPTHUMBBUTTON pButton);
|
||||
|
||||
|
||||
//preliminary
|
||||
[MethodImpl(MethodImplOptions.InternalCall,
|
||||
MethodCodeType = MethodCodeType.Runtime)]
|
||||
@@ -150,7 +150,7 @@ namespace nspector.Native.WINAPI
|
||||
MethodCodeType = MethodCodeType.Runtime)]
|
||||
void SetThumbnailClip([In] IntPtr hwnd,
|
||||
[In] IntPtr prcClip);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.IO;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using nspector.Common;
|
||||
using nspector.Common.Import;
|
||||
using nspector.Common.Helper;
|
||||
using nspector.Native.WINAPI;
|
||||
|
||||
namespace nspector
|
||||
@@ -29,6 +29,7 @@ namespace nspector
|
||||
#endif
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
DropDownMenuScrollWheelHandler.Enable(true);
|
||||
|
||||
var argFileIndex = ArgFileIndex(args);
|
||||
if (argFileIndex != -1)
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("NVIDIA Profile Inspector")]
|
||||
[assembly: AssemblyCopyright("©2020 by Orbmu2k")]
|
||||
[assembly: AssemblyCopyright("©2022 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.3.0.0")]
|
||||
[assembly: AssemblyFileVersion("2.3.0.0")]
|
||||
[assembly: AssemblyVersion("2.4.0.1")]
|
||||
[assembly: AssemblyFileVersion("2.4.0.1")]
|
||||
|
||||
|
||||
|
||||
24
nspector/Properties/Resources.Designer.cs
generated
24
nspector/Properties/Resources.Designer.cs
generated
@@ -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", "15.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class Resources {
|
||||
@@ -73,17 +73,19 @@ namespace nspector.Properties {
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die <?xml version="1.0" encoding="utf-8"?>
|
||||
///<CustomSettingNames>
|
||||
/// <ShowCustomizedSettingNamesOnly>false</ShowCustomizedSettingNamesOnly>
|
||||
/// <Settings>
|
||||
/// <CustomSetting>
|
||||
/// <UserfriendlyName>NVLINK SLI Mode</UserfriendlyName>
|
||||
/// <HexSettingID>0x00A06948</HexSettingID>
|
||||
/// <GroupName>6 - SLI</GroupName>
|
||||
/// <MinRequiredDriverVersion>410.00</MinRequiredDriverVersion>
|
||||
/// </CustomSetting>
|
||||
/// <CustomSetting>
|
||||
/// <UserfriendlyName>Texture filtering - Quality substitution</UserfriendlyName>
|
||||
/// [Rest der Zeichenfolge wurde abgeschnitten]"; ähnelt.
|
||||
/// <CustomSetting>
|
||||
/// <UserfriendlyName>VRR Support Indicator</UserfriendlyName>
|
||||
/// <HexSettingID>0x8df510</HexSettingID>
|
||||
/// <GroupName>2 - Sync and Refresh</GroupName>
|
||||
/// <SettingValues>
|
||||
/// <CustomSettingValue>
|
||||
/// <UserfriendlyName>Off</UserfriendlyName>
|
||||
/// <HexValue>0x00000000</HexValue>
|
||||
/// </CustomSettingValue>
|
||||
/// <CustomSettingValue>
|
||||
/// <UserfriendlyName>On</UserfriendlyName>
|
||||
/// <HexValue>0x0000000 [Rest der Zeichenfolge wurde abgeschnitten]"; ähnelt.
|
||||
/// </summary>
|
||||
public static string CustomSettingNames {
|
||||
get {
|
||||
|
||||
3
nspector/app.config
Normal file
3
nspector/app.config
Normal file
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
|
||||
@@ -150,7 +150,13 @@ namespace nspector
|
||||
|
||||
foreach (var settingItem in _currentProfileSettingItems)
|
||||
{
|
||||
lvSettings.Items.Add(CreateListViewItem(settingItem));
|
||||
if (settingItem.IsSettingHidden) continue;
|
||||
|
||||
var itm = lvSettings.Items.Add(CreateListViewItem(settingItem));
|
||||
if (Debugger.IsAttached && !settingItem.IsApiExposed)
|
||||
{
|
||||
itm.ForeColor = Color.LightCoral;
|
||||
}
|
||||
}
|
||||
|
||||
btnResetValue.Enabled = false;
|
||||
@@ -845,6 +851,9 @@ namespace nspector
|
||||
if (MessageBox.Show(this, "Really delete all profiles?", "Delete all profiles", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
|
||||
{
|
||||
_drs.DeleteAllProfilesHard();
|
||||
ChangeCurrentProfile(_baseProfileName);
|
||||
DrsSessionScope.DestroyGlobalSession();
|
||||
RefreshAll();
|
||||
}
|
||||
}
|
||||
else if (MessageBox.Show(this, "Really delete this profile?\r\n\r\nNote: NVIDIA predefined profiles can not be restored until next driver installation!", "Delete Profile", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
|
||||
@@ -1213,8 +1222,71 @@ namespace nspector
|
||||
{
|
||||
CopyModifiedSettingsToClipBoard();
|
||||
}
|
||||
|
||||
if (Debugger.IsAttached && e.Control && e.KeyCode == Keys.T)
|
||||
{
|
||||
TestStoreSettings();
|
||||
}
|
||||
}
|
||||
|
||||
private void TestStoreSettings()
|
||||
{
|
||||
var sbSettings = new StringBuilder();
|
||||
sbSettings.AppendFormat("{0,-40} {1}\r\n", "### Inspector Store Failed ###", _CurrentProfile);
|
||||
|
||||
pbMain.Minimum = 0;
|
||||
pbMain.Maximum = lvSettings.Items.Count;
|
||||
int cntIndex = 0;
|
||||
|
||||
foreach (ListViewGroup group in lvSettings.Groups)
|
||||
{
|
||||
bool groupTitleAdded = false;
|
||||
foreach (ListViewItem item in group.Items)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
pbMain.Value = cntIndex++;
|
||||
|
||||
var settingId = (uint)item.Tag;
|
||||
var meta = _meta.GetSettingMeta(settingId);
|
||||
if (meta.SettingType != NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE) continue;
|
||||
|
||||
var wasNotSet = new int[] { 1, 2, 3 }.Contains(item.ImageIndex);
|
||||
|
||||
if (wasNotSet)
|
||||
{
|
||||
_drs.SetDwordValueToProfile(_CurrentProfile, settingId, 0x0);
|
||||
_drs.ResetValue(_CurrentProfile, settingId, out var rm);
|
||||
}
|
||||
else
|
||||
{
|
||||
var tmpValue = _drs.GetDwordValueFromProfile(_CurrentProfile, settingId);
|
||||
_drs.SetDwordValueToProfile(_CurrentProfile, settingId, 0x0);
|
||||
_drs.SetDwordValueToProfile(_CurrentProfile, settingId, tmpValue);
|
||||
}
|
||||
|
||||
}
|
||||
catch (NvapiException ne)
|
||||
{
|
||||
if (!groupTitleAdded)
|
||||
{
|
||||
sbSettings.AppendFormat("\r\n[{0}]\r\n", group.Header);
|
||||
groupTitleAdded = true;
|
||||
}
|
||||
sbSettings.AppendFormat("{0,-40} SettingId: {1} Failed: {2}\r\n", item.Text, DrsUtil.GetDwordString((uint)item.Tag), ne.Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pbMain.Value = 0;
|
||||
|
||||
Clipboard.SetText(sbSettings.ToString());
|
||||
MessageBox.Show("Failed Settings Stored to Clipboard");
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void CopyModifiedSettingsToClipBoard()
|
||||
{
|
||||
var sbSettings = new StringBuilder();
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>nspector</RootNamespace>
|
||||
<AssemblyName>nvidiaProfileInspector</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<TargetFrameworkProfile />
|
||||
@@ -135,6 +135,7 @@
|
||||
<Compile Include="Common\DrsSessionScope.cs" />
|
||||
<Compile Include="Common\DrsSettingsMetaService.cs" />
|
||||
<Compile Include="Common\DrsUtil.cs" />
|
||||
<Compile Include="Common\Helper\DropDownMenuScrollWheelHandler.cs" />
|
||||
<Compile Include="Common\Helper\ListViewGroupSorter.cs" />
|
||||
<Compile Include="Common\Helper\ShortcutResolver.cs" />
|
||||
<Compile Include="Common\Helper\SteamAppResolver.cs" />
|
||||
@@ -225,6 +226,7 @@
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="app.config" />
|
||||
<None Include="app.manifest">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
|
||||
Reference in New Issue
Block a user