Re: Windows 8 and 8.1
Posted: Tue Nov 11, 2014 12:40 pm
RtlGetVersion() as said above it's a kernel function and it can be called from user mode thanks to the stub in ntdll.dll, but it works natively in unicode.smacker wrote:yes, RtlGetVersion() is ok to use but it should be noted that the RtlGetVersion() seems to only works properly "fully" when compiled unicode when using the OSVERSIONINFOEX structure.
The kernel is unicode only, and the higher level API converts unicode to ascii when called from a ascii client (PB program compiled in ascii).
The OSVERSIONEX defined in PB is made to be used with the normal API functions, so correctly uses .c for chars to work with the ascii and unicode version of the API called (they will do the internal conversion).
In short, to call the kernel function which is only unicode-aware you can do this:
Code: Select all
Structure KERNEL_OSVERSIONINFOEX
dwOSVersionInfoSize.l
dwMajorVersion.l
dwMinorVersion.l
dwBuildNumber.l
dwPlatformId.l
szCSDVersion.u[128]
wServicePackMajor.w
wServicePackMinor.w
wSuiteMask.w
wProductType.b
wReserved.b
EndStructure
Global osvex.KERNEL_OSVERSIONINFOEX
Global *fp, hDLL, major, minor, build, sp$
osvex\dwOSVersionInfoSize = SizeOf(osvex)
hDLL = OpenLibrary (#PB_Any, "ntdll.dll")
If hDLL
*fp = GetFunction(hDLL, "RtlGetVersion")
If *fp And CallFunctionFast(*fp, @osvex) = 0 ; #STATUS_SUCCESS
major = osvex\dwMajorVersion
minor = osvex\dwMinorVersion
build = osvex\dwBuildNumber
product = osvex\wProductType
sp$ = PeekS(@osvex\szCSDVersion[0], -1, #PB_Unicode)
ShowMemoryViewer(@osvex, SizeOf(osvex))
EndIf
CloseLibrary(hDLL)
EndIf
Debug major
Debug minor
Debug build
Debug product
Debug sp$
Code: Select all
[12:35:58] 6
[12:35:58] 1
[12:35:58] 7601
[12:35:58] 1
[12:35:58] Service Pack 1