그림판뷰어소스
비공개 (손님)
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;
        }
    }
} 3.238.250.73 |

정보 | 336명이 읽었어요. 3.238.250.73 | | 10

레어·유머·자작 실시간 인기글
1 나라팔아먹은 이완용 후손들의 상황 03-24
2 주 69시간... 야근, 야근, 야근, 야근, 야근, 병원, 기절 12시간 전
3 9년전 헤어진 여친이 몰래 혼인신고…애까지 떠안을 판 18시간 전
4 AV처자가 거르는 남배우 10시간 전
댓글 0
메뉴 목록 맨위로 로그인
TE31.COM ⓒ 2002-2023
서버 부하 13.5%