| 6 | namespace PenguLoader.Main |
| 7 | { |
| 8 | internal static class DataStore |
| 9 | { |
| 10 | public static bool IsDataStore(string path) |
| 11 | { |
| 12 | if (string.IsNullOrEmpty(path)) |
| 13 | return false; |
| 14 | |
| 15 | return Path.GetFileName(path).Equals("datastore", StringComparison.OrdinalIgnoreCase) |
| 16 | && File.Exists(path); |
| 17 | } |
| 18 | |
| 19 | public static void DumpDataStore(string path) |
| 20 | { |
| 21 | try |
| 22 | { |
| 23 | var output = Path.GetTempFileName(); |
| 24 | var bytes = File.ReadAllBytes(path); |
| 25 | |
| 26 | if (bytes.Length == 0) |
| 27 | { |
| 28 | MessageBox.Show("Your DataStore is empty!", |
| 29 | Program.Name, MessageBoxButton.OK, MessageBoxImage.Information); |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | Transform(bytes); |
| 34 | File.WriteAllBytes(output, bytes); |
| 35 | |
| 36 | Process.Start(new ProcessStartInfo |
| 37 | { |
| 38 | FileName = "notepad.exe", |
| 39 | Arguments = $"\"{output}\"", |
| 40 | UseShellExecute = false |
| 41 | }); |
| 42 | } |
| 43 | catch |
| 44 | { |
| 45 | MessageBox.Show($"Failed to dump DataStore from path: {path}", |
| 46 | Program.Name, MessageBoxButton.OK, MessageBoxImage.Information); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | static void Transform(byte[] bytes) |
| 51 | { |
| 52 | const string KEY = "A5dgY6lz9fpG9kGNiH1mZ"; |
| 53 | |
| 54 | if (bytes != null && bytes.Length > 0) |
| 55 | { |
| 56 | for (int i = 0; i < bytes.Length; i++) |
| 57 | { |
| 58 | bytes[i] ^= (byte)KEY[i % KEY.Length]; |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | } |
nothing calls this directly
no outgoing calls
no test coverage detected