channels/smartcard: improve debug output, fix GetStatusChange SCARD_E_CANCELLED, fix SCardGetAttrib current protocol type
This commit is contained in:
parent
4460a1a7cf
commit
b3114ff4d8
@ -194,6 +194,8 @@ static UINT32 smartcard_ReleaseContext(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardReleaseContext(hContext);
|
||||
|
||||
smartcard_trace_long_return(smartcard, &ret, "ReleaseContext");
|
||||
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
@ -215,6 +217,8 @@ static UINT32 smartcard_IsValidContext(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardIsValidContext(hContext);
|
||||
|
||||
smartcard_trace_long_return(smartcard, &ret, "IsValidContext");
|
||||
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
@ -326,7 +330,7 @@ static UINT32 smartcard_GetStatusChangeA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardGetStatusChangeA(hContext, call.dwTimeOut, call.rgReaderStates, call.cReaders);
|
||||
|
||||
if (status && (status != SCARD_E_TIMEOUT))
|
||||
if (status && (status != SCARD_E_TIMEOUT) && (status != SCARD_E_CANCELLED))
|
||||
return status;
|
||||
|
||||
ret.cReaders = call.cReaders;
|
||||
@ -384,7 +388,7 @@ static UINT32 smartcard_GetStatusChangeW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardGetStatusChangeW(hContext, call.dwTimeOut, call.rgReaderStates, call.cReaders);
|
||||
|
||||
if (status && (status != SCARD_E_TIMEOUT))
|
||||
if (status && (status != SCARD_E_TIMEOUT) && (status != SCARD_E_CANCELLED))
|
||||
return status;
|
||||
|
||||
ret.cReaders = call.cReaders;
|
||||
@ -440,6 +444,8 @@ static UINT32 smartcard_Cancel(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardCancel(hContext);
|
||||
|
||||
smartcard_trace_long_return(smartcard, &ret, "Cancel");
|
||||
|
||||
return ret.ReturnCode;
|
||||
}
|
||||
|
||||
@ -591,6 +597,8 @@ static UINT32 smartcard_Disconnect(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardDisconnect(hCard, call.dwDisposition);
|
||||
|
||||
smartcard_trace_long_return(smartcard, &ret, "Disconnect");
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
@ -617,6 +625,8 @@ static UINT32 smartcard_BeginTransaction(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardBeginTransaction(hCard);
|
||||
|
||||
smartcard_trace_long_return(smartcard, &ret, "BeginTransaction");
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
@ -643,6 +653,8 @@ static UINT32 smartcard_EndTransaction(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
||||
|
||||
status = ret.ReturnCode = SCardEndTransaction(hCard, call.dwDisposition);
|
||||
|
||||
smartcard_trace_long_return(smartcard, &ret, "EndTransaction");
|
||||
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
|
@ -459,7 +459,8 @@ void smartcard_trace_establish_context_return(SMARTCARD_DEVICE* smartcard, Estab
|
||||
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG, "EstablishContext_Return {");
|
||||
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG, "ReturnCode: 0x%08X", ret->ReturnCode);
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG, "ReturnCode: %s (0x%08X)",
|
||||
SCardGetErrorString(ret->ReturnCode), ret->ReturnCode);
|
||||
|
||||
pb = (BYTE*) &(ret->hContext.pbContext);
|
||||
|
||||
@ -519,6 +520,19 @@ void smartcard_trace_context_call(SMARTCARD_DEVICE* smartcard, Context_Call* cal
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG, "}");
|
||||
}
|
||||
|
||||
void smartcard_trace_long_return(SMARTCARD_DEVICE* smartcard, Long_Return* ret, const char* name)
|
||||
{
|
||||
if (!WLog_IsLevelActive(smartcard->log, WLOG_DEBUG))
|
||||
return;
|
||||
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG, "%s_Return {", name);
|
||||
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG, "ReturnCode: %s (0x%08X)",
|
||||
SCardGetErrorString(ret->ReturnCode), ret->ReturnCode);
|
||||
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG, "}");
|
||||
}
|
||||
|
||||
UINT32 smartcard_unpack_list_readers_call(SMARTCARD_DEVICE* smartcard, wStream* s, ListReaders_Call* call)
|
||||
{
|
||||
UINT32 status;
|
||||
|
@ -465,6 +465,8 @@ void smartcard_trace_establish_context_return(SMARTCARD_DEVICE* smartcard, Estab
|
||||
UINT32 smartcard_unpack_context_call(SMARTCARD_DEVICE* smartcard, wStream* s, Context_Call* call);
|
||||
void smartcard_trace_context_call(SMARTCARD_DEVICE* smartcard, Context_Call* call, const char* name);
|
||||
|
||||
void smartcard_trace_long_return(SMARTCARD_DEVICE* smartcard, Long_Return* ret, const char* name);
|
||||
|
||||
UINT32 smartcard_unpack_list_readers_call(SMARTCARD_DEVICE* smartcard, wStream* s, ListReaders_Call* call);
|
||||
void smartcard_trace_list_readers_call(SMARTCARD_DEVICE* smartcard, ListReaders_Call* call, BOOL unicode);
|
||||
|
||||
|
@ -2118,10 +2118,11 @@ WINSCARDAPI LONG WINAPI PCSC_SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, L
|
||||
{
|
||||
LPDWORD pdwProtocol = (LPDWORD) pbAttr;
|
||||
|
||||
if (cbAttrLen < 4)
|
||||
if (cbAttrLen < sizeof(DWORD))
|
||||
return SCARD_E_INSUFFICIENT_BUFFER;
|
||||
|
||||
*pdwProtocol = PCSC_ConvertProtocolsToWinSCard(dwProtocol);
|
||||
*pcbAttrLen = sizeof(DWORD);
|
||||
}
|
||||
}
|
||||
else if (dwAttrId == SCARD_ATTR_VENDOR_IFD_TYPE)
|
||||
|
Loading…
Reference in New Issue
Block a user