Compare commits

..

5 Commits

Author SHA1 Message Date
Orbmu2k
8b6c13216a possible fix for #131 2023-03-26 11:35:33 +02:00
Orbmu2k
3c74a9b5e5 additional invariant culture checks for lower case 2023-03-26 11:30:05 +02:00
Orbmu2k
70c63b1239 possible fix for #128 2023-03-26 11:27:21 +02:00
Orbmu2k
f003324d55 fallback functionIds 2023-03-26 11:25:42 +02:00
Orbmu2k
b9563767ef fixed dpi 2022-11-30 23:22:10 +01:00
11 changed files with 51 additions and 30 deletions

View File

@@ -89,7 +89,7 @@ namespace nspector.Common
private string FormatInternalSettingKey(string profileName, uint settingId)
{
return profileName + settingId.ToString("X8").ToLower();
return profileName + settingId.ToString("X8").ToLowerInvariant();
}
public bool IsInternalSetting(string profileName, uint settingId)

View File

@@ -198,7 +198,7 @@ namespace nspector.Common
public string FindProfilesUsingApplication(string applicationName)
{
string lowerApplicationName = applicationName.ToLower();
string lowerApplicationName = applicationName.ToLowerInvariant();
string tmpfile = TempFile.GetTempFileName();
try
@@ -219,7 +219,7 @@ namespace nspector.Common
string scope = m.Result("${scope}");
foreach (Match ms in Regex.Matches(scope, "Executable\\s\\\"(?<app>.*?)\\\"", RegexOptions.Singleline))
{
if (ms.Result("${app}").ToLower() == lowerApplicationName)
if (ms.Result("${app}").ToLowerInvariant() == lowerApplicationName)
{
matchingProfiles.Add(m.Result("${profile}"));
}

View File

@@ -17,7 +17,7 @@ namespace nspector.Common
public static uint ParseDwordByInputSafe(string input)
{
uint result = 0;
if (input.ToLower().StartsWith("0x"))
if (input.ToLowerInvariant().StartsWith("0x"))
{
try
{

View File

@@ -8,6 +8,7 @@ namespace nspector.Common.Helper
{
internal class InputBox
{
internal static DialogResult Show(string title, string promptText, ref string value, List<string> invalidInputs, string mandatoryFormatRegExPattern, int maxLength)
{
var form = new Form();
@@ -59,12 +60,12 @@ namespace nspector.Common.Helper
buttonOk.Enabled = false;
label.SetBounds(9, 20, 372, 13);
textBox.SetBounds(12, 36, 352, 20);
buttonOk.SetBounds(228, 72, 75, 23);
buttonCancel.SetBounds(309, 72, 75, 23);
label.SetBounds(Dpi(9), Dpi(20), Dpi(372), Dpi(13));
textBox.SetBounds(Dpi(12), Dpi(36), Dpi(352), Dpi(20));
buttonOk.SetBounds(Dpi(228), Dpi(72), Dpi(75), Dpi(23));
buttonCancel.SetBounds(Dpi(309), Dpi(72), Dpi(75), Dpi(23));
imageBox.SetBounds(368, 36, 16, 16);
imageBox.SetBounds(Dpi(368), Dpi(36), Dpi(16), Dpi(16));
label.AutoSize = true;
imageBox.Anchor = AnchorStyles.Top | AnchorStyles.Right;
@@ -72,9 +73,9 @@ namespace nspector.Common.Helper
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
form.ClientSize = new Size(396, 107);
form.ClientSize = new Size(Dpi(396), Dpi(107));
form.ClientSize = new Size(Math.Max(Dpi(300), label.Right + Dpi(10)), form.ClientSize.Height);
form.Controls.AddRange(new Control[] { label, textBox, imageBox, buttonOk, buttonCancel });
form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterParent;
form.MinimizeBox = false;
@@ -88,5 +89,10 @@ namespace nspector.Common.Helper
value = textBox.Text;
return dialogResult;
}
private static int Dpi(int input)
{
return (int)Math.Round(input * frmDrvSettings.ScaleFactor);
}
}
}

View File

@@ -30,7 +30,7 @@ namespace nspector.Common.Helper
try
{
switch (fileInfo.Extension.ToLower())
switch (fileInfo.Extension.ToLowerInvariant())
{
case ".lnk": return ResolveFromShellLinkFile(fileInfo.FullName);
case ".url": return ResolveFromUrlFile(fileInfo.FullName);
@@ -54,7 +54,7 @@ namespace nspector.Common.Helper
}
var targetInfo = new FileInfo(shellLink.Target);
if (targetInfo.Name.ToLower() == SteamAppResolver.SteamExeName)
if (targetInfo.Name.ToLowerInvariant() == SteamAppResolver.SteamExeName)
{
if (shellLink.Arguments.Contains(SteamAppResolver.SteamArgumentPattern))
{
@@ -63,7 +63,7 @@ namespace nspector.Common.Helper
}
}
if (targetInfo.Extension.ToLower().Equals(".exe"))
if (targetInfo.Extension.ToLowerInvariant().Equals(".exe"))
{
return targetInfo.Name;
}

View File

@@ -41,7 +41,14 @@ namespace nspector.Common.Helper
var filename = GetSettingsFilename();
if (!File.Exists(filename)) return new UserSettings();
return XMLHelper<UserSettings>.DeserializeFromXMLFile(GetSettingsFilename());
try
{
return XMLHelper<UserSettings>.DeserializeFromXMLFile(GetSettingsFilename());
}
catch
{
return new UserSettings();
}
}
}
}

View File

@@ -30,7 +30,7 @@ namespace nspector.Common.Meta
{
if (string.IsNullOrEmpty(type)) return null;
switch(type.ToLower())
switch(type.ToLowerInvariant())
{
case "dword":
return NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE;

View File

@@ -424,13 +424,17 @@ namespace nspector.Native.NVAPI2
}
}
private static void GetDelegate<T>(uint id, out T newDelegate) where T : class
private static void GetDelegate<T>(uint id, out T newDelegate, uint? fallbackId = null) where T : class
{
IntPtr ptr = nvapi_QueryInterface(id);
if (ptr != IntPtr.Zero)
{
newDelegate = Marshal.GetDelegateForFunctionPointer(ptr, typeof(T)) as T;
}
else if (fallbackId.HasValue)
{
GetDelegate(fallbackId.Value, out newDelegate);
}
else
{
newDelegate = null;
@@ -604,6 +608,7 @@ namespace nspector.Native.NVAPI2
[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);
@@ -739,20 +744,19 @@ namespace nspector.Native.NVAPI2
GetDelegate(0xED1F8C69, out DRS_GetApplicationInfo);
GetDelegate(0x7FA2173A, out DRS_EnumApplicationsInternal);
GetDelegate(0xEEE566B2, out DRS_FindApplicationByName);
GetDelegate(0x8A2CF5F5, out _DRS_SetSetting);
GetDelegate(0xEA99498D, out _DRS_GetSetting);
GetDelegate(0xCFD6983E, out DRS_EnumSettingsInternal);
GetDelegate(0xE5DE48E5, out DRS_EnumAvailableSettingIdsInternal);
GetDelegate(0x8A2CF5F5, out _DRS_SetSetting, 0x577DD202);
GetDelegate(0xEA99498D, out _DRS_GetSetting, 0x73BF8338);
GetDelegate(0xCFD6983E, out DRS_EnumSettingsInternal, 0xAE3039DA);
GetDelegate(0xE5DE48E5, out DRS_EnumAvailableSettingIdsInternal, 0xF020614A);
GetDelegate(0x2EC39F90, out DRS_EnumAvailableSettingValuesInternal);
GetDelegate(0xCB7309CD, out DRS_GetSettingIdFromName);
GetDelegate(0x1EB13791, out DRS_GetSettingNameFromId);
GetDelegate(0xE4A26362, out DRS_DeleteProfileSetting);
GetDelegate(0x1EB13791, out DRS_GetSettingNameFromId, 0xD61CBE6E);
GetDelegate(0xD20D29DF, out DRS_DeleteProfileSetting, 0xE4A26362);
GetDelegate(0x5927B094, out DRS_RestoreAllDefaults);
GetDelegate(0xFA5F6134, out DRS_RestoreProfileDefault);
GetDelegate(0x7DD5B261, out DRS_RestoreProfileDefaultSetting);
GetDelegate(0x7DD5B261, out DRS_RestoreProfileDefaultSetting, 0x53F0381E);
GetDelegate(0xDA8466A0, out DRS_GetBaseProfile);
#endregion
}
}
}

View File

@@ -35,7 +35,7 @@ namespace nspector
if (argFileIndex != -1)
{
if (new FileInfo(args[argFileIndex]).Extension.ToLower() == ".nip")
if (new FileInfo(args[argFileIndex]).Extension.ToLowerInvariant() == ".nip")
{
try
{

View File

@@ -76,7 +76,7 @@ namespace nspector
{
for (int f = 0; f < filters.Length; f++)
{
if (settingProfileNames[p].ToLower().Contains(filters[f].ToLower()))
if (settingProfileNames[p].ToLowerInvariant().Contains(filters[f].ToLower()))
{
profileNames += settingProfileNames[p] + ",";
}

View File

@@ -530,8 +530,12 @@ namespace nspector
Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
}
public static double ScaleFactor = 1;
private void SetupDpiAdjustments()
{
ScaleFactor = lblWidth330.Width / 330;
chSettingID.Width = lblWidth330.Width;
chSettingValueHex.Width = lblWidth96.Width;
}
@@ -1154,7 +1158,7 @@ namespace nspector
if (files.Length == 1)
{
var fileInfo = new FileInfo(files[0]);
if (fileInfo.Extension.ToLower().Equals(".nip"))
if (fileInfo.Extension.ToLowerInvariant().Equals(".nip"))
{
ImportProfiles(fileInfo.FullName);
return;
@@ -1291,11 +1295,11 @@ namespace nspector
string inputString = "";
if (InputBox.Show("Search Setting", "Please enter setting name:", ref inputString, new List<string>(), "", 2048) == System.Windows.Forms.DialogResult.OK)
{
var lowerInput = inputString.Trim().ToLower();
var lowerInput = inputString.Trim().ToLowerInvariant();
lvSettings.BeginUpdate();
foreach(ListViewItem itm in lvSettings.Items)
{
if (!itm.Text.ToLower().Contains(lowerInput))
if (!itm.Text.ToLowerInvariant().Contains(lowerInput))
{
itm.Remove();
}