±×¸²ÆǺä¾î¼Ò½º
ºñ°ø°³
(¼Õ´Ô)
2023.01.12 02:43:00
±×¸²ÆÇ ºä¾î ¼Ò½º
ÄÚµå´Â °³ÆÇÀÌ´Ï ¿åÇÏÁö ¸»±Í
µ¹¾Æ¸¸ °¨

using System.Diagnostics;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;

namespace mspaintcap
{
    public partial class Form1 : Form
    {
        Process[] p;
        public uint DELETE = 0x00010000;
        public uint READ_CONTROL = 0x00020000;
        public uint WRITE_DAC = 0x00040000;
        public uint WRITE_OWNER = 0x00080000;
        public uint SYNCHRONIZE = 0x00100000;
        public uint END = 0xFFF;

        [DllImport("kernel32.dll")]
        public static extern int OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);

        [DllImport("kernel32.dll")]
        public static extern bool ReadProcessMemory(int hProcess, UInt64 lpBaseAddress, byte[] buffer, int size, int lpNumberOfBytesRead);

        public Form1()
        {
            InitializeComponent();
        }

        int processHandle = 0;

        string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");


        private void Form1_Load(object sender, EventArgs e)
        {
            Directory.CreateDirectory(dtstr);
            Directory.SetCurrentDirectory(dtstr);

            try
            {
                p = Process.GetProcessesByName("mspaint");
            }
            catch { textBoxADDR.Text = "error"; }
            processHandle = OpenProcess((DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER | SYNCHRONIZE | END), false, p[0].Id);
        }

        private void buttonFind_Click(object sender, EventArgs e)
        {
            CAP();

        }

        private void CAP()
        {
            int cpp = 3;
            if (checkBox32bpp.Checked) cpp = 4;
            if (processHandle == 0) return;
            labelHANDLE.Text = processHandle.ToString();
            int w = 300;
            int h = 300;
            UInt64 addr = UInt64.Parse(textBoxADDR.Text, System.Globalization.NumberStyles.HexNumber);
            if (int.TryParse(textBoxW.Text, out w) == false) return;
            if(int.TryParse(textBoxH.Text, out h) == false) return; // int rrrr = w * h;
            byte [] ImageBytes = ReadMemory(addr, w * h * cpp, processHandle);
            if (checkBox32bpp.Checked) for (int ii = 0; ii < w * h * cpp; ii += 4) ImageBytes[ii + 3] = 255;
            Bitmap output = new Bitmap(w, h, cpp == 4 ? PixelFormat.Format32bppArgb : PixelFormat.Format24bppRgb);
            Rectangle rect = new Rectangle(0, 0, output.Width, output.Height);
            BitmapData bmpData = output.LockBits(rect, ImageLockMode.ReadWrite, output.PixelFormat);
            IntPtr ptr = bmpData.Scan0;
            for(int pos = 0; pos < ImageBytes.Length; pos += w * cpp)
            Marshal.Copy(ImageBytes, pos, ptr + ImageBytes.Length - pos - w * cpp, w * cpp);

            output.UnlockBits(bmpData);
            pictureBox1.Image = output;
            pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
            pictureBox1.Refresh();
            output.Save(labelCount.Text, ImageFormat.Png);
        }

        public static byte[] ReadMemory(UInt64 adress, int processSize, int processHandle)
        {
            byte[] buffer = new byte[processSize];
            ReadProcessMemory(processHandle, adress, buffer, processSize, 0);
            return buffer;
        }

        int count = 0;

        private void timer1_Tick(object sender, EventArgs e)
        {
            labelCount.Text = count.ToString("D5") + ".png";
            CAP();
            ++count;
        }

        private void buttonstalt_Click(object sender, EventArgs e)
        {
            textBoxTimer.ReadOnly = true;
            buttonstalt.Hide();
            int interval = 30;
            int.TryParse(textBoxTimer.Text, out interval);
            timer1.Interval = interval * 1000;
            timer1.Enabled = true;
        }
    }
} 18.223.196.211 |

Á¤º¸ | 1,413¸íÀÌ Àоú¾î¿ä. 18.223.196.211 | | 10

·¹¾î¡¤À¯¸Ó¡¤ÀÚÀÛ Àαâ±Û
1 ÀÌ»¡»çÀÌ¿¡ À½½Ä ²¼À»¶§ 13½Ã°£ Àü
2 [¼¼¿ùÈ£ Âü»ç 10ÁÖ±â ƯÁý] ¼¼ °¡Áö ¾ÈºÎ ¨é ¡´µå¶ó... 17½Ã°£ Àü
´ñ±Û 0°³
¸Þ´º ¸ñ·Ï ¸ÇÀ§·Î ·Î±×ÀÎ
TE31.COM ¨Ï 2002-2024
¼­¹ö ºÎÇÏ 15.25%