From b34cbe8a3e2b6d5f8c8765d367057a24143025c8 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Thu, 19 Dec 2013 14:05:35 -0800 Subject: [PATCH] chansrv: got \?PnP?\Notification working, handle pcsc exit without cleanup --- sesman/chansrv/pcsc/xrdp_pcsc.c | 11 +++++++++-- sesman/chansrv/smartcard_pcsc.c | 16 +++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/sesman/chansrv/pcsc/xrdp_pcsc.c b/sesman/chansrv/pcsc/xrdp_pcsc.c index 89c80534..43a95b5f 100644 --- a/sesman/chansrv/pcsc/xrdp_pcsc.c +++ b/sesman/chansrv/pcsc/xrdp_pcsc.c @@ -714,10 +714,16 @@ SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, offset = 12; for (index = 0; index < cReaders; index++) { + if (rgReaderStates[index].dwCurrentState == 0) /* SCARD_STATE_UNAWARE */ + { + rgReaderStates[index].dwEventState = 0; + rgReaderStates[index].cbAtr = 0; + } str_len = strlen(rgReaderStates[index].szReader); str_len = LMIN(str_len, 99); memset(msg + offset, 0, 100); memcpy(msg + offset, rgReaderStates[index].szReader, str_len); + LLOGLN(10, (" in szReader %s", rgReaderStates[index].szReader)); offset += 100; LLOGLN(10, (" in dwCurrentState 0x%8.8x", rgReaderStates[index].dwCurrentState)); SET_UINT32(msg, offset, rgReaderStates[index].dwCurrentState); @@ -761,12 +767,13 @@ SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, LLOGLN(10, ("SCardGetStatusChange: got back cReaders %d", cReaders)); for (index = 0; index < cReaders; index++) { + LLOGLN(10, (" out szReader %s", rgReaderStates[index].szReader)); rgReaderStates[index].dwCurrentState = GET_UINT32(msg, offset); offset += 4; - LLOGLN(10, (" out dwCurrentState %d", rgReaderStates[index].dwCurrentState)); + LLOGLN(10, (" out dwCurrentState 0x%8.8x", rgReaderStates[index].dwCurrentState)); rgReaderStates[index].dwEventState = GET_UINT32(msg, offset); offset += 4; - LLOGLN(10, (" out dwEventState %d", rgReaderStates[index].dwEventState)); + LLOGLN(10, (" out dwEventState 0x%8.8x", rgReaderStates[index].dwEventState)); rgReaderStates[index].cbAtr = GET_UINT32(msg, offset); offset += 4; LLOGLN(10, (" out cbAtr %d", rgReaderStates[index].cbAtr)); diff --git a/sesman/chansrv/smartcard_pcsc.c b/sesman/chansrv/smartcard_pcsc.c index beccd4f9..ebf52c82 100644 --- a/sesman/chansrv/smartcard_pcsc.c +++ b/sesman/chansrv/smartcard_pcsc.c @@ -106,14 +106,24 @@ scard_pcsc_get_wait_objs(tbus *objs, int *count, int *timeout) int APP_CC scard_pcsc_check_wait_objs(void) { - LLOGLN(10, ("scard_pcsc_check_wait_objs")); + LLOGLN(10, ("scard_pcsc_check_wait_objs:")); if (g_lis != 0) { - trans_check_wait_objs(g_lis); + if (trans_check_wait_objs(g_lis) != 0) + { + LLOGLN(0, ("scard_pcsc_check_wait_objs: g_lis trans_check_wait_objs error")); + } } if (g_con != 0) { - trans_check_wait_objs(g_con); + if (trans_check_wait_objs(g_con) != 0) + { + LLOGLN(0, ("scard_pcsc_check_wait_objs: g_con trans_check_wait_objs error")); + /* TODO: cleanup better */ + trans_delete(g_con); + g_con = 0; + g_xrdp_pcsc_state = 0; + } } return 0; }