Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a manifest's supportedOS setting actually do behind the scenes?

I can't find much documentation but recently I had to run the Windows Server 2012 R2 Platform Ready Test Tool to validate some MSVC++ and C# products (.exe's, services, libraries, dll's, etc.) and I came across some error messages saying that the supportedOS setting was not available in some project manifests.

I fixed the errors but I can't help but wonder what the supportedOS setting actually does behind the scenes. For example, say I set the supportedOS setting to Windows 8.1 for all of my projects, will that start to throw errors if running these products on Windows 8 or Windows 7, even though they are known to work for sure on those operating systems?

The most I could find on supportedOS is stuff like this: http://msdn.microsoft.com/en-us/library/windows/desktop/dn302074(v=vs.85).aspx

like image 584
Alexandru Avatar asked Apr 10 '14 19:04

Alexandru


1 Answers

Pseudo code for how Windows reads the supportedOS values might look something like this:

double compatVer = 4.0; // Win95
if (hasW10guid && _WIN_VER >= 0xa00)
  compatVer = 10.0;
else if (hasW81guid && _WIN_VER >= 0x603)
  compatVer = 6.3;
else if (hasW8guid && _WIN_VER >= 0x602)
  compatVer = 6.2;
else if (hasW7guid && _WIN_VER >= 0x601)
  compatVer = 6.1;
else if (hasWVistaguid && _WIN_VER >= 0x601)
  compatVer = 6.0; // Application wants Vista compatibility on Win7+
else if (hasRequestedExecutionLevel)
  compatVer = 6.0; // UAC compatible

compatVer is stored somewhere internally in the process, probably in the PEB.

compatVer is compared to the real Windows version inside certain functions to either enable new features or change its behavior so it is compatible with the Windows version the application was designed for. Some of the behavior changes are documented in the compatibility cookbook on MSDN.

Because the supportedOS values are GUIDs they are impossible to guess so developers cannot claim support for Windows versions that have not been released yet. Therefore the Windows 8 GUID will have no effect when the application runs on Windows 7.

There is a risk that your application has a bug that is hidden by compatibility behavior and it might be exposed by adding supportedOS values...

like image 105
Anders Avatar answered Nov 08 '22 11:11

Anders