BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved) { BOOL bStatus = TRUE; switch (fdwReason) { case DLL_PROCESS_ATTACH: RTR3InitDll(0); VbglR3Init(); LogRel(("VBOXNP: DLL loaded.\n")); break; case DLL_PROCESS_DETACH: LogRel(("VBOXNP: DLL unloaded.\n")); VbglR3Term(); /// @todo RTR3Term(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; default: break; } return(bStatus); }
VBOXDRVCFG_DECL(HRESULT) VBoxDrvCfgInit() { int rc = RTR3InitDll(0); if (rc != VINF_SUCCESS) { NonStandardLogRelCrap(("Could not init IPRT!, rc (%d)\n", rc)); return E_FAIL; } return S_OK; }
void IPC_InitLog(const char *prefix) { #ifdef VBOX // initialize VBox Runtime RTR3InitDll(0); PL_strncpyz(ipcLogPrefix, prefix, sizeof(ipcLogPrefix)); #else if (PR_GetEnv("IPC_LOG_ENABLE")) { ipcLogEnabled = PR_TRUE; PL_strncpyz(ipcLogPrefix, prefix, sizeof(ipcLogPrefix)); } #endif }
status_t VBoxGuestDeskbarView::_Init(BMessage *archive) { BString toolTipText; toolTipText << VBOX_PRODUCT << " Guest Additions "; toolTipText << VBOX_VERSION_MAJOR << "." << VBOX_VERSION_MINOR << "." << VBOX_VERSION_BUILD; toolTipText << "r" << VBOX_SVN_REV; SetToolTip(toolTipText.String()); image_info info; if (our_image(info) != B_OK) return B_ERROR; BFile file(info.name, B_READ_ONLY); if (file.InitCheck() < B_OK) return B_ERROR; BResources resources(&file); if (resources.InitCheck() < B_OK) return B_ERROR; const void *data = NULL; size_t size; //data = resources.LoadResource(B_VECTOR_ICON_TYPE, // kNetworkStatusNoDevice + i, &size); data = resources.LoadResource('data', 400, &size); if (data != NULL) { BMemoryIO mem(data, size); fIcon = BTranslationUtils::GetBitmap(&mem); } int rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); if (RT_SUCCESS(rc)) { rc = VbglR3Init(); if (RT_SUCCESS(rc)) { fClipboardService = new VBoxClipboardService(); fDisplayService = new VBoxDisplayService(); } else LogRel(("VBoxGuestDeskbarView::_init VbglR3Init failed. rc=%d\n", rc)); } else LogRel(("VBoxGuestDeskbarView::_init RTR3InitDll failed. rc=%d\n", rc)); return RTErrConvertToErrno(rc); }
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) { if (dwReason == DLL_PROCESS_ATTACH) { _Module.Init(ObjectMap, hInstance, &LIBID_VirtualBox); DisableThreadLibraryCalls(hInstance); // idempotent, so doesn't harm, and needed for COM embedding scenario RTR3InitDll(0); } else if (dwReason == DLL_PROCESS_DETACH) { _Module.Term(); } return TRUE; }
DECLEXPORT(EGLDisplay) eglGetDisplay(EGLNativeDisplayType hDisplay) { Display *pDisplay; int rc, cError, cEvent, cMajor, cMinor; rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); if (RT_FAILURE(rc)) return EGL_NO_DISPLAY; if (!clearEGLError()) /* Set up our tls. */ return EGL_NO_DISPLAY; if (hDisplay != EGL_DEFAULT_DISPLAY) pDisplay = hDisplay; else { RTOnce(&g_defaultDisplayOnce, defaultDisplayInitOnce, NULL); pDisplay = g_pDefaultDisplay; } if (pDisplay && glXQueryExtension(pDisplay, &cError, &cEvent)) if (glXQueryVersion(pDisplay, &cMajor, &cMinor)) if (cMajor > 1 || (cMajor == 1 && cMinor >= 3)) return (EGLDisplay) pDisplay; return EGL_NO_DISPLAY; }
BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved) { (void) lpvReserved; (void) hDLLInst; switch (fdwReason) { case DLL_PROCESS_ATTACH: { int rc; rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); CRASSERT(rc==0); # ifdef IN_GUEST rc = VbglR3Init(); # endif LogRel(("crUtil DLL loaded.\n")); # if defined(DEBUG_misha) char aName[MAX_PATH]; GetModuleFileNameA(hDLLInst, aName, RT_ELEMENTS(aName)); crDbgCmdSymLoadPrint(aName, hDLLInst); # endif break; } case DLL_PROCESS_DETACH: { LogRel(("crUtil DLL unloaded.")); # ifdef IN_GUEST VbglR3Term(); # endif } default: break; } return TRUE; }
/** * Shows a balloon message using VBoxTray's notification area in the * Windows task bar. * * @param hwndParent Window handle of parent. * @param string_size Size of variable string. * @param variables The actual variable string. * @param stacktop Pointer to a pointer to the current stack. */ VBOXINSTALLHELPER_EXPORT VBoxTrayShowBallonMsg(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop) { EXDLL_INIT(); char szMsg[256]; char szTitle[128]; HRESULT hr = vboxPopString(szMsg, sizeof(szMsg) / sizeof(char)); if (SUCCEEDED(hr)) hr = vboxPopString(szTitle, sizeof(szTitle) / sizeof(char)); /** @todo Do we need to restore the stack on failure? */ if (SUCCEEDED(hr)) { RTR3InitDll(0); uint32_t cbMsg = sizeof(VBOXTRAYIPCMSG_SHOWBALLOONMSG) + strlen(szMsg) + 1 /* Include terminating zero */ + strlen(szTitle) + 1; /* Dito. */ Assert(cbMsg); PVBOXTRAYIPCMSG_SHOWBALLOONMSG pIpcMsg = (PVBOXTRAYIPCMSG_SHOWBALLOONMSG)RTMemAlloc(cbMsg); if (pIpcMsg) { /* Stuff in the strings. */ memcpy(pIpcMsg->szMsgContent, szMsg, strlen(szMsg) + 1); memcpy(pIpcMsg->szMsgTitle, szTitle, strlen(szTitle) + 1); /* Pop off the values in reverse order from the stack. */ if (SUCCEEDED(hr)) hr = vboxPopULong((ULONG*)&pIpcMsg->uType); if (SUCCEEDED(hr)) hr = vboxPopULong((ULONG*)&pIpcMsg->uShowMS); if (SUCCEEDED(hr)) { RTLOCALIPCSESSION hSession = 0; int rc = vboxConnectToVBoxTray(&hSession); if (RT_SUCCESS(rc)) { VBOXTRAYIPCHEADER ipcHdr = { VBOXTRAY_IPC_HDR_MAGIC, 0 /* Header version */, VBOXTRAYIPCMSGTYPE_SHOWBALLOONMSG, cbMsg }; rc = RTLocalIpcSessionWrite(hSession, &ipcHdr, sizeof(ipcHdr)); if (RT_SUCCESS(rc)) rc = RTLocalIpcSessionWrite(hSession, pIpcMsg, cbMsg); int rc2 = RTLocalIpcSessionClose(hSession); if (RT_SUCCESS(rc)) rc = rc2; } if (RT_FAILURE(rc)) hr = __HRESULT_FROM_WIN32(ERROR_BROKEN_PIPE); } RTMemFree(pIpcMsg); } else hr = __HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY); } /* Push simple return value on stack. */ SUCCEEDED(hr) ? pushstring("0") : pushstring("1"); }
/** * Do one-time initializations for the faker. * Returns TRUE on success, FALSE otherwise. */ static bool stubInitLocked(void) { /* Here is where we contact the mothership to find out what we're supposed * to be doing. Networking code in a DLL initializer. I sure hope this * works :) * * HOW can I pass the mothership address to this if I already know it? */ CRConnection *conn = NULL; char response[1024]; char **spuchain; int num_spus; int *spu_ids; char **spu_names; const char *app_id; int i; int disable_sync = 0; stubInitVars(); crGetProcName(response, 1024); crDebug("Stub launched for %s", response); #if defined(CR_NEWWINTRACK) && !defined(WINDOWS) /*@todo when vm boots with compiz turned on, new code causes hang in xcb_wait_for_reply in the sync thread * as at the start compiz runs our code under XGrabServer. */ if (!crStrcmp(response, "compiz") || !crStrcmp(response, "compiz_real") || !crStrcmp(response, "compiz.real") || !crStrcmp(response, "compiz-bin")) { disable_sync = 1; } #elif defined(WINDOWS) && defined(VBOX_WITH_WDDM) && defined(VBOX_WDDM_MINIPORT_WITH_VISIBLE_RECTS) if (GetModuleHandle(VBOX_MODNAME_DISPD3D)) { disable_sync = 1; crDebug("running with " VBOX_MODNAME_DISPD3D); stub.trackWindowVisibleRgn = 0; stub.bRunningUnderWDDM = true; } #endif /* @todo check if it'd be of any use on other than guests, no use for windows */ app_id = crGetenv( "CR_APPLICATION_ID_NUMBER" ); crNetInit( NULL, NULL ); #ifndef WINDOWS { CRNetServer ns; ns.name = "vboxhgcm://host:0"; ns.buffer_size = 1024; crNetServerConnect(&ns #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) , NULL #endif ); if (!ns.conn) { crWarning("Failed to connect to host. Make sure 3D acceleration is enabled for this VM."); return false; } else { crNetFreeConnection(ns.conn); } #if 0 && defined(CR_NEWWINTRACK) { Status st = XInitThreads(); if (st==0) { crWarning("XInitThreads returned %i", (int)st); } } #endif } #endif strcpy(response, "2 0 feedback 1 pack"); spuchain = crStrSplit( response, " " ); num_spus = crStrToInt( spuchain[0] ); spu_ids = (int *) crAlloc( num_spus * sizeof( *spu_ids ) ); spu_names = (char **) crAlloc( num_spus * sizeof( *spu_names ) ); for (i = 0 ; i < num_spus ; i++) { spu_ids[i] = crStrToInt( spuchain[2*i+1] ); spu_names[i] = crStrdup( spuchain[2*i+2] ); crDebug( "SPU %d/%d: (%d) \"%s\"", i+1, num_spus, spu_ids[i], spu_names[i] ); } stubSetDefaultConfigurationOptions(); stub.spu = crSPULoadChain( num_spus, spu_ids, spu_names, stub.spu_dir, NULL ); crFree( spuchain ); crFree( spu_ids ); for (i = 0; i < num_spus; ++i) crFree(spu_names[i]); crFree( spu_names ); // spu chain load failed somewhere if (!stub.spu) { return false; } crSPUInitDispatchTable( &glim ); /* This is unlikely to change -- We still want to initialize our dispatch * table with the functions of the first SPU in the chain. */ stubInitSPUDispatch( stub.spu ); /* we need to plug one special stub function into the dispatch table */ glim.GetChromiumParametervCR = stub_GetChromiumParametervCR; #if !defined(VBOX_NO_NATIVEGL) /* Load pointers to native OpenGL functions into stub.nativeDispatch */ stubInitNativeDispatch(); #endif /*crDebug("stub init"); raise(SIGINT);*/ #ifdef WINDOWS # ifndef CR_NEWWINTRACK stubInstallWindowMessageHook(); # endif #endif #ifdef CR_NEWWINTRACK { int rc; RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); if (!disable_sync) { crDebug("Starting sync thread"); rc = RTThreadCreate(&stub.hSyncThread, stubSyncThreadProc, NULL, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "Sync"); if (RT_FAILURE(rc)) { crError("Failed to start sync thread! (%x)", rc); } RTThreadUserWait(stub.hSyncThread, 60 * 1000); RTThreadUserReset(stub.hSyncThread); crDebug("Going on"); } } #endif #ifdef GLX stub.xshmSI.shmid = -1; stub.bShmInitFailed = GL_FALSE; stub.pGLXPixmapsHash = crAllocHashtable(); stub.bXExtensionsChecked = GL_FALSE; stub.bHaveXComposite = GL_FALSE; stub.bHaveXFixes = GL_FALSE; #endif return true; }
/** * Initializes pam_vbox. * * @return IPRT status code. * @param hPAM PAM handle. */ static int pam_vbox_init(pam_handle_t *hPAM) { #ifdef DEBUG g_pam_handle = hPAM; /* hack for getting assertion text */ #endif /* Don't make assertions panic because the PAM stack + * the current logon module won't work anymore (or just restart). * This could result in not able to log into the system anymore. */ RTAssertSetMayPanic(false); pam_vbox_log(hPAM, "pam_vbox: %sr%s, running on %s\n", RTBldCfgVersion(), RTBldCfgRevisionStr(), RTBldCfgTargetArch()); int rc = RTR3InitDll(0); if (RT_FAILURE(rc)) { pam_vbox_error(hPAM, "pam_vbox_init: could not init runtime! rc=%Rrc. Aborting\n", rc); return PAM_SUCCESS; /* Jump out as early as we can to not mess around. */ } pam_vbox_log(hPAM, "pam_vbox_init: runtime initialized\n"); if (RT_SUCCESS(rc)) { rc = VbglR3InitUser(); if (RT_FAILURE(rc)) { switch(rc) { case VERR_ACCESS_DENIED: pam_vbox_error(hPAM, "pam_vbox_init: access is denied to guest driver! Please make sure you run with sufficient rights. Aborting\n"); break; case VERR_FILE_NOT_FOUND: pam_vbox_error(hPAM, "pam_vbox_init: guest driver not found! Guest Additions installed? Aborting\n"); break; default: pam_vbox_error(hPAM, "pam_vbox_init: could not init VbglR3 library! rc=%Rrc. Aborting\n", rc); break; } } pam_vbox_log(hPAM, "pam_vbox_init: guest lib initialized\n"); } if (RT_SUCCESS(rc)) { char *rhost = NULL; char *tty = NULL; char *prompt = NULL; #ifdef RT_OS_SOLARIS pam_get_item(hPAM, PAM_RHOST, (void**) &rhost); pam_get_item(hPAM, PAM_TTY, (void**) &tty); pam_get_item(hPAM, PAM_USER_PROMPT, (void**) &prompt); #else pam_get_item(hPAM, PAM_RHOST, (const void**) &rhost); pam_get_item(hPAM, PAM_TTY, (const void**) &tty); pam_get_item(hPAM, PAM_USER_PROMPT, (const void**) &prompt); #endif pam_vbox_log(hPAM, "pam_vbox_init: rhost=%s, tty=%s, prompt=%s\n", rhost ? rhost : "<none>", tty ? tty : "<none>", prompt ? prompt : "<none>"); } return rc; }