channels/smartcard: handle ntstatus codes
This commit is contained in:
parent
f158cf0ac3
commit
7b4c44c5ff
@ -190,9 +190,12 @@ static UINT32 smartcard_EstablishContext(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
ret.Context.cbContext = sizeof(ULONG_PTR);
|
||||
ret.Context.pbContext = (UINT64) hContext;
|
||||
|
||||
smartcard_pack_establish_context_return(smartcard, irp->output, &ret);
|
||||
status = smartcard_pack_establish_context_return(smartcard, irp->output, &ret);
|
||||
|
||||
return status;
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static UINT32 smartcard_ReleaseContext(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -213,7 +216,7 @@ static UINT32 smartcard_ReleaseContext(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
smartcard->hContext = 0;
|
||||
|
||||
return status;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static UINT32 smartcard_IsValidContext(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -232,7 +235,7 @@ static UINT32 smartcard_IsValidContext(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardIsValidContext(hContext);
|
||||
|
||||
return status;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static UINT32 smartcard_ListReadersA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -247,7 +250,7 @@ static UINT32 smartcard_ListReadersA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
status = smartcard_unpack_list_readers_call(smartcard, irp->input, &call);
|
||||
|
||||
if (status)
|
||||
goto finish;
|
||||
return status;
|
||||
|
||||
hContext = (ULONG_PTR) call.Context.pbContext;
|
||||
|
||||
@ -255,24 +258,24 @@ static UINT32 smartcard_ListReadersA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardListReadersA(hContext, (LPCSTR) call.mszGroups, (LPSTR) &mszReaders, &cchReaders);
|
||||
|
||||
if (status != SCARD_S_SUCCESS)
|
||||
goto finish;
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
ret.msz = (BYTE*) mszReaders;
|
||||
ret.cBytes = smartcard_multi_string_length_a((char*) ret.msz) + 2;
|
||||
|
||||
smartcard_pack_list_readers_return(smartcard, irp->output, &ret);
|
||||
status = smartcard_pack_list_readers_return(smartcard, irp->output, &ret);
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
finish:
|
||||
if (mszReaders)
|
||||
{
|
||||
SCardFreeMemory(hContext, mszReaders);
|
||||
}
|
||||
|
||||
if (call.mszGroups)
|
||||
free(call.mszGroups);
|
||||
|
||||
return status;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static UINT32 smartcard_ListReadersW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -287,7 +290,7 @@ static UINT32 smartcard_ListReadersW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
status = smartcard_unpack_list_readers_call(smartcard, irp->input, &call);
|
||||
|
||||
if (status)
|
||||
goto finish;
|
||||
return status;
|
||||
|
||||
hContext = (ULONG_PTR) call.Context.pbContext;
|
||||
|
||||
@ -295,24 +298,24 @@ static UINT32 smartcard_ListReadersW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardListReadersW(hContext, (LPCWSTR) call.mszGroups, (LPWSTR) &mszReaders, &cchReaders);
|
||||
|
||||
if (status != SCARD_S_SUCCESS)
|
||||
goto finish;
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
ret.msz = (BYTE*) mszReaders;
|
||||
ret.cBytes = (smartcard_multi_string_length_w((WCHAR*) ret.msz) + 2) * 2;
|
||||
|
||||
smartcard_pack_list_readers_return(smartcard, irp->output, &ret);
|
||||
status = smartcard_pack_list_readers_return(smartcard, irp->output, &ret);
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
finish:
|
||||
if (mszReaders)
|
||||
{
|
||||
SCardFreeMemory(hContext, mszReaders);
|
||||
}
|
||||
|
||||
if (call.mszGroups)
|
||||
free(call.mszGroups);
|
||||
|
||||
return status;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static UINT32 smartcard_GetStatusChangeA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -348,6 +351,9 @@ static UINT32 smartcard_GetStatusChangeA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardGetStatusChangeA(hContext, call.dwTimeOut, rgReaderStates, call.cReaders);
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
ret.cReaders = call.cReaders;
|
||||
ret.rgReaderStates = (ReaderState_Return*) calloc(ret.cReaders, sizeof(ReaderState_Return));
|
||||
|
||||
@ -363,6 +369,9 @@ static UINT32 smartcard_GetStatusChangeA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = smartcard_pack_get_status_change_return(smartcard, irp->output, &ret);
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
if (call.rgReaderStates)
|
||||
{
|
||||
for (index = 0; index < call.cReaders; index++)
|
||||
@ -379,7 +388,7 @@ static UINT32 smartcard_GetStatusChangeA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
free(ret.rgReaderStates);
|
||||
|
||||
return status;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static UINT32 smartcard_GetStatusChangeW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -415,6 +424,9 @@ static UINT32 smartcard_GetStatusChangeW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardGetStatusChangeW(hContext, (DWORD) call.dwTimeOut, rgReaderStates, (DWORD) call.cReaders);
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
ret.cReaders = call.cReaders;
|
||||
ret.rgReaderStates = (ReaderState_Return*) calloc(ret.cReaders, sizeof(ReaderState_Return));
|
||||
|
||||
@ -430,6 +442,9 @@ static UINT32 smartcard_GetStatusChangeW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = smartcard_pack_get_status_change_return(smartcard, irp->output, &ret);
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
if (call.rgReaderStates)
|
||||
{
|
||||
for (index = 0; index < call.cReaders; index++)
|
||||
@ -446,7 +461,7 @@ static UINT32 smartcard_GetStatusChangeW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
free(ret.rgReaderStates);
|
||||
|
||||
return status;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static UINT32 smartcard_Cancel(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -465,7 +480,7 @@ static UINT32 smartcard_Cancel(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardCancel(hContext);
|
||||
|
||||
return status;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
UINT32 smartcard_ConnectA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -481,7 +496,7 @@ UINT32 smartcard_ConnectA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
status = smartcard_unpack_connect_a_call(smartcard, irp->input, &call);
|
||||
|
||||
if (status)
|
||||
goto finish;
|
||||
return status;
|
||||
|
||||
hContext = (ULONG_PTR) call.Common.Context.pbContext;
|
||||
|
||||
@ -494,6 +509,9 @@ UINT32 smartcard_ConnectA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
status = ret.ReturnCode = SCardConnectA(hContext, (char*) call.szReader, call.Common.dwShareMode,
|
||||
call.Common.dwPreferredProtocols, &hCard, &ret.dwActiveProtocol);
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
smartcard->hCard = hCard;
|
||||
|
||||
ret.hCard.Context.cbContext = 0;
|
||||
@ -502,13 +520,15 @@ UINT32 smartcard_ConnectA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
ret.hCard.cbHandle = sizeof(ULONG_PTR);
|
||||
ret.hCard.pbHandle = (UINT64) hCard;
|
||||
|
||||
smartcard_pack_connect_return(smartcard, irp->output, &ret);
|
||||
status = smartcard_pack_connect_return(smartcard, irp->output, &ret);
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
finish:
|
||||
if (call.szReader)
|
||||
free(call.szReader);
|
||||
|
||||
return status;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
UINT32 smartcard_ConnectW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -524,7 +544,7 @@ UINT32 smartcard_ConnectW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
status = smartcard_unpack_connect_w_call(smartcard, irp->input, &call);
|
||||
|
||||
if (status)
|
||||
goto finish;
|
||||
return status;
|
||||
|
||||
hContext = (ULONG_PTR) call.Common.Context.pbContext;
|
||||
|
||||
@ -537,6 +557,9 @@ UINT32 smartcard_ConnectW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
status = ret.ReturnCode = SCardConnectW(hContext, (WCHAR*) call.szReader, call.Common.dwShareMode,
|
||||
call.Common.dwPreferredProtocols, &hCard, &ret.dwActiveProtocol);
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
smartcard->hCard = hCard;
|
||||
|
||||
ret.hCard.Context.cbContext = 0;
|
||||
@ -547,11 +570,13 @@ UINT32 smartcard_ConnectW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = smartcard_pack_connect_return(smartcard, irp->output, &ret);
|
||||
|
||||
finish:
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
if (call.szReader)
|
||||
free(call.szReader);
|
||||
|
||||
return status;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static UINT32 smartcard_Reconnect(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -573,9 +598,15 @@ static UINT32 smartcard_Reconnect(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
status = ret.ReturnCode = SCardReconnect(hCard, call.dwShareMode,
|
||||
call.dwPreferredProtocols, call.dwInitialization, &ret.dwActiveProtocol);
|
||||
|
||||
smartcard_pack_reconnect_return(smartcard, irp->output, &ret);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
return status;
|
||||
status = smartcard_pack_reconnect_return(smartcard, irp->output, &ret);
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static UINT32 smartcard_Disconnect(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -596,9 +627,12 @@ static UINT32 smartcard_Disconnect(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardDisconnect(hCard, (DWORD) call.dwDisposition);
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
smartcard->hCard = 0;
|
||||
|
||||
return status;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static UINT32 smartcard_BeginTransaction(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -619,7 +653,10 @@ static UINT32 smartcard_BeginTransaction(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardBeginTransaction(hCard);
|
||||
|
||||
return status;
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static UINT32 smartcard_EndTransaction(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -640,7 +677,10 @@ static UINT32 smartcard_EndTransaction(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardEndTransaction(hCard, call.dwDisposition);
|
||||
|
||||
return status;
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static UINT32 smartcard_State(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -663,15 +703,18 @@ static UINT32 smartcard_State(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardState(hCard, &ret.dwState, &ret.dwProtocol, (BYTE*) &ret.rgAtr, &ret.cbAtrLen);
|
||||
|
||||
if (status != SCARD_S_SUCCESS)
|
||||
if (ret.ReturnCode)
|
||||
{
|
||||
Stream_Zero(irp->output, 256);
|
||||
return status;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
smartcard_pack_state_return(smartcard, irp->output, &ret);
|
||||
status = smartcard_pack_state_return(smartcard, irp->output, &ret);
|
||||
|
||||
return status;
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static DWORD smartcard_StatusA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -687,7 +730,7 @@ static DWORD smartcard_StatusA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
status = smartcard_unpack_status_call(smartcard, irp->input, &call);
|
||||
|
||||
if (status)
|
||||
goto finish;
|
||||
return status;
|
||||
|
||||
hCard = (ULONG_PTR) call.hCard.pbHandle;
|
||||
hContext = (ULONG_PTR) call.hCard.Context.pbContext;
|
||||
@ -703,24 +746,24 @@ static DWORD smartcard_StatusA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
status = ret.ReturnCode = SCardStatusA(hCard, (LPSTR) &mszReaderNames, &cchReaderLen,
|
||||
&ret.dwState, &ret.dwProtocol, (BYTE*) &ret.pbAtr, &ret.cbAtrLen);
|
||||
|
||||
if (status != SCARD_S_SUCCESS)
|
||||
if (ret.ReturnCode)
|
||||
{
|
||||
Stream_Zero(irp->output, 256);
|
||||
goto finish;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
ret.mszReaderNames = (BYTE*) mszReaderNames;
|
||||
ret.cBytes = smartcard_multi_string_length_a((char*) ret.mszReaderNames) + 2;
|
||||
|
||||
smartcard_pack_status_return(smartcard, irp->output, &ret);
|
||||
status = smartcard_pack_status_return(smartcard, irp->output, &ret);
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
finish:
|
||||
if (mszReaderNames)
|
||||
{
|
||||
SCardFreeMemory(hContext, mszReaderNames);
|
||||
}
|
||||
|
||||
return status;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static DWORD smartcard_StatusW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -736,7 +779,7 @@ static DWORD smartcard_StatusW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
status = smartcard_unpack_status_call(smartcard, irp->input, &call);
|
||||
|
||||
if (status)
|
||||
goto finish;
|
||||
return status;
|
||||
|
||||
hCard = (ULONG_PTR) call.hCard.pbHandle;
|
||||
hContext = (ULONG_PTR) call.hCard.Context.pbContext;
|
||||
@ -752,24 +795,24 @@ static DWORD smartcard_StatusW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
status = ret.ReturnCode = SCardStatusW(hCard, (LPWSTR) &mszReaderNames, &cchReaderLen,
|
||||
&ret.dwState, &ret.dwProtocol, (BYTE*) &ret.pbAtr, &ret.cbAtrLen);
|
||||
|
||||
if (status != SCARD_S_SUCCESS)
|
||||
if (ret.ReturnCode)
|
||||
{
|
||||
Stream_Zero(irp->output, 256);
|
||||
goto finish;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
ret.mszReaderNames = (BYTE*) mszReaderNames;
|
||||
ret.cBytes = (smartcard_multi_string_length_w((WCHAR*) ret.mszReaderNames) + 2) * 2;
|
||||
|
||||
smartcard_pack_status_return(smartcard, irp->output, &ret);
|
||||
status = smartcard_pack_status_return(smartcard, irp->output, &ret);
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
finish:
|
||||
if (mszReaderNames)
|
||||
{
|
||||
SCardFreeMemory(hContext, mszReaderNames);
|
||||
}
|
||||
|
||||
return status;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static UINT32 smartcard_Transmit(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -783,7 +826,7 @@ static UINT32 smartcard_Transmit(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
status = smartcard_unpack_transmit_call(smartcard, irp->input, &call);
|
||||
|
||||
if (status)
|
||||
goto finish;
|
||||
return status;
|
||||
|
||||
hCard = (ULONG_PTR) call.hCard.pbHandle;
|
||||
hContext = (ULONG_PTR) call.hCard.Context.pbContext;
|
||||
@ -802,9 +845,14 @@ static UINT32 smartcard_Transmit(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
status = ret.ReturnCode = SCardTransmit(hCard, call.pioSendPci, call.pbSendBuffer,
|
||||
call.cbSendLength, ret.pioRecvPci, ret.pbRecvBuffer, &(ret.cbRecvLength));
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
status = smartcard_pack_transmit_return(smartcard, irp->output, &ret);
|
||||
|
||||
finish:
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
if (call.pbSendBuffer)
|
||||
free(call.pbSendBuffer);
|
||||
if (ret.pbRecvBuffer)
|
||||
@ -814,7 +862,7 @@ finish:
|
||||
if (call.pioRecvPci)
|
||||
free(call.pioRecvPci);
|
||||
|
||||
return status;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static UINT32 smartcard_Control(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -829,7 +877,7 @@ static UINT32 smartcard_Control(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
status = smartcard_unpack_control_call(smartcard, irp->input, &call);
|
||||
|
||||
if (status)
|
||||
goto finish;
|
||||
return status;
|
||||
|
||||
hCard = (ULONG_PTR) call.hCard.pbHandle;
|
||||
hContext = (ULONG_PTR) call.hCard.Context.pbContext;
|
||||
@ -847,15 +895,20 @@ static UINT32 smartcard_Control(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
call.dwControlCode, call.pvInBuffer, call.cbInBufferSize,
|
||||
ret.pvOutBuffer, call.cbOutBufferSize, &ret.cbOutBufferSize);
|
||||
|
||||
smartcard_pack_control_return(smartcard, irp->output, &ret);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
status = smartcard_pack_control_return(smartcard, irp->output, &ret);
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
finish:
|
||||
if (call.pvInBuffer)
|
||||
free(call.pvInBuffer);
|
||||
if (ret.pvOutBuffer)
|
||||
free(ret.pvOutBuffer);
|
||||
|
||||
return status;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static UINT32 smartcard_GetAttrib(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -881,53 +934,49 @@ static UINT32 smartcard_GetAttrib(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
status = ret.ReturnCode = SCardGetAttrib(hCard, call.dwAttrId,
|
||||
(cbAttrLen == 0) ? NULL : (BYTE*) &ret.pbAttr, &cbAttrLen);
|
||||
|
||||
if (status != SCARD_S_SUCCESS)
|
||||
{
|
||||
if (status)
|
||||
cbAttrLen = (call.cbAttrLen == 0) ? 0 : SCARD_AUTOALLOCATE;
|
||||
}
|
||||
|
||||
if (call.dwAttrId == SCARD_ATTR_DEVICE_FRIENDLY_NAME_A && status == SCARD_E_UNSUPPORTED_FEATURE)
|
||||
if ((call.dwAttrId == SCARD_ATTR_DEVICE_FRIENDLY_NAME_A) && (status == SCARD_E_UNSUPPORTED_FEATURE))
|
||||
{
|
||||
status = SCardGetAttrib(hCard, SCARD_ATTR_DEVICE_FRIENDLY_NAME_W,
|
||||
(cbAttrLen == 0) ? NULL : (BYTE*) &ret.pbAttr, &cbAttrLen);
|
||||
|
||||
if (status != SCARD_S_SUCCESS)
|
||||
{
|
||||
if (status)
|
||||
cbAttrLen = (call.cbAttrLen == 0) ? 0 : SCARD_AUTOALLOCATE;
|
||||
}
|
||||
}
|
||||
|
||||
if (call.dwAttrId == SCARD_ATTR_DEVICE_FRIENDLY_NAME_W && status == SCARD_E_UNSUPPORTED_FEATURE)
|
||||
if ((call.dwAttrId == SCARD_ATTR_DEVICE_FRIENDLY_NAME_W) && (status == SCARD_E_UNSUPPORTED_FEATURE))
|
||||
{
|
||||
status = SCardGetAttrib(hCard, SCARD_ATTR_DEVICE_FRIENDLY_NAME_A,
|
||||
(cbAttrLen == 0) ? NULL : (BYTE*) &ret.pbAttr, &cbAttrLen);
|
||||
|
||||
if (status != SCARD_S_SUCCESS)
|
||||
{
|
||||
if (status)
|
||||
cbAttrLen = (call.cbAttrLen == 0) ? 0 : SCARD_AUTOALLOCATE;
|
||||
}
|
||||
}
|
||||
|
||||
if ((cbAttrLen > call.cbAttrLen) && (ret.pbAttr != NULL))
|
||||
{
|
||||
if ((cbAttrLen > call.cbAttrLen) && (ret.pbAttr))
|
||||
status = SCARD_E_INSUFFICIENT_BUFFER;
|
||||
}
|
||||
|
||||
ret.ReturnCode = status;
|
||||
|
||||
call.cbAttrLen = cbAttrLen;
|
||||
ret.cbAttrLen = call.cbAttrLen;
|
||||
|
||||
if (status != SCARD_S_SUCCESS)
|
||||
if (ret.ReturnCode)
|
||||
{
|
||||
Stream_Zero(irp->output, 256);
|
||||
goto finish;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
smartcard_pack_get_attrib_return(smartcard, irp->output, &ret);
|
||||
status = smartcard_pack_get_attrib_return(smartcard, irp->output, &ret);
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
finish:
|
||||
SCardFreeMemory(hContext, ret.pbAttr);
|
||||
|
||||
return status;
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
static UINT32 smartcard_AccessStartedEvent(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
@ -1248,7 +1297,7 @@ void smartcard_irp_device_control(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
smartcard_pack_write_offset_align(smartcard, irp->output, 8);
|
||||
|
||||
if ((result != SCARD_S_SUCCESS) && (result != SCARD_E_TIMEOUT))
|
||||
if ((result != SCARD_S_SUCCESS) /* && (result != SCARD_E_TIMEOUT) */)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN,
|
||||
"IRP failure: %s (0x%08X), status: %s (0x%08X)",
|
||||
@ -1256,6 +1305,20 @@ void smartcard_irp_device_control(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
SCardGetErrorString(result), result);
|
||||
}
|
||||
|
||||
irp->IoStatus = 0;
|
||||
|
||||
if ((result & 0xC0000000) == 0xC0000000)
|
||||
{
|
||||
/* NTSTATUS error */
|
||||
|
||||
irp->IoStatus = result;
|
||||
Stream_SetPosition(irp->output, RDPDR_DEVICE_IO_RESPONSE_LENGTH);
|
||||
|
||||
WLog_Print(smartcard->log, WLOG_WARN,
|
||||
"IRP failure: %s (0x%08X), ntstatus: 0x%08X",
|
||||
smartcard_get_ioctl_string(ioControlCode, TRUE), ioControlCode, result);
|
||||
}
|
||||
|
||||
Stream_SealLength(irp->output);
|
||||
outputBufferLength = Stream_Length(irp->output) - RDPDR_DEVICE_IO_RESPONSE_LENGTH - 4;
|
||||
objectBufferLength = outputBufferLength - RDPDR_DEVICE_IO_RESPONSE_LENGTH;
|
||||
@ -1271,6 +1334,5 @@ void smartcard_irp_device_control(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
Stream_SetPosition(irp->output, Stream_Length(irp->output));
|
||||
|
||||
irp->IoStatus = 0;
|
||||
smartcard_complete_irp(smartcard, irp);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ UINT32 smartcard_unpack_common_type_header(SMARTCARD_DEVICE* smartcard, wStream*
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "CommonTypeHeader is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
/* Process CommonTypeHeader */
|
||||
@ -50,25 +50,25 @@ UINT32 smartcard_unpack_common_type_header(SMARTCARD_DEVICE* smartcard, wStream*
|
||||
if (version != 1)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Unsupported CommonTypeHeader Version %d", version);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (endianness != 0x10)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Unsupported CommonTypeHeader Endianness %d", endianness);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (commonHeaderLength != 8)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Unsupported CommonTypeHeader CommonHeaderLength %d", commonHeaderLength);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (filler != 0xCCCCCCCC)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Unexpected CommonTypeHeader Filler 0x%08X", filler);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -93,7 +93,7 @@ UINT32 smartcard_unpack_private_type_header(SMARTCARD_DEVICE* smartcard, wStream
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "PrivateTypeHeader is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, objectBufferLength); /* ObjectBufferLength (4 bytes) */
|
||||
@ -102,14 +102,14 @@ UINT32 smartcard_unpack_private_type_header(SMARTCARD_DEVICE* smartcard, wStream
|
||||
if (filler != 0x00000000)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Unexpected PrivateTypeHeader Filler 0x%08X", filler);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (objectBufferLength != Stream_GetRemainingLength(s))
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "PrivateTypeHeader ObjectBufferLength mismatch: Actual: %d, Expected: %d",
|
||||
(int) objectBufferLength, Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -163,7 +163,7 @@ UINT32 smartcard_unpack_redir_scard_context(SMARTCARD_DEVICE* smartcard, wStream
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDCONTEXT is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, context->cbContext); /* cbContext (4 bytes) */
|
||||
@ -172,7 +172,7 @@ UINT32 smartcard_unpack_redir_scard_context(SMARTCARD_DEVICE* smartcard, wStream
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDCONTEXT is too short: Actual: %d, Expected: %d",
|
||||
(int) Stream_GetRemainingLength(s), context->cbContext);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Seek_UINT32(s); /* pbContextNdrPtr (4 bytes) */
|
||||
@ -181,7 +181,7 @@ UINT32 smartcard_unpack_redir_scard_context(SMARTCARD_DEVICE* smartcard, wStream
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDCONTEXT is too long: Actual: %d, Expected: %d",
|
||||
(int) Stream_GetRemainingLength(s), context->cbContext);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return SCARD_S_SUCCESS;
|
||||
@ -207,7 +207,7 @@ UINT32 smartcard_unpack_redir_scard_context_ref(SMARTCARD_DEVICE* smartcard, wSt
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDCONTEXT is too short: Actual: %d, Expected: %d\n",
|
||||
(int) Stream_GetRemainingLength(s), 4);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, length); /* Length (4 bytes) */
|
||||
@ -215,14 +215,14 @@ UINT32 smartcard_unpack_redir_scard_context_ref(SMARTCARD_DEVICE* smartcard, wSt
|
||||
if ((length != 4) && (length != 8))
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDCONTEXT length is not 4 or 8: %d\n", length);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((Stream_GetRemainingLength(s) < length) || (!length))
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDCONTEXT is too short: Actual: %d, Expected: %d\n",
|
||||
(int) Stream_GetRemainingLength(s), length);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
if (length > 4)
|
||||
@ -262,7 +262,7 @@ UINT32 smartcard_unpack_redir_scard_handle(SMARTCARD_DEVICE* smartcard, wStream*
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "SCARDHANDLE is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, length); /* Length (4 bytes) */
|
||||
@ -271,7 +271,7 @@ UINT32 smartcard_unpack_redir_scard_handle(SMARTCARD_DEVICE* smartcard, wStream*
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "SCARDHANDLE is too short: Actual: %d, Expected: %d",
|
||||
(int) Stream_GetRemainingLength(s), length);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Seek_UINT32(s); /* NdrPtr (4 bytes) */
|
||||
@ -311,7 +311,7 @@ UINT32 smartcard_unpack_redir_scard_handle_ref(SMARTCARD_DEVICE* smartcard, wStr
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDHANDLE is too short: Actual: %d, Expected: %d\n",
|
||||
(int) Stream_GetRemainingLength(s), 4);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, length); /* Length (4 bytes) */
|
||||
@ -319,14 +319,14 @@ UINT32 smartcard_unpack_redir_scard_handle_ref(SMARTCARD_DEVICE* smartcard, wStr
|
||||
if ((length != 4) && (length != 8))
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDHANDLE length is not 4 or 8: %d\n", length);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((Stream_GetRemainingLength(s) < length) || (!length))
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDHANDLE is too short: Actual: %d, Expected: %d\n",
|
||||
(int) Stream_GetRemainingLength(s), length);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
if (length > 4)
|
||||
@ -365,7 +365,7 @@ UINT32 smartcard_unpack_establish_context_call(SMARTCARD_DEVICE* smartcard, wStr
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "EstablishContext_Call is too short: Actual: %d, Expected: %d\n",
|
||||
(int) Stream_GetRemainingLength(s), 4);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, call->dwScope); /* dwScope (4 bytes) */
|
||||
@ -420,7 +420,7 @@ UINT32 smartcard_unpack_list_readers_call(SMARTCARD_DEVICE* smartcard, wStream*
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "ListReaders_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, call->cBytes); /* cBytes (4 bytes) */
|
||||
@ -429,7 +429,7 @@ UINT32 smartcard_unpack_list_readers_call(SMARTCARD_DEVICE* smartcard, wStream*
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "ListReaders_Call is too short: Actual: %d, Expected: %d",
|
||||
(int) Stream_GetRemainingLength(s), call->cBytes);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
call->mszGroups = NULL;
|
||||
@ -442,7 +442,7 @@ UINT32 smartcard_unpack_list_readers_call(SMARTCARD_DEVICE* smartcard, wStream*
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "ListReaders_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
status = smartcard_unpack_redir_scard_context_ref(smartcard, s, &(call->Context));
|
||||
@ -472,7 +472,7 @@ UINT32 smartcard_unpack_connect_common(SMARTCARD_DEVICE* smartcard, wStream* s,
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Connect_Common is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
status = smartcard_unpack_redir_scard_context(smartcard, s, &(common->Context));
|
||||
@ -497,7 +497,7 @@ UINT32 smartcard_unpack_connect_a_call(SMARTCARD_DEVICE* smartcard, wStream* s,
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "ConnectA_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Seek_UINT32(s); /* szReaderNdrPtr (4 bytes) */
|
||||
@ -534,7 +534,7 @@ UINT32 smartcard_unpack_connect_w_call(SMARTCARD_DEVICE* smartcard, wStream* s,
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "ConnectA_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Seek_UINT32(s); /* szReaderNdrPtr (4 bytes) */
|
||||
@ -592,7 +592,7 @@ UINT32 smartcard_unpack_reconnect_call(SMARTCARD_DEVICE* smartcard, wStream* s,
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Reconnect_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, call->dwShareMode); /* dwShareMode (4 bytes) */
|
||||
@ -627,7 +627,7 @@ UINT32 smartcard_unpack_hcard_and_disposition_call(SMARTCARD_DEVICE* smartcard,
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "HCardAndDisposition_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, call->dwDisposition); /* dwDisposition (4 bytes) */
|
||||
@ -658,7 +658,7 @@ UINT32 smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wS
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "GetStatusChangeA_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, call->dwTimeOut); /* dwTimeOut (4 bytes) */
|
||||
@ -674,7 +674,7 @@ UINT32 smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wS
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "GetStatusChangeA_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Seek_UINT32(s); /* NdrConformant (4 bytes) */
|
||||
@ -691,7 +691,7 @@ UINT32 smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wS
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "GetStatusChangeA_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Seek_UINT32(s); /* (4 bytes) */
|
||||
@ -714,7 +714,7 @@ UINT32 smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wS
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "GetStatusChangeA_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Seek_UINT32(s); /* NdrMaxCount (4 bytes) */
|
||||
@ -725,7 +725,7 @@ UINT32 smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wS
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "GetStatusChangeA_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
readerState->szReader = malloc(count + 1);
|
||||
@ -736,7 +736,7 @@ UINT32 smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wS
|
||||
if (!readerState->szReader)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "GetStatusChangeA_Call null reader name");
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (strcmp((char*) readerState->szReader, "\\\\?PnP?\\Notification") == 0)
|
||||
@ -767,7 +767,7 @@ UINT32 smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wS
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "GetStatusChangeW_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, call->dwTimeOut); /* dwTimeOut (4 bytes) */
|
||||
@ -783,7 +783,7 @@ UINT32 smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wS
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "GetStatusChangeW_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Seek_UINT32(s); /* NdrConformant (4 bytes) */
|
||||
@ -800,7 +800,7 @@ UINT32 smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wS
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "GetStatusChangeW_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Seek_UINT32(s); /* (4 bytes) */
|
||||
@ -823,7 +823,7 @@ UINT32 smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wS
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "GetStatusChangeW_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Seek_UINT32(s); /* NdrMaxCount (4 bytes) */
|
||||
@ -834,7 +834,7 @@ UINT32 smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wS
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "GetStatusChangeW_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
readerState->szReader = malloc((count + 1) * 2);
|
||||
@ -845,7 +845,7 @@ UINT32 smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wS
|
||||
if (!readerState->szReader)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "GetStatusChangeW_Call null reader name");
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -895,7 +895,7 @@ UINT32 smartcard_unpack_state_call(SMARTCARD_DEVICE* smartcard, wStream* s, Stat
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "State_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, call->fpbAtrIsNULL); /* fpbAtrIsNULL (4 bytes) */
|
||||
@ -935,7 +935,7 @@ UINT32 smartcard_unpack_status_call(SMARTCARD_DEVICE* smartcard, wStream* s, Sta
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Status_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, call->fmszReaderNamesIsNULL); /* fmszReaderNamesIsNULL (4 bytes) */
|
||||
@ -979,7 +979,7 @@ UINT32 smartcard_unpack_get_attrib_call(SMARTCARD_DEVICE* smartcard, wStream* s,
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "GetAttrib_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, call->dwAttrId); /* dwAttrId (4 bytes) */
|
||||
@ -1026,7 +1026,7 @@ UINT32 smartcard_unpack_control_call(SMARTCARD_DEVICE* smartcard, wStream* s, Co
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Control_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, call->dwControlCode); /* dwControlCode (4 bytes) */
|
||||
@ -1046,7 +1046,7 @@ UINT32 smartcard_unpack_control_call(SMARTCARD_DEVICE* smartcard, wStream* s, Co
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Control_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, length); /* Length (4 bytes) */
|
||||
@ -1055,7 +1055,7 @@ UINT32 smartcard_unpack_control_call(SMARTCARD_DEVICE* smartcard, wStream* s, Co
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Control_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
call->pvInBuffer = (BYTE*) malloc(length);
|
||||
@ -1106,7 +1106,7 @@ UINT32 smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, T
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Transmit_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, ioSendPci.dwProtocol); /* dwProtocol (4 bytes) */
|
||||
@ -1129,7 +1129,7 @@ UINT32 smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, T
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Transmit_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, length); /* Length (4 bytes) */
|
||||
@ -1138,7 +1138,7 @@ UINT32 smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, T
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Transmit_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
ioSendPci.pbExtraBytes = (BYTE*) Stream_Pointer(s);
|
||||
@ -1148,7 +1148,7 @@ UINT32 smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, T
|
||||
if (!call->pioSendPci)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Transmit_Call out of memory error (pioSendPci)");
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
call->pioSendPci->dwProtocol = ioSendPci.dwProtocol;
|
||||
@ -1165,7 +1165,7 @@ UINT32 smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, T
|
||||
if (!call->pioSendPci)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Transmit_Call out of memory error (pioSendPci)");
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
call->pioSendPci->dwProtocol = SCARD_PROTOCOL_T1;
|
||||
@ -1178,7 +1178,7 @@ UINT32 smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, T
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Transmit_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, length); /* Length (4 bytes) */
|
||||
@ -1187,14 +1187,14 @@ UINT32 smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, T
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Transmit_Call unexpected length: Actual: %d, Expected: %d",
|
||||
(int) length, (int) call->cbSendLength);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Stream_GetRemainingLength(s) < call->cbSendLength)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Transmit_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
call->pbSendBuffer = (BYTE*) malloc(call->cbSendLength);
|
||||
@ -1202,7 +1202,7 @@ UINT32 smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, T
|
||||
if (!call->pbSendBuffer)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Transmit_Call out of memory error (pbSendBuffer)");
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
Stream_Read(s, call->pbSendBuffer, call->cbSendLength);
|
||||
@ -1214,7 +1214,7 @@ UINT32 smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, T
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Transmit_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
winpr_HexDump(Stream_Pointer(s), Stream_GetRemainingLength(s));
|
||||
@ -1229,14 +1229,14 @@ UINT32 smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, T
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Transmit_Call unexpected length: Actual: %d, Expected: %d",
|
||||
(int) length, (int) ioRecvPci.cbExtraBytes);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Stream_GetRemainingLength(s) < ioRecvPci.cbExtraBytes)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Transmit_Call is too short: %d",
|
||||
(int) Stream_GetRemainingLength(s));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
ioRecvPci.pbExtraBytes = (BYTE*) Stream_Pointer(s);
|
||||
@ -1246,7 +1246,7 @@ UINT32 smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, T
|
||||
if (!call->pbSendBuffer)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "Transmit_Call out of memory error (pioRecvPci)");
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
call->pioRecvPci->dwProtocol = ioRecvPci.dwProtocol;
|
||||
|
Loading…
Reference in New Issue
Block a user