예제 #1
0
        private static void setZAxis(float zAxisDiff)
        {
            ProcessMemoryReaderLib.ProcessMemoryReader pReader = GetAoCProcess();
            pReader.OpenProcess();

            int writtenBytes, readBytes;

            byte[] axisBuffer = pReader.ReadProcessMemory((IntPtr)((int)playerDMA + zAxisOffset), 4, out readBytes);
            float  zAxis      = BitConverter.ToSingle(axisBuffer, 0);

            byte[] buffer = BitConverter.GetBytes(zAxis + zAxisDiff);
            pReader.WriteProcessMemory((IntPtr)((int)playerDMA + zAxisOffset), buffer, out writtenBytes);
            pReader.CloseHandle();
        }
예제 #2
0
        private static float getRunspeed()
        {
            playerDMA = GetDMA();
            ProcessMemoryReaderLib.ProcessMemoryReader pReader = GetAoCProcess();
            pReader.OpenProcess();

            int readBytes;

            byte[] buffer;

            buffer = pReader.ReadProcessMemory((IntPtr)((int)playerDMA + runspeedOffset), 4, out readBytes);
            pReader.CloseHandle();
            return(BitConverter.ToSingle(buffer, 0));
        }
예제 #3
0
        private static IntPtr GetDMA()
        {
            ProcessMemoryReaderLib.ProcessMemoryReader pReader = GetAoCProcess();
            pReader.OpenProcess();

            int readBytes;

            byte[] buffer;

            // Get the memory location pointed to by the static address
            buffer = pReader.ReadProcessMemory(StaticAddress, 4, out readBytes);
            IntPtr DMAAddress = (IntPtr)(
                buffer[0] +
                256 * buffer[1] +
                256 * 256 * buffer[2] +
                256 * 256 * 256 * buffer[3]);

            pReader.CloseHandle();
            return(DMAAddress);
        }
예제 #4
0
        private void btnRead_Click(object sender, System.EventArgs e)
        {
            int iWidthAddress;
            int iHeightAddress;
            int iMinesAddress;
            int iCellBaseAddress;

            // check if version is win2k or winXP
            if (Environment.OSVersion.Version.Major == 5)
            {
                if (Environment.OSVersion.Version.Minor == 0)                   // win2K
                {
                    // Thanks goes to Ryan Schreiber for discovering these addresses.
                    iWidthAddress    = 0x10056f8;
                    iHeightAddress   = 0x1005a68;
                    iMinesAddress    = 0x1005a6c;
                    iCellBaseAddress = 0x1005700;
                }
                else                    // winXP
                {
                    iWidthAddress    = 0x1005334;
                    iHeightAddress   = 0x1005338;
                    iMinesAddress    = 0x1005330;
                    iCellBaseAddress = 0x1005340;
                }
            }
            else
            {
                MessageBox.Show("Sorry, only winXP and win2K are supported!");
                return;
            }

            System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));

            ProcessMemoryReaderLib.ProcessMemoryReader pReader = new ProcessMemoryReaderLib.ProcessMemoryReader();

            System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcessesByName("winmine");

            // take first instance of minesweeper you find
            if (myProcesses.Length == 0)
            {
                MessageBox.Show("No MineSweeper process found!");
                return;
            }
            pReader.ReadProcess = myProcesses[0];

            // open process in read memory mode
            pReader.OpenProcess();

            int bytesReaded;
            int iWidth, iHeight, iMines;
            int iIsMine;
            int iCellAddress;

            byte[] memory;

            memory        = pReader.ReadProcessMemory((IntPtr)iWidthAddress, 1, out bytesReaded);
            iWidth        = memory[0];
            txtWidth.Text = iWidth.ToString();

            memory         = pReader.ReadProcessMemory((IntPtr)iHeightAddress, 1, out bytesReaded);
            iHeight        = memory[0];
            txtHeight.Text = iHeight.ToString();

            memory        = pReader.ReadProcessMemory((IntPtr)iMinesAddress, 1, out bytesReaded);
            iMines        = memory[0];
            txtMines.Text = iMines.ToString();

            this.Controls.Clear();
            this.Controls.AddRange(MainControls);
            ButtonArray = new System.Windows.Forms.Button[iWidth, iHeight];
            int x, y;

            for (y = 0; y < iHeight; y++)
            {
                for (x = 0; x < iWidth; x++)
                {
                    ButtonArray[x, y]          = new System.Windows.Forms.Button();
                    ButtonArray[x, y].Location = new System.Drawing.Point(20 + x * 16, 70 + y * 16);
                    ButtonArray[x, y].Name     = "";
                    ButtonArray[x, y].Size     = new System.Drawing.Size(16, 16);

                    iCellAddress = (iCellBaseAddress) + (32 * (y + 1)) + (x + 1);
                    memory       = pReader.ReadProcessMemory((IntPtr)iCellAddress, 1, out bytesReaded);
                    iIsMine      = memory[0];

                    if (iIsMine == 0x8f)
                    {
                        ButtonArray[x, y].Image = ((System.Drawing.Bitmap)(resources.GetObject("button1.Image")));
                    }

                    this.Controls.Add(ButtonArray[x, y]);
                }
            }

            // close process handle
            pReader.CloseHandle();
        }