winscard: Implement SCardRe/Disconnect().

This commit is contained in:
Hans Leidekker 2023-02-16 12:43:43 +01:00 committed by Alexandre Julliard
parent 836974d4d8
commit ba2010a02a
4 changed files with 79 additions and 2 deletions

View file

@ -40,6 +40,8 @@ LONG SCardListReaders( UINT64, const char *, char *, UINT64 * );
LONG SCardListReaderGroups( UINT64, char *, UINT64 * );
LONG SCardConnect( UINT64, const char *, UINT64, UINT64, UINT64 *, UINT64 * );
LONG SCardStatus( UINT64, char *, UINT64 *, UINT64 *, UINT64 *, BYTE *, UINT64 * );
LONG SCardDisconnect( UINT64, UINT64 );
LONG SCardReconnect( UINT64, UINT64, UINT64, UINT64, UINT64 * );
static NTSTATUS scard_establish_context( void *args )
{
@ -97,6 +99,19 @@ static NTSTATUS scard_status( void *args )
params->atr, params->atr_len );
}
static NTSTATUS scard_reconnect( void *args )
{
struct scard_reconnect_params *params = args;
return SCardReconnect( params->handle, params->share_mode, params->preferred_protocols,
params->initialization, params->protocol );
}
static NTSTATUS scard_disconnect( void *args )
{
struct scard_disconnect_params *params = args;
return SCardDisconnect( params->handle, params->disposition );
}
const unixlib_entry_t __wine_unix_call_funcs[] =
{
scard_establish_context,
@ -108,4 +123,6 @@ const unixlib_entry_t __wine_unix_call_funcs[] =
scard_list_reader_groups,
scard_connect,
scard_status,
scard_reconnect,
scard_disconnect,
};

View file

@ -95,6 +95,21 @@ struct scard_status_params
UINT64 *atr_len;
};
struct scard_reconnect_params
{
UINT64 handle;
UINT64 share_mode;
UINT64 preferred_protocols;
UINT64 initialization;
UINT64 *protocol;
};
struct scard_disconnect_params
{
UINT64 handle;
UINT64 disposition;
};
enum winscard_funcs
{
unix_scard_establish_context,
@ -106,4 +121,6 @@ enum winscard_funcs
unix_scard_list_reader_groups,
unix_scard_connect,
unix_scard_status,
unix_scard_reconnect,
unix_scard_disconnect,
};

View file

@ -710,6 +710,49 @@ LONG WINAPI SCardConnectW( SCARDCONTEXT context, const WCHAR *reader, DWORD shar
return ret;
}
LONG WINAPI SCardReconnect( SCARDHANDLE connect, DWORD share_mode, DWORD preferred_protocols, DWORD initalization,
DWORD *protocol )
{
struct handle *handle = (struct handle *)connect;
struct scard_reconnect_params params;
UINT64 protocol64;
LONG ret;
TRACE( "%Ix, %#lx, %#lx, %#lx, %p\n", connect, share_mode, preferred_protocols, initalization, protocol );
if (!handle || handle->magic != CONNECT_MAGIC) return ERROR_INVALID_HANDLE;
params.handle = handle->unix_handle;
params.share_mode = share_mode;
params.preferred_protocols = preferred_protocols;
params.initialization = initalization;
params.protocol = &protocol64;
if (!(ret = UNIX_CALL( scard_reconnect, &params )) && protocol) *protocol = protocol64;
TRACE( "returning %#lx\n", ret );
return ret;
}
LONG WINAPI SCardDisconnect( SCARDHANDLE connect, DWORD disposition )
{
struct handle *handle = (struct handle *)connect;
struct scard_disconnect_params params;
LONG ret;
TRACE( "%Ix, %#lx\n", connect, disposition );
if (!handle || handle->magic != CONNECT_MAGIC) return ERROR_INVALID_HANDLE;
params.handle = handle->unix_handle;
params.disposition = disposition;
if (!(ret = UNIX_CALL( scard_disconnect, &params )))
{
handle->magic = 0;
free( handle );
}
TRACE( "returning %#lx\n", ret );
return ret;
}
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, void *reserved )
{
switch (reason)

View file

@ -10,7 +10,7 @@
@ stdcall SCardConnectA(long str long long ptr ptr)
@ stdcall SCardConnectW(long wstr long long ptr ptr)
@ stub SCardControl
@ stub SCardDisconnect
@ stdcall SCardDisconnect(long long)
@ stub SCardEndTransaction
@ stdcall SCardEstablishContext(long ptr ptr ptr)
@ stub SCardForgetCardTypeA
@ -46,7 +46,7 @@
@ stub SCardLocateCardsByATRA
@ stub SCardLocateCardsByATRW
@ stub SCardLocateCardsW
@ stub SCardReconnect
@ stdcall SCardReconnect(long long long long ptr)
@ stdcall SCardReleaseContext(long)
@ stdcall SCardReleaseStartedEvent()
@ stub SCardRemoveReaderFromGroupA