Mercurial > hg > ucis.core
annotate USBLib/Internal/Windows/Win32Kernel.cs @ 75:50d4aed66c67
Improved HTTP classes
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Mon, 03 Feb 2014 22:53:31 +0100 |
parents | e811297f5aa4 |
children |
rev | line source |
---|---|
21 | 1 ???using System; |
2 using System.Runtime.InteropServices; | |
3 using System.Security; | |
4 using System.Threading; | |
5 using Microsoft.Win32.SafeHandles; | |
6 | |
7 namespace UCIS.USBLib.Internal.Windows { | |
8 [SuppressUnmanagedCodeSecurity] | |
9 static class Kernel32 { | |
10 [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
11 internal static extern SafeFileHandle CreateFile(string fileName, NativeFileAccess fileAccess, NativeFileShare fileShare, IntPtr securityAttributes, NativeFileMode creationDisposition, NativeFileFlag flags, IntPtr template); | |
12 [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
13 public static extern SafeFileHandle CreateFile(string lpFileName, uint dwDesiredAccess, int dwShareMode, IntPtr lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile); | |
14 | |
15 [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi)] | |
16 unsafe internal static extern bool DeviceIoControl(SafeHandle hDevice, int IoControlCode, IntPtr InBuffer, int nInBufferSize, IntPtr OutBuffer, int nOutBufferSize, out int pBytesReturned, NativeOverlapped* Overlapped); | |
57
b1efeada517e
Added VirtualBox USB driver backend for direct USB communication
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
17 [DllImport("kernel32.dll", SetLastError = true)] |
b1efeada517e
Added VirtualBox USB driver backend for direct USB communication
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
18 unsafe internal static extern bool DeviceIoControl(SafeHandle hDevice, int IoControlCode, void* InBuffer, int nInBufferSize, void* OutBuffer, int nOutBufferSize, out int pBytesReturned, NativeOverlapped* Overlapped); |
68
e811297f5aa4
Updated USBLib: removed old LibUsbDotNet compatibility code and added new information helper classes
Ivo Smits <Ivo@UCIS.nl>
parents:
58
diff
changeset
|
19 [DllImport("kernel32.dll", SetLastError = true)] |
e811297f5aa4
Updated USBLib: removed old LibUsbDotNet compatibility code and added new information helper classes
Ivo Smits <Ivo@UCIS.nl>
parents:
58
diff
changeset
|
20 unsafe internal static extern bool DeviceIoControl(SafeHandle hDevice, int IoControlCode, Byte[] InBuffer, int nInBufferSize, Byte[] OutBuffer, int nOutBufferSize, out int pBytesReturned, IntPtr Overlapped); |
e811297f5aa4
Updated USBLib: removed old LibUsbDotNet compatibility code and added new information helper classes
Ivo Smits <Ivo@UCIS.nl>
parents:
58
diff
changeset
|
21 [DllImport("kernel32.dll", SetLastError = true)] |
21 | 22 unsafe internal static extern bool GetOverlappedResult(SafeHandle hFile, NativeOverlapped* lpOverlapped, out int lpNumberOfBytesTransferred, Boolean bWait); |
23 | |
24 [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
25 public static extern bool DeviceIoControl(SafeHandle hDevice, int dwIoControlCode, IntPtr lpInBuffer, int nInBufferSize, out USB_ROOT_HUB_NAME lpOutBuffer, int nOutBufferSize, out int lpBytesReturned, IntPtr lpOverlapped); | |
26 [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
27 public static extern bool DeviceIoControl(SafeHandle hDevice, int dwIoControlCode, [In] ref USB_NODE_INFORMATION lpInBuffer, int nInBufferSize, out USB_NODE_INFORMATION lpOutBuffer, int nOutBufferSize, out int lpBytesReturned, IntPtr lpOverlapped); | |
28 [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
58
fd63c453ff65
Improved Windows USB enumeration classes
Ivo Smits <Ivo@UCIS.nl>
parents:
57
diff
changeset
|
29 public static extern bool DeviceIoControl(SafeHandle hDevice, int dwIoControlCode, [In] ref USB_DESCRIPTOR_REQUEST lpInBuffer, int nInBufferSize, Byte[] lpOutBuffer, int nOutBufferSize, out int lpBytesReturned, IntPtr lpOverlapped); |
21 | 30 [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] |
31 public static extern bool DeviceIoControl(SafeHandle hDevice, int dwIoControlCode, [In] ref USB_NODE_CONNECTION_DRIVERKEY_NAME lpInBuffer, int nInBufferSize, out USB_NODE_CONNECTION_DRIVERKEY_NAME lpOutBuffer, int nOutBufferSize, out int lpBytesReturned, IntPtr lpOverlapped); | |
32 [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
33 public static extern bool DeviceIoControl(SafeHandle hDevice, int dwIoControlCode, [In] ref USB_NODE_CONNECTION_INFORMATION_EX lpInBuffer, int nInBufferSize, out USB_NODE_CONNECTION_INFORMATION_EX lpOutBuffer, int nOutBufferSize, out int lpBytesReturned, IntPtr lpOverlapped); | |
34 [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
35 public static extern bool DeviceIoControl(SafeHandle hDevice, int dwIoControlCode, [In] ref USB_NODE_CONNECTION_NAME lpInBuffer, int nInBufferSize, out USB_NODE_CONNECTION_NAME lpOutBuffer, int nOutBufferSize, out int lpBytesReturned, IntPtr lpOverlapped); | |
36 | |
57
b1efeada517e
Added VirtualBox USB driver backend for direct USB communication
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
37 public const uint GENERIC_READ = 0x80000000; |
21 | 38 public const uint GENERIC_WRITE = 0x40000000; |
39 //public const uint GENERIC_EXECUTE = 0x20000000; | |
40 //public const uint GENERIC_ALL = 0x10000000; | |
57
b1efeada517e
Added VirtualBox USB driver backend for direct USB communication
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
41 public const uint FILE_FLAG_NO_BUFFERING = 0x20000000; |
21 | 42 |
57
b1efeada517e
Added VirtualBox USB driver backend for direct USB communication
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
43 public const int FILE_SHARE_READ = 0x1; |
21 | 44 public const int FILE_SHARE_WRITE = 0x2; |
45 public const int OPEN_EXISTING = 0x3; | |
57
b1efeada517e
Added VirtualBox USB driver backend for direct USB communication
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
46 |
b1efeada517e
Added VirtualBox USB driver backend for direct USB communication
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
47 public const int FILE_ATTRIBUTE_SYSTEM = 0x00000004; |
b1efeada517e
Added VirtualBox USB driver backend for direct USB communication
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
48 public const int FILE_FLAG_OVERLAPPED = 0x40000000; |
21 | 49 } |
50 | |
51 [Flags] | |
52 enum NativeFileAccess : uint { | |
53 FILE_SPECIAL = 0, | |
54 FILE_APPEND_DATA = (0x0004), // file | |
55 FILE_READ_DATA = (0x0001), // file & pipe | |
56 FILE_WRITE_DATA = (0x0002), // file & pipe | |
57 FILE_READ_EA = (0x0008), // file & directory | |
58 FILE_WRITE_EA = (0x0010), // file & directory | |
59 FILE_READ_ATTRIBUTES = (0x0080), // all | |
60 FILE_WRITE_ATTRIBUTES = (0x0100), // all | |
61 DELETE = 0x00010000, | |
62 READ_CONTROL = (0x00020000), | |
63 WRITE_DAC = (0x00040000), | |
64 WRITE_OWNER = (0x00080000), | |
65 SYNCHRONIZE = (0x00100000), | |
66 STANDARD_RIGHTS_REQUIRED = (0x000F0000), | |
67 STANDARD_RIGHTS_READ = (READ_CONTROL), | |
68 STANDARD_RIGHTS_WRITE = (READ_CONTROL), | |
69 STANDARD_RIGHTS_EXECUTE = (READ_CONTROL), | |
70 STANDARD_RIGHTS_ALL = (0x001F0000), | |
71 SPECIFIC_RIGHTS_ALL = (0x0000FFFF), | |
72 FILE_GENERIC_READ = (STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE), | |
73 FILE_GENERIC_WRITE = (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE), | |
74 SPECIAL = 0 | |
75 } | |
76 | |
77 enum NativeFileMode : uint { | |
78 CREATE_NEW = 1, | |
79 CREATE_ALWAYS = 2, | |
80 OPEN_EXISTING = 3, | |
81 OPEN_ALWAYS = 4, | |
82 TRUNCATE_EXISTING = 5, | |
83 } | |
84 | |
85 [Flags] | |
86 enum NativeFileShare : uint { | |
87 NONE = 0, | |
88 FILE_SHARE_READ = 0x00000001, | |
89 FILE_SHARE_WRITE = 0x00000002, | |
90 FILE_SHARE_DEELETE = 0x00000004, | |
91 } | |
92 | |
93 [Flags] | |
94 enum NativeFileFlag : uint { | |
95 FILE_ATTRIBUTE_READONLY = 0x00000001, | |
96 FILE_ATTRIBUTE_HIDDEN = 0x00000002, | |
97 FILE_ATTRIBUTE_SYSTEM = 0x00000004, | |
98 FILE_ATTRIBUTE_DIRECTORY = 0x00000010, | |
99 FILE_ATTRIBUTE_ARCHIVE = 0x00000020, | |
100 FILE_ATTRIBUTE_DEVICE = 0x00000040, | |
101 FILE_ATTRIBUTE_NORMAL = 0x00000080, | |
102 FILE_ATTRIBUTE_TEMPORARY = 0x00000100, | |
103 FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200, | |
104 FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400, | |
105 FILE_ATTRIBUTE_COMPRESSED = 0x00000800, | |
106 FILE_ATTRIBUTE_OFFLINE = 0x00001000, | |
107 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000, | |
108 FILE_ATTRIBUTE_ENCRYPTED = 0x00004000, | |
109 FILE_FLAG_WRITE_THROUGH = 0x80000000, | |
110 FILE_FLAG_OVERLAPPED = 0x40000000, | |
111 FILE_FLAG_NO_BUFFERING = 0x20000000, | |
112 FILE_FLAG_RANDOM_ACCESS = 0x10000000, | |
113 FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000, | |
114 FILE_FLAG_DELETE_ON_CLOSE = 0x04000000, | |
115 FILE_FLAG_BACKUP_SEMANTICS = 0x02000000, | |
116 FILE_FLAG_POSIX_SEMANTICS = 0x01000000, | |
117 FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000, | |
118 FILE_FLAG_OPEN_NO_RECALL = 0x00100000, | |
119 FILE_FLAG_FIRST_PIPE_INSTANCE = 0x00080000, | |
120 } | |
121 } |