简体   繁体   English

清单支持的OS设置在幕后实际上做了什么?

[英]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. 我找不到太多文档,但最近我不得不运行Windows Server 2012 R2平台就绪测试工具来验证一些MSVC ++和C#产品(.exe,服务,库,dll等),我发现了一些错误消息说某些项目清单中没有supportOS设置。

I fixed the errors but I can't help but wonder what the supportedOS setting actually does behind the scenes. 我修复了错误,但我不禁想知道支持的OS设置实际上在幕后做了什么。 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? 例如,假设我为所有项目设置了支持的OS设置为Windows 8.1,如果在Windows 8或Windows 7上运行这些产品,即使已知它们在这些操作系统上运行肯定会产生错误吗?

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 我在supportedOS上找到的最多的东西是这样的: http//msdn.microsoft.com/en-us/library/windows/desktop/dn302074(v = vs。85).aspx

Pseudo code for how Windows reads the supportedOS values might look something like this: Windows如何读取受支持的OS值的伪代码可能如下所示:

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存储在进程内部的某个地方,可能在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. 将compatVer与某些功能中的真实Windows版本进行比较,以启用新功能或更改其行为,使其与应用程序所针对的Windows版本兼容。 Some of the behavior changes are documented in the compatibility cookbook on MSDN. 某些行为更改记录在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. 由于supportedOS值是GUID,因此无法猜测,因此开发人员无法声明对尚未发布的Windows版本的支持。 Therefore the Windows 8 GUID will have no effect when the application runs on Windows 7. 因此,当应用程序在Windows 7上运行时,Windows 8 GUID将不起作用。

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... 您的应用程序存在一个由兼容性行为隐藏的错误,并且可能通过添加supportedOS值来暴露它...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM