channels/smartcard: cleanup and simplify ListReaders call
This commit is contained in:
parent
2b52c294a2
commit
dd5fab82b5
@ -93,9 +93,6 @@ struct _SMARTCARD_DEVICE
|
|||||||
HANDLE thread;
|
HANDLE thread;
|
||||||
wMessageQueue* IrpQueue;
|
wMessageQueue* IrpQueue;
|
||||||
wListDictionary* OutstandingIrps;
|
wListDictionary* OutstandingIrps;
|
||||||
|
|
||||||
SCARDCONTEXT hContext;
|
|
||||||
SCARDHANDLE hCard;
|
|
||||||
};
|
};
|
||||||
typedef struct _SMARTCARD_DEVICE SMARTCARD_DEVICE;
|
typedef struct _SMARTCARD_DEVICE SMARTCARD_DEVICE;
|
||||||
|
|
||||||
|
@ -185,8 +185,6 @@ static UINT32 smartcard_EstablishContext(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
|||||||
|
|
||||||
status = ret.ReturnCode = SCardEstablishContext(call.dwScope, NULL, NULL, &hContext);
|
status = ret.ReturnCode = SCardEstablishContext(call.dwScope, NULL, NULL, &hContext);
|
||||||
|
|
||||||
smartcard->hContext = hContext;
|
|
||||||
|
|
||||||
ret.Context.cbContext = sizeof(ULONG_PTR);
|
ret.Context.cbContext = sizeof(ULONG_PTR);
|
||||||
ret.Context.pbContext = (UINT64) hContext;
|
ret.Context.pbContext = (UINT64) hContext;
|
||||||
|
|
||||||
@ -214,8 +212,6 @@ static UINT32 smartcard_ReleaseContext(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
|||||||
|
|
||||||
status = ret.ReturnCode = SCardReleaseContext(hContext);
|
status = ret.ReturnCode = SCardReleaseContext(hContext);
|
||||||
|
|
||||||
smartcard->hContext = 0;
|
|
||||||
|
|
||||||
return ret.ReturnCode;
|
return ret.ReturnCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,10 +321,7 @@ static UINT32 smartcard_GetStatusChangeA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
|||||||
SCARDCONTEXT hContext;
|
SCARDCONTEXT hContext;
|
||||||
GetStatusChangeA_Call call;
|
GetStatusChangeA_Call call;
|
||||||
GetStatusChange_Return ret;
|
GetStatusChange_Return ret;
|
||||||
ReaderStateA* readerState = NULL;
|
|
||||||
ReaderState_Return* readerStateRet = NULL;
|
|
||||||
LPSCARD_READERSTATEA rgReaderState = NULL;
|
LPSCARD_READERSTATEA rgReaderState = NULL;
|
||||||
LPSCARD_READERSTATEA rgReaderStates = NULL;
|
|
||||||
|
|
||||||
status = smartcard_unpack_get_status_change_a_call(smartcard, irp->input, &call);
|
status = smartcard_unpack_get_status_change_a_call(smartcard, irp->input, &call);
|
||||||
|
|
||||||
@ -337,19 +330,7 @@ static UINT32 smartcard_GetStatusChangeA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
|||||||
|
|
||||||
hContext = (ULONG_PTR) call.Context.pbContext;
|
hContext = (ULONG_PTR) call.Context.pbContext;
|
||||||
|
|
||||||
rgReaderStates = (SCARD_READERSTATEA*) calloc(call.cReaders, sizeof(SCARD_READERSTATEA));
|
status = ret.ReturnCode = SCardGetStatusChangeA(hContext, call.dwTimeOut, call.rgReaderStates, call.cReaders);
|
||||||
|
|
||||||
for (index = 0; index < call.cReaders; index++)
|
|
||||||
{
|
|
||||||
rgReaderState = &rgReaderStates[index];
|
|
||||||
rgReaderState->szReader = (LPCSTR) call.rgReaderStates[index].szReader;
|
|
||||||
rgReaderState->dwCurrentState = call.rgReaderStates[index].Common.dwCurrentState;
|
|
||||||
rgReaderState->dwEventState = call.rgReaderStates[index].Common.dwEventState;
|
|
||||||
rgReaderState->cbAtr = call.rgReaderStates[index].Common.cbAtr;
|
|
||||||
CopyMemory(&(rgReaderState->rgbAtr), &(call.rgReaderStates[index].Common.rgbAtr), 36);
|
|
||||||
}
|
|
||||||
|
|
||||||
status = ret.ReturnCode = SCardGetStatusChangeA(hContext, call.dwTimeOut, rgReaderStates, call.cReaders);
|
|
||||||
|
|
||||||
if (status && (status != SCARD_E_TIMEOUT))
|
if (status && (status != SCARD_E_TIMEOUT))
|
||||||
return status;
|
return status;
|
||||||
@ -359,12 +340,10 @@ static UINT32 smartcard_GetStatusChangeA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
|||||||
|
|
||||||
for (index = 0; index < ret.cReaders; index++)
|
for (index = 0; index < ret.cReaders; index++)
|
||||||
{
|
{
|
||||||
rgReaderState = &rgReaderStates[index];
|
ret.rgReaderStates[index].dwCurrentState = call.rgReaderStates[index].dwCurrentState;
|
||||||
readerStateRet = &ret.rgReaderStates[index];
|
ret.rgReaderStates[index].dwEventState = call.rgReaderStates[index].dwEventState;
|
||||||
readerStateRet->dwCurrentState = rgReaderState->dwCurrentState;
|
ret.rgReaderStates[index].cbAtr = call.rgReaderStates[index].cbAtr;
|
||||||
readerStateRet->dwEventState = rgReaderState->dwEventState;
|
CopyMemory(&ret.rgReaderStates[index].rgbAtr, &call.rgReaderStates[index].rgbAtr, 32);
|
||||||
readerStateRet->cbAtr = rgReaderState->cbAtr;
|
|
||||||
CopyMemory(readerStateRet->rgbAtr, rgReaderState->rgbAtr, 36);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
status = smartcard_pack_get_status_change_return(smartcard, irp->output, &ret);
|
status = smartcard_pack_get_status_change_return(smartcard, irp->output, &ret);
|
||||||
@ -376,14 +355,12 @@ static UINT32 smartcard_GetStatusChangeA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
|||||||
{
|
{
|
||||||
for (index = 0; index < call.cReaders; index++)
|
for (index = 0; index < call.cReaders; index++)
|
||||||
{
|
{
|
||||||
readerState = &call.rgReaderStates[index];
|
rgReaderState = &call.rgReaderStates[index];
|
||||||
|
|
||||||
if (readerState->szReader)
|
if (rgReaderState->szReader)
|
||||||
free((void*) readerState->szReader);
|
free((void*) rgReaderState->szReader);
|
||||||
readerState->szReader = NULL;
|
|
||||||
}
|
}
|
||||||
free(call.rgReaderStates);
|
free(call.rgReaderStates);
|
||||||
free(rgReaderStates);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(ret.rgReaderStates);
|
free(ret.rgReaderStates);
|
||||||
@ -398,10 +375,7 @@ static UINT32 smartcard_GetStatusChangeW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
|||||||
SCARDCONTEXT hContext;
|
SCARDCONTEXT hContext;
|
||||||
GetStatusChangeW_Call call;
|
GetStatusChangeW_Call call;
|
||||||
GetStatusChange_Return ret;
|
GetStatusChange_Return ret;
|
||||||
ReaderStateW* readerState = NULL;
|
|
||||||
ReaderState_Return* readerStateRet = NULL;
|
|
||||||
LPSCARD_READERSTATEW rgReaderState = NULL;
|
LPSCARD_READERSTATEW rgReaderState = NULL;
|
||||||
LPSCARD_READERSTATEW rgReaderStates = NULL;
|
|
||||||
|
|
||||||
status = smartcard_unpack_get_status_change_w_call(smartcard, irp->input, &call);
|
status = smartcard_unpack_get_status_change_w_call(smartcard, irp->input, &call);
|
||||||
|
|
||||||
@ -410,19 +384,7 @@ static UINT32 smartcard_GetStatusChangeW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
|||||||
|
|
||||||
hContext = (ULONG_PTR) call.Context.pbContext;
|
hContext = (ULONG_PTR) call.Context.pbContext;
|
||||||
|
|
||||||
rgReaderStates = (SCARD_READERSTATEW*) calloc(call.cReaders, sizeof(SCARD_READERSTATEW));
|
status = ret.ReturnCode = SCardGetStatusChangeW(hContext, call.dwTimeOut, call.rgReaderStates, call.cReaders);
|
||||||
|
|
||||||
for (index = 0; index < call.cReaders; index++)
|
|
||||||
{
|
|
||||||
rgReaderState = &rgReaderStates[index];
|
|
||||||
rgReaderState->szReader = (LPCWSTR) call.rgReaderStates[index].szReader;
|
|
||||||
rgReaderState->dwCurrentState = call.rgReaderStates[index].Common.dwCurrentState;
|
|
||||||
rgReaderState->dwEventState = call.rgReaderStates[index].Common.dwEventState;
|
|
||||||
rgReaderState->cbAtr = call.rgReaderStates[index].Common.cbAtr;
|
|
||||||
CopyMemory(&(rgReaderState->rgbAtr), &(call.rgReaderStates[index].Common.rgbAtr), 36);
|
|
||||||
}
|
|
||||||
|
|
||||||
status = ret.ReturnCode = SCardGetStatusChangeW(hContext, call.dwTimeOut, rgReaderStates, call.cReaders);
|
|
||||||
|
|
||||||
if (status && (status != SCARD_E_TIMEOUT))
|
if (status && (status != SCARD_E_TIMEOUT))
|
||||||
return status;
|
return status;
|
||||||
@ -432,12 +394,10 @@ static UINT32 smartcard_GetStatusChangeW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
|||||||
|
|
||||||
for (index = 0; index < ret.cReaders; index++)
|
for (index = 0; index < ret.cReaders; index++)
|
||||||
{
|
{
|
||||||
rgReaderState = &rgReaderStates[index];
|
ret.rgReaderStates[index].dwCurrentState = call.rgReaderStates[index].dwCurrentState;
|
||||||
readerStateRet = &ret.rgReaderStates[index];
|
ret.rgReaderStates[index].dwEventState = call.rgReaderStates[index].dwEventState;
|
||||||
readerStateRet->dwCurrentState = rgReaderState->dwCurrentState;
|
ret.rgReaderStates[index].cbAtr = call.rgReaderStates[index].cbAtr;
|
||||||
readerStateRet->dwEventState = rgReaderState->dwEventState;
|
CopyMemory(&ret.rgReaderStates[index].rgbAtr, &call.rgReaderStates[index].rgbAtr, 32);
|
||||||
readerStateRet->cbAtr = rgReaderState->cbAtr;
|
|
||||||
CopyMemory(readerStateRet->rgbAtr, rgReaderState->rgbAtr, 36);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
status = smartcard_pack_get_status_change_return(smartcard, irp->output, &ret);
|
status = smartcard_pack_get_status_change_return(smartcard, irp->output, &ret);
|
||||||
@ -449,14 +409,12 @@ static UINT32 smartcard_GetStatusChangeW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
|||||||
{
|
{
|
||||||
for (index = 0; index < call.cReaders; index++)
|
for (index = 0; index < call.cReaders; index++)
|
||||||
{
|
{
|
||||||
readerState = &call.rgReaderStates[index];
|
rgReaderState = &call.rgReaderStates[index];
|
||||||
|
|
||||||
if (readerState->szReader)
|
if (rgReaderState->szReader)
|
||||||
free((void*) readerState->szReader);
|
free((void*) rgReaderState->szReader);
|
||||||
readerState->szReader = NULL;
|
|
||||||
}
|
}
|
||||||
free(call.rgReaderStates);
|
free(call.rgReaderStates);
|
||||||
free(rgReaderStates);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(ret.rgReaderStates);
|
free(ret.rgReaderStates);
|
||||||
@ -512,8 +470,6 @@ UINT32 smartcard_ConnectA(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
|||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
smartcard->hCard = hCard;
|
|
||||||
|
|
||||||
ret.hCard.Context.cbContext = sizeof(ULONG_PTR);
|
ret.hCard.Context.cbContext = sizeof(ULONG_PTR);
|
||||||
ret.hCard.Context.pbContext = (UINT64) hContext;
|
ret.hCard.Context.pbContext = (UINT64) hContext;
|
||||||
|
|
||||||
@ -560,8 +516,6 @@ UINT32 smartcard_ConnectW(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
|||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
smartcard->hCard = hCard;
|
|
||||||
|
|
||||||
ret.hCard.Context.cbContext = sizeof(ULONG_PTR);
|
ret.hCard.Context.cbContext = sizeof(ULONG_PTR);
|
||||||
ret.hCard.Context.pbContext = (UINT64) hContext;
|
ret.hCard.Context.pbContext = (UINT64) hContext;
|
||||||
|
|
||||||
@ -630,8 +584,6 @@ static UINT32 smartcard_Disconnect(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
|||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
smartcard->hCard = 0;
|
|
||||||
|
|
||||||
return ret.ReturnCode;
|
return ret.ReturnCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -715,12 +715,14 @@ UINT32 smartcard_unpack_hcard_and_disposition_call(SMARTCARD_DEVICE* smartcard,
|
|||||||
|
|
||||||
UINT32 smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wStream* s, GetStatusChangeA_Call* call)
|
UINT32 smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wStream* s, GetStatusChangeA_Call* call)
|
||||||
{
|
{
|
||||||
int index;
|
UINT32 index;
|
||||||
UINT32 count;
|
UINT32 count;
|
||||||
UINT32 status;
|
UINT32 status;
|
||||||
|
UINT32 offset;
|
||||||
|
UINT32 maxCount;
|
||||||
UINT32 szReaderNdrPtr;
|
UINT32 szReaderNdrPtr;
|
||||||
ReaderStateA* readerState;
|
|
||||||
UINT32 rgReaderStatesNdrPtr;
|
UINT32 rgReaderStatesNdrPtr;
|
||||||
|
LPSCARD_READERSTATEA readerState;
|
||||||
|
|
||||||
call->rgReaderStates = NULL;
|
call->rgReaderStates = NULL;
|
||||||
|
|
||||||
@ -764,7 +766,7 @@ UINT32 smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wS
|
|||||||
|
|
||||||
if (call->cReaders > 0)
|
if (call->cReaders > 0)
|
||||||
{
|
{
|
||||||
call->rgReaderStates = (ReaderStateA*) calloc(call->cReaders, sizeof(ReaderStateA));
|
call->rgReaderStates = (LPSCARD_READERSTATEA) calloc(call->cReaders, sizeof(SCARD_READERSTATEA));
|
||||||
|
|
||||||
for (index = 0; index < call->cReaders; index++)
|
for (index = 0; index < call->cReaders; index++)
|
||||||
{
|
{
|
||||||
@ -778,11 +780,11 @@ UINT32 smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wS
|
|||||||
}
|
}
|
||||||
|
|
||||||
Stream_Read_UINT32(s, szReaderNdrPtr); /* szReaderNdrPtr (4 bytes) */
|
Stream_Read_UINT32(s, szReaderNdrPtr); /* szReaderNdrPtr (4 bytes) */
|
||||||
Stream_Read_UINT32(s, readerState->Common.dwCurrentState); /* dwCurrentState (4 bytes) */
|
Stream_Read_UINT32(s, readerState->dwCurrentState); /* dwCurrentState (4 bytes) */
|
||||||
Stream_Read_UINT32(s, readerState->Common.dwEventState); /* dwEventState (4 bytes) */
|
Stream_Read_UINT32(s, readerState->dwEventState); /* dwEventState (4 bytes) */
|
||||||
Stream_Read_UINT32(s, readerState->Common.cbAtr); /* cbAtr (4 bytes) */
|
Stream_Read_UINT32(s, readerState->cbAtr); /* cbAtr (4 bytes) */
|
||||||
Stream_Read(s, readerState->Common.rgbAtr, 32); /* rgbAtr [0..32] (32 bytes) */
|
Stream_Read(s, readerState->rgbAtr, 32); /* rgbAtr [0..32] (32 bytes) */
|
||||||
Stream_Seek_UINT32(s); /* rgbAtr [32..36] (4 bytes) */
|
Stream_Seek(s, 4); /* rgbAtr [32..36] (4 bytes) */
|
||||||
}
|
}
|
||||||
|
|
||||||
for (index = 0; index < call->cReaders; index++)
|
for (index = 0; index < call->cReaders; index++)
|
||||||
@ -796,8 +798,8 @@ UINT32 smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wS
|
|||||||
return STATUS_BUFFER_TOO_SMALL;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream_Seek_UINT32(s); /* NdrMaxCount (4 bytes) */
|
Stream_Read_UINT32(s, maxCount); /* NdrMaxCount (4 bytes) */
|
||||||
Stream_Seek_UINT32(s); /* NdrOffset (4 bytes) */
|
Stream_Read_UINT32(s, offset); /* NdrOffset (4 bytes) */
|
||||||
Stream_Read_UINT32(s, count); /* NdrActualCount (4 bytes) */
|
Stream_Read_UINT32(s, count); /* NdrActualCount (4 bytes) */
|
||||||
|
|
||||||
if (Stream_GetRemainingLength(s) < count)
|
if (Stream_GetRemainingLength(s) < count)
|
||||||
@ -807,10 +809,10 @@ UINT32 smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wS
|
|||||||
return STATUS_BUFFER_TOO_SMALL;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
readerState->szReader = (unsigned char*) malloc(count + 1);
|
readerState->szReader = (LPCSTR) malloc(count + 1);
|
||||||
Stream_Read(s, readerState->szReader, count);
|
Stream_Read(s, (void*) readerState->szReader, count);
|
||||||
smartcard_unpack_read_size_align(smartcard, s, count, 4);
|
smartcard_unpack_read_size_align(smartcard, s, count, 4);
|
||||||
readerState->szReader[count] = '\0';
|
((char*) readerState->szReader)[count] = '\0';
|
||||||
|
|
||||||
if (!readerState->szReader)
|
if (!readerState->szReader)
|
||||||
{
|
{
|
||||||
@ -820,7 +822,7 @@ UINT32 smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wS
|
|||||||
|
|
||||||
if (strcmp((char*) readerState->szReader, SMARTCARD_PNP_NOTIFICATION_A) == 0)
|
if (strcmp((char*) readerState->szReader, SMARTCARD_PNP_NOTIFICATION_A) == 0)
|
||||||
{
|
{
|
||||||
readerState->Common.dwCurrentState |= SCARD_STATE_IGNORE;
|
readerState->dwCurrentState |= SCARD_STATE_IGNORE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -830,11 +832,14 @@ UINT32 smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wS
|
|||||||
|
|
||||||
UINT32 smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wStream* s, GetStatusChangeW_Call* call)
|
UINT32 smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wStream* s, GetStatusChangeW_Call* call)
|
||||||
{
|
{
|
||||||
int index;
|
UINT32 index;
|
||||||
UINT32 count;
|
UINT32 count;
|
||||||
UINT32 status;
|
UINT32 status;
|
||||||
ReaderStateW* readerState;
|
UINT32 offset;
|
||||||
|
UINT32 maxCount;
|
||||||
|
UINT32 szReaderNdrPtr;
|
||||||
UINT32 rgReaderStatesNdrPtr;
|
UINT32 rgReaderStatesNdrPtr;
|
||||||
|
LPSCARD_READERSTATEW readerState;
|
||||||
|
|
||||||
call->rgReaderStates = NULL;
|
call->rgReaderStates = NULL;
|
||||||
|
|
||||||
@ -870,7 +875,7 @@ UINT32 smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wS
|
|||||||
|
|
||||||
if (call->cReaders > 0)
|
if (call->cReaders > 0)
|
||||||
{
|
{
|
||||||
call->rgReaderStates = (ReaderStateW*) calloc(call->cReaders, sizeof(ReaderStateW));
|
call->rgReaderStates = (LPSCARD_READERSTATEW) calloc(call->cReaders, sizeof(SCARD_READERSTATEW));
|
||||||
|
|
||||||
for (index = 0; index < call->cReaders; index++)
|
for (index = 0; index < call->cReaders; index++)
|
||||||
{
|
{
|
||||||
@ -883,12 +888,12 @@ UINT32 smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wS
|
|||||||
return STATUS_BUFFER_TOO_SMALL;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream_Seek_UINT32(s); /* (4 bytes) */
|
Stream_Read_UINT32(s, szReaderNdrPtr); /* (4 bytes) */
|
||||||
Stream_Read_UINT32(s, readerState->Common.dwCurrentState); /* dwCurrentState (4 bytes) */
|
Stream_Read_UINT32(s, readerState->dwCurrentState); /* dwCurrentState (4 bytes) */
|
||||||
Stream_Read_UINT32(s, readerState->Common.dwEventState); /* dwEventState (4 bytes) */
|
Stream_Read_UINT32(s, readerState->dwEventState); /* dwEventState (4 bytes) */
|
||||||
Stream_Read_UINT32(s, readerState->Common.cbAtr); /* cbAtr (4 bytes) */
|
Stream_Read_UINT32(s, readerState->cbAtr); /* cbAtr (4 bytes) */
|
||||||
Stream_Read(s, readerState->Common.rgbAtr, 32); /* rgbAtr [0..32] (32 bytes) */
|
Stream_Read(s, readerState->rgbAtr, 32); /* rgbAtr [0..32] (32 bytes) */
|
||||||
Stream_Seek_UINT32(s); /* rgbAtr [32..36] (4 bytes) */
|
Stream_Seek(s, 4); /* rgbAtr [32..36] (4 bytes) */
|
||||||
}
|
}
|
||||||
|
|
||||||
for (index = 0; index < call->cReaders; index++)
|
for (index = 0; index < call->cReaders; index++)
|
||||||
@ -902,8 +907,8 @@ UINT32 smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wS
|
|||||||
return STATUS_BUFFER_TOO_SMALL;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream_Seek_UINT32(s); /* NdrMaxCount (4 bytes) */
|
Stream_Read_UINT32(s, maxCount); /* NdrMaxCount (4 bytes) */
|
||||||
Stream_Seek_UINT32(s); /* NdrOffset (4 bytes) */
|
Stream_Read_UINT32(s, offset); /* NdrOffset (4 bytes) */
|
||||||
Stream_Read_UINT32(s, count); /* NdrActualCount (4 bytes) */
|
Stream_Read_UINT32(s, count); /* NdrActualCount (4 bytes) */
|
||||||
|
|
||||||
if (Stream_GetRemainingLength(s) < (count * 2))
|
if (Stream_GetRemainingLength(s) < (count * 2))
|
||||||
@ -914,9 +919,9 @@ UINT32 smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wS
|
|||||||
}
|
}
|
||||||
|
|
||||||
readerState->szReader = (WCHAR*) malloc((count + 1) * 2);
|
readerState->szReader = (WCHAR*) malloc((count + 1) * 2);
|
||||||
Stream_Read(s, readerState->szReader, (count * 2));
|
Stream_Read(s, (void*) readerState->szReader, (count * 2));
|
||||||
smartcard_unpack_read_size_align(smartcard, s, (count * 2), 4);
|
smartcard_unpack_read_size_align(smartcard, s, (count * 2), 4);
|
||||||
readerState->szReader[count] = '\0';
|
((WCHAR*) readerState->szReader)[count] = '\0';
|
||||||
|
|
||||||
if (!readerState->szReader)
|
if (!readerState->szReader)
|
||||||
{
|
{
|
||||||
@ -926,7 +931,7 @@ UINT32 smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wS
|
|||||||
|
|
||||||
if (_wcscmp((WCHAR*) readerState->szReader, SMARTCARD_PNP_NOTIFICATION_W) == 0)
|
if (_wcscmp((WCHAR*) readerState->szReader, SMARTCARD_PNP_NOTIFICATION_W) == 0)
|
||||||
{
|
{
|
||||||
readerState->Common.dwCurrentState |= SCARD_STATE_IGNORE;
|
readerState->dwCurrentState |= SCARD_STATE_IGNORE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -936,7 +941,7 @@ UINT32 smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wS
|
|||||||
|
|
||||||
UINT32 smartcard_pack_get_status_change_return(SMARTCARD_DEVICE* smartcard, wStream* s, GetStatusChange_Return* ret)
|
UINT32 smartcard_pack_get_status_change_return(SMARTCARD_DEVICE* smartcard, wStream* s, GetStatusChange_Return* ret)
|
||||||
{
|
{
|
||||||
int index;
|
UINT32 index;
|
||||||
ReaderState_Return* rgReaderState;
|
ReaderState_Return* rgReaderState;
|
||||||
|
|
||||||
Stream_Write_UINT32(s, ret->cReaders); /* cReaders (4 bytes) */
|
Stream_Write_UINT32(s, ret->cReaders); /* cReaders (4 bytes) */
|
||||||
@ -950,7 +955,7 @@ UINT32 smartcard_pack_get_status_change_return(SMARTCARD_DEVICE* smartcard, wStr
|
|||||||
Stream_Write_UINT32(s, rgReaderState->dwEventState); /* dwEventState (4 bytes) */
|
Stream_Write_UINT32(s, rgReaderState->dwEventState); /* dwEventState (4 bytes) */
|
||||||
Stream_Write_UINT32(s, rgReaderState->cbAtr); /* cbAtr (4 bytes) */
|
Stream_Write_UINT32(s, rgReaderState->cbAtr); /* cbAtr (4 bytes) */
|
||||||
Stream_Write(s, rgReaderState->rgbAtr, 32); /* rgbAtr [0..32] (32 bytes) */
|
Stream_Write(s, rgReaderState->rgbAtr, 32); /* rgbAtr [0..32] (32 bytes) */
|
||||||
Stream_Zero(s, 4); /* rgbAtr [32..36] (4 bytes) */
|
Stream_Zero(s, 4); /* rgbAtr [32..36] (32 bytes) */
|
||||||
}
|
}
|
||||||
|
|
||||||
return SCARD_S_SUCCESS;
|
return SCARD_S_SUCCESS;
|
||||||
@ -991,6 +996,7 @@ UINT32 smartcard_pack_state_return(SMARTCARD_DEVICE* smartcard, wStream* s, Stat
|
|||||||
Stream_Write_UINT32(s, 0x00020020); /* rgAtrNdrPtr (4 bytes) */
|
Stream_Write_UINT32(s, 0x00020020); /* rgAtrNdrPtr (4 bytes) */
|
||||||
Stream_Write_UINT32(s, ret->cbAtrLen); /* rgAtrLength (4 bytes) */
|
Stream_Write_UINT32(s, ret->cbAtrLen); /* rgAtrLength (4 bytes) */
|
||||||
Stream_Write(s, ret->rgAtr, ret->cbAtrLen); /* rgAtr */
|
Stream_Write(s, ret->rgAtr, ret->cbAtrLen); /* rgAtr */
|
||||||
|
|
||||||
smartcard_pack_write_size_align(smartcard, s, ret->cbAtrLen, 4);
|
smartcard_pack_write_size_align(smartcard, s, ret->cbAtrLen, 4);
|
||||||
|
|
||||||
return SCARD_S_SUCCESS;
|
return SCARD_S_SUCCESS;
|
||||||
|
@ -147,7 +147,7 @@ typedef struct _GetStatusChangeA_Call
|
|||||||
REDIR_SCARDCONTEXT Context;
|
REDIR_SCARDCONTEXT Context;
|
||||||
DWORD dwTimeOut;
|
DWORD dwTimeOut;
|
||||||
/* [range] */ DWORD cReaders;
|
/* [range] */ DWORD cReaders;
|
||||||
/* [size_is] */ ReaderStateA *rgReaderStates;
|
/* [size_is] */ LPSCARD_READERSTATEA rgReaderStates;
|
||||||
} GetStatusChangeA_Call;
|
} GetStatusChangeA_Call;
|
||||||
|
|
||||||
typedef struct _LocateCardsA_Call
|
typedef struct _LocateCardsA_Call
|
||||||
@ -207,7 +207,7 @@ typedef struct _GetStatusChangeW_Call
|
|||||||
REDIR_SCARDCONTEXT Context;
|
REDIR_SCARDCONTEXT Context;
|
||||||
DWORD dwTimeOut;
|
DWORD dwTimeOut;
|
||||||
/* [range] */ DWORD cReaders;
|
/* [range] */ DWORD cReaders;
|
||||||
/* [size_is] */ ReaderStateW *rgReaderStates;
|
/* [size_is] */ LPSCARD_READERSTATEW rgReaderStates;
|
||||||
} GetStatusChangeW_Call;
|
} GetStatusChangeW_Call;
|
||||||
|
|
||||||
typedef struct _Connect_Common
|
typedef struct _Connect_Common
|
||||||
|
Loading…
Reference in New Issue
Block a user