Add generic RAM read/write form

accessible once a save is loaded, same as item injecting

untested, but should be fine
This commit is contained in:
Kurt
2020-04-01 16:29:56 -07:00
parent 5578f4898b
commit ebfd2ca87f
18 changed files with 834 additions and 138 deletions

View File

@@ -0,0 +1,83 @@
using System.Windows.Forms;
namespace NHSE.WinForms
{
partial class SimpleHexEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.RTB_RAM = new System.Windows.Forms.RichTextBox();
this.B_Update = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// RTB_RAM
//
this.RTB_RAM.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.RTB_RAM.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.RTB_RAM.Location = new System.Drawing.Point(9, 10);
this.RTB_RAM.Name = "RTB_RAM";
this.RTB_RAM.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedVertical;
this.RTB_RAM.Size = new System.Drawing.Size(364, 292);
this.RTB_RAM.TabIndex = 0;
this.RTB_RAM.Text = "";
//
// B_Update
//
this.B_Update.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.B_Update.Location = new System.Drawing.Point(9, 308);
this.B_Update.Name = "B_Update";
this.B_Update.Size = new System.Drawing.Size(363, 26);
this.B_Update.TabIndex = 1;
this.B_Update.Text = "Update";
this.B_Update.UseVisualStyleBackColor = true;
this.B_Update.Click += new System.EventHandler(this.Update_Click);
//
// SimpleHexEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(384, 343);
this.Controls.Add(this.B_Update);
this.Controls.Add(this.RTB_RAM);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SimpleHexEditor";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "RAM Edit";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.RichTextBox RTB_RAM;
private Button B_Update;
}
}

View File

