void Reader::IoSmartCardTransmit(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) { UNREFERENCED_PARAMETER(inBufSize); UNREFERENCED_PARAMETER(outBufSize); OutputDebugString(L"[BixVReader][TRSM]IOCTL_SMARTCARD_TRANSMIT"); SCARD_IO_REQUEST *scardRequest=NULL; int scardRequestSize=0; BYTE *RAPDU=NULL; int RAPDUSize=0; if (!getBuffer(pRequest,(void **)&scardRequest,&scardRequestSize) || scardRequestSize<sizeof *scardRequest || scardRequest->dwProtocol!=protocol) { SectionLocker lock(device->m_RequestLock); pRequest->CompleteWithInformation(STATUS_INVALID_DEVICE_STATE, 0); goto end; } if (!QueryTransmit((BYTE *)(scardRequest+1), scardRequestSize-sizeof(SCARD_IO_REQUEST), &RAPDU,&RAPDUSize)) { SectionLocker lock(device->m_RequestLock); pRequest->CompleteWithInformation(STATUS_NO_MEDIA, 0); goto end; } SCARD_IO_REQUEST *p=(SCARD_IO_REQUEST *)realloc(scardRequest,RAPDUSize+sizeof(SCARD_IO_REQUEST)); if (p==NULL) { SectionLocker lock(device->m_RequestLock); pRequest->CompleteWithInformation(STATUS_INVALID_DEVICE_STATE, 0); goto end; } scardRequest = p; scardRequest->cbPciLength=sizeof(SCARD_IO_REQUEST); scardRequest->dwProtocol=protocol; memcpy(scardRequest+1,RAPDU,RAPDUSize); setBuffer(device,pRequest,scardRequest,RAPDUSize+sizeof(SCARD_IO_REQUEST)); end: free(scardRequest); free(RAPDU); }
void Reader::IoSmartCardTransmit(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) { UNREFERENCED_PARAMETER(inBufSize); UNREFERENCED_PARAMETER(outBufSize); OutputDebugString(L"[BixVReader][TRSM]IOCTL_SMARTCARD_TRANSMIT"); BYTE APDU[1000]; int APDUSize; getBuffer(pRequest,APDU,&APDUSize); if (((SCARD_IO_REQUEST*)APDU)->dwProtocol!=protocol) { SectionLocker lock(device->m_RequestLock); pRequest->CompleteWithInformation(STATUS_INVALID_DEVICE_STATE, 0); return; } BYTE Resp[1000]; int RespSize; if (!QueryTransmit(APDU+sizeof(SCARD_IO_REQUEST),APDUSize-sizeof(SCARD_IO_REQUEST),Resp+sizeof(SCARD_IO_REQUEST),&RespSize)) { SectionLocker lock(device->m_RequestLock); pRequest->CompleteWithInformation(STATUS_NO_MEDIA, 0); return; } ((SCARD_IO_REQUEST*)Resp)->cbPciLength=sizeof(SCARD_IO_REQUEST); ((SCARD_IO_REQUEST*)Resp)->dwProtocol=protocol; setBuffer(device,pRequest,Resp,RespSize+sizeof(SCARD_IO_REQUEST)); }