c# - kernel32.dll API 的包装器 C#

标签 c# winapi wrapper kernel32

是否有任何帮助程序类在任何地方包装了 kernel32 API,具有所有功能、方法和结构?或者任何包装生成器?

我想要 C# 中 kernel32.dll 的所有方法,如下所示:

 [DllImport("kernel32.dll",EntryPoint="RtlMoveMemory")]
        public static extern void RtlMoveMemory(int des, int src, int count);

        [DllImport("kernel32.dll", EntryPoint = "OpenProcess")]
        public static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, uint dwProcessId);

        [DllImport("kernel32", CharSet = CharSet.Ansi)]
        public extern static int GetProcAddress(int hwnd, string procedureName);

        [DllImport("kernel32.dll", EntryPoint = "GetModuleHandle")]
        public static extern int GetModuleHandle(string lpModuleName);

        [DllImport("kernel32.dll", EntryPoint = "VirtualAllocEx")]
        public static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);

        [DllImport("kernel32")]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool CloseHandle(IntPtr hObject);

        [DllImport("kernel32", EntryPoint = "CreateRemoteThread")]
        public static extern IntPtr CreateRemoteThread(IntPtr hProcess, IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, uint lpThreadId);

        [DllImport("kernel32.dll", EntryPoint = "WriteProcessMemory")]
        public static extern IntPtr WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] buffer, uint size, IntPtr lpNumberOfBytesWritten);

最佳答案

我怀疑。

你见过http://www.pinvoke.net/吗? ?

关于c# - kernel32.dll API 的包装器 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1942829/

相关文章:

c# - windows服务奇怪的行为

c++ - 无法读取代码页不匹配的 FileVersionInfo

python - 如何编写适配成员类接口(interface)的容器/包装类?

java - 如果将成员数据声明为原始数据类型,如果对象被声明为可序列化,值是否会被序列化?

c# - 存储过程:使用Return还是选择Select?

c# - 如何使用 PropertyInfo.SetValue Method (Object, Object) 设置可空属性的值

在 Visual Studio 2010 中使用 SQLite 数据库发布的 C# WPF

c# - 使磁盘在线/离线

c# - 从不使用标签控件的对话框中获取文本?

python - 在 python 中包装一个函数,提供一个额外的 bool 值