channels/smartcard: better selection of async vs sync processing of IRPs

This commit is contained in:
Marc-André Moreau 2014-05-07 21:16:05 -04:00
parent e7408089bd
commit 81be8b2473
2 changed files with 67 additions and 22 deletions

View File

@ -37,8 +37,6 @@
#define DEBUG_SMARTCARD_INIT 1
static BOOL g_SmartCardAsync = TRUE;
static void smartcard_free(DEVICE* device)
{
SMARTCARD_DEVICE* smartcard = (SMARTCARD_DEVICE*) device;
@ -213,28 +211,75 @@ void smartcard_process_irp(SMARTCARD_DEVICE* smartcard, IRP* irp)
if (!ioControlCode)
return;
if (g_SmartCardAsync)
asyncIrp = TRUE;
/**
* The following matches mstsc's behavior of processing
* only certain requests asynchronously while processing
* those expected to return fast synchronously.
*/
switch (ioControlCode)
{
asyncIrp = TRUE;
case SCARD_IOCTL_ESTABLISHCONTEXT:
case SCARD_IOCTL_RELEASECONTEXT:
case SCARD_IOCTL_ISVALIDCONTEXT:
case SCARD_IOCTL_LISTREADERGROUPSA:
case SCARD_IOCTL_LISTREADERGROUPSW:
case SCARD_IOCTL_LISTREADERSA:
case SCARD_IOCTL_LISTREADERSW:
case SCARD_IOCTL_INTRODUCEREADERGROUPA:
case SCARD_IOCTL_INTRODUCEREADERGROUPW:
case SCARD_IOCTL_FORGETREADERGROUPA:
case SCARD_IOCTL_FORGETREADERGROUPW:
case SCARD_IOCTL_INTRODUCEREADERA:
case SCARD_IOCTL_INTRODUCEREADERW:
case SCARD_IOCTL_FORGETREADERA:
case SCARD_IOCTL_FORGETREADERW:
case SCARD_IOCTL_ADDREADERTOGROUPA:
case SCARD_IOCTL_ADDREADERTOGROUPW:
case SCARD_IOCTL_REMOVEREADERFROMGROUPA:
case SCARD_IOCTL_REMOVEREADERFROMGROUPW:
case SCARD_IOCTL_LOCATECARDSA:
case SCARD_IOCTL_LOCATECARDSW:
case SCARD_IOCTL_LOCATECARDSBYATRA:
case SCARD_IOCTL_LOCATECARDSBYATRW:
case SCARD_IOCTL_CANCEL:
case SCARD_IOCTL_READCACHEA:
case SCARD_IOCTL_READCACHEW:
case SCARD_IOCTL_WRITECACHEA:
case SCARD_IOCTL_WRITECACHEW:
case SCARD_IOCTL_GETREADERICON:
case SCARD_IOCTL_GETDEVICETYPEID:
asyncIrp = FALSE;
break;
switch (ioControlCode)
{
case SCARD_IOCTL_ESTABLISHCONTEXT:
case SCARD_IOCTL_RELEASECONTEXT:
case SCARD_IOCTL_ISVALIDCONTEXT:
case SCARD_IOCTL_ACCESSSTARTEDEVENT:
case SCARD_IOCTL_RELEASESTARTEDEVENT:
asyncIrp = FALSE;
break;
case SCARD_IOCTL_GETSTATUSCHANGEA:
case SCARD_IOCTL_GETSTATUSCHANGEW:
asyncIrp = TRUE;
break;
case SCARD_IOCTL_TRANSMIT:
case SCARD_IOCTL_STATUSA:
case SCARD_IOCTL_STATUSW:
case SCARD_IOCTL_GETSTATUSCHANGEA:
case SCARD_IOCTL_GETSTATUSCHANGEW:
asyncIrp = TRUE;
break;
}
case SCARD_IOCTL_CONNECTA:
case SCARD_IOCTL_CONNECTW:
case SCARD_IOCTL_RECONNECT:
case SCARD_IOCTL_DISCONNECT:
case SCARD_IOCTL_BEGINTRANSACTION:
case SCARD_IOCTL_ENDTRANSACTION:
case SCARD_IOCTL_STATE:
case SCARD_IOCTL_STATUSA:
case SCARD_IOCTL_STATUSW:
case SCARD_IOCTL_TRANSMIT:
case SCARD_IOCTL_CONTROL:
case SCARD_IOCTL_GETATTRIB:
case SCARD_IOCTL_SETATTRIB:
case SCARD_IOCTL_GETTRANSMITCOUNT:
asyncIrp = TRUE;
break;
case SCARD_IOCTL_ACCESSSTARTEDEVENT:
case SCARD_IOCTL_RELEASESTARTEDEVENT:
asyncIrp = FALSE;
break;
}
if (!asyncIrp)

View File

@ -856,7 +856,7 @@ void smartcard_trace_connect_w_call(SMARTCARD_DEVICE* smartcard, ConnectW_Call*
ConvertFromUnicode(CP_UTF8, 0, call->szReader, -1, &szReaderA, 0, NULL, NULL);
WLog_Print(smartcard->log, WLOG_DEBUG, "ConnectA_Call {");
WLog_Print(smartcard->log, WLOG_DEBUG, "ConnectW_Call {");
pb = (BYTE*) &(call->Common.hContext.pbContext);