Reply To: How to get Service Pack Number of OS from Kernel Mode

Home Forums Discussions General Discussion How to get Service Pack Number of OS from Kernel Mode Reply To: How to get Service Pack Number of OS from Kernel Mode

#6344

Vadim Smirnov
Moderator

RTFM DDK

Windows XP and below:

BOOLEAN
PsGetVersion(
PULONG MajorVersion OPTIONAL,
PULONG MinorVersion OPTIONAL,
PULONG BuildNumber OPTIONAL,
PUNICODE_STRING CSDVersion OPTIONAL
);
Parameters
MajorVersion
Points to a caller-supplied variable that this routine sets to the major version of the operating system. This optional parameter can be NULL.
MinorVersion
Points to a caller-supplied variable that this routine sets to the minor version of the operating system. This optional parameter can be NULL.
BuildNumber
Points to a caller-supplied variable that this routine sets to the current build number of the operating system. This optional parameter can be NULL.
CSDVersion
Points to a caller-allocated buffer in which this routine returns the current service-pack version as a Unicode string only during system driver initialization. This optional parameter can be NULL.

Windows XP and above

NTSTATUS
RtlGetVersion(
IN OUT PRTL_OSVERSIONINFOW lpVersionInformation
);
Parameters
lpVersionInformation
Pointer to either a RTL_OSVERSIONINFOW structure or a RTL_OSVERSIONINFOEXW structure that contains the version information about the currently running operating system. A caller specifies which input structure is used by setting the dwOSVersionInfoSize member of the structure to the size in bytes of the structure that is used.

typedef struct _OSVERSIONINFOEXW {
ULONG dwOSVersionInfoSize;
ULONG dwMajorVersion;
ULONG dwMinorVersion;
ULONG dwBuildNumber;
ULONG dwPlatformId;
WCHAR szCSDVersion[ 128 ]; // Maintenance string for PSS usage
USHORT wServicePackMajor;
USHORT wServicePackMinor;

USHORT wSuiteMask;
UCHAR wProductType;
UCHAR wReserved;
} RTL_OSVERSIONINFOEXW;