Last active
February 22, 2019 23:27
-
-
Save jnmronquillo/55e031a3eb6c845a01b530c816460a8f to your computer and use it in GitHub Desktop.
Snippet from method CBiometricDevice::CreateUsbIoTargets From Line 582
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (SUCCEEDED(hr)) | |
{ | |
//UCHAR NumInterfaces = pIUsbTargetDevice->GetNumInterfaces(); | |
UCHAR NumInterfaces = m_pIUsbTargetDevice->GetNumInterfaces(); | |
TraceEvents(TRACE_LEVEL_INFORMATION, | |
BIOMETRIC_TRACE_DEVICE, | |
"%!FUNC! Found %u interfaces", | |
NumInterfaces | |
); | |
//hr = pIUsbTargetDevice->RetrieveUsbInterface(0, &pIUsbInterface); | |
//hr = m_pIUsbTargetDevice->RetrieveUsbInterface(1, &pIUsbInterface);//JMRR | |
for (UCHAR InterfaceIndex = 0; InterfaceIndex < NumInterfaces; InterfaceIndex++) | |
{ | |
hr = m_pIUsbTargetDevice->RetrieveUsbInterface(InterfaceIndex, &pIUsbInterface);//JMRR | |
if (FAILED(hr)) | |
{ | |
TraceEvents(TRACE_LEVEL_ERROR, | |
BIOMETRIC_TRACE_DEVICE, | |
"%!FUNC! Unable to retrieve USB interface from USB Device I/O Target %!HRESULT!", | |
hr | |
); | |
} | |
else | |
{ | |
m_pIUsbInterface = pIUsbInterface; | |
BiometricSafeRelease(pIUsbInterface); // release creation reference | |
} | |
////// | |
/*if (SUCCEEDED(hr)) | |
{ | |
//NumEndPoints = pIUsbInterface->GetNumEndPoints(); | |
NumEndPoints = m_pIUsbInterface->GetNumEndPoints(); //JMRR | |
// TODO: Change NUM_WBDI_ENDPOINTS to match your device | |
if (NumEndPoints != NUM_WBDI_ENDPOINTS) | |
{ | |
hr = E_UNEXPECTED; | |
TraceEvents(TRACE_LEVEL_ERROR, | |
BIOMETRIC_TRACE_DEVICE, | |
"%!FUNC! Has %d endpoints, expected %d, returning %!HRESULT! ", | |
NumEndPoints, | |
NUM_WBDI_ENDPOINTS, | |
hr | |
); | |
} | |
}*/ | |
if (SUCCEEDED(hr)) | |
{ | |
NumEndPoints = m_pIUsbInterface->GetNumEndPoints(); //JMRR | |
for (UCHAR PipeIndex = 0; PipeIndex < NumEndPoints; PipeIndex++) | |
{ | |
//hr = pIUsbInterface->RetrieveUsbPipeObject(PipeIndex, &pIUsbPipe); | |
hr = m_pIUsbInterface->RetrieveUsbPipeObject(PipeIndex, &pIUsbPipe);//JMRR | |
if (FAILED(hr)) | |
{ | |
TraceEvents(TRACE_LEVEL_ERROR, | |
BIOMETRIC_TRACE_DEVICE, | |
"%!FUNC! Unable to retrieve USB Pipe for PipeIndex %d, %!HRESULT!", | |
PipeIndex, | |
hr | |
); | |
} | |
else | |
{ | |
if (pIUsbPipe->IsInEndPoint()) | |
{ | |
if (UsbdPipeTypeInterrupt == pIUsbPipe->GetType()) | |
{ | |
m_pIUsbInterruptPipe = pIUsbPipe; | |
} | |
else if (UsbdPipeTypeBulk == pIUsbPipe->GetType()) | |
{ | |
m_pIUsbInputPipe = pIUsbPipe; | |
} | |
else | |
{ | |
pIUsbPipe->DeleteWdfObject(); | |
} | |
} | |
else if (pIUsbPipe->IsOutEndPoint() && (UsbdPipeTypeBulk == pIUsbPipe->GetType())) | |
{ | |
m_pIUsbOutputPipe = pIUsbPipe; | |
} | |
else | |
{ | |
pIUsbPipe->DeleteWdfObject(); | |
} | |
BiometricSafeRelease(pIUsbPipe); //release creation reference | |
} | |
} | |
} | |
} | |
} | |
if (NULL == m_pIUsbInputPipe || NULL == m_pIUsbOutputPipe || NULL == m_pIUsbInterruptPipe) | |
{ | |
hr = E_UNEXPECTED; | |
TraceEvents(TRACE_LEVEL_ERROR, | |
BIOMETRIC_TRACE_DEVICE, | |
"%!FUNC! Input or output or interrupt pipe not found, returning %!HRESULT!", | |
hr | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment