Пример #1
0
        public virtual byte[] Control(byte[] cctrl)
        {
            byte[] rctrl = new byte[280];
            uint   rl    = 0;
            uint   rc;

            Trace.WriteLine("Control << " + (new CardBuffer(cctrl)).AsString());

            rc = SCARD.Control(_hCard,
                               SCARD.IOCTL_CSB6_PCSC_ESCAPE,
                               cctrl,
                               (uint)cctrl.Length,
                               rctrl,
                               280,
                               ref rl);

            if (rc == 1)
            {
                rc = SCARD.Control(_hCard,
                                   SCARD.IOCTL_MS_CCID_ESCAPE,
                                   cctrl,
                                   (uint)cctrl.Length,
                                   rctrl,
                                   280,
                                   ref rl);
            }

            if (rc != SCARD.S_SUCCESS)
            {
                Trace.WriteLine("Control: " + rc);
                _last_error = rc;
                rctrl       = null;
                return(null);
            }

            byte[] r = new byte[rl];
            for (int i = 0; i < rl; i++)
            {
                r[i] = rctrl[i];
            }

            Trace.WriteLine("Control >> " + (new CardBuffer(r)).AsString());

            return(r);
        }