// Component Events private void buttonConnect_Click(object sender, EventArgs e) { //if (this.NtrClient? == null) this.NtrClient? = new NtrClient(); if (this.NtrClient?.IsConnected ?? false) { this.NtrClient?.Disconnect(); } this.buttonConnect.Enabled = false; this.txtIpAddress.Enabled = false; this.NtrClient?.SetServer(txtIpAddress.Text, 8000); this.ReadMemoryType = ReadMemoryType.None; this.ReadNtrStringType = ReadNtrStringType.None; this.Config.IpAddress = txtIpAddress.Text; new Task(() => { int Retry = 0; LogLine("Trying to connect to {0}", txtIpAddress.Text); do { NtrClient.ConnectToServer(); } while (!NtrClient.IsConnected && ++Retry < 3); if (!NtrClient.IsConnected) { LogLine("Unable to connect. :("); EnableConnect(); } }).Start(); }
private void cmbProcesses_SelectedIndexChanged(object sender, EventArgs e) { this.ReadNtrStringType = ReadNtrStringType.MemLayout; UInt32 Pid = GetPid(); cmbMemlayout.Enabled = true; if (!IsRestricted(GetProcessName())) { this.NtrClient?.SendMemLayoutPacket(Pid); } else { cmbMemlayout.Enabled = false; cmbMemlayout.Items.Clear(); LogLine("Memregions unavailable. Check Github for more information."); LogLine("If you want to get memregions anyways, click the button on the lower left of the General Tab"); } }
private void buttonProcesses_Click(object sender, EventArgs e) { this.ReadNtrStringType = ReadNtrStringType.Process; this.NtrClient?.SendProcessPacket(); }
private void buttonMemregions_Click(object sender, EventArgs e) { this.ReadNtrStringType = ReadNtrStringType.MemLayout; this.NtrClient?.SendMemLayoutPacket(GetPid()); }
private void HandleMessageReceived(String Message) { ReadNtrStringType Rnst = this.ReadNtrStringType; this.ReadNtrStringType = ReadNtrStringType.None; LogLine(Message); if (Rnst == ReadNtrStringType.Process) { // Now replace regex:" {2,}" with a single space. Message = new Regex(@"[ |\t]{2,}").Replace(Message, " "); // probably going to rewrite this, I don't like this solution List <String> ProcessStringList = Message.Split(Environment.NewLine).ToList(); List <String> cList = new List <string>(); //String processString = "{0} - {1}", PID, ProcessName for (int i = 0; i < ProcessStringList.Count; i++) { String[] sSplit = ProcessStringList[i].Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray(); if (sSplit.Length > 4) { cList.Add(String.Format("{0} - {1}", sSplit[1].Substring(2, 8), sSplit[3].Replace(",", ""))); } } this.cmbProcesses.TryInvoke(new Action(() => { this.cmbProcesses.Items.Clear(); this.cmbProcesses.Items.AddRange(cList.ToArray()); this.cmbProcesses.SelectedIndex = 0; })); } else if (Rnst == ReadNtrStringType.MemLayout) { /* * @"00100000 - 00dd7fff , size: 00cd8000" * 0 1 2 3 4 5 */ //if (IsRestricted(GetProcessName())) return; List <String> MemoryLayoutList = Message.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries).ToList(); if (MemoryLayoutList.Count >= 3) { Console.WriteLine("MLL Count: {0}", MemoryLayoutList.Count); MemoryLayoutList.RemoveAt(0); MemoryLayoutList.RemoveAt(MemoryLayoutList.Count - 1); List <String> MemLayouts = new List <string>(); foreach (String Entry in MemoryLayoutList) { try { String[] s = Entry.Split(' '); // split this later with @" | " String k = String.Format("{0} | {1} | {2}", s[0], s[2], s[5]); MemLayouts.Add(k); } catch (Exception) { } } cmbMemlayout.TryInvoke(new Action(() => { cmbMemlayout.Enabled = true; cmbMemlayout.Items.Clear(); cmbMemlayout.Items.AddRange(MemLayouts.ToArray()); cmbMemlayout.SelectedIndex = 0; })); } } }