sdkcreationmw/sdkruntimes/scard/src/Winscard.cpp
author rajpuroh
Mon, 08 Mar 2010 12:09:11 +0530
changeset 0 b26acd06ea60
permissions -rw-r--r--
First Contribution of SDK components
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     1
/*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     2
* Copyright (c) 2003-2005 Nokia Corporation and/or its subsidiary(-ies).
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     3
* All rights reserved.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     4
* This component and the accompanying materials are made available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     6
* which accompanies this distribution, and is available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     8
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     9
* Initial Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    11
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    12
* Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    13
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    14
* Description: 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    15
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    16
*/
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    17
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    18
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    19
#define g_rgSCardT0Pci  _g_rgSCardT0Pci
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    20
#define g_rgSCardT1Pci  _g_rgSCardT1Pci
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    21
#define g_rgSCardRawPci _g_rgSCardRawPci
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    22
#define WINSCARDDATA
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    23
#define WINSCARDAPI
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    24
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    25
#define TRACE_PREFIX "SCARD: [WinsCard] "
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    26
#include "SdkCardDebug.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    27
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    28
#include <windows.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    29
#include <winioctl.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    30
#undef FILE_DEVICE_SMARTCARD /* redefined in <winscard.h> */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    31
#include <winscard.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    32
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    33
#undef g_rgSCardT0Pci
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    34
#undef g_rgSCardT1Pci
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    35
#undef g_rgSCardRawPci
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    36
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    37
/**
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    38
 * We can't use TRACE macros here because some of these functions may be
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    39
 * called from within Emulator::Escape()/Reenter() block.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    40
 */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    41
#ifdef _REALLY_DEBUG
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    42
#  define WINSCARD_TRACE(s) OutputDebugStringA(TRACE_PREFIX s "\n")
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    43
#else 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    44
#  define WINSCARD_TRACE(s)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    45
#endif // _REALLY_DEBUG
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    46
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    47
/* *************************************************************************
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    48
 *  Support for WINSCARD.DLL
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    49
 *  This code will run on the systems that don't have WINSCARD.DLL installed
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    50
 * *************************************************************************/
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    51
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    52
/* handle to WINSCARD.DLL */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    53
static HMODULE WINSCARD_handle = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    54
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    55
/*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    56
 * This flag is set to TRUE if we determine that WINSCARD.DLL is missing
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    57
 * or unusable (i.e. some required exports are missing), so that we don't 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    58
 * try to load it more than once.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    59
 */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    60
static BOOL WINSCARD_missing = FALSE; 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    61
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    62
static LPCSTR WINSCARD_DLL = "WINSCARD.DLL";
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    63
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    64
/* 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    65
 * these are entry points used by this module. These are NOT all entry
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    66
 * points exported by WINSCARD.DLL, just those we need here
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    67
 */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    68
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    69
/* SCardConnectW */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    70
#define WINSCARD_PROC_CONNECT_W  "SCardConnectW"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    71
#define WINSCARD_PROC_CONNECT WINSCARD_PROC_CONNECT_W
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    72
#define WINSCARD_CONNECT WINSCARD_CONNECT_W
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    73
#define WINSCARD_Connect WINSCARD_ConnectW
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    74
typedef LONG (WINAPI * WINSCARD_CONNECT_W)(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    75
    IN      SCARDCONTEXT hContext,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    76
    IN      LPCWSTR szReader,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    77
    IN      DWORD dwShareMode,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    78
    IN      DWORD dwPreferredProtocols,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    79
    OUT     LPSCARDHANDLE phCard,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    80
    OUT     LPDWORD pdwActiveProtocol);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    81
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    82
/* SCardDisconnect */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    83
#define WINSCARD_PROC_DISCONNECT "SCardDisconnect"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    84
typedef LONG (WINAPI * WINSCARD_DISCONNECT)(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    85
    IN      SCARDHANDLE hCard,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    86
    IN      DWORD dwDisposition);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    87
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    88
/* SCardEstablishContext */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    89
#define WINSCARD_PROC_ESTABLISH_CONTEXT "SCardEstablishContext"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    90
typedef LONG (WINAPI * WINSCARD_ESTABLISH_CONTEXT)(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    91
    IN  DWORD dwScope,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    92
    IN  LPCVOID pvReserved1,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    93
    IN  LPCVOID pvReserved2,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    94
    OUT LPSCARDCONTEXT phContext);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    95
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    96
/* SCardListReadersW */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    97
#define WINSCARD_PROC_LIST_READERS_W "SCardListReadersW"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    98
#define WINSCARD_PROC_LIST_READERS WINSCARD_PROC_LIST_READERS_W
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    99
#define WINSCARD_LIST_READERS WINSCARD_LIST_READERS_W
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   100
#define WINSCARD_ListReaders WINSCARD_ListReadersW
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   101
typedef LONG (WINAPI * WINSCARD_LIST_READERS_W)(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   102
    IN      SCARDCONTEXT hContext,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   103
    IN      LPCWSTR mszGroups,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   104
    OUT     LPWSTR mszReaders,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   105
    IN OUT  LPDWORD pcchReaders);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   106
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   107
/* SCardReleaseContext */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   108
#define WINSCARD_PROC_RELEASE_CONTEXT "SCardReleaseContext"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   109
typedef LONG (WINAPI * WINSCARD_RELEASE_CONTEXT)(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   110
    IN      SCARDCONTEXT hContext);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   111
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   112
/* SCardTransmit */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   113
#define WINSCARD_PROC_TRANSMIT "SCardTransmit"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   114
typedef LONG (WINAPI * WINSCARD_TRANSMIT)(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   115
    IN SCARDHANDLE hCard,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   116
    IN LPCSCARD_IO_REQUEST pioSendPci,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   117
    IN LPCBYTE pbSendBuffer,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   118
    IN DWORD cbSendLength,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   119
    IN OUT LPSCARD_IO_REQUEST pioRecvPci,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   120
    OUT LPBYTE pbRecvBuffer,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   121
    IN OUT LPDWORD pcbRecvLength);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   122
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   123
/* SCardStatusW */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   124
#define WINSCARD_PROC_STATUS_W "SCardStatusW"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   125
#define WINSCARD_PROC_STATUS WINSCARD_PROC_STATUS_W
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   126
#define WINSCARD_STATUS WINSCARD_STATUS_W
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   127
#define WINSCARD_Status WINSCARD_StatusW
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   128
typedef LONG (WINAPI * WINSCARD_STATUS_W)(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   129
    IN SCARDHANDLE hCard,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   130
    OUT LPWSTR szReaderName,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   131
    IN OUT LPDWORD pcchReaderLen,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   132
    OUT LPDWORD pdwState,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   133
    OUT LPDWORD pdwProtocol,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   134
    OUT LPBYTE pbAtr,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   135
    OUT LPDWORD pcbAtrLen);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   136
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   137
/* SCardGetStatusChangeW */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   138
#define WINSCARD_PROC_GET_STATUS_CHANGE_W "SCardGetStatusChangeW"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   139
#define WINSCARD_PROC_GET_STATUS_CHANGE WINSCARD_PROC_GET_STATUS_CHANGE_W
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   140
#define WINSCARD_GET_STATUS_CHANGE WINSCARD_GET_STATUS_CHANGE_W
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   141
#define WINSCARD_GetStatusChange WINSCARD_GetStatusChangeW
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   142
typedef LONG (WINAPI * WINSCARD_GET_STATUS_CHANGE_W)(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   143
    IN SCARDCONTEXT hContext,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   144
    IN DWORD dwTimeout,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   145
    IN OUT LPSCARD_READERSTATE_W rgReaderStates,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   146
    IN DWORD cReaders);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   147
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   148
/* SCardCancel */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   149
#define WINSCARD_PROC_CANCEL "SCardCancel"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   150
typedef LONG (WINAPI * WINSCARD_CANCEL)(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   151
    IN SCARDCONTEXT hContext);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   152
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   153
/* addresses of functions */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   154
static WINSCARD_CONNECT             WINSCARD_Connect            = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   155
static WINSCARD_DISCONNECT          WINSCARD_Disconnect         = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   156
static WINSCARD_ESTABLISH_CONTEXT   WINSCARD_EstablishContext   = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   157
static WINSCARD_LIST_READERS        WINSCARD_ListReaders        = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   158
static WINSCARD_RELEASE_CONTEXT     WINSCARD_ReleaseContext     = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   159
static WINSCARD_TRANSMIT            WINSCARD_Transmit           = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   160
static WINSCARD_STATUS              WINSCARD_Status             = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   161
static WINSCARD_GET_STATUS_CHANGE   WINSCARD_GetStatusChange    = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   162
static WINSCARD_CANCEL              WINSCARD_Cancel             = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   163
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   164
/* and some variables, too */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   165
static SCARD_IO_REQUEST * WINSCARD_g_rgSCardT0Pci  = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   166
static SCARD_IO_REQUEST * WINSCARD_g_rgSCardT1Pci  = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   167
static SCARD_IO_REQUEST * WINSCARD_g_rgSCardRawPci = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   168
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   169
extern "C" SCARD_IO_REQUEST g_rgSCardT0Pci;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   170
extern "C" SCARD_IO_REQUEST g_rgSCardT1Pci;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   171
extern "C" SCARD_IO_REQUEST g_rgSCardRawPci;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   172
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   173
SCARD_IO_REQUEST g_rgSCardT0Pci;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   174
SCARD_IO_REQUEST g_rgSCardT1Pci;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   175
SCARD_IO_REQUEST g_rgSCardRawPci;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   176
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   177
static struct _WINSCARD_Export {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   178
    const char* name;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   179
    FARPROC * value_ptr;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   180
} WINSCARD_exports [] = {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   181
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   182
    /* functions */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   183
    {WINSCARD_PROC_CONNECT,             (FARPROC*)&WINSCARD_Connect},
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   184
    {WINSCARD_PROC_DISCONNECT,          (FARPROC*)&WINSCARD_Disconnect},
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   185
    {WINSCARD_PROC_ESTABLISH_CONTEXT,   (FARPROC*)&WINSCARD_EstablishContext},
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   186
    {WINSCARD_PROC_LIST_READERS,        (FARPROC*)&WINSCARD_ListReaders},
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   187
    {WINSCARD_PROC_RELEASE_CONTEXT,     (FARPROC*)&WINSCARD_ReleaseContext},
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   188
    {WINSCARD_PROC_TRANSMIT,            (FARPROC*)&WINSCARD_Transmit},
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   189
    {WINSCARD_PROC_STATUS,              (FARPROC*)&WINSCARD_Status},
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   190
    {WINSCARD_PROC_GET_STATUS_CHANGE,   (FARPROC*)&WINSCARD_GetStatusChange},
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   191
    {WINSCARD_PROC_CANCEL,              (FARPROC*)&WINSCARD_Cancel},
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   192
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   193
    /* variables */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   194
    {"g_rgSCardT0Pci",                  (FARPROC*)&WINSCARD_g_rgSCardT0Pci},
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   195
    {"g_rgSCardT1Pci",                  (FARPROC*)&WINSCARD_g_rgSCardT1Pci},
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   196
    {"g_rgSCardRawPci",                 (FARPROC*)&WINSCARD_g_rgSCardRawPci},
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   197
};
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   198
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   199
#define COUNT(array) (sizeof(array)/sizeof(array[0]))
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   200
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   201
/**
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   202
 * Checks if WINSCARD.DLL has been loaded; if not, attempts to load it
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   203
 * Returns TRUE if WINSCARD.DLL has been successfully loaded, FALSE 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   204
 * it the DLL or some entry points are missing.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   205
 */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   206
