This repository was archived by the owner on Jul 26, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 226
kernel32!VerifyVersionInfo and ntdll!RtlVerifyVersionInfo #438
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| // Copyright (c) All contributors. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| namespace PInvoke | ||
| { | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| /// <summary> | ||
| /// Contains the <see cref="OSVERSIONINFOEX"/> nested type. | ||
| /// </summary> | ||
| public static partial class Kernel32 | ||
| { | ||
| /// <summary> | ||
| /// The RTL_OSVERSIONINFOEXW structure contains operating system version information. | ||
| /// </summary> | ||
| [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] | ||
| public unsafe partial struct OSVERSIONINFOEX | ||
| { | ||
| /// <summary> | ||
| /// The size, in bytes, of an RTL_OSVERSIONINFOEXW structure. | ||
| /// This member must be set before the structure is used with RtlGetVersion. | ||
| /// </summary> | ||
| public int dwOSVersionInfoSize; | ||
|
|
||
| /// <summary> | ||
| /// The major version number of the operating system. For example, for Windows 2000, the major version number is five. | ||
| /// </summary> | ||
| public int dwMajorVersion; | ||
|
|
||
| /// <summary> | ||
| /// The minor version number of the operating system. For example, for Windows 2000, the minor version number is zero | ||
| /// </summary> | ||
| public int dwMinorVersion; | ||
|
|
||
| /// <summary> | ||
| /// The build number of the operating system. | ||
| /// </summary> | ||
| public int dwBuildNumber; | ||
|
|
||
| /// <summary> | ||
| /// The operating system platform. For Win32 on NT-based operating systems, RtlGetVersion returns the value | ||
| /// VER_PLATFORM_WIN32_NT. | ||
| /// </summary> | ||
| public int dwPlatformId; | ||
|
|
||
| /// <summary> | ||
| /// The service-pack version string. This member contains a null-terminated string, such as "Service Pack 3", which | ||
| /// indicates the latest service pack installed on the system. If no service pack is installed, RtlGetVersion might not | ||
| /// initialize this string. Initialize szCSDVersion to zero (empty string) before the call to RtlGetVersion. | ||
| /// </summary> | ||
| public fixed char szCSDVersion[128]; | ||
|
|
||
| /// <summary> | ||
| /// The major version number of the latest service pack installed on the system. For example, for Service Pack 3, | ||
| /// the major version number is three. If no service pack has been installed, the value is zero. | ||
| /// </summary> | ||
| public short wServicePackMajor; | ||
|
|
||
| /// <summary> | ||
| /// The minor version number of the latest service pack installed on the system. For example, for Service Pack 3, | ||
| /// the minor version number is zero. | ||
| /// </summary> | ||
| public short wServicePackMinor; | ||
|
|
||
| /// <summary> | ||
| /// The product suites available on the system. This member is set to zero or to the bitwise OR of one or more of | ||
| /// the <see cref="PRODUCT_SUITE"/> values. | ||
| /// </summary> | ||
| public PRODUCT_SUITE wSuiteMask; | ||
|
|
||
| /// <summary> | ||
| /// The product type. This member contains additional information about the system. | ||
| /// </summary> | ||
| public OS_TYPE wProductType; | ||
|
|
||
| /// <summary> | ||
| /// Reserved for future use. | ||
| /// </summary> | ||
| public byte wReserved; | ||
|
|
||
| /// <summary> | ||
| /// Helper method to create <see cref="OSVERSIONINFOEX"/> with | ||
| /// the right pre-initialization for <see cref="dwOSVersionInfoSize"/> | ||
| /// </summary> | ||
| /// <returns>A newly initialzed instance of <see cref="OSVERSIONINFOEX"/></returns> | ||
| public static OSVERSIONINFOEX Create() => new OSVERSIONINFOEX | ||
| { | ||
| #if NETSTANDARD1_3_ORLATER | ||
| dwOSVersionInfoSize = Marshal.SizeOf<OSVERSIONINFOEX>() | ||
| #else | ||
| dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX)) | ||
| #endif | ||
| }; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Copyright (c) All contributors. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| namespace PInvoke | ||
| { | ||
| /// <summary> | ||
| /// Contains the <see cref="OS_TYPE"/> nested type. | ||
| /// </summary> | ||
| public static partial class Kernel32 | ||
| { | ||
| /// <summary> | ||
| /// The product type enumeration | ||
| /// </summary> | ||
| public enum OS_TYPE : byte | ||
| { | ||
| VER_NT_WORKSTATION = 0x00000001, | ||
| VER_NT_DOMAIN_CONTROLLER = 0x00000002, | ||
| VER_NT_SERVER = 0x00000003 | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| // Copyright (c) All contributors. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| namespace PInvoke | ||
| { | ||
| using System; | ||
|
|
||
| /// <summary> | ||
| /// Contains the <see cref="PRODUCT_SUITE"/> nested type | ||
| /// </summary> | ||
| public static partial class Kernel32 | ||
| { | ||
| /// <summary> | ||
| /// The product suites available on the system. | ||
| /// </summary> | ||
| [Flags] | ||
| public enum PRODUCT_SUITE : short | ||
| { | ||
| /// <summary> | ||
| /// Microsoft BackOffice components are installed. | ||
| /// </summary> | ||
| VER_SUITE_BACKOFFICE = 0x00000004, | ||
vatsan-madhavan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// <summary> | ||
| /// Windows Server 2003, Web Edition is installed. | ||
| /// </summary> | ||
| VER_SUITE_BLADE = 0x00000400, | ||
|
|
||
| /// <summary> | ||
| /// Windows Server 2003, Compute Cluster Edition is installed. | ||
| /// </summary> | ||
| VER_SUITE_COMPUTE_SERVER = 0x00004000, | ||
|
|
||
| /// <summary> | ||
| /// Windows Server 2008 Datacenter, Windows Server 2003, Datacenter Edition, or Windows 2000 Datacenter Server is installed. | ||
| /// </summary> | ||
| VER_SUITE_DATACENTER = 0x00000080, | ||
|
|
||
| /// <summary> | ||
| /// Windows Server 2008 Enterprise, Windows Server 2003, Enterprise Edition, or Windows 2000 Advanced Server is installed. | ||
| /// </summary> | ||
| VER_SUITE_ENTERPRISE = 0x00000002, | ||
|
|
||
| /// <summary> | ||
| /// Windows XP Embedded is installed. | ||
| /// </summary> | ||
| VER_SUITE_EMBEDDEDNT = 0x00000040, | ||
|
|
||
| /// <summary> | ||
| /// Windows Vista Home Premium, Windows Vista Home Basic, or Windows XP Home Edition is installed. | ||
| /// </summary> | ||
| VER_SUITE_PERSONAL = 0x00000200, | ||
|
|
||
| /// <summary> | ||
| /// Remote Desktop is supported, but only one interactive session is supported. | ||
| /// This value is set unless the system is running in application server mode. | ||
| /// </summary> | ||
| VER_SUITE_SINGLEUSERTS = 0x00000100, | ||
|
|
||
| /// <summary> | ||
| /// Microsoft Small Business Server was once installed on the system, but may have been upgraded to another version of Windows. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// You should not rely solely on the <see cref="VER_SUITE_SMALLBUSINESS"/> flag to determine whether Small Business Server is currently installed. | ||
| /// Both this flag and the <see cref="VER_SUITE_SMALLBUSINESS_RESTRICTED"/> flag are set when this product suite is installed. If you upgrade this | ||
| /// installation to Windows Server, Standard Edition, the <see cref="VER_SUITE_SMALLBUSINESS_RESTRICTED"/> flag is cleared, but the | ||
| /// <see cref="VER_SUITE_SMALLBUSINESS"/> flag remains set, which, in this case, indicates that Small Business Server was previously installed on | ||
| /// this system. If this installation is further upgraded to Windows Server, Enterprise Edition, the <see cref="VER_SUITE_SMALLBUSINESS"/> flag | ||
| /// remains set. | ||
| /// </remarks> | ||
| VER_SUITE_SMALLBUSINESS = 0x00000001, | ||
|
|
||
| /// <summary> | ||
| /// Microsoft Small Business Server is installed with the restrictive client license in force. | ||
| /// For more information about this flag bit, see the remarks for <see cref="VER_SUITE_SMALLBUSINESS"/> flag. | ||
| /// </summary> | ||
| VER_SUITE_SMALLBUSINESS_RESTRICTED = 0x00000020, | ||
|
|
||
| /// <summary> | ||
| /// Windows Storage Server 2003 R2 or Windows Storage Server 2003 is installed. | ||
| /// </summary> | ||
| VER_SUITE_STORAGE_SERVER = 0x00002000, | ||
|
|
||
| /// <summary> | ||
| /// Terminal Services is installed. This value is always set. If <see cref="VER_SUITE_TERMINAL"/> is set but <see cref="VER_SUITE_SINGLEUSERTS"/> is not set, | ||
| /// the operating system is running in application server mode. | ||
| /// </summary> | ||
| VER_SUITE_TERMINAL = 0x00000010, | ||
|
|
||
| /// <summary> | ||
| /// Windows Home Server is installed. | ||
| /// </summary> | ||
| VER_SUITE_WH_SERVER = unchecked((short)0x00008000) | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // Copyright (c) All contributors. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| namespace PInvoke | ||
| { | ||
| /// <summary> | ||
| /// Contains the nested type <see cref="VER_CONDITION"/> | ||
| /// </summary> | ||
| public static partial class Kernel32 | ||
| { | ||
| /// <summary> | ||
| /// The operator to be used for the comparison. The <see cref="VerifyVersionInfo(OSVERSIONINFOEX*, VER_MASK, long)"/> function uses this operator to compare a specified | ||
| /// attribute value to the corresponding value for the currently running system. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// For all values of dwTypeBitMask other than VER_SUITENAME, this parameter can be one of the following values: | ||
| /// - <see cref="VER_EQUAL"/> | ||
| /// - <see cref="VER_GREATER"/> | ||
| /// - <see cref="VER_GREATER_EQUAL"/> | ||
| /// - <see cref="VER_LESS"/> | ||
| /// - <see cref="VER_LESS_EQUAL"/> | ||
| /// If dwTypeBitMask is VER_SUITENAME, this parameter can be one of the following values: | ||
| /// - <see cref="VER_AND"/> | ||
| /// - <see cref="VER_OR"/> | ||
| /// </remarks> | ||
| public enum VER_CONDITION : byte | ||
| { | ||
| /// <summary> | ||
| /// The current value must be equal to the specified value. | ||
| /// </summary> | ||
| VER_EQUAL = 1, | ||
|
|
||
| /// <summary> | ||
| /// The current value must be greater than the specified value. | ||
| /// </summary> | ||
| VER_GREATER = 2, | ||
|
|
||
| /// <summary> | ||
| /// The current value must be greater than or equal to the specified value. | ||
| /// </summary> | ||
| VER_GREATER_EQUAL = 3, | ||
|
|
||
| /// <summary> | ||
| /// The current value must be less than the specified value. | ||
| /// </summary> | ||
| VER_LESS = 4, | ||
|
|
||
| /// <summary> | ||
| /// The current value must be less than or equal to the specified value. | ||
| /// </summary> | ||
| VER_LESS_EQUAL = 5, | ||
|
|
||
| /// <summary> | ||
| /// All product suites specified in the wSuiteMask member must be present in the current system. | ||
| /// </summary> | ||
| VER_AND = 6, | ||
|
|
||
| /// <summary> | ||
| /// At least one of the specified product suites must be present in the current system. | ||
| /// </summary> | ||
| VER_OR = 7 | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // Copyright (c) All contributors. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| namespace PInvoke | ||
| { | ||
| using System; | ||
|
|
||
| /// <summary> | ||
| /// Contains the <see cref="VER_MASK"/> nested type. | ||
| /// </summary> | ||
| public static partial class Kernel32 | ||
| { | ||
| /// <summary> | ||
| /// A mask that indicates the member of the <see cref="OSVERSIONINFOEX"/> structure whose comparison operator is being set. | ||
| /// This value corresponds to one of the bits specified in the dwTypeMask parameter for the <see cref="VerifyVersionInfo(OSVERSIONINFOEX*, VER_MASK, long)"/> function. | ||
| /// </summary> | ||
| [Flags] | ||
| public enum VER_MASK : int | ||
| { | ||
| /// <summary> | ||
| /// dwBuildNumber | ||
| /// </summary> | ||
| VER_BUILDNUMBER = 0x0000004, | ||
|
|
||
| /// <summary> | ||
| /// dwBuildNumber | ||
| /// </summary> | ||
| VER_MAJORVERSION = 0x0000002, | ||
|
|
||
| /// <summary> | ||
| /// dwMinorVersion | ||
| /// </summary> | ||
| VER_MINORVERSION = 0x0000001, | ||
|
|
||
| /// <summary> | ||
| /// dwPlatformId | ||
| /// </summary> | ||
| VER_PLATFORMID = 0x0000008, | ||
|
|
||
| /// <summary> | ||
| /// wProductType | ||
| /// </summary> | ||
| VER_PRODUCT_TYPE = 0x0000080, | ||
|
|
||
| /// <summary> | ||
| /// wServicePackMajor | ||
| /// </summary> | ||
| VER_SERVICEPACKMAJOR = 0x0000020, | ||
|
|
||
| /// <summary> | ||
| /// wServicePackMinor | ||
| /// </summary> | ||
| VER_SERVICEPACKMINOR = 0x0000010, | ||
|
|
||
| /// <summary> | ||
| /// wSuiteMask | ||
| /// </summary> | ||
| VER_SUITENAME = 0x0000040 | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.