@@ -0,0 +1,26 @@
using System.Linq;
using System.Windows.Forms;
using NHSE.Injection;
namespace NHSE.WinForms
{
public partial class SimpleHexEditor : Form
{
public byte[] Bytes;
public SimpleHexEditor(byte[] originalBytes)
{
InitializeComponent();
RTB_RAM.Text = string.Join(" ", originalBytes.Select(z => $"{z:X2}"));
Bytes = originalBytes;
}
private void Update_Click(object sender, System.EventArgs e)
{
var bytestring = RTB_RAM.Text.Replace("\t", "").Replace(" ", "").Trim();
Bytes = Decoder.StringToByteArray(bytestring);
DialogResult = DialogResult.OK;
Close();
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,105 @@
using System;
using System.Windows.Forms;
using NHSE.Injection;
using NHSE.WinForms.Properties;
namespace NHSE.WinForms
{
public class SysBotController
{
public SysBotController(InjectionType type) => Type = type;
private readonly InjectionType Type;
private readonly SysBot Bot = new SysBot();
private readonly Settings Settings = Settings.Default;
public string IP => Settings.SysBotIP;
public string Port => Settings.SysBotPort.ToString();
public bool Connect(string ip, string port)
{
if (!int.TryParse(port, out var p))
p = 6000;
try
{
Bot.Connect(ip, p);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
WinFormsUtil.Error(ex.Message);
return false;
}
var settings = Settings;
settings.SysBotIP = ip;
settings.SysBotPort = p;
settings.Save();
return true;
}
public uint GetDefaultOffset()
{
var settings = Settings;
return Type switch
{
InjectionType.Generic => settings.SysBotGenericOffset,
InjectionType.Pouch => settings.SysBotPouchOffset,
_ => throw new ArgumentOutOfRangeException()
};
}
public void SetOffset(uint value)
{
var settings = Settings;
switch (Type)
{
case InjectionType.Generic: settings.SysBotGenericOffset = value; break;
case InjectionType.Pouch: settings.SysBotPouchOffset = value; break;
default: return;
}
settings.Save();
}
public void HexEdit(uint offset, int length)
{
var data = ReadBytes(offset, length);
using var ram = new SimpleHexEditor(data);
if (ram.ShowDialog() != DialogResult.OK)
return;
WriteBytes(data, offset);
SetOffset(offset);
System.Media.SystemSounds.Asterisk.Play();
}
public void PopPrompt()
{
if (Settings.SysBotPrompted)
return;
const string info = "This SysBot reads and writes RAM directly to your game when called to Read/Write.";
const string reqd = "Using this functionality requires the sys-botbase sysmodule running on the console." +
"Your console must be on the same network as the PC running this program.";
WinFormsUtil.Alert(info, reqd);
Settings.SysBotPrompted = true;
Settings.Save();
}
public void WriteBytes(byte[] data, uint offset)
{
Bot.WriteBytes(data, offset);
SetOffset(offset);
}
public byte[] ReadBytes(uint offset, int length)
{
var result = Bot.ReadBytes(offset, length);
SetOffset(offset);
return result;
}
}
}

View File

@@ -0,0 +1,203 @@
namespace NHSE.WinForms
{
partial class SysBotRAMEdit
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.B_Connect = new System.Windows.Forms.Button();
this.L_Port = new System.Windows.Forms.Label();
this.TB_Port = new System.Windows.Forms.TextBox();
this.L_IP = new System.Windows.Forms.Label();
this.TB_IP = new System.Windows.Forms.TextBox();
this.GB_Inject = new System.Windows.Forms.GroupBox();
this.NUD_Offset = new System.Windows.Forms.NumericUpDown();
this.L_Length = new System.Windows.Forms.Label();
this.RamOffset = new System.Windows.Forms.TextBox();
this.L_Offset = new System.Windows.Forms.Label();
this.B_Edit = new System.Windows.Forms.Button();
this.GB_Inject.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_Offset)).BeginInit();
this.SuspendLayout();
//
// B_Connect
//
this.B_Connect.Location = new System.Drawing.Point(102, 37);
this.B_Connect.Name = "B_Connect";
this.B_Connect.Size = new System.Drawing.Size(63, 23);
this.B_Connect.TabIndex = 12;
this.B_Connect.Text = "Connect";
this.B_Connect.UseVisualStyleBackColor = true;
this.B_Connect.Click += new System.EventHandler(this.B_Connect_Click);
//
// L_Port
//
this.L_Port.Location = new System.Drawing.Point(13, 38);
this.L_Port.Name = "L_Port";
this.L_Port.Size = new System.Drawing.Size(40, 20);
this.L_Port.TabIndex = 11;
this.L_Port.Text = "Port:";
this.L_Port.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// TB_Port
//
this.TB_Port.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.TB_Port.Location = new System.Drawing.Point(54, 38);
this.TB_Port.Name = "TB_Port";
this.TB_Port.Size = new System.Drawing.Size(42, 20);
this.TB_Port.TabIndex = 10;
this.TB_Port.Text = "6000";
//
// L_IP
//
this.L_IP.Location = new System.Drawing.Point(13, 12);
this.L_IP.Name = "L_IP";
this.L_IP.Size = new System.Drawing.Size(40, 20);
this.L_IP.TabIndex = 9;
this.L_IP.Text = "IP:";
this.L_IP.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// TB_IP
//
this.TB_IP.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.TB_IP.Location = new System.Drawing.Point(54, 12);
this.TB_IP.Name = "TB_IP";
this.TB_IP.Size = new System.Drawing.Size(111, 20);
this.TB_IP.TabIndex = 8;
this.TB_IP.Text = "111.111.111.111";
//
// GB_Inject
//
this.GB_Inject.Controls.Add(this.NUD_Offset);
this.GB_Inject.Controls.Add(this.L_Length);
this.GB_Inject.Controls.Add(this.RamOffset);
this.GB_Inject.Controls.Add(this.L_Offset);
this.GB_Inject.Controls.Add(this.B_Edit);
this.GB_Inject.Enabled = false;
this.GB_Inject.Location = new System.Drawing.Point(16, 66);
this.GB_Inject.Name = "GB_Inject";
this.GB_Inject.Size = new System.Drawing.Size(210, 67);
this.GB_Inject.TabIndex = 13;
this.GB_Inject.TabStop = false;
this.GB_Inject.Text = "Injector";
//
// numericUpDown1
//
this.NUD_Offset.Location = new System.Drawing.Point(73, 39);
this.NUD_Offset.Maximum = new decimal(new int[] {
8192,
0,
0,
0});
this.NUD_Offset.Name = "NUD_Offset";
this.NUD_Offset.Size = new System.Drawing.Size(63, 20);
this.NUD_Offset.TabIndex = 22;
this.NUD_Offset.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.NUD_Offset.Value = new decimal(new int[] {
1024,
0,
0,
0});
//
// L_Length
//
this.L_Length.Location = new System.Drawing.Point(5, 37);
this.L_Length.Name = "L_Length";
this.L_Length.Size = new System.Drawing.Size(63, 20);
this.L_Length.TabIndex = 21;
this.L_Length.Text = "Length:";
this.L_Length.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// RamOffset
//
this.RamOffset.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.RamOffset.Location = new System.Drawing.Point(73, 15);
this.RamOffset.MaxLength = 8;
this.RamOffset.Name = "RamOffset";
this.RamOffset.Size = new System.Drawing.Size(63, 20);
this.RamOffset.TabIndex = 20;
this.RamOffset.Text = "AC3B90C0";
//
// L_Offset
//
this.L_Offset.Location = new System.Drawing.Point(4, 14);
this.L_Offset.Name = "L_Offset";
this.L_Offset.Size = new System.Drawing.Size(63, 20);
this.L_Offset.TabIndex = 19;
this.L_Offset.Text = "Offset:";
this.L_Offset.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// B_Edit
//
this.B_Edit.Location = new System.Drawing.Point(142, 15);
this.B_Edit.Name = "B_Edit";
this.B_Edit.Size = new System.Drawing.Size(56, 44);
this.B_Edit.TabIndex = 0;
this.B_Edit.Text = "Edit";
this.B_Edit.UseVisualStyleBackColor = true;
this.B_Edit.Click += new System.EventHandler(this.B_Edit_Click);
//
// SysBotRAMEdit
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(234, 140);
this.Controls.Add(this.GB_Inject);
this.Controls.Add(this.B_Connect);
this.Controls.Add(this.L_Port);
this.Controls.Add(this.TB_Port);
this.Controls.Add(this.L_IP);
this.Controls.Add(this.TB_IP);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = global::NHSE.WinForms.Properties.Resources.icon;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SysBotRAMEdit";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "SysBotUI";
this.GB_Inject.ResumeLayout(false);
this.GB_Inject.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_Offset)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button B_Connect;
private System.Windows.Forms.Label L_Port;
private System.Windows.Forms.TextBox TB_Port;
private System.Windows.Forms.Label L_IP;
private System.Windows.Forms.TextBox TB_IP;
private System.Windows.Forms.GroupBox GB_Inject;
private System.Windows.Forms.Button B_Edit;
private System.Windows.Forms.TextBox RamOffset;
private System.Windows.Forms.Label L_Offset;
private System.Windows.Forms.Label L_Length;
private System.Windows.Forms.NumericUpDown NUD_Offset;
}
}