static BOOL WINSCARD_IsAvailable()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   207
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   208
    if (!WINSCARD_handle && !WINSCARD_missing)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   209
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   210
        HINSTANCE handle = LoadLibraryA(WINSCARD_DLL);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   211
        if (handle)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   212
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   213
            int i;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   214
            for( i=0; i<COUNT(WINSCARD_exports); i++)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   215
            {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   216
                LPCSTR name = WINSCARD_exports[i].name;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   217
                FARPROC addr = GetProcAddress(handle,name);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   218
                if (addr)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   219
                {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   220
                    *(WINSCARD_exports[i].value_ptr) = addr;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   221
                }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   222
                else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   223
                {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   224
                    TRACE2("ERROR: export %hs is missing from %hs\n",
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   225
                               name, WINSCARD_DLL);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   226
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   227
                    /* bad library, don't use it */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   228
                    WINSCARD_missing = TRUE;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   229
                    FreeLibrary(handle);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   230
                    handle = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   231
                    break;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   232
                }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   233
            }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   234
            g_rgSCardT0Pci = *WINSCARD_g_rgSCardT0Pci;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   235
            g_rgSCardT1Pci = *WINSCARD_g_rgSCardT1Pci;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   236
            g_rgSCardRawPci = *WINSCARD_g_rgSCardRawPci;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   237
            WINSCARD_handle = handle;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   238
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   239
        else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   240
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   241
            TRACE1("ERROR: failed to load %hs\n",WINSCARD_DLL);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   242
            WINSCARD_missing = TRUE;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   243
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   244
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   245
    return (WINSCARD_handle != NULL);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   246
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   247
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   248
/* *************************************************************************
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   249
 *  Functions that redirect WINSCARD calls to the real DLL if possible
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   250
 * *************************************************************************/
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   251
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   252
LONG WINAPI
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   253
SCardConnectW(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   254
    IN      SCARDCONTEXT hContext,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   255
    IN      LPCWSTR szReader,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   256
    IN      DWORD dwShareMode,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   257
    IN      DWORD dwPreferredProtocols,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   258
    OUT     LPSCARDHANDLE phCard,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   259
    OUT     LPDWORD pdwActiveProtocol)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   260
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   261
    WINSCARD_TRACE("SCardConnect");
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   262
    if (WINSCARD_IsAvailable())
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   263
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   264
        return WINSCARD_ConnectW(hContext,szReader,dwShareMode,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   265
                                 dwPreferredProtocols, phCard,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   266
                                 pdwActiveProtocol);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   267
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   268
    return SCARD_E_NO_SERVICE;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   269
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   270
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   271
LONG WINAPI
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   272
SCardDisconnect(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   273
    IN      SCARDHANDLE hCard,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   274
    IN      DWORD dwDisposition)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   275
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   276
    WINSCARD_TRACE("SCardDisconnect");
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   277
    if (WINSCARD_IsAvailable())
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   278
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   279
        return WINSCARD_Disconnect(hCard,dwDisposition);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   280
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   281
    return SCARD_E_NO_SERVICE;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   282
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   283
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   284
LONG WINAPI
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   285
SCardEstablishContext(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   286
    IN  DWORD dwScope,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   287
    IN  LPCVOID pvReserved1,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   288
    IN  LPCVOID pvReserved2,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   289
    OUT LPSCARDCONTEXT phContext)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   290
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   291
    WINSCARD_TRACE("SCardEstablishContext");
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   292
    if (WINSCARD_IsAvailable())
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   293
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   294
        return WINSCARD_EstablishContext(dwScope,pvReserved1,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   295
                                         pvReserved2,phContext);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   296
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   297
    return SCARD_E_NO_SERVICE;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   298
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   299
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   300
LONG WINAPI
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   301
SCardListReadersW(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   302
    IN      SCARDCONTEXT hContext,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   303
    IN      LPCWSTR mszGroups,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   304
    OUT     LPWSTR mszReaders,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   305
    IN OUT  LPDWORD pcchReaders)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   306
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   307
    WINSCARD_TRACE("SCardListReaders");
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   308
    if (WINSCARD_IsAvailable())
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   309
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   310
        return WINSCARD_ListReadersW(hContext,mszGroups,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   311
                                     mszReaders,pcchReaders);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   312
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   313
    return SCARD_E_NO_SERVICE;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   314
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   315
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   316
LONG WINAPI
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   317
SCardReleaseContext(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   318
    IN      SCARDCONTEXT hContext)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   319
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   320
    WINSCARD_TRACE("SCardReleaseContext");
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   321
    if (WINSCARD_IsAvailable())
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   322
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   323
        return WINSCARD_ReleaseContext(hContext);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   324
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   325
    return SCARD_E_NO_SERVICE;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   326
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   327
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   328
LONG WINAPI
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   329
SCardTransmit(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   330
    IN SCARDHANDLE hCard,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   331
    IN LPCSCARD_IO_REQUEST pioSendPci,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   332
    IN LPCBYTE pbSendBuffer,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   333
    IN DWORD cbSendLength,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   334
    IN OUT LPSCARD_IO_REQUEST pioRecvPci,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   335
    OUT LPBYTE pbRecvBuffer,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   336
    IN OUT LPDWORD pcbRecvLength)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   337
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   338
    WINSCARD_TRACE("SCardTransmit");
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   339
    if (WINSCARD_IsAvailable())
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   340
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   341
        return WINSCARD_Transmit(hCard, pioSendPci, pbSendBuffer, 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   342
                                 cbSendLength, pioRecvPci, pbRecvBuffer,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   343
                                 pcbRecvLength);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   344
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   345
    return SCARD_E_NO_SERVICE;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   346
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   347
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   348
LONG WINAPI
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   349
SCardStatusW(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   350
    IN SCARDHANDLE hCard,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   351
    OUT LPWSTR szReaderName,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   352
    IN OUT LPDWORD pcchReaderLen,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   353
    OUT LPDWORD pdwState,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   354
    OUT LPDWORD pdwProtocol,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   355
    OUT LPBYTE pbAtr,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   356
    OUT LPDWORD pcbAtrLen)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   357
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   358
    WINSCARD_TRACE("SCardStatus");
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   359
    if (WINSCARD_IsAvailable())
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   360
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   361
        return WINSCARD_StatusW(hCard, szReaderName, pcchReaderLen,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   362
                                pdwState, pdwProtocol, pbAtr, pcbAtrLen);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   363
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   364
    return SCARD_E_NO_SERVICE;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   365
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   366
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   367
LONG WINAPI
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   368
SCardGetStatusChangeW(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   369
    IN SCARDCONTEXT hContext,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   370
    IN DWORD dwTimeout,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   371
    IN OUT LPSCARD_READERSTATE_W rgReaderStates,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   372
    IN DWORD cReaders)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   373
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   374
    //WINSCARD_TRACE("SCardGetStatusChange");
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   375
    if (WINSCARD_IsAvailable())
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   376
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   377
        return WINSCARD_GetStatusChangeW(hContext, dwTimeout, rgReaderStates,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   378
                                         cReaders);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   379
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   380
    return SCARD_E_NO_SERVICE;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   381
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   382
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   383
LONG WINAPI
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   384
SCardCancel(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   385
    IN SCARDCONTEXT hContext)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   386
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   387
    WINSCARD_TRACE("SCardCancel");
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   388
    if (WINSCARD_IsAvailable())
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   389
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   390
        return WINSCARD_Cancel(hContext);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   391
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   392
    return SCARD_E_NO_SERVICE;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   393
}