java smartcard winscard.dll,在没有连接智能卡的情况下使用winscard.dll(PC / SC)发送APDU...

I'm trying to send APDU commands to the card reader itself instead of the Smart Card. The test command I'm using turns the RF field on and off.

This commands sends over SCardTransmit if I first connected to a smart card. But as soon as the RF field is off, the card disconnects and I cant send another APDU to turn the field on.

Basically is there any way to send APDU's over pc/sc without a card present. I want to configure certain parts of the reader before reading a card.

Thanks in advance.

-----Edit-----

As FPGA Warrior mentioned I need to use SCardControl to send APDU commands to the card reader.

The steps I've gotten so far:

Connect to 'card' with SCardConnect with SCARD_SHARE_DIRECT and SCARD_PROTOCOL_UNDEFINED. This will return as success and give you the card handle.

_lastError = SCardConnect(_hContext, _cardReaderName, dwShareMode, dwPreferredProtocols, ref phCard, ref _activeProtocol);

Returns: 0 and what looks like a valid _hCard handle.

I then call SCardControl

_lastError = SCardControl(phCard, CTL_code(3500), txBytes, (uint)txByte.Length, out rxBytes, (uint)rxAttr.Length, out rxLen);

I now get the error ERROR_INVALID_HANDLE (0x6). So it seems that my SCardConnect does not return a valid handle, even thou it does not return an error.

As a side note to use PC_to_RDR_Escape mode on the device you might need to edit the registry to turn it on if the drivers you installed does not allow it.

https://msdn.microsoft.com/en-us/library/windows/hardware/dn653571%28v=vs.85%29.aspx

解决方案

I'm not sure why is configuring a reader is made by sending APDUs to a card. It should not be that way. SCardTransmit is for sending command to a card, and it will not work if there is no card (unless you hack the driver so it lies that there is actually a card inserted).

You might be looking for one of these APIs:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa375369(v=vs.85).aspx

It gives more direct acces to your reader / card.

Specifying that what configurations you wish to set on the reader might increase the change to get an answer that helps you.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值