chansrv: work on smartcard stability, handle multi threaded calls, app crashes, etc
This commit is contained in:
parent
6eab2ed11b
commit
1483c75911
@ -243,16 +243,20 @@ send_message(int code, char *data, int bytes)
|
||||
{
|
||||
char header[8];
|
||||
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
SET_UINT32(header, 0, bytes);
|
||||
SET_UINT32(header, 4, code);
|
||||
if (send(g_sck, header, 8, 0) != 8)
|
||||
{
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return 1;
|
||||
}
|
||||
if (send(g_sck, data, bytes, 0) != bytes)
|
||||
{
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return 1;
|
||||
}
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -262,9 +266,49 @@ get_message(int *code, char *data, int *bytes)
|
||||
{
|
||||
char header[8];
|
||||
int max_bytes;
|
||||
int error;
|
||||
int max;
|
||||
int lcode;
|
||||
struct timeval time;
|
||||
fd_set rd_set;
|
||||
|
||||
LLOGLN(10, ("get_message:"));
|
||||
max = g_sck + 1;
|
||||
while (1)
|
||||
{
|
||||
LLOGLN(10, ("get_message: loop"));
|
||||
time.tv_sec = 1;
|
||||
time.tv_usec = 0;
|
||||
FD_ZERO(&rd_set);
|
||||
FD_SET(((unsigned int)g_sck), &rd_set);
|
||||
error = select(max, &rd_set, 0, 0, &time);
|
||||
if (error == 1)
|
||||
{
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
time.tv_sec = 0;
|
||||
time.tv_usec = 0;
|
||||
FD_ZERO(&rd_set);
|
||||
FD_SET(((unsigned int)g_sck), &rd_set);
|
||||
error = select(max, &rd_set, 0, 0, &time);
|
||||
if (error == 1)
|
||||
{
|
||||
if (recv(g_sck, header, 8, MSG_PEEK) == 8)
|
||||
{
|
||||
lcode = GET_UINT32(header, 4);
|
||||
if (lcode == *code)
|
||||
{
|
||||
/* still have mutex lock */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
if (recv(g_sck, header, 8, 0) != 8)
|
||||
{
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return 1;
|
||||
}
|
||||
max_bytes = *bytes;
|
||||
@ -272,12 +316,15 @@ get_message(int *code, char *data, int *bytes)
|
||||
*code = GET_UINT32(header, 4);
|
||||
if (*bytes > max_bytes)
|
||||
{
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return 1;
|
||||
}
|
||||
if (recv(g_sck, data, *bytes, 0) != *bytes)
|
||||
{
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return 1;
|
||||
}
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -302,28 +349,24 @@ SCardEstablishContext(DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2,
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
}
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
SET_UINT32(msg, 0, dwScope);
|
||||
if (send_message(SCARD_ESTABLISH_CONTEXT, msg, 4) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardEstablishContext: error, send_message"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
bytes = 256;
|
||||
code = SCARD_ESTABLISH_CONTEXT;
|
||||
if (get_message(&code, msg, &bytes) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardEstablishContext: error, get_message"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
if ((code != SCARD_ESTABLISH_CONTEXT) || (bytes != 8))
|
||||
{
|
||||
LLOGLN(0, ("SCardEstablishContext: error, bad code"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
context = GET_UINT32(msg, 0);
|
||||
status = GET_UINT32(msg, 4);
|
||||
LLOGLN(10, ("SCardEstablishContext: got context 0x%8.8x", context));
|
||||
@ -346,28 +389,24 @@ SCardReleaseContext(SCARDCONTEXT hContext)
|
||||
LLOGLN(0, ("SCardReleaseContext: error, not connected"));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
SET_UINT32(msg, 0, hContext);
|
||||
if (send_message(SCARD_RELEASE_CONTEXT, msg, 4) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardReleaseContext: error, send_message"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
bytes = 256;
|
||||
code = SCARD_RELEASE_CONTEXT;
|
||||
if (get_message(&code, msg, &bytes) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardReleaseContext: error, get_message"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
if ((code != SCARD_RELEASE_CONTEXT) || (bytes != 4))
|
||||
{
|
||||
LLOGLN(0, ("SCardReleaseContext: error, bad code"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
status = GET_UINT32(msg, 0);
|
||||
LLOGLN(10, ("SCardReleaseContext: got status 0x%8.8x", status));
|
||||
return status;
|
||||
@ -383,8 +422,6 @@ SCardIsValidContext(SCARDCONTEXT hContext)
|
||||
LLOGLN(0, ("SCardIsValidContext: error, not connected"));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_S_SUCCESS;
|
||||
}
|
||||
|
||||
@ -425,27 +462,23 @@ SCardConnect(SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode,
|
||||
offset += 4;
|
||||
SET_UINT32(msg, offset, dwPreferredProtocols);
|
||||
offset += 4;
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
if (send_message(SCARD_CONNECT, msg, offset) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardConnect: error, send_message"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
bytes = 256;
|
||||
code = SCARD_CONNECT;
|
||||
if (get_message(&code, msg, &bytes) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardConnect: error, get_message"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
if (code != SCARD_CONNECT)
|
||||
{
|
||||
LLOGLN(0, ("SCardConnect: error, bad code"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
*phCard = GET_UINT32(msg, 0);
|
||||
*pdwActiveProtocol = GET_UINT32(msg, 4);
|
||||
status = GET_UINT32(msg, 8);
|
||||
@ -465,8 +498,6 @@ SCardReconnect(SCARDHANDLE hCard, DWORD dwShareMode,
|
||||
LLOGLN(0, ("SCardReconnect: error, not connected"));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_S_SUCCESS;
|
||||
}
|
||||
|
||||
@ -485,29 +516,25 @@ SCardDisconnect(SCARDHANDLE hCard, DWORD dwDisposition)
|
||||
LLOGLN(0, ("SCardDisconnect: error, not connected"));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
SET_UINT32(msg, 0, hCard);
|
||||
SET_UINT32(msg, 4, dwDisposition);
|
||||
if (send_message(SCARD_DISCONNECT, msg, 8) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardDisconnect: error, send_message"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
bytes = 256;
|
||||
code = SCARD_DISCONNECT;
|
||||
if (get_message(&code, msg, &bytes) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardDisconnect: error, get_message"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
if ((code != SCARD_DISCONNECT) || (bytes != 4))
|
||||
{
|
||||
LLOGLN(0, ("SCardDisconnect: error, bad code"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
status = GET_UINT32(msg, 0);
|
||||
LLOGLN(10, ("SCardDisconnect: got status 0x%8.8x", status));
|
||||
return status;
|
||||
@ -528,28 +555,24 @@ SCardBeginTransaction(SCARDHANDLE hCard)
|
||||
LLOGLN(0, ("SCardBeginTransaction: error, not connected"));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
SET_UINT32(msg, 0, hCard);
|
||||
if (send_message(SCARD_BEGIN_TRANSACTION, msg, 4) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardBeginTransaction: error, send_message"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
bytes = 256;
|
||||
code = SCARD_BEGIN_TRANSACTION;
|
||||
if (get_message(&code, msg, &bytes) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardBeginTransaction: error, get_message"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
if ((code != SCARD_BEGIN_TRANSACTION) || (bytes != 4))
|
||||
{
|
||||
LLOGLN(0, ("SCardBeginTransaction: error, bad code"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
status = GET_UINT32(msg, 0);
|
||||
LLOGLN(10, ("SCardBeginTransaction: got status 0x%8.8x", status));
|
||||
return status;
|
||||
@ -570,29 +593,25 @@ SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition)
|
||||
LLOGLN(0, ("SCardEndTransaction: error, not connected"));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
SET_UINT32(msg, 0, hCard);
|
||||
SET_UINT32(msg, 4, dwDisposition);
|
||||
if (send_message(SCARD_END_TRANSACTION, msg, 8) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardEndTransaction: error, send_message"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
bytes = 256;
|
||||
code = SCARD_END_TRANSACTION;
|
||||
if (get_message(&code, msg, &bytes) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardEndTransaction: error, get_message"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
if ((code != SCARD_END_TRANSACTION) || (bytes != 4))
|
||||
{
|
||||
LLOGLN(0, ("SCardEndTransaction: error, bad code"));
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
status = GET_UINT32(msg, 0);
|
||||
LLOGLN(10, ("SCardEndTransaction: got status 0x%8.8x", status));
|
||||
return status;
|
||||
@ -627,30 +646,26 @@ SCardStatus(SCARDHANDLE hCard, LPSTR mszReaderName, LPDWORD pcchReaderLen,
|
||||
SET_UINT32(msg, 0, hCard);
|
||||
SET_UINT32(msg, 4, cchReaderLen);
|
||||
SET_UINT32(msg, 8, *pcbAtrLen);
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
if (send_message(SCARD_STATUS, msg, 12) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardStatus: error, send_message"));
|
||||
free(msg);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
bytes = 8192;
|
||||
code = SCARD_STATUS;
|
||||
if (get_message(&code, msg, &bytes) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardStatus: error, get_message"));
|
||||
free(msg);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
if (code != SCARD_STATUS)
|
||||
{
|
||||
LLOGLN(0, ("SCardStatus: error, bad code"));
|
||||
free(msg);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
|
||||
LLOGLN(10, ("SCardStatus: cchReaderLen in %d", *pcchReaderLen));
|
||||
offset = 0;
|
||||
@ -693,12 +708,17 @@ SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout,
|
||||
LPSCARD_READERSTATE rgReaderStates, DWORD cReaders)
|
||||
{
|
||||
char *msg;
|
||||
const char *rname;
|
||||
int bytes;
|
||||
int code;
|
||||
int index;
|
||||
int offset;
|
||||
int str_len;
|
||||
int status;
|
||||
int dwCurrentState;
|
||||
int dwEventState;
|
||||
int cbAtr;
|
||||
char atr[36];
|
||||
|
||||
LLOGLN(10, ("SCardGetStatusChange:"));
|
||||
LLOGLN(10, (" dwTimeout %d cReaders %d", dwTimeout, cReaders));
|
||||
@ -714,69 +734,79 @@ SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout,
|
||||
offset = 12;
|
||||
for (index = 0; index < cReaders; index++)
|
||||
{
|
||||
if (rgReaderStates[index].dwCurrentState == 0) /* SCARD_STATE_UNAWARE */
|
||||
rname = rgReaderStates[index].szReader;
|
||||
if (strcmp(rname, "\\\\?PnP?\\Notification") == 0)
|
||||
{
|
||||
rgReaderStates[index].dwEventState = 0;
|
||||
rgReaderStates[index].cbAtr = 0;
|
||||
LLOGLN(10, (" found \\\\?PnP?\\Notification"));
|
||||
dwCurrentState = 0x00010000;
|
||||
dwEventState = 0;
|
||||
cbAtr = 0;
|
||||
memset(atr, 0, 36);
|
||||
}
|
||||
str_len = strlen(rgReaderStates[index].szReader);
|
||||
else
|
||||
{
|
||||
dwCurrentState = rgReaderStates[index].dwCurrentState;
|
||||
dwEventState = rgReaderStates[index].dwEventState;
|
||||
cbAtr = rgReaderStates[index].cbAtr;
|
||||
memset(atr, 0, 36);
|
||||
memcpy(atr, rgReaderStates[index].rgbAtr, 33);
|
||||
}
|
||||
str_len = strlen(rname);
|
||||
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));
|
||||
memcpy(msg + offset, rname, str_len);
|
||||
LLOGLN(10, (" in szReader %s", rname));
|
||||
offset += 100;
|
||||
LLOGLN(10, (" in dwCurrentState 0x%8.8x", rgReaderStates[index].dwCurrentState));
|
||||
SET_UINT32(msg, offset, rgReaderStates[index].dwCurrentState);
|
||||
LLOGLN(10, (" in dwCurrentState 0x%8.8x", dwCurrentState));
|
||||
SET_UINT32(msg, offset, dwCurrentState);
|
||||
offset += 4;
|
||||
LLOGLN(10, (" in dwEventState 0x%8.8x", rgReaderStates[index].dwEventState));
|
||||
SET_UINT32(msg, offset, rgReaderStates[index].dwEventState);
|
||||
LLOGLN(10, (" in dwEventState 0x%8.8x", dwEventState));
|
||||
SET_UINT32(msg, offset, dwEventState);
|
||||
offset += 4;
|
||||
LLOGLN(10, (" in cbAtr %d", rgReaderStates[index].cbAtr));
|
||||
SET_UINT32(msg, offset, rgReaderStates[index].cbAtr);
|
||||
LLOGLN(10, (" in cbAtr %d", cbAtr));
|
||||
SET_UINT32(msg, offset, cbAtr);
|
||||
offset += 4;
|
||||
memset(msg + offset, 0, 36);
|
||||
memcpy(msg + offset, rgReaderStates[index].rgbAtr, 33);
|
||||
memcpy(msg + offset, atr, 36);
|
||||
offset += 36;
|
||||
}
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
if (send_message(SCARD_GET_STATUS_CHANGE, msg, offset) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardGetStatusChange: error, send_message"));
|
||||
free(msg);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
bytes = 8192;
|
||||
code = SCARD_GET_STATUS_CHANGE;
|
||||
if (get_message(&code, msg, &bytes) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardGetStatusChange: error, get_message"));
|
||||
free(msg);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
if (code != SCARD_GET_STATUS_CHANGE)
|
||||
{
|
||||
LLOGLN(0, ("SCardGetStatusChange: error, bad code"));
|
||||
free(msg);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
cReaders = GET_UINT32(msg, 0);
|
||||
offset = 4;
|
||||
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);
|
||||
dwCurrentState = GET_UINT32(msg, offset);
|
||||
rgReaderStates[index].dwCurrentState = dwCurrentState;
|
||||
offset += 4;
|
||||
LLOGLN(10, (" out dwCurrentState 0x%8.8x", rgReaderStates[index].dwCurrentState));
|
||||
rgReaderStates[index].dwEventState = GET_UINT32(msg, offset);
|
||||
LLOGLN(10, (" out dwCurrentState 0x%8.8x", dwCurrentState));
|
||||
dwEventState = GET_UINT32(msg, offset);
|
||||
rgReaderStates[index].dwEventState = dwEventState;
|
||||
offset += 4;
|
||||
LLOGLN(10, (" out dwEventState 0x%8.8x", rgReaderStates[index].dwEventState));
|
||||
rgReaderStates[index].cbAtr = GET_UINT32(msg, offset);
|
||||
LLOGLN(10, (" out dwEventState 0x%8.8x", dwEventState));
|
||||
cbAtr = GET_UINT32(msg, offset);
|
||||
rgReaderStates[index].cbAtr = cbAtr;
|
||||
offset += 4;
|
||||
LLOGLN(10, (" out cbAtr %d", rgReaderStates[index].cbAtr));
|
||||
LLOGLN(10, (" out cbAtr %d", cbAtr));
|
||||
memcpy(rgReaderStates[index].rgbAtr, msg + offset, 33);
|
||||
offset += 36;
|
||||
}
|
||||
@ -831,30 +861,26 @@ SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer,
|
||||
offset += cbSendLength;
|
||||
SET_UINT32(msg, offset, cbRecvLength);
|
||||
offset += 4;
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
if (send_message(SCARD_CONTROL, msg, offset) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardControl: error, send_message"));
|
||||
free(msg);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
bytes = 8192;
|
||||
code = SCARD_CONTROL;
|
||||
if (get_message(&code, msg, &bytes) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardControl: error, get_message"));
|
||||
free(msg);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
if (code != SCARD_CONTROL)
|
||||
{
|
||||
LLOGLN(0, ("SCardControl: error, bad code"));
|
||||
free(msg);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
offset = 0;
|
||||
*lpBytesReturned = GET_UINT32(msg, offset);
|
||||
LLOGLN(10, (" cbRecvLength %d", *lpBytesReturned));
|
||||
@ -937,30 +963,26 @@ SCardTransmit(SCARDHANDLE hCard, const SCARD_IO_REQUEST *pioSendPci,
|
||||
}
|
||||
SET_UINT32(msg, offset, *pcbRecvLength);
|
||||
offset += 4;
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
if (send_message(SCARD_TRANSMIT, msg, offset) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardTransmit: error, send_message"));
|
||||
free(msg);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
bytes = 8192;
|
||||
code = SCARD_TRANSMIT;
|
||||
if (get_message(&code, msg, &bytes) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardTransmit: error, get_message"));
|
||||
free(msg);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
if (code != SCARD_TRANSMIT)
|
||||
{
|
||||
LLOGLN(0, ("SCardTransmit: error, bad code"));
|
||||
free(msg);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
offset = 0;
|
||||
if (pioRecvPci == 0)
|
||||
{
|
||||
@ -1000,8 +1022,6 @@ SCardListReaderGroups(SCARDCONTEXT hContext, LPSTR mszGroups,
|
||||
LLOGLN(0, ("SCardListReaderGroups: error, not connected"));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_S_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1033,7 +1053,6 @@ SCardListReaders(SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders,
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
msg = (char *) malloc(8192);
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
offset = 0;
|
||||
SET_UINT32(msg, offset, hContext);
|
||||
offset += 4;
|
||||
@ -1053,25 +1072,22 @@ SCardListReaders(SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders,
|
||||
{
|
||||
LLOGLN(0, ("SCardListReaders: error, send_message"));
|
||||
free(msg);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
bytes = 8192;
|
||||
code = SCARD_LIST_READERS;
|
||||
if (get_message(&code, msg, &bytes) != 0)
|
||||
{
|
||||
LLOGLN(0, ("SCardListReaders: error, get_message"));
|
||||
free(msg);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
if (code != SCARD_LIST_READERS)
|
||||
{
|
||||
LLOGLN(0, ("SCardListReaders: error, bad code"));
|
||||
free(msg);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
offset = 0;
|
||||
llen = GET_UINT32(msg, offset);
|
||||
offset += 4;
|
||||
@ -1095,10 +1111,11 @@ SCardListReaders(SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders,
|
||||
reader_names[reader_names_index] = 0;
|
||||
reader_names_index++;
|
||||
status = GET_UINT32(msg, offset);
|
||||
LLOGLN(10, ("SCardListReaders: status 0x%8.8x", status));
|
||||
offset += 4;
|
||||
if (mszReaders == 0)
|
||||
{
|
||||
reader_names_index = llen;
|
||||
reader_names_index = llen / 2;
|
||||
}
|
||||
if (pcchReaders != 0)
|
||||
{
|
||||
@ -1123,8 +1140,6 @@ SCardFreeMemory(SCARDCONTEXT hContext, LPCVOID pvMem)
|
||||
LLOGLN(0, ("SCardFreeMemory: error, not connected"));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_S_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1138,8 +1153,6 @@ SCardCancel(SCARDCONTEXT hContext)
|
||||
LLOGLN(0, ("SCardCancel: error, not connected"));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_S_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1154,8 +1167,6 @@ SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr,
|
||||
LLOGLN(0, ("SCardGetAttrib: error, not connected"));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_S_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1170,8 +1181,6 @@ SCardSetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr,
|
||||
LLOGLN(0, ("SCardSetAttrib: error, not connected"));
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
}
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
return SCARD_S_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ scard_deinit(void)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_send_establish_context(struct trans *con, int scope)
|
||||
scard_send_establish_context(void *user_data, int scope)
|
||||
{
|
||||
IRP *irp;
|
||||
|
||||
@ -352,7 +352,7 @@ scard_send_establish_context(struct trans *con, int scope)
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->DeviceId = g_device_id;
|
||||
irp->callback = scard_handle_EstablishContext_Return;
|
||||
irp->user_data = con;
|
||||
irp->user_data = user_data;
|
||||
|
||||
/* send IRP to client */
|
||||
scard_send_EstablishContext(irp, scope);
|
||||
@ -364,7 +364,7 @@ scard_send_establish_context(struct trans *con, int scope)
|
||||
* Release a previously established Smart Card context
|
||||
*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_send_release_context(struct trans *con, tui32 context)
|
||||
scard_send_release_context(void *user_data, tui32 context)
|
||||
{
|
||||
IRP *irp;
|
||||
|
||||
@ -379,7 +379,7 @@ scard_send_release_context(struct trans *con, tui32 context)
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->DeviceId = g_device_id;
|
||||
irp->callback = scard_handle_ReleaseContext_Return;
|
||||
irp->user_data = con;
|
||||
irp->user_data = user_data;
|
||||
|
||||
/* send IRP to client */
|
||||
scard_send_ReleaseContext(irp, context);
|
||||
@ -391,7 +391,7 @@ scard_send_release_context(struct trans *con, tui32 context)
|
||||
* Checks if a previously established context is still valid
|
||||
*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_send_is_valid_context(struct trans *con, tui32 context)
|
||||
scard_send_is_valid_context(void *user_data, tui32 context)
|
||||
{
|
||||
IRP *irp;
|
||||
|
||||
@ -406,7 +406,7 @@ scard_send_is_valid_context(struct trans *con, tui32 context)
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->DeviceId = g_device_id;
|
||||
irp->callback = scard_handle_IsContextValid_Return;
|
||||
irp->user_data = con;
|
||||
irp->user_data = user_data;
|
||||
|
||||
/* send IRP to client */
|
||||
scard_send_IsContextValid(irp, context);
|
||||
@ -418,7 +418,7 @@ scard_send_is_valid_context(struct trans *con, tui32 context)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_send_list_readers(struct trans *con, tui32 context, char *groups,
|
||||
scard_send_list_readers(void *user_data, tui32 context, char *groups,
|
||||
int cchReaders, int wide)
|
||||
{
|
||||
IRP *irp;
|
||||
@ -433,7 +433,7 @@ scard_send_list_readers(struct trans *con, tui32 context, char *groups,
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->DeviceId = g_device_id;
|
||||
irp->callback = scard_handle_ListReaders_Return;
|
||||
irp->user_data = con;
|
||||
irp->user_data = user_data;
|
||||
|
||||
/* send IRP to client */
|
||||
scard_send_ListReaders(irp, context, groups, cchReaders, wide);
|
||||
@ -451,7 +451,7 @@ scard_send_list_readers(struct trans *con, tui32 context, char *groups,
|
||||
* @param rsa array of READER_STATEs
|
||||
*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_send_get_status_change(struct trans *con, tui32 context, int wide,
|
||||
scard_send_get_status_change(void *user_data, tui32 context, int wide,
|
||||
tui32 timeout, tui32 num_readers,
|
||||
READER_STATE* rsa)
|
||||
{
|
||||
@ -468,7 +468,7 @@ scard_send_get_status_change(struct trans *con, tui32 context, int wide,
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->DeviceId = g_device_id;
|
||||
irp->callback = scard_handle_GetStatusChange_Return;
|
||||
irp->user_data = con;
|
||||
irp->user_data = user_data;
|
||||
|
||||
/* send IRP to client */
|
||||
scard_send_GetStatusChange(irp, context, wide, timeout, num_readers, rsa);
|
||||
@ -483,7 +483,7 @@ scard_send_get_status_change(struct trans *con, tui32 context, int wide,
|
||||
* @param wide TRUE if unicode string
|
||||
*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_send_connect(struct trans *con, tui32 context, int wide,
|
||||
scard_send_connect(void *user_data, tui32 context, int wide,
|
||||
READER_STATE* rs)
|
||||
{
|
||||
IRP *irp;
|
||||
@ -499,7 +499,7 @@ scard_send_connect(struct trans *con, tui32 context, int wide,
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->DeviceId = g_device_id;
|
||||
irp->callback = scard_handle_Connect_Return;
|
||||
irp->user_data = con;
|
||||
irp->user_data = user_data;
|
||||
|
||||
/* send IRP to client */
|
||||
scard_send_Connect(irp, context, wide, rs);
|
||||
@ -519,7 +519,7 @@ scard_send_connect(struct trans *con, tui32 context, int wide,
|
||||
* rs.init_type
|
||||
*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_send_reconnect(struct trans *con, tui32 context, tui32 sc_handle,
|
||||
scard_send_reconnect(void *user_data, tui32 context, tui32 sc_handle,
|
||||
READER_STATE* rs)
|
||||
{
|
||||
IRP *irp;
|
||||
@ -535,7 +535,7 @@ scard_send_reconnect(struct trans *con, tui32 context, tui32 sc_handle,
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->DeviceId = g_device_id;
|
||||
irp->callback = scard_handle_Reconnect_Return;
|
||||
irp->user_data = con;
|
||||
irp->user_data = user_data;
|
||||
|
||||
/* send IRP to client */
|
||||
scard_send_Reconnect(irp, context, sc_handle, rs);
|
||||
@ -550,7 +550,7 @@ scard_send_reconnect(struct trans *con, tui32 context, tui32 sc_handle,
|
||||
* @param con connection to client
|
||||
*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_send_begin_transaction(struct trans *con, tui32 sc_handle)
|
||||
scard_send_begin_transaction(void *user_data, tui32 sc_handle)
|
||||
{
|
||||
IRP *irp;
|
||||
|
||||
@ -565,7 +565,7 @@ scard_send_begin_transaction(struct trans *con, tui32 sc_handle)
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->DeviceId = g_device_id;
|
||||
irp->callback = scard_handle_BeginTransaction_Return;
|
||||
irp->user_data = con;
|
||||
irp->user_data = user_data;
|
||||
|
||||
/* send IRP to client */
|
||||
scard_send_BeginTransaction(irp, sc_handle);
|
||||
@ -581,7 +581,7 @@ scard_send_begin_transaction(struct trans *con, tui32 sc_handle)
|
||||
* @param sc_handle handle to smartcard
|
||||
*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_send_end_transaction(struct trans *con, tui32 sc_handle,
|
||||
scard_send_end_transaction(void *user_data, tui32 sc_handle,
|
||||
tui32 dwDisposition)
|
||||
{
|
||||
IRP *irp;
|
||||
@ -597,7 +597,7 @@ scard_send_end_transaction(struct trans *con, tui32 sc_handle,
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->DeviceId = g_device_id;
|
||||
irp->callback = scard_handle_EndTransaction_Return;
|
||||
irp->user_data = con;
|
||||
irp->user_data = user_data;
|
||||
|
||||
/* send IRP to client */
|
||||
scard_send_EndTransaction(irp, sc_handle, dwDisposition);
|
||||
@ -612,7 +612,7 @@ scard_send_end_transaction(struct trans *con, tui32 sc_handle,
|
||||
* @param wide TRUE if unicode string
|
||||
*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_send_status(struct trans *con, int wide, tui32 sc_handle,
|
||||
scard_send_status(void *user_data, int wide, tui32 sc_handle,
|
||||
int cchReaderLen, int cbAtrLen)
|
||||
{
|
||||
IRP *irp;
|
||||
@ -628,7 +628,7 @@ scard_send_status(struct trans *con, int wide, tui32 sc_handle,
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->DeviceId = g_device_id;
|
||||
irp->callback = scard_handle_Status_Return;
|
||||
irp->user_data = con;
|
||||
irp->user_data = user_data;
|
||||
|
||||
/* send IRP to client */
|
||||
scard_send_Status(irp, wide, sc_handle, cchReaderLen, cbAtrLen);
|
||||
@ -643,7 +643,7 @@ scard_send_status(struct trans *con, int wide, tui32 sc_handle,
|
||||
* @param sc_handle handle to smartcard
|
||||
*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_send_disconnect(struct trans *con, tui32 context, tui32 sc_handle,
|
||||
scard_send_disconnect(void *user_data, tui32 context, tui32 sc_handle,
|
||||
int dwDisposition)
|
||||
{
|
||||
IRP *irp;
|
||||
@ -659,7 +659,7 @@ scard_send_disconnect(struct trans *con, tui32 context, tui32 sc_handle,
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->DeviceId = g_device_id;
|
||||
irp->callback = scard_handle_Disconnect_Return;
|
||||
irp->user_data = con;
|
||||
irp->user_data = user_data;
|
||||
|
||||
/* send IRP to client */
|
||||
scard_send_Disconnect(irp, context, sc_handle, dwDisposition);
|
||||
@ -672,7 +672,7 @@ scard_send_disconnect(struct trans *con, tui32 context, tui32 sc_handle,
|
||||
* associated with a valid context.
|
||||
*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_send_transmit(struct trans *con, tui32 sc_handle,
|
||||
scard_send_transmit(void *user_data, tui32 sc_handle,
|
||||
char *send_data, int send_bytes, int recv_bytes,
|
||||
struct xrdp_scard_io_request *send_ior,
|
||||
struct xrdp_scard_io_request *recv_ior)
|
||||
@ -690,7 +690,7 @@ scard_send_transmit(struct trans *con, tui32 sc_handle,
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->DeviceId = g_device_id;
|
||||
irp->callback = scard_handle_Transmit_Return;
|
||||
irp->user_data = con;
|
||||
irp->user_data = user_data;
|
||||
|
||||
/* send IRP to client */
|
||||
scard_send_Transmit(irp, sc_handle, send_data, send_bytes, recv_bytes,
|
||||
@ -703,7 +703,7 @@ scard_send_transmit(struct trans *con, tui32 sc_handle,
|
||||
* Communicate directly with the smart card reader
|
||||
*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_send_control(struct trans *con, tui32 sc_handle,
|
||||
scard_send_control(void *user_data, tui32 sc_handle,
|
||||
char *send_data, int send_bytes,
|
||||
int recv_bytes, int control_code)
|
||||
{
|
||||
@ -720,7 +720,7 @@ scard_send_control(struct trans *con, tui32 sc_handle,
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->DeviceId = g_device_id;
|
||||
irp->callback = scard_handle_Control_Return;
|
||||
irp->user_data = con;
|
||||
irp->user_data = user_data;
|
||||
|
||||
/* send IRP to client */
|
||||
scard_send_Control(irp, sc_handle, send_data,
|
||||
@ -733,7 +733,7 @@ scard_send_control(struct trans *con, tui32 sc_handle,
|
||||
* Cancel any outstanding calls
|
||||
*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_send_cancel(struct trans *con, tui32 context)
|
||||
scard_send_cancel(void *user_data, tui32 context)
|
||||
{
|
||||
IRP *irp;
|
||||
|
||||
@ -748,7 +748,7 @@ scard_send_cancel(struct trans *con, tui32 context)
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->DeviceId = g_device_id;
|
||||
irp->callback = scard_handle_Cancel_Return;
|
||||
irp->user_data = con;
|
||||
irp->user_data = user_data;
|
||||
|
||||
/* send IRP to client */
|
||||
scard_send_Cancel(irp, context);
|
||||
@ -760,7 +760,7 @@ scard_send_cancel(struct trans *con, tui32 context)
|
||||
* Get reader attributes
|
||||
*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_send_get_attrib(struct trans *con, tui32 sc_handle, READER_STATE* rs)
|
||||
scard_send_get_attrib(void *user_data, tui32 sc_handle, READER_STATE* rs)
|
||||
{
|
||||
IRP *irp;
|
||||
|
||||
@ -775,7 +775,7 @@ scard_send_get_attrib(struct trans *con, tui32 sc_handle, READER_STATE* rs)
|
||||
irp->CompletionId = g_completion_id++;
|
||||
irp->DeviceId = g_device_id;
|
||||
irp->callback = scard_handle_GetAttrib_Return;
|
||||
irp->user_data = con;
|
||||
irp->user_data = user_data;
|
||||
|
||||
/* send IRP to client */
|
||||
scard_send_GetAttrib(irp, sc_handle, rs);
|
||||
@ -2060,24 +2060,20 @@ scard_send_Cancel(IRP *irp, tui32 context)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* command format
|
||||
*
|
||||
* ......
|
||||
* 20 bytes padding
|
||||
* u32 4 bytes len 8, LE, v1
|
||||
* u32 4 bytes filler
|
||||
* 16 bytes unused (s->p currently pointed here at unused[0])
|
||||
* u32 4 bytes context len
|
||||
* u32 4 bytes context
|
||||
*/
|
||||
|
||||
xstream_seek(s, 16);
|
||||
xstream_wr_u32_le(s, 4);
|
||||
xstream_wr_u32_le(s, context);
|
||||
s_push_layer(s, mcs_hdr, 4); /* bytes, set later */
|
||||
out_uint32_le(s, 0x00000000);
|
||||
out_uint32_le(s, 0x00000004);
|
||||
out_uint32_le(s, 0x00020000);
|
||||
out_uint32_le(s, 4);
|
||||
out_uint32_le(s, context);
|
||||
|
||||
s_mark_end(s);
|
||||
|
||||
s_pop_layer(s, mcs_hdr);
|
||||
bytes = (int) (s->end - s->p);
|
||||
bytes -= 8;
|
||||
out_uint32_le(s, bytes);
|
||||
|
||||
s_pop_layer(s, iso_hdr);
|
||||
bytes = (int) (s->end - s->p);
|
||||
bytes -= 28;
|
||||
@ -2171,7 +2167,6 @@ scard_handle_EstablishContext_Return(struct stream *s, IRP *irp,
|
||||
tui32 IoStatus)
|
||||
{
|
||||
tui32 len;
|
||||
struct trans *con;
|
||||
|
||||
log_debug("entered");
|
||||
/* sanity check */
|
||||
@ -2182,8 +2177,7 @@ scard_handle_EstablishContext_Return(struct stream *s, IRP *irp,
|
||||
}
|
||||
/* get OutputBufferLen */
|
||||
xstream_rd_u32_le(s, len);
|
||||
con = (struct trans *) (irp->user_data);
|
||||
scard_function_establish_context_return(con, s, len, IoStatus);
|
||||
scard_function_establish_context_return(irp->user_data, s, len, IoStatus);
|
||||
devredir_irp_delete(irp);
|
||||
log_debug("leaving");
|
||||
}
|
||||
@ -2197,7 +2191,6 @@ scard_handle_ReleaseContext_Return(struct stream *s, IRP *irp,
|
||||
tui32 IoStatus)
|
||||
{
|
||||
tui32 len;
|
||||
struct trans *con;
|
||||
|
||||
log_debug("entered");
|
||||
/* sanity check */
|
||||
@ -2208,8 +2201,7 @@ scard_handle_ReleaseContext_Return(struct stream *s, IRP *irp,
|
||||
}
|
||||
/* get OutputBufferLen */
|
||||
xstream_rd_u32_le(s, len);
|
||||
con = (struct trans *) (irp->user_data);
|
||||
scard_function_release_context_return(con, s, len, IoStatus);
|
||||
scard_function_release_context_return(irp->user_data, s, len, IoStatus);
|
||||
devredir_irp_delete(irp);
|
||||
log_debug("leaving");
|
||||
}
|
||||
@ -2223,7 +2215,6 @@ APP_CC scard_handle_IsContextValid_Return(struct stream *s, IRP *irp,
|
||||
tui32 IoStatus)
|
||||
{
|
||||
tui32 len;
|
||||
struct trans *con;
|
||||
|
||||
log_debug("entered");
|
||||
|
||||
@ -2236,8 +2227,7 @@ APP_CC scard_handle_IsContextValid_Return(struct stream *s, IRP *irp,
|
||||
|
||||
/* get OutputBufferLen */
|
||||
xstream_rd_u32_le(s, len);
|
||||
con = (struct trans *) (irp->user_data);
|
||||
scard_function_is_context_valid_return(con, s, len, IoStatus);
|
||||
scard_function_is_context_valid_return(irp->user_data, s, len, IoStatus);
|
||||
devredir_irp_delete(irp);
|
||||
log_debug("leaving");
|
||||
}
|
||||
@ -2251,7 +2241,6 @@ scard_handle_ListReaders_Return(struct stream *s, IRP *irp,
|
||||
tui32 IoStatus)
|
||||
{
|
||||
tui32 len;
|
||||
struct trans *con;
|
||||
|
||||
log_debug("entered");
|
||||
/* sanity check */
|
||||
@ -2262,8 +2251,7 @@ scard_handle_ListReaders_Return(struct stream *s, IRP *irp,
|
||||
}
|
||||
/* get OutputBufferLen */
|
||||
xstream_rd_u32_le(s, len);
|
||||
con = (struct trans *) (irp->user_data);
|
||||
scard_function_list_readers_return(con, s, len, IoStatus);
|
||||
scard_function_list_readers_return(irp->user_data, s, len, IoStatus);
|
||||
devredir_irp_delete(irp);
|
||||
log_debug("leaving");
|
||||
}
|
||||
@ -2277,7 +2265,6 @@ scard_handle_GetStatusChange_Return(struct stream *s, IRP *irp,
|
||||
tui32 IoStatus)
|
||||
{
|
||||
tui32 len;
|
||||
struct trans *con;
|
||||
|
||||
log_debug("entered");
|
||||
/* sanity check */
|
||||
@ -2288,8 +2275,7 @@ scard_handle_GetStatusChange_Return(struct stream *s, IRP *irp,
|
||||
}
|
||||
/* get OutputBufferLen */
|
||||
xstream_rd_u32_le(s, len);
|
||||
con = (struct trans *) (irp->user_data);
|
||||
scard_function_get_status_change_return(con, s, len, IoStatus);
|
||||
scard_function_get_status_change_return(irp->user_data, s, len, IoStatus);
|
||||
devredir_irp_delete(irp);
|
||||
log_debug("leaving");
|
||||
}
|
||||
@ -2303,7 +2289,6 @@ scard_handle_Connect_Return(struct stream *s, IRP *irp,
|
||||
tui32 IoStatus)
|
||||
{
|
||||
tui32 len;
|
||||
struct trans *con;
|
||||
|
||||
log_debug("entered");
|
||||
|
||||
@ -2317,8 +2302,7 @@ scard_handle_Connect_Return(struct stream *s, IRP *irp,
|
||||
/* get OutputBufferLen */
|
||||
xstream_rd_u32_le(s, len);
|
||||
|
||||
con = (struct trans *) (irp->user_data);
|
||||
scard_function_connect_return(con, s, len, IoStatus);
|
||||
scard_function_connect_return(irp->user_data, s, len, IoStatus);
|
||||
devredir_irp_delete(irp);
|
||||
|
||||
log_debug("leaving");
|
||||
@ -2333,7 +2317,6 @@ scard_handle_Reconnect_Return(struct stream *s, IRP *irp,
|
||||
tui32 IoStatus)
|
||||
{
|
||||
tui32 len;
|
||||
struct trans *con;
|
||||
|
||||
log_debug("entered");
|
||||
|
||||
@ -2346,8 +2329,7 @@ scard_handle_Reconnect_Return(struct stream *s, IRP *irp,
|
||||
|
||||
/* get OutputBufferLen */
|
||||
xstream_rd_u32_le(s, len);
|
||||
con = (struct trans *) (irp->user_data);
|
||||
scard_function_reconnect_return(con, s, len, IoStatus);
|
||||
scard_function_reconnect_return(irp->user_data, s, len, IoStatus);
|
||||
devredir_irp_delete(irp);
|
||||
log_debug("leaving");
|
||||
}
|
||||
@ -2361,7 +2343,6 @@ scard_handle_BeginTransaction_Return(struct stream *s, IRP *irp,
|
||||
tui32 IoStatus)
|
||||
{
|
||||
tui32 len;
|
||||
struct trans *con;
|
||||
|
||||
log_debug("entered");
|
||||
|
||||
@ -2374,8 +2355,7 @@ scard_handle_BeginTransaction_Return(struct stream *s, IRP *irp,
|
||||
|
||||
/* get OutputBufferLen */
|
||||
xstream_rd_u32_le(s, len);
|
||||
con = (struct trans *) (irp->user_data);
|
||||
scard_function_begin_transaction_return(con, s, len, IoStatus);
|
||||
scard_function_begin_transaction_return(irp->user_data, s, len, IoStatus);
|
||||
devredir_irp_delete(irp);
|
||||
log_debug("leaving");
|
||||
}
|
||||
@ -2389,7 +2369,6 @@ scard_handle_EndTransaction_Return(struct stream *s, IRP *irp,
|
||||
tui32 IoStatus)
|
||||
{
|
||||
tui32 len;
|
||||
struct trans *con;
|
||||
|
||||
log_debug("entered");
|
||||
|
||||
@ -2402,8 +2381,7 @@ scard_handle_EndTransaction_Return(struct stream *s, IRP *irp,
|
||||
|
||||
/* get OutputBufferLen */
|
||||
xstream_rd_u32_le(s, len);
|
||||
con = (struct trans *) (irp->user_data);
|
||||
scard_function_end_transaction_return(con, s, len, IoStatus);
|
||||
scard_function_end_transaction_return(irp->user_data, s, len, IoStatus);
|
||||
devredir_irp_delete(irp);
|
||||
log_debug("leaving");
|
||||
}
|
||||
@ -2417,7 +2395,6 @@ scard_handle_Status_Return(struct stream *s, IRP *irp,
|
||||
tui32 IoStatus)
|
||||
{
|
||||
tui32 len;
|
||||
struct trans *con;
|
||||
|
||||
log_debug("entered");
|
||||
|
||||
@ -2430,8 +2407,7 @@ scard_handle_Status_Return(struct stream *s, IRP *irp,
|
||||
|
||||
/* get OutputBufferLen */
|
||||
xstream_rd_u32_le(s, len);
|
||||
con = (struct trans *) (irp->user_data);
|
||||
scard_function_status_return(con, s, len, IoStatus);
|
||||
scard_function_status_return(irp->user_data, s, len, IoStatus);
|
||||
devredir_irp_delete(irp);
|
||||
log_debug("leaving");
|
||||
}
|
||||
@ -2445,7 +2421,6 @@ scard_handle_Disconnect_Return(struct stream *s, IRP *irp,
|
||||
tui32 IoStatus)
|
||||
{
|
||||
tui32 len;
|
||||
struct trans *con;
|
||||
|
||||
log_debug("entered");
|
||||
|
||||
@ -2458,8 +2433,7 @@ scard_handle_Disconnect_Return(struct stream *s, IRP *irp,
|
||||
|
||||
/* get OutputBufferLen */
|
||||
xstream_rd_u32_le(s, len);
|
||||
con = (struct trans *) (irp->user_data);
|
||||
scard_function_disconnect_return(con, s, len, IoStatus);
|
||||
scard_function_disconnect_return(irp->user_data, s, len, IoStatus);
|
||||
devredir_irp_delete(irp);
|
||||
log_debug("leaving");
|
||||
}
|
||||
@ -2472,7 +2446,6 @@ scard_handle_Transmit_Return(struct stream *s, IRP *irp, tui32 DeviceId,
|
||||
tui32 CompletionId, tui32 IoStatus)
|
||||
{
|
||||
tui32 len;
|
||||
struct trans *con;
|
||||
|
||||
log_debug("entered");
|
||||
|
||||
@ -2485,8 +2458,7 @@ scard_handle_Transmit_Return(struct stream *s, IRP *irp, tui32 DeviceId,
|
||||
|
||||
/* get OutputBufferLen */
|
||||
xstream_rd_u32_le(s, len);
|
||||
con = (struct trans *) (irp->user_data);
|
||||
scard_function_transmit_return(con, s, len, IoStatus);
|
||||
scard_function_transmit_return(irp->user_data, s, len, IoStatus);
|
||||
devredir_irp_delete(irp);
|
||||
log_debug("leaving");
|
||||
}
|
||||
@ -2499,7 +2471,6 @@ scard_handle_Control_Return(struct stream *s, IRP *irp, tui32 DeviceId,
|
||||
tui32 CompletionId,tui32 IoStatus)
|
||||
{
|
||||
tui32 len;
|
||||
struct trans *con;
|
||||
|
||||
log_debug("entered");
|
||||
|
||||
@ -2512,8 +2483,7 @@ scard_handle_Control_Return(struct stream *s, IRP *irp, tui32 DeviceId,
|
||||
|
||||
/* get OutputBufferLen */
|
||||
xstream_rd_u32_le(s, len);
|
||||
con = (struct trans *) (irp->user_data);
|
||||
scard_function_control_return(con, s, len, IoStatus);
|
||||
scard_function_control_return(irp->user_data, s, len, IoStatus);
|
||||
devredir_irp_delete(irp);
|
||||
log_debug("leaving");
|
||||
}
|
||||
@ -2526,7 +2496,6 @@ scard_handle_Cancel_Return(struct stream *s, IRP *irp, tui32 DeviceId,
|
||||
tui32 CompletionId, tui32 IoStatus)
|
||||
{
|
||||
tui32 len;
|
||||
struct trans *con;
|
||||
|
||||
log_debug("entered");
|
||||
|
||||
@ -2539,8 +2508,7 @@ scard_handle_Cancel_Return(struct stream *s, IRP *irp, tui32 DeviceId,
|
||||
|
||||
/* get OutputBufferLen */
|
||||
xstream_rd_u32_le(s, len);
|
||||
con = (struct trans *) (irp->user_data);
|
||||
scard_function_cancel_return(con, s, len, IoStatus);
|
||||
scard_function_cancel_return(irp->user_data, s, len, IoStatus);
|
||||
devredir_irp_delete(irp);
|
||||
log_debug("leaving");
|
||||
}
|
||||
@ -2553,7 +2521,6 @@ scard_handle_GetAttrib_Return(struct stream *s, IRP *irp, tui32 DeviceId,
|
||||
tui32 CompletionId, tui32 IoStatus)
|
||||
{
|
||||
tui32 len;
|
||||
struct trans *con;
|
||||
|
||||
log_debug("entered");
|
||||
|
||||
@ -2566,8 +2533,7 @@ scard_handle_GetAttrib_Return(struct stream *s, IRP *irp, tui32 DeviceId,
|
||||
|
||||
/* get OutputBufferLen */
|
||||
xstream_rd_u32_le(s, len);
|
||||
con = (struct trans *) (irp->user_data);
|
||||
scard_function_get_attrib_return(con, s, len, IoStatus);
|
||||
scard_function_get_attrib_return(irp->user_data, s, len, IoStatus);
|
||||
devredir_irp_delete(irp);
|
||||
log_debug("leaving");
|
||||
}
|
||||
|
@ -110,42 +110,42 @@ int APP_CC scard_get_wait_objs(tbus *objs, int *count, int *timeout);
|
||||
int APP_CC scard_check_wait_objs(void);
|
||||
int APP_CC scard_init(void);
|
||||
int APP_CC scard_deinit(void);
|
||||
int APP_CC scard_send_establish_context(struct trans *con, int scope);
|
||||
int APP_CC scard_send_release_context(struct trans *con, tui32 context);
|
||||
int APP_CC scard_send_is_valid_context(struct trans *con, tui32 context);
|
||||
int APP_CC scard_send_list_readers(struct trans *con, tui32 context,
|
||||
int APP_CC scard_send_establish_context(void *user_data, int scope);
|
||||
int APP_CC scard_send_release_context(void *user_data, tui32 context);
|
||||
int APP_CC scard_send_is_valid_context(void *user_data, tui32 context);
|
||||
int APP_CC scard_send_list_readers(void *user_data, tui32 context,
|
||||
char *groups, int cchReaders, int wide);
|
||||
|
||||
int APP_CC scard_send_get_status_change(struct trans *con, tui32 context,
|
||||
int APP_CC scard_send_get_status_change(void *user_data, tui32 context,
|
||||
int wide, tui32 timeout,
|
||||
tui32 num_readers, READER_STATE* rsa);
|
||||
|
||||
int APP_CC scard_send_connect(struct trans *con, tui32 context, int wide,
|
||||
int APP_CC scard_send_connect(void *user_data, tui32 context, int wide,
|
||||
READER_STATE* rs);
|
||||
|
||||
int APP_CC scard_send_reconnect(struct trans *con, tui32 context,
|
||||
int APP_CC scard_send_reconnect(void *user_data, tui32 context,
|
||||
tui32 sc_handle, READER_STATE* rs);
|
||||
|
||||
int APP_CC scard_send_begin_transaction(struct trans *con, tui32 sc_handle);
|
||||
int APP_CC scard_send_end_transaction(struct trans *con, tui32 sc_handle,
|
||||
int APP_CC scard_send_begin_transaction(void *user_data, tui32 sc_handle);
|
||||
int APP_CC scard_send_end_transaction(void *user_data, tui32 sc_handle,
|
||||
tui32 dwDisposition);
|
||||
int APP_CC scard_send_status(struct trans *con, int wide, tui32 sc_handle,
|
||||
int APP_CC scard_send_status(void *user_data, int wide, tui32 sc_handle,
|
||||
int cchReaderLen, int cbAtrLen);
|
||||
int APP_CC scard_send_disconnect(struct trans *con, tui32 context,
|
||||
int APP_CC scard_send_disconnect(void *user_data, tui32 context,
|
||||
tui32 sc_handle, int dwDisposition);
|
||||
|
||||
int APP_CC scard_send_transmit(struct trans *con, tui32 sc_handle,
|
||||
int APP_CC scard_send_transmit(void *user_data, tui32 sc_handle,
|
||||
char *send_data, int send_bytes, int recv_bytes,
|
||||
struct xrdp_scard_io_request *send_ior,
|
||||
struct xrdp_scard_io_request *recv_ior);
|
||||
|
||||
int APP_CC scard_send_control(struct trans *con, tui32 sc_handle,
|
||||
int APP_CC scard_send_control(void *user_data, tui32 sc_handle,
|
||||
char *send_data, int send_bytes,
|
||||
int recv_bytes, int control_code);
|
||||
|
||||
int APP_CC scard_send_cancel(struct trans *con, tui32 context);
|
||||
int APP_CC scard_send_cancel(void *user_data, tui32 context);
|
||||
|
||||
int APP_CC scard_send_get_attrib(struct trans *con, tui32 sc_handle,
|
||||
int APP_CC scard_send_get_attrib(void *user_data, tui32 sc_handle,
|
||||
READER_STATE* rs);
|
||||
|
||||
/*
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -28,61 +28,61 @@ int APP_CC scard_pcsc_get_wait_objs(tbus *objs, int *count, int *timeout);
|
||||
int APP_CC scard_pcsc_check_wait_objs(void);
|
||||
int APP_CC scard_pcsc_init(void);
|
||||
int APP_CC scard_pcsc_deinit(void);
|
||||
int APP_CC scard_function_establish_context_return(struct trans *con,
|
||||
int APP_CC scard_function_establish_context_return(void *user_data,
|
||||
struct stream *in_s,
|
||||
int len, int status);
|
||||
int APP_CC scard_function_release_context_return(struct trans *con,
|
||||
int APP_CC scard_function_release_context_return(void *user_data,
|
||||
struct stream *in_s,
|
||||
int len, int status);
|
||||
int APP_CC scard_function_list_readers_return(struct trans *con,
|
||||
int APP_CC scard_function_list_readers_return(void *user_data,
|
||||
struct stream *in_s,
|
||||
int len, int status);
|
||||
|
||||
int APP_CC scard_function_transmit_return(struct trans *con,
|
||||
int APP_CC scard_function_transmit_return(void *user_data,
|
||||
struct stream *in_s,
|
||||
int len, int status);
|
||||
|
||||
int APP_CC scard_function_control_return(struct trans *con,
|
||||
int APP_CC scard_function_control_return(void *user_data,
|
||||
struct stream *in_s,
|
||||
int len, int status);
|
||||
|
||||
int APP_CC scard_function_get_status_change_return(struct trans *con,
|
||||
int APP_CC scard_function_get_status_change_return(void *user_data,
|
||||
struct stream *in_s,
|
||||
int len, int status);
|
||||
|
||||
int APP_CC scard_function_connect_return(struct trans *con,
|
||||
int APP_CC scard_function_connect_return(void *user_data,
|
||||
struct stream *in_s,
|
||||
int len, int status);
|
||||
|
||||
int APP_CC scard_function_status_return(struct trans *con,
|
||||
int APP_CC scard_function_status_return(void *user_data,
|
||||
struct stream *in_s,
|
||||
int len, int status);
|
||||
|
||||
int APP_CC scard_function_begin_transaction_return(struct trans *con,
|
||||
int APP_CC scard_function_begin_transaction_return(void *user_data,
|
||||
struct stream *in_s,
|
||||
int len, int status);
|
||||
|
||||
int APP_CC scard_function_end_transaction_return(struct trans *con,
|
||||
int APP_CC scard_function_end_transaction_return(void *user_data,
|
||||
struct stream *in_s,
|
||||
int len, int status);
|
||||
|
||||
int APP_CC scard_function_is_context_valid_return(struct trans *con,
|
||||
int APP_CC scard_function_is_context_valid_return(void *user_data,
|
||||
struct stream *in_s,
|
||||
int len, int status);
|
||||
|
||||
int APP_CC scard_function_reconnect_return(struct trans *con,
|
||||
int APP_CC scard_function_reconnect_return(void *user_data,
|
||||
struct stream *in_s,
|
||||
int len, int status);
|
||||
|
||||
int APP_CC scard_function_disconnect_return(struct trans *con,
|
||||
int APP_CC scard_function_disconnect_return(void *user_data,
|
||||
struct stream *in_s,
|
||||
int len, int status);
|
||||
|
||||
int APP_CC scard_function_cancel_return(struct trans *con,
|
||||
int APP_CC scard_function_cancel_return(void *user_data,
|
||||
struct stream *in_s,
|
||||
int len, int status);
|
||||
|
||||
int APP_CC scard_function_get_attrib_return(struct trans *con,
|
||||
int APP_CC scard_function_get_attrib_return(void *user_data,
|
||||
struct stream *in_s,
|
||||
int len, int status);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user