[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ms-smartcardddk
Subject:    Re: Snag with SCARD_SHARE_DIRECT
From:       Yvan Nadeau <Yvan.NADEAU () GEMPLUS ! COM>
Date:       1999-07-13 10:50:44
[Download RAW message or body]


Sorry Doug,

I don't like this solution because my driver is not
aware of application connections.  This means that the
application will have to advise directly the driver to
simulate a smart card insertion/removal through a
vendor defined IOCTL.

I think this is another good reason why there should
be a new version of the resource manager under NT4 and
Win9x.  This adds up to the PnP, hot-plugging and
SCardGetAttrib problems.

Meanwhile, subscribers of this forum could agree to
use a special IOCTL to handle this problem.  I propose
CTL_CODE(FILE_DEVICE_SMARTCARD,4080,0,0), with no
input or output parameters.  In an applicative point of
view, this would translate to:

   // Connects even if there is no card in the reader.
   return_code = SCardConnect(hContext,
                              szReader,
                              SCARD_SHARE_DIRECT,
                              0,
                              &hCard,
                              &dwActiveProtocol);

   // Do some stuff here. (Example: get channel id).
   // ...

   // The following SCardControl is to tell reader's
   // driver to simulate an instantaneous smart card
   // insertion and removal if necessary (no card in
   // the reader).  Corrects the snag with the use of
   // SCARD_SHARE_DIRECT.
   dwControlCode = SCARD_CTL_CODE(4080);
   nInBufferSize = 0;
   nOutBufferSize = 0;

   return_code = SCardControl(hCard,
                              dwControlCode,
                              lpInBuffer,
                              nInBufferSize,
                              lpOutBuffer,
                              nOutBufferSize,
                              lpBytesReturned);

   if (return_code != SCARD_S_SUCCESS)
   {
      // The current driver doesn't support this
      // IOCTL.  Ask user to insert (and remove) a
      // smart card in the reader if necessary.
      // Note that State is really SCARD_ABSENT if
      // there is no card in.  The problem is with
      // SCardGetStatusChange.
      SCardStatus(hCard, NULL, &ReaderLen, &State,
                  &Protocol, Atr, &AtrLen);

      if (AtrLen == 0)
         AskUserToInsertSmartCard();
   }

   // If you use anything else than SCARD_LEAVE_CARD
   // when there is no card in the reader, resource
   // manager hangs.
   return_code = SCardDisconnect(hCard,
                                 SCARD_LEAVE_CARD);

   // ...


Jean-Philippe

 -----Reply Separator-----


I found the same snag under Windows 2000, and fixed it.

For the existing release of the smart card base components, it
appears that inserting and removing a card clears the state
problem.  You can work around the problem by just having your
driver complete the outstanding IOCTL_SMARTCARD_PRESENT request.
This will cause the resource manager to think a card has been
inserted, then notice it was wrong, and reset it's internal
state.

BTW: c00000bb is STATUS_NOT_SUPPORTED, which just means that
your driver does not support eject.

Doug

 -----Original Message-----

Hi,

Whether it is to write "Please insert your smart card"
on the LCD screen of a reader or it is simply to get
reader's attributes, some applications just can't
avoid to ask for a connection to a reader before any
smart card is inserted. In short, the mode
SCARD_SHARE_DIRECT is really essential. Unfortunately,
there's a snag using it under NT4 and Win9x.

Connecting in this mode will automatically convince
resource manager that there is a smart card in the
reader, even if there is none. Disconnecting and
releasing the smart card context will not alter this
belief.

To follow resource manager's logic, I also tried to
disconnect with SCARD_EJECT_CARD.  That was not a
good idea: SmartcardDeviceControl (smclib) returned
to my driver the error BERR_XOM_SCHEMA_READ
(0xC00000BB).  This code was forwarded to resource
manager as the return code to DeviceEntry.  After
this, resource manager stopped responding.

Apart from inserting and removing a smart card in
the reader, is there a way to bring up to date the
smart card status?  I'm interrested in both driver
and application based solutions.

Thanks,

Jean-Philippe Mailloux
GEMPLUS ADC - Readers Environment Group
jean-philippe.mailloux@gemplus.com



 ----------------------------------------------------------------
 INFORMATION    AUTOMATIC VIRUS CHECK (GEMPLUS)   No virus known.
 ----------------------------------------------------------------

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic