PC/SC Architecture Explained for Developers

What is the PC/SC architecture? PC/SC is a layered standard that puts a single programming interface between your application and any smart card reader. From the bottom up, the layers are: the card (ICC), the reader (IFD), the reader driver (IFD handler), one resource manager per computer, optional service providers, and your application. On Windows, the resource manager is the Smart Card service (SCardSvr), and programs reach it through the WinSCard functions in winscard.dll. On Linux, the same functions come from pcsc-lite. Your code never talks to the USB device itself. It asks the resource manager, which shares the reader between programs and passes your commands down to the reader or the card.

This page explains each layer, the order of the WinSCard calls, share modes and protocols, the difference between SCardTransmit and SCardControl, and why ACS readers accept "pseudo-APDUs". It is the background for BSD's practical guides, so it links to them for working code instead of repeating it. Facts come from the PC/SC Workgroup specifications and Microsoft's WinSCard documentation (see Sources). BSD Infotech is an independent ACS supplier and integrator, not the manufacturer.

The PC/SC Workgroup published its architecture so that any application could use any compliant reader and card, whoever made them. Part 1 of the specification names the building blocks, and the other parts define each interface between them. Read the diagram from the bottom: each layer only talks to the layers next to it.

PC/SC architecture layers From top to bottom: your application, an optional service provider, the PC/SC API (winscard.dll, libpcsclite or the macOS PC/SC layer), the ICC resource manager (SCardSvr or pcscd), the IFD handler or reader driver, the IFD or reader, and the ICC or card. SCardTransmit carries commands down to the card; SCardControl carries commands down to the reader. Your application ICC-aware application: C#, C/C++, Java, Python Service provider optional, e.g. Base CSP + card minidriver (Windows) direct calls PC/SC API (the SCard… functions) winscard.dll on Windows · libpcsclite on Linux Apple's own PC/SC layer on macOS ICC resource manager (one per computer) Smart Card service SCardSvr on Windows · pcscd on Linux reader list, card events, sharing, transactions IFD handler = the reader driver ACS PC/SC driver or the Windows CCID driver libccid or ACS's driver on Linux IFD = the reader e.g. ACR1252U, ACR1552U, ACR122U, ACR39U each slot (PICC, SAM, ICC) is a separate reader ICC = the card contact (ISO 7816) or contactless (ISO 14443, ISO 15693) SCardTransmit: APDU to the card SCardControl: to the reader Diagram by BSD Infotech, based on PC/SC Part 1 and Microsoft's WinSCard documentation.
Every PC/SC program, on every platform, follows this path. The table below gives the same layers in words.
PC/SC termWhat it isOn WindowsOn Linux (pcsc-lite)
ICC (integrated circuit card)The card. PC/SC covers contact cards (ISO 7816) and contactless cards such as ISO 14443 (proximity) and ISO 15693 (vicinity), with the aim of giving them the same interface at application level.The same card on any platform: MIFARE, NTAG, DESFire, SLE memory cards, chip cards in a contact slot.
IFD (interface device)The reader. It powers the card, supplies the clock and carries the data. A reader can have several slots.The ACS reader. Each slot is offered to programs as a separate reader, which is why an ACR1252U shows a PICC entry and a SAM entry.
IFD handlerLow-level PC software for one kind of reader. Part 1 says it "will likely" be a device driver; it hides the difference between simple and intelligent readers.The ACS PC/SC driver, or the CCID driver built into Windows (see the driver guide).The free CCID driver (libccid), or ACS's own Linux driver. Both plug into pcscd through the IFD Handler API.
ICC resource managerThe single system service that tracks readers and cards, shares them between programs and offers transactions.Smart Card service, service name SCardSvr.The pcscd daemon.
Service providersOptional components that wrap a card's functions (files, authentication, cryptography) in a higher-level interface.Base CSP and smart card KSP with a card minidriver, used by certificate and sign-in cards.Not part of pcsc-lite itself; any such layer is separate software that calls the SCard functions.
Application"ICC-aware" software that uses the resource manager and, if it needs one, a service provider.Calls the WinSCard functions in winscard.dll.Calls the same SCard functions in libpcsclite.

For ACS readers, the important point is the middle of the stack. Whether Windows loaded ACS's driver or its own CCID driver, your program sees the same thing: a reader name in the resource manager's list. That is why one program can work with an ACR1252U, an ACR1552U and an ACR39U without a separate API for each. The USB and CCID level below the driver is covered in our USB CCID reader communication guide.

PC/SC Part 1 calls the resource manager "a key component" and says there should be only one per system, normally supplied by the operating system vendor. It gives it three jobs:

  1. Track resources. Which readers are installed, which card types are known, and when cards are inserted or removed.
  2. Control access. Let programs attach to a reader or card in shared or exclusive mode.
  3. Provide transactions. Cards are single-threaded and an operation often needs several commands in a row, so a program can lock the card until the sequence is finished.

