diff --git a/.vs/Ledybot/v14/.suo b/.vs/Ledybot/v14/.suo index bdb7c80..6d85653 100644 Binary files a/.vs/Ledybot/v14/.suo and b/.vs/Ledybot/v14/.suo differ diff --git a/Ledybot/Form1.Designer.cs b/Ledybot/Form1.Designer.cs index 9d1d2ce..b3a9a89 100644 --- a/Ledybot/Form1.Designer.cs +++ b/Ledybot/Form1.Designer.cs @@ -28,12 +28,9 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.tb_IP = new System.Windows.Forms.TextBox(); - this.tb_Port = new System.Windows.Forms.TextBox(); - this.l_dummy = new System.Windows.Forms.Label(); - this.tb_PID = new System.Windows.Forms.TextBox(); - this.lb_dummy2 = new System.Windows.Forms.Label(); this.btn_Connect = new System.Windows.Forms.Button(); this.tb_PokemonToFind = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); @@ -57,7 +54,29 @@ private void InitializeComponent() this.cmb_Gender = new System.Windows.Forms.ComboBox(); this.label8 = new System.Windows.Forms.Label(); this.cmb_Levels = new System.Windows.Forms.ComboBox(); + this.tc_Control = new System.Windows.Forms.TabControl(); + this.tp_GTS = new System.Windows.Forms.TabPage(); + this.tp_Injection = new System.Windows.Forms.TabPage(); + this.nud_CountInjection = new System.Windows.Forms.NumericUpDown(); + this.label10 = new System.Windows.Forms.Label(); + this.btn_Inject = new System.Windows.Forms.Button(); + this.nud_SlotInjection = new System.Windows.Forms.NumericUpDown(); + this.nud_BoxInjection = new System.Windows.Forms.NumericUpDown(); + this.label9 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.btn_BrowseInject = new System.Windows.Forms.Button(); + this.txt_FileInjection = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.ofd_Injection = new System.Windows.Forms.OpenFileDialog(); + this.btn_Disconnect = new System.Windows.Forms.Button(); + this.timer1 = new System.Windows.Forms.Timer(this.components); ((System.ComponentModel.ISupportInitialize)(this.nud_Dex)).BeginInit(); + this.tc_Control.SuspendLayout(); + this.tp_GTS.SuspendLayout(); + this.tp_Injection.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nud_CountInjection)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nud_SlotInjection)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nud_BoxInjection)).BeginInit(); this.SuspendLayout(); // // tb_IP @@ -68,45 +87,11 @@ private void InitializeComponent() this.tb_IP.TabIndex = 0; this.tb_IP.Text = "192.168.1.19"; // - // tb_Port - // - this.tb_Port.Location = new System.Drawing.Point(135, 13); - this.tb_Port.Name = "tb_Port"; - this.tb_Port.Size = new System.Drawing.Size(34, 20); - this.tb_Port.TabIndex = 1; - this.tb_Port.Text = "8000"; - // - // l_dummy - // - this.l_dummy.AutoSize = true; - this.l_dummy.Location = new System.Drawing.Point(119, 16); - this.l_dummy.Name = "l_dummy"; - this.l_dummy.Size = new System.Drawing.Size(10, 13); - this.l_dummy.TabIndex = 2; - this.l_dummy.Text = ":"; - // - // tb_PID - // - this.tb_PID.Location = new System.Drawing.Point(191, 13); - this.tb_PID.Name = "tb_PID"; - this.tb_PID.Size = new System.Drawing.Size(19, 20); - this.tb_PID.TabIndex = 3; - this.tb_PID.Text = "2c"; - // - // lb_dummy2 - // - this.lb_dummy2.AutoSize = true; - this.lb_dummy2.Location = new System.Drawing.Point(175, 16); - this.lb_dummy2.Name = "lb_dummy2"; - this.lb_dummy2.Size = new System.Drawing.Size(10, 13); - this.lb_dummy2.TabIndex = 4; - this.lb_dummy2.Text = "-"; - // // btn_Connect // - this.btn_Connect.Location = new System.Drawing.Point(216, 11); + this.btn_Connect.Location = new System.Drawing.Point(119, 13); this.btn_Connect.Name = "btn_Connect"; - this.btn_Connect.Size = new System.Drawing.Size(75, 23); + this.btn_Connect.Size = new System.Drawing.Size(75, 20); this.btn_Connect.TabIndex = 5; this.btn_Connect.Text = "Connect"; this.btn_Connect.UseVisualStyleBackColor = true; @@ -114,7 +99,7 @@ private void InitializeComponent() // // tb_PokemonToFind // - this.tb_PokemonToFind.Location = new System.Drawing.Point(12, 67); + this.tb_PokemonToFind.Location = new System.Drawing.Point(5, 19); this.tb_PokemonToFind.Name = "tb_PokemonToFind"; this.tb_PokemonToFind.Size = new System.Drawing.Size(100, 20); this.tb_PokemonToFind.TabIndex = 6; @@ -123,7 +108,7 @@ private void InitializeComponent() // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(10, 51); + this.label1.Location = new System.Drawing.Point(3, 3); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(106, 13); this.label1.TabIndex = 7; @@ -132,7 +117,7 @@ private void InitializeComponent() // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(13, 159); + this.label4.Location = new System.Drawing.Point(6, 111); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(68, 13); this.label4.TabIndex = 12; @@ -140,7 +125,7 @@ private void InitializeComponent() // // tb_Default // - this.tb_Default.Location = new System.Drawing.Point(12, 176); + this.tb_Default.Location = new System.Drawing.Point(5, 128); this.tb_Default.Name = "tb_Default"; this.tb_Default.Size = new System.Drawing.Size(354, 20); this.tb_Default.TabIndex = 13; @@ -149,7 +134,7 @@ private void InitializeComponent() // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(16, 203); + this.label5.Location = new System.Drawing.Point(9, 155); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(101, 13); this.label5.TabIndex = 14; @@ -157,7 +142,7 @@ private void InitializeComponent() // // tb_Folder // - this.tb_Folder.Location = new System.Drawing.Point(12, 219); + this.tb_Folder.Location = new System.Drawing.Point(5, 171); this.tb_Folder.Name = "tb_Folder"; this.tb_Folder.Size = new System.Drawing.Size(354, 20); this.tb_Folder.TabIndex = 15; @@ -165,7 +150,7 @@ private void InitializeComponent() // // btn_Start // - this.btn_Start.Location = new System.Drawing.Point(161, 121); + this.btn_Start.Location = new System.Drawing.Point(154, 73); this.btn_Start.Name = "btn_Start"; this.btn_Start.Size = new System.Drawing.Size(58, 23); this.btn_Start.TabIndex = 16; @@ -175,7 +160,7 @@ private void InitializeComponent() // // btn_Stop // - this.btn_Stop.Location = new System.Drawing.Point(225, 121); + this.btn_Stop.Location = new System.Drawing.Point(218, 73); this.btn_Stop.Name = "btn_Stop"; this.btn_Stop.Size = new System.Drawing.Size(58, 23); this.btn_Stop.TabIndex = 17; @@ -192,7 +177,7 @@ private void InitializeComponent() this.Country, this.SubCountry}); this.lv_log.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.lv_log.Location = new System.Drawing.Point(13, 246); + this.lv_log.Location = new System.Drawing.Point(6, 198); this.lv_log.Name = "lv_log"; this.lv_log.Size = new System.Drawing.Size(353, 262); this.lv_log.TabIndex = 18; @@ -223,7 +208,7 @@ private void InitializeComponent() // // btn_Export // - this.btn_Export.Location = new System.Drawing.Point(12, 515); + this.btn_Export.Location = new System.Drawing.Point(5, 467); this.btn_Export.Name = "btn_Export"; this.btn_Export.Size = new System.Drawing.Size(354, 23); this.btn_Export.TabIndex = 19; @@ -234,7 +219,7 @@ private void InitializeComponent() // cb_Spanish // this.cb_Spanish.AutoSize = true; - this.cb_Spanish.Location = new System.Drawing.Point(289, 125); + this.cb_Spanish.Location = new System.Drawing.Point(282, 77); this.cb_Spanish.Name = "cb_Spanish"; this.cb_Spanish.Size = new System.Drawing.Size(64, 17); this.cb_Spanish.TabIndex = 20; @@ -244,7 +229,7 @@ private void InitializeComponent() // label6 // this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(119, 51); + this.label6.Location = new System.Drawing.Point(112, 3); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(29, 13); this.label6.TabIndex = 22; @@ -252,7 +237,7 @@ private void InitializeComponent() // // nud_Dex // - this.nud_Dex.Location = new System.Drawing.Point(122, 67); + this.nud_Dex.Location = new System.Drawing.Point(115, 19); this.nud_Dex.Maximum = new decimal(new int[] { 802, 0, @@ -276,7 +261,7 @@ private void InitializeComponent() // label7 // this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(175, 51); + this.label7.Location = new System.Drawing.Point(168, 3); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(48, 13); this.label7.TabIndex = 24; @@ -288,7 +273,7 @@ private void InitializeComponent() this.cmb_Gender.Items.AddRange(new object[] { "Male", "Female"}); - this.cmb_Gender.Location = new System.Drawing.Point(178, 67); + this.cmb_Gender.Location = new System.Drawing.Point(171, 19); this.cmb_Gender.Name = "cmb_Gender"; this.cmb_Gender.RightToLeft = System.Windows.Forms.RightToLeft.No; this.cmb_Gender.Size = new System.Drawing.Size(59, 21); @@ -298,7 +283,7 @@ private void InitializeComponent() // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(243, 51); + this.label8.Location = new System.Drawing.Point(236, 3); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(36, 13); this.label8.TabIndex = 26; @@ -318,40 +303,232 @@ private void InitializeComponent() "71 - 80", "81 - 90", "91 - Higher"}); - this.cmb_Levels.Location = new System.Drawing.Point(246, 67); + this.cmb_Levels.Location = new System.Drawing.Point(239, 19); this.cmb_Levels.Name = "cmb_Levels"; this.cmb_Levels.RightToLeft = System.Windows.Forms.RightToLeft.No; this.cmb_Levels.Size = new System.Drawing.Size(84, 21); this.cmb_Levels.TabIndex = 27; this.cmb_Levels.Text = "91 to Higher"; // + // tc_Control + // + this.tc_Control.Controls.Add(this.tp_GTS); + this.tc_Control.Controls.Add(this.tp_Injection); + this.tc_Control.Location = new System.Drawing.Point(1, 33); + this.tc_Control.Name = "tc_Control"; + this.tc_Control.SelectedIndex = 0; + this.tc_Control.Size = new System.Drawing.Size(377, 521); + this.tc_Control.TabIndex = 28; + // + // tp_GTS + // + this.tp_GTS.Controls.Add(this.label1); + this.tp_GTS.Controls.Add(this.cmb_Levels); + this.tp_GTS.Controls.Add(this.tb_PokemonToFind); + this.tp_GTS.Controls.Add(this.label8); + this.tp_GTS.Controls.Add(this.label4); + this.tp_GTS.Controls.Add(this.cmb_Gender); + this.tp_GTS.Controls.Add(this.tb_Default); + this.tp_GTS.Controls.Add(this.label7); + this.tp_GTS.Controls.Add(this.label5); + this.tp_GTS.Controls.Add(this.nud_Dex); + this.tp_GTS.Controls.Add(this.tb_Folder); + this.tp_GTS.Controls.Add(this.label6); + this.tp_GTS.Controls.Add(this.btn_Start); + this.tp_GTS.Controls.Add(this.cb_Spanish); + this.tp_GTS.Controls.Add(this.btn_Stop); + this.tp_GTS.Controls.Add(this.btn_Export); + this.tp_GTS.Controls.Add(this.lv_log); + this.tp_GTS.Location = new System.Drawing.Point(4, 22); + this.tp_GTS.Name = "tp_GTS"; + this.tp_GTS.Padding = new System.Windows.Forms.Padding(3); + this.tp_GTS.Size = new System.Drawing.Size(369, 495); + this.tp_GTS.TabIndex = 0; + this.tp_GTS.Text = "GTS"; + this.tp_GTS.UseVisualStyleBackColor = true; + // + // tp_Injection + // + this.tp_Injection.Controls.Add(this.nud_CountInjection); + this.tp_Injection.Controls.Add(this.label10); + this.tp_Injection.Controls.Add(this.btn_Inject); + this.tp_Injection.Controls.Add(this.nud_SlotInjection); + this.tp_Injection.Controls.Add(this.nud_BoxInjection); + this.tp_Injection.Controls.Add(this.label9); + this.tp_Injection.Controls.Add(this.label3); + this.tp_Injection.Controls.Add(this.btn_BrowseInject); + this.tp_Injection.Controls.Add(this.txt_FileInjection); + this.tp_Injection.Controls.Add(this.label2); + this.tp_Injection.Location = new System.Drawing.Point(4, 22); + this.tp_Injection.Name = "tp_Injection"; + this.tp_Injection.Padding = new System.Windows.Forms.Padding(3); + this.tp_Injection.Size = new System.Drawing.Size(369, 495); + this.tp_Injection.TabIndex = 1; + this.tp_Injection.Text = "Injection"; + this.tp_Injection.UseVisualStyleBackColor = true; + // + // nud_CountInjection + // + this.nud_CountInjection.Location = new System.Drawing.Point(95, 64); + this.nud_CountInjection.Maximum = new decimal(new int[] { + 960, + 0, + 0, + 0}); + this.nud_CountInjection.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.nud_CountInjection.Name = "nud_CountInjection"; + this.nud_CountInjection.Size = new System.Drawing.Size(38, 20); + this.nud_CountInjection.TabIndex = 9; + this.nud_CountInjection.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.nud_CountInjection.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(92, 47); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(38, 13); + this.label10.TabIndex = 8; + this.label10.Text = "Count:"; + // + // btn_Inject + // + this.btn_Inject.Location = new System.Drawing.Point(7, 91); + this.btn_Inject.Name = "btn_Inject"; + this.btn_Inject.Size = new System.Drawing.Size(354, 23); + this.btn_Inject.TabIndex = 7; + this.btn_Inject.Text = "Inject"; + this.btn_Inject.UseVisualStyleBackColor = true; + this.btn_Inject.Click += new System.EventHandler(this.btn_Inject_Click); + // + // nud_SlotInjection + // + this.nud_SlotInjection.Location = new System.Drawing.Point(51, 64); + this.nud_SlotInjection.Maximum = new decimal(new int[] { + 32, + 0, + 0, + 0}); + this.nud_SlotInjection.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.nud_SlotInjection.Name = "nud_SlotInjection"; + this.nud_SlotInjection.Size = new System.Drawing.Size(38, 20); + this.nud_SlotInjection.TabIndex = 6; + this.nud_SlotInjection.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.nud_SlotInjection.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.nud_SlotInjection.ValueChanged += new System.EventHandler(this.nud_SlotInjection_ValueChanged); + // + // nud_BoxInjection + // + this.nud_BoxInjection.Location = new System.Drawing.Point(7, 64); + this.nud_BoxInjection.Maximum = new decimal(new int[] { + 32, + 0, + 0, + 0}); + this.nud_BoxInjection.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.nud_BoxInjection.Name = "nud_BoxInjection"; + this.nud_BoxInjection.Size = new System.Drawing.Size(38, 20); + this.nud_BoxInjection.TabIndex = 5; + this.nud_BoxInjection.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.nud_BoxInjection.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.nud_BoxInjection.ValueChanged += new System.EventHandler(this.nud_BoxInjection_ValueChanged); + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(48, 47); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(28, 13); + this.label9.TabIndex = 4; + this.label9.Text = "Slot:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(6, 47); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(28, 13); + this.label3.TabIndex = 3; + this.label3.Text = "Box:"; + // + // btn_BrowseInject + // + this.btn_BrowseInject.Location = new System.Drawing.Point(291, 24); + this.btn_BrowseInject.Name = "btn_BrowseInject"; + this.btn_BrowseInject.Size = new System.Drawing.Size(75, 20); + this.btn_BrowseInject.TabIndex = 2; + this.btn_BrowseInject.Text = "Browse"; + this.btn_BrowseInject.UseVisualStyleBackColor = true; + this.btn_BrowseInject.Click += new System.EventHandler(this.btn_BrowseInject_Click); + // + // txt_FileInjection + // + this.txt_FileInjection.Location = new System.Drawing.Point(7, 24); + this.txt_FileInjection.Name = "txt_FileInjection"; + this.txt_FileInjection.Size = new System.Drawing.Size(279, 20); + this.txt_FileInjection.TabIndex = 1; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(4, 8); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(26, 13); + this.label2.TabIndex = 0; + this.label2.Text = "File:"; + // + // ofd_Injection + // + this.ofd_Injection.FileName = "Pokemon.pk7"; + // + // btn_Disconnect + // + this.btn_Disconnect.Location = new System.Drawing.Point(200, 13); + this.btn_Disconnect.Name = "btn_Disconnect"; + this.btn_Disconnect.Size = new System.Drawing.Size(75, 20); + this.btn_Disconnect.TabIndex = 29; + this.btn_Disconnect.Text = "Disconnect"; + this.btn_Disconnect.UseVisualStyleBackColor = true; + this.btn_Disconnect.Click += new System.EventHandler(this.btn_Disconnect_Click); + // + // timer1 + // + this.timer1.Enabled = true; + this.timer1.Interval = 1000; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(378, 552); - this.Controls.Add(this.cmb_Levels); - this.Controls.Add(this.label8); - this.Controls.Add(this.cmb_Gender); - this.Controls.Add(this.label7); - this.Controls.Add(this.nud_Dex); - this.Controls.Add(this.label6); - this.Controls.Add(this.cb_Spanish); - this.Controls.Add(this.btn_Export); - this.Controls.Add(this.lv_log); - this.Controls.Add(this.btn_Stop); - this.Controls.Add(this.btn_Start); - this.Controls.Add(this.tb_Folder); - this.Controls.Add(this.label5); - this.Controls.Add(this.tb_Default); - this.Controls.Add(this.label4); - this.Controls.Add(this.label1); - this.Controls.Add(this.tb_PokemonToFind); + this.Controls.Add(this.btn_Disconnect); + this.Controls.Add(this.tc_Control); this.Controls.Add(this.btn_Connect); - this.Controls.Add(this.lb_dummy2); - this.Controls.Add(this.tb_PID); - this.Controls.Add(this.l_dummy); - this.Controls.Add(this.tb_Port); this.Controls.Add(this.tb_IP); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "MainForm"; @@ -359,6 +536,14 @@ private void InitializeComponent() this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); this.Load += new System.EventHandler(this.MainForm_Load); ((System.ComponentModel.ISupportInitialize)(this.nud_Dex)).EndInit(); + this.tc_Control.ResumeLayout(false); + this.tp_GTS.ResumeLayout(false); + this.tp_GTS.PerformLayout(); + this.tp_Injection.ResumeLayout(false); + this.tp_Injection.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nud_CountInjection)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nud_SlotInjection)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nud_BoxInjection)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -367,10 +552,6 @@ private void InitializeComponent() #endregion private System.Windows.Forms.TextBox tb_IP; - private System.Windows.Forms.TextBox tb_Port; - private System.Windows.Forms.Label l_dummy; - private System.Windows.Forms.TextBox tb_PID; - private System.Windows.Forms.Label lb_dummy2; private System.Windows.Forms.Button btn_Connect; private System.Windows.Forms.TextBox tb_PokemonToFind; private System.Windows.Forms.Label label1; @@ -394,6 +575,22 @@ private void InitializeComponent() private System.Windows.Forms.ComboBox cmb_Gender; private System.Windows.Forms.Label label8; private System.Windows.Forms.ComboBox cmb_Levels; + private System.Windows.Forms.TabControl tc_Control; + private System.Windows.Forms.TabPage tp_GTS; + private System.Windows.Forms.TabPage tp_Injection; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button btn_Inject; + private System.Windows.Forms.NumericUpDown nud_SlotInjection; + private System.Windows.Forms.NumericUpDown nud_BoxInjection; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button btn_BrowseInject; + private System.Windows.Forms.TextBox txt_FileInjection; + private System.Windows.Forms.OpenFileDialog ofd_Injection; + private System.Windows.Forms.NumericUpDown nud_CountInjection; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Button btn_Disconnect; + private System.Windows.Forms.Timer timer1; } } diff --git a/Ledybot/Form1.cs b/Ledybot/Form1.cs index 0941dc3..d2cf4be 100644 --- a/Ledybot/Form1.cs +++ b/Ledybot/Form1.cs @@ -1,8 +1,11 @@ using System; using System.Configuration; +using System.Globalization; using System.IO; +using System.Linq; using System.Text; using System.Threading; +using System.Threading.Tasks; using System.Windows.Forms; namespace Ledybot @@ -11,29 +14,52 @@ public partial class MainForm : Form { public MainForm() { + Program.ntrClient.Connected += connectCheck; + Program.ntrClient.InfoReady += getGame; InitializeComponent(); + + ofd_Injection.Title = "Select an EKX/PKX file"; + ofd_Injection.Filter = "Gen 7 pokémon files|*.pk7"; + string path = @Application.StartupPath; + ofd_Injection.InitialDirectory = path; } + public int pid = 0; + private void btn_Connect_Click(object sender, EventArgs e) { string szIp = tb_IP.Text; - string szPort = tb_Port.Text; - - int iPort = Convert.ToInt32(szPort); if (!Program.Connected) { - Program.Connected = Program.scriptHelper.connect(szIp, iPort); - if (Program.Connected) - { - MessageBox.Show("Connection Successful!"); - } - } else + Program.scriptHelper.connect(szIp, 8000); + } + else { MessageBox.Show("You are already connected!"); } + + } + + public void getGame(object sender, EventArgs e) + { + InfoReadyEventArgs args = (InfoReadyEventArgs) e; + string log = args.info; + if(log.Contains("niji_loc")) + { + string splitlog = log.Substring(log.IndexOf(", pname: niji_loc") - 8, log.Length - log.IndexOf(", pname: niji_loc")); + pid = Convert.ToInt32("0x" + splitlog.Substring(0, 8), 16); + Program.scriptHelper.write(0x3DFFD0, BitConverter.GetBytes(0xE3A01000), pid); + MessageBox.Show("Connection Successful!"); + } + } + + public void connectCheck(object sender, EventArgs e) + { + + Program.scriptHelper.listprocess(); } Thread workerThread = null; @@ -44,17 +70,17 @@ private void btn_Start_Click(object sender, EventArgs e) if (workerThread == null && workerObject == null) { workerObject = new Worker(); - workerObject.setValues(tb_PokemonToFind.Text, tb_Default.Text, tb_Folder.Text, tb_PID.Text, cb_Spanish.Checked, (int) nud_Dex.Value, cmb_Gender.SelectedIndex, cmb_Levels.SelectedIndex); + workerObject.setValues(tb_PokemonToFind.Text, tb_Default.Text, tb_Folder.Text, pid, cb_Spanish.Checked, (int)nud_Dex.Value, cmb_Gender.SelectedIndex, cmb_Levels.SelectedIndex); workerThread = new Thread(workerObject.DoWork); workerThread.Start(); - } + } } public void AppendListViewItem(string szTrainerName, string szNickname, string szCountry, string szSubCountry) { if (InvokeRequired) { - this.Invoke(new Action(AppendListViewItem), new object[] { szTrainerName, szNickname, szCountry, szSubCountry }); + this.Invoke(new Action(AppendListViewItem), new object[] { szTrainerName, szNickname, szCountry, szSubCountry }); return; } string[] row = { DateTime.Now.ToString("h:mm:ss"), szTrainerName, szNickname, szCountry, szSubCountry }; @@ -66,7 +92,7 @@ public void AppendListViewItem(string szTrainerName, string szNickname, string s private void btn_Stop_Click(object sender, EventArgs e) { - if(workerThread != null && workerObject != null) + if (workerThread != null && workerObject != null) { workerObject.RequestStop(); workerThread.Join(); @@ -116,8 +142,6 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings["IP"].Value = tb_IP.Text; - config.AppSettings.Settings["Port"].Value = tb_Port.Text; - config.AppSettings.Settings["PID"].Value = tb_PID.Text; config.AppSettings.Settings["Deposited"].Value = tb_PokemonToFind.Text; config.AppSettings.Settings["Dex"].Value = nud_Dex.Value.ToString(); config.AppSettings.Settings["Level"].Value = cmb_Levels.SelectedIndex.ToString(); @@ -135,8 +159,6 @@ private void MainForm_Load(object sender, EventArgs e) { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); tb_IP.Text = config.AppSettings.Settings["IP"].Value; - tb_Port.Text = config.AppSettings.Settings["Port"].Value; - tb_PID.Text = config.AppSettings.Settings["PID"].Value; tb_PokemonToFind.Text = config.AppSettings.Settings["Deposited"].Value; nud_Dex.Value = Int32.Parse(config.AppSettings.Settings["Dex"].Value); cmb_Levels.SelectedIndex = Int32.Parse(config.AppSettings.Settings["Level"].Value); @@ -145,5 +167,75 @@ private void MainForm_Load(object sender, EventArgs e) tb_Folder.Text = config.AppSettings.Settings["Folder"].Value; cmb_Gender.SelectedIndex = Int32.Parse(config.AppSettings.Settings["Gender"].Value); } + + private void btn_BrowseInject_Click(object sender, EventArgs e) + { + if (ofd_Injection.ShowDialog() == DialogResult.OK) + { + txt_FileInjection.Text = ofd_Injection.FileName; + ofd_Injection.InitialDirectory = Path.GetDirectoryName(ofd_Injection.FileName); + } + } + + public uint boxOff = 0x330D9838; + + private void btn_Inject_Click(object sender, EventArgs e) + { + byte[] pkmEncrypted = System.IO.File.ReadAllBytes(txt_FileInjection.Text); + byte[] cloneshort = PKHeX.encryptArray(pkmEncrypted.Take(232).ToArray()); + uint boxIndex = Decimal.ToUInt32((nud_BoxInjection.Value - 1) * 30 + nud_SlotInjection.Value - 1); + uint count = Decimal.ToUInt32(nud_CountInjection.Value); + if (boxIndex + count > 32 * 30) + { + uint newCount = 32 * 30 - boxIndex; + count = newCount; + } + + byte[] dataToWrite = new byte[count * 232]; + for (int i = 0; i < count; i++) + cloneshort.CopyTo(dataToWrite, i * 232); + uint offset = boxOff + boxIndex * 232; + Program.scriptHelper.write(offset, dataToWrite, pid); + MessageBox.Show("Injection Successful!"); + } + + private void btn_Disconnect_Click(object sender, EventArgs e) + { + if (Program.Connected) + { + Program.ntrClient.disconnect(); + + if (!Program.Connected) + { + MessageBox.Show("Disconnection Successful!"); + } + } + else + { + MessageBox.Show("You are already disconnected!"); + } + } + + private void timer1_Tick(object sender, EventArgs e) + { + try + { + Program.ntrClient.sendHeartbeatPacket(); + } + catch (Exception) + { + + } + } + + private void nud_BoxInjection_ValueChanged(object sender, EventArgs e) + { + nud_CountInjection.Maximum = 32 * 30 - (Decimal.ToUInt32((nud_BoxInjection.Value - 1) * 30 + nud_SlotInjection.Value - 1)); + } + + private void nud_SlotInjection_ValueChanged(object sender, EventArgs e) + { + nud_CountInjection.Maximum = 32 * 30 - (Decimal.ToUInt32((nud_BoxInjection.Value - 1) * 30 + nud_SlotInjection.Value - 1)); + } } } diff --git a/Ledybot/Form1.resx b/Ledybot/Form1.resx index 5f6f09f..30f250b 100644 --- a/Ledybot/Form1.resx +++ b/Ledybot/Form1.resx @@ -117,6 +117,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 139, 17 + diff --git a/Ledybot/NTRClient.cs b/Ledybot/NTRClient.cs index 0936d22..83077de 100644 --- a/Ledybot/NTRClient.cs +++ b/Ledybot/NTRClient.cs @@ -7,6 +7,17 @@ namespace Ledybot { + + public class InfoReadyEventArgs : EventArgs + { + public string info; + + public InfoReadyEventArgs(string info_) + { + this.info = info_; + } + } + public class NTRClient { public String host; @@ -26,6 +37,20 @@ public class NTRClient public string retVal; public bool retDone; + public event EventHandler InfoReady; + public event EventHandler Connected; + + + protected virtual void OnInfoReady(InfoReadyEventArgs e) + { + InfoReady?.Invoke(this, e); + } + + protected virtual void OnConnected(EventArgs e) + { + Connected?.Invoke(this, e); + } + int readNetworkStream(NetworkStream stream, byte[] buf, int length) { @@ -97,6 +122,7 @@ void packetRecvThreadStart() byte[] dataBuf = new byte[dataLen]; readNetworkStream(stream, dataBuf, dataBuf.Length); string logMsg = Encoding.UTF8.GetString(dataBuf); + OnInfoReady(new InfoReadyEventArgs(logMsg)); //Console.WriteLine(logMsg); } lock (syncLock) @@ -136,38 +162,34 @@ void handleReadMem(UInt32 seq, byte[] dataBuf) return; } lastReadMemSeq = 0; - - int i = 0; - int iBufferlength = dataBuf.Length; - for (i = 0; i < dataBuf.Length; i++) + string szResult = ""; + if (dataBuf.Length > 4) { - if (i % 2 == 0) + int i = 0; + int iBufferlength = dataBuf.Length; + for (i = 0; i < dataBuf.Length; i++) { - if (dataBuf[i] == 0x00) + if (i % 2 == 0) { - iBufferlength = i; - break; + if (dataBuf[i] == 0x00) + { + iBufferlength = i; + break; + } } } - } - byte[] actualBuffer = new byte[iBufferlength]; - for (i = 0; i < actualBuffer.Length; i++) - { - actualBuffer[i] = dataBuf[i]; - } - - string szResult = ""; - - if(dataBuf.Length <= 4) - { - Array.Reverse(actualBuffer); - szResult = BitConverter.ToString(actualBuffer).Replace("-", string.Empty); + byte[] actualBuffer = new byte[iBufferlength]; + for (i = 0; i < actualBuffer.Length; i++) + { + actualBuffer[i] = dataBuf[i]; + } + szResult = Encoding.Unicode.GetString(actualBuffer).Trim('\0'); } else { - szResult = Encoding.Unicode.GetString(actualBuffer).Trim('\0'); + Array.Reverse(dataBuf); + szResult = BitConverter.ToString(dataBuf).Replace("-", string.Empty); } - //t.BeginInvoke((MethodInvoker)delegate () { t.Text = szResult; ; }); lock (retValLock) @@ -204,7 +226,7 @@ public void setServer(String serverHost, int serverPort) port = serverPort; } - public Boolean connectToServer() + public void connectToServer() { if (tcp != null) { @@ -214,26 +236,20 @@ public Boolean connectToServer() tcp.NoDelay = true; try { - if (tcp.ConnectAsync(host, port).Wait(1000)) - { - currentSeq = 0; - netStream = tcp.GetStream(); - heartbeatSendable = 1; - packetRecvThread = new Thread(new ThreadStart(packetRecvThreadStart)); - packetRecvThread.Start(); - Program.Connected = true; - } - else - { - Program.Connected = false; - } + tcp.Connect(host, port); + currentSeq = 0; + netStream = tcp.GetStream(); + heartbeatSendable = 1; + packetRecvThread = new Thread(new ThreadStart(packetRecvThreadStart)); + packetRecvThread.Start(); + OnConnected(null); + Program.Connected = true; } catch { + MessageBox.Show("Error connecting to the 3DS. Please make sure you have the correct IP.", "Ledybot", MessageBoxButtons.OK, MessageBoxIcon.Error); Program.Connected = false; } - - return Program.Connected; } public void disconnect(bool waitPacketThread = true) @@ -302,7 +318,7 @@ public void sendWriteMemPacket(UInt32 addr, UInt32 pid, byte[] buf) public void sendHeartbeatPacket() { - if (Program.Connected) + if (tcp != null) { lock (syncLock) { @@ -311,14 +327,6 @@ public void sendHeartbeatPacket() heartbeatSendable = 0; sendPacket(0, 0, null, 0); } - else - { - timeout++; - if (timeout == 5) - { - disconnect(false); - } - } } } diff --git a/Ledybot/ScriptHelper.cs b/Ledybot/ScriptHelper.cs index 78485b6..1ab34a1 100644 --- a/Ledybot/ScriptHelper.cs +++ b/Ledybot/ScriptHelper.cs @@ -1,5 +1,6 @@ using System; using System.Threading; +using System.Threading.Tasks; namespace Ledybot { @@ -15,10 +16,10 @@ public class ScriptHelper public uint searchBtn = 0x01B618E0; - public Boolean connect(string host, int port) + public void connect(string host, int port) { Program.ntrClient.setServer(host, port); - return Program.ntrClient.connectToServer(); + Program.ntrClient.connectToServer(); } public void disconnect() @@ -124,5 +125,10 @@ public string readSafe(UInt32 addr, UInt32 byteCount, int pid) return szReturn; } + public void listprocess() + { + Program.ntrClient.sendEmptyPacket(5); + } + } } \ No newline at end of file diff --git a/Ledybot/Worker.cs b/Ledybot/Worker.cs index 6a6f7d1..733adeb 100644 --- a/Ledybot/Worker.cs +++ b/Ledybot/Worker.cs @@ -34,6 +34,7 @@ public class Worker //private uint addr_PageEntryDexRequest = 0x32A6A7D0; private uint addr_PageSize = 0x32A6A1A4; private uint addr_PageEndStartRecord = 0x32A6A68C; + private uint addr_PageCurrentView = 0x305ea384; private uint addr_RequestedPokemon; private uint addr_RequestedLevel; @@ -449,12 +450,12 @@ public void RequestStop() _shouldStop = true; } - public void setValues(string szPtF, string szD, string szF, string szP, bool bSpanish, int dex, int gender, int level) + public void setValues(string szPtF, string szD, string szF, int iP, bool bSpanish, int dex, int gender, int level) { this.szPokemonToFind = szPtF; this.szDefaultPk7 = szD; this.szPk7Folder = szF; - this.szPID = szP; + this.iPID = iP; this.bSpanish = bSpanish; this.dexNum = dex; this.genderIndex = gender + 1; @@ -480,7 +481,7 @@ public void setValues(string szPtF, string szD, string szF, string szP, bool bSp addr_TrainerSubCountry = addr_TrainerSubCountry_en; } - this.iPID = int.Parse(szPID, NumberStyles.HexNumber); + } }