Пример #1
1
Файл: util.c Проект: 5y/node
static int is_windows_version_or_greater(DWORD os_major,
                                         DWORD os_minor,
                                         WORD service_pack_major,
                                         WORD service_pack_minor) {
  OSVERSIONINFOEX osvi;
  DWORDLONG condition_mask = 0;
  int op = VER_GREATER_EQUAL;

  /* Initialize the OSVERSIONINFOEX structure. */
  ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
  osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
  osvi.dwMajorVersion = os_major;
  osvi.dwMinorVersion = os_minor;
  osvi.wServicePackMajor = service_pack_major;
  osvi.wServicePackMinor = service_pack_minor;

  /* Initialize the condition mask. */
  VER_SET_CONDITION(condition_mask, VER_MAJORVERSION, op);
  VER_SET_CONDITION(condition_mask, VER_MINORVERSION, op);
  VER_SET_CONDITION(condition_mask, VER_SERVICEPACKMAJOR, op);
  VER_SET_CONDITION(condition_mask, VER_SERVICEPACKMINOR, op);

  /* Perform the test. */
  return (int) VerifyVersionInfo(
    &osvi, 
    VER_MAJORVERSION | VER_MINORVERSION | 
    VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
    condition_mask);
}
Пример #2
0
BOOL IsWindowsXPSP2OrLater ( void ) 
{
   OSVERSIONINFOEX osvi;
   DWORDLONG dwlConditionMask = 0;
   int op = VER_GREATER_EQUAL;

   // Initialize the OSVERSIONINFOEX structure.
   memset ( &osvi, 0, sizeof ( OSVERSIONINFOEX ) );
   osvi.dwOSVersionInfoSize = sizeof ( OSVERSIONINFOEX );
   osvi.dwMajorVersion = 5;
   osvi.dwMinorVersion = 1;
   osvi.wServicePackMajor = 2;
   osvi.wServicePackMinor = 0;

   // Initialize the condition mask.
   VER_SET_CONDITION ( dwlConditionMask, VER_MAJORVERSION, op );
   VER_SET_CONDITION ( dwlConditionMask, VER_MINORVERSION, op );
   VER_SET_CONDITION ( dwlConditionMask, VER_SERVICEPACKMAJOR, op );
   VER_SET_CONDITION ( dwlConditionMask, VER_SERVICEPACKMINOR, op );

   // Perform the test.
   return VerifyVersionInfo (
      &osvi, 
      VER_MAJORVERSION | VER_MINORVERSION | 
      VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
      dwlConditionMask
   );
}
Пример #3
0
BOOL IsWindowsVista() {

   // Code from Chapter 4
   // Prepare the OSVERSIONINFOEX structure to indicate Windows Vista.
   OSVERSIONINFOEX osver = { 0 };
   osver.dwOSVersionInfoSize = sizeof(osver);
   osver.dwMajorVersion = 6;
   osver.dwMinorVersion = 0;
   osver.dwPlatformId = VER_PLATFORM_WIN32_NT;

   // Prepare the condition mask.
   DWORDLONG dwlConditionMask = 0;	// You MUST initialize this to 0.
   VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_EQUAL);
   VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_EQUAL);
   VER_SET_CONDITION(dwlConditionMask, VER_PLATFORMID, VER_EQUAL);

   // Perform the version test.
   if (VerifyVersionInfo(&osver, VER_MAJORVERSION  | VER_MINORVERSION | 
      VER_PLATFORMID, dwlConditionMask)) {
      // The host system is Windows Vista exactly.
      return(TRUE);
   } else {
      // The host system is NOT Windows Vista.
      return(FALSE);
   }
}
Пример #4
0
bool ImageHandler::CheckWin8()
{
  OSVERSIONINFOEX osvi;
  DWORDLONG dwlConditionMask = 0;
  BYTE op = VER_GREATER_EQUAL;

  // Initialize the OSVERSIONINFOEX structure.

  ::ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
  osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
  osvi.dwMajorVersion = 6;
  osvi.dwMinorVersion = 2;

  // Initialize the condition mask.

  VER_SET_CONDITION( dwlConditionMask, VER_MAJORVERSION, op );
  VER_SET_CONDITION( dwlConditionMask, VER_MINORVERSION, op );

  // Perform the test.

  if( ::VerifyVersionInfo(
    &osvi, 
    VER_MAJORVERSION | VER_MINORVERSION | 
    VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
    dwlConditionMask) )
  {
    return true;
  }
  else
  {
    return false;
  }
}
Пример #5
0
int is_windows_7()
{
#ifdef __MINGW32__
  printf("Warning: this test was built with MinGW.\n"
         "MinGW does not contain necessary version checking infrastructure. Claiming to be Windows 7, even if we're not.\n");
  return 1;
#endif
#if (defined(_WIN32) || defined(__WIN32__)) && ( !defined(__MINGW32__))
  OSVERSIONINFOEX osvi;
  DWORDLONG condition_mask = 0;

  ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
  osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

  // NT 6.1 is Windows 7
  osvi.dwMajorVersion = 6;
  osvi.dwMinorVersion = 1;

  VER_SET_CONDITION(condition_mask, VER_MAJORVERSION, VER_EQUAL);
  VER_SET_CONDITION(condition_mask, VER_MINORVERSION, VER_GREATER_EQUAL);

  return VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, condition_mask);
