namespace SHNDecryptHK { using System; using System.ComponentModel; using System.Drawing; using System.IO; using System.Text; using System.Windows.Forms; public class OPToolEditor : Form { private Button btnReplc; private Button button1; private ToolStripMenuItem closeToolStripMenuItem; private IContainer components; private ContextMenuStrip contextMenuStrip1; private string extension = ""; private GroupBox groupMysql; private Label label1; private Label label2; private MenuStrip menuStrip1; private ToolStripMenuItem openTXTToolStripMenuItem; private ToolStripMenuItem openTXTToolStripMenuItem1; private ToolStripMenuItem saveToTXTToolStripMenuItem; private ToolStripMenuItem saveTXTToolStripMenuItem; private ToolStripMenuItem toolToolStripMenuItem; private TextBox txtFrom; private TextBox txtSettings; private TextBox txtWith; public OPToolEditor(frmMain frm, byte[] data, string ext) { this.InitializeComponent(); if (data.Length >= 10) { this.txtSettings.Text = Encoding.ASCII.GetString(data); this.extension = ext; this.Text = this.extension.ToUpper() + " Editor"; } } private void btnReplc_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you would like to complete this action?\r\nReplace ' " + this.txtFrom.Text + " ' with ' " + this.txtWith.Text + " '", "SHN", MessageBoxButtons.YesNo) != DialogResult.No) { string str = this.txtSettings.Text.Replace(this.txtFrom.Text, this.txtWith.Text); this.txtSettings.Text = str; } } private void button1_Click(object sender, EventArgs e) { SaveFileDialog dialog = new SaveFileDialog { Filter = "File (*" + this.extension + ")|*" + this.extension + "|Any file(*.*)|*.*", Title = "Save file" }; if (dialog.ShowDialog() == DialogResult.OK) { byte[] bytes = Encoding.ASCII.GetBytes(this.txtSettings.Text); this.Decrypt(bytes, 0, bytes.Length); BinaryWriter writer = new BinaryWriter(File.Create(dialog.FileName)); writer.Write(bytes); writer.Close(); } } private void closeToolStripMenuItem_Click(object sender, EventArgs e) { base.Close(); } private void Decrypt(byte[] data, int index, int length) { if (((index < 0) | (length < 1)) | ((index + length) > data.Length)) { throw new IndexOutOfRangeException(); } byte num = (byte) length; for (int i = length - 1; i >= 0; i--) { data[i] = (byte) (data[i] ^ num); byte num3 = (byte) i; num3 = (byte) (num3 & 15); num3 = (byte) (num3 + 0x55); num3 = (byte) (num3 ^ ((byte) (((byte) i) * 11))); num3 = (byte) (num3 ^ num); num3 = (byte) (num3 ^ 170); num = num3; } } protected override void Dispose(bool disposing) { if (disposing && (this.components != null)) { this.components.Dispose(); } base.Dispose(disposing); } private void InitializeComponent() { this.components = new Container(); ComponentResourceManager manager = new ComponentResourceManager(typeof(OPToolEditor)); this.contextMenuStrip1 = new ContextMenuStrip(this.components); this.openTXTToolStripMenuItem = new ToolStripMenuItem(); this.saveToTXTToolStripMenuItem = new ToolStripMenuItem(); this.menuStrip1 = new MenuStrip(); this.toolToolStripMenuItem = new ToolStripMenuItem(); this.openTXTToolStripMenuItem1 = new ToolStripMenuItem(); this.saveTXTToolStripMenuItem = new ToolStripMenuItem(); this.closeToolStripMenuItem = new ToolStripMenuItem(); this.button1 = new Button(); this.label1 = new Label(); this.txtFrom = new TextBox(); this.label2 = new Label(); this.txtWith = new TextBox(); this.btnReplc = new Button(); this.groupMysql = new GroupBox(); this.txtSettings = new TextBox(); this.contextMenuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.groupMysql.SuspendLayout(); base.SuspendLayout(); this.contextMenuStrip1.Items.AddRange(new ToolStripItem[] { this.openTXTToolStripMenuItem, this.saveToTXTToolStripMenuItem }); this.contextMenuStrip1.Name = "contextMenuStrip1"; this.contextMenuStrip1.Size = new Size(0x89, 0x30); this.contextMenuStrip1.Text = "File"; this.openTXTToolStripMenuItem.Name = "openTXTToolStripMenuItem"; this.openTXTToolStripMenuItem.Size = new Size(0x88, 0x16); this.openTXTToolStripMenuItem.Text = "Open TXT"; this.saveToTXTToolStripMenuItem.Name = "saveToTXTToolStripMenuItem"; this.saveToTXTToolStripMenuItem.Size = new Size(0x88, 0x16); this.saveToTXTToolStripMenuItem.Text = "Save to TXT"; this.menuStrip1.Items.AddRange(new ToolStripItem[] { this.toolToolStripMenuItem }); this.menuStrip1.Location = new Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new Size(0x310, 0x18); this.menuStrip1.TabIndex = 8; this.menuStrip1.Text = "menuStrip1"; this.toolToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.openTXTToolStripMenuItem1, this.saveTXTToolStripMenuItem, this.closeToolStripMenuItem }); this.toolToolStripMenuItem.Name = "toolToolStripMenuItem"; this.toolToolStripMenuItem.Size = new Size(0x2b, 20); this.toolToolStripMenuItem.Text = "Tool"; this.openTXTToolStripMenuItem1.Name = "openTXTToolStripMenuItem1"; this.openTXTToolStripMenuItem1.Size = new Size(0x7f, 0x16); this.openTXTToolStripMenuItem1.Text = "Open TXT"; this.openTXTToolStripMenuItem1.Click += new EventHandler(this.openTXTToolStripMenuItem1_Click); this.saveTXTToolStripMenuItem.Name = "saveTXTToolStripMenuItem"; this.saveTXTToolStripMenuItem.Size = new Size(0x7f, 0x16); this.saveTXTToolStripMenuItem.Text = "Save TXT"; this.saveTXTToolStripMenuItem.Click += new EventHandler(this.saveTXTToolStripMenuItem_Click); this.closeToolStripMenuItem.Name = "closeToolStripMenuItem"; this.closeToolStripMenuItem.Size = new Size(0x7f, 0x16); this.closeToolStripMenuItem.Text = "Close"; this.closeToolStripMenuItem.Click += new EventHandler(this.closeToolStripMenuItem_Click); this.button1.Location = new Point(12, 0x13); this.button1.Name = "button1"; this.button1.Size = new Size(0x57, 0x19); this.button1.TabIndex = 1; this.button1.Text = "Save to File"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new EventHandler(this.button1_Click); this.label1.AutoSize = true; this.label1.Location = new Point(0x7c, 0x1b); this.label1.Name = "label1"; this.label1.Size = new Size(50, 13); this.label1.TabIndex = 2; this.label1.Text = "Replace:"; this.txtFrom.Location = new Point(180, 0x18); this.txtFrom.Name = "txtFrom"; this.txtFrom.Size = new Size(0x7f, 20); this.txtFrom.TabIndex = 3; this.txtFrom.KeyDown += new KeyEventHandler(this.txtWith_KeyDown); this.label2.AutoSize = true; this.label2.Location = new Point(0x144, 0x1b); this.label2.Name = "label2"; this.label2.Size = new Size(0x20, 13); this.label2.TabIndex = 4; this.label2.Text = "With:"; this.txtWith.Location = new Point(0x16a, 0x18); this.txtWith.Name = "txtWith"; this.txtWith.Size = new Size(0x6a, 20); this.txtWith.TabIndex = 5; this.txtWith.KeyDown += new KeyEventHandler(this.txtWith_KeyDown); this.btnReplc.AutoSize = true; this.btnReplc.Location = new Point(0x1da, 0x15); this.btnReplc.Name = "btnReplc"; this.btnReplc.Size = new Size(0x3b, 0x17); this.btnReplc.TabIndex = 6; this.btnReplc.Text = "Go"; this.btnReplc.UseVisualStyleBackColor = true; this.btnReplc.Click += new EventHandler(this.btnReplc_Click); this.groupMysql.Controls.Add(this.btnReplc); this.groupMysql.Controls.Add(this.txtWith); this.groupMysql.Controls.Add(this.txtFrom); this.groupMysql.Controls.Add(this.label2); this.groupMysql.Controls.Add(this.label1); this.groupMysql.Controls.Add(this.button1); this.groupMysql.Dock = DockStyle.Bottom; this.groupMysql.Location = new Point(0, 0x20f); this.groupMysql.Name = "groupMysql"; this.groupMysql.Size = new Size(0x310, 0x37); this.groupMysql.TabIndex = 11; this.groupMysql.TabStop = false; this.txtSettings.Dock = DockStyle.Fill; this.txtSettings.Location = new Point(0, 0x18); this.txtSettings.Multiline = true; this.txtSettings.Name = "txtSettings"; this.txtSettings.ScrollBars = ScrollBars.Vertical; this.txtSettings.Size = new Size(0x310, 0x1f7); this.txtSettings.TabIndex = 0; base.AutoScaleDimensions = new SizeF(6f, 13f); base.AutoScaleMode = AutoScaleMode.Font; base.ClientSize = new Size(0x310, 0x246); base.Controls.Add(this.txtSettings); base.Controls.Add(this.groupMysql); base.Controls.Add(this.menuStrip1); base.Icon = (Icon) manager.GetObject("$this.Icon"); base.MainMenuStrip = this.menuStrip1; base.MaximizeBox = false; base.MinimizeBox = false; this.MinimumSize = new Size(600, 400); base.Name = "OPToolEditor"; base.StartPosition = FormStartPosition.CenterParent; this.Text = "Text Editor"; this.contextMenuStrip1.ResumeLayout(false); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.groupMysql.ResumeLayout(false); this.groupMysql.PerformLayout(); base.ResumeLayout(false); base.PerformLayout(); } private void openTXTToolStripMenuItem1_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog { Title = "Open file" }; if (dialog.ShowDialog() == DialogResult.OK) { StreamReader reader = new StreamReader(dialog.FileName); this.txtSettings.Text = reader.ReadToEnd(); reader.Close(); } } private void saveTXTToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog dialog = new SaveFileDialog { Title = "Save file", Filter = "Text (*.txt)|*.txt" }; if (dialog.ShowDialog() == DialogResult.OK) { TextWriter writer = new StreamWriter(dialog.FileName); writer.Write(this.txtSettings.Text); writer.Close(); } } private void txtWith_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { this.btnReplc.PerformClick(); e.SuppressKeyPress = true; } } } }