Click here to Skip to main content
13,147,540 members (32,597 online)
Click here to Skip to main content
Articles » Languages » C# » Memory Management » Downloads

Stats

259.2K views
13.7K 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.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MemoryScanner
{
    public partial class FreezeValues : Form
    {
        public FreezeValues(int Address, int Type, object CurrentValue)
        {
            InitializeComponent();
            address = Address;
            type = Type;
            currentValue = CurrentValue;
        }
        int address;

        int type;

        object currentValue;

        object newValue;

        public object NewValue
        {
            get { return newValue; }
        }
        
        public int Type
        {
            set { type = value; }
        }

        private void acceptButton_Click(object sender, EventArgs e)
        {
            try
            {
                switch (type)
                {
                    case 0:
                        newValue = Int16.Parse(newValueTextBox.Text);
                        break;
                    case 1:
                        newValue = Int32.Parse(newValueTextBox.Text);
                        break;
                    case 2:
                        newValue = Int64.Parse(newValueTextBox.Text);
                        break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        private void FreezeValues_Load(object sender, EventArgs e)
        {
            addressLabel.Text = "0x" + Convert.ToString(address, 16).ToUpper();

            valueLabel.Text = currentValue.ToString();
        }
    }
}

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
Web04 | 2.8.170915.1 | Last Updated 23 Sep 2006
Article Copyright 2006 by Rojan Gh.
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid