From dd5eb0c7b5525c5e8938e1ff658ffb3565fb9e18 Mon Sep 17 00:00:00 2001 From: BranK <23649425+ItsBranK@users.noreply.github.com> Date: Fri, 18 Nov 2022 19:36:27 -0500 Subject: [PATCH] v1.2 - Converted the project to .NET 7.0 --- AboutFrm.Designer.cs | 10 ++-- AboutFrm.cs | 4 +- MainFrm.Designer.cs | 2 - MainFrm.cs | 124 ++++++++++++++++++------------------------ SignatureMaker.csproj | 10 +++- 5 files changed, 68 insertions(+), 82 deletions(-) diff --git a/AboutFrm.Designer.cs b/AboutFrm.Designer.cs index b4cfc6e..ba5b6ba 100644 --- a/AboutFrm.Designer.cs +++ b/AboutFrm.Designer.cs @@ -44,8 +44,8 @@ private void InitializeComponent() // this.GitHubLbl.BackColor = System.Drawing.Color.Transparent; this.GitHubLbl.Cursor = System.Windows.Forms.Cursors.Hand; - this.GitHubLbl.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.GitHubLbl.ForeColor = System.Drawing.Color.Blue; + this.GitHubLbl.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point); + this.GitHubLbl.ForeColor = System.Drawing.Color.DodgerBlue; this.GitHubLbl.Location = new System.Drawing.Point(103, 69); this.GitHubLbl.Name = "GitHubLbl"; this.GitHubLbl.Size = new System.Drawing.Size(255, 30); @@ -58,8 +58,8 @@ private void InitializeComponent() // this.IconsLbl.BackColor = System.Drawing.Color.Transparent; this.IconsLbl.Cursor = System.Windows.Forms.Cursors.Hand; - this.IconsLbl.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.IconsLbl.ForeColor = System.Drawing.Color.Blue; + this.IconsLbl.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point); + this.IconsLbl.ForeColor = System.Drawing.Color.DodgerBlue; this.IconsLbl.Location = new System.Drawing.Point(103, 99); this.IconsLbl.Name = "IconsLbl"; this.IconsLbl.Size = new System.Drawing.Size(255, 30); @@ -87,7 +87,7 @@ private void InitializeComponent() this.ArchetypeLbl.Name = "ArchetypeLbl"; this.ArchetypeLbl.Size = new System.Drawing.Size(255, 30); this.ArchetypeLbl.TabIndex = 6; - this.ArchetypeLbl.Text = "x64"; + this.ArchetypeLbl.Text = "x0"; this.ArchetypeLbl.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // GitHubTitle diff --git a/AboutFrm.cs b/AboutFrm.cs index 1f23d94..8245f33 100644 --- a/AboutFrm.cs +++ b/AboutFrm.cs @@ -1,4 +1,4 @@ -//#define X64BIT +#define X64BIT using System; using System.Collections.Generic; using System.ComponentModel; @@ -14,7 +14,7 @@ namespace SignatureMaker { public partial class AboutFrm : Form { - static readonly string Version = "v2.2"; + static readonly string Version = "v2.3"; public AboutFrm() { diff --git a/MainFrm.Designer.cs b/MainFrm.Designer.cs index e299102..52e9c40 100644 --- a/MainFrm.Designer.cs +++ b/MainFrm.Designer.cs @@ -477,7 +477,6 @@ private void InitializeComponent() this.MaskBx.ForeColor = System.Drawing.Color.Black; this.MaskBx.Location = new System.Drawing.Point(95, 50); this.MaskBx.Name = "MaskBx"; - this.MaskBx.ReadOnly = true; this.MaskBx.Size = new System.Drawing.Size(329, 25); this.MaskBx.TabIndex = 19; // @@ -499,7 +498,6 @@ private void InitializeComponent() this.BytesBx.ForeColor = System.Drawing.Color.Black; this.BytesBx.Location = new System.Drawing.Point(95, 20); this.BytesBx.Name = "BytesBx"; - this.BytesBx.ReadOnly = true; this.BytesBx.Size = new System.Drawing.Size(329, 25); this.BytesBx.TabIndex = 17; // diff --git a/MainFrm.cs b/MainFrm.cs index ba2f2b3..4af2cad 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -1,35 +1,35 @@ -//#define X64BIT +#define X64BIT using System; using System.Drawing; using System.Diagnostics; using System.Windows.Forms; using System.Globalization; using System.Collections.Generic; -using System.Text.RegularExpressions; using System.Runtime.InteropServices; +using System.Reflection; namespace SignatureMaker { enum OutputModes : byte { - MODE_HEX = 1, - MODE_HEX_ESCAPED = 2, - MODE_BYTE_ARRAY = 3, - MODE_MASK = 4 + MODE_HEX, + MODE_HEX_ESCAPED, + MODE_BYTE_ARRAY, + MODE_MASK } enum StatusTypes : byte { - TYPE_OK = 0, - TYPE_INFO = 1, - TYPE_WARNING = 2, - TYPE_ERROR = 3 + TYPE_OK, + TYPE_INFO, + TYPE_WARNING, + TYPE_ERROR } public partial class MainFrm : Form { [DllImport("kernel32.dll")] - public static extern bool ReadProcessMemory(IntPtr handle, IntPtr baseAddress, [Out] byte[] buffer, int size, out IntPtr numberOfBytesRead); + public static extern bool ReadProcessMemory(IntPtr handle, IntPtr baseAddress, [Out] byte[] buffer, Int32 size, out IntPtr numberOfBytesRead); bool FirstScan = true; OutputModes OutputMode = OutputModes.MODE_HEX_ESCAPED; @@ -54,27 +54,6 @@ private void MainFrm_Load(object sender, EventArgs e) #endif } - private T ConvertByteArray(ref byte[] bytes) - { - GCHandle handle = default(GCHandle); - T result; - - try - { - handle = GCHandle.Alloc(bytes, GCHandleType.Pinned); - result = Marshal.PtrToStructure(handle.AddrOfPinnedObject()); - } - finally - { - if (handle.IsAllocated) - { - handle.Free(); - } - } - - return result; - } - private byte[] ParsePattern(string pattern) { string[] patternArray = pattern.Split(' '); @@ -88,7 +67,7 @@ private byte[] ParsePattern(string pattern) return phrasedBytes.ToArray(); } - private byte[] ReadMemory(IntPtr handle, IntPtr address, int size) + private byte[] ReadMemory(IntPtr handle, IntPtr address, Int32 size) { IntPtr intPtr; byte[] array = new byte[size]; @@ -110,24 +89,24 @@ private IntPtr FindPattern(Process process, string pattern, string mask) IntPtr bytesRead; ReadProcessMemory(process.Handle, baseAddress, moduleBytes, moduleBytes.Length, out bytesRead); - int pos = 0; - int maskLength = mask.Length - 1; + Int32 currentPos = 0; + Int32 maskLength = (mask.Length - 1); - for (int modulePos = 0; modulePos < moduleBytes.Length; modulePos++) + for (Int32 modulePos = 0; modulePos < moduleBytes.Length; modulePos++) { - if (moduleBytes[modulePos] == patternBytes[pos] || mask[pos] == '?') + if (moduleBytes[modulePos] == patternBytes[currentPos] || mask[currentPos] == '?') { - if (pos == maskLength) + if (currentPos == maskLength) { - return IntPtr.Add(baseAddress, modulePos - maskLength); + return IntPtr.Add(baseAddress, (modulePos - maskLength)); } - pos++; + currentPos++; } else { - modulePos -= pos; - pos = 0; + modulePos -= currentPos; + currentPos = 0; } } @@ -137,16 +116,18 @@ private IntPtr FindPattern(Process process, string pattern, string mask) private void LoadProcesses() { ProcessBx.Items.Clear(); - Process[] processList = Process.GetProcesses(); foreach (Process process in processList) { - ProcessBx.Items.Add(process.ProcessName + " [" + process.Id.ToString() + "]"); + if (process != null) + { + ProcessBx.Items.Add(process.ProcessName + " [" + process.Id.ToString() + "]"); + } } } - private Process FindProcess(int pid) + private Process FindProcess(Int32 pid) { Process[] processList = Process.GetProcesses(); @@ -170,9 +151,9 @@ private string FixSpacing(string inputAOB, bool bAddSpacing) string rebuiltAOB = ""; char[] aobArray = inputAOB.ToCharArray(); - int index = 0; + Int32 index = 0; - for (int i = 0; i < aobArray.Length; i++) + for (Int32 i = 0; i < aobArray.Length; i++) { rebuiltAOB += aobArray[i].ToString(); @@ -210,10 +191,9 @@ private string CreateHex(string inputAOB) string[] inplutSplit = inputAOB.Split(' '); - for (int i = 0; i < inplutSplit.Length; i++) + for (Int32 i = 0; i < inplutSplit.Length; i++) { - if (inplutSplit[i].Length < 1 - || inplutSplit[i].Contains("?")) + if ((inplutSplit[i].Length < 1) || inplutSplit[i].Contains("?")) { inplutSplit[i] = "00"; } @@ -229,9 +209,9 @@ private string CreateByteArray(string inputAOB) string byteArray = "0x"; inputAOB = inputAOB.Replace("?", "0"); - int index = 0; + Int32 index = 0; - for (int i = 0; i < inputAOB.Length; i++) + for (Int32 i = 0; i < inputAOB.Length; i++) { if (i != inputAOB.Length) { @@ -261,11 +241,11 @@ private string CreateMask(string inputAOB) string result = ""; char[] splitBytes = inputAOB.ToCharArray(); - for (int i = 0; i < splitBytes.Length; i += 2) + for (Int32 i = 0; i < splitBytes.Length; i += 2) { - if (splitBytes[i].ToString() != "?" - && (i + 1) < splitBytes.Length - && splitBytes[(i + 1)].ToString() != "?") + if ((splitBytes[i].ToString() != "?") + && ((i + 1) < splitBytes.Length) + && (splitBytes[(i + 1)].ToString() != "?")) { result += "x"; } @@ -284,7 +264,7 @@ private string CompareBytes(string inputAOB, string compareAOB, out bool bBytesE char[] baseSplit = inputAOB.ToCharArray(); char[] compareSplit = compareAOB.ToCharArray(); - for (int i = 0; i < inputAOB.Length; i++) + for (Int32 i = 0; i < inputAOB.Length; i++) { if (i < compareAOB.Length) { @@ -304,7 +284,7 @@ private string CompareBytes(string inputAOB, string compareAOB, out bool bBytesE if (inputAOB.Length < compareAOB.Length) { - for (int i = inputAOB.Length; i < compareAOB.Length; i++) + for (Int32 i = inputAOB.Length; i < compareAOB.Length; i++) { string difference = compareSplit[i].ToString(); result += difference; @@ -312,7 +292,7 @@ private string CompareBytes(string inputAOB, string compareAOB, out bool bBytesE } else if (inputAOB.Length > compareAOB.Length) { - for (int i = compareAOB.Length; i < inputAOB.Length; i++) + for (Int32 i = compareAOB.Length; i < inputAOB.Length; i++) { string difference = inputAOB[i].ToString(); result += difference; @@ -360,20 +340,20 @@ private void SetStatus(string text, StatusTypes type) private void ProcessBx_SelectedValueChanged(object sender, EventArgs e) { - int pidStart = ProcessBx.Text.IndexOf('[') + 1; + Int32 pidStart = ProcessBx.Text.IndexOf('[') + 1; string pidStr = ProcessBx.Text.Substring(pidStart, (ProcessBx.Text.Length - pidStart) - 1); - PIDBx.Value = int.Parse(pidStr); + PIDBx.Value = Int32.Parse(pidStr); } private void PIDBx_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { - Process foundProcess = FindProcess((int)PIDBx.Value); + Process foundProcess = FindProcess((Int32)PIDBx.Value); if (foundProcess != null) { - ProcessBx.Text = foundProcess.ProcessName + " [" + foundProcess.Id.ToString() + "]"; + ProcessBx.Text = (foundProcess.ProcessName + " [" + foundProcess.Id.ToString() + "]"); } } } @@ -387,15 +367,17 @@ private void RefreshBtn_Click(object sender, EventArgs e) private void PasteBtn_Click(object sender, EventArgs e) { AddressBx.Text = Clipboard.GetText(); + AddressBx.Text = AddressBx.Text.Replace("0x", ""); + AddressBx.Text = AddressBx.Text.Replace("0X", ""); } private void CreateBtn_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(AddressBx.Text)) { - Process process = FindProcess((int)PIDBx.Value); - + Process process = FindProcess((Int32)PIDBx.Value); CurrentAddress = AddressBx.Text.Replace("0x", ""); + CurrentAddress = AddressBx.Text.Replace("0X", ""); if (process != null) { @@ -406,7 +388,7 @@ private void CreateBtn_Click(object sender, EventArgs e) #endif IntPtr addressPointer = (IntPtr)addressDecimal; - byte[] foundBytes = ReadMemory(process.Handle, addressPointer, (int)LengthBx.Value); + byte[] foundBytes = ReadMemory(process.Handle, addressPointer, (Int32)LengthBx.Value); if (foundBytes != null) { @@ -414,8 +396,7 @@ private void CreateBtn_Click(object sender, EventArgs e) if (!string.IsNullOrEmpty(BaseBx.Text)) { - if (!string.IsNullOrEmpty(CompareBx.Text) - && !BaseBx.Items.Contains(CompareBx.Text)) + if (!string.IsNullOrEmpty(CompareBx.Text) && !BaseBx.Items.Contains(CompareBx.Text)) { BaseBx.Items.Add(CompareBx.Text); } @@ -536,14 +517,13 @@ private void ResetBtn_Click(object sender, EventArgs e) private void TestBtn_Click(object sender, EventArgs e) { - if (!string.IsNullOrEmpty(BytesBx.Text) - && !string.IsNullOrEmpty(MaskBx.Text)) + if (!string.IsNullOrEmpty(BytesBx.Text) && !string.IsNullOrEmpty(MaskBx.Text)) { - Process process = FindProcess((int)PIDBx.Value); + Process process = FindProcess((Int32)PIDBx.Value); if (process != null) { - IntPtr foundPointer = FindPattern(process, FixSpacing(CurrentHex, true), CreateMask(CurrentDifferenceAOB)); + IntPtr foundPointer = FindPattern(process, FixSpacing(CurrentHex, true), MaskBx.Text); if (foundPointer != IntPtr.Zero) { diff --git a/SignatureMaker.csproj b/SignatureMaker.csproj index b55470d..8620fec 100644 --- a/SignatureMaker.csproj +++ b/SignatureMaker.csproj @@ -1,10 +1,18 @@  WinExe - net5.0-windows + net7.0-windows true AnyCPU;x64;x86 SM.ico + ItsBranK + Automatically generate signatures from an address, or compare your own array of bytes. + ItsBranK + ItsBranK + + https://github.com/ItsBranK/SignatureMaker + 2.3.0.0 + false