public void BinaryRoundTripTest() { UID original = new UID(0xabcd); using (MemoryStream stream = new MemoryStream()) { BinaryPropertyListWriter.Write(stream, original); stream.Position = 0; UID roundtrip = BinaryPropertyListParser.Parse(stream) as UID; Assert.Equal(original.Bytes, roundtrip.Bytes); } }
public void ParseDoubleTest(byte[] binaryValue, double expectedValue) { Assert.Equal(expectedValue, BinaryPropertyListParser.ParseDouble(binaryValue), 14); }
public void ParseLongTest(byte[] binaryValue, long expectedValue) { Assert.Equal(expectedValue, BinaryPropertyListParser.ParseLong(binaryValue)); }
public void ParseUnsignedIntTest(byte[] binaryValue, int expectedValue) { Assert.Equal(expectedValue, BinaryPropertyListParser.ParseUnsignedInt(binaryValue)); }
public static void LoadSettings() { Current = new SetSettings(); PlatformID ptId = DetectOS.GetRealPlatformID(); FileStream prefsFs = null; StreamReader prefsSr = null; try { switch (ptId) { case PlatformID.MacOSX: case PlatformID.iOS: { string preferencesPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Preferences"); string preferencesFilePath = Path.Combine(preferencesPath, "com.claunia.museum.apprepodbmgr.plist"); if (!File.Exists(preferencesFilePath)) { SetDefaultSettings(); SaveSettings(); } prefsFs = new FileStream(preferencesFilePath, FileMode.Open); var parsedPreferences = (NSDictionary)BinaryPropertyListParser.Parse(prefsFs); if (parsedPreferences != null) { Current.TemporaryFolder = parsedPreferences.TryGetValue("TemporaryFolder", out NSObject obj) ? ((NSString)obj).ToString() : Path.GetTempPath(); Current.DatabasePath = parsedPreferences.TryGetValue("DatabasePath", out obj) ? ((NSString)obj).ToString() : Path. Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "apprepodbmgr.db"); Current.RepositoryPath = parsedPreferences.TryGetValue("RepositoryPath", out obj) ? ((NSString)obj).ToString() : Path. Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "apprepo"); Current.UnArchiverPath = parsedPreferences.TryGetValue("UnArchiverPath", out obj) ? ((NSString)obj).ToString() : null; if (parsedPreferences.TryGetValue("CompressionAlgorithm", out obj)) { if (!Enum.TryParse(((NSString)obj).ToString(), true, out Current.CompressionAlgorithm)) { Current.CompressionAlgorithm = AlgoEnum.GZip; } } else { Current.CompressionAlgorithm = AlgoEnum.GZip; } Current.UseAntivirus = parsedPreferences.TryGetValue("UseAntivirus", out obj) && ((NSNumber)obj).ToBool(); Current.UseClamd = parsedPreferences.TryGetValue("UseClamd", out obj) && ((NSNumber)obj).ToBool(); Current.ClamdHost = parsedPreferences.TryGetValue("ClamdHost", out obj) ? ((NSString)obj).ToString() : null; if (parsedPreferences.TryGetValue("ClamdPort", out obj)) { Current.ClamdPort = (ushort)((NSNumber)obj).ToLong(); } else { Current.ClamdPort = 3310; } Current.ClamdIsLocal = parsedPreferences.TryGetValue("ClamdIsLocal", out obj) && ((NSNumber)obj).ToBool(); Current.ClamdIsLocal = parsedPreferences.TryGetValue("UseVirusTotal", out obj) && ((NSNumber)obj).ToBool(); Current.ClamdHost = parsedPreferences.TryGetValue("VirusTotalKey", out obj) ? ((NSString)obj).ToString() : null; prefsFs.Close(); } else { prefsFs.Close(); SetDefaultSettings(); SaveSettings(); } } break; case PlatformID.Win32NT: case PlatformID.Win32S: case PlatformID.Win32Windows: case PlatformID.WinCE: case PlatformID.WindowsPhone: { RegistryKey parentKey = Registry.CurrentUser.OpenSubKey("SOFTWARE")?. OpenSubKey("Canary Islands Computer Museum"); if (parentKey == null) { SetDefaultSettings(); SaveSettings(); return; } RegistryKey key = parentKey.OpenSubKey("AppRepoDBMgr"); if (key == null) { SetDefaultSettings(); SaveSettings(); return; } Current.TemporaryFolder = (string)key.GetValue("TemporaryFolder"); Current.DatabasePath = (string)key.GetValue("DatabasePath"); Current.RepositoryPath = (string)key.GetValue("RepositoryPath"); Current.UnArchiverPath = (string)key.GetValue("UnArchiverPath"); if (!Enum.TryParse((string)key.GetValue("CompressionAlgorithm"), true, out Current.CompressionAlgorithm)) { Current.CompressionAlgorithm = AlgoEnum.GZip; } Current.UseAntivirus = bool.Parse((string)key.GetValue("UseAntivirus")); Current.UseClamd = bool.Parse((string)key.GetValue("UseClamd")); Current.ClamdHost = (string)key.GetValue("ClamdHost"); Current.ClamdPort = ushort.Parse((string)key.GetValue("ClamdPort")); Current.ClamdIsLocal = bool.Parse((string)key.GetValue("ClamdIsLocal")); Current.UseVirusTotal = bool.Parse((string)key.GetValue("UseVirusTotal")); Current.VirusTotalKey = (string)key.GetValue("VirusTotalKey"); } break; default: { string configPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config"); string settingsPath = Path.Combine(configPath, "AppRepoDBMgr.xml"); if (!Directory.Exists(configPath)) { SetDefaultSettings(); SaveSettings(); return; } var xs = new XmlSerializer(Current.GetType()); prefsSr = new StreamReader(settingsPath); Current = (SetSettings)xs.Deserialize(prefsSr); prefsSr.Close(); } break; } } catch { prefsFs?.Close(); prefsSr?.Close(); SetDefaultSettings(); SaveSettings(); } }
/// <summary> /// Loads settings /// </summary> public static void LoadSettings() { Current = new DicSettings(); PlatformID ptId = DetectOS.GetRealPlatformID(); string homePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); try { switch (ptId) { // In case of macOS or iOS statistics and reports will be saved in ~/Library/Application Support/Claunia.com/DiscImageChef case PlatformID.MacOSX: case PlatformID.iOS: { string appSupportPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Application Support", "Claunia.com"); if (!Directory.Exists(appSupportPath)) { Directory.CreateDirectory(appSupportPath); } string dicPath = Path.Combine(appSupportPath, "DiscImageChef"); if (!Directory.Exists(dicPath)) { Directory.CreateDirectory(dicPath); } ReportsPath = Path.Combine(dicPath, "Reports"); if (!Directory.Exists(ReportsPath)) { Directory.CreateDirectory(ReportsPath); } StatsPath = Path.Combine(dicPath, "Statistics"); if (!Directory.Exists(StatsPath)) { Directory.CreateDirectory(StatsPath); } } break; // In case of Windows statistics and reports will be saved in %APPDATA%\Claunia.com\DiscImageChef case PlatformID.Win32NT: case PlatformID.Win32S: case PlatformID.Win32Windows: case PlatformID.WinCE: case PlatformID.WindowsPhone: { string appSupportPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Claunia.com"); if (!Directory.Exists(appSupportPath)) { Directory.CreateDirectory(appSupportPath); } string dicPath = Path.Combine(appSupportPath, "DiscImageChef"); if (!Directory.Exists(dicPath)) { Directory.CreateDirectory(dicPath); } ReportsPath = Path.Combine(dicPath, "Reports"); if (!Directory.Exists(ReportsPath)) { Directory.CreateDirectory(ReportsPath); } StatsPath = Path.Combine(dicPath, "Statistics"); if (!Directory.Exists(StatsPath)) { Directory.CreateDirectory(StatsPath); } } break; // Otherwise, statistics and reports will be saved in ~/.claunia.com/DiscImageChef default: { string xdgDataPath = Path.Combine(homePath, Environment.GetEnvironmentVariable(XDG_DATA_HOME) ?? XDG_DATA_HOME_RESOLVED); string oldDicPath = Path.Combine(homePath, ".claunia.com", "DiscImageChef"); string dicPath = Path.Combine(xdgDataPath, "DiscImageChef"); if (Directory.Exists(oldDicPath) && !Directory.Exists(dicPath)) { Directory.Move(oldDicPath, dicPath); Directory.Delete(Path.Combine(homePath, ".claunia.com")); } if (!Directory.Exists(dicPath)) { Directory.CreateDirectory(dicPath); } ReportsPath = Path.Combine(dicPath, "Reports"); if (!Directory.Exists(ReportsPath)) { Directory.CreateDirectory(ReportsPath); } StatsPath = Path.Combine(dicPath, "Statistics"); if (!Directory.Exists(StatsPath)) { Directory.CreateDirectory(StatsPath); } } break; } } catch { ReportsPath = null; } FileStream prefsFs = null; StreamReader prefsSr = null; try { switch (ptId) { // In case of macOS or iOS settings will be saved in ~/Library/Preferences/com.claunia.discimagechef.plist case PlatformID.MacOSX: case PlatformID.iOS: { string preferencesPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Preferences"); string preferencesFilePath = Path.Combine(preferencesPath, "com.claunia.discimagechef.plist"); if (!File.Exists(preferencesFilePath)) { SetDefaultSettings(); SaveSettings(); } prefsFs = new FileStream(preferencesFilePath, FileMode.Open, FileAccess.Read); NSDictionary parsedPreferences = (NSDictionary)BinaryPropertyListParser.Parse(prefsFs); if (parsedPreferences != null) { Current.SaveReportsGlobally = parsedPreferences.TryGetValue("SaveReportsGlobally", out NSObject obj) && ((NSNumber)obj).ToBool(); Current.ShareReports = parsedPreferences.TryGetValue("ShareReports", out obj) && ((NSNumber)obj).ToBool(); if (parsedPreferences.TryGetValue("Stats", out obj)) { NSDictionary stats = (NSDictionary)obj; if (stats != null) { Current.Stats = new StatsSettings { ShareStats = stats.TryGetValue("ShareStats", out NSObject obj2) && ((NSNumber)obj2).ToBool(), BenchmarkStats = stats.TryGetValue("BenchmarkStats", out obj2) && ((NSNumber)obj2).ToBool(), CommandStats = stats.TryGetValue("CommandStats", out obj2) && ((NSNumber)obj2).ToBool(), DeviceStats = stats.TryGetValue("DeviceStats", out obj2) && ((NSNumber)obj2).ToBool(), FilesystemStats = stats.TryGetValue("FilesystemStats", out obj2) && ((NSNumber)obj2).ToBool(), FilterStats = stats.TryGetValue("FilterStats", out obj2) && ((NSNumber)obj2).ToBool(), MediaImageStats = stats.TryGetValue("MediaImageStats", out obj2) && ((NSNumber)obj2).ToBool(), MediaScanStats = stats.TryGetValue("MediaScanStats", out obj2) && ((NSNumber)obj2).ToBool(), PartitionStats = stats.TryGetValue("PartitionStats", out obj2) && ((NSNumber)obj2).ToBool(), MediaStats = stats.TryGetValue("MediaStats", out obj2) && ((NSNumber)obj2).ToBool(), VerifyStats = stats.TryGetValue("VerifyStats", out obj2) && ((NSNumber)obj2).ToBool() } } ; } else { Current.Stats = null; } Current.GdprCompliance = parsedPreferences.TryGetValue("GdprCompliance", out obj) ? (ulong)((NSNumber)obj).ToLong() : 0; prefsFs.Close(); } else { prefsFs.Close(); SetDefaultSettings(); SaveSettings(); } } break; #if !NETSTANDARD2_0 // In case of Windows settings will be saved in the registry: HKLM/SOFTWARE/Claunia.com/DiscImageChef case PlatformID.Win32NT: case PlatformID.Win32S: case PlatformID.Win32Windows: case PlatformID.WinCE: case PlatformID.WindowsPhone: { RegistryKey parentKey = Registry.CurrentUser.OpenSubKey("SOFTWARE")?.OpenSubKey("Claunia.com"); if (parentKey == null) { SetDefaultSettings(); SaveSettings(); return; } RegistryKey key = parentKey.OpenSubKey("DiscImageChef"); if (key == null) { SetDefaultSettings(); SaveSettings(); return; } Current.SaveReportsGlobally = Convert.ToBoolean(key.GetValue("SaveReportsGlobally")); Current.ShareReports = Convert.ToBoolean(key.GetValue("ShareReports")); Current.GdprCompliance = Convert.ToUInt64(key.GetValue("GdprCompliance")); bool stats = Convert.ToBoolean(key.GetValue("Statistics")); if (stats) { Current.Stats = new StatsSettings { ShareStats = Convert.ToBoolean(key.GetValue("ShareStats")), BenchmarkStats = Convert.ToBoolean(key.GetValue("BenchmarkStats")), CommandStats = Convert.ToBoolean(key.GetValue("CommandStats")), DeviceStats = Convert.ToBoolean(key.GetValue("DeviceStats")), FilesystemStats = Convert.ToBoolean(key.GetValue("FilesystemStats")), FilterStats = Convert.ToBoolean(key.GetValue("FilterStats")), MediaImageStats = Convert.ToBoolean(key.GetValue("MediaImageStats")), MediaScanStats = Convert.ToBoolean(key.GetValue("MediaScanStats")), PartitionStats = Convert.ToBoolean(key.GetValue("PartitionStats")), MediaStats = Convert.ToBoolean(key.GetValue("MediaStats")), VerifyStats = Convert.ToBoolean(key.GetValue("VerifyStats")) } } ; } break; #endif // Otherwise, settings will be saved in ~/.config/DiscImageChef.xml default: { string oldConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config"); string oldSettingsPath = Path.Combine(oldConfigPath, "DiscImageChef.xml"); string xdgConfigPath = Path.Combine(homePath, Environment.GetEnvironmentVariable(XDG_CONFIG_HOME) ?? XDG_CONFIG_HOME_RESOLVED); string settingsPath = Path.Combine(xdgConfigPath, "DiscImageChef.xml"); if (File.Exists(oldSettingsPath) && !File.Exists(settingsPath)) { if (!Directory.Exists(xdgConfigPath)) { Directory.CreateDirectory(xdgConfigPath); } File.Move(oldSettingsPath, settingsPath); } if (!File.Exists(settingsPath)) { SetDefaultSettings(); SaveSettings(); return; } XmlSerializer xs = new XmlSerializer(Current.GetType()); prefsSr = new StreamReader(settingsPath); Current = (DicSettings)xs.Deserialize(prefsSr); } break; } } catch { prefsFs?.Close(); prefsSr?.Close(); SetDefaultSettings(); SaveSettings(); } }
private void btnGetSteamGuardData_Click(object sender, EventArgs e) { var iosBackups = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Apple Computer", "MobileSync", "Backup"); if (!Directory.Exists(iosBackups)) { txtResults.Text = @"No ios backups found"; return; } foreach (var d in Directory.GetDirectories(iosBackups)) { var name = new DirectoryInfo(d).Name; if (!File.Exists(Path.Combine(d, "Manifest.mbdb"))) { txtResults.AppendText($"Directory {name} is not a valid ios backup, skipping" + Environment.NewLine + Environment.NewLine); continue; } txtResults.AppendText($"Processing Directory {name}" + Environment.NewLine); var data = File.ReadAllBytes(Path.Combine(d, "Manifest.mbdb")); var steamfiles = Encoding.UTF8.GetBytes("AppDomain-com.valvesoftware.Steam"); for (var index = 0; ; index += steamfiles.Length) { index = SearchBytes(data, steamfiles, index); if (index == -1) { break; } var index2 = index + steamfiles.Length; var filelen = data[index2] << 8 | data[index2 + 1]; var temp = new byte[filelen]; Array.Copy(data, index2 + 2, temp, 0, filelen); var steamfilename = Encoding.UTF8.GetString(temp); if (!steamfilename.StartsWith("Documents/Steamguard-")) { continue; } var hash = new SHA1Managed().ComputeHash( Encoding.UTF8.GetBytes("AppDomain-com.valvesoftware.Steam-" + steamfilename)); var hashstr = BitConverter.ToString(hash).Replace("-", ""); if (File.Exists(Path.Combine(d, hashstr))) { txtResults.AppendText($"Processing {steamfilename}" + Environment.NewLine); try { var sgdata = BinaryPropertyListParser.Parse(File.ReadAllBytes(Path.Combine(d, hashstr))); var sglist = ((NSArray)((NSDictionary)sgdata)["$objects"]).GetArray(); var auth = new SteamAuthenticator() { SharedSecret = sglist[14].ToString(), Uri = sglist[15].ToString(), Steamid = sglist[16].ToString(), RevocationCode = sglist[17].ToString(), SerialNumber = sglist[18].ToString(), TokenGid = sglist[19].ToString(), IdentitySecret = sglist[20].ToString(), Secret = sglist[21].ToString(), ServerTime = sglist[22].ToString(), AccountName = sglist[23].ToString(), SteamguardScheme = sglist[24].ToString(), Status = sglist[25].ToString() }; txtResults.AppendText(Environment.NewLine); txtResults.AppendText("In WinAuth, Add Steam Authenticator. Select the Import Android Tab" + Environment.NewLine + Environment.NewLine); txtResults.AppendText("Paste this into the steam_uuid.xml text box" + Environment.NewLine); txtResults.AppendText($"android:{name}" + Environment.NewLine + Environment.NewLine); txtResults.AppendText( "Paste the following data, including the {} into the SteamGuare-NNNNNNNNN... text box" + Environment.NewLine); txtResults.AppendText(JsonConvert.SerializeObject(auth, Formatting.Indented) + Environment.NewLine + Environment.NewLine); } catch (PropertyListFormatException) //The only way this should happen is if we opened an encrypted backup. { txtResults.AppendText("Error: Encrypted backups are not supported. You need to create a decrypted backup to proceed." + Environment.NewLine); break; } catch (Exception ex) { txtResults.AppendText($"An Exception occurred while processing: {ex.Message}"); } } else { txtResults.AppendText($"Error: {steamfilename} is missing from ios backup, aborting" + Environment.NewLine); break; } } txtResults.AppendText("Done" + Environment.NewLine + Environment.NewLine); } }
private bool ProcessSteamGuardFile(string filename, string filepath, string deviceID) { txtResults.AppendText($"Processing {filename}" + Environment.NewLine); try { var sgdata = BinaryPropertyListParser.Parse(File.ReadAllBytes(filepath)); var sglist = ((NSArray)((NSDictionary)sgdata)["$objects"]).GetArray(); var auth = new SteamAuthenticator() { DeviceID = $"android:{deviceID}" }; for (var i = 2; i < 14; i++) { switch (sglist[i].ToString()) { case "shared_secret": auth.SharedSecret = sglist[i + 12].ToString(); break; case "uri": auth.Uri = sglist[i + 12].ToString(); break; case "steamid": auth.Steamid = sglist[i + 12].ToString(); break; case "revocation_code": auth.RevocationCode = sglist[i + 12].ToString(); break; case "serial_number": auth.SerialNumber = sglist[i + 12].ToString(); break; case "token_gid": auth.TokenGid = sglist[i + 12].ToString(); break; case "identity_secret": auth.IdentitySecret = sglist[i + 12].ToString(); break; case "secret_1": auth.Secret = sglist[i + 12].ToString(); break; case "server_time": auth.ServerTime = sglist[i + 12].ToString(); break; case "account_name": auth.AccountName = sglist[i + 12].ToString(); break; case "steamguard_scheme": auth.SteamguardScheme = sglist[i + 12].ToString(); break; case "status": auth.Status = sglist[i + 12].ToString(); break; } } txtResults.AppendText(Environment.NewLine); txtResults.AppendText("In WinAuth, Add Steam Authenticator. Select the Import Android Tab" + Environment.NewLine + Environment.NewLine); txtResults.AppendText("Paste this into the steam_uuid.xml text box" + Environment.NewLine); txtResults.AppendText($"android:{deviceID}" + Environment.NewLine + Environment.NewLine); txtResults.AppendText( "Paste the following data, including the {} into the SteamGuare-NNNNNNNNN... text box" + Environment.NewLine); txtResults.AppendText(JsonConvert.SerializeObject(auth, Formatting.Indented) + Environment.NewLine + Environment.NewLine); txtResults.AppendText( "Alternatively, you can paste the above json text into {botname}.maFile in your ASF config directory, if you use ASF" + Environment.NewLine + Environment.NewLine); } catch (PropertyListFormatException) //The only way this should happen is if we opened an encrypted backup. { txtResults.AppendText("Error: Encrypted backups are not supported. You need to create a decrypted backup to proceed." + Environment.NewLine); return(false); } catch (Exception ex) { txtResults.AppendText($"An Exception occurred while processing: {ex.Message}"); return(false); } return(true); }
/// <summary>Loads settings</summary> public static void LoadSettings() { Current = new SetSettings(); PlatformID ptId = DetectOS.GetRealPlatformID(); string homePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); FileStream prefsFs = null; StreamReader prefsSr = null; try { switch (ptId) { // In case of macOS or iOS settings will be saved in ~/Library/Preferences/com.claunia.romrepomgr.plist case PlatformID.MacOSX: case PlatformID.iOS: { string preferencesPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Preferences"); string preferencesFilePath = Path.Combine(preferencesPath, "com.claunia.romrepomgr.plist"); if (!File.Exists(preferencesFilePath)) { SetDefaultSettings(); SaveSettings(); } prefsFs = new FileStream(preferencesFilePath, FileMode.Open, FileAccess.Read); var parsedPreferences = (NSDictionary)BinaryPropertyListParser.Parse(prefsFs); if (parsedPreferences != null) { NSObject obj; Current.DatabasePath = parsedPreferences.TryGetValue("DatabasePath", out obj) ? ((NSString)obj).ToString() : null; Current.RepositoryPath = parsedPreferences.TryGetValue("RepositoryPath", out obj) ? ((NSString)obj).ToString() : null; Current.TemporaryFolder = parsedPreferences.TryGetValue("TemporaryFolder", out obj) ? ((NSString)obj).ToString() : null; Current.UnArchiverPath = parsedPreferences.TryGetValue("UnArchiverPath", out obj) ? ((NSString)obj).ToString() : null; prefsFs.Close(); } else { prefsFs.Close(); SetDefaultSettings(); SaveSettings(); } } break; #if !NETSTANDARD2_0 // In case of Windows settings will be saved in the registry: HKLM/SOFTWARE/Claunia.com/RomRepoMgr case PlatformID.Win32NT when OperatingSystem.IsWindows(): case PlatformID.Win32S when OperatingSystem.IsWindows(): case PlatformID.Win32Windows when OperatingSystem.IsWindows(): case PlatformID.WinCE when OperatingSystem.IsWindows(): case PlatformID.WindowsPhone when OperatingSystem.IsWindows(): { RegistryKey parentKey = Registry.CurrentUser.OpenSubKey("SOFTWARE")?.OpenSubKey("Claunia.com"); if (parentKey == null) { SetDefaultSettings(); SaveSettings(); return; } RegistryKey key = parentKey.OpenSubKey("RomRepoMgr"); if (key == null) { SetDefaultSettings(); SaveSettings(); return; } Current.DatabasePath = key.GetValue("DatabasePath") as string; Current.RepositoryPath = key.GetValue("RepositoryPath") as string; Current.TemporaryFolder = key.GetValue("TemporaryFolder") as string; Current.UnArchiverPath = key.GetValue("UnArchiverPath") as string; } break; #endif // Otherwise, settings will be saved in ~/.config/RomRepoMgr.json default: { string xdgConfigPath = Path.Combine(homePath, Environment.GetEnvironmentVariable(XDG_CONFIG_HOME) ?? XDG_CONFIG_HOME_RESOLVED); string settingsPath = Path.Combine(xdgConfigPath, "RomRepoMgr.json"); if (!File.Exists(settingsPath)) { SetDefaultSettings(); SaveSettings(); return; } prefsSr = new StreamReader(settingsPath); Current = JsonSerializer.Deserialize <SetSettings>(prefsSr.ReadToEnd(), new JsonSerializerOptions { AllowTrailingCommas = true, PropertyNameCaseInsensitive = true, ReadCommentHandling = JsonCommentHandling.Skip, WriteIndented = true }); } break; } } catch { prefsFs?.Close(); prefsSr?.Close(); SetDefaultSettings(); SaveSettings(); } }