示例#1
0
        internal uint GetSearchMemorySize(DataTypeExact DataType)
        {
            switch (DataType)
            {
            case DataTypeExact.Bytes1:     //1 Byte
                return(1);

            case DataTypeExact.Bytes2:     //2 Bytes
                return(2);

            case DataTypeExact.Bytes4:     //4 Bytes
                return(4);

            case DataTypeExact.Bytes8:     //8 Bytes
                return(8);

            case DataTypeExact.Float:     //Float
                return((uint)BitConverter.GetBytes(float.MinValue).Length);

            case DataTypeExact.Double:     //Double
                return((uint)BitConverter.GetBytes(double.MinValue).Length);

            case DataTypeExact.Raw:     //Raw Bytes
                return((uint)Utilities.GetByteArrayFromByteString(SearchValue.Text).Length);

            default:     //Text
                return((uint)System.Text.Encoding.Default.GetBytes(SearchValue.Text).Length);
            }
        }
示例#2
0
        public string GetDisplayForByteArray(byte[] p, DataTypeExact DataType)
        {
            switch (DataType)
            {
            case DataTypeExact.Bytes1:     //1 Byte
                return(((uint)p[0]).ToString());

            case DataTypeExact.Bytes2:     //2 Bytes
                return(BitConverter.ToUInt16(p, 0).ToString());

            case DataTypeExact.Bytes4:     //4 Bytes
                return(BitConverter.ToUInt32(p, 0).ToString());

            case DataTypeExact.Bytes8:     //8 Bytes
                return(BitConverter.ToUInt64(p, 0).ToString());

            case DataTypeExact.Float:     //Float
                return(BitConverter.ToSingle(p, 0).ToString());

            case DataTypeExact.Double:     //Double
                return(BitConverter.ToDouble(p, 0).ToString());

            case DataTypeExact.Raw:     //Raw Bytes
                return(Utilities.GetStringFromByteArray(p));

            default:     //Text
                return(System.Text.Encoding.Default.GetString(p));
            }
        }
示例#3
0
        private byte[] GetByteArrayForDataType(DataTypeExact DataType, string Value)
        {
            switch (DataType)
            {
            case DataTypeExact.Bytes1:     //1 Byte
                return(new byte[] { (byte)uint.Parse(Value) });

            case DataTypeExact.Bytes2:     //2 Bytes
                return(BitConverter.GetBytes(ushort.Parse(Value)));

            case DataTypeExact.Bytes4:     //4 Bytes
                return(BitConverter.GetBytes(uint.Parse(Value)));

            case DataTypeExact.Bytes8:     //8 Bytes
                return(BitConverter.GetBytes(ulong.Parse(Value)));

            case DataTypeExact.Float:     //Float
                return(BitConverter.GetBytes(float.Parse(Value)));

            case DataTypeExact.Double:     //Double
                return(BitConverter.GetBytes(double.Parse(Value)));

            case DataTypeExact.Raw:     //Raw Bytes
                return(Utilities.GetByteArrayFromByteString(Value));

            case DataTypeExact.Text:     //Raw Bytes
            default:
                return(System.Text.Encoding.Default.GetBytes(Value));
            }
        }
示例#4
0
        internal void SetMemory(int RowIndex)
        {
            string        TextAddress = (string)ValuesGrid[1, RowIndex].Value;
            string        valString   = (string)ValuesGrid[3, RowIndex].Value;
            DataTypeExact type        = DataTypeExactTool.GetValue((string)ValuesGrid[4, RowIndex].Value);

            SetMemory(TextAddress, valString, type, RowIndex);
        }
 internal byte[] GetMemoryAtAddress(string ProcessID, uint Address, DataTypeExact DataType)
 {
     if (ProcessID.Contains("|"))
     {
         ProcessID = ProcessID.Substring(0, ProcessID.IndexOf('|'));
     }
     return(GetMemoryAtAddress(BitConverter.ToUInt32(Utilities.GetByteArrayFromByteString(ProcessID), 0), Address, DataType));
 }
示例#6
0
 public static string GetKey(DataTypeExact value)
 {
     foreach (string key in Mapping.Keys)
     {
         if (Mapping[key] == value)
         {
             return key;
         }
     }
     return null;
 }
示例#7
0
 public static string GetKey(DataTypeExact value)
 {
     foreach (string key in Mapping.Keys)
     {
         if (Mapping[key] == value)
         {
             return(key);
         }
     }
     return(null);
 }
