Example #1
0
        public void DisplayBytes(IntPtr address, int byteCount)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            if (byteCount < 1 || byteCount > 255)
            {
                throw new ArgumentOutOfRangeException("byteCount");
            }

            // Update Parameters
            Address   = address;
            ByteCount = byteCount;

            // Reset Memory States Slider
            trackBarMemoryStates.Value    = 0;
            trackBarMemoryStates.Minimum  = 0;
            trackBarMemoryStates.Maximum  = 0;
            trackBarMemoryStates.Enabled  = false;
            trackBarMemoryStatesLastValue = trackBarMemoryStates.Value;

            // Update offset labels
            for (int i = 0; i < 16; i++)
            {
                offsetLabels[i].Text = (address.ToInt32() + (i * 16)).ToString("X");
            }

            // Reset tags
            for (int r = 0; r < 16; r++)
            {
                for (int c = 0; c < 16; c++)
                {
                    byteLabels[c, r].Tag = 0;
                }
            }

            // Setup Memory States
            MemoryStates.Clear();
            ReadTimes.Clear();
            LiveView = true;

            // Reset HoveredLabel
            if (hoveredLabel != null)
            {
                hoveredLabel.BackColor = SystemColors.Control;
            }
            labelHoverInfo.Text = "XX [0x00000000]";

            // Display
            UpdateBytes();
        }
Example #2
0
        public void UpdateBytes(bool skipRead = false)
        {
            if (skipRead == false)
            {
                try {
                    MemoryStates.Add(ProcessMemory.Read((int)Address, ByteCount));
                    ReadTimes.Add(DateTime.Now);
                }
                catch { throw; }
            }

            if (trackBarMemoryStates.Maximum != MemoryStates.Count - 1)
            {
                trackBarMemoryStates.Maximum = MemoryStates.Count - 1;
            }
            if (!trackBarMemoryStates.Enabled)
            {
                trackBarMemoryStates.Enabled = true;
            }

            if (LiveView)
            {
                trackBarMemoryStates.Value    = trackBarMemoryStates.Maximum;
                trackBarMemoryStatesLastValue = trackBarMemoryStates.Value;
            }

            // Update info label with base address and number of bytes read
            labelMemoryStateInfo.Text = $"[{trackBarMemoryStates.Value}]{ReadTimes[trackBarMemoryStates.Value].ToString("mm:ss:fff")} - 0x{((int)Address).ToString("X8")} [{ByteCount}]";

            int b = 0; string byteString; byte currentByte, originalByte;

            for (int r = 0; r < 16; r++)
            {
                for (int c = 0; c < 16; c++, b++)
                {
                    if (b < ByteCount)
                    {
                        originalByte = MemoryStates[0][b];
                        currentByte  = MemoryStates[trackBarMemoryStates.Value][b];


                        byteString = currentByte.ToString("X2");

                        toolTip.SetToolTip(byteLabels[c, r], GenerateTooltip(b));

                        // Byte same
                        if (currentByte == originalByte)
                        {
                            if ((int)byteLabels[c, r].Tag == 1)
                            {
                                // Bytes that have changed but now match their original value are green
                                byteLabels[c, r].ForeColor = Color.DarkGreen;
                            }
                            else
                            {
                                // Bytes that have maintained their original value stay black
                                byteLabels[c, r].ForeColor = SystemColors.ControlText;
                            }
                        }
                        // Byte changed
                        else
                        {
                            byteLabels[c, r].ForeColor = Color.Red;
                            // Denotes label value has changed at some point
                            byteLabels[c, r].Tag = 1;
                        }

                        byteLabels[c, r].Text = byteString;
                    }
                    else
                    {
                        toolTip.SetToolTip(byteLabels[c, r], "");
                        byteLabels[c, r].ForeColor = SystemColors.ControlText;
                        byteLabels[c, r].Text      = "XX";
                    }
                }
            }
        }