博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C#做外挂的常用API,本人用了很久,基本没发现问题
阅读量:7063 次
发布时间:2019-06-28

本文共 4264 字,大约阅读时间需要 14 分钟。

using System;using System.Collections.Generic;using System.Text;using System.Runtime.InteropServices;  //这个肯定要的  namespace WindowsApplication1{    class win32API    {        public const int OPEN_PROCESS_ALL = 2035711;        public const int PAGE_READWRITE = 4;        public const int PROCESS_CREATE_THREAD = 2;        public const int PROCESS_HEAP_ENTRY_BUSY = 4;        public const int PROCESS_VM_OPERATION = 8;        public const int PROCESS_VM_READ = 256;        public const int PROCESS_VM_WRITE = 32;        private const int PAGE_EXECUTE_READWRITE = 0x4;        private const int MEM_COMMIT = 4096;        private const int MEM_RELEASE = 0x8000;        private const int MEM_DECOMMIT = 0x4000;        private const int PROCESS_ALL_ACCESS = 0x1F0FFF;                //查找窗体        [DllImport("User32.dll", EntryPoint = "FindWindow")]        public extern static IntPtr FindWindow(            string lpClassName,             string lpWindowName            );        //得到目标进程句柄的函数        [DllImport("USER32.DLL")]         public extern static int GetWindowThreadProcessId(            int hwnd,             ref int lpdwProcessId            );        [DllImport("USER32.DLL")]        public extern static int GetWindowThreadProcessId(            IntPtr hwnd,             ref int lpdwProcessId            );        //打开进程        [DllImport("kernel32.dll")]        public extern static int OpenProcess(            int dwDesiredAccess,             int bInheritHandle,             int dwProcessId            );        [DllImport("kernel32.dll")]        public extern static IntPtr OpenProcess(            uint dwDesiredAccess,             int bInheritHandle,             uint dwProcessId            );                //关闭句柄的函数        [DllImport("kernel32.dll", EntryPoint = "CloseHandle")]        public static extern int CloseHandle(            int hObject            );        //读内存        [DllImport("Kernel32.dll ")]        public static extern Int32 ReadProcessMemory(            IntPtr hProcess,            IntPtr lpBaseAddress,            [In, Out] byte[] buffer,            int size,            out IntPtr lpNumberOfBytesWritten            );        [DllImport("Kernel32.dll ")]        public static extern Int32 ReadProcessMemory(            int hProcess,            int lpBaseAddress,            ref int buffer,            //byte[] buffer,            int size,            int lpNumberOfBytesWritten            );        [DllImport("Kernel32.dll ")]        public static extern Int32 ReadProcessMemory(            int hProcess,            int lpBaseAddress,            byte[] buffer,            int size,            int lpNumberOfBytesWritten            );        //写内存        [DllImport("kernel32.dll")]        public static extern Int32 WriteProcessMemory(            IntPtr hProcess,            IntPtr lpBaseAddress,             [In, Out] byte[] buffer,             int size,             out IntPtr lpNumberOfBytesWritten            );        [DllImport("kernel32.dll")]        public static extern Int32 WriteProcessMemory(            int hProcess,             int lpBaseAddress,             byte[] buffer,             int size,             int lpNumberOfBytesWritten            );        //创建线程        [DllImport("kernel32", EntryPoint = "CreateRemoteThread")]        public static extern int CreateRemoteThread(            int hProcess,            int lpThreadAttributes,            int dwStackSize,            int lpStartAddress,            int lpParameter,            int dwCreationFlags,            ref int lpThreadId            );        //开辟指定进程的内存空间        [DllImport("Kernel32.dll")]        public static extern System.Int32 VirtualAllocEx(         System.IntPtr hProcess,         System.Int32 lpAddress,         System.Int32 dwSize,         System.Int16 flAllocationType,         System.Int16 flProtect         );        [DllImport("Kernel32.dll")]        public static extern System.Int32 VirtualAllocEx(        int hProcess,        int lpAddress,        int dwSize,        int flAllocationType,        int flProtect        );        //释放内存空间        [DllImport("Kernel32.dll")]        public static extern System.Int32 VirtualFreeEx(        int hProcess,        int lpAddress,        int dwSize,        int flAllocationType        );    }}

 

转载地址:http://uknll.baihongyu.com/

你可能感兴趣的文章
HBase生产环境配置与使用优化不完全指南
查看>>
mysql创建数据表时如何判断是否已经存在?
查看>>
RocketMQ 基本概念
查看>>
VUE多项目间跳转保存用户解决方法
查看>>
HashMap 详解四
查看>>
GCP为Kubernetes引擎提供支持原生容器的负载均衡器
查看>>
住宅格局解剖图鉴
查看>>
6.Swift学习之逻辑分支
查看>>
自定义textview invalidate ()不调用ondraw()可能原因
查看>>
CDH5.3配置Kerberos+LDAP+Sentry记录
查看>>
Laravel 5 基础教程 || 1.安装与部署 - 表严肃
查看>>
F5 LTM 在SIP消息负载均衡中存在的问题
查看>>
怎么安装docker registry
查看>>
findbugs eclipse 插件 及使用
查看>>
【微服务No.4】 API网关组件Ocelot+Consul
查看>>
微软以白金会员加入 OpenChain 开源组织
查看>>
windows下的套接字IO模型
查看>>
Session,cookie,localStorage
查看>>
Jenkins——持续集成服务器
查看>>
《利用Python进行数据分析·第2版》第12章 pandas高级应用
查看>>