![]() | This article has multiple issues. Please helpimprove it or discuss these issues on thetalk page.(Learn how and when to remove these messages) (Learn how and when to remove this message)
|
TheMicrosoft Windowsoperating system andMicrosoft Windows SDK support a collection ofshared libraries thatsoftware can use to access theWindows API. This article provides an overview of the core libraries that are included with every modern Windowsinstallation, on top of which most Windowsapplications are built.
The Windows operating system containscompiled versions of these libraries known asdynamically-linked libraries (.dll), which areexecutable libraries that can be used by multipleprograms while only one copy of the library is loaded intomemory. These are canonically referred to assystem libraries and all programs installed on the system can utilize them.
The Windows SDK additionally distributes compiled versions of these libraries known asstatically-linked libraries (.lib), which are non-executable libraries that, in whole or in part, can be embedded into a program when it is compiled. The most common Windows compilers beingMicrosoft Visual Studio andMinGW.
HAL.DLL is a kernel-mode library file and it cannot be used by any user-mode program. NTDLL.DLL is only used by some programs, but it is a dependency of most Win32 libraries used by programs.
The WindowsHardware Abstraction Layer (HAL) is implemented inhal.dll.[1] The HAL implements a number of functions that are implemented in different ways by different hardware platforms, which in this context, refers mostly to thechipset. Other components in theoperating system can then call these functions in the same way on all platforms, without regard for the actual implementation.
For example, responding to an interrupt is quite different on a machine with anAdvanced Programmable Interrupt Controller (APIC) than on one without. The HAL provides a single function for this purpose that works with all kinds of interrupts by various chipsets, so that other components need not be concerned with the differences.
The HAL is loaded into kernel address space and runs in kernel mode, so routines in the HAL cannot be called directly by applications, and no user mode APIs correspond directly to HAL routines. Instead, the HAL provides services primarily to the Windows executive and kernel and to kernel mode device drivers. Although drivers for most hardware are contained in other files, commonly of file type.sys, a few core drivers are compiled intohal.dll.
Kernel mode device drivers for devices on buses such asPCI andPCI Express directly call routines in the HAL to accessI/O ports and registers of their devices. The drivers use HAL routines because different platforms may require different implementations of these operations. The HAL implements the operations appropriately for each platform, so the same driver executable file can be used on all platforms using the sameCPU architecture, and the driver source file can be portable across all architectures.
Onx86 systems prior toWindows 8, there are several different HAL files on the installation media. The Windows installation procedure determines which ones are appropriate for the current platform and copies it to the hard drive, renaming it tohal.dll if necessary. Among the criteria for this selection are: the presence of anACPI-compatible BIOS, the presence of anAPIC, and whether or not multiple processors are present and enabled. (The multiple cores of amulti-core CPU, and even the "logical processors" implemented by ahyperthreading CPU, all count as "processors" for this purpose.) Onx86-64 andItanium platforms there is just one possiblehal.dll for each CPU architecture. On Windows 8 and later, the x86 version also only has one HAL.
HAL is merged (or statically linked) into ntoskrnl.exe[2] starting with version 2004 of Windows 10, and the dll only serves as a stub for backwards compatibility.
NTDLL.DLL exports the WindowsNative API. The Native API is the interface used by user-mode components of the operating system that must run without support fromWin32 or other API subsystems. Most of this API is implemented inNTDLL.DLL and at the upper edge ofntoskrnl.exe (and its variants), and the majority of exported symbols within these libraries are prefixedNt, for exampleNtDisplayString. Native APIs are also used to implement many of the "kernel APIs" or "base APIs" exported by KERNEL32.DLL.[3][4][5] The large majority of Windows applications do not call NTDLL.DLL directly.[6]
Applications that arelinked directly against this library are said to use thenative subsystem; the primary reason for their existence is to perform tasks that must run early in the system startup sequence before the Win32 subsystem is available. An obvious but important example is the creation of the Win32 subsystem process,csrss.exe. Before the csrss.exe process exists, no Win32 processes may be created, therefore the process that creates it (Smss.exe, the "session manager") must use the native subsystem.csrss.exe itself is such an application.
Despite having an ".exe" file extension, native applications cannot be executed by the user (or any program in the Win32 or other subsystems). An example is theautochk.exe binary that runschkdsk during the system initialization "Blue Screen". Other prominent examples are the services that implement the various subsystems, such ascsrss.exe.
UnlikeWin32 applications, native applications instantiate within the Kernel runtime code (ntoskrnl.exe) and so they must have a different entry point (NtProcessStartup, rather than(w)(Win)MainCRTStartup as is found in a Win32 application),[4] obtain their command-line arguments via a pointer to an in-memory structure, manage their own memory using theRtl heap API, (which the Win32 heap APIs are just wrappers around—no real difference there) and return execution with a call toRtlExitUserProcess (as opposed toExitProcess). A common library linked with Native applications is nt.lib, which contains startup code for Native applications, similar to how the C runtime provides startup code for Win32 apps.[7]
Though most of the API is not publicly documented or supported. This allows the API to evolve without having to guarantee retro-compatibility, and breaking changes are thus possible without notification. Native Applications can be built using theWindows Driver Development Kit.
The libraries in this section each implement various subsets of the Win32 API.
KERNEL32.DLL exposes to applications most of the Win32 base APIs, such asmemory management,input/output (I/O) operations,process andthread creation, and synchronization functions.[8]
GDI32.DLL exportsGraphics Device Interface (GDI) functions that perform primitive drawing functions for output to video displays and printers. It is used, for example, in the XP version of Paint. Applications call GDI functions directly to perform low-level drawing (line, rectangle, ellipse), text output, font management, and similar functions.[8][9]
Initially, GDI supported 16 and 256 colorEGA/VGAdisplay cards andmonochrome printers. The functionality has expanded over the years, and now includes support for things likeTrueType fonts,alpha channels, andmultiple monitors.[10]
USER32.DLL implements the Windows USER component that creates and manipulates the standard elements of the Windows user interface, such as the desktop, windows, and menus.It thus enables programs to implement agraphical user interface (GUI) that matches the Windows look and feel. Programs call functions from Windows USER to perform operations such as creating and managing windows, receiving window messages (which are mostly user input such as mouse and keyboard events, but also notifications from the operating system), displaying text in a window, and displaying message boxes.
Many of the functions in USER32.DLL call upon GDI functions exported by GDI32.DLL to do the actual rendering of the various elements of the user interface. Some types of programs will also call GDI functions directly to perform lower-level drawing operations within a window previously created via USER32 functions.
COMCTL32.DLL implements a wide variety of standard Windows controls, such as File Open, Save, and Save As dialogs, progress bars, and list views. It calls functions from both USER32.DLL and GDI32.DLL to create and manage the windows for these UI elements, place various graphic elements within them, and collect user input.
COMDLG32.DLL, the Common Dialog Box Library, implements a wide variety of Windows dialog boxes intended to perform what Microsoft deems 'common application tasks'. Starting with the release of Windows Vista, Microsoft considers the "Open" and "Save as" dialog boxes provided by this library as deprecated and replaced by the 'Common Item Dialog API'.[11]
WS2_32.DLL implements theWinsock API, which provides TCP/IP networking functions and provides partial, broken compatibility with other network APIs.wsock.dll andwsock32.dll are older versions for Win3.11 and Win95 compatibility.
ADVAPI32.DLL, the Advanced Windows 32 Base API DLL,[12] provides security calls and functions for manipulating theWindows Registry.
NETAPI32.DLL provides functions for querying and managing network interfaces.
OLE32.DLL provides theComponent Object Model, as well asObject Linking and Embedding.
SHSCRAP.DLL is part of theObject Linking and Embedding (OLE) mechanism. It implements support forshell scrap files, which are automatically created when you drag selected content from an OLE-capable application into an Explorer window or desktop,[13] but you can also use theObject Packager to create them. They can then be dragged into another OLE-capable application.
This functionality was removed from Windows Vista (and therefore later versions) to improve security and rid the operating system of generally unused functionality.[14] Scrap (.shs) files have been used by viruses because they can contain a wide variety of files (including executable code), and the file extension is not shown even when "Hide file extensions from known file types" is disabled.[15] The functionality can be restored by copying registry entries and theDLL from aWindows XP system.[16]
WINMM.DLL provides access to the originalWinMM audio API.
IMM32 is responsible for invoking and interacting with theInput Method Editor.
MSVCRT.DLL is theC standard library for theVisual C++ (MSVC) compiler from version 4.2 to 6.0. It provides programs compiled by these versions of MSVC with most of the standard C library functions. These include string manipulation, memory allocation, C-style input/output calls, and others.MSVCP*.DLL is the corresponding C++ library.
It has shipped with Windows versions since Windows 95 OSR2.5 for use by other Windows components; earlier versions shipped with theCRTDLL.DLL library instead. In older versions of Windows, programs which linked against MSVCRT.DLL were expected to install a compatible copy in the System32 folder, but this contributed toDLL Hell because many installers failed to check the library version against the installed version before replacing it.
Versions of MSVC before 4.0 and from 7.0 to 12.0 used differently named DLLs for each version (MSVCR20.DLL, MSVCR70.DLL, MSVCR71.DLL, MSVCP110.DLL, etc.). Applications are required to install the appropriate version,[17] and Microsoft offersVisual C++ Redistributable packages for this purpose, though Windows typically comes with one version already installed.
This runtime library is used by programs written in Visual C++ and a few other compilers (e.g.MinGW). Some compilers have their own runtime libraries.
With Version 14.0 (Visual Studio 2015), most of the C/C++ runtime was moved into a new DLL, UCRTBASE.DLL, which conforms closely with C99[1].Universal C Run Time (UCRT) from Windows 10 onwards become a component part of Windows[2], so every compiler (either non MS, likeGCC orClang/LLVM) can link against UCRT[3]. Additionally, C/C++ programs using UCRTBASE.DLL need to link against another new DLL, the Visual C++ Runtime. At Version 14.0, this was VCRUNTIME140.DLL.[18] The name has the potential to change at future versions, but has not done so as far as of Version 17.0.
Source code for runtime libraries is included in Visual C++[19] for reference and debugging (e.g. inC:\Program Files\Microsoft Visual Studio 11.0\VC\crt\src
).
Programs written inC#,Visual Basic.NET,C++/CLI and other .NET languages require the.NET Framework. It has many libraries (one of them ismscorlib.dll – Multilanguage Standard Common Object Runtime Library, formerly Microsoft Common Object Runtime Library[20]) and so-calledassemblies (e.g.System.Windows.Forms.dll).