Closed emako closed 9 months ago
It looks different from the API results of NtDll.
NtDll.RtlGetVersion
is OK.
public static class NtDll
{
[SecurityCritical]
[DllImport(Lib.NTdll, SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
public static extern int RtlGetVersion(out OSVERSIONINFOEX versionInfo);
}
[StructLayout(LayoutKind.Sequential)]
public struct OSVERSIONINFOEX
{
public int OSVersionInfoSize;
public int MajorVersion;
public int MinorVersion;
public int BuildNumber;
public int Revision;
public int PlatformId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string CSDVersion;
public ushort ServicePackMajor;
public ushort ServicePackMinor;
public short SuiteMask;
public byte ProductType;
public byte Reserved;
}
Could you reopen the issuse?
Both those methods (GetVersionEx and RtlGetVersion) are marked as obsolete in lieu of the functions in VersionHelpers.h. You can find the Varana equivalents at PInvoke/Kernel32/VersionHelpers.cs
To use GetVersionEx
you have to set the size or use the Default
field:
var ver = OSVERSIONINFOEX.Default;
if (!GetVersionEx(ref ver)) ...
Kernel32.OSVERSIONINFOEX.Default
make Kernel32.GetVersionEx
return true, but it seems that the value is not eq to NtDll.RtlGetVersion
.
Kernel32.GetVersionEx
NtDll.RtlGetVersion
Addtional infos:
My TargetFramework like following and I don't use any app.manifest
file.
<TargetFramework>net7.0-windows10.0.22621.0</TargetFramework> // in my exe csproj
<TargetFramework>net7.0-windows</TargetFramework> // in my lib csproj
RtlGetVersion not found in NtDll.