#else
  return 0;
#endif
}
Пример #6
0
/*
 * Check Windows version
 * The problem happens only in Windows 7
 *
 */
static BOOL IsWin7OrLater() 
{
   OSVERSIONINFOEX osvi;
   DWORDLONG dwlConditionMask = 0;
   int op = VER_GREATER_EQUAL;

   /* Initialize the OSVERSIONINFOEX structure */
   ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
   osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
   osvi.dwMajorVersion = 6;
   osvi.dwMinorVersion = 1;
   osvi.wServicePackMajor = 0;
   osvi.wServicePackMinor = 0;

   /* Initialize the condition mask */
   VER_SET_CONDITION( dwlConditionMask, VER_MAJORVERSION, op );
   VER_SET_CONDITION( dwlConditionMask, VER_MINORVERSION, op );
   VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMAJOR, op );
   VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMINOR, op );

   /* Perform the test */
   return VerifyVersionInfo(
      &osvi, 
      VER_MAJORVERSION | VER_MINORVERSION | 
      VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
      dwlConditionMask);
}
Пример #7
0
BOOL FileReader::IsVistaOrLater() 
{
   OSVERSIONINFOEX osvi;
   DWORDLONG dwlConditionMask = 0;
   int op=VER_GREATER_EQUAL;

   // Initialize the OSVERSIONINFOEX structure.

   ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
   osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
   osvi.dwMajorVersion = 6;
   osvi.dwMinorVersion = 0;
   osvi.wServicePackMajor = 0;
   osvi.wServicePackMinor = 0;

   // Initialize the condition mask.

   VER_SET_CONDITION( dwlConditionMask, VER_MAJORVERSION, op );
   VER_SET_CONDITION( dwlConditionMask, VER_MINORVERSION, op );
   VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMAJOR, op );
   VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMINOR, op );

   // Perform the test.

   m_bIsVistaOrLater = VerifyVersionInfo(
      &osvi, 
      VER_MAJORVERSION | VER_MINORVERSION | 
      VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
      dwlConditionMask);
      
   return m_bIsVistaOrLater;
}
Пример #8
0
BOOL IsWin2kSP4OrLater()
{
   OSVERSIONINFOEX osvi;
   DWORDLONG dwlConditionMask = 0;
   BYTE op=VER_GREATER_EQUAL;

   // Initialize the OSVERSIONINFOEX structure.

   ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
   osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
   osvi.dwMajorVersion = 5;
   osvi.dwMinorVersion = 0;
   osvi.wServicePackMajor = 4;
   osvi.wServicePackMinor = 0;

   // Initialize the condition mask.

   VER_SET_CONDITION( dwlConditionMask, VER_MAJORVERSION, op );
   VER_SET_CONDITION( dwlConditionMask, VER_MINORVERSION, op );
   VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMAJOR, op );
   VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMINOR, op );

   // Perform the test.

   return VerifyVersionInfo(
      &osvi,
      VER_MAJORVERSION | VER_MINORVERSION |
      VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
      dwlConditionMask);
}
Пример #9
0
BOOL IsOSWin7()
{
	BOOL bIsWinSeven = FALSE;

	OSVERSIONINFOEX osvi;
	DWORDLONG dwlConditionMask = 0;

	// Initialize the OSVERSIONINFOEX structure.
	ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
	osvi.dwMajorVersion = 6;
	osvi.dwMinorVersion = 1;
	osvi.wServicePackMajor = 0;

	// Initialize the condition mask.
	VER_SET_CONDITION( dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL );
	VER_SET_CONDITION( dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL );
	VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL );

	// Perform the test.
	if(VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask))
	{
		bIsWinSeven = TRUE;
	}

	return bIsWinSeven;
}
Пример #10
0
QT_BEGIN_INCLUDE_NAMESPACE
#include "qt_windows.h"
QT_END_INCLUDE_NAMESPACE

