【问题标题】:Wrapper C# for kernel32.dll API用于 kernel32.dll API 的包装器 C#
【发布时间】:2010-12-28 21:47:16
【问题描述】:

任何地方的任何帮助类都包装了 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);

【问题讨论】:

  • 有 1359 个入口点,太多了。确保使用良好的声明来源,你得到的那些是错误的。
  • 如果生成所有的入口点,之后不要浪费时间去做。并且生成源代码更好,代码不会出错

标签: c# winapi wrapper kernel32


【解决方案1】:

我怀疑。

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

【讨论】:

  • 哦,是的,但不支持VS 2008 !!!真遗憾 !!另一个具有kernel32.dll所有功能的工具或源代码类??谢谢
  • VS插件可能不支持2008,这并不意味着你不能使用网站上的内容。搜索 API 并复制代码可能看起来很费力,但从头开始编写仍然更好。从好的方面来说,您只需要这样做一次。
  • 费力地搜索 API 并复制代码......也许,但对我来说任何实践解决方案,用于 kernel32.dll、gdi.dll 的包装器的自动化代码生成......谢谢!!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-25
  • 1970-01-01
  • 2014-04-26
  • 1970-01-01
  • 2010-11-12
相关资源
最近更新 更多