示例#8
0
        internal byte[] GetMemoryAtAddress(uint ProcessID, uint Address, DataTypeExact DataType)
        {
            SearchCriteria Criteria = new SearchCriteria();

            Criteria.ProcessID    = ProcessID;
            Criteria.DataType     = DataType;
            Criteria.StartAddress = Address;
            Criteria.Length       = Criteria.Size = Form.GetSearchMemorySize(DataType);
            Criteria.SearchType   = SearchTypeBase.Unknown;
            Criteria.SearchValue  = new byte[] { 0 };
            Form.NTRConnection.SearchCriteria.Add(Criteria);
            Form.NTRConnection.SendReadMemoryPacket(Criteria);
            return(Criteria.AddressesFound.Values.First());
        }
示例#9
0
        private void btnAddSelected_Click(object sender, EventArgs e)
        {
            DataTypeExact addrType = DataTypeExactTool.GetValue(comboSelType.Text);

            if (addrType == DataTypeExact.INVALID)
            {
                return;
            }
            String addrStr            = selectedAddress.ToString("x2").PadLeft(8, '0');
            int    existingAddressIdx = ResultingCodes.FindIndex(c => c.address == addrStr);

            if (existingAddressIdx != -1)
            {
                ResultingCodes[existingAddressIdx] = new SaveCode(addrType, addrStr, txtSelTitle.Text);
            }
            else
            {
                ResultingCodes.Add(new SaveCode(DataTypeExactTool.GetValue(comboSelType.Text), addrStr, txtSelTitle.Text));
            }
            RefreshDataGrid();
        }
示例#10
0
 internal byte[] GetMemoryAtAddress(uint ProcessID, string Address, DataTypeExact DataType)
 {
     return(GetMemoryAtAddress(ProcessID, BitConverter.ToUInt32(Utilities.GetByteArrayFromByteString(Address).Reverse().ToArray(), 0), DataType));
 }
示例#11
0
 internal byte[] GetMemoryAtAddress(string ProcessID, uint Address, DataTypeExact DataType)
 {
     return(GetMemoryAtAddress(BitConverter.ToUInt32(Utilities.GetByteArrayFromByteString(ProcessID), 0), Address, DataType));
 }
 internal byte[] GetMemoryAtAddress(uint ProcessID, uint Address, DataTypeExact DataType)
 {
     SearchCriteria Criteria = new SearchCriteria();
     Criteria.ProcessID = ProcessID;
     Criteria.DataType = DataType;
     Criteria.StartAddress = Address;
     Criteria.Length = Criteria.Size = Form.GetSearchMemorySize(DataType);
     Criteria.SearchType = SearchTypeBase.Unknown;
     Criteria.SearchValue = new byte[] { 0 };
     Form.NTRConnection.SearchCriteria.Add(Criteria);
     Form.NTRConnection.SendReadMemoryPacket(Criteria);
     return Criteria.AddressesFound.Values.First();
 }
 internal byte[] GetMemoryAtAddress(string ProcessID, uint Address, DataTypeExact DataType)
 {
     return GetMemoryAtAddress(BitConverter.ToUInt32(Utilities.GetByteArrayFromByteString(ProcessID), 0), Address, DataType);
 }
 internal byte[] GetMemoryAtAddress(uint ProcessID, string Address, DataTypeExact DataType)
 {
     return GetMemoryAtAddress(ProcessID, BitConverter.ToUInt32(Utilities.GetByteArrayFromByteString(Address).Reverse().ToArray(), 0), DataType);
 }
示例#15
0
 public SaveCode(DataTypeExact type, String address, String title)
 {
     this.type    = type;
     this.address = address;
     this.title   = title;
 }
示例#16
0
 public SaveCode(DataTypeExact type, String address)
 {
     this.type = type;
     this.address = address;
 }
示例#17
0
 public SaveCode()
 {
     type = DataTypeExact.Raw;
     address = null;
 }
示例#18
0
 public SaveCode()
 {
     type    = DataTypeExact.Raw;
     address = null;
 }
示例#19
0
 internal uint GetSearchMemorySize(DataTypeExact DataType)
 {
     switch (DataType)
     {
         case DataTypeExact.Bytes1: //1 Byte
             return 1;
         case DataTypeExact.Bytes2: //2 Bytes
             return 2;
         case DataTypeExact.Bytes4: //4 Bytes
             return 4;
         case DataTypeExact.Bytes8: //8 Bytes
             return 8;
         case DataTypeExact.Float: //Float
             return (uint)BitConverter.GetBytes(float.MinValue).Length;
         case DataTypeExact.Double: //Double
             return (uint)BitConverter.GetBytes(double.MinValue).Length;
         case DataTypeExact.Raw: //Raw Bytes
             return (uint)Utilities.GetByteArrayFromByteString(SearchValue.Text).Length;
         default: //Text
             return (uint)System.Text.Encoding.Default.GetBytes(SearchValue.Text).Length;
     }
 }
