开发者

Accessing SLE4442 memory card in C - need some help (RPC_X_BAD_STUB_DATA)

I'm new to SmartCard Programming, so please bear with me..

I'm trying to access an SLE4442 memory card anagrammatically using the WinSCard API. When accessing the card with pcscdiag.exe tool from here: http://scm-smartpcscdiag.software.informer.com/ I get the following information:

T=65535

Clock=372

F=372

D=-

N=0

W=0

IFSD=252

EBC=Longitudinal Redundancy Check

ICC type per ATR=unknown Type

Naturally, trying to access the card using T=0 or T=1 protocol fails, but I am able to connect to the read with RAW access:

lReturn = SCardConnect(   
    (sc->hContext),  
    (LPCTSTR)(sc->pmszReaders),  
    SCARD_SHARE_EXCLUSIVE,  
    SCARD_PROTOCOL_RAW,  
    //SCARD_SHARE_EXCLUSIVE,  
    //SCARD_PROTOCOL_T1,  
    &(sc->hCardHandle),  
    &(sc->dwAP) );  

Now, I'm trying, as a first step, to read the contents of the card:

lReturn = SCardBeginTransaction(sc.hCardHandle); // successful ,err checking omitted

DWORD dwSendLength, dwRecvLength;
SCARD_IO_REQUEST pioRecvPci;
BYTE pbSendBuffer[512];
BYTE pbRecvBuffer[512];
dwSendLength = 512;
dwRecvLength = 512;

pbSendBuffer[0] = 0x00;     // CLA
pbSendBuffer[1] = 0xB0; // INS
pbSendBuffer[2] = 0x00;     // P1
pbSendBuffer[3] = 0x00;     // P2
pbSendBuffer[4] = 0x00;     // LEN

dwSendLength = 5;

lReturn = S开发者_JAVA技巧CardTransmit(
    sc.hCardHandle,
    SCARD_PCI_RAW,
    //SCARD_PCI_T1,
    pbSendBuffer,
    dwSendLength,
    &pioRecvPci, 
    pbRecvBuffer, 
    &dwRecvLength
    );

I've also tries setting the CLA to 0xFF, and other variants (nested loops, with values of 0..255 for the CLA and the INS)

I keep getting an 1783 error: RPC_X_BAD_STUB_DATA

What am I doing wrong? What do I need to do in order to read the card?

Thanks in advance!


Accessing memory cards (I2C in this case) may depend entirely on the smart card reader you are using.

Some may provide additional API (proprietary or something more standard like CT-API) in a DLL that use smart card reader kernel driver directly, some may simulate a T=0 cards by using part 7 of MKT specification, some may need that you call SCardControl() function with special parameters.

Check the documentation of your particular smart card reader.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