View File

@@ -0,0 +1,43 @@
using System;
using System.Windows.Forms;
using NHSE.Core;
using NHSE.Injection;
namespace NHSE.WinForms
{
public partial class SysBotRAMEdit : Form
{
private readonly SysBotController Bot;
public SysBotRAMEdit(InjectionType type)
{
InitializeComponent();
Bot = new SysBotController(type);
RamOffset.Text = Bot.GetDefaultOffset().ToString("X8");
TB_IP.Text = Bot.IP;
TB_Port.Text = Bot.Port;
Bot.PopPrompt();
}
private void B_Connect_Click(object sender, EventArgs e)
{
if (!Bot.Connect(TB_IP.Text, TB_Port.Text))
return;
GB_Inject.Enabled = true;
}
private void B_Edit_Click(object sender, EventArgs e)
{
var offset = StringUtil.GetHexValue(RamOffset.Text);
if (offset == 0)
{
WinFormsUtil.Error("Incorrect hex offset.");
return;
}
var length = (int)NUD_Offset.Value;
Bot.HexEdit(offset, length);
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,181 @@
namespace NHSE.WinForms
{
partial class SysBotUI
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.B_Connect = new System.Windows.Forms.Button();
this.L_Port = new System.Windows.Forms.Label();
this.TB_Port = new System.Windows.Forms.TextBox();
this.L_IP = new System.Windows.Forms.Label();
this.TB_IP = new System.Windows.Forms.TextBox();
this.GB_Inject = new System.Windows.Forms.GroupBox();
this.RamOffset = new System.Windows.Forms.TextBox();
this.L_Offset = new System.Windows.Forms.Label();
this.B_ReadCurrent = new System.Windows.Forms.Button();
this.B_WriteCurrent = new System.Windows.Forms.Button();
this.GB_Inject.SuspendLayout();
this.SuspendLayout();
//
// B_Connect
//
this.B_Connect.Location = new System.Drawing.Point(102, 37);
this.B_Connect.Name = "B_Connect";
this.B_Connect.Size = new System.Drawing.Size(63, 23);
this.B_Connect.TabIndex = 12;
this.B_Connect.Text = "Connect";
this.B_Connect.UseVisualStyleBackColor = true;
this.B_Connect.Click += new System.EventHandler(this.B_Connect_Click);
//
// L_Port
//
this.L_Port.Location = new System.Drawing.Point(13, 38);
this.L_Port.Name = "L_Port";
this.L_Port.Size = new System.Drawing.Size(40, 20);
this.L_Port.TabIndex = 11;
this.L_Port.Text = "Port:";
this.L_Port.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// TB_Port
//
this.TB_Port.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.TB_Port.Location = new System.Drawing.Point(54, 38);
this.TB_Port.Name = "TB_Port";
this.TB_Port.Size = new System.Drawing.Size(42, 20);
this.TB_Port.TabIndex = 10;
this.TB_Port.Text = "6000";
//
// L_IP
//
this.L_IP.Location = new System.Drawing.Point(13, 12);
this.L_IP.Name = "L_IP";
this.L_IP.Size = new System.Drawing.Size(40, 20);
this.L_IP.TabIndex = 9;
this.L_IP.Text = "IP:";
this.L_IP.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// TB_IP
//
this.TB_IP.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.TB_IP.Location = new System.Drawing.Point(54, 12);
this.TB_IP.Name = "TB_IP";
this.TB_IP.Size = new System.Drawing.Size(111, 20);
this.TB_IP.TabIndex = 8;
this.TB_IP.Text = "111.111.111.111";
//
// GB_Inject
//
this.GB_Inject.Controls.Add(this.RamOffset);
this.GB_Inject.Controls.Add(this.L_Offset);
this.GB_Inject.Controls.Add(this.B_ReadCurrent);
this.GB_Inject.Controls.Add(this.B_WriteCurrent);
this.GB_Inject.Enabled = false;
this.GB_Inject.Location = new System.Drawing.Point(16, 66);
this.GB_Inject.Name = "GB_Inject";
this.GB_Inject.Size = new System.Drawing.Size(149, 74);
this.GB_Inject.TabIndex = 13;
this.GB_Inject.TabStop = false;
this.GB_Inject.Text = "Injector";
//
// RamOffset
//
this.RamOffset.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.RamOffset.Location = new System.Drawing.Point(72, 19);
this.RamOffset.MaxLength = 8;
this.RamOffset.Name = "RamOffset";
this.RamOffset.Size = new System.Drawing.Size(63, 20);
this.RamOffset.TabIndex = 20;
this.RamOffset.Text = "AC3B90C0";
//
// L_Offset
//
this.L_Offset.Location = new System.Drawing.Point(3, 18);
this.L_Offset.Name = "L_Offset";
this.L_Offset.Size = new System.Drawing.Size(63, 20);
this.L_Offset.TabIndex = 19;
this.L_Offset.Text = "Offset:";
this.L_Offset.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// B_ReadCurrent
//
this.B_ReadCurrent.Location = new System.Drawing.Point(18, 41);
this.B_ReadCurrent.Name = "B_ReadCurrent";
this.B_ReadCurrent.Size = new System.Drawing.Size(56, 23);
this.B_ReadCurrent.TabIndex = 0;
this.B_ReadCurrent.Text = "Read";
this.B_ReadCurrent.UseVisualStyleBackColor = true;
this.B_ReadCurrent.Click += new System.EventHandler(this.B_ReadCurrent_Click);
//
// B_WriteCurrent
//
this.B_WriteCurrent.Location = new System.Drawing.Point(80, 41);
this.B_WriteCurrent.Name = "B_WriteCurrent";
this.B_WriteCurrent.Size = new System.Drawing.Size(56, 23);
this.B_WriteCurrent.TabIndex = 1;
this.B_WriteCurrent.Text = "Write";
this.B_WriteCurrent.UseVisualStyleBackColor = true;
this.B_WriteCurrent.Click += new System.EventHandler(this.B_WriteCurrent_Click);
//
// SysBotUI
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(184, 151);
this.Controls.Add(this.GB_Inject);
this.Controls.Add(this.B_Connect);
this.Controls.Add(this.L_Port);
this.Controls.Add(this.TB_Port);
this.Controls.Add(this.L_IP);
this.Controls.Add(this.TB_IP);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = global::NHSE.WinForms.Properties.Resources.icon;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SysBotUI";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "SysBotUI";
this.GB_Inject.ResumeLayout(false);
this.GB_Inject.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button B_Connect;
private System.Windows.Forms.Label L_Port;
private System.Windows.Forms.TextBox TB_Port;
private System.Windows.Forms.Label L_IP;
private System.Windows.Forms.TextBox TB_IP;
private System.Windows.Forms.GroupBox GB_Inject;
private System.Windows.Forms.Button B_ReadCurrent;
private System.Windows.Forms.Button B_WriteCurrent;
private System.Windows.Forms.TextBox RamOffset;
private System.Windows.Forms.Label L_Offset;
}
}

View File

@@ -0,0 +1,80 @@
using System;
using System.Windows.Forms;
using NHSE.Core;
using NHSE.Injection;
namespace NHSE.WinForms
{
public partial class SysBotUI : Form
{
private readonly Func<byte[]> ByteFetch;
private readonly Action<byte[]> ByteSet;
private readonly SysBotController Bot;
public SysBotUI(Action<byte[]> read, Func<byte[]> write, InjectionType type)
{
InitializeComponent();
Bot = new SysBotController(type);
ByteFetch = write;
ByteSet = read;
RamOffset.Text = Bot.GetDefaultOffset().ToString("X8");
TB_IP.Text = Bot.IP;
TB_Port.Text = Bot.Port;
Bot.PopPrompt();
}
private void B_Connect_Click(object sender, EventArgs e)
{
if (!Bot.Connect(TB_IP.Text, TB_Port.Text))
return;
GB_Inject.Enabled = true;
}
private void B_WriteCurrent_Click(object sender, EventArgs e)
{
var offset = StringUtil.GetHexValue(RamOffset.Text);
if (offset == 0)
{
WinFormsUtil.Error("Incorrect hex offset.");
return;
}
try
{
var data = ByteFetch();
Bot.WriteBytes(data, offset);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
WinFormsUtil.Error(ex.Message);
}
}
private void B_ReadCurrent_Click(object sender, EventArgs e)
{
var offset = StringUtil.GetHexValue(RamOffset.Text);
if (offset == 0)
{
WinFormsUtil.Error("Incorrect hex offset.");
return;
}
try
{
var data = ByteFetch();
var result = Bot.ReadBytes(offset, data.Length);
ByteSet(result);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
WinFormsUtil.Error(ex.Message);
}
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>