// // ESciVis::ShutdownPhysX // void ESciVis::ShutdownPhysX( void ) { LOG_SHUTDOWN("PhysX"); if (nx_cook) { nx_cook->NxCloseCooking(); nx_cook = NULL; } if (nx_scene) { nx->releaseScene(*nx_scene); nx_scene = NULL; } if (nx) { nx->release(); nx = NULL; } }
// Service "main" function void _ServiceMain( void* ) { ThreadBag *pBag = NULL; //HANDLE hEvent; int tryTimes = 0; DWORD Current = 0; DWORD Previous = 0; LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\__gingko_pipe_server"); DWORD dwWaitRet = WaitForMultipleObjects(2, g_hServiceEvents, FALSE, 10000); LOG_START(); if( GkoInitialize() == FALSE ) { return; } InitCheapman(); LOG(L"GkCryptoInitialize\n"); //InstallAndLoadDriver(); LOG(L"InstallAndLoadDriver\n"); //StartGingkoService(); //StartGingkoHookingBackendThread(); //GingkoOneProcess( 1256, 0 ); //hEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); //if( hEvent == NULL || hEvent == INVALID_HANDLE_VALUE ) //{ // LOG(L"Error to CreateEvent. Error Code: %d.\n", GetLastError()); //} PipeListenerServerThreadStart(); if( DriverLoad() != ERROR_SUCCESS ) { PipeListenerServerThreadStop(); GkoUnInitialize(); UninitCheapman(); ServiceStatus.dwCurrentState = SERVICE_STOPPED; SetServiceStatus( ServiceStatusHandle, &ServiceStatus ); return; } StartThread(DeviceIoThreadProc, NULL, &pBag ); if( pBag == NULL ) { LOG(L"Error to Start DeviceIoThreadProc. Error Code: %d.\n", GetLastError()); } while (dwWaitRet != WAIT_OBJECT_0) //do until receive a STOP events { dwWaitRet = WaitForMultipleObjects(2, g_hServiceEvents, FALSE, 2000000); if (dwWaitRet == WAIT_OBJECT_0 + 1) // Receive PAUSE events { WaitForSingleObject( g_hServiceEvents[2], INFINITE); // Wait for CONTINUE events } //LOG(L"CALL PING\n"); Current = GetTickCount(); if( Previous == 0 ) { Previous = GetTickCount(); } if( Current - Previous > 10000 ) { Previous = Current; if( TRUE ) { tryTimes ++; } if( tryTimes > 10 ) { tryTimes = 0; } } } //SERVICE_STATUS ServiceStatus = {0}; ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING; SetServiceStatus( ServiceStatusHandle, &ServiceStatus ); LOG(_T("Service stop pending\n") ); LOG(_T("Service stop pending\n") ); UninitCheapman(); StopThread( pBag ); LOG(_T("Service stop pending\n") ); PipeListenerServerThreadStop(); //SetEvent( hEvent ); ///Exit the server thread. // Let's delete itself, after the service stopped //DeleteSvc(); LOG(_T("Close the Service Event Handle\n") ); CloseHandle( g_hServiceEvents[0] ); CloseHandle( g_hServiceEvents[1] ); CloseHandle( g_hServiceEvents[2] ); LOG(_T("Unload Driver\n") ); CloseBluefishDriver(); DriverUnload(); LOG(_T("Uninitialize Gingko System.\n") ); GkoUnInitialize(); LOG(_T("Shutdown LOG\n") ); LOG_SHUTDOWN(); ServiceStatus.dwCurrentState = SERVICE_STOPPED; SetServiceStatus( ServiceStatusHandle, &ServiceStatus ); }