/* $Id$ */
/** @file
*/
/*
* 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <SessionImpl.h>
#include <VirtualBoxClientImpl.h>
#include <atlbase.h>
#include <atlcom.h>
#include <iprt/initterm.h>
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** @def WITH_MANUAL_CLEANUP
* Manually clean up the registry. */
#if defined(DEBUG) && !defined(VBOX_IN_32_ON_64_MAIN_API)
//# define WITH_MANUAL_CLEANUP
#endif
#ifdef WITH_MANUAL_CLEANUP
/** Type library GUIDs to clean up manually. */
static const char * const g_apszTypelibGuids[] =
{
"{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}",
"{d7569351-1750-46f0-936e-bd127d5bc264}",
};
/** Same as above but with a "Typelib\\" prefix. */
static const char * const g_apszTypelibGuidKeys[] =
{
"TypeLib\\{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}",
"TypeLib\\{d7569351-1750-46f0-936e-bd127d5bc264}",
};
/** Type library version to clean up manually. */
static const char * const g_apszTypelibVersions[] =
{
"1.0",
"1.3",
};
#endif
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
#ifdef WITH_MANUAL_CLEANUP
static void removeOldMess(void);
#endif
/////////////////////////////////////////////////////////////////////////////
// DLL Entry Point
extern "C"
{
if (dwReason == DLL_PROCESS_ATTACH)
{
// idempotent, so doesn't harm, and needed for COM embedding scenario
}
else if (dwReason == DLL_PROCESS_DETACH)
{
}
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE
{
}
/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type
{
}
/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry
{
// registers object, typelib and all interfaces in typelib
}
/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry
{
#ifdef WITH_MANUAL_CLEANUP
#endif
return hrc;
}
#ifdef WITH_MANUAL_CLEANUP
/**
* Checks if the typelib GUID is one of the ones we wish to clean up.
*
* @returns true if it should be cleaned up, false if not.
* @param pszTypelibGuid The typelib GUID as bracketed string.
*/
{
unsigned i = RT_ELEMENTS(g_apszTypelibGuids);
while (i-- > 0)
return true;
return false;
}
/**
* Checks if the typelib version is one of the ones we wish to clean up.
*
* @returns true if it should be cleaned up, false if not.
* @param pszTypelibVer The typelib version as string.
*/
{
unsigned i = RT_ELEMENTS(g_apszTypelibVersions);
while (i-- > 0)
return true;
return false;
}
/**
* Hack to clean out the class IDs belonging to obsolete typelibs on development
* boxes and such likes.
*/
{
LONG rc = RegOpenKeyExA(hkeyClassesRoot, "CLSID", NULL, DELETE | KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE,
&hkeyClsId);
if (rc == ERROR_SUCCESS)
{
{
if (rc == ERROR_NO_MORE_ITEMS)
break;
/*
* Get the typelib GUID and program ID with the class ID.
*/
if (rc != ERROR_SUCCESS)
continue;
if (rc != ERROR_SUCCESS)
cbValue = 0;
continue;
/* ProgId */
if (rc != ERROR_SUCCESS)
continue;
if (rc != ERROR_SUCCESS)
cbValue = 0;
continue;
/*
* Ok, it's an orphaned VirtualBox interface. Delete it.
*/
//rc = SHDeleteKeyA(hkeyClsId, szCurNm);
}
}
}
/**
* Hack to clean out the interfaces belonging to obsolete typelibs on
* development boxes and such likes.
*/
{
LONG rc = RegOpenKeyExA(hkeyClassesRoot, "Interface", NULL, DELETE | KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE,
if (rc == ERROR_SUCCESS)
{
{
if (rc == ERROR_NO_MORE_ITEMS)
break;
/*
* Get the typelib GUID and version associated with the interface.
*/
if (rc != ERROR_SUCCESS)
continue;
if (rc != ERROR_SUCCESS)
cbValue = 0;
{
continue;
}
if (rc != ERROR_SUCCESS)
cbValue = 0;
continue;
/*
* Ok, it's an orphaned VirtualBox interface. Delete it.
*/
}
}
}
/**
* Hack to clean obsolete typelibs on development boxes and such.
*/
{
/*
* Open it and verify the identity.
*/
unsigned i = RT_ELEMENTS(g_apszTypelibGuidKeys);
while (i-- > 0)
{
if (rc == ERROR_SUCCESS)
{
while (iVer-- > 0)
{
if (rc == ERROR_SUCCESS)
{
if (rc == ERROR_SUCCESS)
{
{
/*
* Delete the type library.
*/
//RTAssertMsg2("Should delete HCR\\%s\\%s\n", g_apszTypelibGuidKeys[i], g_apszTypelibVersions[iVer]);
}
}
}
}
/*
* The typelib key should be empty now, so we can try remove it (non-recursively).
*/
}
}
}
/**
* Hack to clean out obsolete typelibs on development boxes and such.
*/
static void removeOldMess(void)
{
/*
* The standard location.
*/
/*
* Wow64 if present.
*/
if (rc == ERROR_SUCCESS)
{
}
}
#endif /* WITH_MANUAL_CLEANUP */