none
WinScard Smart Card dll 32 bit 64 bit compatibility RRS feed

  • Question

  • I have to make use of the WinScard.dll library to access the smart card . I have a Java application that loads and makes use of this library to access the smart card .

    32 Bit systems : Initially our application was written for a 32 bit Windows . Hence the following interface to the library worked well .

    SCard INSTANCE = (SCard)Native.loadLibrary("C:\\Windows\\SysWOW64\\WinSCard.dll", SCard.class);   
    
    public int SCardEstablishContext(int iScope, Pointer pvReserved1, Pointer pvReserved2, /*OUT &long*/LongByReference rRdrlHandle);    
    
    public int SCardGetStatusChangeA(int iHandle, int dwTimeout, /*IN/OUT*/SCardReaderState.ByReference rgReaderStates, int cReaders);


    64 bit systems : Now while we were migrating our application for a 64 bit windows we realised that to make it work we needed to make all the iHandle long intead of int . Thus the following works

    SCard INSTANCE = (SCard)Native.loadLibrary("winscard", SCard.class);
    
    public int SCardEstablishContext(int iScope, Pointer pvReserved1, Pointer pvReserved2, /*OUT &long*/LongByReference rRdrlHandle);
    
    public int SCardGetStatusChangeA(long iHandle, int dwTimeout, /*IN/OUT*/SCardReaderState.ByReference rgReaderStates, int cReaders);


    So now my question is this :

    Scenario 1 :

     

    -          64 bit Java VM

    -          64 bit dll ( C:\Windows\System32 )

    -          Keep Long in the interface iHandle


    Handler obtained : Correct

     

    Scenario 2 ( running on a 64 bit system but using 32 bit artifacts ) :

    -          32 bit Java VM

    -          32 bit dll

    -          Keep Long

     

    Handler obtained : Incorrect

    Shouldn't the scenario 2 be taken care automatically by the WOW64 subsystem . I read that WOW64 automatically converts the data structures so that a 32 bit application can run on a 64 bit system .

    Can someone advice me on how to get my application running on both 32 & 64 bit systems without having the need to change the interface of the iHandle every time ?

    Monday, October 14, 2013 2:48 AM

All replies