Microsoft's documentation describes how Windows does this. The Smart Cards for Windows service (formerly called Smart Card Resource Manager, service name SCardSvr) runs as a local service inside a shared svchost process. Its start type is manual by default: reader drivers that install in the SmartCardReader device class make Windows start it when a reader is plugged in. That is why the service can look stopped on a PC with no reader attached. Once running, it handles device introduction, reader initialisation, notifying programs of new readers, serialising access to readers, card access and "tunneling of reader-specific commands". That last item is the path that escape commands take.

Microsoft also notes that the service treats each reader slot as a unique reader, whatever the physical device looks like. To check that the service is running and see which readers it offers, use the PC/SC reader status guide; to start or repair it, see the Smart Card service section of the driver guide.

In the PC/SC model, a service provider wraps what a card can do (read files, authenticate, sign) in a high-level interface, so an application can use it without knowing the card's commands. Part 1 describes ICC service providers and, as one type of them, the cryptographic service provider (CSP), which should expose only cryptographic functions.

Windows uses this model for certificate cards. Microsoft's architecture page shows applications calling CryptoAPI or CNG, which reach the card through the Base CSP or the smart card key storage provider and a card-specific minidriver. Those components then talk to the card through WinSCard. Windows sign-in with a smart card works this way.

Most applications built around ACS contactless readers do not need a service provider. Attendance, access control, cashless and membership systems that read a UID, MIFARE blocks or DESFire files call the WinSCard functions directly, as the BSD guides do. Several ACS readers also support CT-API, an older interface that ACS provides as a wrapper on top of PC/SC (see the PC/SC, CCID and CT-API summary).

Every PC/SC program, in any language, makes the same calls in the same order. The names below are the Windows ones; pcsc-lite uses the same names. A handle from one step is needed for the next, and each step can fail for a reason that belongs to one layer.

StepCallWhat it doesLayer that answers
1SCardEstablishContextOpens a session ("context") with the resource manager. Scope SCARD_SCOPE_USER or SCARD_SCOPE_SYSTEM. In a remote session on a system without smart card redirection, Windows returns ERROR_BROKEN_PIPE.Resource manager
2SCardListReadersReturns the names of the readers the resource manager knows. Pick yours by part of the name, never by position.Resource manager
3SCardGetStatusChangeReports each reader's state, or waits until it changes, for example until a card arrives. With a time-out of zero it returns at once.Resource manager (fed by the driver)
4SCardConnectConnects to the card in one reader, with a share mode and the protocols you accept. Returns a card handle and the active protocol. Fails if there is no card, unless you use direct mode.Resource manager, driver, card
(4a)SCardBeginTransactionOptional. Blocks other programs from the card while a sequence of commands runs.Resource manager
5SCardTransmit or SCardControlSends a command to the card (Transmit) or to the reader (Control). See the comparison below.Card, or reader
(5a)SCardEndTransactionEnds the transaction and says what to do with the card.Resource manager
6SCardDisconnectEnds the connection with a disposition: leave, reset, unpower or eject the card.Resource manager, card
7SCardReleaseContextCloses the session with the resource manager. Always do it, even after an error.Resource manager

Two more calls are useful between steps 4 and 6: SCardStatus returns the card's current state, protocol and ATR on an open connection, and SCardReconnect re-establishes a connection after another program reset the card. Microsoft adds a rule that matters for crashes: if a program exits without calling SCardDisconnect, the card is reset automatically.

Working code for each step

This page does not repeat code that BSD has already published. Steps 1 to 3 are in the read-only C# PC/SC reader status check (.NET 10), which lists readers and their states without connecting. Steps 4 to 7 with SCardTransmit are in the C# read-UID examples for the ACR1252U, ACR1552U and ACR122U, and with SCardControl in the firmware version example. To try the calls one by one without code, see the PC/SC Learning Tool guide. Each page states its own test status.

Share modes (SCardConnect)

ValueMicrosoft's meaning (summarised)When to use it
SCARD_SHARE_SHAREDThe program is willing to share the card with other programs.The default for almost everything. Use a transaction when a sequence of commands must not be interrupted.
SCARD_SHARE_EXCLUSIVEThe program will not share the card.Rarely. Other programs then get SCARD_E_SHARING_VIOLATION until you disconnect.
SCARD_SHARE_DIRECTThe program takes the reader for its private use and controls it directly. No other program may access it.Reader commands sent with SCardControl, with or without a card on the reader. Release it quickly.

Protocols: T=0, T=1 and raw

