/* $Id$ */
/** @file
* IPRT - Init Ring-3, Windows Specific Code.
*/
/*
* Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <Windows.h>
#endif
#include "internal-r3-win.h"
#include <iprt/initterm.h>
#include "../init.h"
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** Windows DLL loader protection level. */
/** Our simplified windows version. */
/** Extended windows version information. */
/** The native kernel32.dll handle. */
/** The native ntdll.dll handle. */
/**
* Translates OSVERSIONINOFEX into a Windows OS type.
*
* @returns The Windows OS type.
* @param pOSInfoEx The OS info returned by Windows.
*
* @remarks This table has been assembled from Usenet postings, personal
* observations, and reading other people's code. Please feel
* free to add to it or correct it.
* <pre>
dwPlatFormID dwMajorVersion dwMinorVersion dwBuildNumber
95 1 4 0 950
95 SP1 1 4 0 >950 && <=1080
95 OSR2 1 4 <10 >1080
98 1 4 10 1998
98 SP1 1 4 10 >1998 && <2183
98 SE 1 4 10 >=2183
ME 1 4 90 3000
NT 3.51 2 3 51 1057
NT 4 2 4 0 1381
2000 2 5 0 2195
XP 2 5 1 2600
2003 2 5 2 3790
Vista 2 6 0
CE 1.0 3 1 0
CE 2.0 3 2 0
CE 2.1 3 2 1
CE 3.0 3 3 0
</pre>
*/
{
&& dwMajorVersion == 4)
{
if ( dwMinorVersion < 10
&& dwBuildNumber == 950)
else if ( dwMinorVersion < 10
&& dwBuildNumber > 950
&& dwBuildNumber <= 1080)
else if ( dwMinorVersion < 10
&& dwBuildNumber > 1080)
else if ( dwMinorVersion == 10
&& dwBuildNumber == 1998)
else if ( dwMinorVersion == 10
&& dwBuildNumber > 1998
&& dwBuildNumber < 2183)
else if ( dwMinorVersion == 10
&& dwBuildNumber >= 2183)
else if (dwMinorVersion == 90)
}
else if (dwPlatformId == VER_PLATFORM_WIN32_NT)
{
if ( dwMajorVersion == 3
&& dwMinorVersion == 51)
else if ( dwMajorVersion == 4
&& dwMinorVersion == 0)
else if ( dwMajorVersion == 5
&& dwMinorVersion == 0)
else if ( dwMajorVersion == 5
&& dwMinorVersion == 1)
else if ( dwMajorVersion == 5
&& dwMinorVersion == 2)
else if ( dwMajorVersion == 6
&& dwMinorVersion == 0)
{
if (bProductType != VER_NT_WORKSTATION)
else
}
else if ( dwMajorVersion == 6
&& dwMinorVersion == 1)
else if ( dwMajorVersion == 6
&& dwMinorVersion == 2)
else if ( dwMajorVersion == 6
&& dwMinorVersion == 3)
else if ( dwMajorVersion == 6
&& dwMinorVersion == 4)
else
}
return enmVer;
}
/**
* Initializes the global variables related to windows version.
*/
static void rtR3InitWindowsVersion(void)
{
/*
* ASSUMES OSVERSIONINFOEX starts with the exact same layout as OSVERSIONINFO (safe).
*/
/*
* Use the NT version of GetVersionExW so we don't get fooled by
* compatability shims.
*/
if (pfnRtlGetVersion)
if (rcNt != 0)
{
/*
* Couldn't find it or it failed, try the windows version of the API.
*/
{
/*
* If that didn't work either, just get the basic version bits.
*/
else
{
}
}
}
}
static int rtR3InitNativeObtrusiveWorker(void)
{
/*
* Disable error popups.
*/
/*
* Restrict DLL searching for the process on windows versions which allow
* us to do so.
* - The first trick works on XP SP1+ and disables the searching of the
* current directory.
* - The second trick is W7 w/ KB2533623 and W8+, it restrict the DLL
* searching to the application directory and the System32 directory.
*/
PFNSETDLLDIRECTORY pfnSetDllDir = (PFNSETDLLDIRECTORY)GetProcAddress(g_hModKernel32, "SetDllDirectoryW");
if (pfnSetDllDir)
{
if (pfnSetDllDir(L""))
else
}
/** @bugref 6861: Observed GUI issues on Vista (32-bit and 64-bit). */
if (g_enmWinVer > kRTWinOSType_VISTA)
{
pfnSetDefDllDirs = (PFNSETDEFAULTDLLDIRECTORIES)GetProcAddress(g_hModKernel32, "SetDefaultDllDirectories");
if (pfnSetDefDllDirs)
{
else if (RT_SUCCESS(rc))
}
}
return rc;
}
{
/*
* Make sure we've got the handles of the two main Windows NT dlls.
*/
if (g_hModKernel32 == NULL)
return VERR_INTERNAL_ERROR_2;
if (g_hModNtDll == NULL)
return VERR_INTERNAL_ERROR_2;
if (!(fFlags & RTR3INIT_FLAGS_UNOBTRUSIVE))
return rc;
}
{
}
{
/* Nothing to do here. */
return VINF_SUCCESS;
}