PC/SC Architecture Explained for Developers
← Back to the smart card SDK and developer centre
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 Layers, From Card to Application
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 term | What it is | On Windows | On 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 handler | Low-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 manager | The 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 providers | Optional 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.
The Resource Manager: What SCardSvr Does
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:
- Track resources. Which readers are installed, which card types are known, and when cards are inserted or removed.
- Control access. Let programs attach to a reader or card in shared or exclusive mode.
- 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.
Service Providers: When an Application Does Not Call WinSCard Itself
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).
The WinSCard Call Sequence
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.
| Step | Call | What it does | Layer that answers |
|---|---|---|---|
| 1 | SCardEstablishContext | Opens 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 |
| 2 | SCardListReaders | Returns the names of the readers the resource manager knows. Pick yours by part of the name, never by position. | Resource manager |
| 3 | SCardGetStatusChange | Reports 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) |
| 4 | SCardConnect | Connects 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) | SCardBeginTransaction | Optional. Blocks other programs from the card while a sequence of commands runs. | Resource manager |
| 5 | SCardTransmit or SCardControl | Sends a command to the card (Transmit) or to the reader (Control). See the comparison below. | Card, or reader |
| (5a) | SCardEndTransaction | Ends the transaction and says what to do with the card. | Resource manager |
| 6 | SCardDisconnect | Ends the connection with a disposition: leave, reset, unpower or eject the card. | Resource manager, card |
| 7 | SCardReleaseContext | Closes 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.
SCardTransmit vs SCardControl
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.
| SCardTransmit | SCardControl | |
|---|---|---|
| Goes to | The card (or the reader, for a pseudo-APDU) | The reader and its driver |
| You send | An 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 card | No, if you connect in direct mode |
| Reply | Data followed by the status word SW1 SW2 (for example 90 00) | Whatever the driver or reader defines for that control code |
| ACS examples | FF CA 00 00 00 (Get Data, card UID); APDUs to DESFire or other ISO 14443-4 cards | Escape 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 maker | Mostly 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).
Pseudo-APDUs: Reader Commands That Travel Like Card Commands
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) | Bytes | What the reader does |
|---|---|---|
| Get Data (UID) | FF CA 00 00 00 | Returns the card's UID, or serial number, without passing a command to the card. |
| Load Keys | FF 82 ... | Stores a key in the reader for later authentication. |
| General Authenticate | FF 86 ... | Authenticates a block or sector of the card with a stored key. |
| Read Binary | FF B0 ... | Reads data from the card. |
| Update Binary | FF D6 ... | Writes data to the card. |
| Verify | FF 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.
PC/SC on Linux and macOS (pcsc-lite)
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
pcscddaemon. - 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
| Topic | Windows | pcsc-lite |
|---|---|---|
| Context scope | SCARD_SCOPE_USER or SCARD_SCOPE_SYSTEM | Only 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 SCardStatus | An enumeration | A bit field |
| Feature not supported | 0x80100022 (or ERROR_NOT_SUPPORTED) | 0x8010001F |
Transactions after SCardReconnect | Released; call SCardBeginTransaction again | Stay valid |
| Control code formula | ACS writes SCARD_CTL_CODE(3500) as 0x310000 + 3500 * 4 | SCARD_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.
Which Layer Is Failing?
Thinking in layers makes errors easier to place. Start at the bottom: a fault in a lower layer hides everything above it.
| What you see | Layer | Where to go |
|---|---|---|
| Reader missing from Device Manager, or shown with a warning | IFD and IFD handler (USB, driver) | Check whether Windows detects the reader, then the driver installation guide. |
SCardEstablishContext fails with 0x8010001D (no service) | Resource manager | Start 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 Desktop | PC/SC status guide and the "no reader found" checks. |
SCardConnect returns 0x8010000B (sharing violation) | Resource manager: another program holds the card | Reader states: close the other program, use shared mode. |
SCardConnect returns 0x8010000C (no card) | Card | Place the card first, or wait for it with SCardGetStatusChange. For reader commands, use direct mode. |
SCardTransmit succeeds but the reply ends in 6X XX | Card (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 command | IFD handler: wrong control code, share mode or driver | Use 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.
Sources
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.
- PC/SC Workgroup specifications (current set v2.01.14): Part 1 "Introduction and Architecture Overview" rev. 2.01.01 (architecture, ICC, IFD, IFD handler, resource manager, service providers); Part 3 "Requirements for PC-Connected Interface Devices" rev. 2.01.09 (contactless ATR, section 3.1.3.2.3; storage card commands, section 3.2.2.1)
- Microsoft: Smart Card Architecture and Smart Cards for Windows Service
- Microsoft Win32 reference: SCardEstablishContext, SCardConnect, SCardTransmit, SCardControl, SCardBeginTransaction, SCardDisconnect
- Microsoft: Smart Card Driver Environment (resource manager to reader driver)
- pcsc-lite: project page (platforms, macOS note), PC/SC Lite API (functions and Windows differences), reader.h (SCARD_CTL_CODE)
- CCID free software driver: project page, reader list and SCardControl commands
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.