示例#20
0
 public string GetDisplayForByteArray(byte[] p, DataTypeExact DataType)
 {
     switch (DataType)
     {
         case DataTypeExact.Bytes1: //1 Byte
             return ((uint)p[0]).ToString();
         case DataTypeExact.Bytes2: //2 Bytes
             return BitConverter.ToUInt16(p, 0).ToString();
         case DataTypeExact.Bytes4: //4 Bytes
             return BitConverter.ToUInt32(p, 0).ToString();
         case DataTypeExact.Bytes8: //8 Bytes
             return BitConverter.ToUInt64(p, 0).ToString();
         case DataTypeExact.Float: //Float
             return BitConverter.ToSingle(p, 0).ToString();
         case DataTypeExact.Double: //Double
             return BitConverter.ToDouble(p, 0).ToString();
         case DataTypeExact.Raw: //Raw Bytes
             return Utilities.GetStringFromByteArray(p);
         default: //Text
             return System.Text.Encoding.Default.GetString(p);
     }
 }
示例#21
0
        internal void SetMemory(string address, string value, DataTypeExact type, int RowIndex = -1)
        {
            MemoryDispatch MemoryDispatch = new MemoryDispatch();

            MemoryDispatch.Row         = RowIndex;
            MemoryDispatch.TextAddress = address;
            MemoryDispatch.Type        = type;
            if (MemoryDispatch.Type == DataTypeExact.INVALID)
            {
                return;
            }
            //check value for type range
            bool inputInvalidOrOutOfRange;

            switch (MemoryDispatch.Type)
            {
            case DataTypeExact.Bytes1:
                try
                {
                    byte.Parse(value);
                    inputInvalidOrOutOfRange = false;
                }
                catch
                {
                    inputInvalidOrOutOfRange = true;
                }
                break;

            case DataTypeExact.Bytes2:
                try
                {
                    UInt16.Parse(value);
                    inputInvalidOrOutOfRange = false;
                }
                catch
                {
                    inputInvalidOrOutOfRange = true;
                }
                break;

            case DataTypeExact.Bytes4:
                try
                {
                    UInt32.Parse(value);
                    inputInvalidOrOutOfRange = false;
                }
                catch
                {
                    inputInvalidOrOutOfRange = true;
                }
                break;

            case DataTypeExact.Bytes8:
                try
                {
                    UInt64.Parse(value);
                    inputInvalidOrOutOfRange = false;
                }
                catch
                {
                    inputInvalidOrOutOfRange = true;
                }

                break;

            case DataTypeExact.Float:
                try
                {
                    float.Parse(value);
                    inputInvalidOrOutOfRange = false;
                }
                catch
                {
                    inputInvalidOrOutOfRange = true;
                }

                break;

            case DataTypeExact.Double:
                try
                {
                    double.Parse(value);
                    inputInvalidOrOutOfRange = false;
                }
                catch
                {
                    inputInvalidOrOutOfRange = true;
                }

                break;

            default:
                inputInvalidOrOutOfRange = false;
                break;
            }
            if (!inputInvalidOrOutOfRange)
            {
                MemoryDispatch.Value = GetByteArrayForDataType(MemoryDispatch.Type, value);
                ThreadEventDispatcher.WriteAddress.Enqueue(MemoryDispatch);

                if (RowIndex >= 0)
                {
                    ValuesGrid[4, RowIndex].ErrorText       = "";
                    ValuesGrid[4, RowIndex].Style.BackColor = System.Drawing.Color.Transparent;
                }
            }
            else
            {
                if (RowIndex >= 0)
                {
                    ValuesGrid[4, RowIndex].ErrorText       = "Value is out of range";
                    ValuesGrid[4, RowIndex].Style.BackColor = System.Drawing.Color.Red;
                }
            }
        }
示例#22
0
 public SaveCode(DataTypeExact type, String address)
 {
     this.type    = type;
     this.address = address;
 }
 private byte[] GetValueForDataType(DataTypeExact CurrentSelectedDataType, string Value)
 {
     switch (CurrentSelectedDataType)
     {
         case DataTypeExact.Bytes1: //1 Byte
             return new byte[] { (byte)uint.Parse(Value) };
         case DataTypeExact.Bytes2: //2 Bytes
             return BitConverter.GetBytes(ushort.Parse(Value));
         case DataTypeExact.Bytes4: //4 Bytes
             return BitConverter.GetBytes(uint.Parse(Value));
         case DataTypeExact.Bytes8: //8 Bytes
             return BitConverter.GetBytes(ulong.Parse(Value));
         case DataTypeExact.Float: //Float
             return BitConverter.GetBytes(float.Parse(Value));
         case DataTypeExact.Double: //Double
             return BitConverter.GetBytes(double.Parse(Value));
         case DataTypeExact.Raw: //Raw Bytes
             return Utilities.GetByteArrayFromByteString(Value);
         default: //Text
             return System.Text.Encoding.Default.GetBytes(Value);
     }
 }