用 C 访问 SLE4442 存储卡 - 需要一些帮助 (RPC_X_BAD_STUB_DATA)
我是智能卡编程的新手,所以请耐心等待。
我正在尝试使用 WinSCard API 以语法方式访问 SLE4442 存储卡。 从此处使用 pcscdiag.exe 工具访问卡时: http://scm-smartpcscdiag.software.informer.com/ 我得到以下信息:
T=65535
时钟=372
F=372
D=-
N=0
W=0
IFSD=252
EBC=纵向冗余校验
每个 ATR 的 ICC 类型=未知类型
当然,尝试使用 T=0 或 T=1 协议访问卡会失败,但我能够使用 RAW 访问连接到读取:
lReturn = SCardConnect(
(sc->hContext),
(LPCTSTR)(sc->pmszReaders),
SCARD_SHARE_EXCLUSIVE,
SCARD_PROTOCOL_RAW,
//SCARD_SHARE_EXCLUSIVE,
//SCARD_PROTOCOL_T1,
&(sc->hCardHandle),
&(sc->dwAP) );
现在,我正在尝试,作为第一步,读取卡的内容:
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 = SCardTransmit(
sc.hCardHandle,
SCARD_PCI_RAW,
//SCARD_PCI_T1,
pbSendBuffer,
dwSendLength,
&pioRecvPci,
pbRecvBuffer,
&dwRecvLength
);
我还尝试将 CLA 设置为 0xFF 和其他变体(嵌套循环,CLA 和 INS 的值为 0..255)
我不断收到 1783 错误: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 = SCardTransmit(
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
访问存储卡(在本例中为 I2C)可能完全取决于您使用的智能卡读卡器。
有些可能会在直接使用智能卡读卡器内核驱动程序的 DLL 中提供额外的 API(专有的或更标准的东西,如 CT-API),有些可能会使用 MKT 规范的第 7 部分模拟 T=0 卡,有些可能需要您调用具有特殊参数的 SCardControl() 函数。
检查特定智能卡读卡器的文档。
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.