Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About IsWindowsVersionOrGreaterFx function in OsInfoFx.cpp #3

Open
zyyujq opened this issue Feb 14, 2023 · 4 comments
Open

About IsWindowsVersionOrGreaterFx function in OsInfoFx.cpp #3

zyyujq opened this issue Feb 14, 2023 · 4 comments

Comments

@zyyujq
Copy link

zyyujq commented Feb 14, 2023

IsWindowsVersionOrGreaterFx (10,0) , on the exe execution file, there is an additional manifest file manifest:

manifest file:

< compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
< application>
< !-- Windows Vista -->
< supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
< !-- Windows 7 -->
< supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
< !-- Windows 8 -->
< supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
< !-- Windows 8.1 -->
< supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
< !-- Windows 10 -->
< supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
< /application>
< /compatibility>


So , can return TRUE on Windows 10 and 11.

If there is no manifest file, the exe execution file has an error on Windows 11.

if you build the CrystalDiskInfo.DLL file, even if the manifest file is attached, the shell program runs on Windows 11 and calls CrystalDiskInfo.DLL. Unfortunately, the program error.


I solved this problem temporarily with a simple method, even without the manifest file of the program.

In OsInfoFx.cpp:

#include "pch.h"
#include "stdafx.h"
#include "OsInfoFx.h"
#include "UtilityFx.h"

typedef BOOL (WINAPI* FuncGetProductInfo)(DWORD, DWORD, DWORD, DWORD, PDWORD);
typedef BOOL (WINAPI* FuncGetNativeSystemInfo)(LPSYSTEM_INFO);
typedef BOOL (WINAPI* FuncIsWow64Process)(HANDLE hProcess,PBOOL Wow64Process);
typedef LONG (WINAPI* FuncRtlGetVersion)(POSVERSIONINFOEXW osvi);

//---add
typedef LONG NTSTATUS, * PNTSTATUS;
#define STATUS_SUCCESS (0x00000000)`

typedef NTSTATUS(WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);

RTL_OSVERSIONINFOW GetRealOSVersion() {
	HMODULE hMod = ::GetModuleHandleW(L"ntdll.dll");
	if (hMod) {
		RtlGetVersionPtr fxPtr = (RtlGetVersionPtr)::GetProcAddress(hMod, "RtlGetVersion");
		if (fxPtr != nullptr) {
			RTL_OSVERSIONINFOW rovi = { 0 };
			rovi.dwOSVersionInfoSize = sizeof(rovi);
			if (STATUS_SUCCESS == fxPtr(&rovi)) {
				return rovi;
			}
		}
	}
	RTL_OSVERSIONINFOW rovi = { 0 };
	return rovi;
}
//---

BOOL IsWindowsVersionOrGreaterFx(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
{
	OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0 };
	DWORDLONG        const dwlConditionMask = VerSetConditionMask(
		                                                              VerSetConditionMask(
			                                                    VerSetConditionMask(
				                                           0, VER_MAJORVERSION, VER_GREATER_EQUAL),
			                                                VER_MINORVERSION, VER_GREATER_EQUAL),
		                                                  VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);

	osvi.dwMajorVersion = wMajorVersion;
	osvi.dwMinorVersion = wMinorVersion;
	osvi.wServicePackMajor = wServicePackMajor;

//---add

	//osvi.dwBuildNumber= GetRealOSVersion().dwBuildNumber;
	//osvi.dwOSVersionInfoSize = GetRealOSVersion().dwOSVersionInfoSize;
	//osvi.dwPlatformId = GetRealOSVersion().dwPlatformId;


	DWORD wntMajorVersion= GetRealOSVersion().dwMajorVersion;//W11=10
	DWORD wntMinorVersion = GetRealOSVersion().dwMinorVersion;//W11=0
	DWORD wntBuildNumber = GetRealOSVersion().dwBuildNumber;//W11=22621
	DWORD wntPlatformId = GetRealOSVersion().dwPlatformId;//W11=2
	DWORD wntOSVersionInfoSize = GetRealOSVersion().dwOSVersionInfoSize;//W11=276
	WCHAR *wntszCSDVersion = GetRealOSVersion().szCSDVersion;//W11=0x012fd0e4

//---modify

	if ((wMajorVersion == wntMajorVersion) && (wntBuildNumber > 20000)) //Windows 11
	{
		return TRUE;
	}
	else
	{
		return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
	}
}
@PeratX
Copy link
Member

PeratX commented Feb 15, 2023

the current version is based on 8.9.0 and may not support windows 11. thanks for the comment.

@zyyujq
Copy link
Author

zyyujq commented Feb 16, 2023

With the above modifications, even V8. 9 without manifests supports Windows 11

@zyyujq
Copy link
Author

zyyujq commented Feb 16, 2023

With the above modifications, even V8. 9 without manifests supports Windows 11.
The latest version of V8.17.14 is modified as above, and the DLL also supports Windows 11.

@PeratX
Copy link
Member

PeratX commented Feb 16, 2023

nice work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants