On 17/03/2020 18:28, Nikolay Sivov wrote:
On 3/17/20 7:07 PM, Gabriel Ivăncescu wrote:
+/***********************************************************************
- Win8 info, reported if app doesn't provide compat GUID in manifest.
- */
+static const RTL_OSVERSIONINFOEXW windows8_version_data = +{ + sizeof(RTL_OSVERSIONINFOEXW), 6, 2, 0x23f0, VER_PLATFORM_WIN32_NT, + {0}, 0, 0, VER_SUITE_SINGLEUSERTS, VER_NT_WORKSTATION, 0 +};
+/***********************************************************************
- Windows versions that need compatibility GUID specified in manifest
- in order to be reported by the APIs.
- */
+static const struct +{ + RTL_OSVERSIONINFOEXW info; + GUID guid; +} version_data[] = +{ + /* Windows 8.1 */ + { + { + sizeof(RTL_OSVERSIONINFOEXW), 6, 3, 0x2580, VER_PLATFORM_WIN32_NT, + {0}, 0, 0, VER_SUITE_SINGLEUSERTS, VER_NT_WORKSTATION, 0 + },
{0x1f676c76,0x80e1,0x4239,{0x95,0xbb,0x83,0xd0,0xf6,0xd0,0xda,0x78}} + }, + /* Windows 10 */ + { + { + sizeof(RTL_OSVERSIONINFOEXW), 10, 0, 0x42ee, VER_PLATFORM_WIN32_NT, + {0}, 0, 0, VER_SUITE_SINGLEUSERTS, VER_NT_WORKSTATION, 0 + },
{0x8e0f7a12,0xbfb3,0x4fe8,{0xb9,0xa5,0x48,0xfd,0x50,0xa1,0x5a,0x9a}} + } +};
For that you only need to store 3 values - major/minor/build.
Ah alright, I just copy-pasted the entires from ntdll.
+/***********************************************************************
- Holds the current version (including compatibility mode).
- Call init_current_version before using it.
- */
+static RTL_OSVERSIONINFOEXW current_version;
+/******************************************************************************
- * init_current_version
- Initialize the current_version variable.
- For compatibility, Windows 8.1 and later report Win8 version
unless the app
- has a manifest that confirms its compatibility with newer versions
of Windows.
- */
+static BOOL CALLBACK init_current_version_callback(PINIT_ONCE init_once, PVOID parameter, PVOID *context) +{
Should it actually be static and initialized once? What happens if you activate another context dynamically?
I actually have no idea, didn't know you can do that. I'm somewhat unfamiliar with activation context APIs. What API should I be using to test this?
+ /*ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION*/DWORD *acci;
Why not use proper type pointer?
I don't know, ntdll does the same thing when filling it, for some reason we don't even have that structure so I couldn't use it, although I did find it in headers. So I was a bit confused and just copied what ntdll does, assuming it had a good reason to.
+ if (elements[i].Type == ACTCX_COMPATIBILITY_ELEMENT_TYPE_OS && + IsEqualGUID(&elements[i].Id, &version_data[idx].guid))
Type value name has a typo.
Right, but that's in our headers, I thought it was intentional. Should I send a fix for this?