channels/smartcard: add more debug output
This commit is contained in:
parent
32b65c3000
commit
727a4914f2
@ -1358,7 +1358,10 @@ UINT32 smartcard_pack_get_status_change_return(SMARTCARD_DEVICE* smartcard, wStr
|
||||
|
||||
void smartcard_trace_get_status_change_return(SMARTCARD_DEVICE* smartcard, GetStatusChange_Return* ret)
|
||||
{
|
||||
BYTE* pb;
|
||||
UINT32 index;
|
||||
char* szEventState;
|
||||
char* szCurrentState;
|
||||
ReaderState_Return* rgReaderState;
|
||||
|
||||
if (!WLog_IsLevelActive(smartcard->log, WLOG_DEBUG))
|
||||
@ -1372,10 +1375,31 @@ void smartcard_trace_get_status_change_return(SMARTCARD_DEVICE* smartcard, GetSt
|
||||
for (index = 0; index < ret->cReaders; index++)
|
||||
{
|
||||
rgReaderState = &(ret->rgReaderStates[index]);
|
||||
pb = (BYTE*) &rgReaderState->rgbAtr;
|
||||
|
||||
szCurrentState = SCardGetStateString(rgReaderState->dwCurrentState);
|
||||
szEventState = SCardGetStateString(rgReaderState->dwEventState);
|
||||
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG,
|
||||
"\t[%d]: dwCurrentState: 0x%08X dwEventState: 0x%08X cbAtr: %d",
|
||||
index, rgReaderState->dwCurrentState, rgReaderState->dwEventState, rgReaderState->cbAtr);
|
||||
"\t[%d]: dwCurrentState: 0x%08X (%s)",
|
||||
index, rgReaderState->dwCurrentState, szCurrentState);
|
||||
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG,
|
||||
"\t[%d]: dwEventState: 0x%08X (%s)",
|
||||
index, rgReaderState->dwCurrentState, szEventState);
|
||||
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG,
|
||||
"\t[%d]: cbAtr: %d rgbAtr: "
|
||||
"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X"
|
||||
"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
|
||||
index, rgReaderState->cbAtr,
|
||||
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7],
|
||||
pb[8], pb[9], pb[10], pb[11], pb[12], pb[13], pb[14], pb[15],
|
||||
pb[16], pb[17], pb[18], pb[19], pb[20], pb[21], pb[22], pb[23],
|
||||
pb[24], pb[25], pb[26], pb[27], pb[28], pb[29], pb[30], pb[31]);
|
||||
|
||||
free(szCurrentState);
|
||||
free(szEventState);
|
||||
}
|
||||
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG, "}");
|
||||
@ -1534,10 +1558,15 @@ UINT32 smartcard_pack_status_return(SMARTCARD_DEVICE* smartcard, wStream* s, Sta
|
||||
|
||||
void smartcard_trace_status_return(SMARTCARD_DEVICE* smartcard, Status_Return* ret, BOOL unicode)
|
||||
{
|
||||
BYTE* pb;
|
||||
UINT32 index;
|
||||
UINT32 length;
|
||||
char* szState = NULL;
|
||||
char* mszReaderNamesA = NULL;
|
||||
|
||||
if (!WLog_IsLevelActive(smartcard->log, WLOG_DEBUG))
|
||||
return;
|
||||
|
||||
if (unicode)
|
||||
{
|
||||
length = ret->cBytes / 2;
|
||||
@ -1556,21 +1585,34 @@ void smartcard_trace_status_return(SMARTCARD_DEVICE* smartcard, Status_Return* r
|
||||
mszReaderNamesA[index] = ',';
|
||||
}
|
||||
|
||||
if (!WLog_IsLevelActive(smartcard->log, WLOG_DEBUG))
|
||||
return;
|
||||
pb = (BYTE*) &ret->pbAtr;
|
||||
|
||||
szState = SCardGetStateString(ret->dwState);
|
||||
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG, "Status%s_Return {", unicode ? "W" : "A");
|
||||
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG, "ReturnCode: 0x%08X", ret->ReturnCode);
|
||||
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG, "cBytes: %d dwState: 0x%08X dwProtocol: 0x%08X cbAtrLen: %d",
|
||||
ret->cBytes, ret->dwState, ret->dwProtocol, ret->cbAtrLen);
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG, "dwState: %s (0x%08X) dwProtocol: %s (0x%08X)",
|
||||
szState, ret->dwState, SCardGetProtocolString(ret->dwProtocol), ret->dwProtocol);
|
||||
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG, "mszReaderNames: %s", mszReaderNamesA);
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG, "cBytes: %d mszReaderNames: %s",
|
||||
ret->cBytes, mszReaderNamesA);
|
||||
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG,
|
||||
"cbAtrLen: %d pbAtr: "
|
||||
"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X"
|
||||
"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
|
||||
index, ret->cbAtrLen,
|
||||
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7],
|
||||
pb[8], pb[9], pb[10], pb[11], pb[12], pb[13], pb[14], pb[15],
|
||||
pb[16], pb[17], pb[18], pb[19], pb[20], pb[21], pb[22], pb[23],
|
||||
pb[24], pb[25], pb[26], pb[27], pb[28], pb[29], pb[30], pb[31]);
|
||||
|
||||
WLog_Print(smartcard->log, WLOG_DEBUG, "}");
|
||||
|
||||
free(mszReaderNamesA);
|
||||
free(szState);
|
||||
}
|
||||
|
||||
UINT32 smartcard_unpack_get_attrib_call(SMARTCARD_DEVICE* smartcard, wStream* s, GetAttrib_Call* call)
|
||||
|
@ -1105,6 +1105,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 char* WINAPI SCardGetStateString(DWORD dwEventState);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -781,6 +781,120 @@ WINSCARDAPI const char* WINAPI SCardGetAttributeString(DWORD dwAttrId)
|
||||
return "SCARD_ATTR_UNKNOWN";
|
||||
}
|
||||
|
||||
WINSCARDAPI const char* WINAPI SCardGetProtocolString(DWORD dwProtocols)
|
||||
{
|
||||
if (dwProtocols == SCARD_PROTOCOL_UNDEFINED)
|
||||
return "SCARD_PROTOCOL_UNDEFINED";
|
||||
|
||||
if (dwProtocols == SCARD_PROTOCOL_T0)
|
||||
return "SCARD_PROTOCOL_T0";
|
||||
|
||||
if (dwProtocols == SCARD_PROTOCOL_T1)
|
||||
return "SCARD_PROTOCOL_T1";
|
||||
|
||||
if (dwProtocols == SCARD_PROTOCOL_Tx)
|
||||
return "SCARD_PROTOCOL_Tx";
|
||||
|
||||
if (dwProtocols == SCARD_PROTOCOL_RAW)
|
||||
return "SCARD_PROTOCOL_RAW";
|
||||
|
||||
if (dwProtocols == SCARD_PROTOCOL_DEFAULT)
|
||||
return "SCARD_PROTOCOL_DEFAULT";
|
||||
|
||||
if (dwProtocols == (SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_RAW))
|
||||
return "SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_RAW";
|
||||
|
||||
if (dwProtocols == (SCARD_PROTOCOL_T1 | SCARD_PROTOCOL_RAW))
|
||||
return "SCARD_PROTOCOL_T1 | SCARD_PROTOCOL_RAW";
|
||||
|
||||
if (dwProtocols == (SCARD_PROTOCOL_Tx | SCARD_PROTOCOL_RAW))
|
||||
return "SCARD_PROTOCOL_Tx | SCARD_PROTOCOL_RAW";
|
||||
|
||||
return "SCARD_PROTOCOL_UNKNOWN";
|
||||
}
|
||||
|
||||
WINSCARDAPI char* WINAPI SCardGetStateString(DWORD dwEventState)
|
||||
{
|
||||
char* szEventState = malloc(512);
|
||||
|
||||
if (!szEventState)
|
||||
return NULL;
|
||||
|
||||
szEventState[0] = '\0';
|
||||
|
||||
if (dwEventState & SCARD_STATE_IGNORE)
|
||||
{
|
||||
if (szEventState[0])
|
||||
strcat(szEventState, " | ");
|
||||
strcat(szEventState, "SCARD_STATE_IGNORE");
|
||||
}
|
||||
if (dwEventState & SCARD_STATE_CHANGED)
|
||||
{
|
||||
if (szEventState[0])
|
||||
strcat(szEventState, " | ");
|
||||
strcat(szEventState, "SCARD_STATE_CHANGED");
|
||||
}
|
||||
if (dwEventState & SCARD_STATE_UNKNOWN)
|
||||
{
|
||||
if (szEventState[0])
|
||||
strcat(szEventState, " | ");
|
||||
strcat(szEventState, "SCARD_STATE_UNKNOWN");
|
||||
}
|
||||
if (dwEventState & SCARD_STATE_UNAVAILABLE)
|
||||
{
|
||||
if (szEventState[0])
|
||||
strcat(szEventState, " | ");
|
||||
strcat(szEventState, "SCARD_STATE_UNAVAILABLE");
|
||||
}
|
||||
if (dwEventState & SCARD_STATE_EMPTY)
|
||||
{
|
||||
if (szEventState[0])
|
||||
strcat(szEventState, " | ");
|
||||
strcat(szEventState, "SCARD_STATE_EMPTY");
|
||||
}
|
||||
if (dwEventState & SCARD_STATE_PRESENT)
|
||||
{
|
||||
if (szEventState[0])
|
||||
strcat(szEventState, " | ");
|
||||
strcat(szEventState, "SCARD_STATE_PRESENT");
|
||||
}
|
||||
if (dwEventState & SCARD_STATE_ATRMATCH)
|
||||
{
|
||||
if (szEventState[0])
|
||||
strcat(szEventState, " | ");
|
||||
strcat(szEventState, "SCARD_STATE_ATRMATCH");
|
||||
}
|
||||
if (dwEventState & SCARD_STATE_EXCLUSIVE)
|
||||
{
|
||||
if (szEventState[0])
|
||||
strcat(szEventState, " | ");
|
||||
strcat(szEventState, "SCARD_STATE_EXCLUSIVE");
|
||||
}
|
||||
if (dwEventState & SCARD_STATE_INUSE)
|
||||
{
|
||||
if (szEventState[0])
|
||||
strcat(szEventState, " | ");
|
||||
strcat(szEventState, "SCARD_STATE_INUSE");
|
||||
}
|
||||
if (dwEventState & SCARD_STATE_MUTE)
|
||||
{
|
||||
if (szEventState[0])
|
||||
strcat(szEventState, " | ");
|
||||
strcat(szEventState, "SCARD_STATE_MUTE");
|
||||
}
|
||||
if (dwEventState & SCARD_STATE_UNPOWERED)
|
||||
{
|
||||
if (szEventState[0])
|
||||
strcat(szEventState, " | ");
|
||||
strcat(szEventState, "SCARD_STATE_UNPOWERED");
|
||||
}
|
||||
|
||||
if (!szEventState[0])
|
||||
strcat(szEventState, "SCARD_STATE_UNAWARE");
|
||||
|
||||
return szEventState;
|
||||
}
|
||||
|
||||
void InitializeSCardApiStubs(void)
|
||||
{
|
||||
g_Initialized = TRUE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user