static void swapsyncConnect(void) { char hostname[4096], protocol[4096]; unsigned short port; crNetInit(NULL, NULL); if (!crParseURL( render_spu.swap_master_url, protocol, hostname, &port, 9876)) crError( "Bad URL: %s", render_spu.swap_master_url ); if (render_spu.is_swap_master) { int a; render_spu.swap_conns = (CRConnection **)crAlloc( render_spu.num_swap_clients*sizeof(CRConnection *)); for (a=0; a<render_spu.num_swap_clients; a++) { render_spu.swap_conns[a] = crNetAcceptClient( protocol, hostname, port, render_spu.swap_mtu, 1); } } else { render_spu.swap_conns = (CRConnection **)crAlloc(sizeof(CRConnection *)); render_spu.swap_conns[0] = crNetConnectToServer(render_spu.swap_master_url, port, render_spu.swap_mtu, 1); if (!render_spu.swap_conns[0]) crError("Failed connection"); } }
void packspuConnectToServer( CRNetServer *server #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) , struct VBOXUHGSMI *pHgsmi #endif ) { crNetInit( packspuReceiveData, NULL ); crNetServerConnect( server #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) , pHgsmi #endif ); }
CRConnection *crMothershipConnect( void ) { const char *mother_server; crNetInit( NULL, NULL ); mother_server = crGetenv( "CRMOTHERSHIP" ); if (!mother_server) { crWarning( "Couldn't find the CRMOTHERSHIP environment variable, defaulting to localhost" ); mother_server = "localhost"; } return crNetConnectToServer( mother_server, DEFAULT_MOTHERSHIP_PORT, 8096, 0 ); }
int main( int argc, char *argv[] ) { char *mothership = NULL; crNetInit(crutProxyRecv, crutProxyClose); crutInitProxy(mothership); for (;;) crNetRecv(); #ifndef WINDOWS return 0; #endif }
static void injectorspuConnect( void ) { char hostname[4096], protocol[4096] ; unsigned short port ; crNetInit( injectorspuReceiveData, NULL ) ; injector_spu.oob_conn = crAlloc( sizeof(CRConnection*) ) ; if ( ! crParseURL( injector_spu.oob_url, protocol, hostname, &port, (unsigned short) INJECTORSPU_OOB_PORT ) ) crError( "Malformed URL: \"%s\"", injector_spu.oob_url ) ; injector_spu.oob_conn = crNetAcceptClient( protocol, NULL, (short) port, 32768 /*mtu*/, 0 /*broker*/ ) ; /* Initialize the message we send back after every frame */ injector_spu.info_msg.header.type = CR_MESSAGE_OOB ; injector_spu.info_msg.header.conn_id = injector_spu.oob_conn->id ; injector_spu.info_msg.frameNum = 0 ; }
static void packspuFirstConnectToServer( CRNetServer *server #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) , struct VBOXUHGSMI *pHgsmi #endif ) { crNetInit( packspuReceiveData, NULL ); crNetServerConnect( server #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) , pHgsmi #endif ); if (server->conn) { g_u32VBoxHostCaps = crNetHostCapsGet(); crPackCapsSet(g_u32VBoxHostCaps); } }
CRConnection *__copy_of_crMothershipConnect( void ) { CRConnection *conn; const char *mother_server = NULL; crNetInit( NULL, NULL ); mother_server = crGetenv( "CRMOTHERSHIP" ); if (!mother_server) { crWarning( "Couldn't find the CRMOTHERSHIP environment variable, defaulting to localhost" ); mother_server = "localhost"; } conn = crNetConnectToServer( mother_server, DEFAULT_MOTHERSHIP_PORT, 8096, 0 ); if (!conn) crError("Failed to connect to mothership\n"); return conn; }
void replicatespuConnectToServer( CRNetServer *server ) { crNetInit( replicatespuReceiveData, NULL ); crNetServerConnect( server ); }
/** * Do CRServer initializations. After this, we can begin servicing clients. */ void crServerInit(int argc, char *argv[]) { int i; char *mothership = NULL; CRMuralInfo *defaultMural; for (i = 1 ; i < argc ; i++) { if (!crStrcmp( argv[i], "-mothership" )) { if (i == argc - 1) { crError( "-mothership requires an argument" ); } mothership = argv[i+1]; i++; } else if (!crStrcmp( argv[i], "-port" )) { /* This is the port on which we'll accept client connections */ if (i == argc - 1) { crError( "-port requires an argument" ); } cr_server.tcpip_port = crStrToInt(argv[i+1]); i++; } else if (!crStrcmp( argv[i], "-vncmode" )) { cr_server.vncMode = 1; } else if (!crStrcmp( argv[i], "-help" )) { crPrintHelp(); exit(0); } } signal( SIGTERM, crServerCleanup ); signal( SIGINT, crServerCleanup ); #ifndef WINDOWS signal( SIGPIPE, SIG_IGN ); #endif #if DEBUG_FP_EXCEPTIONS { fpu_control_t mask; _FPU_GETCW(mask); mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM | _FPU_MASK_OM | _FPU_MASK_UM); _FPU_SETCW(mask); } #endif cr_server.firstCallCreateContext = GL_TRUE; cr_server.firstCallMakeCurrent = GL_TRUE; /* * Create default mural info and hash table. */ cr_server.muralTable = crAllocHashtable(); defaultMural = (CRMuralInfo *) crCalloc(sizeof(CRMuralInfo)); crHashtableAdd(cr_server.muralTable, 0, defaultMural); cr_server.programTable = crAllocHashtable(); crNetInit(crServerRecv, crServerClose); crStateInit(); crServerGatherConfiguration(mothership); crStateLimitsInit( &(cr_server.limits) ); /* * Default context */ cr_server.contextTable = crAllocHashtable(); cr_server.DummyContext = crStateCreateContext( &cr_server.limits, CR_RGB_BIT | CR_DEPTH_BIT, NULL ); cr_server.curClient->currentCtx = cr_server.DummyContext; crServerInitDispatch(); crStateDiffAPI( &(cr_server.head_spu->dispatch_table) ); crUnpackSetReturnPointer( &(cr_server.return_ptr) ); crUnpackSetWritebackPointer( &(cr_server.writeback_ptr) ); cr_server.barriers = crAllocHashtable(); cr_server.semaphores = crAllocHashtable(); }
/* Windows crap */ BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved) { (void) lpvReserved; switch (fdwReason) { case DLL_PROCESS_ATTACH: { CRNetServer ns; #ifdef CHROMIUM_THREADSAFE crInitTSD(&g_stubCurrentContextTSD); #endif crInitMutex(&stub_init_mutex); #ifdef VDBG_VEHANDLER vboxVDbgVEHandlerRegister(); #endif crNetInit(NULL, NULL); ns.name = "vboxhgcm://host:0"; ns.buffer_size = 1024; crNetServerConnect(&ns #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) , NULL #endif ); if (!ns.conn) { crDebug("Failed to connect to host (is guest 3d acceleration enabled?), aborting ICD load."); #ifdef VDBG_VEHANDLER vboxVDbgVEHandlerUnregister(); #endif return FALSE; } else crNetFreeConnection(ns.conn); break; } case DLL_PROCESS_DETACH: { /* do exactly the same thing as for DLL_THREAD_DETACH since * DLL_THREAD_DETACH is not called for the thread doing DLL_PROCESS_DETACH according to msdn docs */ stubSetCurrentContext(NULL); if (stub_initialized) { CRASSERT(stub.spu); stub.spu->dispatch_table.VBoxDetachThread(); } stubSPUSafeTearDown(); #ifdef CHROMIUM_THREADSAFE crFreeTSD(&g_stubCurrentContextTSD); #endif #ifdef VDBG_VEHANDLER vboxVDbgVEHandlerUnregister(); #endif break; } case DLL_THREAD_ATTACH: { if (stub_initialized) { CRASSERT(stub.spu); stub.spu->dispatch_table.VBoxAttachThread(); } break; } case DLL_THREAD_DETACH: { stubSetCurrentContext(NULL); if (stub_initialized) { CRASSERT(stub.spu); stub.spu->dispatch_table.VBoxDetachThread(); } break; } default: break; } return TRUE; }
/** * 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; }
void packspuConnectToServer( CRNetServer *server ) { crNetInit( packspuReceiveData, packspuCloseCallback ); crNetServerConnect( server ); }
static void crutInitServer(char *mothership, int argc, char *argv[]) { char response[8096]; #ifndef WINDOWS int drawable; #endif int displayMode; crNetInit( NULL/*crutServerRecv*/, crutServerClose ); crutInitAPI( &crut_api, mothership ); /* here? */ crMothershipIdentifyCRUTServer( crut_api.mothershipConn, response ); crutGetWindowParams( &crut_api ); /* set up GLUT window */ glutInit(&argc, argv); displayMode = GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA; if (crut_api.compositeAlpha) displayMode |= GLUT_ALPHA; if (crut_api.compositeDepth) displayMode |= GLUT_STENCIL; glutInitDisplayMode(displayMode); glutInitWindowPosition( crut_api.winX,crut_api.winY ); glutInitWindowSize( crut_api.winWidth,crut_api.winHeight ); glutCreateWindow("CRUTServer Interactive Window"); glutDisplayFunc(showWin); /* give window id to mothership */ #ifndef WINDOWS #ifdef DARWIN /* XXX \todo crut get current drawable (this only gets glut win_num) */ drawable = glutGetWindow(); #else /* XXX is this cast safe? */ drawable = (int) glXGetCurrentDrawable(); #endif crutSetWindowID( &crut_api, drawable); #endif /* use API to connect to clients */ crutConnectToClients( &crut_api ); /* Retrieve events to send out */ crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_mouse", response ); crut_server.callbacks.mouse = crStrToInt(response); crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_keyboard", response ); crut_server.callbacks.keyboard = crStrToInt(response); crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_motion", response ); crut_server.callbacks.motion = crStrToInt(response); crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_passivemotion", response ); crut_server.callbacks.passivemotion = crStrToInt(response); crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_reshape", response ); crut_server.callbacks.reshape = crStrToInt(response); crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_visibility", response ); crut_server.callbacks.visibility = crStrToInt(response); crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_menu", response ); crut_server.callbacks.menu = crStrToInt(response); /* Exit flag */ crMothershipGetCRUTServerParam( crut_api.mothershipConn, response, "exit_on_escape"); crut_server.exit_on_escape = crStrToInt(response); #ifdef USE_CRUT_MENUS crutGetMenuXML(); buildMenu(); #endif }
/** * Do CRServer initializations. After this, we can begin servicing clients. */ GLboolean crVBoxServerInit(void) { CRMuralInfo *defaultMural; #if DEBUG_FP_EXCEPTIONS { fpu_control_t mask; _FPU_GETCW(mask); mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM | _FPU_MASK_OM | _FPU_MASK_UM); _FPU_SETCW(mask); } #endif crNetInit(crServerRecv, crServerClose); cr_server.firstCallCreateContext = GL_TRUE; cr_server.firstCallMakeCurrent = GL_TRUE; cr_server.bIsInLoadingState = GL_FALSE; cr_server.bIsInSavingState = GL_FALSE; cr_server.pCleanupClient = NULL; /* * Create default mural info and hash table. */ cr_server.muralTable = crAllocHashtable(); defaultMural = (CRMuralInfo *) crCalloc(sizeof(CRMuralInfo)); crHashtableAdd(cr_server.muralTable, 0, defaultMural); cr_server.programTable = crAllocHashtable(); crStateInit(); crStateLimitsInit( &(cr_server.limits) ); cr_server.barriers = crAllocHashtable(); cr_server.semaphores = crAllocHashtable(); crUnpackSetReturnPointer( &(cr_server.return_ptr) ); crUnpackSetWritebackPointer( &(cr_server.writeback_ptr) ); /* * Default context */ cr_server.contextTable = crAllocHashtable(); cr_server.DummyContext = crStateCreateContext( &cr_server.limits, CR_RGB_BIT | CR_DEPTH_BIT, NULL ); cr_server.pContextCreateInfoTable = crAllocHashtable(); cr_server.pWindowCreateInfoTable = crAllocHashtable(); crServerSetVBoxConfigurationHGCM(); if (!cr_server.head_spu) return GL_FALSE; crServerInitDispatch(); crStateDiffAPI( &(cr_server.head_spu->dispatch_table) ); /*Check for PBO support*/ if (crStateGetCurrent()->extensions.ARB_pixel_buffer_object) { cr_server.bUsePBOForReadback=GL_TRUE; } return GL_TRUE; }
int main(int argc, char *argv[]) { const int port = 10000; CRConnection *conn[MAX_SERVERS]; const char *servers[MAX_SERVERS]; int numServers = 0; int bufferSize = 10000; int numBuffers = 10; int autoMode = 0; int size; int i, j; if (argc < 2) { PrintHelp(); return 0; } for (i = 1; i < argc; i++) { if (!crStrcmp(argv[i], "-a")) { autoMode = 1; } else if (!crStrcmp(argv[i], "-b") && (i + 1 < argc)) { bufferSize = crStrToInt(argv[i + 1]); i++; } else if (!crStrcmp(argv[i], "-h")) { PrintHelp(); return 0; } else if (!crStrcmp(argv[i], "-m") && (i + 1 < argc)) { MTU = crStrToInt(argv[i + 1]); i++; } else if (!crStrcmp(argv[i], "-n") && (i + 1 < argc)) { numBuffers = crStrToInt(argv[i + 1]); i++; } else if ((argv[i][0] != '-') && (numServers < MAX_SERVERS)) { servers[numServers] = argv[i]; numServers++; } } if (numServers == 0) { printf("npclient error: need to specify at least one server\n"); return 1; } if (autoMode) printf("npclient: MTU=%d (automatic buffer sizing)\n", MTU); else printf("npclient: MTU=%d bufferSize=%d numBuffers=%d\n", MTU, bufferSize, numBuffers); MyTimer = crTimerNewTimer(); crNetInit( ReceiveFunc, CloseFunc ); printf("npclient: Connecting to servers\n"); for (i = 0; i < numServers; i++) { conn[i] = crNetConnectToServer(servers[i], (unsigned short) port, MTU, 0); if (conn[i]) { printf("npclient: Connection to %s OK.\n", servers[i]); } else { printf("npclient: Connection to %s failed!\n", servers[i]); exit(1); } } printf("npclient: Testing...\n"); if (autoMode) { bufferSize = 10000; for (size = 0; size < 5; size++) { double t0, t1, dt, rate; double bytes; int buffers; bytes = 0.0; buffers = 0; crStartTimer(MyTimer); t0 = crTimerTime(MyTimer); do { for (j = 0; j < numServers; j++) { SendOpcodes(conn[j], bufferSize, 0); } bytes += (double) bufferSize; buffers++; t1 = crTimerTime(MyTimer); } while (t1 - t0 < 5.0); crStopTimer(MyTimer); dt = t1 - t0; rate = (double) bytes / dt / 1000000.0; printf("npclient: %8.3f MB/s (%d bytes / buffer, %d buffers, %d servers)\n", rate, bufferSize, buffers, numServers); if (rate < 0.0) { char *t = 0; *t = 0; CRASSERT(rate >= 0.0); } bufferSize *= 10; } } else { double t0, t1, dt, rate; double bytes; crStartTimer(MyTimer); t0 = crTimerTime(MyTimer); bytes = 0.0; for (i = 0; i < numBuffers; i++) { for (j = 0; j < numServers; j++) { SendOpcodes(conn[j], bufferSize, 0); } bytes += (double) bufferSize; } t1 = crTimerTime(MyTimer); dt = t1 - t0; rate = (double) bytes / dt / 1000000.0; printf("npclient: %8.3f MB/s (%d bytes / buffer, %d buffers, %d servers)\n", rate, bufferSize, numBuffers, numServers); } /* Send exit message to servers */ for (j = 0; j < numServers; j++) { SendOpcodes(conn[j], 100, 1); } for (j = 0; j < numServers; j++) { crNetDisconnect(conn[j]); } printf("npclient: done!\n"); return 0; }
/* Windows crap */ BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved) { (void) lpvReserved; switch (fdwReason) { case DLL_PROCESS_ATTACH: { CRNetServer ns; const char * env; #if defined(DEBUG_misha) HMODULE hCrUtil; char aName[MAX_PATH]; GetModuleFileNameA(hDLLInst, aName, RT_ELEMENTS(aName)); crDbgCmdSymLoadPrint(aName, hDLLInst); hCrUtil = GetModuleHandleA("VBoxOGLcrutil.dll"); Assert(hCrUtil); crDbgCmdSymLoadPrint("VBoxOGLcrutil.dll", hCrUtil); #endif #ifdef CHROMIUM_THREADSAFE crInitTSD(&g_stubCurrentContextTSD); #endif crInitMutex(&stub_init_mutex); #ifdef VDBG_VEHANDLER env = crGetenv("CR_DBG_VEH_ENABLE"); g_VBoxVehEnable = crStrParseI32(env, # ifdef DEBUG_misha 1 # else 0 # endif ); if (g_VBoxVehEnable) { char procName[1024]; size_t cProcName; size_t cChars; env = crGetenv("CR_DBG_VEH_FLAGS"); g_VBoxVehFlags = crStrParseI32(env, 0 # ifdef DEBUG_misha | VBOXVEH_F_BREAK # else | VBOXVEH_F_DUMP # endif ); env = crGetenv("CR_DBG_VEH_DUMP_DIR"); if (!env) env = VBOXMD_DUMP_DIR_DEFAULT; g_cVBoxMdFilePrefixLen = strlen(env); if (RT_ELEMENTS(g_aszwVBoxMdFilePrefix) <= g_cVBoxMdFilePrefixLen + 26 + (sizeof (VBOXMD_DUMP_NAME_PREFIX_W) - sizeof (WCHAR)) / sizeof (WCHAR)) { g_cVBoxMdFilePrefixLen = 0; env = ""; } mbstowcs_s(&cChars, g_aszwVBoxMdFilePrefix, g_cVBoxMdFilePrefixLen + 1, env, _TRUNCATE); Assert(cChars == g_cVBoxMdFilePrefixLen + 1); g_cVBoxMdFilePrefixLen = cChars - 1; if (g_cVBoxMdFilePrefixLen && g_aszwVBoxMdFilePrefix[g_cVBoxMdFilePrefixLen - 1] != L'\\') g_aszwVBoxMdFilePrefix[g_cVBoxMdFilePrefixLen++] = L'\\'; memcpy(g_aszwVBoxMdFilePrefix + g_cVBoxMdFilePrefixLen, VBOXMD_DUMP_NAME_PREFIX_W, sizeof (VBOXMD_DUMP_NAME_PREFIX_W) - sizeof (WCHAR)); g_cVBoxMdFilePrefixLen += (sizeof (VBOXMD_DUMP_NAME_PREFIX_W) - sizeof (WCHAR)) / sizeof (WCHAR); crGetProcName(procName, RT_ELEMENTS(procName)); cProcName = strlen(procName); if (RT_ELEMENTS(g_aszwVBoxMdFilePrefix) > g_cVBoxMdFilePrefixLen + cProcName + 1 + 26) { mbstowcs_s(&cChars, g_aszwVBoxMdFilePrefix + g_cVBoxMdFilePrefixLen, cProcName + 1, procName, _TRUNCATE); Assert(cChars == cProcName + 1); g_cVBoxMdFilePrefixLen += cChars - 1; g_aszwVBoxMdFilePrefix[g_cVBoxMdFilePrefixLen++] = L'_'; } /* sanity */ g_aszwVBoxMdFilePrefix[g_cVBoxMdFilePrefixLen] = L'\0'; env = crGetenv("CR_DBG_VEH_DUMP_TYPE"); g_enmVBoxMdDumpType = crStrParseI32(env, MiniDumpNormal | MiniDumpWithDataSegs | MiniDumpWithFullMemory | MiniDumpWithHandleData //// | MiniDumpFilterMemory //// | MiniDumpScanMemory // | MiniDumpWithUnloadedModules //// | MiniDumpWithIndirectlyReferencedMemory //// | MiniDumpFilterModulePaths // | MiniDumpWithProcessThreadData // | MiniDumpWithPrivateReadWriteMemory //// | MiniDumpWithoutOptionalData // | MiniDumpWithFullMemoryInfo // | MiniDumpWithThreadInfo // | MiniDumpWithCodeSegs // | MiniDumpWithFullAuxiliaryState // | MiniDumpWithPrivateWriteCopyMemory // | MiniDumpIgnoreInaccessibleMemory // | MiniDumpWithTokenInformation //// | MiniDumpWithModuleHeaders //// | MiniDumpFilterTriage ); vboxVDbgVEHandlerRegister(); } #endif crNetInit(NULL, NULL); ns.name = "vboxhgcm://host:0"; ns.buffer_size = 1024; crNetServerConnect(&ns #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) , NULL #endif ); if (!ns.conn) { crDebug("Failed to connect to host (is guest 3d acceleration enabled?), aborting ICD load."); #ifdef VDBG_VEHANDLER if (g_VBoxVehEnable) vboxVDbgVEHandlerUnregister(); #endif return FALSE; } else { crNetFreeConnection(ns.conn); } #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) VBoxCrHgsmiInit(); #endif break; } case DLL_PROCESS_DETACH: { /* do exactly the same thing as for DLL_THREAD_DETACH since * DLL_THREAD_DETACH is not called for the thread doing DLL_PROCESS_DETACH according to msdn docs */ stubSetCurrentContext(NULL); if (stub_initialized) { CRASSERT(stub.spu); stub.spu->dispatch_table.VBoxDetachThread(); } #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) VBoxCrHgsmiTerm(); #endif stubSPUSafeTearDown(); #ifdef CHROMIUM_THREADSAFE crFreeTSD(&g_stubCurrentContextTSD); #endif #ifdef VDBG_VEHANDLER if (g_VBoxVehEnable) vboxVDbgVEHandlerUnregister(); #endif break; } case DLL_THREAD_ATTACH: { if (stub_initialized) { CRASSERT(stub.spu); stub.spu->dispatch_table.VBoxAttachThread(); } break; } case DLL_THREAD_DETACH: { stubSetCurrentContext(NULL); if (stub_initialized) { CRASSERT(stub.spu); stub.spu->dispatch_table.VBoxDetachThread(); } break; } default: break; } return TRUE; }