[usb] Fix Code Analysis Warnings
This commit is contained in:
Родитель
6b8cbe40b8
Коммит
80cc22cbde
|
@ -21,10 +21,10 @@ Environment:
|
|||
|
||||
--*/
|
||||
|
||||
|
||||
|
||||
#include <DriverSpecs.h>
|
||||
_Analysis_mode_(_Analysis_code_type_user_code_)
|
||||
|
||||
_Analysis_mode_(_Analysis_code_type_user_code_)
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <conio.h>
|
||||
|
@ -37,7 +37,7 @@ _Analysis_mode_(_Analysis_code_type_user_code_)
|
|||
#include "public.h"
|
||||
#include "strsafe.h"
|
||||
|
||||
#pragma warning(disable:4200) //
|
||||
#pragma warning(disable:4200) //
|
||||
#pragma warning(disable:4201) // nameless struct/union
|
||||
#pragma warning(disable:4214) // bit field types other than int
|
||||
|
||||
|
@ -48,7 +48,7 @@ _Analysis_mode_(_Analysis_code_type_user_code_)
|
|||
#pragma warning(default:4200)
|
||||
#pragma warning(default:4201)
|
||||
#pragma warning(default:4214)
|
||||
|
||||
|
||||
|
||||
#define NOISY(_x_) printf _x_ ;
|
||||
#define MAX_LENGTH 256
|
||||
|
@ -160,8 +160,8 @@ Return Value:
|
|||
|
||||
|
||||
HANDLE
|
||||
OpenUsbDevice(
|
||||
_In_ LPGUID pGuid,
|
||||
OpenUsbDevice(
|
||||
_In_ LPGUID pGuid,
|
||||
_In_ PSTR outNameBuf
|
||||
)
|
||||
/*++
|
||||
|
@ -197,10 +197,10 @@ Return Value:
|
|||
|
||||
//
|
||||
// Open a handle to the plug and play dev node.
|
||||
// SetupDiGetClassDevs() returns a device information set that contains
|
||||
// SetupDiGetClassDevs() returns a device information set that contains
|
||||
// info on all installed devices of a specified class.
|
||||
//
|
||||
hardwareDeviceInfo =
|
||||
hardwareDeviceInfo =
|
||||
SetupDiGetClassDevs ( pGuid,
|
||||
NULL, // Define no enumerator (global)
|
||||
NULL, // Define no
|
||||
|
@ -247,10 +247,10 @@ Return Value:
|
|||
}
|
||||
|
||||
for (; i < NumberDevices; i++) {
|
||||
// SetupDiEnumDeviceInterfaces() returns information about device
|
||||
// interfaces exposed by one or more devices. Each call returns
|
||||
// information about one interface; the routine can be called
|
||||
// repeatedly to get information about several interfaces exposed
|
||||
// SetupDiEnumDeviceInterfaces() returns information about device
|
||||
// interfaces exposed by one or more devices. Each call returns
|
||||
// information about one interface; the routine can be called
|
||||
// repeatedly to get information about several interfaces exposed
|
||||
// by one or more devices.
|
||||
|
||||
if (SetupDiEnumDeviceInterfaces (hardwareDeviceInfo,
|
||||
|
@ -285,8 +285,8 @@ Return Value:
|
|||
|
||||
|
||||
BOOL
|
||||
GetUsbDeviceFileName(
|
||||
_In_ LPGUID pGuid,
|
||||
GetUsbDeviceFileName(
|
||||
_In_ LPGUID pGuid,
|
||||
_In_ PSTR outNameBuf
|
||||
)
|
||||
/*++
|
||||
|
@ -334,14 +334,14 @@ Return Value:
|
|||
|
||||
--*/
|
||||
{
|
||||
HANDLE hDEV = OpenUsbDevice( (LPGUID)&GUID_CLASS_USBSAMP_USB,
|
||||
HANDLE hDEV = OpenUsbDevice( (LPGUID)&GUID_CLASS_USBSAMP_USB,
|
||||
completeDeviceName);
|
||||
|
||||
if (hDEV == INVALID_HANDLE_VALUE) {
|
||||
printf("Failed to open (%s) = %u", completeDeviceName, GetLastError());
|
||||
} else {
|
||||
printf("DeviceName = (%s)\n", completeDeviceName);
|
||||
}
|
||||
}
|
||||
|
||||
return hDEV;
|
||||
|
||||
|
@ -349,7 +349,7 @@ Return Value:
|
|||
|
||||
|
||||
HANDLE
|
||||
open_file(
|
||||
open_file(
|
||||
_In_ PSTR filename
|
||||
)
|
||||
/*++
|
||||
|
@ -378,7 +378,7 @@ Return Value:
|
|||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
(void) StringCchCat (completeDeviceName, MAX_LENGTH, "\\" );
|
||||
(void) StringCchCat (completeDeviceName, MAX_LENGTH, "\\" );
|
||||
|
||||
if(FAILED(StringCchCat (completeDeviceName, MAX_LENGTH, filename))) {
|
||||
NOISY(("Failed to open handle - possibly long filename\n"));
|
||||
|
@ -400,7 +400,7 @@ Return Value:
|
|||
success = 0;
|
||||
} else {
|
||||
NOISY(("Opened successfully.\n"));
|
||||
}
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ Return Value:
|
|||
void
|
||||
parse(
|
||||
_In_ int argc,
|
||||
_In_reads_(argc) char *argv[]
|
||||
_In_reads_(argc) char *argv[]
|
||||
)
|
||||
/*++
|
||||
Routine Description:
|
||||
|
@ -565,8 +565,8 @@ Return Value:
|
|||
|
||||
BOOL
|
||||
compare_buffs(
|
||||
_In_reads_bytes_(length) char *buff1,
|
||||
_In_reads_bytes_(length) char *buff2,
|
||||
_In_reads_bytes_(length) char *buff1,
|
||||
_In_reads_bytes_(length) char *buff2,
|
||||
_In_ int length
|
||||
)
|
||||
/*++
|
||||
|
@ -668,29 +668,29 @@ Return Value:
|
|||
|
||||
case USB_CONFIGURATION_DESCRIPTOR_TYPE:
|
||||
return "USB_CONFIGURATION_DESCRIPTOR_TYPE";
|
||||
|
||||
|
||||
|
||||
case USB_STRING_DESCRIPTOR_TYPE:
|
||||
return "USB_STRING_DESCRIPTOR_TYPE";
|
||||
|
||||
|
||||
|
||||
case USB_INTERFACE_DESCRIPTOR_TYPE:
|
||||
return "USB_INTERFACE_DESCRIPTOR_TYPE";
|
||||
|
||||
|
||||
|
||||
case USB_ENDPOINT_DESCRIPTOR_TYPE:
|
||||
return "USB_ENDPOINT_DESCRIPTOR_TYPE";
|
||||
|
||||
case USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_TYPE:
|
||||
return "USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_TYPE";
|
||||
|
||||
|
||||
|
||||
#ifdef USB_POWER_DESCRIPTOR_TYPE // this is the older definintion which is actually obsolete
|
||||
// workaround for temporary bug in 98ddk, older USB100.h file
|
||||
case USB_POWER_DESCRIPTOR_TYPE:
|
||||
return "USB_POWER_DESCRIPTOR_TYPE";
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USB_RESERVED_DESCRIPTOR_TYPE // this is the current version of USB100.h as in NT5DDK
|
||||
|
||||
case USB_RESERVED_DESCRIPTOR_TYPE:
|
||||
|
@ -704,7 +704,7 @@ Return Value:
|
|||
#endif // for current nt5ddk version of USB100.h
|
||||
|
||||
default:
|
||||
return "??? UNKNOWN!!";
|
||||
return "??? UNKNOWN!!";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -734,16 +734,16 @@ Return Value:
|
|||
return "USB_ENDPOINT_TYPE_INTERRUPT";
|
||||
|
||||
case USB_ENDPOINT_TYPE_BULK:
|
||||
return "USB_ENDPOINT_TYPE_BULK";
|
||||
return "USB_ENDPOINT_TYPE_BULK";
|
||||
|
||||
case USB_ENDPOINT_TYPE_ISOCHRONOUS:
|
||||
return "USB_ENDPOINT_TYPE_ISOCHRONOUS";
|
||||
return "USB_ENDPOINT_TYPE_ISOCHRONOUS";
|
||||
|
||||
case USB_ENDPOINT_TYPE_CONTROL:
|
||||
return "USB_ENDPOINT_TYPE_CONTROL";
|
||||
return "USB_ENDPOINT_TYPE_CONTROL";
|
||||
|
||||
default:
|
||||
return "??? UNKNOWN!!";
|
||||
return "??? UNKNOWN!!";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -775,13 +775,13 @@ Return Value:
|
|||
|
||||
case USB_CONFIG_SELF_POWERED:
|
||||
return "USB_CONFIG_SELF_POWERED";
|
||||
|
||||
|
||||
case USB_CONFIG_REMOTE_WAKEUP:
|
||||
return "USB_CONFIG_REMOTE_WAKEUP";
|
||||
|
||||
|
||||
|
||||
default:
|
||||
return "??? UNKNOWN!!";
|
||||
return "??? UNKNOWN!!";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -933,7 +933,7 @@ Return Value:
|
|||
);
|
||||
}
|
||||
|
||||
printf(
|
||||
printf(
|
||||
"bmAttributes= 0x%x ( %s )\n", ed->bmAttributes, usbEndPointTypeString ( ed->bmAttributes )
|
||||
);
|
||||
|
||||
|
@ -1024,7 +1024,7 @@ Return Value:
|
|||
NOISY(("DEV not open"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
success = DeviceIoControl(hDEV,
|
||||
IOCTL_USBSAMP_GET_CONFIG_DESCRIPTOR,
|
||||
buf,
|
||||
|
@ -1035,7 +1035,7 @@ Return Value:
|
|||
NULL);
|
||||
|
||||
NOISY(("request complete, success = %u nBytes = %d\n", success, nBytes));
|
||||
|
||||
|
||||
if (success) {
|
||||
|
||||
UINT j = 0, k = 0, n;
|
||||
|
@ -1078,7 +1078,7 @@ Return Value:
|
|||
}
|
||||
j = 0;
|
||||
k = 0;
|
||||
print_USB_INTERFACE_DESCRIPTOR((PUSB_INTERFACE_DESCRIPTOR)commonDesc, n++);
|
||||
print_USB_INTERFACE_DESCRIPTOR((PUSB_INTERFACE_DESCRIPTOR)commonDesc, n++);
|
||||
break;
|
||||
|
||||
case USB_ENDPOINT_DESCRIPTOR_TYPE:
|
||||
|
@ -1104,7 +1104,7 @@ Return Value:
|
|||
default:
|
||||
displayUnknown = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (displayUnknown)
|
||||
{
|
||||
|
@ -1113,10 +1113,10 @@ Return Value:
|
|||
|
||||
commonDesc = (PUSB_COMMON_DESCRIPTOR)((PUCHAR)commonDesc + commonDesc->bLength);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1154,8 +1154,8 @@ Return Value:
|
|||
|
||||
|
||||
|
||||
int
|
||||
_cdecl
|
||||
int
|
||||
_cdecl
|
||||
main(
|
||||
_In_ int argc,
|
||||
_In_reads_(argc) char *argv[]
|
||||
|
@ -1212,6 +1212,9 @@ Return Value:
|
|||
|
||||
hRead = open_file( inPipe);
|
||||
pinBuf = (char*) malloc(ReadLen);
|
||||
if (pinBuf == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1224,6 +1227,9 @@ Return Value:
|
|||
|
||||
hWrite = open_file( outPipe);
|
||||
poutBuf = (char*)malloc(WriteLen);
|
||||
if (poutBuf == NULL) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0; i<IterationCount; i++) {
|
||||
|
@ -1254,32 +1260,32 @@ Return Value:
|
|||
if (fRead && pinBuf) {
|
||||
|
||||
success = ReadFile(hRead, pinBuf, ReadLen, (PULONG) &nBytesRead, NULL);
|
||||
|
||||
if (success) {
|
||||
|
||||
if (success) {
|
||||
printf("<%s> R (%04.4u) : request %06.6d bytes -- %06.6d bytes read\n",
|
||||
inPipe, i, ReadLen, nBytesRead);
|
||||
|
||||
|
||||
if (fWrite && fCompareData) {
|
||||
|
||||
|
||||
//
|
||||
// validate the input buffer against what
|
||||
// we sent to the device (loopback test)
|
||||
//
|
||||
#pragma warning(suppress: 26053)
|
||||
ok = compare_buffs(pinBuf, poutBuf, nBytesRead);
|
||||
|
||||
|
||||
if( fDumpReadData ) {
|
||||
printf("Dumping read buffer\n");
|
||||
dump( (PUCHAR) pinBuf, nBytesRead );
|
||||
dump( (PUCHAR) pinBuf, nBytesRead );
|
||||
printf("Dumping write buffer\n");
|
||||
dump( (PUCHAR) poutBuf, nBytesRead );
|
||||
}
|
||||
assert(ok);
|
||||
|
||||
|
||||
if(ok != 1) {
|
||||
fail++;
|
||||
}
|
||||
|
||||
|
||||
assert(ReadLen == WriteLen);
|
||||
assert(nBytesRead == ReadLen);
|
||||
}
|
||||
|
@ -1301,7 +1307,7 @@ Return Value:
|
|||
|
||||
if(hWrite != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(hWrite);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ Environment:
|
|||
#pragma alloc_text(PAGE, RetrieveDeviceInformation)
|
||||
#pragma alloc_text(PAGE, UsbSamp_ValidateConfigurationDescriptor)
|
||||
#if (NTDDI_VERSION >= NTDDI_WIN8)
|
||||
#pragma alloc_text(PAGE, UsbSamp_EvtPipeContextCleanup)
|
||||
#pragma alloc_text(PAGE, InitializePipeContextForSuperSpeedDevice)
|
||||
#pragma alloc_text(PAGE, GetEndpointDescriptorForEndpointAddress)
|
||||
#pragma alloc_text(PAGE, InitializePipeContextForSuperSpeedIsochPipe)
|
||||
|
@ -199,7 +198,7 @@ Return Value:
|
|||
|
||||
//
|
||||
// Register I/O callbacks to tell the framework that you are interested
|
||||
// in handling WdfRequestTypeRead, WdfRequestTypeWrite, and
|
||||
// in handling WdfRequestTypeRead, WdfRequestTypeWrite, and
|
||||
// IRP_MJ_DEVICE_CONTROL requests.
|
||||
// WdfIoQueueDispatchParallel means that we are capable of handling
|
||||
// all the I/O request simultaneously and we are responsible for protecting
|
||||
|
@ -233,12 +232,12 @@ Return Value:
|
|||
//
|
||||
WDF_IO_QUEUE_CONFIG_INIT(&ioQueueConfig,
|
||||
WdfIoQueueDispatchManual);
|
||||
|
||||
|
||||
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
|
||||
attributes.SynchronizationScope=WdfSynchronizationScopeQueue;
|
||||
|
||||
|
||||
ioQueueConfig.EvtIoStop = UsbSamp_EvtIoStop;
|
||||
|
||||
|
||||
status = WdfIoQueueCreate(device,
|
||||
&ioQueueConfig,
|
||||
&attributes,
|
||||
|
@ -255,7 +254,7 @@ Return Value:
|
|||
status = WdfIoQueueReadyNotify(pDevContext->IsochReadQueue,
|
||||
UsbSamp_EvtIoQueueReadyNotification,
|
||||
(WDFCONTEXT)pDevContext);
|
||||
|
||||
|
||||
if (!NT_SUCCESS(status)) {
|
||||
UsbSamp_DbgPrint(1, ("WdfIoQueueReadyNotify failed for isoch 0x%x\n", status));
|
||||
return status;
|
||||
|
@ -267,12 +266,12 @@ Return Value:
|
|||
//
|
||||
WDF_IO_QUEUE_CONFIG_INIT(&ioQueueConfig,
|
||||
WdfIoQueueDispatchManual);
|
||||
|
||||
|
||||
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
|
||||
attributes.SynchronizationScope=WdfSynchronizationScopeQueue;
|
||||
|
||||
|
||||
ioQueueConfig.EvtIoStop = UsbSamp_EvtIoStop;
|
||||
|
||||
|
||||
status = WdfIoQueueCreate(device,
|
||||
&ioQueueConfig,
|
||||
&attributes,
|
||||
|
@ -289,12 +288,12 @@ Return Value:
|
|||
status = WdfIoQueueReadyNotify(pDevContext->IsochWriteQueue,
|
||||
UsbSamp_EvtIoQueueReadyNotification,
|
||||
(WDFCONTEXT)pDevContext);
|
||||
|
||||
|
||||
if (!NT_SUCCESS(status)) {
|
||||
UsbSamp_DbgPrint(1, ("WdfIoQueueReadyNotify failed for isoch 0x%x\n", status));
|
||||
return status;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Register a device interface so that app can find our device and talk to it.
|
||||
//
|
||||
|
@ -306,11 +305,11 @@ Return Value:
|
|||
return status;
|
||||
}
|
||||
|
||||
status = USBD_CreateHandle(WdfDeviceWdmGetDeviceObject(device),
|
||||
WdfDeviceWdmGetAttachedDevice(device),
|
||||
USBD_CLIENT_CONTRACT_VERSION_602,
|
||||
POOL_TAG,
|
||||
&pDevContext->UsbdHandle);
|
||||
status = USBD_CreateHandle(WdfDeviceWdmGetDeviceObject(device),
|
||||
WdfDeviceWdmGetAttachedDevice(device),
|
||||
USBD_CLIENT_CONTRACT_VERSION_602,
|
||||
POOL_TAG,
|
||||
&pDevContext->UsbdHandle);
|
||||
if(!NT_SUCCESS(status)){
|
||||
UsbSamp_DbgPrint(1, ("USBD_CreateHandle failed 0x%x", status));
|
||||
return status;
|
||||
|
@ -470,10 +469,10 @@ Return Value:
|
|||
//
|
||||
if (pDeviceContext->WdfUsbTargetDevice == NULL) {
|
||||
WDF_USB_DEVICE_CREATE_CONFIG config;
|
||||
|
||||
|
||||
WDF_USB_DEVICE_CREATE_CONFIG_INIT(&config,
|
||||
USBD_CLIENT_CONTRACT_VERSION_602);
|
||||
|
||||
|
||||
status = WdfUsbTargetDeviceCreateWithParameters(Device,
|
||||
&config,
|
||||
WDF_NO_OBJECT_ATTRIBUTES,
|
||||
|
@ -483,14 +482,14 @@ Return Value:
|
|||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WdfUsbTargetDeviceGetDeviceDescriptor(pDeviceContext->WdfUsbTargetDevice,
|
||||
&pDeviceContext->UsbDeviceDescriptor);
|
||||
|
||||
NT_ASSERT(pDeviceContext->UsbDeviceDescriptor.bNumConfigurations);
|
||||
|
||||
status = ConfigureDevice(Device);
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -572,9 +571,9 @@ Return Value:
|
|||
|
||||
//
|
||||
// Check if the descriptors are valid
|
||||
//
|
||||
//
|
||||
status = UsbSamp_ValidateConfigurationDescriptor(configurationDescriptor, size , &Offset);
|
||||
|
||||
|
||||
if (!NT_SUCCESS(status)) {
|
||||
UsbSamp_DbgPrint(1, ("Descriptor validation failed with Status code %x and at the offset %p\n", status , Offset ));
|
||||
return status;
|
||||
|
@ -624,9 +623,9 @@ Return Value:
|
|||
//
|
||||
// The device has only one interface and the interface may have multiple
|
||||
// alternate settings. It will try to use alternate setting zero if it has
|
||||
// non-zero endpoints, otherwise it will try to search an alternate
|
||||
// non-zero endpoints, otherwise it will try to search an alternate
|
||||
// setting with non-zero endpoints.
|
||||
//
|
||||
//
|
||||
|
||||
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_SINGLE_INTERFACE( &configParams);
|
||||
|
||||
|
@ -667,7 +666,7 @@ Return Value:
|
|||
numberConfiguredPipes = 0;
|
||||
|
||||
for (i = 0; i < numberAlternateSettings && numberConfiguredPipes == 0; i++) {
|
||||
|
||||
|
||||
WDF_USB_INTERFACE_SELECT_SETTING_PARAMS_INIT_SETTING(&selectSettingParams, i);
|
||||
|
||||
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&pipeAttributes, PIPE_CONTEXT);
|
||||
|
@ -680,19 +679,19 @@ Return Value:
|
|||
&pipeAttributes,
|
||||
&selectSettingParams
|
||||
);
|
||||
|
||||
|
||||
if (NT_SUCCESS(status)) {
|
||||
|
||||
|
||||
numberConfiguredPipes = WdfUsbInterfaceGetNumConfiguredPipes(pDeviceContext->UsbInterface);
|
||||
|
||||
if (numberConfiguredPipes > 0){
|
||||
|
||||
|
||||
pDeviceContext->SelectedAlternateSetting = i;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
pDeviceContext->NumberConfiguredPipes = numberConfiguredPipes;
|
||||
|
@ -711,21 +710,21 @@ Return Value:
|
|||
}
|
||||
else if (pDeviceContext->IsDeviceHighSpeed) {
|
||||
status = InitializePipeContextForHighSpeedDevice(pipe);
|
||||
}
|
||||
}
|
||||
else {
|
||||
status = InitializePipeContextForFullSpeedDevice(pipe);
|
||||
}
|
||||
#else
|
||||
if (pDeviceContext->IsDeviceHighSpeed) {
|
||||
status = InitializePipeContextForHighSpeedDevice(pipe);
|
||||
}
|
||||
}
|
||||
else {
|
||||
status = InitializePipeContextForFullSpeedDevice(pipe);
|
||||
}
|
||||
#endif
|
||||
if (!NT_SUCCESS(status)) {
|
||||
UsbSamp_DbgPrint(1, ("InitializePipeContext failed %x\n", status));
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -822,7 +821,7 @@ Return Value:
|
|||
|
||||
WDF_USB_PIPE_INFORMATION_INIT(&pipeInfo);
|
||||
WdfUsbTargetPipeGetInformation(Pipe, &pipeInfo);
|
||||
|
||||
|
||||
//
|
||||
// We only use pipe context for super speed isoch and bulk speed bulk endpoints.
|
||||
//
|
||||
|
@ -839,9 +838,9 @@ Return Value:
|
|||
Pipe);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -893,11 +892,11 @@ Return Value:
|
|||
|
||||
*ppEndpointCompanionDescriptor = NULL;
|
||||
|
||||
//
|
||||
//
|
||||
// Parse the ConfigurationDescriptor (including all Interface and
|
||||
// Endpoint Descriptors) and locate a Interface Descriptor which
|
||||
// matches the InterfaceNumber, AlternateSetting, InterfaceClass,
|
||||
// InterfaceSubClass, and InterfaceProtocol parameters.
|
||||
// InterfaceSubClass, and InterfaceProtocol parameters.
|
||||
//
|
||||
pInterfaceDescriptor = USBD_ParseConfigurationDescriptorEx(
|
||||
pConfigurationDescriptor,
|
||||
|
@ -919,7 +918,7 @@ Return Value:
|
|||
startingPosition = (PUCHAR) pInterfaceDescriptor;
|
||||
|
||||
for(index = 0; index < pInterfaceDescriptor->bNumEndpoints; index++) {
|
||||
|
||||
|
||||
pCommonDescriptorHeader = USBD_ParseDescriptors(pConfigurationDescriptor,
|
||||
pConfigurationDescriptor->wTotalLength,
|
||||
startingPosition,
|
||||
|
@ -929,12 +928,12 @@ Return Value:
|
|||
|
||||
UsbSamp_DbgPrint(1, ("USBD_ParseDescriptors failed to retrieve SuperSpeed Endpoint Descriptor unexpectedly\n"));
|
||||
goto End;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// UsbSamp_ValidateConfigurationDescriptor validates all descriptors.
|
||||
// This means that the descriptor pointed to by pCommonDescriptorHeader( received above ) is completely
|
||||
// This means that the descriptor pointed to by pCommonDescriptorHeader( received above ) is completely
|
||||
// contained within the buffer representing ConfigurationDescriptor and
|
||||
// it also verifies that pCommonDescriptorHeader->bLength is equal to sizeof(USB_ENDPOINT_DESCRIPTOR).
|
||||
//
|
||||
|
@ -945,18 +944,18 @@ Return Value:
|
|||
// Search an Endpoint Descriptor that matches the EndpointAddress
|
||||
//
|
||||
if (pEndpointDescriptor->bEndpointAddress == EndpointAddress){
|
||||
|
||||
|
||||
found = TRUE;
|
||||
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Skip the current Endpoint Descriptor and search for the next.
|
||||
//
|
||||
startingPosition = (PUCHAR)pCommonDescriptorHeader + pCommonDescriptorHeader->bLength;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (found) {
|
||||
|
@ -969,26 +968,26 @@ Return Value:
|
|||
USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_TYPE);
|
||||
|
||||
if (pCommonDescriptorHeader != NULL) {
|
||||
|
||||
|
||||
//
|
||||
// UsbSamp_ValidateConfigurationDescriptor validates all descriptors.
|
||||
// This means that the descriptor pointed to by pCommonDescriptorHeader( received above ) is completely
|
||||
// This means that the descriptor pointed to by pCommonDescriptorHeader( received above ) is completely
|
||||
// contained within the buffer representing ConfigurationDescriptor and
|
||||
// it also verifies that pCommonDescriptorHeader->bLength is >= sizeof(USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR)
|
||||
//
|
||||
|
||||
*ppEndpointCompanionDescriptor =
|
||||
|
||||
*ppEndpointCompanionDescriptor =
|
||||
(PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR) pCommonDescriptorHeader;
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
UsbSamp_DbgPrint(3, ("USBD_ParseDescriptors failed to retrieve SuperSpeed Endpoint Companion Descriptor unexpectedly\n"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
End:
|
||||
return pEndpointDescriptor;
|
||||
}
|
||||
|
@ -1018,7 +1017,7 @@ Return Value:
|
|||
-*/
|
||||
{
|
||||
WDF_USB_PIPE_INFORMATION pipeInfo;
|
||||
PPIPE_CONTEXT pipeContext;
|
||||
PPIPE_CONTEXT pipeContext;
|
||||
UCHAR endpointAddress;
|
||||
PUSB_ENDPOINT_DESCRIPTOR pEndpointDescriptor;
|
||||
PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR pEndpointCompanionDescriptor;
|
||||
|
@ -1032,7 +1031,7 @@ Return Value:
|
|||
|
||||
WDF_USB_PIPE_INFORMATION_INIT(&pipeInfo);
|
||||
WdfUsbTargetPipeGetInformation(Pipe, &pipeInfo);
|
||||
|
||||
|
||||
//
|
||||
// We use the pipe context only for isoch endpoints.
|
||||
//
|
||||
|
@ -1053,17 +1052,17 @@ Return Value:
|
|||
&pEndpointCompanionDescriptor);
|
||||
|
||||
if (pEndpointDescriptor == NULL || pEndpointCompanionDescriptor == NULL ){
|
||||
|
||||
|
||||
UsbSamp_DbgPrint(1, ("pEndpointDescriptor or pEndpointCompanionDescriptor is invalid (NULL)\n"));
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// For SuperSpeed isoch endpoint, it uses wBytesPerInterval from its
|
||||
// endpoint companion descriptor. If bMaxBurst field in its endpoint
|
||||
// companion descriptor is greater than zero, wMaxPacketSize must be
|
||||
// 1024. If the value in the bMaxBurst field is set to zero then
|
||||
// 1024. If the value in the bMaxBurst field is set to zero then
|
||||
// wMaxPacketSize can have any value from 0 to 1024.
|
||||
//
|
||||
wBytesPerInterval = pEndpointCompanionDescriptor->wBytesPerInterval;
|
||||
|
@ -1072,7 +1071,7 @@ Return Value:
|
|||
bMult = pEndpointCompanionDescriptor->bmAttributes.Isochronous.Mult;
|
||||
|
||||
if (wBytesPerInterval > (wMaxPacketSize * (bMaxBurst + 1) * (bMult + 1))){
|
||||
|
||||
|
||||
UsbSamp_DbgPrint(1, ("SuperSpeed isochronouse endpoints's wBytesPerInterval value (%d) is greater than wMaxPacketSize * (bMaxBurst+1) * (Mult +1) (%d) \n",
|
||||
wBytesPerInterval, (wMaxPacketSize * (bMaxBurst + 1) * (bMult + 1))));
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
@ -1081,13 +1080,13 @@ Return Value:
|
|||
|
||||
if (bMaxBurst > 0){
|
||||
|
||||
if (wMaxPacketSize != USB_ENDPOINT_SUPERSPEED_ISO_MAX_PACKET_SIZE){
|
||||
|
||||
if (wMaxPacketSize != USB_ENDPOINT_SUPERSPEED_ISO_MAX_PACKET_SIZE){
|
||||
|
||||
UsbSamp_DbgPrint(1, ("SuperSpeed isochronouse endpoints must have wMaxPacketSize value of %d bytes when bMaxpBurst is %d \n",
|
||||
USB_ENDPOINT_SUPERSPEED_ISO_MAX_PACKET_SIZE, bMaxBurst));
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -1097,24 +1096,24 @@ Return Value:
|
|||
USB_ENDPOINT_SUPERSPEED_ISO_MAX_PACKET_SIZE, bMaxBurst));
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// This sample demos how to use wBytesPerInterval from its Endpoint
|
||||
// This sample demos how to use wBytesPerInterval from its Endpoint
|
||||
// Companion Descriptor. Actaully, for Superspeed isochronous endpoints,
|
||||
// MaximumPacketSize in WDF_USB_PIPE_INFORMATION and USBD_PIPE_INFORMATION
|
||||
// is returned with the value of wBytesPerInterval in the endpoint
|
||||
// companion descriptor. This is different than the true MaxPacketSize of
|
||||
// the endpoint descriptor.
|
||||
//
|
||||
NT_ASSERT(pipeInfo.MaximumPacketSize == wBytesPerInterval);
|
||||
NT_ASSERT(pipeInfo.MaximumPacketSize == wBytesPerInterval);
|
||||
pipeContext->TransferSizePerMicroframe = wBytesPerInterval;
|
||||
|
||||
|
||||
//
|
||||
// Microsoft USB 3.0 stack only supports bInterval value of 1, 2, 3 and 4
|
||||
// Microsoft USB 3.0 stack only supports bInterval value of 1, 2, 3 and 4
|
||||
// (or polling period of 1, 2, 4 and 8).
|
||||
// For super-speed isochronous endpoints, the bInterval value is used as
|
||||
// the exponent for a 2^(bInterval-1) value expressed in microframes;
|
||||
|
@ -1157,14 +1156,14 @@ Return Value:
|
|||
break;
|
||||
}
|
||||
|
||||
UsbSamp_DbgPrint(1, ("MaxPacketSize = %d, bInterval = %d\n",
|
||||
UsbSamp_DbgPrint(1, ("MaxPacketSize = %d, bInterval = %d\n",
|
||||
pipeInfo.MaximumPacketSize,
|
||||
pipeInfo.Interval));
|
||||
|
||||
UsbSamp_DbgPrint(1, ("TransferSizePerFrame = %d, TransferSizePerMicroframe = %d\n",
|
||||
pipeContext->TransferSizePerFrame,
|
||||
pipeContext->TransferSizePerMicroframe));
|
||||
|
||||
UsbSamp_DbgPrint(1, ("TransferSizePerFrame = %d, TransferSizePerMicroframe = %d\n",
|
||||
pipeContext->TransferSizePerFrame,
|
||||
pipeContext->TransferSizePerMicroframe));
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1198,23 +1197,23 @@ Return Value:
|
|||
|
||||
WDF_USB_PIPE_INFORMATION_INIT(&pipeInfo);
|
||||
WdfUsbTargetPipeGetInformation(Pipe, &pipeInfo);
|
||||
|
||||
|
||||
//
|
||||
// We use the pipe context only for isoch endpoints.
|
||||
//
|
||||
if ((WdfUsbPipeTypeIsochronous != pipeInfo.PipeType)) {
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
pipeContext = GetPipeContext(Pipe);
|
||||
|
||||
|
||||
if (pipeInfo.MaximumPacketSize == 0) {
|
||||
UsbSamp_DbgPrint(1, ("MaximumPacketSize in the pipeInfo is invalid (zero)\n"));
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Universal Serial Bus Specification Revision 2.0 5.6.3 Isochronous Transfer
|
||||
// Universal Serial Bus Specification Revision 2.0 5.6.3 Isochronous Transfer
|
||||
// Packet Size Constraints: High-speed endpoints are allowed up to 1024-byte data
|
||||
// payloads per microframe and allowed up to a maximum of 3 transactions per microframe.
|
||||
//
|
||||
|
@ -1225,7 +1224,7 @@ Return Value:
|
|||
// 10 - 2 additional (3 per microframe)
|
||||
// 11 - Reserved.
|
||||
//
|
||||
// Note: MaximumPacketSize of WDF_USB_PIPE_INFORMATION is already adjusted to include
|
||||
// Note: MaximumPacketSize of WDF_USB_PIPE_INFORMATION is already adjusted to include
|
||||
// additional transactions if it is a high bandwidth pipe.
|
||||
//
|
||||
|
||||
|
@ -1236,7 +1235,7 @@ Return Value:
|
|||
|
||||
//
|
||||
// Microsoft USB stack only supports bInterval value of 1, 2, 3 and 4 (or polling period of 1, 2, 4 and 8).
|
||||
//
|
||||
//
|
||||
if (pipeInfo.Interval == 0 || pipeInfo.Interval > 4) {
|
||||
UsbSamp_DbgPrint(1, ("bInterval value in pipeInfo is invalid (0 or > 4)\n"));
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
@ -1282,14 +1281,14 @@ Return Value:
|
|||
break;
|
||||
}
|
||||
|
||||
UsbSamp_DbgPrint(1, ("MaxPacketSize = %d, bInterval = %d\n",
|
||||
UsbSamp_DbgPrint(1, ("MaxPacketSize = %d, bInterval = %d\n",
|
||||
pipeInfo.MaximumPacketSize,
|
||||
pipeInfo.Interval));
|
||||
|
||||
UsbSamp_DbgPrint(1, ("TransferSizePerFrame = %d, TransferSizePerMicroframe = %d\n",
|
||||
pipeContext->TransferSizePerFrame,
|
||||
pipeContext->TransferSizePerMicroframe));
|
||||
|
||||
UsbSamp_DbgPrint(1, ("TransferSizePerFrame = %d, TransferSizePerMicroframe = %d\n",
|
||||
pipeContext->TransferSizePerFrame,
|
||||
pipeContext->TransferSizePerMicroframe));
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1321,14 +1320,14 @@ Return Value:
|
|||
|
||||
WDF_USB_PIPE_INFORMATION_INIT(&pipeInfo);
|
||||
WdfUsbTargetPipeGetInformation(Pipe, &pipeInfo);
|
||||
|
||||
|
||||
//
|
||||
// We use the pipe context only for isoch endpoints.
|
||||
//
|
||||
if ((WdfUsbPipeTypeIsochronous != pipeInfo.PipeType)) {
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
pipeContext = GetPipeContext(Pipe);
|
||||
|
||||
if (pipeInfo.MaximumPacketSize == 0) {
|
||||
|
@ -1351,7 +1350,7 @@ Return Value:
|
|||
//
|
||||
// Microsoft USB stack only supports bInterval value of 1 for
|
||||
// full-speed isochronous endpoints.
|
||||
//
|
||||
//
|
||||
if (pipeInfo.Interval != 1) {
|
||||
UsbSamp_DbgPrint(1, ("bInterval value in endpoint descriptor is invalid\n"));
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
@ -1360,8 +1359,8 @@ Return Value:
|
|||
pipeContext->TransferSizePerFrame = pipeInfo.MaximumPacketSize;
|
||||
pipeContext->TransferSizePerMicroframe = 0;
|
||||
|
||||
UsbSamp_DbgPrint(1, ("TransferSizePerFrame = %d\n", pipeContext->TransferSizePerFrame));
|
||||
|
||||
UsbSamp_DbgPrint(1, ("TransferSizePerFrame = %d\n", pipeContext->TransferSizePerFrame));
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1428,13 +1427,13 @@ RetrieveDeviceInformation(
|
|||
|
||||
if (pDeviceContext->IsStaticStreamsSupported) {
|
||||
UsbSamp_DbgPrint(3, ("Number of Streams supported by the controller: %d\n", numberOfStreams));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NTSTATUS
|
||||
ReadFdoRegistryKeyValue(
|
||||
_In_ WDFDRIVER Driver,
|
||||
|
@ -1457,7 +1456,7 @@ Arguments:
|
|||
|
||||
Return Value:
|
||||
|
||||
NTSTATUS
|
||||
NTSTATUS
|
||||
|
||||
--*/
|
||||
{
|
||||
|
@ -1513,6 +1512,11 @@ Return Value:
|
|||
WDFDEVICE device;
|
||||
PDEVICE_CONTEXT pDevContext;
|
||||
|
||||
//
|
||||
// EvtCleanupCallback for WDFDEVICE is always called at PASSIVE_LEVEL
|
||||
//
|
||||
_Analysis_assume_(KeGetCurrentIrql() == PASSIVE_LEVEL);
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
device = (WDFDEVICE)WdfDevice;
|
||||
|
@ -1526,7 +1530,7 @@ Return Value:
|
|||
}
|
||||
|
||||
USBD_STATUS
|
||||
UsbSamp_ValidateConfigurationDescriptor(
|
||||
UsbSamp_ValidateConfigurationDescriptor(
|
||||
_In_reads_bytes_(BufferLength) PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc,
|
||||
_In_ ULONG BufferLength,
|
||||
_Inout_ PUCHAR *Offset
|
||||
|
@ -1539,13 +1543,13 @@ Routine Description:
|
|||
|
||||
Parameters:
|
||||
|
||||
ConfigDesc: Pointer to the entire USB Configuration descriptor returned by
|
||||
ConfigDesc: Pointer to the entire USB Configuration descriptor returned by
|
||||
the device
|
||||
|
||||
BufferLength: Known size of buffer pointed to by ConfigDesc (Not wTotalLength)
|
||||
|
||||
Offset: if the USBD_STATUS returned is not USBD_STATUS_SUCCESS, offet will
|
||||
be set to the address within the ConfigDesc buffer where the failure
|
||||
be set to the address within the ConfigDesc buffer where the failure
|
||||
occured.
|
||||
|
||||
Return Value:
|
||||
|
@ -1568,7 +1572,7 @@ Return Value:
|
|||
// It also checks for interface numbers, number of endpoints in an interface etc.
|
||||
// Please refer to msdn documentation for this function for more information.
|
||||
//
|
||||
|
||||
|
||||
status = USBD_ValidateConfigurationDescriptor( ConfigDesc, BufferLength , ValidationLevel , Offset , POOL_TAG );
|
||||
if (!(NT_SUCCESS (status)) ){
|
||||
return status;
|
||||
|
@ -1576,12 +1580,12 @@ Return Value:
|
|||
|
||||
//
|
||||
// TODO: You should validate the correctness of other descriptors which are not taken care by USBD_ValidateConfigurationDescriptor
|
||||
// The below code loops through the configuration descriptor and verifies that all instances of
|
||||
// The below code loops through the configuration descriptor and verifies that all instances of
|
||||
// USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR have a size of >= USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR
|
||||
// You should put in more validations as per requirement
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
|
||||
|
||||
offset = ((PUCHAR)ConfigDesc) + ConfigDesc->bLength;
|
||||
end = ((PUCHAR)ConfigDesc) + ConfigDesc->wTotalLength;
|
||||
|
||||
|
@ -1590,12 +1594,12 @@ Return Value:
|
|||
//
|
||||
// Ensure the descriptor header is in bounds. We always
|
||||
// need to ensure we have enough data to look at the descriptor
|
||||
// header fields. Sometimes descriptors are zeroed at the end,
|
||||
// header fields. Sometimes descriptors are zeroed at the end,
|
||||
// this is OK.
|
||||
//
|
||||
commonDesc = (PUSB_COMMON_DESCRIPTOR)offset;
|
||||
|
||||
|
||||
|
||||
switch(commonDesc->bDescriptorType){
|
||||
|
||||
case USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_TYPE:
|
||||
|
@ -1621,7 +1625,7 @@ Return Value:
|
|||
}
|
||||
|
||||
ValidateConfigurationDescriptor_Done:
|
||||
|
||||
|
||||
if(!USBD_SUCCESS(status)){
|
||||
NT_ASSERT(index);
|
||||
*Offset = index;
|
||||
|
@ -1657,8 +1661,6 @@ Return Value:
|
|||
PPIPE_CONTEXT pPipeContext = NULL;
|
||||
PUSBSAMP_STREAM_INFO pStreamInfo = NULL;
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
pipe = (WDFUSBPIPE)WdfObject;
|
||||
pPipeContext = GetPipeContext(pipe);
|
||||
|
||||
|
@ -1669,6 +1671,5 @@ Return Value:
|
|||
ExFreePool(pStreamInfo->StreamList);
|
||||
pStreamInfo->StreamList = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -101,7 +101,7 @@ Return Value:
|
|||
WdfUsbTargetPipeSetNoMaximumPacketSizeCheck(pipe);
|
||||
|
||||
status = STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
else {
|
||||
status = STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
|
@ -161,6 +161,12 @@ Return Value:
|
|||
|
||||
UsbSamp_DbgPrint(3, ("Entered UsbSamp_DispatchDevCtrl\n"));
|
||||
|
||||
//
|
||||
// If your driver is at the top of its driver stack, EvtIoDeviceControl is called
|
||||
// at IRQL = PASSIVE_LEVEL.
|
||||
//
|
||||
_Analysis_assume_(KeGetCurrentIrql() == PASSIVE_LEVEL);
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
//
|
||||
|
@ -257,6 +263,12 @@ Return Value:
|
|||
WDFUSBPIPE pipe;
|
||||
WDF_USB_PIPE_INFORMATION pipeInfo;
|
||||
|
||||
//
|
||||
// If your driver is at the top of its driver stack, EvtIoRead is called
|
||||
// at IRQL = PASSIVE_LEVEL.
|
||||
//
|
||||
_Analysis_assume_(KeGetCurrentIrql() == PASSIVE_LEVEL);
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
//
|
||||
|
@ -278,7 +290,7 @@ Return Value:
|
|||
ReadWriteBulkEndPoints(Queue, Request, (ULONG) Length, WdfRequestTypeRead);
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
else if (WdfUsbPipeTypeIsochronous == pipeInfo.PipeType){
|
||||
|
||||
#if !defined(BUFFERED_READ_WRITE) // if doing DIRECT_IO
|
||||
|
@ -325,6 +337,12 @@ Return Value:
|
|||
WDFUSBPIPE pipe;
|
||||
WDF_USB_PIPE_INFORMATION pipeInfo;
|
||||
|
||||
//
|
||||
// If your driver is at the top of its driver stack, EvtIoWrite is called
|
||||
// at IRQL = PASSIVE_LEVEL.
|
||||
//
|
||||
_Analysis_assume_(KeGetCurrentIrql() == PASSIVE_LEVEL);
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
//
|
||||
|
@ -346,7 +364,7 @@ Return Value:
|
|||
ReadWriteBulkEndPoints(Queue, Request, (ULONG) Length, WdfRequestTypeWrite);
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
else if (WdfUsbPipeTypeIsochronous == pipeInfo.PipeType){
|
||||
|
||||
#if !defined(BUFFERED_READ_WRITE) // if doing DIRECT_IO
|
||||
|
@ -565,7 +583,7 @@ Return Value:
|
|||
PAGED_CODE();
|
||||
|
||||
pDeviceContext = GetDeviceContext(Device);
|
||||
|
||||
|
||||
//
|
||||
// A reset-device
|
||||
// request will be stuck in the USB until the pending transactions
|
||||
|
@ -576,7 +594,7 @@ Return Value:
|
|||
// continuous reader (by calling WdfIoTargetStart) after the request completes.
|
||||
//
|
||||
StopAllPipes(pDeviceContext);
|
||||
|
||||
|
||||
//
|
||||
// It may not be necessary to check whether device is connected before
|
||||
// resetting the port.
|
||||
|
@ -588,7 +606,7 @@ Return Value:
|
|||
}
|
||||
|
||||
StartAllPipes(pDeviceContext);
|
||||
|
||||
|
||||
UsbSamp_DbgPrint(3, ("ResetDevice - ends\n"));
|
||||
|
||||
return status;
|
||||
|
|
|
@ -200,7 +200,7 @@ Return Value:
|
|||
pStreamInfo->NumberOfStreams = supportedStreams;
|
||||
|
||||
pStreamInfo->StreamList = ExAllocatePoolWithTag(
|
||||
NonPagedPool,
|
||||
NonPagedPoolNx,
|
||||
supportedStreams * sizeof(USBD_STREAM_INFORMATION),
|
||||
POOL_TAG);
|
||||
|
||||
|
@ -230,6 +230,7 @@ Return Value:
|
|||
pUrb->UrbOpenStaticStreams.Streams = pStreamInfo->StreamList;
|
||||
|
||||
// Send the URB down the stack
|
||||
#pragma prefast(suppress:__WARNING_WRITE_OVERRUN, "SAL noise")
|
||||
status = WdfUsbTargetPipeSendUrbSynchronously(
|
||||
Pipe,
|
||||
NULL,
|
||||
|
|
|
@ -116,7 +116,7 @@ MyReAlloc (
|
|||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
header = (PALLOCHEADER)hMem;
|
||||
header--;
|
||||
|
||||
|
@ -135,6 +135,7 @@ MyReAlloc (
|
|||
// and the original handle and pointer are still valid.
|
||||
// Add the old address back to the allocation list.
|
||||
//
|
||||
#pragma prefast(suppress:__WARNING_USING_UNINIT_VAR, "SAL noise")
|
||||
InsertTailList(&AllocListHead, &header->ListEntry);
|
||||
}
|
||||
else
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -200,7 +200,7 @@ AddItemInformationToFile(
|
|||
|
||||
DWORD
|
||||
DisplayLastError(
|
||||
_Inout_updates_bytes_(count) char *szString,
|
||||
_Inout_updates_bytes_(count) char *szString,
|
||||
int count);
|
||||
|
||||
VOID AddItemInformationToXmlView(
|
||||
|
@ -221,7 +221,7 @@ HRESULT SaveAllInformationAsText(LPTSTR lpstrTextFileName, DWORD dwCreationDispo
|
|||
HRESULT SaveAllInformationAsXml(LPTSTR lpstrTextFileName , DWORD dwCreationDisposition);
|
||||
|
||||
/*****************************************************************************
|
||||
G L O B A L S
|
||||
G L O B A L S
|
||||
*****************************************************************************/
|
||||
BOOL gDoConfigDesc = TRUE;
|
||||
BOOL gDoAnnotation = TRUE;
|
||||
|
@ -345,7 +345,7 @@ WinMain (
|
|||
|
||||
ProcessCommandLine()
|
||||
|
||||
Parses the command line and takes appropriate actions. Returns FALSE If there is no action to
|
||||
Parses the command line and takes appropriate actions. Returns FALSE If there is no action to
|
||||
perform
|
||||
*****************************************************************************/
|
||||
BOOL ProcessCommandLine()
|
||||
|
@ -354,7 +354,7 @@ BOOL ProcessCommandLine()
|
|||
LPTSTR szArg = NULL;
|
||||
LPTSTR szAnsiArg= NULL;
|
||||
BOOL quietMode = FALSE;
|
||||
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
DWORD dwCreationDisposition = CREATE_NEW;
|
||||
USBVIEW_SAVE_FILE_TYPE fileType = UsbViewNone;
|
||||
|
@ -667,7 +667,7 @@ VOID DisplayMessage(DWORD dwResId, ...)
|
|||
}
|
||||
|
||||
dwLen = FormatMessage(
|
||||
FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||
FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||
szFormat,
|
||||
dwResId,
|
||||
0,
|
||||
|
@ -749,7 +749,7 @@ VOID PrintString(LPTSTR lpszString)
|
|||
return;
|
||||
}
|
||||
|
||||
if (gbConsoleFile)
|
||||
if (gbConsoleFile)
|
||||
{
|
||||
// Console has been redirected to a file, ex: `usbview /savexml:xx > test.txt`. We need to use WriteFile instead of
|
||||
// WriteConsole for text output.
|
||||
|
@ -1042,7 +1042,7 @@ USBView_OnInitDialog (
|
|||
|
||||
ghEditWnd = GetDlgItem(hWnd, IDC_EDIT);
|
||||
|
||||
#ifdef H264_SUPPORT
|
||||
#ifdef H264_SUPPORT
|
||||
// set the edit control to have a max text limit size
|
||||
SendMessage(ghEditWnd, EM_LIMITTEXT, 0 /* USE DEFAULT MAX*/, 0);
|
||||
#endif
|
||||
|
@ -1101,7 +1101,7 @@ USBView_OnClose (
|
|||
|
||||
AddItemInformationToFile()
|
||||
|
||||
Saves the information about the current item to the list
|
||||
Saves the information about the current item to the list
|
||||
*****************************************************************************/
|
||||
VOID
|
||||
AddItemInformationToFile(
|
||||
|
@ -1140,7 +1140,7 @@ SaveAllInformationAsText()
|
|||
|
||||
Saves the entire USB tree as a text file
|
||||
*****************************************************************************/
|
||||
HRESULT
|
||||
HRESULT
|
||||
SaveAllInformationAsText(
|
||||
LPTSTR lpstrTextFileName,
|
||||
DWORD dwCreationDisposition
|
||||
|
@ -1154,7 +1154,7 @@ SaveAllInformationAsText(
|
|||
0,
|
||||
NULL,
|
||||
dwCreationDisposition,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
|
||||
if (hf == INVALID_HANDLE_VALUE)
|
||||
|
@ -1702,10 +1702,10 @@ AboutDlgProc (
|
|||
|
||||
if (hItem != NULL)
|
||||
{
|
||||
hr = StringCbPrintfA(TextBuffer,
|
||||
hr = StringCbPrintfA(TextBuffer,
|
||||
sizeof(TextBuffer),
|
||||
"USBView version: %d.%d",
|
||||
USBVIEW_MAJOR_VERSION,
|
||||
"USBView version: %d.%d",
|
||||
USBVIEW_MAJOR_VERSION,
|
||||
USBVIEW_MINOR_VERSION);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
|
@ -1717,10 +1717,10 @@ AboutDlgProc (
|
|||
|
||||
if (hItem != NULL)
|
||||
{
|
||||
hr = StringCbPrintfA(TextBuffer,
|
||||
hr = StringCbPrintfA(TextBuffer,
|
||||
sizeof(TextBuffer),
|
||||
"USB Video Class Spec version: %d.%d",
|
||||
UVC_SPEC_MAJOR_VERSION,
|
||||
"USB Video Class Spec version: %d.%d",
|
||||
UVC_SPEC_MAJOR_VERSION,
|
||||
UVC_SPEC_MINOR_VERSION);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
|
@ -1735,7 +1735,7 @@ AboutDlgProc (
|
|||
{
|
||||
case IDOK:
|
||||
case IDCANCEL:
|
||||
|
||||
|
||||
EndDialog (hwnd, 0);
|
||||
break;
|
||||
}
|
||||
|
@ -1820,7 +1820,7 @@ AddLeaf (
|
|||
tvins.item.iImage = giGoodSsDevice;
|
||||
tvins.item.iSelectedImage = giGoodSsDevice;
|
||||
break;
|
||||
|
||||
|
||||
case NoSsDeviceIcon:
|
||||
tvins.item.iImage = giNoSsDevice;
|
||||
tvins.item.iSelectedImage = giNoSsDevice;
|
||||
|
@ -1886,7 +1886,7 @@ WalkTreeTopDown(
|
|||
}
|
||||
else
|
||||
{
|
||||
// If there are no more siblings, we have reached the end of
|
||||
// If there are no more siblings, we have reached the end of
|
||||
// list of child nodes. Call notify function
|
||||
if (lpfnTreeNotifyCallback != NULL)
|
||||
{
|
||||
|
@ -1959,7 +1959,7 @@ SaveAllInformationAsXML()
|
|||
|
||||
Saves the entire USB tree as an XML file
|
||||
*****************************************************************************/
|
||||
HRESULT
|
||||
HRESULT
|
||||
SaveAllInformationAsXml(
|
||||
LPTSTR lpstrTextFileName,
|
||||
DWORD dwCreationDisposition
|
||||
|
@ -2070,8 +2070,8 @@ DisplayLastError()
|
|||
|
||||
DWORD
|
||||
DisplayLastError(
|
||||
_Inout_updates_bytes_(count) char *szString,
|
||||
int count)
|
||||
_Inout_updates_bytes_(count) char *szString,
|
||||
int count)
|
||||
{
|
||||
LPVOID lpMsgBuf;
|
||||
|
||||
|
@ -2079,9 +2079,9 @@ DisplayLastError(
|
|||
DWORD dwError = GetLastError();
|
||||
|
||||
// get the system message for this error code
|
||||
if (FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
if (FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
dwError,
|
||||
|
@ -2122,8 +2122,8 @@ Oops
|
|||
memset(szBuf, 0, sizeof(szBuf));
|
||||
|
||||
// get the system message for this error code
|
||||
if (FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
if (FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
dwGLE,
|
||||
|
@ -2132,14 +2132,14 @@ Oops
|
|||
0,
|
||||
NULL))
|
||||
{
|
||||
StringCchPrintf(szBuf, sizeof(szBuf),
|
||||
"File: %s, Line %d\r\nGetLastError 0x%x %u %s\n",
|
||||
StringCchPrintf(szBuf, sizeof(szBuf),
|
||||
"File: %s, Line %d\r\nGetLastError 0x%x %u %s\n",
|
||||
File, Line, dwGLE, dwGLE, lpMsgBuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
StringCchPrintf(szBuf, sizeof(szBuf),
|
||||
"File: %s, Line %d\r\nGetLastError 0x%x %u\r\n",
|
||||
StringCchPrintf(szBuf, sizeof(szBuf),
|
||||
"File: %s, Line %d\r\nGetLastError 0x%x %u\r\n",
|
||||
File, Line, dwGLE, dwGLE);
|
||||
}
|
||||
OutputDebugString(szBuf);
|
||||
|
|
|
@ -27,7 +27,7 @@ Revision History:
|
|||
#include "h264.h"
|
||||
#include "xmlhelper.h"
|
||||
|
||||
// usbschema.hpp is autogenerated from schema during build PASS0
|
||||
// usbschema.hpp is autogenerated from schema during build PASS0
|
||||
#include "usbschema.hpp"
|
||||
|
||||
// Include code analysis suppressions
|
||||
|
@ -56,7 +56,7 @@ Revision History:
|
|||
#define USB_GENERIC "USB GENERIC (UNKNOWN)"
|
||||
|
||||
/*****************************************************************************
|
||||
N A M E S P A C E S
|
||||
N A M E S P A C E S
|
||||
*****************************************************************************/
|
||||
|
||||
using namespace System;
|
||||
|
@ -148,7 +148,7 @@ void XmlAddPipeInformation(
|
|||
ULONG numPipes,
|
||||
UCHAR connectionSpeed);
|
||||
void XmlAddUsbDeviceDescriptor(
|
||||
UsbDeviceDescriptorType ^usbXmlDeviceDescriptor,
|
||||
UsbDeviceDescriptorType ^usbXmlDeviceDescriptor,
|
||||
PUSB_DEVICE_DESCRIPTOR usbDeviceDescriptor);
|
||||
void XmlAddConfigurationDescriptor(
|
||||
UsbConfigurationDescriptorType ^ confXmlDesc,
|
||||
|
@ -176,7 +176,7 @@ bool XmlAddDeviceClassDetails(
|
|||
PUSB_NODE_CONNECTION_INFORMATION_EX connectionInfo,
|
||||
PUSBDEVICEINFO deviceInfo);
|
||||
void XmlAddConnectionInfo(
|
||||
NodeConnectionInfoExType ^xmlConnectionInfo,
|
||||
NodeConnectionInfoExType ^xmlConnectionInfo,
|
||||
PUSB_NODE_CONNECTION_INFORMATION_EX connectionInfo,
|
||||
PUSBDEVICEINFO deviceInfo,
|
||||
PSTRING_DESCRIPTOR_NODE stringDesc,
|
||||
|
@ -223,13 +223,13 @@ UsbBillboardCapabilityDescriptorType ^ XmlGetBillboardCapabilityDescriptor(
|
|||
);
|
||||
|
||||
/*****************************************************************************
|
||||
D E F I N I T I O N S
|
||||
D E F I N I T I O N S
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
XmlNotifyEndOfNodeList
|
||||
|
||||
This function is called back by WalkTreeTopDown() function to notify us
|
||||
This function is called back by WalkTreeTopDown() function to notify us
|
||||
that there are no more children to add for the current parent
|
||||
|
||||
*****************************************************************************/
|
||||
|
@ -302,7 +302,7 @@ HRESULT XmlAddHostController(PSTR hcName, PUSBHOSTCONTROLLERINFO hcInfo)
|
|||
else
|
||||
{
|
||||
// Create a new array every time as Array.Resize does not seem to work in our case (CLI)
|
||||
// We do this using ArrayList.
|
||||
// We do this using ArrayList.
|
||||
ArrayList ^hcList = gcnew ArrayList;
|
||||
hcList->AddRange(gXmlView->UsbTree);
|
||||
hc = gcnew HostControllerType();
|
||||
|
@ -325,20 +325,31 @@ HRESULT XmlAddHostController(PSTR hcName, PUSBHOSTCONTROLLERINFO hcInfo)
|
|||
hc->DeviceName = PACHAR_TO_STRING(hcInfo->UsbDeviceProperties->DeviceDesc);
|
||||
hc->DeviceClass = PACHAR_TO_STRING(hcInfo->UsbDeviceProperties->DeviceClass);
|
||||
|
||||
if (_stricmp(hcInfo->UsbDeviceProperties->Service, SERVICE_OHCI) == 0)
|
||||
bool foundUsbProtocol = false;
|
||||
if (hcInfo->UsbDeviceProperties->Service != NULL)
|
||||
{
|
||||
hc->UsbProtocol = gcnew String(USB_1_1);
|
||||
foundUsbProtocol = true;
|
||||
|
||||
if (_stricmp(hcInfo->UsbDeviceProperties->Service, SERVICE_OHCI) == 0)
|
||||
{
|
||||
hc->UsbProtocol = gcnew String(USB_1_1);
|
||||
}
|
||||
else if(_stricmp(hcInfo->UsbDeviceProperties->Service, SERVICE_EHCI) == 0 ||
|
||||
_stricmp(hcInfo->UsbDeviceProperties->Service, SERVICE_UHCI) == 0)
|
||||
{
|
||||
hc->UsbProtocol = gcnew String(USB_2_0);
|
||||
}
|
||||
else if (_stricmp(hcInfo->UsbDeviceProperties->Service, SERVICE_XHCI) == 0)
|
||||
{
|
||||
hc->UsbProtocol = gcnew String(USB_3_0);
|
||||
}
|
||||
else
|
||||
{
|
||||
foundUsbProtocol = false;
|
||||
}
|
||||
}
|
||||
else if(_stricmp(hcInfo->UsbDeviceProperties->Service, SERVICE_EHCI) == 0 ||
|
||||
_stricmp(hcInfo->UsbDeviceProperties->Service, SERVICE_UHCI) == 0)
|
||||
{
|
||||
hc->UsbProtocol = gcnew String(USB_2_0);
|
||||
}
|
||||
else if (_stricmp(hcInfo->UsbDeviceProperties->Service, SERVICE_XHCI) == 0)
|
||||
{
|
||||
hc->UsbProtocol = gcnew String(USB_3_0);
|
||||
}
|
||||
else
|
||||
|
||||
if (!foundUsbProtocol)
|
||||
{
|
||||
// If protocol lookup failed based on service name, try Controller flavor
|
||||
if(NULL != hcInfo->ControllerInfo)
|
||||
|
@ -488,10 +499,10 @@ void XmlAddConnectionInfoV2(NodeConnectionInfoExV2Type ^ connectionXmlInfo, PUSB
|
|||
connectionXmlInfo->Usb200Supported = connectionInfo->SupportedUsbProtocols.Usb200? true:false;
|
||||
connectionXmlInfo->Usb300Supported = connectionInfo->SupportedUsbProtocols.Usb300? true:false;
|
||||
|
||||
connectionXmlInfo->DeviceIsOperatingAtSuperSpeedOrHigher =
|
||||
connectionXmlInfo->DeviceIsOperatingAtSuperSpeedOrHigher =
|
||||
connectionInfo->Flags.DeviceIsOperatingAtSuperSpeedOrHigher;
|
||||
|
||||
connectionXmlInfo->DeviceIsSuperSpeedCapableOrHigher =
|
||||
connectionXmlInfo->DeviceIsSuperSpeedCapableOrHigher =
|
||||
connectionInfo->Flags.DeviceIsSuperSpeedCapableOrHigher;
|
||||
|
||||
connectionXmlInfo->DeviceIsOperatingAtSuperSpeedPlusOrHigher =
|
||||
|
@ -499,7 +510,7 @@ void XmlAddConnectionInfoV2(NodeConnectionInfoExV2Type ^ connectionXmlInfo, PUSB
|
|||
|
||||
connectionXmlInfo->DeviceIsSuperSpeedPlusCapableOrHigher =
|
||||
connectionInfo->Flags.DeviceIsSuperSpeedPlusCapableOrHigher;
|
||||
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -655,7 +666,7 @@ ExternalHubType ^ AddExternalHub(Object ^parent)
|
|||
boolean arrayCreated = false;
|
||||
|
||||
// An external hub can be connected to a Root Hub or another External Hub
|
||||
// We need to determine the type of the object.
|
||||
// We need to determine the type of the object.
|
||||
|
||||
// Try root hub first
|
||||
|
||||
|
@ -736,7 +747,7 @@ NoDeviceType ^ AddDisconnectedPort(Object ^parent)
|
|||
boolean arrayCreated = false;
|
||||
|
||||
// An external hub can be connected to a Root Hub or another External Hub
|
||||
// We need to determine the type of the object.
|
||||
// We need to determine the type of the object.
|
||||
|
||||
// Try RH first
|
||||
|
||||
|
@ -818,7 +829,7 @@ UsbDeviceType ^ AddUsbDevice(Object ^parent)
|
|||
boolean arrayCreated = false;
|
||||
|
||||
// An external hub can be connected to a Root Hub or another External Hub
|
||||
// We need to determine the type of the object.
|
||||
// We need to determine the type of the object.
|
||||
|
||||
// Try RH first
|
||||
|
||||
|
@ -937,9 +948,9 @@ void XmlAddIADDescriptor(
|
|||
iadDesc->bFunctionProtocol);
|
||||
|
||||
// Protocol check
|
||||
if (iadDesc->bFunctionClass == USB_DEVICE_CLASS_VIDEO)
|
||||
if (iadDesc->bFunctionClass == USB_DEVICE_CLASS_VIDEO)
|
||||
{
|
||||
if (iadDesc->bFunctionProtocol != PC_PROTOCOL_UNDEFINED)
|
||||
if (iadDesc->bFunctionProtocol != PC_PROTOCOL_UNDEFINED)
|
||||
{
|
||||
iadXmlDesc->Protocol= gcnew String("WARNING: Protocol must be set to PC_PROTOCOL_UNDEFINED");
|
||||
iadXmlDesc->Protocol+= " for this class but is set to: ";
|
||||
|
@ -949,7 +960,7 @@ void XmlAddIADDescriptor(
|
|||
{
|
||||
iadXmlDesc->Protocol = gcnew String("PC_PROTOCOL_UNDEFINED protocol");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (iadDesc->iFunction)
|
||||
{
|
||||
|
@ -1084,7 +1095,7 @@ UsbDeviceUnknownDescriptorType ^ XmlGetUnknownDescriptor(
|
|||
void XmlAddEndpointDescriptor(
|
||||
EndpointDescriptorType ^usbXmlEndpointDescriptor,
|
||||
PUSB_ENDPOINT_DESCRIPTOR endPointDescriptor,
|
||||
UCHAR connectionSpeed
|
||||
UCHAR connectionSpeed
|
||||
)
|
||||
{
|
||||
EndpointDescriptorType ^ue = usbXmlEndpointDescriptor;
|
||||
|
@ -1172,10 +1183,10 @@ void XmlAddEndpointDescriptor(
|
|||
}
|
||||
|
||||
// Add validation
|
||||
if (endPointDescriptor->wMaxPacketSize & 0xE000)
|
||||
if (endPointDescriptor->wMaxPacketSize & 0xE000)
|
||||
{
|
||||
ue->EndpointPacketSizeValidation = gcnew String("ERROR: wMaxPacketSize bits 15-13 should be 0");
|
||||
} else if (connectionSpeed==UsbHighSpeed)
|
||||
} else if (connectionSpeed==UsbHighSpeed)
|
||||
{
|
||||
USHORT hsMux;
|
||||
|
||||
|
@ -1187,26 +1198,26 @@ void XmlAddEndpointDescriptor(
|
|||
case USB_ENDPOINT_TYPE_INTERRUPT:
|
||||
switch (hsMux) {
|
||||
case 0:
|
||||
if ((maxBytes < 1) || (maxBytes > 1024))
|
||||
if ((maxBytes < 1) || (maxBytes > 1024))
|
||||
{
|
||||
ue->EndpointPacketSizeValidation = gcnew String("ERROR: Invalid maximum packet size, should be between 1 and 1024");
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if ((maxBytes < 513) || (maxBytes > 1024))
|
||||
if ((maxBytes < 513) || (maxBytes > 1024))
|
||||
{
|
||||
ue->EndpointPacketSizeValidation = gcnew String("ERROR: Invalid maximum packet size, should be between 513 and 1024");
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ((maxBytes < 683) || (maxBytes > 1024))
|
||||
if ((maxBytes < 683) || (maxBytes > 1024))
|
||||
{
|
||||
ue->EndpointPacketSizeValidation = gcnew String("ERROR: Invalid maximum packet size, should be between 683 and 1024");
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 3:
|
||||
ue->EndpointPacketSizeValidation = gcnew String("ERROR: Bits 12-11 set to reserved value\r\n");
|
||||
break;
|
||||
|
@ -1264,7 +1275,7 @@ void XmlAddPipeInformation(
|
|||
This routine adds usb device descriptor
|
||||
*****************************************************************************/
|
||||
void XmlAddUsbDeviceDescriptor(
|
||||
UsbDeviceDescriptorType ^usbXmlDeviceDescriptor,
|
||||
UsbDeviceDescriptorType ^usbXmlDeviceDescriptor,
|
||||
PUSB_DEVICE_DESCRIPTOR usbDeviceDescriptor)
|
||||
{
|
||||
UsbDeviceDescriptorType ^ud = usbXmlDeviceDescriptor;
|
||||
|
@ -1310,7 +1321,7 @@ void XmlAddConfigurationDescriptor(
|
|||
return;
|
||||
}
|
||||
|
||||
if(deviceInfo->ConnectionInfoV2 &&
|
||||
if(deviceInfo->ConnectionInfoV2 &&
|
||||
(deviceInfo->ConnectionInfoV2->Flags.DeviceIsOperatingAtSuperSpeedOrHigher ||
|
||||
deviceInfo->ConnectionInfoV2->Flags.DeviceIsOperatingAtSuperSpeedPlusOrHigher))
|
||||
{
|
||||
|
@ -1328,9 +1339,9 @@ void XmlAddConfigurationDescriptor(
|
|||
|
||||
uCount = GetConfigurationSize(deviceInfo);
|
||||
|
||||
if (uCount != configDesc->wTotalLength)
|
||||
if (uCount != configDesc->wTotalLength)
|
||||
{
|
||||
confXmlDesc->ConfigDescError = gcnew String("ERROR: Invalid total configuration size " +
|
||||
confXmlDesc->ConfigDescError = gcnew String("ERROR: Invalid total configuration size " +
|
||||
configDesc->wTotalLength + ", should be " + uCount);
|
||||
}
|
||||
|
||||
|
@ -1432,7 +1443,7 @@ UsbDeviceClassType ^ XmlGetDeviceClass(UCHAR bInterfaceClass, UCHAR bInterfaceSu
|
|||
case USB_DEVICE_CLASS_VENDOR_SPECIFIC:
|
||||
deviceClass = gcnew String("Vendor Specific Device");
|
||||
break;
|
||||
|
||||
|
||||
case USB_DEVICE_CLASS_HUMAN_INTERFACE:
|
||||
|
||||
deviceClass = gcnew String("HID Interface");
|
||||
|
@ -1547,7 +1558,7 @@ UsbDeviceClassType ^ XmlGetDeviceClass(UCHAR bInterfaceClass, UCHAR bInterfaceSu
|
|||
default:
|
||||
|
||||
deviceClass = gcnew String("Interface Class unknown : ");
|
||||
deviceClass += bInterfaceClass;
|
||||
deviceClass += bInterfaceClass;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1588,15 +1599,15 @@ void XmlAddDeviceInterfaceDescriptor(
|
|||
|
||||
// Update class and sub class
|
||||
ifXmlDesc->InterfaceDetails = XmlGetDeviceClass(
|
||||
ifDesc->bInterfaceClass,
|
||||
ifDesc->bInterfaceClass,
|
||||
ifDesc->bInterfaceSubClass,
|
||||
ifDesc->bInterfaceProtocol);
|
||||
|
||||
//This is basically the check for PC_PROTOCOL_UNDEFINED
|
||||
if ((ifDesc->bInterfaceClass == USB_DEVICE_CLASS_VIDEO) ||
|
||||
(ifDesc->bInterfaceClass == USB_DEVICE_CLASS_AUDIO))
|
||||
if ((ifDesc->bInterfaceClass == USB_DEVICE_CLASS_VIDEO) ||
|
||||
(ifDesc->bInterfaceClass == USB_DEVICE_CLASS_AUDIO))
|
||||
{
|
||||
if (ifDesc->bInterfaceProtocol != PC_PROTOCOL_UNDEFINED)
|
||||
if (ifDesc->bInterfaceProtocol != PC_PROTOCOL_UNDEFINED)
|
||||
{
|
||||
ifXmlDesc->ProtocolError = gcnew String("WARNING: Protocol must be set to PC_PROTOCOL_UNDEFINED");
|
||||
ifXmlDesc->ProtocolError += " for this class but is set to: ";
|
||||
|
@ -2087,9 +2098,9 @@ String ^ XmlGetStringDescriptor(UCHAR index, PSTRING_DESCRIPTOR_NODE stringDesc,
|
|||
if ((foundDescriptor == false) && (foundNonEnglishDescriptor == false))
|
||||
{
|
||||
// If no descriptor was found, return error message in field
|
||||
desc = gcnew String("ERROR: No String descriptor for index " +
|
||||
desc = gcnew String("ERROR: No String descriptor for index " +
|
||||
index);
|
||||
}
|
||||
}
|
||||
else if ((foundDescriptor == false) && (foundNonEnglishDescriptor == true) && (enOnly))
|
||||
{
|
||||
desc = gcnew String("ERROR: The index " + index + " does not support English(US)");
|
||||
|
@ -2196,9 +2207,9 @@ bool XmlAddDeviceClassDetails(
|
|||
{
|
||||
deviceDetails->DeviceProtocol = gcnew String("Interface Association Descriptor protocol");
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
deviceDetails->DeviceProtocolError = gcnew String("ERROR: device Protocol should be USB IAD Protocol " +
|
||||
deviceDetails->DeviceProtocolError = gcnew String("ERROR: device Protocol should be USB IAD Protocol " +
|
||||
USB_IAD_PROTOCOL +
|
||||
" when IAD descriptor is used");
|
||||
}
|
||||
|
@ -2208,7 +2219,7 @@ bool XmlAddDeviceClassDetails(
|
|||
{
|
||||
deviceDetails->DeviceType = XmlGetDeviceClassString(connectionInfo->DeviceDescriptor.bDeviceClass);
|
||||
|
||||
if (connectionInfo->DeviceDescriptor.bDeviceClass == USB_DEVICE_CLASS_BILLBOARD &&
|
||||
if (connectionInfo->DeviceDescriptor.bDeviceClass == USB_DEVICE_CLASS_BILLBOARD &&
|
||||
(connectionInfo->DeviceDescriptor.bDeviceSubClass != 0x0 ||
|
||||
connectionInfo->DeviceDescriptor.bDeviceProtocol != 0x0))
|
||||
{
|
||||
|
@ -2233,7 +2244,7 @@ bool XmlAddDeviceClassDetails(
|
|||
}
|
||||
|
||||
// Not an IAD device, so all subclass values are invalid
|
||||
if (connectionInfo->DeviceDescriptor.bDeviceSubClass > 0x00 &&
|
||||
if (connectionInfo->DeviceDescriptor.bDeviceSubClass > 0x00 &&
|
||||
connectionInfo->DeviceDescriptor.bDeviceSubClass < 0xFF)
|
||||
{
|
||||
deviceDetails->SubclassTypeError = gcnew String("ERROR: bDeviceSubClass is invalid - " +
|
||||
|
@ -2241,7 +2252,7 @@ bool XmlAddDeviceClassDetails(
|
|||
}
|
||||
|
||||
// Not an IAD device, so all subclass values are invalid, check protocol
|
||||
if (connectionInfo->DeviceDescriptor.bDeviceProtocol > 0x00 &&
|
||||
if (connectionInfo->DeviceDescriptor.bDeviceProtocol > 0x00 &&
|
||||
connectionInfo->DeviceDescriptor.bDeviceProtocol < 0xFF && tog==1)
|
||||
{
|
||||
deviceDetails->DeviceProtocolError = gcnew String("ERROR: bDeviceProtocol is invalid - " +
|
||||
|
@ -2259,7 +2270,7 @@ bool XmlAddDeviceClassDetails(
|
|||
This routine adds connection information for the device
|
||||
*****************************************************************************/
|
||||
void XmlAddConnectionInfo(
|
||||
NodeConnectionInfoExType ^xmlConnectionInfo,
|
||||
NodeConnectionInfoExType ^xmlConnectionInfo,
|
||||
PUSB_NODE_CONNECTION_INFORMATION_EX connectionInfo,
|
||||
PUSBDEVICEINFO deviceInfo,
|
||||
PSTRING_DESCRIPTOR_NODE stringDesc,
|
||||
|
@ -2281,7 +2292,7 @@ void XmlAddConnectionInfo(
|
|||
|
||||
if (connectionInfo->DeviceDescriptor.iProduct)
|
||||
{
|
||||
// Add EN version of string descriptor
|
||||
// Add EN version of string descriptor
|
||||
|
||||
nc->IProductStringDescEn = XmlGetStringDescriptor(
|
||||
connectionInfo->DeviceDescriptor.iProduct,
|
||||
|
@ -2298,7 +2309,7 @@ void XmlAddConnectionInfo(
|
|||
// Check device descriptor length
|
||||
if (connectionInfo->DeviceDescriptor.bLength != DEVICE_DESCRIPTOR_LENGTH)
|
||||
{
|
||||
nc->LengthError = gcnew String("ERROR: bLength " +
|
||||
nc->LengthError = gcnew String("ERROR: bLength " +
|
||||
connectionInfo->DeviceDescriptor.bLength +
|
||||
" incorrect, should be " +
|
||||
DEVICE_DESCRIPTOR_LENGTH
|
||||
|
@ -2306,7 +2317,7 @@ void XmlAddConnectionInfo(
|
|||
}
|
||||
|
||||
// Check for device error
|
||||
if ((connectionInfo->ConnectionStatus == DeviceFailedEnumeration) ||
|
||||
if ((connectionInfo->ConnectionStatus == DeviceFailedEnumeration) ||
|
||||
(connectionInfo->ConnectionStatus == DeviceGeneralFailure))
|
||||
{
|
||||
nc->DeviceError = gcnew String("ERROR: Device enumeration failure");
|
||||
|
@ -2447,7 +2458,7 @@ HRESULT XmlAddExternalHub(PSTR ehName, PUSBEXTERNALHUBINFO ehInfo)
|
|||
exHub->PortConnector = gcnew PortConnectorType();
|
||||
|
||||
XmlAddPortConnectorProps(
|
||||
exHub->PortConnector,
|
||||
exHub->PortConnector,
|
||||
ehInfo->PortConnectorProps
|
||||
);
|
||||
}
|
||||
|
@ -2518,16 +2529,16 @@ UsbBosDescriptorType ^ XmlGetBosDescriptor(
|
|||
|
||||
commonDesc = (PUSB_COMMON_DESCRIPTOR) bosDesc;
|
||||
|
||||
while ((commonDesc = GetNextDescriptor((PUSB_COMMON_DESCRIPTOR) bosDesc,
|
||||
bosDesc->wTotalLength,
|
||||
commonDesc,
|
||||
while ((commonDesc = GetNextDescriptor((PUSB_COMMON_DESCRIPTOR) bosDesc,
|
||||
bosDesc->wTotalLength,
|
||||
commonDesc,
|
||||
-1)) != NULL)
|
||||
{
|
||||
switch (commonDesc->bDescriptorType)
|
||||
{
|
||||
case USB_DEVICE_CAPABILITY_DESCRIPTOR_TYPE:
|
||||
capDesc = (PUSB_DEVICE_CAPABILITY_DESCRIPTOR)commonDesc;
|
||||
switch (capDesc->bDevCapabilityType)
|
||||
switch (capDesc->bDevCapabilityType)
|
||||
{
|
||||
case USB_DEVICE_CAPABILITY_USB20_EXTENSION:
|
||||
usb20CapExtDescList->Add(
|
||||
|
@ -2591,7 +2602,7 @@ UsbBosDescriptorType ^ XmlGetBosDescriptor(
|
|||
);
|
||||
|
||||
return bosXmlDesc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -2980,7 +2991,7 @@ HRESULT XmlAddUsbDevice(PSTR devName, PUSBDEVICEINFO deviceInfo)
|
|||
deviceInfo->DeviceInfoNode
|
||||
);
|
||||
|
||||
// Add port connector
|
||||
// Add port connector
|
||||
if (NULL != deviceInfo->PortConnectorProps)
|
||||
{
|
||||
usbDevice->PortConnector = gcnew PortConnectorType();
|
||||
|
@ -3049,7 +3060,7 @@ HRESULT XmlAddRootHub(PSTR rhName, PUSBROOTHUBINFO rhInfo)
|
|||
if (hcParent != nullptr)
|
||||
{
|
||||
RootHubType ^ rh = nullptr;
|
||||
hcParent = (HostControllerType ^) parent;
|
||||
hcParent = (HostControllerType ^) parent;
|
||||
hcParent->RootHub = gcnew RootHubType();
|
||||
|
||||
rh = hcParent->RootHub;
|
||||
|
@ -3116,7 +3127,7 @@ VOID XmlSetVersion(
|
|||
|
||||
InitXmlHelper()
|
||||
|
||||
Initialize XML helper
|
||||
Initialize XML helper
|
||||
*****************************************************************************/
|
||||
HRESULT InitXmlHelper()
|
||||
{
|
||||
|
@ -3132,9 +3143,9 @@ HRESULT InitXmlHelper()
|
|||
(XmlGlobal::Instance())->ViewAll->UvcView->UsbTree = nullptr;
|
||||
|
||||
XmlSetVersion(
|
||||
UVC_SPEC_MAJOR_VERSION,
|
||||
UVC_SPEC_MINOR_VERSION,
|
||||
USBVIEW_MAJOR_VERSION,
|
||||
UVC_SPEC_MAJOR_VERSION,
|
||||
UVC_SPEC_MINOR_VERSION,
|
||||
USBVIEW_MAJOR_VERSION,
|
||||
USBVIEW_MINOR_VERSION
|
||||
);
|
||||
|
||||
|
|
|
@ -21,10 +21,10 @@ Environment:
|
|||
|
||||
--*/
|
||||
|
||||
|
||||
|
||||
#include <DriverSpecs.h>
|
||||
_Analysis_mode_(_Analysis_code_type_user_code_)
|
||||
|
||||
_Analysis_mode_(_Analysis_code_type_user_code_)
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -117,6 +117,7 @@ GetDevicePath(
|
|||
|
||||
deviceInterfaceList = (PWSTR)malloc(deviceInterfaceListLength * sizeof(WCHAR));
|
||||
if (deviceInterfaceList == NULL) {
|
||||
bRet = FALSE;
|
||||
printf("Error allocating memory for device interface list.\n");
|
||||
goto clean0;
|
||||
}
|
||||
|
@ -157,7 +158,9 @@ clean0:
|
|||
return bRet;
|
||||
}
|
||||
|
||||
|
||||
_Check_return_
|
||||
_Ret_notnull_
|
||||
_Success_(return != INVALID_HANDLE_VALUE)
|
||||
HANDLE
|
||||
OpenDevice(
|
||||
_In_ BOOL Synchronous
|
||||
|
@ -1201,10 +1204,9 @@ exit:
|
|||
}
|
||||
|
||||
if (hWrite != INVALID_HANDLE_VALUE) {
|
||||
_Analysis_assume_(hWrite != NULL);
|
||||
CloseHandle(hWrite);
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -211,7 +211,9 @@ GetDevicePath(
|
|||
|
||||
}
|
||||
|
||||
|
||||
_Check_return_
|
||||
_Ret_notnull_
|
||||
_Success_(return != INVALID_HANDLE_VALUE)
|
||||
HANDLE
|
||||
OpenDevice(
|
||||
_In_ BOOL Synchronous
|
||||
|
@ -905,7 +907,7 @@ SendFileToDevice(
|
|||
{
|
||||
HANDLE deviceHandle;
|
||||
|
||||
struct
|
||||
struct
|
||||
{
|
||||
USHORT delay;
|
||||
WCHAR buffer[MAX_PATH + 1];
|
||||
|
@ -934,14 +936,14 @@ SendFileToDevice(
|
|||
// Convert the file name from relative to absolute.
|
||||
//
|
||||
|
||||
bufferCch = GetFullPathName(FileName,
|
||||
bufferCch = GetFullPathName(FileName,
|
||||
countof(playback.buffer),
|
||||
playback.buffer,
|
||||
NULL);
|
||||
|
||||
if (bufferCch == 0)
|
||||
{
|
||||
wprintf(L"Error getting full path name for %s - %d\n",
|
||||
wprintf(L"Error getting full path name for %s - %d\n",
|
||||
FileName,
|
||||
GetLastError());
|
||||
goto Error;
|
||||
|
@ -1241,6 +1243,10 @@ Return Value:
|
|||
}
|
||||
|
||||
pinBuf = malloc(G_ReadLen);
|
||||
if (pinBuf == 0) {
|
||||
retValue = 1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (G_fWrite) {
|
||||
|
@ -1260,6 +1266,10 @@ Return Value:
|
|||
}
|
||||
|
||||
poutBuf = malloc(G_WriteLen);
|
||||
if (poutBuf == 0) {
|
||||
retValue = 1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < G_IterationCount; i++) {
|
||||
|
@ -1349,12 +1359,9 @@ exit:
|
|||
}
|
||||
|
||||
if (hWrite != INVALID_HANDLE_VALUE) {
|
||||
_Analysis_assume_(hWrite != NULL);
|
||||
CloseHandle(hWrite);
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*++
|
||||
|
||||
|
||||
Copyright (C) Microsoft Corporation, All Rights Reserved.
|
||||
|
||||
Module Name:
|
||||
|
@ -8,24 +8,24 @@ Module Name:
|
|||
|
||||
Abstract:
|
||||
|
||||
This module contains the implementation of the UMDF Skeleton Sample
|
||||
This module contains the implementation of the UMDF Skeleton Sample
|
||||
Driver's entry point and its exported functions for providing COM support.
|
||||
|
||||
This module can be copied without modification to a new UMDF driver. It
|
||||
depends on some of the code in comsup.cpp & comsup.h to handle DLL
|
||||
depends on some of the code in comsup.cpp & comsup.h to handle DLL
|
||||
registration and creating the first class factory.
|
||||
|
||||
This module is dependent on the following defines:
|
||||
|
||||
MYDRIVER_TRACING_ID - A wide string passed to WPP when initializing
|
||||
tracing. For example the skeleton uses
|
||||
MYDRIVER_TRACING_ID - A wide string passed to WPP when initializing
|
||||
tracing. For example the skeleton uses
|
||||
L"Microsoft\\UMDF\\Skeleton"
|
||||
|
||||
MYDRIVER_CLASS_ID - A GUID encoded in struct format used to
|
||||
initialize the driver's ClassID.
|
||||
MYDRIVER_CLASS_ID - A GUID encoded in struct format used to
|
||||
initialize the driver's ClassID.
|
||||
|
||||
These are defined in internal.h for the skeleton sample. If you choose
|
||||
to use a different primary include file, you should ensure they are
|
||||
to use a different primary include file, you should ensure they are
|
||||
defined there as well.
|
||||
|
||||
Environment:
|
||||
|
@ -50,10 +50,10 @@ DllMain(
|
|||
|
||||
Routine Description:
|
||||
|
||||
This is the entry point and exit point for the I/O trace driver. This
|
||||
This is the entry point and exit point for the I/O trace driver. This
|
||||
does very little as the I/O trace driver has minimal global data.
|
||||
|
||||
This method initializes tracing, and saves the module handle away in a
|
||||
This method initializes tracing, and saves the module handle away in a
|
||||
global variable so that it can be referenced should the COM registration
|
||||
code (Dll[Un]RegisterServer) be called.
|
||||
|
||||
|
@ -72,7 +72,7 @@ DllMain(
|
|||
--*/
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ModuleHandle);
|
||||
|
||||
|
||||
if (DLL_PROCESS_ATTACH == Reason)
|
||||
{
|
||||
//
|
||||
|
@ -93,6 +93,7 @@ DllMain(
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
HRESULT
|
||||
STDAPICALLTYPE
|
||||
DllCanUnloadNow(
|
||||
|
@ -100,7 +101,7 @@ DllCanUnloadNow(
|
|||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Routine Description:
|
||||
|
||||
Called by the COM runtime when determining whether or not this module
|
||||
can be unloaded. Our answer is always "no".
|
||||
|
@ -118,18 +119,19 @@ DllCanUnloadNow(
|
|||
return S_FALSE;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
HRESULT
|
||||
STDAPICALLTYPE
|
||||
DllGetClassObject(
|
||||
_In_ REFCLSID ClassId,
|
||||
_In_ REFIID InterfaceId,
|
||||
_Outptr_ LPVOID *Interface
|
||||
REFCLSID ClassId,
|
||||
REFIID InterfaceId,
|
||||
LPVOID *Interface
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
This routine is called by COM in order to instantiate the
|
||||
This routine is called by COM in order to instantiate the
|
||||
skeleton driver callback object and do an initial query interface on it.
|
||||
|
||||
This method only creates an instance of the driver's class factory, as this
|
||||
|
@ -145,7 +147,7 @@ DllGetClassObject(
|
|||
|
||||
Return Value:
|
||||
|
||||
S_OK if the function succeeds or error indicating the cause of the
|
||||
S_OK if the function succeeds or error indicating the cause of the
|
||||
failure.
|
||||
|
||||
--*/
|
||||
|
@ -157,9 +159,9 @@ DllGetClassObject(
|
|||
*Interface = NULL;
|
||||
|
||||
//
|
||||
// If the CLSID doesn't match that of our "coclass" (defined in the IDL
|
||||
// file) then we can't create the object the caller wants. This may
|
||||
// indicate that the COM registration is incorrect, and another CLSID
|
||||
// If the CLSID doesn't match that of our "coclass" (defined in the IDL
|
||||
// file) then we can't create the object the caller wants. This may
|
||||
// indicate that the COM registration is incorrect, and another CLSID
|
||||
// is referencing this drvier.
|
||||
//
|
||||
|
||||
|
@ -180,19 +182,19 @@ DllGetClassObject(
|
|||
|
||||
factory = new CClassFactory();
|
||||
|
||||
if (NULL == factory)
|
||||
if (NULL == factory)
|
||||
{
|
||||
hr = E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Query the object we created for the interface the caller wants. After
|
||||
// that we release the object. This will drive the reference count to
|
||||
// that we release the object. This will drive the reference count to
|
||||
// 1 (if the QI succeeded an referenced the object) or 0 (if the QI failed).
|
||||
// In the later case the object is automatically deleted.
|
||||
//
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = factory->QueryInterface(InterfaceId, Interface);
|
||||
factory->Release();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*++
|
||||
|
||||
|
||||
Copyright (C) Microsoft Corporation, All Rights Reserved.
|
||||
|
||||
Module Name:
|
||||
|
@ -8,24 +8,24 @@ Module Name:
|
|||
|
||||
Abstract:
|
||||
|
||||
This module contains the implementation of the UMDF Skeleton Sample
|
||||
This module contains the implementation of the UMDF Skeleton Sample
|
||||
Driver's entry point and its exported functions for providing COM support.
|
||||
|
||||
This module can be copied without modification to a new UMDF driver. It
|
||||
depends on some of the code in comsup.cpp & comsup.h to handle DLL
|
||||
depends on some of the code in comsup.cpp & comsup.h to handle DLL
|
||||
registration and creating the first class factory.
|
||||
|
||||
This module is dependent on the following defines:
|
||||
|
||||
MYDRIVER_TRACING_ID - A wide string passed to WPP when initializing
|
||||
tracing. For example the skeleton uses
|
||||
MYDRIVER_TRACING_ID - A wide string passed to WPP when initializing
|
||||
tracing. For example the skeleton uses
|
||||
L"Microsoft\\UMDF\\Skeleton"
|
||||
|
||||
MYDRIVER_CLASS_ID - A GUID encoded in struct format used to
|
||||
initialize the driver's ClassID.
|
||||
MYDRIVER_CLASS_ID - A GUID encoded in struct format used to
|
||||
initialize the driver's ClassID.
|
||||
|
||||
These are defined in internal.h for the skeleton sample. If you choose
|
||||
to use a different primary include file, you should ensure they are
|
||||
to use a different primary include file, you should ensure they are
|
||||
defined there as well.
|
||||
|
||||
Environment:
|
||||
|
@ -50,10 +50,10 @@ DllMain(
|
|||
|
||||
Routine Description:
|
||||
|
||||
This is the entry point and exit point for the I/O trace driver. This
|
||||
This is the entry point and exit point for the I/O trace driver. This
|
||||
does very little as the I/O trace driver has minimal global data.
|
||||
|
||||
This method initializes tracing, and saves the module handle away in a
|
||||
This method initializes tracing, and saves the module handle away in a
|
||||
global variable so that it can be referenced should the COM registration
|
||||
code (Dll[Un]RegisterServer) be called.
|
||||
|
||||
|
@ -72,7 +72,7 @@ DllMain(
|
|||
--*/
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ModuleHandle);
|
||||
|
||||
|
||||
if (DLL_PROCESS_ATTACH == Reason)
|
||||
{
|
||||
//
|
||||
|
@ -93,6 +93,7 @@ DllMain(
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
HRESULT
|
||||
STDAPICALLTYPE
|
||||
DllCanUnloadNow(
|
||||
|
@ -100,7 +101,7 @@ DllCanUnloadNow(
|
|||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Routine Description:
|
||||
|
||||
Called by the COM runtime when determining whether or not this module
|
||||
can be unloaded. Our answer is always "no".
|
||||
|
@ -118,18 +119,19 @@ DllCanUnloadNow(
|
|||
return S_FALSE;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
HRESULT
|
||||
STDAPICALLTYPE
|
||||
DllGetClassObject(
|
||||
_In_ REFCLSID ClassId,
|
||||
_In_ REFIID InterfaceId,
|
||||
_Outptr_ LPVOID *Interface
|
||||
REFCLSID ClassId,
|
||||
REFIID InterfaceId,
|
||||
LPVOID *Interface
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
This routine is called by COM in order to instantiate the
|
||||
This routine is called by COM in order to instantiate the
|
||||
skeleton driver callback object and do an initial query interface on it.
|
||||
|
||||
This method only creates an instance of the driver's class factory, as this
|
||||
|
@ -145,7 +147,7 @@ DllGetClassObject(
|
|||
|
||||
Return Value:
|
||||
|
||||
S_OK if the function succeeds or error indicating the cause of the
|
||||
S_OK if the function succeeds or error indicating the cause of the
|
||||
failure.
|
||||
|
||||
--*/
|
||||
|
@ -157,9 +159,9 @@ DllGetClassObject(
|
|||
*Interface = NULL;
|
||||
|
||||
//
|
||||
// If the CLSID doesn't match that of our "coclass" (defined in the IDL
|
||||
// file) then we can't create the object the caller wants. This may
|
||||
// indicate that the COM registration is incorrect, and another CLSID
|
||||
// If the CLSID doesn't match that of our "coclass" (defined in the IDL
|
||||
// file) then we can't create the object the caller wants. This may
|
||||
// indicate that the COM registration is incorrect, and another CLSID
|
||||
// is referencing this drvier.
|
||||
//
|
||||
|
||||
|
@ -180,19 +182,19 @@ DllGetClassObject(
|
|||
|
||||
factory = new CClassFactory();
|
||||
|
||||
if (NULL == factory)
|
||||
if (NULL == factory)
|
||||
{
|
||||
hr = E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Query the object we created for the interface the caller wants. After
|
||||
// that we release the object. This will drive the reference count to
|
||||
// that we release the object. This will drive the reference count to
|
||||
// 1 (if the QI succeeded an referenced the object) or 0 (if the QI failed).
|
||||
// In the later case the object is automatically deleted.
|
||||
//
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = factory->QueryInterface(InterfaceId, Interface);
|
||||
factory->Release();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*++
|
||||
|
||||
|
||||
Copyright (C) Microsoft Corporation, All Rights Reserved.
|
||||
|
||||
Module Name:
|
||||
|
@ -8,24 +8,24 @@ Module Name:
|
|||
|
||||
Abstract:
|
||||
|
||||
This module contains the implementation of the UMDF Skeleton Sample
|
||||
This module contains the implementation of the UMDF Skeleton Sample
|
||||
Driver's entry point and its exported functions for providing COM support.
|
||||
|
||||
This module can be copied without modification to a new UMDF driver. It
|
||||
depends on some of the code in comsup.cpp & comsup.h to handle DLL
|
||||
depends on some of the code in comsup.cpp & comsup.h to handle DLL
|
||||
registration and creating the first class factory.
|
||||
|
||||
This module is dependent on the following defines:
|
||||
|
||||
MYDRIVER_TRACING_ID - A wide string passed to WPP when initializing
|
||||
tracing. For example the skeleton uses
|
||||
MYDRIVER_TRACING_ID - A wide string passed to WPP when initializing
|
||||
tracing. For example the skeleton uses
|
||||
L"Microsoft\\UMDF\\Skeleton"
|
||||
|
||||
MYDRIVER_CLASS_ID - A GUID encoded in struct format used to
|
||||
initialize the driver's ClassID.
|
||||
MYDRIVER_CLASS_ID - A GUID encoded in struct format used to
|
||||
initialize the driver's ClassID.
|
||||
|
||||
These are defined in internal.h for the skeleton sample. If you choose
|
||||
to use a different primary include file, you should ensure they are
|
||||
to use a different primary include file, you should ensure they are
|
||||
defined there as well.
|
||||
|
||||
Environment:
|
||||
|
@ -50,10 +50,10 @@ DllMain(
|
|||
|
||||
Routine Description:
|
||||
|
||||
This is the entry point and exit point for the I/O trace driver. This
|
||||
This is the entry point and exit point for the I/O trace driver. This
|
||||
does very little as the I/O trace driver has minimal global data.
|
||||
|
||||
This method initializes tracing, and saves the module handle away in a
|
||||
This method initializes tracing, and saves the module handle away in a
|
||||
global variable so that it can be referenced should the COM registration
|
||||
code (Dll[Un]RegisterServer) be called.
|
||||
|
||||
|
@ -72,7 +72,7 @@ DllMain(
|
|||
--*/
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ModuleHandle);
|
||||
|
||||
|
||||
if (DLL_PROCESS_ATTACH == Reason)
|
||||
{
|
||||
//
|
||||
|
@ -93,6 +93,7 @@ DllMain(
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
HRESULT
|
||||
STDAPICALLTYPE
|
||||
DllCanUnloadNow(
|
||||
|
@ -100,7 +101,7 @@ DllCanUnloadNow(
|
|||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Routine Description:
|
||||
|
||||
Called by the COM runtime when determining whether or not this module
|
||||
can be unloaded. Our answer is always "no".
|
||||
|
@ -118,18 +119,19 @@ DllCanUnloadNow(
|
|||
return S_FALSE;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
HRESULT
|
||||
STDAPICALLTYPE
|
||||
DllGetClassObject(
|
||||
_In_ REFCLSID ClassId,
|
||||
_In_ REFIID InterfaceId,
|
||||
_Outptr_ LPVOID *Interface
|
||||
REFCLSID ClassId,
|
||||
REFIID InterfaceId,
|
||||
LPVOID *Interface
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
This routine is called by COM in order to instantiate the
|
||||
This routine is called by COM in order to instantiate the
|
||||
skeleton driver callback object and do an initial query interface on it.
|
||||
|
||||
This method only creates an instance of the driver's class factory, as this
|
||||
|
@ -145,7 +147,7 @@ DllGetClassObject(
|
|||
|
||||
Return Value:
|
||||
|
||||
S_OK if the function succeeds or error indicating the cause of the
|
||||
S_OK if the function succeeds or error indicating the cause of the
|
||||
failure.
|
||||
|
||||
--*/
|
||||
|
@ -157,9 +159,9 @@ DllGetClassObject(
|
|||
*Interface = NULL;
|
||||
|
||||
//
|
||||
// If the CLSID doesn't match that of our "coclass" (defined in the IDL
|
||||
// file) then we can't create the object the caller wants. This may
|
||||
// indicate that the COM registration is incorrect, and another CLSID
|
||||
// If the CLSID doesn't match that of our "coclass" (defined in the IDL
|
||||
// file) then we can't create the object the caller wants. This may
|
||||
// indicate that the COM registration is incorrect, and another CLSID
|
||||
// is referencing this drvier.
|
||||
//
|
||||
|
||||
|
@ -180,19 +182,19 @@ DllGetClassObject(
|
|||
|
||||
factory = new CClassFactory();
|
||||
|
||||
if (NULL == factory)
|
||||
if (NULL == factory)
|
||||
{
|
||||
hr = E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Query the object we created for the interface the caller wants. After
|
||||
// that we release the object. This will drive the reference count to
|
||||
// that we release the object. This will drive the reference count to
|
||||
// 1 (if the QI succeeded an referenced the object) or 0 (if the QI failed).
|
||||
// In the later case the object is automatically deleted.
|
||||
//
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = factory->QueryInterface(InterfaceId, Interface);
|
||||
factory->Release();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*++
|
||||
|
||||
|
||||
Copyright (C) Microsoft Corporation, All Rights Reserved.
|
||||
|
||||
Module Name:
|
||||
|
@ -8,24 +8,24 @@ Module Name:
|
|||
|
||||
Abstract:
|
||||
|
||||
This module contains the implementation of the UMDF Skeleton Sample
|
||||
This module contains the implementation of the UMDF Skeleton Sample
|
||||
Driver's entry point and its exported functions for providing COM support.
|
||||
|
||||
This module can be copied without modification to a new UMDF driver. It
|
||||
depends on some of the code in comsup.cpp & comsup.h to handle DLL
|
||||
depends on some of the code in comsup.cpp & comsup.h to handle DLL
|
||||
registration and creating the first class factory.
|
||||
|
||||
This module is dependent on the following defines:
|
||||
|
||||
MYDRIVER_TRACING_ID - A wide string passed to WPP when initializing
|
||||
tracing. For example the skeleton uses
|
||||
MYDRIVER_TRACING_ID - A wide string passed to WPP when initializing
|
||||
tracing. For example the skeleton uses
|
||||
L"Microsoft\\UMDF\\Skeleton"
|
||||
|
||||
MYDRIVER_CLASS_ID - A GUID encoded in struct format used to
|
||||
initialize the driver's ClassID.
|
||||
MYDRIVER_CLASS_ID - A GUID encoded in struct format used to
|
||||
initialize the driver's ClassID.
|
||||
|
||||
These are defined in internal.h for the skeleton sample. If you choose
|
||||
to use a different primary include file, you should ensure they are
|
||||
to use a different primary include file, you should ensure they are
|
||||
defined there as well.
|
||||
|
||||
Environment:
|
||||
|
@ -50,10 +50,10 @@ DllMain(
|
|||
|
||||
Routine Description:
|
||||
|
||||
This is the entry point and exit point for the I/O trace driver. This
|
||||
This is the entry point and exit point for the I/O trace driver. This
|
||||
does very little as the I/O trace driver has minimal global data.
|
||||
|
||||
This method initializes tracing, and saves the module handle away in a
|
||||
This method initializes tracing, and saves the module handle away in a
|
||||
global variable so that it can be referenced should the COM registration
|
||||
code (Dll[Un]RegisterServer) be called.
|
||||
|
||||
|
@ -72,7 +72,7 @@ DllMain(
|
|||
--*/
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ModuleHandle);
|
||||
|
||||
|
||||
if (DLL_PROCESS_ATTACH == Reason)
|
||||
{
|
||||
//
|
||||
|
@ -93,6 +93,7 @@ DllMain(
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
HRESULT
|
||||
STDAPICALLTYPE
|
||||
DllCanUnloadNow(
|
||||
|
@ -100,7 +101,7 @@ DllCanUnloadNow(
|
|||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Routine Description:
|
||||
|
||||
Called by the COM runtime when determining whether or not this module
|
||||
can be unloaded. Our answer is always "no".
|
||||
|
@ -118,18 +119,19 @@ DllCanUnloadNow(
|
|||
return S_FALSE;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
HRESULT
|
||||
STDAPICALLTYPE
|
||||
DllGetClassObject(
|
||||
_In_ REFCLSID ClassId,
|
||||
_In_ REFIID InterfaceId,
|
||||
_Outptr_ LPVOID *Interface
|
||||
REFCLSID ClassId,
|
||||
REFIID InterfaceId,
|
||||
LPVOID *Interface
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
This routine is called by COM in order to instantiate the
|
||||
This routine is called by COM in order to instantiate the
|
||||
skeleton driver callback object and do an initial query interface on it.
|
||||
|
||||
This method only creates an instance of the driver's class factory, as this
|
||||
|
@ -145,7 +147,7 @@ DllGetClassObject(
|
|||
|
||||
Return Value:
|
||||
|
||||
S_OK if the function succeeds or error indicating the cause of the
|
||||
S_OK if the function succeeds or error indicating the cause of the
|
||||
failure.
|
||||
|
||||
--*/
|
||||
|
@ -157,9 +159,9 @@ DllGetClassObject(
|
|||
*Interface = NULL;
|
||||
|
||||
//
|
||||
// If the CLSID doesn't match that of our "coclass" (defined in the IDL
|
||||
// file) then we can't create the object the caller wants. This may
|
||||
// indicate that the COM registration is incorrect, and another CLSID
|
||||
// If the CLSID doesn't match that of our "coclass" (defined in the IDL
|
||||
// file) then we can't create the object the caller wants. This may
|
||||
// indicate that the COM registration is incorrect, and another CLSID
|
||||
// is referencing this drvier.
|
||||
//
|
||||
|
||||
|
@ -180,19 +182,19 @@ DllGetClassObject(
|
|||
|
||||
factory = new CClassFactory();
|
||||
|
||||
if (NULL == factory)
|
||||
if (NULL == factory)
|
||||
{
|
||||
hr = E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Query the object we created for the interface the caller wants. After
|
||||
// that we release the object. This will drive the reference count to
|
||||
// that we release the object. This will drive the reference count to
|
||||
// 1 (if the QI succeeded an referenced the object) or 0 (if the QI failed).
|
||||
// In the later case the object is automatically deleted.
|
||||
//
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = factory->QueryInterface(InterfaceId, Interface);
|
||||
factory->Release();
|
||||
|
|
Загрузка…
Ссылка в новой задаче