Changeset 47822 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Aug 17, 2013 11:35:27 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 88083
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/win/dllmain.cpp
r46593 r47822 1 /* $Id$ */ 1 2 /** @file 2 * 3 * DLLMAIN - COM DLL exports 4 * 3 * VBoxC - COM DLL exports and DLL init/term. 5 4 */ 6 5 7 6 /* 8 * Copyright (C) 2006-201 1Oracle Corporation7 * Copyright (C) 2006-2013 Oracle Corporation 9 8 * 10 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 16 */ 18 17 18 19 /******************************************************************************* 20 * Header Files * 21 *******************************************************************************/ 19 22 #include "VBox/com/defs.h" 20 23 … … 26 29 27 30 #include <iprt/initterm.h> 31 #include <iprt/assert.h> 32 #include <iprt/string.h> 28 33 29 34 CComModule _Module; … … 34 39 END_OBJECT_MAP() 35 40 41 42 /******************************************************************************* 43 * Internal Functions * 44 *******************************************************************************/ 45 static void removeOldMess(void); 46 47 36 48 ///////////////////////////////////////////////////////////////////////////// 37 49 // DLL Entry Point … … 77 89 { 78 90 // registers object, typelib and all interfaces in typelib 91 removeOldMess(); 79 92 return _Module.RegisterServer(TRUE); 80 93 } … … 87 100 return _Module.UnregisterServer(TRUE); 88 101 } 102 103 104 105 /** 106 * Hack to clean out the interfaces belonging to the old typelib on development 107 * boxes and such likes. 108 */ 109 static void removeOldInterfaces(HKEY hkeyClassesRoot) 110 { 111 HKEY hkeyInterface; 112 LONG rc = RegOpenKeyExA(hkeyClassesRoot, "Interface", NULL, DELETE | KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, 113 &hkeyInterface); 114 if (rc == ERROR_SUCCESS) 115 { 116 for (DWORD idxKey = 0;; idxKey++) 117 { 118 char szCurNm[128 + 128]; 119 DWORD cbCurNm = 128; 120 rc = RegEnumKeyExA(hkeyInterface, idxKey, szCurNm, &cbCurNm, NULL, NULL, NULL, NULL); 121 if (rc == ERROR_NO_MORE_ITEMS) 122 break; 123 124 /* 125 * Get the typelib GUID and version associated with the interface. 126 */ 127 AssertBreak(rc == ERROR_SUCCESS); 128 strcpy(&szCurNm[cbCurNm], "\\TypeLib"); 129 HKEY hkeyIfTypelib; 130 rc = RegOpenKeyExA(hkeyInterface, szCurNm, NULL, KEY_QUERY_VALUE, &hkeyIfTypelib); 131 if (rc != ERROR_SUCCESS) 132 continue; 133 134 char szTypelibGuid[128]; 135 DWORD cbValue = sizeof(szTypelibGuid) - 1; 136 rc = RegQueryValueExA(hkeyIfTypelib, NULL, NULL, NULL, (PBYTE)&szTypelibGuid[0], &cbValue); 137 if (rc != ERROR_SUCCESS) 138 cbValue = 0; 139 szTypelibGuid[cbValue] = '\0'; 140 if (strcmp(szTypelibGuid, "{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}")) 141 { 142 RegCloseKey(hkeyIfTypelib); 143 continue; 144 } 145 146 char szTypelibVer[64]; 147 cbValue = sizeof(szTypelibVer) - 1; 148 rc = RegQueryValueExA(hkeyIfTypelib, "Version", NULL, NULL, (PBYTE)&szTypelibVer[0], &cbValue); 149 if (rc != ERROR_SUCCESS) 150 cbValue = 0; 151 szTypelibVer[cbValue] = '\0'; 152 153 RegCloseKey(hkeyIfTypelib); 154 155 if (strcmp(szTypelibVer, "1.3")) 156 continue; 157 158 159 /* 160 * Ok, it's an orphaned VirtualBox interface. Delete it. 161 */ 162 szCurNm[cbCurNm] = '\0'; 163 //RTAssertMsg2("Should delete HCR/Interface/%s\n", szCurNm); 164 rc = SHDeleteKeyA(hkeyInterface, szCurNm); 165 Assert(rc == ERROR_SUCCESS); 166 } 167 168 RegCloseKey(hkeyInterface); 169 } 170 } 171 172 173 /** 174 * Hack to clean out the old typelib on development boxes and such. 175 */ 176 static void removeOldTypelib(HKEY hkeyClassesRoot) 177 { 178 /* 179 * Open it and verify the identity. 180 */ 181 HKEY hkeyOldTyplib; 182 LONG rc = RegOpenKeyExA(hkeyClassesRoot, "TypeLib\\{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}", NULL, 183 DELETE | KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, &hkeyOldTyplib); 184 if (rc == ERROR_SUCCESS) 185 { 186 HKEY hkeyVer1Dot3; 187 rc = RegOpenKeyExA(hkeyOldTyplib, "1.3", NULL, KEY_READ, &hkeyVer1Dot3); 188 if (rc == ERROR_SUCCESS) 189 { 190 char szValue[128]; 191 DWORD cbValue = sizeof(szValue) - 1; 192 rc = RegQueryValueExA(hkeyVer1Dot3, NULL, NULL, NULL, (PBYTE)&szValue[0], &cbValue); 193 if (rc == ERROR_SUCCESS) 194 { 195 szValue[cbValue] = '\0'; 196 if (!strcmp(szValue, "VirtualBox Type Library")) 197 { 198 RegCloseKey(hkeyVer1Dot3); 199 hkeyVer1Dot3 = NULL; 200 201 /* 202 * Delete the type library. 203 */ 204 //RTAssertMsg2("Should delete HCR/TypeLib/{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}/1.3\n"); 205 rc = SHDeleteKeyA(hkeyOldTyplib, "1.3"); 206 Assert(rc == ERROR_SUCCESS); 207 } 208 } 209 210 if (hkeyVer1Dot3 != NULL) 211 RegCloseKey(hkeyVer1Dot3); 212 } 213 RegCloseKey(hkeyOldTyplib); 214 215 /* 216 * The typelib key should be empty now, so we can try remove it (non-recursively). 217 */ 218 rc = RegDeleteKeyA(hkeyClassesRoot, "TypeLib\\{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}"); 219 Assert(rc == ERROR_SUCCESS); 220 } 221 } 222 223 224 /** 225 * Hack to clean out the old typelib on development boxes and such. 226 */ 227 static void removeOldMess(void) 228 { 229 /* 230 * The standard location. 231 */ 232 removeOldTypelib(HKEY_CLASSES_ROOT); 233 removeOldInterfaces(HKEY_CLASSES_ROOT); 234 235 /* 236 * Wow64 if present. 237 */ 238 HKEY hkeyWow64; 239 LONG rc = RegOpenKeyExA(HKEY_CLASSES_ROOT, "Wow6432Node", NULL, 240 DELETE | KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, &hkeyWow64); 241 if (rc == ERROR_SUCCESS) 242 { 243 removeOldTypelib(hkeyWow64); 244 removeOldInterfaces(hkeyWow64); 245 246 RegCloseKey(hkeyWow64); 247 } 248 } 249
Note:
See TracChangeset
for help on using the changeset viewer.