Changeset 98694 in vbox
- Timestamp:
- Feb 22, 2023 11:08:43 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 155994
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Config.kmk
r98663 r98694 6881 6881 endif 6882 6882 6883 # x86 version of VBoxR3TstExe 6884 TEMPLATE_VBoxR3TstExe-x86 := 32-bit VBox Ring 3 Testcase Exe 6885 TEMPLATE_VBoxR3TstExe-x86_EXTENDS := VBoxR3TstExe 6886 TEMPLATE_VBoxR3TstExe-x86_BLD_TRG_ARCH := x86 6887 TEMPLATE_VBoxR3TstExe-x86_LIBS = $(LIB_RUNTIME_X86) $(TEMPLATE_VBoxR3Exe_LIBS) 6883 6888 6884 6889 # … … 7389 7394 TEMPLATE_VBoxMainClientDll_LDFLAGS.darwin = $(filter-out -bind_at_load,$(TEMPLATE_VBoxMainClientExe_LDFLAGS.darwin)) 7390 7395 7396 # x86 version of VBoxMainClientDll 7397 TEMPLATE_VBoxMainClientDll-x86 := 32-bit VBox MAIN Client (shared library) 7398 TEMPLATE_VBoxMainClientDll-x86_EXTENDS := VBoxMainClientDll 7399 TEMPLATE_VBoxMainClientDll-x86_BLD_TRG_ARCH := x86 7400 TEMPLATE_VBoxMainClientDll-x86_INST.win = $(INST_DLL)x86/ 7401 TEMPLATE_VBoxMainClientDll-x86_DEFS = $(filter-out HC_ARCH_BITS%,$(TEMPLATE_VBoxMainClientDll_DEFS)) \ 7402 HC_ARCH_BIT=32 ARCH_BITS=32 VBOX_IN_32_ON_64_MAIN_API 7403 TEMPLATE_VBoxMainClientDll-x86_LIBS = \ 7404 $(subst $(PATH_STAGE_LIB)/VBoxCOM$(VBOX_SUFF_LIB),$(PATH_STAGE_LIB)/VBoxCOM-x86$(VBOX_SUFF_LIB), \ 7405 $(subst $(LIB_RUNTIME),$(VBOX_LIB_RUNTIME_X86), \ 7406 $(subst $(LIB_XPCOM),$(VBOX_LIB_XPCOM_X86), \ 7407 $(TEMPLATE_VBoxMainClientDll_LIBS)))) 7408 7391 7409 # 7392 7410 # Template for building testcases which are API clients. -
trunk/src/VBox/Main/cbinding/Makefile.kmk
r98431 r98694 104 104 105 105 # 106 # The C API binding utility DLL, 32-bit variant for 64-bit hosts. 107 # 108 ifdef VBOX_WITH_32_ON_64_MAIN_API 109 DLLS += VBoxCAPI-x86 110 VBoxCAPI-x86_EXTENDS := VBoxCAPI 111 VBoxCAPI-x86_TEMPLATE := VBoxMainClientDll-x86 112 ifdef VBOX_WITH_XPCOM 113 VBoxCAPI-x86_INST := $(INST_BIN)VBoxCAPI-x86$(VBOX_SUFF_DLL) 114 endif 115 endif 116 117 # 106 118 # The C glue library. 107 119 # … … 124 136 $(VBOX_PATH_SDK)/bindings/c/glue/VBoxCAPIGlue.h \ 125 137 $(VBOX_PATH_SDK)/bindings/c/include/VBoxCAPI_v$(VBOX_API_VERSION).h 138 139 140 ifdef VBOX_WITH_32_ON_64_MAIN_API 141 # Same as above, but 32-bit version. 142 LIBRARIES += VBoxCAPIGlue-x86 143 VBoxCAPIGlue-x86_EXTENDS := VBoxCAPIGlue 144 VBoxCAPIGlue-x86_BLD_TRG_ARCH := x86 145 endif 146 126 147 127 148 if defined(VBOX_WITH_TESTCASES) && "$(KBUILD_TARGET)" != "darwin" … … 150 171 tstCAPIGlue_LIBS = \ 151 172 $(VBoxCAPIGlue_1_TARGET) 173 174 ifdef VBOX_WITH_32_ON_64_MAIN_API 175 # Same as above, but 32-bit version. 176 PROGRAMS += tstCAPIGlue-x86 177 tstCAPIGlue-x86_EXTENDS := tstCAPIGlue 178 tstCAPIGlue-x86_TEMPLATE := VBoxR3TstExe-x86 179 tstCAPIGlue-x86_BLD_TRG_ARCH := x86 180 tstCAPIGlue-x86_LIBS = $(VBoxCAPIGlue-x86_1_TARGET) 181 endif 152 182 endif 153 183 -
trunk/src/VBox/Main/cbinding/VBoxCAPI.cpp
r98297 r98694 776 776 * initialize it properly. The limited initialization in VBoxC is not 777 777 * sufficient, and causes trouble with com::Initialize() misbehaving. */ 778 RTR3InitDll( 0);778 RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 779 779 780 780 /* -
trunk/src/VBox/Main/cbinding/VBoxCAPIGlue.c
r98103 r98694 49 49 # include <dlfcn.h> 50 50 # include <pthread.h> 51 #else /* WIN32 */51 #else /* WIN32 */ 52 52 # include <Windows.h> 53 53 #endif /* WIN32 */ … … 57 57 * Defined Constants And Macros * 58 58 *********************************************************************************************************************************/ 59 #if defined(__i386__) || defined(_M_IX86) || defined(__X86__) 60 /** This is a 32-bit process running against a 64-bit VBox installation. 61 * Since there are only 64-bit VBox now, we don't need any runtime checks. */ 62 # define IS_32_ON_64 63 #endif 64 59 65 #if defined(__linux__) || defined(__linux_gnu__) || defined(__sun__) || defined(__FreeBSD__) 60 # define DYNLIB_NAME "VBoxXPCOMC.so" 66 # ifndef IS_32_ON_64 67 # define DYNLIB_NAME "VBoxXPCOMC.so" 68 # else 69 # define DYNLIB_NAME "VBoxCAPI-x86.so" 70 # endif 61 71 #elif defined(__APPLE__) 62 # define DYNLIB_NAME "VBoxXPCOMC.dylib" 63 #elif defined(__OS2__) 64 # define DYNLIB_NAME "VBoxXPCOMC.dll" 72 # ifndef IS_32_ON_64 73 # define DYNLIB_NAME "VBoxXPCOMC.dylib" 74 # else 75 # define DYNLIB_NAME "VBoxCAPI-x86.dylib" 76 # endif 65 77 #elif defined(WIN32) 66 # define DYNLIB_NAME "VBoxCAPI.dll" 78 # ifndef IS_32_ON_64 79 # define DYNLIB_NAME "VBoxCAPI.dll" 80 # else 81 # define DYNLIB_NAME "VBoxCAPI-x86.dll" 82 # define DYNLIB_SUBDIR "x86" 83 # define SLASH_DYNLIB_SUBDIR "\\" DYNLIB_SUBDIR 84 # endif 67 85 #else 68 86 # error "Port me" 87 #endif 88 #ifndef DYNLIB_SUBDIR 89 # define DYNLIB_SUBDIR "" 90 # define SLASH_DYNLIB_SUBDIR "" 91 #endif 92 93 #ifdef WIN32 94 # define DIR_SLASH_CH '\\' 95 #else 96 # define DIR_SLASH_CH '/' 69 97 #endif 70 98 … … 131 159 * (boolean). 132 160 */ 133 static int tryLoadLibrary(const char *pszHome, int fSetAppHome) 134 { 135 size_t cchHome = pszHome ? strlen(pszHome) : 0; 136 size_t cbBufNeeded; 137 char szName[4096]; 161 static int tryLoadLibrary(const char *pszHome, const char *pszSub, int fSetAppHome) 162 { 163 size_t const cchHome = pszHome ? strlen(pszHome) : 0; 164 size_t const cchSub = pszSub ? strlen(pszSub) : 0; 165 size_t cbBufNeeded; 166 size_t offName; 167 char szName[4096]; 138 168 139 169 /* 140 170 * Construct the full name. 141 171 */ 142 cbBufNeeded = cchHome + sizeof("/"DYNLIB_NAME);172 cbBufNeeded = cchHome + !!cchHome + cchSub + !!cchSub + sizeof(DYNLIB_NAME); 143 173 if (cbBufNeeded > sizeof(szName)) 144 174 { … … 147 177 return -1; 148 178 } 179 offName = 0; 149 180 if (cchHome) 150 181 { 151 memcpy(szName, pszHome, cchHome); 152 szName[cchHome] = '/'; 153 cchHome++; 154 } 155 memcpy(&szName[cchHome], DYNLIB_NAME, sizeof(DYNLIB_NAME)); 182 memcpy(&szName[offName], pszHome, cchHome); 183 offName += cchHome; 184 szName[offName++] = DIR_SLASH_CH; 185 } 186 if (cchSub) 187 { 188 memcpy(&szName[offName], pszSub, cchSub); 189 offName += cchSub; 190 szName[offName++] = DIR_SLASH_CH; 191 } 192 memcpy(&szName[offName], DYNLIB_NAME, sizeof(DYNLIB_NAME)); 156 193 157 194 /* … … 172 209 g_hVBoxCAPI = dlopen(szName, RTLD_NOW | RTLD_LOCAL); 173 210 #else /* WIN32 */ 174 g_hVBoxCAPI = LoadLibraryExA(szName, NULL /* hFile */, 0 /* dwFlags */); 211 g_hVBoxCAPI = LoadLibraryExA(szName, NULL /* hFile */, 212 cchHome ? LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32 : 0 /* dwFlags */); 213 if (!g_hVBoxCAPI && GetLastError() == ERROR_INVALID_PARAMETER) 214 g_hVBoxCAPI = LoadLibraryExA(szName, NULL /* hFile */, 0 /* dwFlags */); 175 215 #endif /* WIN32 */ 176 216 if (g_hVBoxCAPI) … … 194 234 if (g_pVBoxFuncs) 195 235 { 196 if ( (VBOX_CAPI_MAJOR(g_pVBoxFuncs->uVersion)197 == VBOX_CAPI_MAJOR(VBOX_CAPI_VERSION))198 && (VBOX_CAPI_MINOR(g_pVBoxFuncs->uVersion)199 >= VBOX_CAPI_MINOR(VBOX_CAPI_VERSION)))236 if ( VBOX_CAPI_MAJOR(g_pVBoxFuncs->uVersion) 237 == VBOX_CAPI_MAJOR(VBOX_CAPI_VERSION) 238 && VBOX_CAPI_MINOR(g_pVBoxFuncs->uVersion) 239 >= VBOX_CAPI_MINOR(VBOX_CAPI_VERSION)) 200 240 { 201 241 g_pfnGetFunctions = pfnGetFunctions; … … 266 306 pszHome = getenv("VBOX_APP_HOME"); 267 307 if (pszHome) 268 return tryLoadLibrary(pszHome, 0);308 return tryLoadLibrary(pszHome, DYNLIB_SUBDIR, 0); 269 309 270 310 /* … … 272 312 */ 273 313 #if defined(__gnu__linux__) || defined(__linux__) 274 if (tryLoadLibrary("/opt/VirtualBox", 1) == 0)275 return 0; 276 if (tryLoadLibrary("/usr/lib/virtualbox", 1) == 0)314 if (tryLoadLibrary("/opt/VirtualBox", DYNLIB_SUBDIR, 1) == 0) 315 return 0; 316 if (tryLoadLibrary("/usr/lib/virtualbox", DYNLIB_SUBDIR, 1) == 0) 277 317 return 0; 278 318 #elif defined(__sun__) 279 if (tryLoadLibrary("/opt/VirtualBox/amd64", 1) == 0)280 return 0; 281 if (tryLoadLibrary("/opt/VirtualBox/i386", 1) == 0)319 if (tryLoadLibrary("/opt/VirtualBox/amd64", NULL, 1) == 0) 320 return 0; 321 if (tryLoadLibrary("/opt/VirtualBox/i386", NULL, 1) == 0) 282 322 return 0; 283 323 #elif defined(__APPLE__) 284 if (tryLoadLibrary("/Applications/VirtualBox.app/Contents/MacOS", 1) == 0)324 if (tryLoadLibrary("/Applications/VirtualBox.app/Contents/MacOS", DYNLIB_SUBDIR, 1) == 0) 285 325 return 0; 286 326 #elif defined(__FreeBSD__) 287 if (tryLoadLibrary("/usr/local/lib/virtualbox", 1) == 0) 288 return 0; 289 #elif defined(__OS2__) 290 if (tryLoadLibrary("C:/Apps/VirtualBox", 1) == 0) 327 if (tryLoadLibrary("/usr/local/lib/virtualbox", DYNLIB_SUBDIR, 1) == 0) 291 328 return 0; 292 329 #elif defined(WIN32) 330 # ifdef IS_32_ON_64 331 pszHome = getenv("ProgramW6432"); 332 if (pszHome && tryLoadLibrary(pszHome, "\\Oracle\\VirtualBox" SLASH_DYNLIB_SUBDIR, 1) == 0) 333 return 0; 334 # endif 293 335 pszHome = getenv("ProgramFiles"); 294 if (pszHome) 295 { 296 char szPath[4096]; 297 size_t cb = sizeof(szPath); 298 char *tmp = szPath; 299 strncpy(tmp, pszHome, cb); 300 tmp[cb - 1] = '\0'; 301 cb -= strlen(tmp); 302 tmp += strlen(tmp); 303 strncpy(tmp, "/Oracle/VirtualBox", cb); 304 tmp[cb - 1] = '\0'; 305 if (tryLoadLibrary(szPath, 1) == 0) 306 return 0; 307 } 308 if (tryLoadLibrary("C:/Program Files/Oracle/VirtualBox", 1) == 0) 336 if (pszHome && tryLoadLibrary(pszHome, "\\Oracle\\VirtualBox" SLASH_DYNLIB_SUBDIR, 1) == 0) 337 return 0; 338 if (tryLoadLibrary("C:\\Program Files\\Oracle\\VirtualBox", DYNLIB_SUBDIR, 1) == 0) 309 339 return 0; 310 340 #else … … 315 345 * Finally try the dynamic linker search path. 316 346 */ 317 if (tryLoadLibrary(NULL, 1) == 0)347 if (tryLoadLibrary(NULL, NULL, 1) == 0) 318 348 return 0; 319 349
Note:
See TracChangeset
for help on using the changeset viewer.