#ifndef Q_OS_WINRT
static inline OSVERSIONINFO winOsVersion()
{
	OSVERSIONINFO result = { sizeof(OSVERSIONINFO), 0, 0, 0, 0, {'\0'}};
	// GetVersionEx() has been deprecated in Windows 8.1 and will return
	// only Windows 8 from that version on.
#	if defined(_MSC_VER) && _MSC_VER >= 1800
#		pragma warning( push )
#		pragma warning( disable : 4996 )
#	endif
	GetVersionEx(&result);
#	if defined(_MSC_VER) && _MSC_VER >= 1800
#		pragma warning( pop )
#	endif
#	ifndef Q_OS_WINCE
		if (result.dwMajorVersion == 6 && result.dwMinorVersion == 2) {
			// This could be Windows 8.1 or higher. Note that as of Windows 9,
			// the major version needs to be checked as well.
			DWORDLONG conditionMask = 0;
			VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
			VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
			VER_SET_CONDITION(conditionMask, VER_PLATFORMID, VER_EQUAL);
			OSVERSIONINFOEX checkVersion = { sizeof(OSVERSIONINFOEX), result.dwMajorVersion, result.dwMinorVersion,
							 result.dwBuildNumber, result.dwPlatformId, {'\0'}, 0, 0, 0, 0, 0 };
			for ( ; VerifyVersionInfo(&checkVersion, VER_MAJORVERSION | VER_MINORVERSION | VER_PLATFORMID, conditionMask); ++checkVersion.dwMinorVersion)
				result.dwMinorVersion = checkVersion.dwMinorVersion;
		}
#	endif // !Q_OS_WINCE
	return result;
}
Пример #11
0
static unsigned int
calculate_minimum_latency(void)
{
  OSVERSIONINFOEX osvi;
  DWORDLONG mask;

  /* Running under Terminal Services results in underruns with low latency. */
  if (GetSystemMetrics(SM_REMOTESESSION) == TRUE) {
    return 500;
  }

  /* Vista's WinMM implementation underruns when less than 200ms of audio is buffered. */
  memset(&osvi, 0, sizeof(OSVERSIONINFOEX));
  osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
  osvi.dwMajorVersion = 6;
  osvi.dwMinorVersion = 0;

  mask = 0;
  VER_SET_CONDITION(mask, VER_MAJORVERSION, VER_EQUAL);
  VER_SET_CONDITION(mask, VER_MINORVERSION, VER_EQUAL);

  if (VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, mask) != 0) {
    return 200;
  }

  return 100;
}
Пример #12
0
BOOL WINAPI VerifyWindowsVersion(
	BYTE dwCondMask, 
	DWORD dwMajorVersion, 
	DWORD dwMinorVersion, 
	WORD wServicePackMajor)
{
	OSVERSIONINFOEX osvi = {0};
	DWORDLONG dwlCondMask = 0;
	DWORD dwTypeMask = 0;

	osvi.dwOSVersionInfoSize = sizeof(osvi);
	osvi.dwMajorVersion = dwMajorVersion;
	osvi.dwMinorVersion = dwMinorVersion;

	if (wServicePackMajor < 0xFFFF) {
		osvi.wServicePackMajor = wServicePackMajor;
	}

	VER_SET_CONDITION(dwlCondMask, VER_MAJORVERSION, dwCondMask);
	dwTypeMask |= VER_MAJORVERSION;

	VER_SET_CONDITION(dwlCondMask, VER_MINORVERSION, dwCondMask);
	dwTypeMask |= VER_MINORVERSION;

	if (wServicePackMajor < 0xFFFF) {
		VER_SET_CONDITION(dwlCondMask, VER_SERVICEPACKMAJOR, dwCondMask);
		dwTypeMask |= VER_SERVICEPACKMAJOR;
	}

	return VerifyVersionInfo(
		&osvi, 
		dwTypeMask,
		dwlCondMask);
}
Пример #13
0
VOID
DetectOSVersion()
/*++

Routine Description:

    This routine determines the OS version and initializes some globals used
    in the sample. 

Arguments:
    
    None
    
Return value:

    None. On failure, global variables stay at default value

--*/
{

    RTL_OSVERSIONINFOEXW VersionInfo = {0};
    NTSTATUS Status;
    ULONGLONG ConditionMask = 0;

    //
    // Set VersionInfo to Win7's version number and then use
    // RtlVerifVersionInfo to see if this is win8 or greater.
    //
    
    VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo);
    VersionInfo.dwMajorVersion = 6;
    VersionInfo.dwMinorVersion = 1;

    VER_SET_CONDITION(ConditionMask, VER_MAJORVERSION, VER_LESS_EQUAL);
    VER_SET_CONDITION(ConditionMask, VER_MINORVERSION, VER_LESS_EQUAL);



    Status = RtlVerifyVersionInfo(&VersionInfo,
                                  VER_MAJORVERSION | VER_MINORVERSION,
                                  ConditionMask);
    if (NT_SUCCESS(Status)) {
        g_IsWin8OrGreater = FALSE;
        InfoPrint("DetectOSVersion: This machine is running Windows 7 or an older OS.");
    } else if (Status == STATUS_REVISION_MISMATCH) {
        g_IsWin8OrGreater = TRUE;
        InfoPrint("DetectOSVersion: This machine is running Windows 8 or a newer OS.");
    } else {
        ErrorPrint("RtlVerifyVersionInfo returned unexpected error status 0x%x.",
            Status);

        //
        // default action is to assume this is not win8
        //
        g_IsWin8OrGreater = FALSE;  
    }
    
}
Пример #14
0
INT CALLBACK FolderBrowserDialog::BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM pData)
{
	static BOOL bProcessEnsureVisible = FALSE;

	switch(uMsg)
	{
		case BFFM_INITIALIZED:
		{
			//In case of Windows 7 and later
			//INFO: Correction for the Microsoft bug that doesn't 
			//      scroll the tree-view to the selected item...
			OSVERSIONINFOEX osi;
			DWORDLONG dwlConditionMask = 0;
			::SecureZeroMemory(&osi, sizeof(OSVERSIONINFOEX));
			osi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
			osi.dwMajorVersion = 6;
			osi.dwMinorVersion = 1;
			VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
			VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
			//if (GetVersionEx(&osi) && osi.dwMajorVersion >= 6 && osi.dwMinorVersion >= 1)
			if (VerifyVersionInfo(&osi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask))
				bProcessEnsureVisible = TRUE;

			FolderBrowserDialog* bfd = FolderBrowserDialog::GetInstance();
			if (!bfd)
				break;
			if (bfd->Title[0])
				SetWindowTextW(hwnd,bfd->Title);

			if(bfd->curdir[0])
				::SendMessageW(hwnd, BFFM_SETSELECTIONW, TRUE, (LPARAM)bfd->curdir);
			else if (bfd->root)
				::SendMessageW(hwnd, BFFM_SETSELECTIONW, FALSE, (LPARAM)bfd->root);
			return 1;
		}
		case BFFM_SELCHANGED:
			if (bProcessEnsureVisible)
			{
				bProcessEnsureVisible = FALSE;
				HWND hTreeView = 0;
				::EnumChildWindows(hwnd, FolderBrowserDialog::FindTreeViewCallback, (LPARAM)&hTreeView);
				if (hTreeView)
				{
					HTREEITEM hItm = TreeView_GetSelection(hTreeView);
					if (hItm)
					{
						TreeView_EnsureVisible(hTreeView, hItm);
						TreeView_Expand(hTreeView, hItm, TVE_EXPAND);
					}
				}
			}
			break;
	}
	return 0;
}
Пример #15
0
BOOL IsWindows10OrNewer()
{
    OSVERSIONINFOEX osvi = { 0 };
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
    osvi.dwMajorVersion = 10;
    osvi.dwMinorVersion = 0;
    DWORDLONG dwlConditionMask = 0;
    VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
    VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
    return ::VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask);
}
bool
VolatileBuffer::Init(size_t aSize, size_t aAlignment)
{
  MOZ_ASSERT(!mSize && !mBuf, "Init called twice");
  MOZ_ASSERT(!(aAlignment % sizeof(void *)),
             "Alignment must be multiple of pointer size");

  mSize = aSize;
  if (aSize < MIN_VOLATILE_ALLOC_SIZE) {
    goto heap_alloc;
  }

  static bool sCheckedVersion = false;
  static bool sUndoSupported = false;
  if (!sCheckedVersion) {
    OSVERSIONINFOEX verinfo = { 0 };
    verinfo.dwOSVersionInfoSize = sizeof(verinfo);
    verinfo.dwMajorVersion = 6;
    verinfo.dwMinorVersion = 2;

    DWORDLONG mask = 0;
    VER_SET_CONDITION(mask, VER_MAJORVERSION, VER_GREATER_EQUAL);
    VER_SET_CONDITION(mask, VER_MINORVERSION, VER_GREATER_EQUAL);

    sUndoSupported = VerifyVersionInfo(&verinfo,
                                       VER_MAJORVERSION | VER_MINORVERSION,
                                       mask);
    sCheckedVersion = true;
  }

  if (!sUndoSupported) {
    goto heap_alloc;
  }

  mBuf = VirtualAllocEx(GetCurrentProcess(),
                        nullptr,
                        mSize,
                        MEM_COMMIT | MEM_RESERVE,
                        PAGE_READWRITE);
  if (mBuf) {
    return true;
  }

heap_alloc:
#ifdef MOZ_MEMORY
  posix_memalign(&mBuf, aAlignment, aSize);
#else
  mBuf = _aligned_malloc(aSize, aAlignment);
#endif
  mHeap = true;
  return !!mBuf;
}
Пример #17
0
bool util::OSVersionChecker::IsWin7()
{
    OSVERSIONINFOEX ver;
    DWORDLONG condMask = 0;
    ZeroMemory(&ver, sizeof(OSVERSIONINFOEX));
    ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
    ver.dwMajorVersion = 6;
    ver.dwMinorVersion = 1;
    VER_SET_CONDITION(condMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
    VER_SET_CONDITION(condMask, VER_MINORVERSION, VER_GREATER_EQUAL);
    BOOL bRet = VerifyVersionInfo(&ver, VER_MAJORVERSION | VER_MINORVERSION, condMask);
    return bRet == TRUE;
}
Пример #18
0
bool IsVistaOrHigher() {
	OSVERSIONINFOEX osvi;
	DWORDLONG dwlConditionMask = 0;
	int op = VER_GREATER_EQUAL;
	ZeroMemory(&osvi, sizeof(osvi));
	osvi.dwOSVersionInfoSize = sizeof(osvi);
	osvi.dwMajorVersion = 6;  // Vista is 6.0
	osvi.dwMinorVersion = 0;

	VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, op);
	VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, op);

	return VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask) != FALSE;
}
Пример #19
0
bool IsAtLeast(int major, int minor = 0)
{
	OSVERSIONINFOEX vi = { 0 };
	vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
	vi.dwMajorVersion = major;
	vi.dwMinorVersion = minor;
	vi.dwPlatformId = VER_PLATFORM_WIN32_NT;

	DWORDLONG mask = 0;
	VER_SET_CONDITION(mask, VER_MAJORVERSION, VER_GREATER_EQUAL);
	VER_SET_CONDITION(mask, VER_MINORVERSION, VER_GREATER_EQUAL);
	VER_SET_CONDITION(mask, VER_PLATFORMID, VER_EQUAL);
	return VerifyVersionInfo(&vi, VER_MAJORVERSION | VER_MINORVERSION | VER_PLATFORMID, mask) != 0;
}
Пример #20
0
// ªÒ»°≤Ÿ◊˜œµÕ≥√˚◊÷£¨»Áwindows 7  
// ≥…π¶∑µªÿœµÕ≥–≈œ¢£¨ ß∞‹∑µªÿ Unknown System  
// ≤Œø�?https://msdn.microsoft.com/en-us/library/ms724834(v=vs.85).aspx
std::string get_os_version()  
{  
	OSVERSIONINFO osvi;  
	ZeroMemory(&osvi, sizeof(OSVERSIONINFO));  
	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);  
	if ( FALSE == GetVersionEx(&osvi) ) {  
		return "Unknown System";
	}  
	OSVERSIONINFOEX osviex;
	DWORDLONG dwlConditionMask = 0;
	// Initialize the OSVERSIONINFOEX structure.
	ZeroMemory(&osviex, sizeof(OSVERSIONINFOEX));
	osviex.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
	osviex.dwMajorVersion = osvi.dwMajorVersion;
	osviex.dwMinorVersion = osvi.dwMinorVersion;
	osviex.wProductType = VER_NT_WORKSTATION;
	// Initialize the condition mask.
	VER_SET_CONDITION( dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL );
	VER_SET_CONDITION( dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL );
	VER_SET_CONDITION( dwlConditionMask, VER_PRODUCT_TYPE, VER_GREATER_EQUAL );

	// Perform the test.
	BOOL ret = VerifyVersionInfo(&osviex,VER_MAJORVERSION | VER_MINORVERSION | VER_PRODUCT_TYPE,dwlConditionMask);
	if (osvi.dwMajorVersion == 5) {  
		switch (osvi.dwMinorVersion){  
		case 0: return "Windows 2000";  
		case 1: return "Windows XP";  
		case 2: return GetSystemMetrics(SM_SERVERR2) == 0 ? "Windows Server 2003":"Windows Server 2003 R2";
		default:return "Unknown System";  
		} 
	}else if (osvi.dwMajorVersion == 6) {
		switch (osvi.dwMinorVersion) {
		case 0: return ret ? "Windows Vista" : "Windows Server 2008";  
		case 1: return ret ? "Windows 7" : "Windows Server 2008 R2";  
		case 2: return ret ? "Windows 8" : "Windows Server 2012";
		case 3: return ret ? "Windows 8.1" : "Windows Server 2012 R2";
		default:return "Unknown System";  
		}
	}else if (osvi.dwMajorVersion == 10) {
		switch (osvi.dwMinorVersion) {  
		case 0: return ret ? "Windows 10" : "Windows Server 2016 Technical Preview";
		default:return "Unknown System";  
		}  
	}
	else
	{
		return "Unknown System";
	}
}
Пример #21
0
static BOOL CompareWindowsVersion(DWORD dwMajorVersion, DWORD dwMinorVersion)
{
    OSVERSIONINFOEX ver;
    DWORDLONG dwlConditionMask = 0;

    ZeroMemory(&ver, sizeof(OSVERSIONINFOEX));
    ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
    ver.dwMajorVersion = dwMajorVersion;
    ver.dwMinorVersion = dwMinorVersion;

    VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_EQUAL);
    VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_EQUAL);

    return VerifyVersionInfo(&ver, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask);
}
Пример #22
0
/* other method, when replaced should do it in CD also (cdwinp.cpp) */
static BOOL winCheckWindowsVersion(DWORD major, DWORD minor) 
{
  OSVERSIONINFOEX osvi;
  DWORDLONG dwlConditionMask = 0;

  ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
  osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
  osvi.dwMajorVersion = major;
  osvi.dwMinorVersion = minor;

  VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
  VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);

  return VerifyVersionInfo(&osvi, VER_MAJORVERSION|VER_MINORVERSION, dwlConditionMask);
}
bool XWinSystem::IsSystemVersionOrAbove( SystemVersion inSystemVersion)
{
	OSVERSIONINFOEXW version;

	::memset(&version, 0, sizeof(version));
	version.dwOSVersionInfoSize = sizeof(version);
	
	DWORDLONG conditionMask = 0;
	VER_SET_CONDITION( conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL );
	VER_SET_CONDITION( conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL );

	if (!GetMajorAndMinorFromSystemVersion( inSystemVersion, &version.dwMajorVersion, &version.dwMinorVersion))
		return false;

	return ::VerifyVersionInfoW( &version, VER_MAJORVERSION | VER_MINORVERSION , conditionMask) != 0;
}
Пример #24
0
BOOL checkWindowsVersion(DWORD i_major, DWORD i_minor)
{
    DWORDLONG conditionMask = 0;
    OSVERSIONINFOEX osvi;
    memset(&osvi, 0, sizeof(OSVERSIONINFOEX));

    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
    osvi.dwMajorVersion = i_major;
    osvi.dwMinorVersion = i_minor;

    VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
    VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);

    // Perform the test.
    return VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, conditionMask);
}
Пример #25
0
/*  Initialize all the allocators here.
 *  This function should be called only once when Wireshark or TShark starts
 *  up.
 */
