internal static byte[] SendCmd(IntPtr card, byte[] sendBytes) { byte[] receivedUID = new byte[255]; API.SCARD_IO_REQUEST request = new API.SCARD_IO_REQUEST(); request.dwProtocol = API.SCARD_PCI_T1; request.cbPciLength = Marshal.SizeOf(typeof(API.SCARD_IO_REQUEST)); int outBytes = receivedUID.Length; API.SCardFunctionReturnCodes status = (API.SCardFunctionReturnCodes)API.SCardTransmit(card, ref request, ref sendBytes[0], sendBytes.Length, ref request, ref receivedUID[0], ref outBytes); if (status == API.SCardFunctionReturnCodes.SCARD_S_SUCCESS) { return(receivedUID.Take(outBytes).ToArray()); } return(null); }
static bool SendDnieCmd(IntPtr card, byte[] cmd, byte[] buffer, ref int l) { API.SCARD_IO_REQUEST request = new API.SCARD_IO_REQUEST(); request.dwProtocol = API.SCARD_PCI_T0; request.cbPciLength = Marshal.SizeOf(typeof(API.SCARD_IO_REQUEST)); API.SCardFunctionReturnCodes status = (API.SCardFunctionReturnCodes)API.SCardTransmit(card, ref request, ref cmd[0], cmd.Length, ref request, ref buffer[0], ref l); if (status == API.SCardFunctionReturnCodes.SCARD_S_SUCCESS) { if (l == 2) { bool result = (buffer)[0] == 0x61 || ((buffer)[0] == 0x90 && (buffer)[1] == 0x00); return(result); } return(true); } else { return(false); } }