Desktop Functions: Smart Device Functions:
|
Search Results for "usb" in [All]Structures
ICC_BAR_CLASSES = 0x00000004, // toolbar, statusbar, trackbar, tooltips
' toolbar, statusbar, trackbar, tooltips
struct USB_SETUP_PACKET
struct USB_DESCRIPTOR_REQUEST
public USB_SETUP_PACKET SetupPacket;
Structure USB_DESCRIPTOR_REQUEST
const int USB_DEVICE_DESCRIPTOR_TYPE = 1;
const int USB_STRING_DESCRIPTOR_TYPE = 3; The USB_DESCRIPTOR_REQUEST structure is always followed by either a USB_STRING_DESCRIPTOR or USB_DEVICE_DESCRIPTOR structure. The use of a a zero-length array at the end of the structure requires that you read and write "off the edge" of the structure. This concept is not well supported in C#/VB.Net so you have make sure that you allocate sufficient buffer space to accommodate a the USB_STRING_DESCRIPTOR or USB_DEVICE_DESCRIPTOR structure.
typedef struct _USB_DESCRIPTOR_REQUEST {
} USB_DESCRIPTOR_REQUEST, *PUSB_DESCRIPTOR_REQUEST
USB_DESCRIPTOR_REQUEST Request = new USB_DESCRIPTOR_REQUEST();
Request.SetupPacket.wValue = (short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iManufacturer);
if (DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ptrRequest, nBytes, ptrRequest, nBytes, out nBytesReturned, IntPtr.Zero))
USB_STRING_DESCRIPTOR StringDesc = (USB_STRING_DESCRIPTOR)Marshal.PtrToStructure(ptrStringDesc, typeof(USB_STRING_DESCRIPTOR));
struct USB_DEVICE_DESCRIPTOR
public ushort bcdUSB;
Structure USB_DEVICE_DESCRIPTOR Is often used as a type inside a USB_NODE_CONNECTION_INFORMATION_EX structure, hence the need for the "Pack=1" The values for iManufacturer, iProduct, and iSerialNumber are just indexs that are used by the USB_STRING_DESCRIPTOR request
typedef struct _USB_DEVICE_DESCRIPTOR {
USHORT bcdUSB;
} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR ;
struct USB_HCD_DRIVERKEY_NAME
Structure USB_HCD_DRIVERKEY_NAME
typedef struct _USB_HCD_DRIVERKEY_NAME {
} USB_HCD_DRIVERKEY_NAME, *PUSB_HCD_DRIVERKEY_NAME;
struct USB_HUB_DESCRIPTOR
Structure USB_HUB_DESCRIPTOR This structure is often nested inside the USB_HUB_INFORMATION structure, hence the need for the "pack=1"
typedef struct _USB_HUB_DESCRIPTOR {
} USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
struct USB_HUB_INFORMATION
public USB_HUB_DESCRIPTOR HubDescriptor;
Structure USB_HUB_INFORMATION Often nested inside a USB_NODE_INFORMATION structure
typedef struct _USB_HUB_INFORMATION {
USB_HUB_DESCRIPTOR HubDescriptor;
} USB_HUB_INFORMATION, *PUSB_HUB_INFORMATION;
USB_NODE_INFORMATION NodeInfo = new USB_NODE_INFORMATION();
NodeInfo.NodeType = (int)USB_HUB_NODE.UsbHub;
if (DeviceIoControl(h2, IOCTL_USB_GET_NODE_INFORMATION, ptrNodeInfo, nBytes, ptrNodeInfo, nBytes, out nBytesReturned, IntPtr.Zero))
NodeInfo = (USB_NODE_INFORMATION)Marshal.PtrToStructure(ptrNodeInfo, typeof(USB_NODE_INFORMATION)); 7: USB_HUB_NODE
struct USB_NODE_CONNECTION_DRIVERKEY_NAME
Structure USB_NODE_CONNECTION_DRIVERKEY_NAME Identical to the USB_NODE_CONNECTION_NAME structure
typedef struct _USB_NODE_CONNECTION_DRIVERKEY_NAME {
} USB_NODE_CONNECTION_DRIVERKEY_NAME, *PUSB_NODE_CONNECTION_DRIVERKEY_NAME;
USB_NODE_CONNECTION_DRIVERKEY_NAME DriverKey = new USB_NODE_CONNECTION_DRIVERKEY_NAME();
if (DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME, ptrDriverKey, nBytes, ptrDriverKey, nBytes, out nBytesReturned, IntPtr.Zero))
DriverKey = (USB_NODE_CONNECTION_DRIVERKEY_NAME)Marshal.PtrToStructure(ptrDriverKey, typeof(USB_NODE_CONNECTION_DRIVERKEY_NAME));
struct USB_NODE_CONNECTION_INFORMATION_EX
public USB_DEVICE_DESCRIPTOR DeviceDescriptor;
Structure USB_NODE_CONNECTION_INFORMATION_EX
typedef struct _USB_NODE_CONNECTION_INFORMATION_EX {
USB_DEVICE_DESCRIPTOR DeviceDescriptor;
USB_CONNECTION_STATUS ConnectionStatus;
USB_PIPE_INFO PipeList[0];
} USB_NODE_CONNECTION_INFORMATION_EX, *PUSB_NODE_CONNECTION_INFORMATION_EX;
int nBytes = Marshal.SizeOf(typeof(USB_NODE_CONNECTION_INFORMATION_EX));
USB_NODE_CONNECTION_INFORMATION_EX NodeConnection = new USB_NODE_CONNECTION_INFORMATION_EX();
if (DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, ptrNodeConnection, nBytes, ptrNodeConnection, nBytes, out nBytesReturned, IntPtr.Zero))
NodeConnection = (USB_NODE_CONNECTION_INFORMATION_EX)Marshal.PtrToStructure(ptrNodeConnection, typeof(USB_NODE_CONNECTION_INFORMATION_EX));
// To get the USB_PIPE_INFO data
USB_NODE_CONNECTION_INFORMATION_EX connection = new USB_NODE_CONNECTION_INFORMATION_EX();
size = Marshal.SizeOf(typeof(USB_NODE_CONNECTION_INFORMATION_EX)) + 32 * Marshal.SizeOf(typeof(USB_PIPE_INFO)); // Assuming 32 should be enough, you can make this larger
if (DeviceIoControl(hHub, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, ptr_connection, size, ptr_connection, size, out bytes_returned, IntPtr.Zero))
connection = (USB_NODE_CONNECTION_INFORMATION_EX)Marshal.PtrToStructure(ptr_connection, typeof(USB_NODE_CONNECTION_INFORMATION_EX));
if (bytes_returned != Marshal.SizeOf(typeof(USB_NODE_CONNECTION_INFORMATION_EX)))
int num = (bytes_returned - Marshal.SizeOf(typeof(USB_NODE_CONNECTION_INFORMATION_EX))) / Marshal.SizeOf(typeof(USB_PIPE_INFO));
USB_PIPE_INFO[] pipe_info = new USB_PIPE_INFO[num];
// Set ptr to an USB_PIPE_INFO element and marshal it back
+ Marshal.SizeOf(typeof(USB_NODE_CONNECTION_INFORMATION_EX))
+ j * Marshal.SizeOf(typeof(USB_PIPE_INFO)));
pipe_info[j] = (USB_PIPE_INFO)Marshal.PtrToStructure(ptr_pipeinfo, typeof(USB_PIPE_INFO));
struct USB_NODE_CONNECTION_NAME
Structure USB_NODE_CONNECTION_NAME
typedef struct _USB_NODE_CONNECTION_NAME {
} USB_NODE_CONNECTION_NAME, *PUSB_NODE_CONNECTION_NAME;
USB_NODE_CONNECTION_NAME NodeName = new USB_NODE_CONNECTION_NAME();
if (DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_NAME, ptrNodeName, nBytes, ptrNodeName, nBytes, out nBytesReturned, IntPtr.Zero))
NodeName = (USB_NODE_CONNECTION_NAME)Marshal.PtrToStructure(ptrNodeName, typeof(USB_NODE_CONNECTION_NAME));
// We need a separate struct to hold the union due to the fact that on 64-bit USB_HUB_NODE gets marshaled
struct USB_NODE_INFORMATION
public USB_HUB_NODE NodeType; /* hub, mi parent */
public UsbNodeUnion u;
// Simpler version if you do not care about USB_MI_PARENT_INFORMATION
struct USB_NODE_INFORMATION
public USB_HUB_INFORMATION HubInformation; // Yeah, I'm assuming we'll just use the first form
Structure USB_NODE_INFORMATION
enum USB_HUB_NODE : uint
UsbHub,
UsbMIParent
struct USB_MI_PARENT_INFORMATION
struct UsbNodeUnion
public USB_HUB_INFORMATION HubInformation;
public USB_MI_PARENT_INFORMATION MiParentInformation;
typedef struct _USB_NODE_INFORMATION {
USB_HUB_NODE NodeType;
USB_HUB_INFORMATION HubInformation;
USB_MI_PARENT_INFORMATION MiParentInformation;
} USB_NODE_INFORMATION, *PUSB_NODE_INFORMATION;
USB_NODE_INFORMATION NodeInfo = new USB_NODE_INFORMATION();
NodeInfo.NodeType = (int)USB_HUB_NODE.UsbHub;
if (DeviceIoControl(h2, IOCTL_USB_GET_NODE_INFORMATION, ptrNodeInfo, nBytes, ptrNodeInfo, nBytes, out nBytesReturned, IntPtr.Zero))
NodeInfo = (USB_NODE_INFORMATION)Marshal.PtrToStructure(ptrNodeInfo, typeof(USB_NODE_INFORMATION));
struct USB_ROOT_HUB_NAME
Structure USB_ROOT_HUB_NAME
typedef struct _USB_ROOT_HUB_NAME {
} USB_ROOT_HUB_NAME, *PUSB_ROOT_HUB_NAME;
USB_ROOT_HUB_NAME HubName = new USB_ROOT_HUB_NAME();
if (DeviceIoControl(h, IOCTL_USB_GET_ROOT_HUB_NAME, ptrHubName, nBytes, ptrHubName, nBytes, out nBytesReturned, IntPtr.Zero))
HubName = (USB_ROOT_HUB_NAME)Marshal.PtrToStructure(ptrHubName, typeof(USB_ROOT_HUB_NAME));
struct USB_STRING_DESCRIPTOR
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=MAXIMUM_USB_STRING_LENGTH)]
Structure USB_STRING_DESCRIPTOR
const int MAXIMUM_USB_STRING_LENGTH = 255;
const int USB_STRING_DESCRIPTOR_TYPE = 3;
typedef struct _USB_STRING_DESCRIPTOR {
} USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR; You don't use an IOCTL call directly with a USB_STRING_DESCRIPTOR structure. Instead you use a USB_DESCRIPTOR_REQUEST "request packet" with IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION. The USB_STRING_DESCRIPTOR structure is returned at the very end of the request packet. The whole idea of "writing off the edge" of a structure is counter to the way C#/VB.Net was designed to work, so you'll have to make sure to allocate sufficient amount of memory to handle both the "request packet" and the USB_STRING_DESCRIPTOR structure.
USB_DESCRIPTOR_REQUEST Request = new USB_DESCRIPTOR_REQUEST();
Request.SetupPacket.wValue = (short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iManufacturer);
if (DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ptrRequest, nBytes, ptrRequest, nBytes, out nBytesReturned, IntPtr.Zero))
USB_STRING_DESCRIPTOR StringDesc = (USB_STRING_DESCRIPTOR)Marshal.PtrToStructure(ptrStringDesc, typeof(USB_STRING_DESCRIPTOR)); Constants15: GUID_DEVCLASS
public static readonly Guid GUID_DEVCLASS_USB = new Guid("{0x36fc9e60, 0xc465, 0x11cf, {0x80, 0x56, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}");
public static readonly Guid GUID_DEVCLASS_WCEUSBS = new Guid("{0x25dbce51, 0x6c8f, 0x4a72, {0x8a, 0x6d, 0xb5, 0x4c, 0x2b, 0x4f, 0xc8, 0x35}}");
public static readonly Guid GUID_DEVCLASS_FSFILTER_CONTINUOUSBACKUP = new Guid("{0x71aa14f8, 0x6fad, 0x4622, {0xad, 0x77, 0x92, 0xbb, 0x9d, 0x7e, 0x69, 0x47}}");
public static Guid GUID_DEVINTERFACE_USB_DEVICE = new Guid("A5DCBF10-6530-11D2-901F-00C04FB951ED");
public static Guid GUID_DEVINTERFACE_USB_HOST_CONTROLLER = new Guid("3ABF6F2D-71C4-462A-8A92-1E6861E6AF27");
public static Guid GUID_DEVINTERFACE_USB_HUB = new Guid("F18A0E88-C30C-11D0-8815-00A0C906BED8"); quickusb27: !!!!!!!!!!!!!!! 28: !!!!!!!!!!!!! 29: !!!!!!!!!!! 30: !!!!!!!!!! 31: !!!!!!!! 32: !!!!!!! 33: !!!!!! 34: !!!! 35: !! 36: Close 37: lorem30 QuickUSB is small USB port you can implement into any hardware project of yours. It comes with an unmanaged wrapper library encapsulating many of the USB's functions. The following pages are wrapper documentation form managed perspective. You can order one at http://www.bitwisesys.com Also, see the Managed wrapper class CsQuickUSB http://code.google.com/p/csquickusb/ QuickUsb.dll is not unicode friendly, make sure you use ANSI encodings on your pinvoke calls! 39: QuickUSB
[DllImport("quickusb.dll", CharSet = CharSet.Ansi)]
static extern int QuickUsbWriteData(IntPtr Handle, byte[] outData, int length);
/// Write a block to QuckUSB module
int result = QuickUsbWriteData(handle, data, data.Length);
LastError = "QUSB returned 0";
LastError = "USB connection not open, please open"; 40: QuickUsbClose
[DllImport("quickusb.dll", CharSet = CharSet.Ansi)]
private static extern int QuickUsbClose(IntPtr handle);
Declare Function QuickUsbClose Lib "quickusb.dll" (TODO) As TODO
int result = QuickUsbClose(handle);
[DllImport("quickusb.dll", CharSet = CharSet.Ansi)]
private static extern int QuickUsbFindModules(StringBuilder nameList, int bufferLength); This function will return a null delimited "\0" list of attached devices. For example, after executing this function with one module connected, nameList will contain "QUSB-0\0\0". If there are two devices plugged in, nameList will contain "QUSB-0\0QUSB-1\0\0". 42: QuickUsbOpen
[DllImport("quickusb.dll", CharSet = CharSet.Ansi)]
static extern int QuickUsbOpen(out IntPtr handle, string devName); Make sure devName="QUSB-0\0\0";
string deviceName="QUSB-0\0\0";
int result = QuickUsbOpen(out handle, deviceName); 43: QuickUsbReadData
DllImport("quickusb.dll", CharSet = CharSet.Ansi)]
static extern int QuickUsbReadData(IntPtr Handle, byte[] outData, out int length);
/// Read block from QuickUSB module
/// <param name="data"> Empty byte array to fill with USB data</param>
int result = QuickUsbReadData(handle, readData, out len);
LastError = "USB Connection is not open";
LastError = "Cannot find the QuickUSB dll library. Please install QuickUsb Drivers.";
[DllImport("quickusb.dll", CharSet = CharSet.Ansi)]
static extern int QuickUsbWriteData(IntPtr Handle, byte[] outData, int length);
/// Write a block to QuckUSB module
int result = QuickUsbWriteData(handle, data, data.Length);
LastError = "QUSB returned 0";
LastError = "USB connection not open, please open"; userenvInterfaces
void OnStatusBar([MarshalAs(UnmanagedType.VariantBool)] bool StatusBar);
Sub OnStatusBar(<MarshalAs(UnmanagedType.VariantBool)> ByVal StatusBar As Boolean)
usBuildNumber, // Build Number. 49: IShellBrowser
void SetMenuSB(IntPtr IntPtrShared, IntPtr holemenuRes, 50: IWebBrowser
bool StatusBar { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x193)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x193)] set; }
bool StatusBar { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x193)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x193)] set; }
Property StatusBar() As <MarshalAs(UnmanagedType.VariantBool)> Boolean 51: IWebBrowser2
bool StatusBar { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x193)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x193)] set; }
bool StatusBar { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x193)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x193)] set; }
Property StatusBar() As <MarshalAs(UnmanagedType.VariantBool)> Boolean ntdll52: NtCreateFile
IO_STATUS_BLOCK ioStatusBlock = new IO_STATUS_BLOCK();
ref ioStatusBlock,
[DllImport("ntdll.dll", SetLastError=true)] static extern IntPtr NtQueryInformationFile(IntPtr fileHandle, ref IO_STATUS_BLOCK IoStatusBlock, IntPtr pInfoBlock, uint length, FILE_INFORMATION_CLASS fileInformation);
Declare Function NtQueryInformationFile Lib "ntdll.dll" (ByVal fileHandle As IntPtr, ByRef IoStatusBlock As IO_STATUS_BLOCK, ByVal pInfoBlock As IntPtr, ByVal length As UInteger, ByVal fileInformation As FILE_INFORMATION_CLASS) As IntPtr
static extern IntPtr NtQueryInformationFile(SafeFileHandle fileHandle, ref IO_STATUS_BLOCK IoStatusBlock, IntPtr pInfoBlock, uint length, FILE_INFORMATION_CLASS fileInformation); gdi3254: EnumFontFamilies
int[] fsUsb;
int[] fsUsb; user3257: SB_GETTEXT
public class StatusBar
public StatusBar(IntPtr hWnd)
hProcess = StatusBar.OpenProcess(ProcessAccessTypes.PROCESS_ALL_ACCESS, false, this.OwningPID);
allocated = StatusBar.VirtualAllocEx(hProcess, IntPtr.Zero, length, (VirtualAllocExTypes.MEM_COMMIT_OR_RESERVE), AccessProtectionFlags.PAGE_READWRITE);
StatusBar.SendMessage(this._handle, SB_GETTEXT, (IntPtr)index, allocated);
bool success = StatusBar.ReadProcessMemory(hProcess, allocated, buffer, length, out bytesRead);
StatusBar.VirtualFreeEx(hProcess, allocated, 0, VirtualAllocExTypes.MEM_RELEASE);
StatusBar.CloseHandle(hProcess);
StatusBar.GetWindowThreadProcessId(this._handle, out pid); kernel32
public static bool WriteUSB(IntPtr hDevice, byte[] pBuffer, uint dwBytesToWrite, ref uint lpNumberOfBytesWritten)
' if no Volume GUID passed to sub, use the one corresponding to my USB stick
' if no Volume GUID passed to sub, use the one corresponding to my USB stick Cut off search results after 60. Please refine your search. |