Click here to Skip to main content
13,299,727 members (60,687 online)
Click here to Skip to main content
Articles » Languages » C# » Memory Management » Downloads

Stats

265K views
13.9K downloads
157 bookmarked
Posted 23 Sep 2006

How to write a Memory Scanner using C#

, 23 Sep 2006
Search a process' memory to find specified 16, 32 or 64 bit data values.
namespace MemoryScanner
{
    partial class WholeMemoryScan
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WholeMemoryScan));
            this.listBox = new System.Windows.Forms.ListBox();
            this.startAddress = new System.Windows.Forms.TextBox();
            this.endAddress = new System.Windows.Forms.TextBox();
            this.valueTextBox = new System.Windows.Forms.TextBox();
            this.comboBox = new System.Windows.Forms.ComboBox();
            this.startScan = new System.Windows.Forms.Button();
            this.stopScan = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.nextButton = new System.Windows.Forms.Button();
            this.closeButton = new System.Windows.Forms.Button();
            this.progressBar = new System.Windows.Forms.ProgressBar();
            this.SuspendLayout();
            // 
            // listBox
            // 
            this.listBox.FormattingEnabled = true;
            this.listBox.ItemHeight = 15;
            this.listBox.Location = new System.Drawing.Point(241, 106);
            this.listBox.Name = "listBox";
            this.listBox.SelectionMode = System.Windows.Forms.SelectionMode.None;
            this.listBox.Size = new System.Drawing.Size(339, 214);
            this.listBox.TabIndex = 6;
            // 
            // startAddress
            // 
            this.startAddress.Location = new System.Drawing.Point(291, 13);
            this.startAddress.MaxLength = 8;
            this.startAddress.Name = "startAddress";
            this.startAddress.Size = new System.Drawing.Size(114, 23);
            this.startAddress.TabIndex = 7;
            this.startAddress.Text = "00000000";
            // 
            // endAddress
            // 
            this.endAddress.Location = new System.Drawing.Point(291, 42);
            this.endAddress.MaxLength = 8;
            this.endAddress.Name = "endAddress";
            this.endAddress.Size = new System.Drawing.Size(114, 23);
            this.endAddress.TabIndex = 8;
            this.endAddress.Text = "7FFFFFFF";
            // 
            // valueTextBox
            // 
            this.valueTextBox.Location = new System.Drawing.Point(291, 71);
            this.valueTextBox.Name = "valueTextBox";
            this.valueTextBox.Size = new System.Drawing.Size(114, 23);
            this.valueTextBox.TabIndex = 9;
            // 
            // comboBox
            // 
            this.comboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.comboBox.FormattingEnabled = true;
            this.comboBox.Items.AddRange(new object[] {
            "Int 16",
            "Int 32",
            "Int 64"});
            this.comboBox.Location = new System.Drawing.Point(476, 71);
            this.comboBox.Name = "comboBox";
            this.comboBox.Size = new System.Drawing.Size(73, 23);
            this.comboBox.TabIndex = 10;
            // 
            // startScan
            // 
            this.startScan.BackColor = System.Drawing.Color.SteelBlue;
            this.startScan.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.startScan.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.startScan.ForeColor = System.Drawing.Color.White;
            this.startScan.Location = new System.Drawing.Point(411, 14);
            this.startScan.Name = "startScan";
            this.startScan.Size = new System.Drawing.Size(138, 23);
            this.startScan.TabIndex = 11;
            this.startScan.Text = "Start Scan";
            this.startScan.UseVisualStyleBackColor = false;
            this.startScan.Click += new System.EventHandler(this.startScan_Click);
            // 
            // stopScan
            // 
            this.stopScan.BackColor = System.Drawing.Color.SteelBlue;
            this.stopScan.Enabled = false;
            this.stopScan.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.stopScan.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.stopScan.ForeColor = System.Drawing.Color.White;
            this.stopScan.Location = new System.Drawing.Point(411, 43);
            this.stopScan.Name = "stopScan";
            this.stopScan.Size = new System.Drawing.Size(138, 23);
            this.stopScan.TabIndex = 12;
            this.stopScan.Text = "Abort Scan";
            this.stopScan.UseVisualStyleBackColor = false;
            this.stopScan.Click += new System.EventHandler(this.stopScan_Click);
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.BackColor = System.Drawing.Color.Transparent;
            this.label1.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.ForeColor = System.Drawing.Color.White;
            this.label1.Location = new System.Drawing.Point(244, 16);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(49, 15);
            this.label1.TabIndex = 13;
            this.label1.Text = "Start: 0x";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.BackColor = System.Drawing.Color.Transparent;
            this.label2.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.ForeColor = System.Drawing.Color.White;
            this.label2.Location = new System.Drawing.Point(244, 45);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(48, 15);
            this.label2.TabIndex = 14;
            this.label2.Text = "End:  0x";
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.BackColor = System.Drawing.Color.Transparent;
            this.label3.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label3.ForeColor = System.Drawing.Color.White;
            this.label3.Location = new System.Drawing.Point(244, 74);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(39, 15);
            this.label3.TabIndex = 15;
            this.label3.Text = "Value:";
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.BackColor = System.Drawing.Color.Transparent;
            this.label4.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label4.ForeColor = System.Drawing.Color.White;
            this.label4.Location = new System.Drawing.Point(411, 74);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(62, 15);
            this.label4.TabIndex = 16;
            this.label4.Text = "Data Type:";
            // 
            // nextButton
            // 
            this.nextButton.BackColor = System.Drawing.Color.LightSteelBlue;
            this.nextButton.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.nextButton.Enabled = false;
            this.nextButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.nextButton.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.nextButton.ForeColor = System.Drawing.Color.White;
            this.nextButton.Image = global::MemoryScanner.Properties.Resources.NextButton;
            this.nextButton.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.nextButton.Location = new System.Drawing.Point(520, 329);
            this.nextButton.Name = "nextButton";
            this.nextButton.Size = new System.Drawing.Size(60, 25);
            this.nextButton.TabIndex = 4;
            this.nextButton.Text = "Next";
            this.nextButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.nextButton.UseVisualStyleBackColor = false;
            this.nextButton.Click += new System.EventHandler(this.nextButton_Click);
            // 
            // closeButton
            // 
            this.closeButton.BackColor = System.Drawing.Color.SteelBlue;
            this.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.closeButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.closeButton.ForeColor = System.Drawing.Color.White;
            this.closeButton.Image = global::MemoryScanner.Properties.Resources.CloseButton;
            this.closeButton.Location = new System.Drawing.Point(555, 12);
            this.closeButton.Name = "closeButton";
            this.closeButton.Size = new System.Drawing.Size(25, 25);
            this.closeButton.TabIndex = 5;
            this.closeButton.UseVisualStyleBackColor = false;
            this.closeButton.Click += new System.EventHandler(this.closeButton_Click);
            // 
            // progressBar
            // 
            this.progressBar.BackColor = System.Drawing.Color.LightSteelBlue;
            this.progressBar.ForeColor = System.Drawing.Color.SteelBlue;
            this.progressBar.Location = new System.Drawing.Point(241, 329);
            this.progressBar.Name = "progressBar";
            this.progressBar.Size = new System.Drawing.Size(273, 25);
            this.progressBar.Step = 1;
            this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
            this.progressBar.TabIndex = 17;
            // 
            // WholeMemoryScan
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 15F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(592, 366);
            this.Controls.Add(this.progressBar);
            this.Controls.Add(this.endAddress);
            this.Controls.Add(this.startAddress);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.stopScan);
            this.Controls.Add(this.startScan);
            this.Controls.Add(this.comboBox);
            this.Controls.Add(this.valueTextBox);
            this.Controls.Add(this.listBox);
            this.Controls.Add(this.nextButton);
            this.Controls.Add(this.closeButton);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "WholeMemoryScan";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Sojaner Memory Scanner";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Button nextButton;
        private System.Windows.Forms.Button closeButton;
        private System.Windows.Forms.ListBox listBox;
        private System.Windows.Forms.TextBox startAddress;
        private System.Windows.Forms.TextBox endAddress;
        private System.Windows.Forms.TextBox valueTextBox;
        private System.Windows.Forms.ComboBox comboBox;
        private System.Windows.Forms.Button startScan;
        private System.Windows.Forms.Button stopScan;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.ProgressBar progressBar;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Rojan Gh.
Founder Sojaner AB
Sweden Sweden
UX designer and full stack developer mainly focused on .NET technologies.
Currently loving .NET Core 2.0.

You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171207.1 | Last Updated 23 Sep 2006
Article Copyright 2006 by Rojan Gh.
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid