mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-14 16:07:20 +00:00
winscard: Implement SCardConnectA/W().
This commit is contained in:
parent
abb7f75002
commit
fd3ce00a22
|
@ -38,6 +38,7 @@ LONG SCardGetStatusChange( UINT64, UINT64, struct reader_state *, UINT64 );
|
|||
LONG SCardCancel( UINT64 );
|
||||
LONG SCardListReaders( UINT64, const char *, char *, UINT64 * );
|
||||
LONG SCardListReaderGroups( UINT64, char *, UINT64 * );
|
||||
LONG SCardConnect( UINT64, const char *, UINT64, UINT64, UINT64 *, UINT64 * );
|
||||
|
||||
static NTSTATUS scard_establish_context( void *args )
|
||||
{
|
||||
|
@ -81,6 +82,13 @@ static NTSTATUS scard_list_reader_groups( void *args )
|
|||
return SCardListReaderGroups( params->handle, params->groups, params->groups_len );
|
||||
}
|
||||
|
||||
static NTSTATUS scard_connect( void *args )
|
||||
{
|
||||
struct scard_connect_params *params = args;
|
||||
return SCardConnect( params->context_handle, params->reader, params->share_mode, params->preferred_protocols,
|
||||
params->connect_handle, params->protocol );
|
||||
}
|
||||
|
||||
const unixlib_entry_t __wine_unix_call_funcs[] =
|
||||
{
|
||||
scard_establish_context,
|
||||
|
@ -90,4 +98,5 @@ const unixlib_entry_t __wine_unix_call_funcs[] =
|
|||
scard_cancel,
|
||||
scard_list_readers,
|
||||
scard_list_reader_groups,
|
||||
scard_connect,
|
||||
};
|
||||
|
|
|
@ -74,6 +74,16 @@ struct scard_list_reader_groups_params
|
|||
UINT64 *groups_len;
|
||||
};
|
||||
|
||||
struct scard_connect_params
|
||||
{
|
||||
UINT64 context_handle;
|
||||
const char *reader;
|
||||
UINT64 share_mode;
|
||||
UINT64 preferred_protocols;
|
||||
UINT64 *connect_handle;
|
||||
UINT64 *protocol;
|
||||
};
|
||||
|
||||
enum winscard_funcs
|
||||
{
|
||||
unix_scard_establish_context,
|
||||
|
@ -83,4 +93,5 @@ enum winscard_funcs
|
|||
unix_scard_cancel,
|
||||
unix_scard_list_readers,
|
||||
unix_scard_list_reader_groups,
|
||||
unix_scard_connect,
|
||||
};
|
||||
|
|
|
@ -140,6 +140,7 @@ LONG WINAPI SCardAddReaderToGroupW(SCARDCONTEXT context, LPCWSTR reader, LPCWSTR
|
|||
}
|
||||
|
||||
#define CONTEXT_MAGIC (('C' << 24) | ('T' << 16) | ('X' << 8) | '0')
|
||||
#define CONNECT_MAGIC (('C' << 24) | ('O' << 16) | ('N' << 8) | '0')
|
||||
struct handle
|
||||
{
|
||||
DWORD magic;
|
||||
|
@ -551,6 +552,90 @@ LONG WINAPI SCardGetStatusChangeW( SCARDCONTEXT context, DWORD timeout, SCARD_RE
|
|||
return ret;
|
||||
}
|
||||
|
||||
LONG WINAPI SCardConnectA( SCARDCONTEXT context, const char *reader, DWORD share_mode, DWORD preferred_protocols,
|
||||
SCARDHANDLE *connect, DWORD *protocol )
|
||||
{
|
||||
struct handle *context_handle = (struct handle *)context, *connect_handle;
|
||||
struct scard_connect_params params;
|
||||
char *reader_utf8;
|
||||
UINT64 protocol64;
|
||||
LONG ret;
|
||||
|
||||
TRACE( "%Ix, %s, %#lx, %#lx, %p, %p\n", context, debugstr_a(reader), share_mode, preferred_protocols, connect,
|
||||
protocol );
|
||||
|
||||
if (!context_handle || context_handle->magic != CONTEXT_MAGIC) return ERROR_INVALID_HANDLE;
|
||||
if (!connect) return SCARD_E_INVALID_PARAMETER;
|
||||
|
||||
if (!(connect_handle = malloc( sizeof(*connect_handle) ))) return SCARD_E_NO_MEMORY;
|
||||
connect_handle->magic = CONNECT_MAGIC;
|
||||
|
||||
if (!(reader_utf8 = ansi_to_utf8( reader )))
|
||||
{
|
||||
free( connect_handle );
|
||||
return SCARD_E_NO_MEMORY;
|
||||
}
|
||||
|
||||
params.context_handle = context_handle->unix_handle;
|
||||
params.reader = reader_utf8;
|
||||
params.share_mode = share_mode;
|
||||
params.preferred_protocols = preferred_protocols;
|
||||
params.connect_handle = &connect_handle->unix_handle;
|
||||
params.protocol = &protocol64;
|
||||
if ((ret = UNIX_CALL( scard_connect, ¶ms ))) free( connect_handle );
|
||||
else
|
||||
{
|
||||
*connect = (SCARDHANDLE)connect_handle;
|
||||
if (protocol) *protocol = protocol64;
|
||||
}
|
||||
|
||||
free( reader_utf8 );
|
||||
TRACE( "returning %#lx\n", ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
LONG WINAPI SCardConnectW( SCARDCONTEXT context, const WCHAR *reader, DWORD share_mode, DWORD preferred_protocols,
|
||||
SCARDHANDLE *connect, DWORD *protocol )
|
||||
{
|
||||
struct handle *context_handle = (struct handle *)context, *connect_handle;
|
||||
struct scard_connect_params params;
|
||||
char *reader_utf8;
|
||||
UINT64 protocol64;
|
||||
LONG ret;
|
||||
|
||||
TRACE( "%Ix, %s, %#lx, %#lx, %p, %p\n", context, debugstr_w(reader), share_mode, preferred_protocols, connect,
|
||||
protocol );
|
||||
|
||||
if (!context_handle || context_handle->magic != CONTEXT_MAGIC) return ERROR_INVALID_HANDLE;
|
||||
if (!connect) return SCARD_E_INVALID_PARAMETER;
|
||||
|
||||
if (!(connect_handle = malloc( sizeof(*connect_handle) ))) return SCARD_E_NO_MEMORY;
|
||||
connect_handle->magic = CONNECT_MAGIC;
|
||||
|
||||
if (!(reader_utf8 = utf16_to_utf8( reader )))
|
||||
{
|
||||
free( connect_handle );
|
||||
return SCARD_E_NO_MEMORY;
|
||||
}
|
||||
|
||||
params.context_handle = context_handle->unix_handle;
|
||||
params.reader = reader_utf8;
|
||||
params.share_mode = share_mode;
|
||||
params.preferred_protocols = preferred_protocols;
|
||||
params.connect_handle = &connect_handle->unix_handle;
|
||||
params.protocol = &protocol64;
|
||||
if ((ret = UNIX_CALL( scard_connect, ¶ms ))) free( connect_handle );
|
||||
else
|
||||
{
|
||||
*connect = (SCARDHANDLE)connect_handle;
|
||||
if (protocol) *protocol = protocol64;
|
||||
}
|
||||
|
||||
free( reader_utf8 );
|
||||
TRACE( "returning %#lx\n", ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, void *reserved )
|
||||
{
|
||||
switch (reason)
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
@ stdcall SCardAddReaderToGroupW(long wstr wstr)
|
||||
@ stub SCardBeginTransaction
|
||||
@ stdcall SCardCancel(long)
|
||||
@ stub SCardConnectA
|
||||
@ stub SCardConnectW
|
||||
@ stdcall SCardConnectA(long str long long ptr ptr)
|
||||
@ stdcall SCardConnectW(long wstr long long ptr ptr)
|
||||
@ stub SCardControl
|
||||
@ stub SCardDisconnect
|
||||
@ stub SCardEndTransaction
|
||||
|
|
Loading…
Reference in a new issue