T=0 and T=1 are the two transmission protocols of contact cards defined in ISO 7816-3: T=0 is character-oriented and T=1 block-oriented. In SCardConnect you pass the protocols you accept, normally SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, and Windows returns the one actually negotiated. You must then send every SCardTransmit with the matching protocol header: SCARD_PCI_T0 or SCARD_PCI_T1. If the header does not match the active protocol, the call fails.

  • Direct mode with no protocol. The preferred protocols may be 0 only with SCARD_SHARE_DIRECT. No protocol is negotiated, and the active protocol comes back as SCARD_PROTOCOL_UNDEFINED; Microsoft notes that there may be no card in the reader at all.
  • Raw. Windows also supplies a raw protocol header, SCARD_PCI_RAW, and pcsc-lite documents SCARD_PROTOCOL_RAW for memory-type cards. Ordinary applications for ACS readers do not need it.
  • Contactless cards. ISO 14443 has no T=0 or T=1, but PC/SC Part 3 requires the reader and driver to make a contactless card look like a contact card to the application: they report card insertion and removal and build an ATR from fixed elements that identify the card. So you connect to a MIFARE or DESFire card exactly as to a contact card. Request both protocols and use whichever is returned.

Dispositions (SCardDisconnect, SCardEndTransaction, SCardReconnect)

When you let go of a card you say what should happen to it: SCARD_LEAVE_CARD (nothing special), SCARD_RESET_CARD (reset it), SCARD_UNPOWER_CARD (power it down) or SCARD_EJECT_CARD (eject it, for readers that can). Leave the card is the usual choice, because a reset ends any session another program has with it.

Transactions

SCardBeginTransaction waits until other transactions finish, then blocks all other programs from the card until you call SCardEndTransaction. It is how a shared connection stays safe during a multi-command sequence, such as authenticate then read on a MIFARE Classic sector. Microsoft documents a limit: if a transaction is held for more than five seconds with no operation on the card, the card is reset. Keep transactions short and do not wait for user input inside one.

Both calls send bytes down the stack, but to different places. Microsoft describes SCardTransmit as sending "a service request to the smart card", and SCardControl as giving "direct control of the reader". The resource manager passes control requests on to the driver; that is the "tunneling of reader-specific commands" in Microsoft's list.

SCardTransmitSCardControl
Goes toThe card (or the reader, for a pseudo-APDU)The reader and its driver
You sendAn APDU plus a protocol header (SCARD_PCI_T0, SCARD_PCI_T1)A control code plus an input buffer
Needs a card?Yes: a connection in shared or exclusive mode needs a cardNo, if you connect in direct mode
ReplyData followed by the status word SW1 SW2 (for example 90 00)Whatever the driver or reader defines for that control code
ACS examplesFF CA 00 00 00 (Get Data, card UID); APDUs to DESFire or other ISO 14443-4 cardsEscape command E0 00 00 18 00 (firmware version) on the ACR1252U and ACR1552U, control code SCARD_CTL_CODE(3500)
Portable?Yes: APDUs are defined by ISO 7816-4, PC/SC and the card makerMostly vendor-specific: control codes and their bytes differ by reader, driver and platform

ACS documents its escape commands with control code 3500 and writes the Windows value as 0x310000 + 3500 * 4 (that is, 0x3136B0). Escape commands only work through a driver that passes them on, which on Windows normally means the ACS PC/SC driver. Two BSD guides use this route with real commands: checking the ACS reader firmware version (read-only, a good first test) and controlling the LED and buzzer (changes reader settings, so read the guide first).

Many contactless cards, such as MIFARE Classic and MIFARE Ultralight, do not understand ISO 7816-4 APDUs. PC/SC Part 3 solves this inside the reader stack: for these "storage cards", the reader and driver must translate a set of standard APDUs into the card's own commands. It also says that the reader must not filter or translate APDUs for cards that understand them, such as ISO 14443-4 cards like DESFire. The standard commands all use the class byte FF:

Command (PC/SC Part 3)BytesWhat the reader does
Get Data (UID)FF CA 00 00 00Returns the card's UID, or serial number, without passing a command to the card.
Load KeysFF 82 ...Stores a key in the reader for later authentication.
General AuthenticateFF 86 ...Authenticates a block or sector of the card with a stored key.
Read BinaryFF B0 ...Reads data from the card.
Update BinaryFF D6 ...Writes data to the card.
VerifyFF 20 ...Presents a security code, for cards that have one.

ACS calls commands like these pseudo-APDUs: they look like APDUs and travel through SCardTransmit, but the reader handles them itself. ACS adds its own reader commands to the same family; on the ACR122U, for example, FF 00 48 00 00 returns the firmware version and FF 00 40 ... drives the LED and buzzer. This design lets your program keep one call, SCardTransmit, for card data and simple reader functions. The exact list, and which reader supports which command, is in each reader's ACS manual and in BSD's model guides: the ACR122U pseudo-APDU explanation, the ACR1252U reader-specific commands and the ACR1552U developer notes.

