summaryrefslogtreecommitdiffstats
path: root/sesman/chansrv/pcsc
diff options
context:
space:
mode:
authorJay Sorg <jay.sorg@gmail.com>2014-05-29 20:45:48 -0700
committerJay Sorg <jay.sorg@gmail.com>2014-05-29 20:45:48 -0700
commitd5ea23ed48eff4639355a3752dfeaa26f5fb8642 (patch)
treed1d66d966f3c8ccea778edf340ccea987367363e /sesman/chansrv/pcsc
parent2abe16a609ec3dc23c7bcca04e5f42e5ad7fea25 (diff)
downloadxrdp-proprietary-d5ea23ed48eff4639355a3752dfeaa26f5fb8642.tar.gz
xrdp-proprietary-d5ea23ed48eff4639355a3752dfeaa26f5fb8642.zip
pcsc smartcard fixes form 64 bit from Ken
Diffstat (limited to 'sesman/chansrv/pcsc')
-rw-r--r--sesman/chansrv/pcsc/xrdp_pcsc.c80
1 files changed, 48 insertions, 32 deletions
diff --git a/sesman/chansrv/pcsc/xrdp_pcsc.c b/sesman/chansrv/pcsc/xrdp_pcsc.c
index f4aaba14..439bc35c 100644
--- a/sesman/chansrv/pcsc/xrdp_pcsc.c
+++ b/sesman/chansrv/pcsc/xrdp_pcsc.c
@@ -15,8 +15,13 @@
typedef unsigned char BYTE;
typedef BYTE *LPBYTE;
-typedef unsigned int LONG;
+#ifdef __APPLE__
+typedef int LONG;
typedef unsigned int DWORD;
+#else
+typedef long LONG;
+typedef unsigned long DWORD;
+#endif
typedef DWORD *LPDWORD;
typedef const void *LPCVOID;
typedef const char *LPCSTR;
@@ -156,7 +161,7 @@ get_display_num_from_display(const char *display_text)
host[host_index] = 0;
disp[disp_index] = 0;
scre[scre_index] = 0;
- LLOGLN(0, ("get_display_num_from_display: host [%s] disp [%s] scre [%s]",
+ LLOGLN(10, ("get_display_num_from_display: host [%s] disp [%s] scre [%s]",
host, disp, scre));
rv = atoi(disp);
return rv;
@@ -219,7 +224,7 @@ connect_to_chansrv(void)
bytes = sizeof(saddr.sun_path);
snprintf(saddr.sun_path, bytes, "%s/.pcsc%d/pcscd.comm", home_str, dis);
saddr.sun_path[bytes - 1] = 0;
- LLOGLN(0, ("connect_to_chansrv: connecting to %s", saddr.sun_path));
+ LLOGLN(10, ("connect_to_chansrv: connecting to %s", saddr.sun_path));
psaddr = (struct sockaddr *) &saddr;
bytes = sizeof(struct sockaddr_un);
error = connect(g_sck, psaddr, bytes);
@@ -392,7 +397,7 @@ SCardEstablishContext(DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2,
}
context = GET_UINT32(msg, 0);
status = GET_UINT32(msg, 4);
- LLOGLN(10, ("SCardEstablishContext: got context 0x%8.8x", context));
+ LLOGLN(10, ("SCardEstablishContext: got context 0x%8.8x", (int)context));
*phContext = context;
return status;
}
@@ -463,7 +468,7 @@ SCardConnect(SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode,
LLOGLN(10, ("SCardConnect:"));
LLOGLN(10, ("SCardConnect: hContext 0x%8.8x szReader %s dwShareMode %d "
"dwPreferredProtocols %d",
- hContext, szReader, dwShareMode, dwPreferredProtocols));
+ (int)hContext, szReader, (int)dwShareMode, (int)dwPreferredProtocols));
if (g_sck == -1)
{
LLOGLN(0, ("SCardConnect: error, not connected"));
@@ -507,7 +512,7 @@ SCardConnect(SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode,
status = GET_UINT32(msg, 8);
LLOGLN(10, ("SCardConnect: got status 0x%8.8x hCard 0x%8.8x "
"dwActiveProtocol %d",
- status, *phCard, *pdwActiveProtocol));
+ status, (int)*phCard, (int)*pdwActiveProtocol));
return status;
}
@@ -536,7 +541,7 @@ SCardDisconnect(SCARDHANDLE hCard, DWORD dwDisposition)
int status;
LLOGLN(10, ("SCardDisconnect: hCard 0x%8.8x dwDisposition %d",
- hCard, dwDisposition));
+ (int)hCard, (int)dwDisposition));
if (g_sck == -1)
{
LLOGLN(0, ("SCardDisconnect: error, not connected"));
@@ -575,7 +580,7 @@ SCardBeginTransaction(SCARDHANDLE hCard)
int bytes;
int status;
- LLOGLN(10, ("SCardBeginTransaction: hCard 0x%8.8x", hCard));
+ LLOGLN(10, ("SCardBeginTransaction: hCard 0x%8.8x", (int)hCard));
if (hCard == 0)
{
LLOGLN(0, ("SCardBeginTransaction: error, bad hCard"));
@@ -665,7 +670,7 @@ SCardStatus(SCARDHANDLE hCard, LPSTR mszReaderName, LPDWORD pcchReaderLen,
LLOGLN(10, ("SCardStatus:"));
if (hCard == 0)
{
- LLOGLN(0, ("SCardStatus: error, bad hCard"));
+ LLOGLN(10, ("SCardStatus: error, bad hCard"));
return SCARD_F_INTERNAL_ERROR;
}
if (g_sck == -1)
@@ -673,9 +678,9 @@ SCardStatus(SCARDHANDLE hCard, LPSTR mszReaderName, LPDWORD pcchReaderLen,
LLOGLN(0, ("SCardStatus: error, not connected"));
return SCARD_F_INTERNAL_ERROR;
}
- LLOGLN(10, (" hCard 0x%8.8x", hCard));
- LLOGLN(10, (" cchReaderLen %d", *pcchReaderLen));
- LLOGLN(10, (" cbAtrLen %d", *pcbAtrLen));
+ LLOGLN(10, (" hCard 0x%8.8x", (int)hCard));
+ LLOGLN(10, (" cchReaderLen %d", (int)*pcchReaderLen));
+ LLOGLN(10, (" cbAtrLen %d", (int)*pcbAtrLen));
cchReaderLen = *pcchReaderLen;
msg = (char *) malloc(8192);
@@ -703,10 +708,10 @@ SCardStatus(SCARDHANDLE hCard, LPSTR mszReaderName, LPDWORD pcchReaderLen,
return SCARD_F_INTERNAL_ERROR;
}
- LLOGLN(10, ("SCardStatus: cchReaderLen in %d", *pcchReaderLen));
+ LLOGLN(10, ("SCardStatus: cchReaderLen in %d", (int)*pcchReaderLen));
offset = 0;
*pcchReaderLen = GET_UINT32(msg, offset);
- LLOGLN(10, ("SCardStatus: cchReaderLen out %d", *pcchReaderLen));
+ LLOGLN(10, ("SCardStatus: cchReaderLen out %d", (int)*pcchReaderLen));
offset += 4;
if (cchReaderLen > 0)
{
@@ -721,14 +726,18 @@ SCardStatus(SCARDHANDLE hCard, LPSTR mszReaderName, LPDWORD pcchReaderLen,
LLOGLN(10, ("SCardStatus: mszReaderName out %s", mszReaderName));
offset += *pcchReaderLen;
*pdwState = GET_UINT32(msg, offset);
- LLOGLN(10, ("SCardStatus: dwState %d", *pdwState));
+ if (*pdwState == 1)
+ {
+ *pdwState = 0x34;
+ }
+ LLOGLN(10, ("SCardStatus: dwState %d", (int)*pdwState));
offset += 4;
*pdwProtocol = GET_UINT32(msg, offset);
- LLOGLN(10, ("SCardStatus: dwProtocol %d", *pdwProtocol));
+ LLOGLN(10, ("SCardStatus: dwProtocol %d", (int)*pdwProtocol));
offset += 4;
*pcbAtrLen = GET_UINT32(msg, offset);
offset += 4;
- LLOGLN(10, ("SCardStatus: cbAtrLen %d", *pcbAtrLen));
+ LLOGLN(10, ("SCardStatus: cbAtrLen %d", (int)*pcbAtrLen));
memcpy(pbAtr, msg + offset, *pcbAtrLen);
offset += *pcbAtrLen;
status = GET_UINT32(msg, offset);
@@ -757,7 +766,7 @@ SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout,
char atr[36];
LLOGLN(10, ("SCardGetStatusChange:"));
- LLOGLN(10, (" dwTimeout %d cReaders %d", dwTimeout, cReaders));
+ LLOGLN(10, (" dwTimeout %d cReaders %d", (int)dwTimeout, (int)cReaders));
if (g_sck == -1)
{
LLOGLN(0, ("SCardGetStatusChange: error, not connected"));
@@ -829,7 +838,7 @@ SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout,
}
cReaders = GET_UINT32(msg, 0);
offset = 4;
- LLOGLN(10, ("SCardGetStatusChange: got back cReaders %d", cReaders));
+ LLOGLN(10, ("SCardGetStatusChange: got back cReaders %d", (int)cReaders));
for (index = 0; index < cReaders; index++)
{
rname = rgReaderStates[index].szReader;
@@ -897,10 +906,10 @@ SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer,
LLOGLN(0, ("SCardControl: error, not connected"));
return SCARD_F_INTERNAL_ERROR;
}
- LLOGLN(10, (" hCard 0x%8.8x", hCard));
- LLOGLN(10, (" dwControlCode 0x%8.8x", dwControlCode));
- LLOGLN(10, (" cbSendLength %d", cbSendLength));
- LLOGLN(10, (" cbRecvLength %d", cbRecvLength));
+ LLOGLN(10, (" hCard 0x%8.8x", (int)hCard));
+ LLOGLN(10, (" dwControlCode 0x%8.8x", (int)dwControlCode));
+ LLOGLN(10, (" cbSendLength %d", (int)cbSendLength));
+ LLOGLN(10, (" cbRecvLength %d", (int)cbRecvLength));
/* #define SCARD_CTL_CODE(code) (0x42000000 + (code))
control_code = (control_code & 0x3ffc) >> 2;
@@ -910,7 +919,7 @@ SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer,
dwControlCode = dwControlCode - 0x42000000;
dwControlCode = dwControlCode << 2;
dwControlCode = dwControlCode | (49 << 16);
- LLOGLN(10, (" MS dwControlCode 0x%8.8x", dwControlCode));
+ LLOGLN(10, (" MS dwControlCode 0x%8.8d", (int)dwControlCode));
msg = (char *) malloc(8192);
offset = 0;
@@ -946,7 +955,7 @@ SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer,
}
offset = 0;
*lpBytesReturned = GET_UINT32(msg, offset);
- LLOGLN(10, (" cbRecvLength %d", *lpBytesReturned));
+ LLOGLN(10, (" cbRecvLength %d", (int)*lpBytesReturned));
offset += 4;
memcpy(pbRecvBuffer, msg + offset, *lpBytesReturned);
offset += *lpBytesReturned;
@@ -976,9 +985,10 @@ SCardTransmit(SCARDHANDLE hCard, const SCARD_IO_REQUEST *pioSendPci,
LLOGLN(0, ("SCardTransmit: error, not connected"));
return SCARD_F_INTERNAL_ERROR;
}
- LLOGLN(10, (" hCard 0x%8.8x", hCard));
- LLOGLN(10, (" cbSendLength %d", cbSendLength));
- LLOGLN(10, (" cbRecvLength %d", *pcbRecvLength));
+
+ LLOGLN(10, (" hCard 0x%8.8x", (int)hCard));
+ LLOGLN(10, (" cbSendLength %d", (int)cbSendLength));
+ LLOGLN(10, (" cbRecvLength %d", (int)*pcbRecvLength));
LLOGLN(10, (" pioSendPci->dwProtocol %d", (int)(pioSendPci->dwProtocol)));
LLOGLN(10, (" pioSendPci->cbPciLength %d", (int)(pioSendPci->cbPciLength)));
LLOGLN(10, (" pioRecvPci %p", pioRecvPci));
@@ -993,9 +1003,11 @@ SCardTransmit(SCARDHANDLE hCard, const SCARD_IO_REQUEST *pioSendPci,
offset += 4;
SET_UINT32(msg, offset, pioSendPci->dwProtocol);
offset += 4;
- SET_UINT32(msg, offset, pioSendPci->cbPciLength);
+/* SET_UINT32(msg, offset, pioSendPci->cbPciLength); */
+ SET_UINT32(msg, offset, 8);
offset += 4;
- extra_len = pioSendPci->cbPciLength - 8;
+/* extra_len = pioSendPci->cbPciLength - 8; */
+ extra_len = 0;
SET_UINT32(msg, offset, extra_len);
offset += 4;
memcpy(msg + offset, pioSendPci + 1, extra_len);
@@ -1070,7 +1082,7 @@ SCardTransmit(SCARDHANDLE hCard, const SCARD_IO_REQUEST *pioSendPci,
}
*pcbRecvLength = GET_UINT32(msg, offset);
offset += 4;
- LLOGLN(10, (" cbRecvLength %d", *pcbRecvLength));
+ LLOGLN(10, (" cbRecvLength %d", (int)*pcbRecvLength));
memcpy(pbRecvBuffer, msg + offset, *pcbRecvLength);
offset += *pcbRecvLength;
status = GET_UINT32(msg, offset);
@@ -1113,12 +1125,16 @@ SCardListReaders(SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders,
LLOGLN(10, ("SCardListReaders:"));
LLOGLN(10, ("SCardListReaders: mszGroups %s", mszGroups));
- LLOGLN(10, ("SCardListReaders: *pcchReaders %d", *pcchReaders));
+ LLOGLN(10, ("SCardListReaders: *pcchReaders %d", (int)*pcchReaders));
if (g_sck == -1)
{
LLOGLN(0, ("SCardListReaders: error, not connected"));
return SCARD_F_INTERNAL_ERROR;
}
+ if ((mszGroups == NULL) && (mszReaders == NULL))
+ {
+ *pcchReaders = 0;
+ }
msg = (char *) malloc(8192);
offset = 0;
SET_UINT32(msg, offset, hContext);