channels/smartcard: add more debug output

This commit is contained in:
Marc-André Moreau 2014-04-12 12:42:09 -04:00
parent ee9f44ce5a
commit fd6052f348
5 changed files with 59 additions and 12 deletions

View File

@ -366,7 +366,7 @@ static UINT32 smartcard_GetStatusChangeA(SMARTCARD_DEVICE* smartcard, IRP* irp)
CopyMemory(&ret.rgReaderStates[index].rgbAtr, &call.rgReaderStates[index].rgbAtr, 32);
}
smartcard_trace_get_status_change_return(smartcard, &ret);
smartcard_trace_get_status_change_return(smartcard, &ret, FALSE);
status = smartcard_pack_get_status_change_return(smartcard, irp->output, &ret);
@ -424,7 +424,7 @@ static UINT32 smartcard_GetStatusChangeW(SMARTCARD_DEVICE* smartcard, IRP* irp)
CopyMemory(&ret.rgReaderStates[index].rgbAtr, &call.rgReaderStates[index].rgbAtr, 32);
}
smartcard_trace_get_status_change_return(smartcard, &ret);
smartcard_trace_get_status_change_return(smartcard, &ret, TRUE);
status = smartcard_pack_get_status_change_return(smartcard, irp->output, &ret);

View File

@ -758,8 +758,9 @@ void smartcard_trace_connect_a_call(SMARTCARD_DEVICE* smartcard, ConnectA_Call*
pb[0], pb[1], pb[2], pb[3], call->Common.hContext.cbContext);
}
WLog_Print(smartcard->log, WLOG_DEBUG, "szReader: %s dwShareMode: 0x%08X dwPreferredProtocols: 0x%08X",
call->szReader, call->Common.dwShareMode, call->Common.dwPreferredProtocols);
WLog_Print(smartcard->log, WLOG_DEBUG, "szReader: %s dwShareMode: %s (0x%08X) dwPreferredProtocols: %s (0x%08X)",
call->szReader, SCardGetShareModeString(call->Common.dwShareMode), call->Common.dwShareMode,
SCardGetProtocolString(call->Common.dwPreferredProtocols), call->Common.dwPreferredProtocols);
WLog_Print(smartcard->log, WLOG_DEBUG, "}");
}
@ -826,8 +827,9 @@ void smartcard_trace_connect_w_call(SMARTCARD_DEVICE* smartcard, ConnectW_Call*
pb[0], pb[1], pb[2], pb[3], call->Common.hContext.cbContext);
}
WLog_Print(smartcard->log, WLOG_DEBUG, "szReader: %s dwShareMode: 0x%08X dwPreferredProtocols: %d",
szReaderA, call->Common.dwShareMode, call->Common.dwPreferredProtocols);
WLog_Print(smartcard->log, WLOG_DEBUG, "szReader: %s dwShareMode: %s (0x%08X) dwPreferredProtocols: %s (0x%08X)",
szReaderA, SCardGetShareModeString(call->Common.dwShareMode), call->Common.dwShareMode,
SCardGetProtocolString(call->Common.dwPreferredProtocols), call->Common.dwPreferredProtocols);
WLog_Print(smartcard->log, WLOG_DEBUG, "}");
@ -898,8 +900,8 @@ void smartcard_trace_connect_return(SMARTCARD_DEVICE* smartcard, Connect_Return*
pb[0], pb[1], pb[2], pb[3], ret->hCard.cbHandle);
}
WLog_Print(smartcard->log, WLOG_DEBUG, "dwActiveProtocol: 0x%08X",
ret->dwActiveProtocol);
WLog_Print(smartcard->log, WLOG_DEBUG, "dwActiveProtocol: %s (0x%08X)",
SCardGetProtocolString(ret->dwActiveProtocol), ret->dwActiveProtocol);
WLog_Print(smartcard->log, WLOG_DEBUG, "}");
}
@ -1017,7 +1019,8 @@ void smartcard_trace_hcard_and_disposition_call(SMARTCARD_DEVICE* smartcard, HCa
pb[0], pb[1], pb[2], pb[3], call->hCard.cbHandle);
}
WLog_Print(smartcard->log, WLOG_DEBUG, "dwDisposition: 0x%08X", call->dwDisposition);
WLog_Print(smartcard->log, WLOG_DEBUG, "dwDisposition: %s (0x%08X)",
SCardGetDispositionString(call->dwDisposition), call->dwDisposition);
WLog_Print(smartcard->log, WLOG_DEBUG, "}");
}
@ -1356,7 +1359,7 @@ UINT32 smartcard_pack_get_status_change_return(SMARTCARD_DEVICE* smartcard, wStr
return SCARD_S_SUCCESS;
}
void smartcard_trace_get_status_change_return(SMARTCARD_DEVICE* smartcard, GetStatusChange_Return* ret)
void smartcard_trace_get_status_change_return(SMARTCARD_DEVICE* smartcard, GetStatusChange_Return* ret, BOOL unicode)
{
BYTE* pb;
UINT32 index;
@ -1367,7 +1370,7 @@ void smartcard_trace_get_status_change_return(SMARTCARD_DEVICE* smartcard, GetSt
if (!WLog_IsLevelActive(smartcard->log, WLOG_DEBUG))
return;
WLog_Print(smartcard->log, WLOG_DEBUG, "GetStatusChange_Return {");
WLog_Print(smartcard->log, WLOG_DEBUG, "GetStatusChange%s_Return {", unicode ? "W" : "A");
WLog_Print(smartcard->log, WLOG_DEBUG, "ReturnCode: 0x%08X cReaders: %d",
ret->ReturnCode, ret->cReaders);

View File

@ -493,7 +493,7 @@ UINT32 smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wS
void smartcard_trace_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, GetStatusChangeW_Call* call);
UINT32 smartcard_pack_get_status_change_return(SMARTCARD_DEVICE* smartcard, wStream* s, GetStatusChange_Return* ret);
void smartcard_trace_get_status_change_return(SMARTCARD_DEVICE* smartcard, GetStatusChange_Return* ret);
void smartcard_trace_get_status_change_return(SMARTCARD_DEVICE* smartcard, GetStatusChange_Return* ret, BOOL unicode);
UINT32 smartcard_unpack_state_call(SMARTCARD_DEVICE* smartcard, wStream* s, State_Call* call);
UINT32 smartcard_pack_state_return(SMARTCARD_DEVICE* smartcard, wStream* s, State_Return* ret);

View File

@ -1106,6 +1106,8 @@ extern "C" {
WINSCARDAPI const char* WINAPI SCardGetErrorString(LONG errorCode);
WINSCARDAPI const char* WINAPI SCardGetAttributeString(DWORD dwAttrId);
WINSCARDAPI const char* WINAPI SCardGetProtocolString(DWORD dwProtocols);
WINSCARDAPI const char* WINAPI SCardGetShareModeString(DWORD dwShareMode);
WINSCARDAPI const char* WINAPI SCardGetDispositionString(DWORD dwDisposition);
WINSCARDAPI char* WINAPI SCardGetStateString(DWORD dwEventState);
#ifdef __cplusplus

View File

@ -813,6 +813,48 @@ WINSCARDAPI const char* WINAPI SCardGetProtocolString(DWORD dwProtocols)
return "SCARD_PROTOCOL_UNKNOWN";
}
WINSCARDAPI const char* WINAPI SCardGetShareModeString(DWORD dwShareMode)
{
switch (dwShareMode)
{
case SCARD_SHARE_EXCLUSIVE:
return "SCARD_SHARE_EXCLUSIVE";
break;
case SCARD_SHARE_SHARED:
return "SCARD_SHARE_SHARED";
break;
case SCARD_SHARE_DIRECT:
return "SCARD_SHARE_DIRECT";
break;
default:
return "SCARD_SHARE_UNKNOWN";
break;
}
return "SCARD_SHARE_UNKNOWN";
}
WINSCARDAPI const char* WINAPI SCardGetDispositionString(DWORD dwDisposition)
{
switch (dwDisposition)
{
case SCARD_LEAVE_CARD:
return "SCARD_LEAVE_CARD";
break;
case SCARD_RESET_CARD:
return "SCARD_RESET_CARD";
break;
case SCARD_UNPOWER_CARD:
return "SCARD_UNPOWER_CARD";
break;
default:
return "SCARD_UNKNOWN_CARD";
break;
}
return "SCARD_UNKNOWN_CARD";
}
WINSCARDAPI char* WINAPI SCardGetStateString(DWORD dwEventState)
{
char* szEventState = malloc(512);