Set up the default data execution prevention (DEP) options, including for exception-chain validation, also called “software” DEP. (See Chapter 10 in Part 2 for more information on DEP.)
Check whether this application requires any application compatibility work, and load the shim engine if required.
Detect if this application is protected by SecuROM, SafeDisc, and other kinds of wrapper or protection utilities that could have issues with DEP (and reconfigure DEP settings in those cases).
Run the initializers for all the loaded modules.
Run the post-initialization Shim Engine callback if the module is being shimmed for application compatibility.
Run the associated subsystem DLL post-process initialization routine registered in the PEB. For Windows applications, this does Terminal Services–specific checks, for example.
Running the initializers is the last main step in the loader’s work. This is the step that calls the
SwitchBack
As each new version of Windows fixes bugs such as race conditions and incorrect parameter validation checks in existing API functions, an application-compatibility risk is created for each change, no matter how minor. Windows makes use of a technology called SwitchBack, implemented in the loader, which enables software developers to embed a GUID specific to the Windows version they are targeting in their executable’s associated manifest. For example, if a developer wants to take advantage of improvements added in Windows 7 to a given API, she would include the Windows 7 GUID in her manifest, while if a developer has a legacy application that depends on Windows Vista–specific behavior, she would put the Windows Vista GUID in the manifest instead. SwitchBack parses this information and correlates it with embedded information in SwitchBack-compatible DLLs (in the .sb_data image section) to decide which version of an affected API should be called by the module. Because SwitchBack works at the loaded-module level, it enables a process to have both legacy and current DLLs concurrently calling the same API, yet observing different results.
Windows currently defines two GUIDs that represent either Windows Vista or Windows 7 compatibility settings:
{e2011457-1546-43c5-a5fe-008deee3d3f0} for Windows Vista
{35138b9a-5d96-4fbd-8e2d-a2440225f93a} for Windows 7
These GUIDs must be present in the application’s manifest file under the SupportedOS ID present in a compatibility attribute entry. (If the application manifest does not contain a GUID, Windows Vista is chosen as the default compatibility mode.) Running under the Windows 7 context affects the following components:
RPC components use the Windows thread pool instead of a private implementation.
DirectDraw Lock cannot be acquired on the primary buffer.
Blitting on the desktop is not allowed without a clipping window.
A race condition in
Whenever a Windows API is affected by changes that might break compatibility, the function’s entry code calls the