-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Upgrade the project to .NET 7.0. - Processes are now sorted by alphabetical order in the combobox. - Created separate classes for formatting and reading memory internally. - Various code redundancy fixes and optimization.
- Loading branch information
Showing
6 changed files
with
265 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
using System; | ||
|
||
namespace SignatureMaker | ||
{ | ||
public class Format | ||
{ | ||
public static string CompareBytes(string originalArray, string compareArray) | ||
{ | ||
originalArray = originalArray.Replace("?", "0").Replace(" ", ""); | ||
compareArray = compareArray.Replace("?", "0").Replace(" ", ""); | ||
char[] originalChars = originalArray.ToCharArray(); | ||
char[] compareChars = compareArray.ToCharArray(); | ||
string comparedBytes = ""; | ||
|
||
for (Int32 i = 0; i < originalArray.Length; i++) | ||
{ | ||
if (i < compareArray.Length) | ||
{ | ||
if (originalChars[i] == compareChars[i]) | ||
{ | ||
comparedBytes += originalChars[i]; | ||
} | ||
else | ||
{ | ||
comparedBytes += "?"; | ||
} | ||
} | ||
} | ||
|
||
if (originalArray.Length < compareArray.Length) | ||
{ | ||
for (Int32 i = originalArray.Length; i < compareArray.Length; i++) | ||
{ | ||
comparedBytes += compareChars[i]; | ||
} | ||
} | ||
else if (originalArray.Length > compareArray.Length) | ||
{ | ||
for (Int32 i = compareArray.Length; i < originalArray.Length; i++) | ||
{ | ||
comparedBytes += originalArray[i].ToString(); | ||
} | ||
} | ||
|
||
if ((comparedBytes.Length & 1) == 1) | ||
{ | ||
comparedBytes = comparedBytes.Remove(comparedBytes.Length - 1); | ||
} | ||
|
||
return comparedBytes; | ||
} | ||
|
||
// Inserts a space between every two characets in a string. | ||
public static string FormatSpacing(string arrayOfBytes) | ||
{ | ||
arrayOfBytes = arrayOfBytes.Replace(" ", ""); | ||
char[] charArray = arrayOfBytes.ToCharArray(); | ||
string formattedArray = ""; | ||
|
||
Int32 index = 0; | ||
|
||
for (Int32 i = 0; i < charArray.Length; i++) | ||
{ | ||
formattedArray += charArray[i].ToString(); | ||
|
||
if (i == charArray.Length - 1) | ||
{ | ||
if ((i + 2) <= charArray.Length) | ||
{ | ||
formattedArray = formattedArray.Insert((i + 2), " "); | ||
} | ||
} | ||
else | ||
{ | ||
if (index == 1) | ||
{ | ||
formattedArray += " "; | ||
index = 0; | ||
} | ||
else | ||
{ | ||
index++; | ||
} | ||
} | ||
} | ||
|
||
return formattedArray; | ||
} | ||
|
||
// Creates a "hex valid" string for the given array of bytes, replacing questions with zeros. | ||
public static string CreateHex(string arrayOfBytes) | ||
{ | ||
arrayOfBytes = FormatSpacing(arrayOfBytes); | ||
string[] arraySplit = arrayOfBytes.Split(' '); | ||
string createdHex = ""; | ||
|
||
foreach (string str in arraySplit) | ||
{ | ||
if ((String.IsNullOrEmpty(str)) || str.Contains("?")) | ||
{ | ||
createdHex += "00"; | ||
} | ||
else | ||
{ | ||
createdHex += str; | ||
} | ||
} | ||
|
||
return FormatSpacing(createdHex); | ||
} | ||
|
||
// Creates a hex escaped version of "CreateHex". | ||
public static string CreateHexEscaped(string arrayOfBytes) | ||
{ | ||
string createdHex = ("\\x" + CreateHex(arrayOfBytes)); | ||
return createdHex.Replace(" ", "\\x"); | ||
} | ||
|
||
public static string CreateByteArray(string arrayOfBytes) | ||
{ | ||
arrayOfBytes = arrayOfBytes.Replace("?", "0"); | ||
string createdArray = "0x"; | ||
|
||
Int32 index = 0; | ||
|
||
for (Int32 i = 0; i < arrayOfBytes.Length; i++) | ||
{ | ||
if (i != arrayOfBytes.Length) | ||
{ | ||
if (index == 0) | ||
{ | ||
index = 1; | ||
createdArray += arrayOfBytes[i].ToString(); | ||
} | ||
else if (index == 1) | ||
{ | ||
index = 0; | ||
createdArray += arrayOfBytes[i].ToString(); | ||
|
||
if (i != (arrayOfBytes.Length - 1) && (i + 2) <= arrayOfBytes.Length) | ||
{ | ||
createdArray += ", 0x"; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return createdArray; | ||
} | ||
|
||
// Creates a "half byte" mask with the given array of bytes, treats two characers as one. | ||
public static string CreateHalfMask(string arrayOfBytes) | ||
{ | ||
arrayOfBytes = arrayOfBytes.Replace(" ", ""); | ||
char[] charArray = arrayOfBytes.ToCharArray(); | ||
string createdMask = ""; | ||
|
||
for (Int32 i = 0; i < charArray.Length; i += 2) | ||
{ | ||
if ((charArray[i] != '?') | ||
&& ((i + 1) < charArray.Length) | ||
&& (charArray[(i + 1)] != '?')) | ||
{ | ||
createdMask += "x"; | ||
} | ||
else if ((i + 1) < charArray.Length) | ||
{ | ||
createdMask += "?"; | ||
} | ||
} | ||
|
||
return createdMask; | ||
} | ||
|
||
// Creates a "full byte" mask, creates a one to one mask of the given array of bytes. | ||
public static string CreateFullMask(string arrayOfBytes) | ||
{ | ||
arrayOfBytes = arrayOfBytes.Replace(" ", ""); | ||
string createdMask = ""; | ||
|
||
foreach (char c in arrayOfBytes) | ||
{ | ||
if (c == '?') | ||
{ | ||
createdMask += ((c == '?') ? "?" : "x"); | ||
} | ||
} | ||
|
||
return createdMask; | ||
} | ||
} | ||
} |
Oops, something went wrong.