Newer ACS readers such as the ACR1252U and ACR1552U move most reader settings to escape commands (SCardControl), while keeping the PC/SC storage-card commands for card data. That is why the same task, reading the firmware version, takes a pseudo-APDU on the ACR122U and an escape command on the ACR1552U.

Not yet tested by BSD. BSD's test machines run Windows 10 and 11. This section only reports what the pcsc-lite and CCID driver documentation says; it makes no claim that a given ACS reader works on Linux or macOS.

Linux and other Unix systems use pcsc-lite, which its author describes as middleware to access a smart card through the SCard API (PC/SC). It has the same layers as Windows under different names:

  • The resource manager is the pcscd daemon.
  • Applications link to libpcsclite, which offers the same SCard functions as winscard.dll (pcsc-lite's own API documentation is titled "PC/SC Lite API (WinSCard)").
  • Reader drivers are IFD handlers loaded by pcscd through the IFD Handler API. The usual one is the free CCID driver (libccid). Its reader list includes ACS readers: on 30 Nov 2026 it listed the ACR38U-CCID as supported, and the ACR122U, ACR1252, ACR1552, ACR1581, ACR39U and ACR1255U-J1, among others, under "should work". ACS also lists its own Linux drivers on each reader's download page.

macOS does not need pcsc-lite. According to the pcsc-lite site, Apple provides its own PC/SC layer, built above Apple's CryptoTokenKit, so programs use the same SCard functions without installing pcsc-lite.

Differences documented by pcsc-lite

TopicWindowspcsc-lite
Context scopeSCARD_SCOPE_USER or SCARD_SCOPE_SYSTEMOnly SCARD_SCOPE_SYSTEM is used; the others are marked "Not used".
Direct mode (SCARD_SHARE_DIRECT)The reader is reserved for one program.The reader is accessed in shared mode, "contrary to Windows winscard behavior".
Card state from SCardStatusAn enumerationA bit field
Feature not supported0x80100022 (or ERROR_NOT_SUPPORTED)0x8010001F
Transactions after SCardReconnectReleased; call SCardBeginTransaction againStay valid
Control code formulaACS writes SCARD_CTL_CODE(3500) as 0x310000 + 3500 * 4SCARD_CTL_CODE(code) is defined as 0x42000000 + code

The last row matters for escape commands. The same symbolic code gives a different number on each platform, so hard-coded Windows values will not carry over. With the free CCID driver, the documented route for a vendor escape command is IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE, defined as SCARD_CTL_CODE(1). The driver only allows it for any reader when the DRIVER_OPTION_CCID_EXCHANGE_AUTHORIZED option is set in its Info.plist file, which its documentation restricts for security reasons. If you use ACS's own Linux or macOS driver instead, follow ACS's documentation for that driver.

Thinking in layers makes errors easier to place. Start at the bottom: a fault in a lower layer hides everything above it.

What you seeLayerWhere to go
Reader missing from Device Manager, or shown with a warningIFD and IFD handler (USB, driver)Check whether Windows detects the reader, then the driver installation guide.
SCardEstablishContext fails with 0x8010001D (no service)Resource managerStart the Smart Card service: service section of the driver guide.
SCardListReaders returns 0x8010002E (no readers)Resource manager has no reader: driver, keyboard mode or Remote DesktopPC/SC status guide and the "no reader found" checks.
SCardConnect returns 0x8010000B (sharing violation)Resource manager: another program holds the cardReader states: close the other program, use shared mode.
SCardConnect returns 0x8010000C (no card)CardPlace the card first, or wait for it with SCardGetStatusChange. For reader commands, use direct mode.
SCardTransmit succeeds but the reply ends in 6X XXCard (or reader, for a pseudo-APDU)A status word, not a PC/SC error: check the command in the reader's or card's manual. Card-not-read checks.
SCardControl fails for an ACS escape commandIFD handler: wrong control code, share mode or driverUse code 3500 on the PICC entry in direct mode with the ACS driver: see the firmware guide's troubleshooting.

The full list of PC/SC return codes with their meanings is in the PC/SC error code table.

Checked on 30 Nov 2026. The PC/SC specification parts were downloaded from the PC/SC Workgroup site (direct download, no form, when checked). ACS command bytes and control codes are taken from the ACS manuals cited on BSD's model guides linked above.

BSD Infotech is an independent ACS supplier and integrator, not the manufacturer. ACS, the ACS logo and ACS product names belong to Advanced Card Systems Ltd. Windows is a trademark of Microsoft Corporation; macOS is a trademark of Apple Inc.

Building software on PC/SC?

Tell us the reader model, your platform and what the application must do. We help with WinSCard integration, escape commands and reader handling for ACS readers.