<commit_before>#include "stdafx.h"
#include "sysinv.h"

#include <sddl.h>

PNODE GetOsVersionDetail();
PNODE GetOsIdentityDetail();

PNODE GetOperatingSystemDetail()
{
	PNODE node = NULL;
	PNODE osNode = node_alloc(_T("OperatingSystem"), 0);

	if (NULL != (node = GetOsVersionDetail()))
		node_append_child(osNode, node);
	
	if (NULL != (node = GetOsIdentityDetail()))
		node_append_child(osNode, node);

	return osNode;
}

PNODE GetOsVersionDetail()
{
	PNODE node = node_alloc(L"VersionInfo", 0);
	OSVERSIONINFOEX osinfo;
	TCHAR strBuffer[MAX_PATH + 1];
	HKEY hKey = 0;
	DWORD dwType = REG_SZ;
	DWORD bufferSize;

	osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
	GetVersionEx((LPOSVERSIONINFOW) &osinfo);

	// Get product name from
	// HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName
	RegOpenKey(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hKey);
	RegQueryValueEx(hKey, L"ProductName", NULL, &dwType, (LPBYTE) &strBuffer, &bufferSize);
	node_att_set(node, L"Name", strBuffer, 0);

	// Break down OS name
	switch(osinfo.wProductType) {
	case VER_NT_WORKSTATION:
		switch(osinfo.dwMajorVersion) {
			case 5:
				switch(osinfo.dwMinorVersion) {
				case 0:	
					wcscpy(strBuffer, L"Windows 2000");
					break;
				case 1:
					wcscpy(strBuffer, L"Windows XP");
					break;
				}

				break;

			case 6:
				switch(osinfo.dwMinorVersion) {
				case 0:
					wcscpy(strBuffer, L"Windows Vista");
					break;

				case 1:
					wcscpy(strBuffer, L"Windows 7");
					break;

				case 2:
					wcscpy(strBuffer, L"Windows 8");
					break;

				case 3:
					wcscpy(strBuffer, L"Windows 8.1");
					break;
				}
			}
		break;

	case VER_NT_DOMAIN_CONTROLLER:
	case VER_NT_SERVER:
		switch(osinfo.dwMajorVersion) {
			case 5:
				switch(osinfo.dwMinorVersion) {
				case 0:
					wcscpy(strBuffer, L"Windows 2000 Server");
					break;
				case 1:
					wcscpy(strBuffer, L"Windows Server 2003");
					break;
				case 2:
					wcscpy(strBuffer, L"Windows Server 2003 R2");
					break;
				}
				break;

			case 6:
				switch(osinfo.dwMinorVersion) {
				case 0:
					wcscpy(strBuffer, L"Windows Server 2008");
					break;

				case 1:
					wcscpy(strBuffer, L"Windows Server 2008 R2");
					break;

				case 2:
					wcscpy(strBuffer, L"Windows Server 2012");
					break;

				case 3:
					wcscpy(strBuffer, L"Windows Server 2012 R2");
					break;
				}
		}
		break;

	default:
		wcscpy(strBuffer, L"Unknown");
		break;
	}
	node_att_set(node, L"BaseName", strBuffer, 0);

	// Determine OS Edition
	if(VER_SUITE_BLADE & osinfo.wSuiteMask)
		node_att_set(node, L"Edition", L"Web Edition", 0);

	else if(VER_SUITE_COMPUTE_SERVER & osinfo.wSuiteMask)
		node_att_set(node, L"Edition", L"Computer Cluster Edition", 0);

	else if (VER_SUITE_DATACENTER & osinfo.wSuiteMask)
		node_att_set(node, L"Edition", L"Datacenter Edition", 0);

	else if (VER_SUITE_ENTERPRISE & osinfo.wSuiteMask)
		node_att_set(node, L"Edition", L"Enterprise", 0);

	else if (VER_SUITE_EMBEDDEDNT & osinfo.wSuiteMask)
		node_att_set(node, L"Edition", L"Embedded", 0);

	else if (VER_SUITE_PERSONAL & osinfo.wSuiteMask)
		node_att_set(node, L"Edition", L"Home", 0);
	
	// OS Version numbers
	swprintf(strBuffer, L"%u.%u.%u", osinfo.dwMajorVersion, osinfo.dwMinorVersion, osinfo.dwBuildNumber);
	node_att_set(node, L"Version", strBuffer, 0);<commit_msg>Fixed 2003 SP2 reporting as 2003 R2<commit_after>#include "stdafx.h"
#include "sysinv.h"

#include <sddl.h>

PNODE GetOsVersionDetail();
PNODE GetOsIdentityDetail();

PNODE GetOperatingSystemDetail()
{
	PNODE node = NULL;
	PNODE osNode = node_alloc(_T("OperatingSystem"), 0);

	if (NULL != (node = GetOsVersionDetail()))
		node_append_child(osNode, node);
	
	if (NULL != (node = GetOsIdentityDetail()))
		node_append_child(osNode, node);

	return osNode;
}

PNODE GetOsVersionDetail()
{
	PNODE node = node_alloc(L"VersionInfo", 0);
	OSVERSIONINFOEX osinfo;
	TCHAR strBuffer[MAX_PATH + 1];
	HKEY hKey = 0;
	DWORD dwType = REG_SZ;
	DWORD bufferSize;

	osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
	GetVersionEx((LPOSVERSIONINFOW) &osinfo);

	// Get product name from
	// HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName
	RegOpenKey(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hKey);
	RegQueryValueEx(hKey, L"ProductName", NULL, &dwType, (LPBYTE) &strBuffer, &bufferSize);
	node_att_set(node, L"Name", strBuffer, 0);

	// Break down OS name
	switch(osinfo.wProductType) {
	case VER_NT_WORKSTATION:
		switch(osinfo.dwMajorVersion) {
			case 5:
				switch(osinfo.dwMinorVersion) {
				case 0:	
					wcscpy(strBuffer, L"Windows 2000");
					break;
				case 1:
					wcscpy(strBuffer, L"Windows XP");
					break;
				}

				break;

			case 6:
				switch(osinfo.dwMinorVersion) {
				case 0:
					wcscpy(strBuffer, L"Windows Vista");
					break;

				case 1:
					wcscpy(strBuffer, L"Windows 7");
					break;

				case 2:
					wcscpy(strBuffer, L"Windows 8");
					break;

				case 3:
					wcscpy(strBuffer, L"Windows 8.1");
					break;
				}
			}
		break;

	case VER_NT_DOMAIN_CONTROLLER:
	case VER_NT_SERVER:
		switch(osinfo.dwMajorVersion) {
			case 5:
				if (0 == osinfo.dwMinorVersion) {
					wcscpy(strBuffer, L"Windows 2000 Server");
				}

				else {
					// R2?
					if (0 != GetSystemMetrics(SM_SERVERR2))
						wcscpy(strBuffer, L"Windows Server 2003 R2");
					else
						wcscpy(strBuffer, L"Windows Server 2003");
				}

				break;

			case 6:
				switch(osinfo.dwMinorVersion) {
				case 0:
					wcscpy(strBuffer, L"Windows Server 2008");
					break;

				case 1:
					wcscpy(strBuffer, L"Windows Server 2008 R2");
					break;

				case 2:
					wcscpy(strBuffer, L"Windows Server 2012");
					break;

				case 3:
					wcscpy(strBuffer, L"Windows Server 2012 R2");
					break;
				}
		}
		break;

	default:
		wcscpy(strBuffer, L"Unknown");
		break;
	}
	node_att_set(node, L"BaseName", strBuffer, 0);

	// Determine OS Edition (Needs to move into version specific logic)
	if(VER_SUITE_BLADE & osinfo.wSuiteMask)
		node_att_set(node, L"Edition", L"Web Edition", 0);

	else if(VER_SUITE_COMPUTE_SERVER & osinfo.wSuiteMask)
		node_att_set(node, L"Edition", L"Compute Cluster Edition", 0);

	else if (VER_SUITE_DATACENTER & osinfo.wSuiteMask)
		node_att_set(node, L"Edition", L"Datacenter Edition", 0);

	else if (VER_SUITE_ENTERPRISE & osinfo.wSuiteMask)
		node_att_set(node, L"Edition", L"Enterprise", 0);

	else if (VER_SUITE_EMBEDDEDNT & osinfo.wSuiteMask)
		node_att_set(node, L"Edition", L"Embedded", 0);

	else if (VER_SUITE_PERSONAL & osinfo.wSuiteMask)
		node_att_set(node, L"Edition", L"Home", 0);

	else
		node_att_set(node, L"Edition", L"Standard Edition", 0);
	
	// OS Version numbers
	swprintf(strBuffer, L"%u.%u.%u", osinfo.dwMajorVersion, osinfo.dwMinorVersion, osinfo.dwBuildNumber);
	node_att_set(node, L"Version", strBuffer, 0);
{'fraction_non_alphanumeric': 0.1255090168702734, 'fraction_numerical': 0.02181500872600349, 'mean_word_length': 3.9332855093256813, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1800620', 'n_tokens_mistral': 3174, 'n_tokens_neox': 2567, 'n_words': 549}