예제 #1
0
        /// <summary>
        /// Dump the memory
        /// </summary>
        /// <param name="filename">The file to save to</param>
        /// <param name="startDumpAddress">The start dump address</param>
        /// <param name="dumpLength">The dump length</param>
        public void Dump(string filename, uint startDumpAddress, uint dumpLength)
        {
            if (!Connect())
            {
                return;             //Call function - If not connected return
            }
            if (!GetMeMex(startDumpAddress, dumpLength))
            {
                return; //call function - If not connected or if something wrong return
            }
            var readWriter = new RwStream(filename);

            try
            {
                var data = new byte[1026]; //byte chuncks
                //Writing each byte chuncks========
                for (int i = 0; i < dumpLength / 1024; i++)
                {
                    _tcp.Client.Receive(data);
                    readWriter.WriteBytes(data, 2, 1024);
                    ReportProgress(0, (int)(dumpLength / 1024), (i + 1), "Dumping Memory...");
                }
                //Write whatever is left
                var extra = (int)(dumpLength % 1024);
                if (extra > 0)
                {
                    _tcp.Client.Receive(data);
                    readWriter.WriteBytes(data, 2, extra);
                }
                readWriter.Flush();
            }
            catch (SocketException)
            {
                readWriter.Flush();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                readWriter.Close(false);
                _tcp.Close(); //close connection
                _connected            = false;
                _memexValidConnection = false;
            }
        }
예제 #2
0
        /// <summary>
        /// Find pointer offset
        /// </summary>
        /// <param name="pointer"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public BindingList <SearchResults> FindHexOffset(string pointer)
        {
            _stopSearch = false;
            if (pointer == null)
            {
                throw new Exception("Empty Search string!");
            }
            if (!Functions.IsHex(pointer))
            {
                throw new Exception(string.Format("{0} is not a valid Hex string.", pointer));
            }
            if (!Connect())
            {
                return(null);            //Call function - If not connected return
            }
            if (!GetMeMex())
            {
                return(null);             //call function - If not connected or if something wrong return
            }
            BindingList <SearchResults> values;

            try
            {
                //LENGTH or Size = Length of the dump
                uint size = _startDumpLength;
                _readWriter = new RwStream();
                _readWriter.ReportProgress += ReportProgress;
                var data = new byte[1026]; //byte chuncks

                //Writing each byte chuncks========
                //No need to mess with it :D
                for (int i = 0; i < size / 1024; i++)
                {
                    if (_stopSearch)
                    {
                        return(new BindingList <SearchResults>());
                    }
                    _tcp.Client.Receive(data);
                    _readWriter.WriteBytes(data, 2, 1024);
                    ReportProgress(0, (int)(size / 1024), (i + 1), "Dumping Memory...");
                }
                //Write whatever is left
                var extra = (int)(size % 1024);
                if (extra > 0)
                {
                    if (_stopSearch)
                    {
                        return(new BindingList <SearchResults>());
                    }
                    _tcp.Client.Receive(data);
                    _readWriter.WriteBytes(data, 2, extra);
                }
                _readWriter.Flush();
                //===================================
                //===================================
                if (_stopSearch)
                {
                    return(new BindingList <SearchResults>());
                }
                _readWriter.Position = 0;
                values = _readWriter.SearchHexString(Functions.StringToByteArray(pointer),
                                                     _startDumpOffset);
                return(values);
            }
            catch (SocketException)
            {
                _readWriter.Flush();
                //===================================
                //===================================
                if (_stopSearch)
                {
                    return(new BindingList <SearchResults>());
                }
                _readWriter.Position = 0;
                values = _readWriter.SearchHexString(Functions.StringToByteArray(pointer),
                                                     _startDumpOffset);

                return(values);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                _readWriter.Close(true);
                _tcp.Close(); //close connection
                _connected            = false;
                _memexValidConnection = false;
                ReportProgress(0, 100, 0);
            }
        }
예제 #3
0
        /// <summary>Peek into the Memory</summary>
        /// <param name="startDumpAddress">The Hex offset to start dump Example:0xC0000000 </param>
        /// <param name="dumpLength">The Length or size of dump Example:0xFFFFFF </param>
        /// <param name="memoryAddress">The memory address to peek Example:0xC5352525 </param>
        /// <param name="peekSize">The byte size to peek Example: "0x4" or "4"</param>
        /// <returns>Return the hex string of the value</returns>
        private string Peek(uint startDumpAddress, uint dumpLength, uint memoryAddress, int peekSize)
        {
            uint total = (memoryAddress - startDumpAddress);

            if (memoryAddress > (startDumpAddress + dumpLength) || memoryAddress < startDumpAddress)
            {
                throw new Exception("Memory Address Out of Bounds");
            }

            if (!Connect())
            {
                return(null);            //Call function - If not connected return
            }
            if (!GetMeMex(startDumpAddress, dumpLength))
            {
                return(null); //call function - If not connected or if somethign wrong return
            }
            var readWriter = new RwStream();

            try
            {
                var data = new byte[1026]; //byte chuncks

                //Writing each byte chuncks========
                for (int i = 0; i < dumpLength / 1024; i++)
                {
                    _tcp.Client.Receive(data);
                    readWriter.WriteBytes(data, 2, 1024);
                    ReportProgress(0, (int)(dumpLength / 1024), (i + 1), "Dumping Memory...");
                }
                //Write whatever is left
                var extra = (int)(dumpLength % 1024);
                if (extra > 0)
                {
                    _tcp.Client.Receive(data);
                    readWriter.WriteBytes(data, 2, extra);
                }
                readWriter.Flush();
                readWriter.Position = total;
                byte[] value = readWriter.ReadBytes(peekSize);
                return(Functions.ToHexString(value));
            }
            catch (SocketException se)
            {
                readWriter.Flush();
                readWriter.Position = total;
                byte[] value = readWriter.ReadBytes(peekSize);
                throw new Exception(se.Message);
                return(Functions.ToHexString(value));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                readWriter.Close(true);
                _tcp.Close(); //close connection
                _connected            = false;
                _memexValidConnection = false;
            }
        }
예제 #4
0
        //Refresh results Thread
        private void RefreshResultList()
        {
            try
            {
                EnableControl(resultRefreshButton, false);
                var newSearchResults = new BindingList<SearchResults>();
                var limitSearchResults = new BindingList<SearchResults>();
                int value = 0;
                string retvalue = "";

                if (_searchResult.Count > 500)
                {
                    string results = _rtm.Peek(_tempOffset, _tempLength, _tempOffset, _tempLength);

                    _readWriter = new RwStream();
                    try
                    {
                        byte[] _buffer = Functions.HexToBytes(results);
                        _readWriter.WriteBytes(_buffer, 0, _buffer.Length);

                        _readWriter.Flush();
                        _readWriter.Position = 0;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }

                foreach (SearchResults item in _searchResult)
                {
                    UpdateProgressbar(0, _searchResult.Count, value, "Refreshing...");

                    string length = (item.Value.Length/2).ToString("X");
                    if (_searchResult.Count > 500)
                    {
                        //var retvalue = this._rtm.
                        uint pos = uint.Parse(item.Offset, NumberStyles.AllowHexSpecifier);
                        uint spos = uint.Parse(_tempOffset, NumberStyles.AllowHexSpecifier);
                        _readWriter.Position = (pos - spos);
                        byte[] _value = _readWriter.ReadBytes((item.Value.Length/2));
                        retvalue = Functions.ToHexString(_value);
                    }
                    else
                    {
                        retvalue = _rtm.Peek(item.Offset, length, item.Offset, length);
                    }

                    uint currentResults;
                    uint newResult;

                    if (!uint.TryParse(item.Value, out currentResults))
                        throw new Exception("Invalid Search Value this function only works for Unsigned Integers.");
                    uint.TryParse(retvalue, out newResult);

                    //===================================================
                    //Default
                    if (defaultRadioButton.Checked)
                    {
                        if (item.Value == retvalue) continue; //if value hasn't change continue for each loop
                        if (value < 1000)
                        {
                            GridRowColours(value);
                        }
                        item.Value = retvalue;
                    }
                    else if (ifEqualsRadioButton.Checked)
                    {
                        if (newResult == currentResults)
                        {
                            var searchResultItem = new SearchResults
                                                       {
                                                           ID = item.ID,
                                                           Offset = item.Offset,
                                                           Value = retvalue
                                                       };
                            newSearchResults.Add(searchResultItem);
                        }
                    }
                    else if (ifGreaterThanRadioButton.Checked)
                    {
                        if (newResult > currentResults)
                        {
                            var searchResultItem = new SearchResults
                                                       {
                                                           ID = item.ID,
                                                           Offset = item.Offset,
                                                           Value = retvalue
                                                       };
                            newSearchResults.Add(searchResultItem);
                        }
                    }
                    else if (ifLessThanRadioButton.Checked)
                    {
                        if (newResult < currentResults)
                        {
                            var searchResultItem = new SearchResults
                                                       {
                                                           ID = item.ID,
                                                           Offset = item.Offset,
                                                           Value = retvalue
                                                       };
                            newSearchResults.Add(searchResultItem);
                        }
                    }
                    else if (ifLessThanRadioButton.Checked)
                    {
                        if (newResult != currentResults)
                        {
                            var searchResultItem = new SearchResults
                                                       {
                                                           ID = item.ID,
                                                           Offset = item.Offset,
                                                           Value = retvalue
                                                       };
                            newSearchResults.Add(searchResultItem);
                        }
                    }
                    else if (ifChangeRadioButton.Checked)
                    {
                        if (item.Value != retvalue)
                        {
                            var searchResultItem = new SearchResults
                                                       {
                                                           ID = item.ID,
                                                           Offset = item.Offset,
                                                           Value = retvalue
                                                       };
                            newSearchResults.Add(searchResultItem);
                        }
                    }

                    value++;
                }
                if (defaultRadioButton.Checked)
                {
                    ResultGridUpdate();
                    ResultCountBoxUpdate();
                }
                else
                {
                    _searchResult = newSearchResults;
                    for (int i = 0; i < _searchResult.Count; i++)
                    {
                        if (i >= 1000)
                            break;

                        limitSearchResults.Add(_searchResult[i]);
                    }

                    _searchLimitedResult = limitSearchResults;
                    ResultGridUpdate();
                    ResultCountBoxUpdate();
                }
                UpdateProgressbar(0, 100, 0, "idle");
            }
            catch (Exception ex)
            {
                ShowMessageBox(ex.Message, string.Format("Peek Poker"), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                EnableControl(resultRefreshButton, true);
                UpdateProgressbar(0, 100, 0, "idle");
                Thread.CurrentThread.Abort();
            }
        }
예제 #5
0
        /// <summary>Peek into the Memory</summary>
        /// <param name="startDumpAddress">The Hex offset to start dump Example:0xC0000000 </param>
        /// <param name="dumpLength">The Length or size of dump Example:0xFFFFFF </param>
        /// <param name="memoryAddress">The memory address to peek Example:0xC5352525 </param>
        /// <param name="peekSize">The byte size to peek Example: "0x4" or "4"</param>
        /// <returns>Return the hex string of the value</returns>
        private string Peek(uint startDumpAddress, uint dumpLength, uint memoryAddress, int peekSize)
        {
            uint total = (memoryAddress - startDumpAddress);
            if (memoryAddress > (startDumpAddress + dumpLength) || memoryAddress < startDumpAddress)
                throw new Exception("Memory Address Out of Bounds");

            if (!Connect()) return null; //Call function - If not connected return
            if (!GetMeMex(startDumpAddress, dumpLength))
                return null; //call function - If not connected or if somethign wrong return

            var readWriter = new RwStream();
            try
            {
                var data = new byte[1026]; //byte chuncks

                //Writing each byte chuncks========
                for (int i = 0; i < dumpLength/1024; i++)
                {
                    _tcp.Client.Receive(data);
                    readWriter.WriteBytes(data, 2, 1024);
                    ReportProgress(0, (int) (dumpLength/1024), (i + 1), "Dumping Memory...");
                }
                //Write whatever is left
                var extra = (int) (dumpLength%1024);
                if (extra > 0)
                {
                    _tcp.Client.Receive(data);
                    readWriter.WriteBytes(data, 2, extra);
                }
                readWriter.Flush();
                readWriter.Position = total;
                byte[] value = readWriter.ReadBytes(peekSize);
                return Functions.ToHexString(value);
            }
            catch (SocketException se)
            {
                readWriter.Flush();
                readWriter.Position = total;
                byte[] value = readWriter.ReadBytes(peekSize);
                throw new Exception(se.Message);
                return Functions.ToHexString(value);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                readWriter.Close(true);
                _tcp.Close(); //close connection
                _connected = false;
                _memexValidConnection = false;
            }
        }
예제 #6
0
        /// <summary>
        /// Find pointer offset
        /// </summary>
        /// <param name="pointer"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public BindingList<SearchResults> FindHexOffset(string pointer)
        {
            _stopSearch = false;
            if (pointer == null)
                throw new Exception("Empty Search string!");
            if (!Functions.IsHex(pointer))
                throw new Exception(string.Format("{0} is not a valid Hex string.", pointer));
            if (!Connect()) return null; //Call function - If not connected return
            if (!GetMeMex()) return null; //call function - If not connected or if something wrong return
            BindingList<SearchResults> values;
            try
            {
                //LENGTH or Size = Length of the dump
                uint size = _startDumpLength;
                _readWriter = new RwStream();
                _readWriter.ReportProgress += ReportProgress;
                var data = new byte[1026]; //byte chuncks

                //Writing each byte chuncks========
                //No need to mess with it :D
                for (int i = 0; i < size/1024; i++)
                {
                    if (_stopSearch)
                        return new BindingList<SearchResults>();
                    _tcp.Client.Receive(data);
                    _readWriter.WriteBytes(data, 2, 1024);
                    ReportProgress(0, (int) (size/1024), (i + 1), "Dumping Memory...");
                }
                //Write whatever is left
                var extra = (int) (size%1024);
                if (extra > 0)
                {
                    if (_stopSearch)
                        return new BindingList<SearchResults>();
                    _tcp.Client.Receive(data);
                    _readWriter.WriteBytes(data, 2, extra);
                }
                _readWriter.Flush();
                //===================================
                //===================================
                if (_stopSearch)
                    return new BindingList<SearchResults>();
                _readWriter.Position = 0;
                values = _readWriter.SearchHexString(Functions.StringToByteArray(pointer),
                                                     _startDumpOffset);
                return values;
            }
            catch (SocketException)
            {
                _readWriter.Flush();
                //===================================
                //===================================
                if (_stopSearch)
                    return new BindingList<SearchResults>();
                _readWriter.Position = 0;
                values = _readWriter.SearchHexString(Functions.StringToByteArray(pointer),
                                                     _startDumpOffset);

                return values;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                _readWriter.Close(true);
                _tcp.Close(); //close connection
                _connected = false;
                _memexValidConnection = false;
                ReportProgress(0, 100, 0);
            }
        }
예제 #7
0
        /// <summary>
        /// Dump the memory
        /// </summary>
        /// <param name="filename">The file to save to</param>
        /// <param name="startDumpAddress">The start dump address</param>
        /// <param name="dumpLength">The dump length</param>
        public void Dump(string filename, uint startDumpAddress, uint dumpLength)
        {
            if (!Connect()) return; //Call function - If not connected return
            if (!GetMeMex(startDumpAddress, dumpLength))
                return; //call function - If not connected or if something wrong return

            var readWriter = new RwStream(filename);
            try
            {
                var data = new byte[1026]; //byte chuncks
                //Writing each byte chuncks========
                for (int i = 0; i < dumpLength/1024; i++)
                {
                    _tcp.Client.Receive(data);
                    readWriter.WriteBytes(data, 2, 1024);
                    ReportProgress(0, (int) (dumpLength/1024), (i + 1), "Dumping Memory...");
                }
                //Write whatever is left
                var extra = (int) (dumpLength%1024);
                if (extra > 0)
                {
                    _tcp.Client.Receive(data);
                    readWriter.WriteBytes(data, 2, extra);
                }
                readWriter.Flush();
            }
            catch (SocketException)
            {
                readWriter.Flush();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                readWriter.Close(false);
                _tcp.Close(); //close connection
                _connected = false;
                _memexValidConnection = false;
            }
        }