int TestWinVersion(int argc, char* argv) {
	unsigned char* VersionMajor = new unsigned char[1]; 
	unsigned char* VersionMinor = new unsigned char[1]; 
	unsigned short* BuildNumber = new unsigned short[1];
	unsigned char* PlatformId  = new unsigned char[1];
	unsigned char* ServicePackMajor = new unsigned char[1];
	unsigned char* ServicePackMinor = new unsigned char[1];
	unsigned short* Suite = new unsigned short[1];
	unsigned char* ProductType = new unsigned char[1];
	unsigned char* ServerBuild = new unsigned char[1];
	
	int result = 0;
	char* WindowsDescription = NULL;

	result = GetWindowsVersionInfo(VersionMajor, 
									VersionMinor, 
									BuildNumber,
									PlatformId,
									ServicePackMajor,
									ServicePackMinor,
									Suite,
									ProductType, 
									ServerBuild);

	if (result) {
		WindowsDescription = GetWindowsVersionDesc(VersionMajor, 
									VersionMinor, 
									BuildNumber,
									PlatformId,
									ServicePackMajor,
									ServicePackMinor,
									Suite,
									ProductType,
									ServerBuild);
		if (WindowsDescription) {
			printf(WindowsDescription);
			printf("\n");
		} else {
			printf("[-] Error while retrieving operating system version.\n");
		}
	}
	
	delete VersionMajor; 
	delete VersionMinor; 
	delete BuildNumber;
	delete PlatformId;
	delete ServicePackMajor;
	delete ServicePackMinor;
	delete Suite;
	delete ProductType;
	delete ServerBuild;
	SecureZeroMemory(WindowsDescription, sizeof(WindowsDescription));
	delete WindowsDescription;
	return 0;
}
Beispiel #2
0
BOOL T_WindowsInfo::Init()
{
	nWindowsVersion = WINUNKNOWN;
	nSP = 0;

	ZeroMemory(&osvi, sizeof(osvi));
	if(GetWindowsVersionInfo(osvi))
	{
		FixVersionInfo(osvi);
		nWindowsVersion = _ParseWinVer( osvi );
		nSP = osvi.wServicePackMajor;
		return TRUE;
	}
	return FALSE;
}