void
emem_init(void)
{
	ep_init_chunk();
	se_init_chunk();

	if (getenv("WIRESHARK_DEBUG_SCRUB_MEMORY"))
		debug_use_memory_scrubber  = TRUE;

#if defined (_WIN32)
	/* Set up our guard page info for Win32 */
	GetSystemInfo(&sysinfo);
	pagesize = sysinfo.dwPageSize;

#if (_MSC_VER >= 1800)
	/*
	 * On VS2103, GetVersionEx is deprecated. Microsoft recommend to
	 * use VerifyVersionInfo instead
	 */
	{
		OSVERSIONINFOEX osvi;
		DWORDLONG dwlConditionMask = 0;
		int op = VER_EQUAL;

		SecureZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
		osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
		osvi.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS;
		VER_SET_CONDITION(dwlConditionMask, VER_PLATFORMID, op);
		iswindowsplatform = VerifyVersionInfo(&osvi, VER_PLATFORMID, dwlConditionMask);
	}
#else
	/* calling GetVersionEx using the OSVERSIONINFO structure.
	 * OSVERSIONINFOEX requires Win NT4 with SP6 or newer NT Versions.
	 * OSVERSIONINFOEX will fail on Win9x and older NT Versions.
	 * See also:
	 * http://msdn.microsoft.com/library/en-us/sysinfo/base/getversionex.asp
	 * http://msdn.microsoft.com/library/en-us/sysinfo/base/osversioninfo_str.asp
	 * http://msdn.microsoft.com/library/en-us/sysinfo/base/osversioninfoex_str.asp
	 */
	{
		OSVERSIONINFO versinfo;

		SecureZeroMemory(&versinfo, sizeof(OSVERSIONINFO));
		versinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
		GetVersionEx(&versinfo);
		iswindowsplatform = (versinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
	}
#endif

#elif defined(USE_GUARD_PAGES)
	pagesize = sysconf(_SC_PAGESIZE);
	if (pagesize == -1)
		fprintf(stderr, "Warning: call to sysconf() for _SC_PAGESIZE has failed...\n");
#ifdef NEED_DEV_ZERO
	dev_zero_fd = ws_open("/dev/zero", O_RDWR);
	g_assert(dev_zero_fd != -1);
#endif
#endif /* _WIN32 / USE_GUARD_PAGES */
}
Пример #26
0
BOOL IsWindowsServer()
{
	OSVERSIONINFOEX osvi;
	DWORDLONG dwlConditionMask = 0;

	// Initialize the OSVERSIONINFOEX structure.
	ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
	osvi.dwMajorVersion = 5;
	osvi.wProductType = VER_NT_SERVER;

	// Initialize the condition mask.
	VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
	VER_SET_CONDITION(dwlConditionMask, VER_PRODUCT_TYPE, VER_EQUAL);

	// Perform the test.
	return VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_PRODUCT_TYPE, dwlConditionMask);
}
Пример #27
0
/* MinGW doesn't have IsWindowsVersionOrGreater(). */
BOOL IsWindowsVersionOrGreater(WORD major_version, WORD minor_version,
	WORD service_pack_major)
{
    OSVERSIONINFOEX version_info;
    DWORDLONG condition_mask = 0;

    memset(&version_info, 0, sizeof(OSVERSIONINFOEX));
    version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
    version_info.dwMajorVersion = major_version;
    version_info.dwMinorVersion = minor_version;
    version_info.wServicePackMajor = service_pack_major;
    VER_SET_CONDITION(condition_mask, VER_MAJORVERSION, VER_GREATER_EQUAL);
    VER_SET_CONDITION(condition_mask, VER_MINORVERSION, VER_GREATER_EQUAL);
    VER_SET_CONDITION(condition_mask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
    return VerifyVersionInfo(&version_info,
	    VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR,
	    condition_mask);
}
Пример #28
0
/* Useful if we decide that smpd should not be installed on a domain controller */
BOOL Is_DomainController()
{
   OSVERSIONINFOEX osvi;
   DWORDLONG dwlConditionMask = 0;
 
   /* Initialize the OSVERSIONINFOEX structure. */
   ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
   osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
   osvi.dwMajorVersion = 5;
   osvi.wProductType = VER_NT_DOMAIN_CONTROLLER;
 
   /* Initialize the condition mask. */
   VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
   VER_SET_CONDITION(dwlConditionMask, VER_PRODUCT_TYPE, VER_EQUAL);
 
   /* Perform the test. */
   return VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_PRODUCT_TYPE, dwlConditionMask);
}
Пример #29
0
/* Vista is major: 6, minor: 0 */
bool IsVistaOrGreater()
{
    OSVERSIONINFOEX osver = { 0 };
    ULONGLONG condMask = 0;
    osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
    osver.dwMajorVersion = 6;
    VER_SET_CONDITION(condMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
    return VerifyVersionInfo(&osver, VER_MAJORVERSION, condMask);
}
Пример #30
0
BOOL IsVistaOrGreater(void)
{
	OSVERSIONINFOEX osvi;
	DWORDLONG condition = 0;
	ZeroMemory(&osvi, sizeof osvi);
	osvi.dwOSVersionInfoSize = sizeof osvi;
	osvi.dwMajorVersion = 6;
	VER_SET_CONDITION(condition, VER_MAJORVERSION, VER_GREATER_EQUAL);
	return VerifyVersionInfo(&osvi, VER_MAJORVERSION, condition);
}