Giter Site home page Giter Site logo

crystaldiskinfoembedded's People

Contributors

peratx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

williamqf-ai

crystaldiskinfoembedded's Issues

Not working on NVMe

Code run successfully on SATA but not on NVMe. Seem CArray<ATA_SMART_INFO, ATA_SMART_INFO> vars is always empty in this situation.

I have a question~

I have a question. The InitAtaSmart function must be executed every time disk information is retrieved to refresh the information, but doing so degrades the program's performance, so I wonder if there is a way... The programming language is C# WinForm.

About IsWindowsVersionOrGreaterFx function in OsInfoFx.cpp

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;
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.