//Checks a value based on a scantype by calling other syntax checking methods public static bool Value(string value, ScanDataType ScanValueType, bool isHex) { switch (ScanValueType) { case ScanDataType.Binary: return(BinaryValue(value)); case ScanDataType.Byte: return(ByteValue(value, isHex)); case ScanDataType.Int16: return(Int16Value(value, isHex)); case ScanDataType.Int32: return(Int32Value(value, isHex)); case ScanDataType.Int64: return(Int64Value(value, isHex)); case ScanDataType.Single: return(SingleValue(value, isHex)); case ScanDataType.Double: return(DoubleValue(value, isHex)); case ScanDataType.Text: return(true); } return(false); }
private void ComboBox_DataType_SelectedIndexChanged(object sender, EventArgs e) { RadioButton_Truncated.Visible = false; RadioButton_Rounded.Visible = false; ScanDataType _ScanValueType = (ScanDataType)ComboBox_DataType.SelectedIndex; switch (_ScanValueType) { case ScanDataType.Binary: case ScanDataType.Byte: NUD_OptimizeScan.Value = 1; break; case ScanDataType.Int16: NUD_OptimizeScan.Value = 2; break; case ScanDataType.Single: case ScanDataType.Double: RadioButton_Truncated.Visible = true; RadioButton_Rounded.Visible = true; NUD_OptimizeScan.Value = 4; break; case ScanDataType.Int32: case ScanDataType.Int64: NUD_OptimizeScan.Value = 4; break; } }
public ValueWindow(ScanDataType ScanType, object Value) { InitializeComponent(); AcceptValueButton.DialogResult = System.Windows.Forms.DialogResult.OK; this.ScanType = ScanType; this.Value = Value; ValueTextBox.Text = Value.ToString(); }
public Form_EditValue(ScanDataType ScanType, object Value) { InitializeComponent(); Button_Accept.DialogResult = System.Windows.Forms.DialogResult.OK; this.ScanType = ScanType; this.Value = Value; TextBox_Value.Text = Value.ToString(); }
public TableEntry(string Description, UInt64 Address, ScanDataType ScanType, bool IsSigned, bool ValueAsHex, bool AddressAsHex, string ASMScript) { this.Description = Description; this.Address = Address; this.ScanType = ScanType; this.IsSigned = IsSigned; this.ValueAsHex = ValueAsHex; this.AddressAsHex = AddressAsHex; this.ASMScript = ASMScript; Value = null; CheckState = false; }
public static string ScanTypeToName(ScanDataType _ScanType) { switch (_ScanType) { case ScanDataType.AOB: return("Array of Bytes"); case ScanDataType.All: return(ScanDataType.All.ToString()); default: return(_ScanType.ToString()); } }
public TableEntry(string Description, UInt64 Address, ScanDataType ScanType, bool IsSigned, bool ValueAsHex, bool AddressAsHex, string ASMScript) { //Load in initial data this.Description = Description; this.Address = Address; this.ScanType = ScanType; this.IsSigned = IsSigned; this.ValueAsHex = ValueAsHex; this.AddressAsHex = AddressAsHex; this.ASMScript = ASMScript; //Determined later Value = null; CheckState = false; }
public void AddTable(string Description, UInt64 Address, ScanDataType scantype, bool Signed, bool ValueAsHex, bool AddressAsHex, string ASMScript) { TableData.Add(new TableEntry(Description, Address, scantype, Signed, ValueAsHex, AddressAsHex, ASMScript)); int TableIndex = TableData.Count - 1; string[] AddInfo = new string[4]; AddInfo[0] = TableData[TableIndex].Description; AddInfo[1] = Conversions.Conversions.ToAddress((TableData[TableIndex].Address.ToString())); AddInfo[2] = Conversions.Conversions.ScanTypeToName(TableData[TableIndex].ScanType); AddInfo[3] = "???"; ListView_Table.Items.Add("").SubItems.AddRange(AddInfo); Button_Table_Clear.Enabled = true; }
public Form_AddSpecific(bool isChanged, string address, string description, ScanDataType scanType) { InitializeComponent(); if (isChanged == true) { this.Text = "Change Specific Address"; TextBox_Address.Text = Address; TextBox_Description.Text = Description; ComboBox_ValueType.SelectedIndex = changeType; ScanType = scanType; ComboBox_ValueType.SelectedIndex = (int)ScanType; } else { this.Text = "Add Specific Address"; } }
public AddSpecificWindow(bool isChanged, string address, string description, ScanDataType scanType) { InitializeComponent(); if (isChanged == true) { this.Text = "Change Address"; AddressTextBox.Text = Address; DescriptionTextBox.Text = Description; ValueTypeComboBox.SelectedIndex = changeType; ScanType = scanType; ValueTypeComboBox.SelectedIndex = (int)ScanType; } else { this.Text = "Add New Address"; } SetToolTips(); }
public static DataTypeSize ScanDataTypeToDataTypeSize(ScanDataType ScanDataType) { switch (ScanDataType) { case ScanDataType.Byte: return(DataTypeSize.Byte); case ScanDataType.Int16: return(DataTypeSize.Int16); case ScanDataType.Int32: return(DataTypeSize.Int32); case ScanDataType.Int64: return(DataTypeSize.Int64); case ScanDataType.Single: return(DataTypeSize.Single); case ScanDataType.Double: return(DataTypeSize.Double); } return(DataTypeSize.Int32); }
//Checks a value based on a scantype by calling other syntax checking methods public static bool Value(string value, ScanDataType ScanValueType, bool isHex) { switch (ScanValueType) { case ScanDataType.Binary: return BinaryValue(value); case ScanDataType.Byte: return ByteValue(value, isHex); case ScanDataType.Int16: return Int16Value(value, isHex); case ScanDataType.Int32: return Int32Value(value, isHex); case ScanDataType.Int64: return Int64Value(value, isHex); case ScanDataType.Single: return SingleValue(value, isHex); case ScanDataType.Double: return DoubleValue(value, isHex); case ScanDataType.Text: return true; } return false; }
private bool ScanButtonShared(bool IsRescan, UInt64 FirstAddress, UInt64 LastAddress) { object ScanValue; object SecondScanValue; SelectedScanType = (ScanDataType)ComboBox_DataType.SelectedIndex; #region Collect scan data from form and check for errors if (TargetProcess == null) { MessageBox.Show("Please select a process", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } if (!CheckSyntax.Value(TextBox_ScanValue.Text, (ScanDataType)ComboBox_DataType.SelectedIndex, CheckBox_IsHex.Checked) && TextBox_ScanValue.Enabled == true || !CheckSyntax.Value(ScanSecondValueTextBox.Text, (ScanDataType)ComboBox_DataType.SelectedIndex, CheckBox_IsHex.Checked) && ScanSecondValueTextBox.Visible == true) { MessageBox.Show("Invalid value format", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } if (TextBox_ScanValue.Enabled == true) { ScanValue = Conversions.Conversions.ToUnsigned(TextBox_ScanValue.Text, SelectedScanType); } else { ScanValue = null; } if (ScanSecondValueTextBox.Visible == true) { SecondScanValue = Conversions.Conversions.ToUnsigned(ScanSecondValueTextBox.Text, SelectedScanType); } else { SecondScanValue = null; } #endregion #region Prescan events uint[] Protect = new uint[8]; int CheckedItems = CheckedListBox_Protection.CheckedIndices.Count; for (int ecx = 0; ecx < CheckedItems; ecx++) { Protect[CheckedListBox_Protection.CheckedIndices[ecx]] = 1; } uint[] Type = new uint[3]; CheckedItems = CheckedListBox_Type.CheckedIndices.Count; for (int ecx = 0; ecx < CheckedItems; ecx++) { Type[CheckedListBox_Type.CheckedIndices[ecx]] = 1; } ScanOptimizationData ScanOptimizationData = new ScanOptimizationData(CheckBox_OptimizeScan.Checked, (UInt64)NUD_OptimizeScan.Value, RadioButton_LastDigits.Checked); bool CompareToFirstScan = false; if (IsRescan && CheckBox_CompareToFirstCB.Checked == true) { CompareToFirstScan = true; } Scan = new ScanMemory(TargetProcess, FirstAddress, LastAddress, SelectedScanType, Conversions.Conversions.StringToScanType(ComboBox_CompareType.Items[ComboBox_CompareType.SelectedIndex].ToString()), ScanValue, SecondScanValue, Protect, Type, RadioButton_Truncated.Checked, ScanOptimizationData, ExecutablePath, CompareToFirstScan); Scan.ScanProgressChanged += new ScanMemory.ScanProgressedEventHandler(scan_ScanProgressChanged); Scan.ScanCompleted += new ScanMemory.ScanCompletedEventHandler(scan_ScanCompleted); Scan.ScanCanceled += new ScanMemory.ScanCanceledEventHandler(scan_ScanCanceled); ListView_Address.VirtualListSize = 0; ListView_Address.Items.Clear(); if (CurrentAddressAccessor != null) { CurrentAddressAccessor.Dispose(); } if (CurrentScanAddresses != null) { CurrentScanAddresses.Dispose(); } ProgressBar.Value = 0; #endregion #region Start scan ScanTimeStopwatch = Stopwatch.StartNew(); try { Scan.StartScan(IsRescan); } catch (Exception ex) { MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Warning); Scan.CancelScan(); return(false); } return(true); #endregion }
public static DataTypeSize ScanDataTypeToDataTypeSize(ScanDataType ScanDataType) { switch (ScanDataType) { case ScanDataType.Byte: return DataTypeSize.Byte; case ScanDataType.Int16: return DataTypeSize.Int16; case ScanDataType.Int32: return DataTypeSize.Int32; case ScanDataType.Int64: return DataTypeSize.Int64; case ScanDataType.Single: return DataTypeSize.Single; case ScanDataType.Double: return DataTypeSize.Double; } return DataTypeSize.Int32; }
public static object ToUnsigned(string value, ScanDataType ScanType) { object ScanValue = 0; bool signed = false; if (value.Substring(0, 1) == "-") { signed = true; } switch (ScanType) { case ScanDataType.Binary: break; case ScanDataType.Byte: if (signed) //if signed convert to unsigned (easier to deal with) { sbyte signedByte = Convert.ToSByte(value); ScanValue = (byte)signedByte; } else { ScanValue = Convert.ToByte(value); } break; case ScanDataType.Int16: if (signed) { Int16 signedInt16 = Convert.ToInt16(value); ScanValue = (UInt16)signedInt16; } else { ScanValue = Convert.ToUInt16(value); } break; case ScanDataType.Int32: if (signed) { Int32 signedInt32 = Convert.ToInt32(value); ScanValue = (UInt32)signedInt32; } else { ScanValue = Convert.ToUInt32(value); } break; case ScanDataType.Int64: if (signed) { Int64 signedInt64 = Convert.ToInt64(value); ScanValue = (UInt64)signedInt64; } else { ScanValue = Convert.ToUInt64(value); } break; case ScanDataType.Single: ScanValue = Convert.ToSingle(value); break; case ScanDataType.Double: ScanValue = Convert.ToDouble(value); break; case ScanDataType.Text: ScanValue = value; break; case ScanDataType.AOB: break; case ScanDataType.All: break; default: break; } return(ScanValue); }
public Form_EditType(ScanDataType ScanType) { InitializeComponent(); this.ScanType = ScanType; }
//Computes logic regarding significant decimal places if the scan type is single/float public void CalculateSignificantFigures(ScanDataType ScanDataType) { switch (ScanDataType) { case ScanDataType.Single: //Determine significant decimal figures based on how many user typed if (ScanValue != null) { string FloatString = Convert.ToString((Single)ScanValue); int DecimalIndex = FloatString.IndexOf("."); if (DecimalIndex == -1) SignificantDigits = 0; else SignificantDigits = (FloatString.Length - 1) - DecimalIndex; //We multiply numbers we find by 10^x power and cast to an int64, //so that we only check up to the correct decimal place SignificantDigits = (Int32)Math.Pow(10d, SignificantDigits); _ScanValue = (Int64)((Single)ScanValue * SignificantDigits); } break; case ScanDataType.Double: if (ScanValue != null) { string DoubleString = Convert.ToString((Double)ScanValue); int DecimalIndex = DoubleString.IndexOf("."); if (DecimalIndex == -1) SignificantDigits = 0; else SignificantDigits = (DoubleString.Length - 1) - DecimalIndex; SignificantDigits = (Int32)Math.Pow(10d, SignificantDigits); _ScanValue = (Int64)((Double)ScanValue * SignificantDigits); } break; default: return; } }
private void acceptButton_Click(object sender, EventArgs e) { ScanType = (ScanDataType)ValueTypeComboBox.SelectedIndex; }
public TypeWindow(ScanDataType ScanType) { InitializeComponent(); this.ScanType = ScanType; }
public static object ToUnsigned(string value, ScanDataType ScanType) { object ScanValue = 0; bool signed = false; if (value.Substring(0, 1) == "-") signed = true; switch (ScanType) { case ScanDataType.Binary: break; case ScanDataType.Byte: if (signed) //if signed convert to unsigned (easier to deal with) { sbyte signedByte = Convert.ToSByte(value); ScanValue = (byte)signedByte; } else ScanValue = Convert.ToByte(value); break; case ScanDataType.Int16: if (signed) { Int16 signedInt16 = Convert.ToInt16(value); ScanValue = (UInt16)signedInt16; } else ScanValue = Convert.ToUInt16(value); break; case ScanDataType.Int32: if (signed) { Int32 signedInt32 = Convert.ToInt32(value); ScanValue = (UInt32)signedInt32; } else ScanValue = Convert.ToUInt32(value); break; case ScanDataType.Int64: if (signed) { Int64 signedInt64 = Convert.ToInt64(value); ScanValue = (UInt64)signedInt64; } else ScanValue = Convert.ToUInt64(value); break; case ScanDataType.Single: ScanValue = Convert.ToSingle(value); break; case ScanDataType.Double: ScanValue = Convert.ToDouble(value); break; case ScanDataType.Text: ScanValue = value; break; case ScanDataType.AOB: break; case ScanDataType.All: break; default: break; } return ScanValue; }
public static string ScanTypeToName(ScanDataType _ScanType) { switch (_ScanType) { case ScanDataType.AOB: return "Array of Bytes"; case ScanDataType.All: return ScanDataType.All.ToString(); default: return _ScanType.ToString(); } }
private void acceptButton_Click(object sender, EventArgs e) { if (IsHexCB.Checked == true) { if (!CheckSyntax.Address(AddressTextBox.Text)) { MessageBox.Show("Invalid address format.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Address = AddressTextBox.Text; } else { if (!CheckSyntax.Int32Value(AddressTextBox.Text, false)) { MessageBox.Show("Invalid address format.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Address = Conversions.ToHex(AddressTextBox.Text); } if (DescriptionTextBox.Text == "") Description = "No Description"; else Description = DescriptionTextBox.Text; switch (ValueTypeComboBox.SelectedIndex) { case 0: ScanType = ScanDataType.Binary; break; case 1: ScanType = ScanDataType.Byte; break; case 2: ScanType = ScanDataType.Int16; break; case 3: ScanType = ScanDataType.Int32; break; case 4: ScanType = ScanDataType.Int64; break; case 5: ScanType = ScanDataType.Single; break; case 6: ScanType = ScanDataType.Double; break; case 7: ScanType = ScanDataType.Text; break; case 8: ScanType = ScanDataType.AOB; break; case 9: ScanType = ScanDataType.All; break; } this.Close(); }
private void Button_Accept_Click(object sender, EventArgs e) { ScanType = (ScanDataType)ComboBox_ValueType.SelectedIndex; }
private void acceptButton_Click(object sender, EventArgs e) { if (IsHexCB.Checked == true) { if (!CheckSyntax.Address(AddressTextBox.Text)) { MessageBox.Show("Invalid address format.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Address = AddressTextBox.Text; } else { if (!CheckSyntax.Int32Value(AddressTextBox.Text, false)) { MessageBox.Show("Invalid address format.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Address = Conversions.ToHex(AddressTextBox.Text); } if (DescriptionTextBox.Text == "") { Description = "No Description"; } else { Description = DescriptionTextBox.Text; } switch (ValueTypeComboBox.SelectedIndex) { case 0: ScanType = ScanDataType.Binary; break; case 1: ScanType = ScanDataType.Byte; break; case 2: ScanType = ScanDataType.Int16; break; case 3: ScanType = ScanDataType.Int32; break; case 4: ScanType = ScanDataType.Int64; break; case 5: ScanType = ScanDataType.Single; break; case 6: ScanType = ScanDataType.Double; break; case 7: ScanType = ScanDataType.Text; break; case 8: ScanType = ScanDataType.AOB; break; case 9: ScanType = ScanDataType.All; break; } this.Close(); }
public void AddTable(string Description, UInt64 Address, ScanDataType scantype, bool Signed, bool ValueAsHex, bool AddressAsHex, string ASMScript) { TableData.Add(new TableEntry(Description, Address, scantype, Signed, ValueAsHex, AddressAsHex, ASMScript)); //Get index of last (most recently added) table int TableIndex = TableData.Count - 1; string[] AddInfo = new string[4]; //4 total parameters AddInfo[0] = TableData[TableIndex].Description; AddInfo[1] = Conversions.ToAddress((TableData[TableIndex].Address.ToString())); AddInfo[2] = Conversions.ScanTypeToName(TableData[TableIndex].ScanType); AddInfo[3] = "???"; TableListView.Items.Add("").SubItems.AddRange(AddInfo); ClearTableButton.Enabled = true; }
//Shared by First & Next scan private bool ScanButtonShared(bool IsRescan, UInt64 FirstAddress, UInt64 LastAddress) { //Object that holds data of variable type and amount we wish to scan for object ScanValue; object SecondScanValue; SelectedScanType = (ScanDataType)ScanDataTypeComboBox.SelectedIndex; #region Collect scan data from form and check for errors //Check to see if a process has been selected if (TargetProcess == null) { MessageBox.Show("Please select a process", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } if (!CheckSyntax.Value(ScanValueTextBox.Text, (ScanDataType)ScanDataTypeComboBox.SelectedIndex, IsHexCB.Checked) && ScanValueTextBox.Enabled == true || !CheckSyntax.Value(ScanSecondValueTextBox.Text, (ScanDataType)ScanDataTypeComboBox.SelectedIndex, IsHexCB.Checked) && ScanSecondValueTextBox.Visible == true) { MessageBox.Show("Invalid value format", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } if (ScanValueTextBox.Enabled == true) ScanValue = Conversions.ToUnsigned(ScanValueTextBox.Text, SelectedScanType); else ScanValue = null; // ScanValue = Conversions.ToUnsigned("0", ScanType); if (ScanSecondValueTextBox.Visible == true) SecondScanValue = Conversions.ToUnsigned(ScanSecondValueTextBox.Text, SelectedScanType); else SecondScanValue = null; //SecondScanValue = Conversions.ToUnsigned("0", ScanType); #endregion #region Prescan events //Figure out what Protect types to scan based on check states uint[] Protect = new uint[8]; int CheckedItems = ProtectionCheckedListBox.CheckedIndices.Count; for (int ecx = 0; ecx < CheckedItems; ecx++) Protect[ProtectionCheckedListBox.CheckedIndices[ecx]] = 1; uint[] Type = new uint[3]; CheckedItems = TypeCheckedListBox.CheckedIndices.Count; for (int ecx = 0; ecx < CheckedItems; ecx++) Type[TypeCheckedListBox.CheckedIndices[ecx]] = 1; ScanOptimizationData ScanOptimizationData = new ScanOptimizationData(OptimizeScanCB.Checked, (UInt64)OptimizeScanVal.Value, LastDigitsRB.Checked); bool CompareToFirstScan = false; if (IsRescan && CompareToFirstCB.Checked == true) CompareToFirstScan = true; //Create new instance of scanner and pass it all necessary info Scan = new ScanMemory(TargetProcess, FirstAddress, LastAddress, SelectedScanType, Conversions.StringToScanType(ScanCompareTypeComboBox.Items[ScanCompareTypeComboBox.SelectedIndex].ToString()), ScanValue, SecondScanValue, Protect, Type, TruncatedRB.Checked, ScanOptimizationData, ExecutablePath, CompareToFirstScan); Scan.ScanProgressChanged += new ScanMemory.ScanProgressedEventHandler(scan_ScanProgressChanged); Scan.ScanCompleted += new ScanMemory.ScanCompletedEventHandler(scan_ScanCompleted); Scan.ScanCanceled += new ScanMemory.ScanCanceledEventHandler(scan_ScanCanceled); AddressListView.VirtualListSize = 0; AddressListView.Items.Clear(); if (CurrentAddressAccessor != null) CurrentAddressAccessor.Dispose(); if (CurrentScanAddresses != null) CurrentScanAddresses.Dispose(); ProgressBar.Value = 0; #endregion #region Start scan ScanTimeStopwatch = Stopwatch.StartNew(); try { Scan.StartScan(IsRescan); } catch (Exception ex) { MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Warning); Scan.CancelScan(); return false; } return true; #endregion }
private Int64 _ScanValue; //Rounded value for singles/doubles for significant digit comparisons #endregion Fields #region Constructors //Constructor public ScanMemory(Process Process, UInt64 StartAddress, UInt64 EndAddress, ScanDataType ScanDataType, ScanCompareType ScanCompareType, object ScanValue, object SecondScanValue, uint[] Protect, uint[] Type, bool Truncated, ScanOptimizationData ScanOptimizationData, string ExecutablePath, bool CompareToFirstScan) { ProcessMemoryEditor = new ProcessMemoryEditor(); ProcessMemoryEditor.ReadProcess = Process; this.BaseAddress = (IntPtr)StartAddress; this.MaxAddress = (IntPtr)EndAddress; this.ScanDataType = ScanDataType; this.ScanCompareType = ScanCompareType; this.Protect = Protect; this.Type = Type; this.ScanValue = ScanValue; this.SecondScanValue = SecondScanValue; this.Truncated = Truncated; this.ScanOptimizationData = ScanOptimizationData; this.ExecutablePath = ExecutablePath; this.CompareToFirstScan = CompareToFirstScan; }