Windows - What is an API set?

The quick answer:

An API set is a collection of Windows API functions, organized by category, and exported from a DLL with a strong name (The DLL name is part of the contract with the developer. If the API Set changes, so does the name). An API Set DLL is called a Stub DLL because it doesn't implement any of the exported functions (that's why the DLLs are typically around 20KB each). An API Set DLL implements a Stub function that forwards the call (at runtime) to another DLL that actually implements the requested function: Kernel.dll, User32.dll, ucrtbase.dll, etc. The ability to export a function whose implementation is forwarded (called Export Forwarding or Function Forwarding) has been part of Windows (a DEF file capability) for many years. Kernel32.dll uses this technique to forward to ntdll.dll for example. The complete list of API Set DLLs that the OS supports is called the API Set Schema and is contained in \windows\system32\apisetschema.dll, a resource only DLL that is loaded at boot time. There is a different schema file for each release of the OS.


Article continues below Ad.

Ads by Google

Some background:
Windows Operating System functions are exposed through APIs. Application Programming Interfaces. An API is a collection of C style functions exported from a DLL.

There is an API for graphics (mostly in GDI32.DLL), one for windowing (mostly in USER32.DLL), another for registry access (a part of ADVAPI32.DLL), one for the file system (a part of KERNEL32.DLL), and so on. One of the problems with these legacy APIs, is that with a few exceptions, there isn't a one-to-one mapping between a DLL and the type of functions that it exports. Windows API DLLs have evolved over time. For example, ADVAPI32.DLL implements the Advanced Services API that includes registry access, user logon, windows services, etc.

We refer to these APIs collectively as the Windows API. Or the Win32 API.

The API set formalizes this list. You can think of an API Set as a Subset of the Windows API. Each API set contains functionality for a specific area: console, datetime, fibers, file, registry, etc.

An API Set is provided as a DLL with a strong name. E.g.:

  • api-ms-win-crt-conio-l1-1-0.dll
  • api-ms-win-crt-convert-l1-1-0.dll
  • api-ms-win-crt-environment-l1-1-0.dll
  • api-ms-win-crt-filesystem-l1-1-0.dll
  • ...
api-ms-* files contain core functions. ext-ms-* files contain extension functions.

Unlike most Operating System DLLs, an API Set DLL doesn't implement the functions that it exports. It forwards the call (at runtime) to another DLL via a small Stub function.

Because API Set DLLs do not contain the function's implementation, they are called Stub DLLs.
The API Set for the new Universal C Runtime for example, forwards to ucrtbase.dll.

The complete list of ApiSet Stub DLLs supported by the OS is called the API Set Schema and is found in the file: c:\windows\sytem32\apisetschema.dll
This is a resource only DLL that is loaded at boot time.

Ads by Google


Ask a question, send a comment, or report a problem - click here to contact me.

© Richard McGrath