2009-12-21 37 views
6

Bất kỳ lớp trình trợ giúp nào ở bất kỳ đâu bao bọc các API kernel32, với tất cả các hàm và phương thức hàm? Hoặc bất kỳ trình tạo trình bao bọc nào?Trình bao bọc C# cho kernel32.dll API

Tôi muốn tất cả các phương pháp của kernel32.dll trong C# như thế này:

[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); 
+0

Một câu hỏi - tại sao? –

+3

Có 1359 điểm vào, cách quá nhiều. Hãy chắc chắn sử dụng một nguồn tốt cho các khai báo, những cái bạn đã có là sai. –

+0

Nếu tạo ra tất cả các điểm vào, sau khi không lãng phí thời gian để làm điều đó. Và tạo ra mã nguồn là tốt hơn, không phải lỗi trong mã số –

Trả lời

7

Tôi nghi ngờ điều đó.

Bạn đã xem http://www.pinvoke.net/ chưa?

+0

Ồ, vâng, nhưng không hỗ trợ VS 2008 !!! thật đáng tiếc !! một công cụ hoặc mã nguồn lớp với tất cả các chức năng của kernel32.dll ?? thanks –

+1

Plugin VS có thể không hỗ trợ 2008, điều đó không có nghĩa là bạn không thể sử dụng nội dung từ trang web. Có vẻ như việc tìm kiếm các API và tìm kiếm các mã API có vẻ mất thời gian, nhưng vẫn tốt hơn là viết nó từ đầu. Về mặt cộng, bạn chỉ cần làm điều này một lần. – donovan

+0

mất thời gian tìm kiếm các API và sao chép mã .... có lẽ, nhưng bất kỳ giải pháp thực hành nào cho tôi, để tạo mã tự động cho trình bao bọc của kernel32.dll, gdi.dll, ... THANKS !! –

Các vấn đề liên quan