runxinzhi.com
首页
百度搜索
C#引入Win32API:常用Win32API
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 ); } }
相关阅读:
《实战Java高并发程序设计》读书笔记一
《实战Java高并发程序设计》读书笔记二
SprintBoot学习(三)
SprintBoot学习(二)
SprintBoot学习(一)
jQuery学习(三)
jQuery学习(二)
jQuery学习(一)
利用activeX控件在网页里自动登录WIN2003远程桌面并实时控制
上传读取Excel文件数据
原文地址:https://www.cnblogs.com/bdstjk/p/2519866.html
最新文章
使用JSONObject进行序列化时,避开定义get或set为开头的方法名称
python中else的用法
将jacoco集成到测试工具平台
基于pytest的接口测试
基于spring-boot的测试桩设计-添加配置文件(properties)
验证python中函数传参是引用传递
将Factory-boy生成的复杂对象转成dict的方法
pytest 用 @pytest.mark.usefixtures("fixtureName")或@pytest.fixture(scope="function", autouse=True)装饰,实现类似setup和TearDown的功能
yield函数的执行顺序
二阶段项目所遇问题 如何头像上传数据库并且取出使用
热门文章
二阶段项目所遇问题 如何实现php向js传输数据
利用php做出简单的发布信息和回复功能
php简单的文件操作
文件操作
jquery 基础
php 多条件查询
php 数据访问基础
连接数据库 ,登录 注册
php 数据连接 基础
《实战Java高并发程序设计》读书笔记三
Copyright © 2020-2023
润新知