WIKI
+ -

Windows内核版本大全及获取函数

2021-08-30 799 0

做Windows驱动,经常需要获取内核版本,本人现把常用的操作系统的内核版本整理一下:

Windows10内核版本

ULONG OsMajorVersion()
{
    RTL_OSVERSIONINFOEXW info;
    if (!OsGetVersionInfo(info)) return INVALID_VERSION;
    return info.dwMajorVersion;
}

ULONG OsMinorVersion()
{
    RTL_OSVERSIONINFOEXW info;
    if (!OsGetVersionInfo(info)) return INVALID_VERSION;
    return info.dwMinorVersion;
}

ULONG OsBuildNumber()
{
    RTL_OSVERSIONINFOEXW info;
    if (!OsGetVersionInfo(info)) return INVALID_VERSION;
    return info.dwBuildNumber;
}

BOOLEAN OsGetVersionInfo(IN OUT RTL_OSVERSIONINFOEXW &info)
{
    NTSTATUS status;
    RtlZeroMemory(&info, sizeof(info));
    info.dwOSVersionInfoSize = sizeof(info);
    status = RtlGetVersion((RTL_OSVERSIONINFOW*)&info);
    return NT_SUCCESS(status);
}

#define INVALID_VERSION -1

typedef enum _NTOS_VERSION {
    NTOS_UNKNOWN,
    NTOS_WINXP,
    NTOS_WINXPSP1,
    NTOS_WINXPSP2,
    NTOS_WINXPSP3,
    NTOS_WIN2003,
    NTOS_WIN2003SP1,
    NTOS_WIN2003SP2,
    NTOS_WINVISTA,
    NTOS_WINVISTASP1,
    NTOS_WINVISTASP2,
    NTOS_WIN7,
    NTOS_WIN7SP1,
    NTOS_WIN8,
    NTOS_WIN81,
    NTOS_WIN10_1507, //10240
    NTOS_WIN10_1511, //10586
    NTOS_WIN10_1607, //14393
    NTOS_WIN10_1703, //15063
    NTOS_WIN10_1709, //16299
    NTOS_WIN10_1803, //17134
    NTOS_WIN10_1809, //17763
    NTOS_WIN10_1903, //18362
    NTOS_WIN10_1909, //18363
    NTOS_WIN10_2004, //19041
    NTOS_WIN10_20H2, //19042
    NTOS_WIN10_21H1, //19043
    NTOS_WIN10_21H2, //19044
    NTOS_WIN10_22H2, //19045
    NTOS_WIN11_21H2, //22000
    NTOS_WIN11_22H2, //22621
    NTOS_WIN_MAX, //22621
} NTOS_VERSION, *PNTOS_VERSION;

NTOS_VERSION OsNtVersion()
{
    RTL_OSVERSIONINFOEXW info;
    if (!OsGetVersionInfo(info)) return NTOS_UNKNOWN;

    switch (info.dwMajorVersion) {
    case 5: {
        if (info.dwMinorVersion == 1) {
            if (info.wServicePackMajor == 1) return NTOS_WINXPSP1;
            if (info.wServicePackMajor == 2) return NTOS_WINXPSP2;
            if (info.wServicePackMajor == 3) return NTOS_WINXPSP3;
            return NTOS_WINXP;
        }
        if (info.dwMinorVersion == 2) {
            if (info.wServicePackMajor == 1) return NTOS_WIN2003SP1;
            if (info.wServicePackMajor == 2) return NTOS_WIN2003SP2;
            return NTOS_WIN2003;
        }
        break;
    } case 6: {
        if (info.dwMinorVersion == 0) {
            if (info.wServicePackMajor == 1) return NTOS_WINVISTASP1;
            if (info.wServicePackMajor == 2) return NTOS_WINVISTASP2;
            return NTOS_WINVISTA;
        }
        if (info.dwMinorVersion == 1) {
            if (info.wServicePackMajor == 1) return NTOS_WIN7SP1;
            return NTOS_WIN7;
        }
        if (info.dwMinorVersion == 2) {
            return NTOS_WIN8;
        }
        if (info.dwMinorVersion == 3) {
            return NTOS_WIN81;
        }
        break;
    } case 10: {
        if (info.dwBuildNumber == 10240) return NTOS_WIN10_1507;
        if (info.dwBuildNumber == 10586) return NTOS_WIN10_1511;
        if (info.dwBuildNumber == 14393) return NTOS_WIN10_1607;
        if (info.dwBuildNumber == 15063) return NTOS_WIN10_1703;
        if (info.dwBuildNumber == 16299) return NTOS_WIN10_1709;
        if (info.dwBuildNumber == 17134) return NTOS_WIN10_1803;
        if (info.dwBuildNumber == 17763) return NTOS_WIN10_1809;
        if (info.dwBuildNumber == 18362) return NTOS_WIN10_1903;
        if (info.dwBuildNumber == 18363) return NTOS_WIN10_1909;
        if (info.dwBuildNumber == 19041) return NTOS_WIN10_2004;
        if (info.dwBuildNumber == 19042) return NTOS_WIN10_20H2;
        if (info.dwBuildNumber == 19043) return NTOS_WIN10_21H1;
        if (info.dwBuildNumber == 19044) return NTOS_WIN10_21H2;
        if (info.dwBuildNumber == 19045) return NTOS_WIN10_22H2;
        if (info.dwBuildNumber == 22000) return NTOS_WIN11_21H2;
        if (info.dwBuildNumber == 22621) return NTOS_WIN11_22H2;
        if (info.dwBuildNumber > 22621) return NTOS_WIN_MAX;
    }
    default:
        break;
    }
    return NTOS_UNKNOWN;
}

