public byte[] Transceive(byte[] buffer)
        {
            if (buffer == null) throw new ArgumentNullException(nameof(buffer));

            var sioreq = new SCARD_IO_REQUEST
            {
                dwProtocol = 0x2,
                cbPciLength = 8
            };
            var rioreq = new SCARD_IO_REQUEST
            {
                cbPciLength = 8,
                dwProtocol = 0x2
            };

            var receiveBuffer = new byte[255];
            var rlen = receiveBuffer.Length;

            Debug.WriteLine($"SmartCardConnection.Transceive: hCard = {hCard}, buffer = {buffer.ByteArrayToString()}");
            var retVal = SafeNativeMethods.SCardTransmit(hCard, ref sioreq, buffer, buffer.Length, ref rioreq, receiveBuffer, ref rlen);
            Helpers.CheckError(retVal);

            var retBuf = new byte[rlen];
            Array.Copy(receiveBuffer, retBuf, rlen);

            return retBuf;
        }
Exemplo n.º 2
0
 public static extern int SCardTransmit(IntPtr hCard, ref SCARD_IO_REQUEST pioSendRequest,
                                                     byte[] SendBuff,
                                                     int SendBuffLen,
                                                     ref SCARD_IO_REQUEST pioRecvRequest,
                                                     byte[] RecvBuff, ref int RecvBuffLen);
Exemplo n.º 3
0
 public static extern int SCardTransmit(IntPtr hCard, ref SCARD_IO_REQUEST pioSendRequest,
                                        byte[] SendBuff,
                                        int SendBuffLen,
                                        ref SCARD_IO_REQUEST pioRecvRequest,
                                        byte[] RecvBuff, ref int RecvBuffLen);