Exemplo n.º 1
0
BOOL UsbDeviceList::FindFilterForInterface(LPCUSB_DEVICE lpDevice, LPCUSB_INTERFACE lpInterface, LPDWORD index)
{
	for (DWORD i = 0; i < mNumInterfaceFilters; i++) {
		BOOL match = MatchFilterField(true, lpInterface->Descriptor.bInterfaceClass, &mInterfaceFilters[i].bInterfaceClass);
		match &= MatchFilterField(match, lpInterface->Descriptor.bInterfaceSubClass, &mInterfaceFilters[i].bInterfaceSubClass);
		match &= MatchFilterField(match, lpInterface->Descriptor.bInterfaceProtocol, &mInterfaceFilters[i].bInterfaceProtocol);
		match &= MatchFilterField(match, lpDevice->Descriptor.idVendor, &mInterfaceFilters[i].idVendor);
		match &= MatchFilterField(match, lpDevice->Descriptor.idProduct, &mInterfaceFilters[i].idProduct);

		if (match) {
			(*index) = i;
			return TRUE;
		}
	}

	// No match
	return FALSE;
}
Exemplo n.º 2
0
BOOL UsbDeviceList::FindFilterForInterface(LPCUSB_DEVICE lpDevice, LPCUSB_INTERFACE lpInterface, LPINTERFACE_FILTER* filter)
{
	// Filter list is maintained in priority order
	PFILTER_NODE next = mInterfaceFilters;
	while (next) {
		BOOL match = MatchFilterField(true, lpInterface->Descriptor.bInterfaceClass, &next->filter.bInterfaceClass);
		match &= MatchFilterField(match, lpInterface->Descriptor.bInterfaceSubClass, &next->filter.bInterfaceSubClass);
		match &= MatchFilterField(match, lpInterface->Descriptor.bInterfaceProtocol, &next->filter.bInterfaceProtocol);
		match &= MatchFilterField(match, lpDevice->Descriptor.idVendor, &next->filter.idVendor);
		match &= MatchFilterField(match, lpDevice->Descriptor.idProduct, &next->filter.idProduct);

		if (match) {
			(*filter) = &next->filter;
			return TRUE;
		}

		next = next->next;
	}

	// No match
	return FALSE;
}