Windows 10 2110 21H2 (November 2021 Update)
build: 10.0.19041.1288
date: 2021-10-06

Windows 10 2104 21H1 (May 2021 Update)
build: 10.0.19041.928
date: 2021-04-09

Windows 10 2009 20H2 (October 2020 Update)
build: 10.0.19041.508
date: 2020-09-27

Windows 10 2004 20H1 (May 2020 Update)
build: 10.0.19041.264
date: 2020-05-11

Windows 10 1909 19H2 (November 2019 Update)
build: 10.0.18362.418
date: 2019-10-07

Windows 10 1903 19H1 (May 2019 Update)
build: 10.0.18362.1
date: 2019-03-19

Windows 10 1809 Redstone 5 (October Update)
build: 10.0.17763.107
date: 2018-10-30

Windows 10 1803 Redstone 4 (Spring Creators Update)
build: 10.0.17134.1
date: 2018-04-11

Windows 10 1709 Redstone 3 (Fall Creators Update)
build: 10.0.16299.15
date: 2017-09-29

Windows 10 1703 Redstone 2 (Creators Update)
build: 10.0.15063.0
date: 2017-03-18

Windows 10 1607 Redstone 1 (Anniversary Update)
build: 10.0.14393.0
date: 2016-07-16

Windows 10 1511 Threshold 2
build: 10.0.10586.0
date: 2015-10-30

Windows 10 1507 Threshold 1
build: 10.0.10240.16384
date: 2015-07-10

Windows8内核版本

序号 内核版本
1 6.2.9200

Windows7内核版本

序号 内核版本
1 6.1.7600
2 6.2.7601

Windows Vista内核版本

windows Vista的内核版一为6.0

Windows Server2003

WindowsServer2003内核版本为5.2

Windows XP内核版本

Windows XP内核版本为5.1

Windows 2000 内核版本

Windows 2000 内核版本为 5.0


Windows内核版本的获取

Windows内核版本获取可通过函数 IoIsWdmVersionAvailable 和RtlGetVersion获取,而RtlGetVersion获取的更加全面,并且从Windows2000已经开始支持了。

    RTL_OSVERSIONINFOW Version = { 0 };
    Version.dwOSVersionInfoSize = sizeof(Version);
    NTSTATUS status = RtlGetVersion(&Version);
    if (!NT_SUCCESS(status)
    {
        //获取版本显示
    }

RTL_OSVERSIONINFOW的定义如下:

typedef struct _OSVERSIONINFO
{
    DWORD dwOSVersionInfoSize;
    DWORD dwMajorVersion;
    DWORD dwMinorVersion;
    DWORD dwBuildNumber;
    DWORD dwPlatformId;
    TCHAR szCSDVersion[ 128 ];
} OSVERSIONINFO;

成员说明:
dwOSVersionInfoSize
以字节为单位,指定这个数据结构的大小。须在调用GetVersionEx(OSVERSIONINFO)函数之前,将这个成员设置为sizeof(OSVERSIONINFO)。

dwMajorVersion
标识操作系统的主版本号。例如,对于Windows NT 3.51版,其主版本号为3;对于Windows NT 4.0版,其主版本号为4。

dwMinorVersion
标识操作系统的次要版本号。例如,对于Windows NT 3.51版,其次要版本号为51;对于Windows NT 4.0版本,其次要版本号为0。

dwBuildNumber
Windows NT:标识操作系统的内部版本号。
Windows 95:低位字标识操作系统数的内部版本号。高位字包含了主要和次要版本号。

dwPlatformId
标识操作系统平台。这个成员可以是下列值之一:

平台
VER_PLATFORM_WIN32s Win32s on Windows 3.1
VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95
VER_PLATFORM_WIN32_NT Win32 on Windows NT

szCSDVersion
Windows NT:包含一个以NULL结尾的字符串,如“Service Pack 3”,就表明系统上安装了最新的Service Pack。如果没有安装Service Pack,该字符串为空。
Windows 95:包含一个以NULL结尾的字符串,提供了对操作系统的任意补充信息。

0 篇笔记 写笔记

Windows内核版本大全及获取函数
做Windows驱动,经常需要获取内核版本,本人现把常用的操作系统的内核版本整理一下:Windows10内核版本ULONG OsMajorVersion(){ RTL_OSVERSIONINFOEXW info; if (!OsGetVersionInfo(info)) retu......
作者信息
我爱内核
Windows驱动开发,网站开发
好好学习,天天向上。
取消
感谢您的支持,我会继续努力的!
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

您的支持,是我们前进的动力!