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

정보 | 973명이 읽었어요. 35.175.107.142 | | 10

레어·유머·자작 인기글
1 어느 게임 코스어의 최후 22시간 전
2 사우디 리아드 엑스포 유치전 최종 프레젠테이션 인트로 31분 전
3 부산엑스포 유치전 최종 프레젠테이션 인트로 영상 1시간 전
4 도그 어질리티 1시간 전
5 우주의 끝 동호회 1시간 전
댓글 0
메뉴 목록 맨위로 로그인
TE31.COM ⓒ 2002-2023
서버 부하 19.25%