protected override void OnDrop(DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] file = e.Data.GetData(DataFormats.FileDrop, true) as string[]; if (file.Length == 1) { try { ObfuscationDatabase db = new ObfuscationDatabase(); using (BinaryReader rdr = new BinaryReader(File.OpenRead(file[0]))) db.Deserialize(rdr); Db = db; UpdateTitle(Path.GetFileName(file[0])); tree.ItemsSource = new object[] { new Db(Path.GetFileName(file[0]), db) }; } catch (Exception ex) { MessageBox.Show(string.Format( @"""{0}"" is not a valid database! Message : {1} Stack Trace : {2}", file[0], ex.Message, ex.StackTrace), "Confuser", MessageBoxButton.OK, MessageBoxImage.Error); } return; } } }
public Db(string name, ObfuscationDatabase db) { this.Name = name; foreach (var i in db) { if (string.IsNullOrEmpty(i.Key)) { foreach (var j in i.Value) { base.Add(new DbTable(j.Key, j.Value)); } } else { base.Add(new DbModule(i.Key, i.Value)); } } }
private void Translate_Click(object sender, RoutedEventArgs e) { ObfuscationDatabase db = new ObfuscationDatabase(); try { using (BinaryReader rdr = new BinaryReader(File.OpenRead(path.Text))) db.Deserialize(rdr); } catch (Exception ex) { MessageBox.Show(string.Format( @"""{0}"" is not a valid database! Message : {1} Stack Trace : {2}", path.Text, ex.Message, ex.StackTrace), "Confuser", MessageBoxButton.OK, MessageBoxImage.Error); return; } string stacktrace = input.Text; var entries = new Dictionary <string, string>(); foreach (var mod in db) { foreach (var tbl in mod.Value) { if (tbl.Key == "Rename") { foreach (var i in tbl.Value) { int index = stacktrace.IndexOf(i.Item2); if (index != -1 && !entries.ContainsKey(i.Item2)) { entries.Add(i.Item2, i.Item1); } } } } } string regex = "(" + string.Join("|", entries.Keys.Select(_ => Regex.Escape(_)).ToArray()) + ")"; string result = Regex.Replace(stacktrace, regex, m => entries[m.Value]); output.Text = result; }
private void Translate_Click(object sender, RoutedEventArgs e) { ObfuscationDatabase db = new ObfuscationDatabase(); try { using (BinaryReader rdr = new BinaryReader(File.OpenRead(path.Text))) db.Deserialize(rdr); } catch (Exception ex) { MessageBox.Show(string.Format( @"""{0}"" is not a valid database! Message : {1} Stack Trace : {2}", path.Text, ex.Message, ex.StackTrace), "Confuser", MessageBoxButton.OK, MessageBoxImage.Error); return; } string stacktrace = input.Text; var entries = new Dictionary<string, string>(); foreach (var mod in db) foreach (var tbl in mod.Value) if (tbl.Key == "Rename") foreach (var i in tbl.Value) { int index = stacktrace.IndexOf(i.Item2); if (index != -1 && !entries.ContainsKey(i.Item2)) entries.Add(i.Item2, i.Item1); } string regex = "(" + string.Join("|", entries.Keys.Select(_ => Regex.Escape(_)).ToArray()) + ")"; string result = Regex.Replace(stacktrace, regex, m => entries[m.Value]); output.Text = result; }