ÇÁ·Î±×·¡¹Ö
ù ÆäÀÌÁö ·£´ý ±Û ȸ¿ø°¡ÀÔ ·Î±×ÀÎ
ºñ°ø°³ ¼Õ´Ô ¡¦ 2023-01-12 02:43:00
URL https://te31.com/rgr/view.php?id=study&no=3097 ¸ð¹ÙÀÏ È­¸é
±×¸²ÆÇ ºä¾î ¼Ò½º

ÄÚµå´Â °³ÆÇÀÌ´Ï ¿åÇÏÁö ¸»±Í
µ¹¾Æ¸¸ °¨

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 buttonStart_Click(object sender, EventArgs e)
        {
            textBoxTimer.ReadOnly = true;
            buttonStart.Hide();
            int interval = 30;
            int.TryParse(textBoxTimer.Text, out interval);
            timer1.Interval = interval * 1000;
            timer1.Enabled = true;
        }
    }
}

Á¤º¸ | 1436¸íÀÌ Àоú¾î¿ä. 3.137.164.241

0
´ñ±ÛÀ» ÀÛ¼ºÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.
(±ÇÇÑÀÌ ¾ø´Â ȸ¿ø·¹º§)
¸ñ·ÏÀ¸·Î
¡â ÀÌÀü±Û: (¹é¿£µå) ÀÌ·²¶§ DB Å×ÀÌºí ¼³°è ¾î¶»°Ô ÇϽóª¿ä ? [4]
¡ä ´ÙÀ½±Û: ±×¸²ÆÇ Àüüº¸±â ±â´É ¼º°ø? [7]
ÀÌ¿ë¾à°ü | ±¤°í/Á¦ÈÞ | °³ÀÎÁ¤º¸Ãë±Þ¹æħ | ¹®ÀÇ/½Å°í | ¸ð¹ÙÀÏ TE31 | ¼­¹ö ºÎÇÏ : 33.75%
½Ç½Ã°£ Issue Ä¿¹Â´ÏƼ TE31 [¾ËÁö·Õ] ¨Ï 2002-2024
TOP arrow_upward