// ========================================================================= // Unload the driver from the system VOID DriverUnload( IN PDRIVER_OBJECT DriverObject ) { PDEVICE_EXTENSION devExt; PDEVICE_OBJECT devObj; NTSTATUS status; DEBUGOUTHASHDRV(DEBUGLEV_ENTER, ("DriverUnload\n")); // Walk through all the device objects, shutting them down and deleting // them devObj = DriverObject->DeviceObject; while (devObj != NULL) { DEBUGOUTHASHDRV(DEBUGLEV_INFO, ("Found a device to destroy; destroying it...\n")); devObj = DestroyDevice(devObj); } status = ZwClose(DirFreeOTFERoot); status = ZwClose(DirFreeOTFEHash); DEBUGOUTHASHDRV(DEBUGLEV_EXIT, ("DriverUnload\n")); return; }
/** * Adds a udev device. */ static int AddDevice (services_discovery_t *sd, struct udev_device *dev) { services_discovery_sys_t *p_sys = sd->p_sys; char *mrl = p_sys->subsys->get_mrl (dev); if (mrl == NULL) return 0; /* don't know if it was an error... */ char *name = p_sys->subsys->get_name (dev); input_item_t *item = input_item_NewWithType (VLC_OBJECT (sd), mrl, name ? name : mrl, 0, NULL, 0, -1, p_sys->subsys->item_type); msg_Dbg (sd, "adding %s (%s)", mrl, name); free (name); free (mrl); if (item == NULL) return -1; struct device *d = malloc (sizeof (*d)); if (d == NULL) { vlc_gc_decref (item); return -1; } d->devnum = udev_device_get_devnum (dev); d->item = item; d->sd = NULL; struct device **dp = tsearch (d, &p_sys->root, cmpdev); if (dp == NULL) /* Out-of-memory */ { DestroyDevice (d); return -1; } if (*dp != d) /* Overwrite existing device */ { DestroyDevice (*dp); *dp = d; } name = p_sys->subsys->get_cat (dev); services_discovery_AddItem (sd, item, name ? name : "Generic"); d->sd = sd; free (name); return 0; }
//---------------------------------------------------------------------------- // Cleans up and stops D3D, and closes the window. //---------------------------------------------------------------------------- D3D_PUBLIC void D3DWnd_Shutdown( void ) { DestroyDevice(); DestroySwapChain(); ::UnregisterClass( WINDOW_CLASS_NAME, g_wv.hInstance ); ::DestroyWindow( g_hWnd ); g_hWnd = NULL; }
//--------------------------------------------------------------------------------------------- void TMainForm::sl_Start() { // для загрузки Mesh нужно устройство MakeDevice(); // создать список файлов MakeListPath(); // загружать по одному и сохранять ConvertAll(); DestroyDevice(); }
void directx_va_Close(vlc_va_t *va, directx_sys_t *dx_sys) { DestroyVideoDecoder(va, dx_sys); DestroyVideoService(va, dx_sys); DestroyDeviceManager(va, dx_sys); DestroyDevice(va, dx_sys); if (dx_sys->hdecoder_dll) FreeLibrary(dx_sys->hdecoder_dll); vlc_mutex_destroy( &dx_sys->surface_lock ); }
/** * Removes a udev device (if present). */ static void RemoveDevice (services_discovery_t *sd, struct udev_device *dev) { services_discovery_sys_t *p_sys = sd->p_sys; dev_t num = udev_device_get_devnum (dev); struct device **dp = tfind (&(dev_t){ num }, &p_sys->root, cmpdev); if (dp == NULL) return; struct device *d = *dp; tdelete (d, &p_sys->root, cmpdev); DestroyDevice (d); }
HRESULT DrawDevice::ResetDevice() { HRESULT hr = S_OK; if (m_pDevice) { D3DPRESENT_PARAMETERS d3dpp = m_d3dpp; hr = m_pDevice->Reset(&d3dpp); if (FAILED(hr)) { DestroyDevice(); } } if (m_pDevice == NULL) { hr = CreateDevice(m_hwnd); if (FAILED(hr)) { goto done; } } if ((m_pSwapChain == NULL) && (m_format != D3DFMT_UNKNOWN)) { hr = CreateSwapChains(); if (FAILED(hr)) { goto done; } UpdateDestinationRect(); } done: return hr; }
Bool VIV2DGPUCtxDeInit(GALINFOPTR galInfo) { TRACE_ENTER(); gctBOOL ret = gcvTRUE; VIVGPUPtr gpuctx = gcvNULL; if (galInfo->mGpu == NULL) { TRACE_ERROR("GPU CTX IS NULL\n"); TRACE_EXIT(TRUE); } VDestroySurf(); gpuctx = (VIVGPUPtr) (galInfo->mGpu); ret = DestroyDevice(gpuctx->mDevice); if (ret != gcvTRUE) { TRACE_ERROR("ERROR WHILE DESTROYING DEVICE \n"); TRACE_EXIT(FALSE); } ret = DestroyDriver(gpuctx->mDriver); if (ret != gcvTRUE) { TRACE_ERROR("ERROR WHILE DESTROYING DRIVER\n"); TRACE_EXIT(FALSE); } TRACE_EXIT(TRUE); }
DeviceManagerD3D9::~DeviceManagerD3D9() { DestroyDevice(); }
DrawDevice::~DrawDevice() { DestroyDevice(); }
DrawDevice::~DrawDevice() { DestroyDevice(); if (m_pBuf) delete [] m_pBuf; }
static void SC_DestroyDevice(__SYSCALL_PARAM_BLOCK* pspb) { DestroyDevice((HANDLE)PARAM(0)); }
void D3DWin8_Shutdown() { DestroyDevice(); DestroySwapChain(); }
// Direct3D 제거 void ReleaseD3D() { //###################################################################################### //작 성 자 : 오 영 석 DestroyDevice( lpDeviceDesc ); //###################################################################################### //###################################################################################### //작 성 자 : 오 영 석 ReleaseNewRenderTarget(); //###################################################################################### // Viewport 제거 if ( lpD3DViewport ) { // Direct3D Device 에서 Viewport 제거 lpD3DDevice->DeleteViewport( lpD3DViewport ); lpD3DViewport->Release(); lpD3DViewport = NULL; } // Direct3D Device 제거 if ( lpD3DDevice ) { lpD3DDevice->Release(); lpD3DDevice = NULL; } // Z-Buffer Surface 제거 if ( lpDDSZBuffer ) { // Back Surface 에서 Z-Buffer Surface 제거 if ( lpDDSBack ) lpDDSBack->DeleteAttachedSurface( 0L, lpDDSZBuffer ); lpDDSZBuffer->Release(); lpDDSZBuffer = NULL; } //###################################################################################### //작 성 자 : 오 영 석 if ( lpDDSBack ) { lpDDSBack->Release(); lpDDSBack = NULL; } //###################################################################################### // Direct3D Interface 제거 if ( lpD3D ) { lpD3D->Release(); lpD3D = NULL; } // Primary Surface 제거 if ( lpDDSPrimary ) { lpDDSPrimary->Release(); lpDDSPrimary = NULL; } // DirectDraw2 Interface 제거 if ( lpDD ) { // 비디오 모드 복귀 lpDD->RestoreDisplayMode(); lpDD->Release(); lpDD = NULL; } }
// but this still gives a PFD warning?! NTSTATUS CreateDevice ( IN PDRIVER_OBJECT DriverObject, OUT PDEVICE_OBJECT *DeviceObject ) { NTSTATUS status; UNICODE_STRING devName; PDEVICE_EXTENSION devExtension; HANDLE threadHandle; PDEVICE_OBJECT devObj; ANSI_STRING tmpANSIName; GUID driverGUID; HASH_DRIVER_INFO tmpDevExt; DEBUGOUTHASHDRV(DEBUGLEV_ENTER, ("CreateDevice\n")); ASSERT(DriverObject != NULL); DEBUGOUTHASHDRV(DEBUGLEV_INFO, ("Building device name...\n")); // We subtrace a sizeof(WCHAR) to discount the #NULL - required // since although the UNICODE_STRING string doesn't require it, swprintf // adds one on anyway // This is a bit of a hack to get the driver's GUID ImpHashDriverExtDetailsInit(&tmpDevExt); driverGUID = tmpDevExt.DriverGUID; ImpHashDriverExtDetailsCleardown(&tmpDevExt); devName.MaximumLength = sizeof(DEVICE_HASH_DIR_NAME) // ^^ dir name + sizeof(WCHAR) // ^^ slash + GUID_STRING_REP_UNICODE_BYTE_LENGTH // ^^ GUID length + sizeof(WCHAR); // ^^ terminating NULL devName.Buffer = FREEOTFE_MEMALLOC(devName.MaximumLength); RtlZeroMemory(devName.Buffer, devName.MaximumLength); // Note the "/" in the format string devName.Length = (USHORT)FREEOTFE_SWPRINTF( devName.Buffer, (devName.MaximumLength / sizeof(*(devName.Buffer))), L"%s\\", DEVICE_HASH_DIR_NAME ); // swprintf returns the number of WCHARs, not the length in bytes devName.Length = devName.Length * sizeof(WCHAR); status = AppendGUIDToUnicodeString(driverGUID, &devName); if (!NT_SUCCESS(status)) { DEBUGOUTHASHDRV(DEBUGLEV_ERROR, ("AppendGUIDToUnicodeString NOT OK\n")); SecZeroAndFreeMemory( devName.Buffer, devName.MaximumLength ); return status; } DEBUGOUTHASHDRV(DEBUGLEV_INFO, ("xdevNameLength: %d\n", devName.Length)); DEBUGOUTHASHDRV(DEBUGLEV_INFO, ("xdevNameMaximumLength: %d\n", devName.MaximumLength)); DEBUGOUTHASHDRV(DEBUGLEV_INFO, ("About to create device: %ls\n", devName.Buffer)); // Hmmm... I'd prefer to use FILE_DEVICE_UNKNOWN, but since // IOCTL control codes pass through the device type, and we just // pass then through... // (See other call to IoCreateDevice in this file for details why we don't // use FILE_DEVICE_VIRTUAL_DISK) status = IoCreateDevice( DriverObject, sizeof(DEVICE_EXTENSION), &devName, FILE_DEVICE_UNKNOWN, 0, FALSE, &devObj ); if (!NT_SUCCESS(status)) { DEBUGOUTHASHDRV(DEBUGLEV_ERROR, ("Status NOT OK\n")); SecZeroAndFreeMemory( devName.Buffer, devName.MaximumLength ); return status; } devExtension = (PDEVICE_EXTENSION)devObj->DeviceExtension; devExtension->zzDeviceName = devName; devExtension->ThreadObject = NULL; devExtension->zzSymbolicLinkName.Buffer = NULL; status = ImpHashDriverExtDetailsInit(&(devExtension->DriverInfo)); if (!NT_SUCCESS(status)) { DEBUGOUTHASHDRV(DEBUGLEV_ERROR, ("Failed to ImpHashDriverExtDetailsInit.\n")); DestroyDevice(devObj); return status; } // Create symlink; his allows user applications to CreateFile with // "SymbolicName" DEBUGOUTHASHDRV(DEBUGLEV_INFO, ("Building symlink name...\n")); // We add on sizeof(WCHAR) to include the terminating #NULL - required // since although the UNICODE_STRING string doesn't require it, swprintf // adds one on anyway devExtension->zzSymbolicLinkName.MaximumLength = sizeof(DEVICE_HASH_SYMLINK_PREFIX) // ^^ dir name + sizeof(WCHAR) // ^^ slash + GUID_STRING_REP_UNICODE_BYTE_LENGTH // ^^ GUID length + sizeof(WCHAR); // ^^ terminating NULL devExtension->zzSymbolicLinkName.Buffer = FREEOTFE_MEMALLOC(devExtension->zzSymbolicLinkName.MaximumLength); RtlZeroMemory(devExtension->zzSymbolicLinkName.Buffer, devExtension->zzSymbolicLinkName.MaximumLength); devExtension->zzSymbolicLinkName.Length = (USHORT)FREEOTFE_SWPRINTF( devExtension->zzSymbolicLinkName.Buffer, (devExtension->zzSymbolicLinkName.MaximumLength / sizeof(*(devExtension->zzSymbolicLinkName.Buffer))), L"%s", DEVICE_HASH_SYMLINK_PREFIX ); // swprintf returns the number of WCHARs, not the length in bytes devExtension->zzSymbolicLinkName.Length = devExtension->zzSymbolicLinkName.Length * sizeof(WCHAR); status = AppendGUIDToUnicodeString(driverGUID, &devExtension->zzSymbolicLinkName); if (!NT_SUCCESS(status)) { DEBUGOUTHASHDRV(DEBUGLEV_ERROR, ("AppendGUIDToUnicodeString NOT OK\n")); DestroyDevice(devObj); return status; } DEBUGOUTHASHDRV(DEBUGLEV_INFO, ("Unicoded symlink name: %ls\n", devExtension->zzSymbolicLinkName.Buffer)); DEBUGOUTHASHDRV(DEBUGLEV_INFO, ("Length: %d\n", devExtension->zzSymbolicLinkName.Length)); DEBUGOUTHASHDRV(DEBUGLEV_INFO, ("MaximumLength: %d\n", devExtension->zzSymbolicLinkName.MaximumLength)); DEBUGOUTHASHDRV(DEBUGLEV_INFO, ("About to create dosdevice symlink: %ls -> %ls\n", devExtension->zzSymbolicLinkName.Buffer, devExtension->zzDeviceName.Buffer)); status = IoCreateSymbolicLink(&devExtension->zzSymbolicLinkName, &devExtension->zzDeviceName); DEBUGOUTHASHDRV(DEBUGLEV_INFO, ("Done, checking status...\n")); if (!NT_SUCCESS(status)) { DEBUGOUTHASHDRV(DEBUGLEV_ERROR, ("Status NOT OK\n")); DestroyDevice(devObj); return status; } DEBUGOUTHASHDRV(DEBUGLEV_INFO, ("OK\n")); devObj->Flags |= DO_DIRECT_IO; devObj->Characteristics |= FILE_READ_ONLY_DEVICE; // (Some of the bits following are taken from the DDK src/general/cancel example) // This is used to serialize access to the queue. KeInitializeSpinLock(&devExtension->IRPQueueLock); KeInitializeSemaphore(&devExtension->IRPQueueSemaphore, 0, MAXLONG ); // Initialize the pending Irp devicequeue InitializeListHead(&devExtension->PendingIRPQueue); // Initialize the cancel safe queue IoCsqInitialize(&devExtension->CancelSafeQueue, CSQInsertIrp, CSQRemoveIrp, CSQPeekNextIrp, CSQAcquireLock, CSQReleaseLock, CSQCompleteCanceledIrp); // Create a thread for the device object devExtension->TerminateThread = FALSE; status = PsCreateSystemThread( &threadHandle, (ACCESS_MASK)0, NULL, (HANDLE)0L, // )0L because it's a // driver-created thread NULL, FreeOTFEThread, devObj ); if (!(NT_SUCCESS(status))) { DEBUGOUTHASHDRV(DEBUGLEV_ERROR, ("Create thread FAILED.\n")); DestroyDevice(devObj); return status; } DEBUGOUTHASHDRV(DEBUGLEV_INFO, ("OK\n")); // Convert the Thread object handle into a pointer to the Thread object // itself. Then close the handle. status = ObReferenceObjectByHandle( threadHandle, THREAD_ALL_ACCESS, NULL, KernelMode, &devExtension->ThreadObject, NULL ); DEBUGOUTHASHDRV(DEBUGLEV_INFO, ("Done processing thread; checking status.\n")); if (!NT_SUCCESS(status)) { DEBUGOUTHASHDRV(DEBUGLEV_ERROR, ("Status FAILED.\n")); ZwClose(threadHandle); DestroyDevice(devObj); return status; } DEBUGOUTHASHDRV(DEBUGLEV_INFO, ("OK\n")); // Close the thread handle ZwClose(threadHandle); // This is an easy thing to overlook - we do *not* have to unset the // device's DO_DEVICE_INITIALIZING "Flags" as this function is carried out // undef DriverEntry, and not something like AddDevice *DeviceObject = devObj; DEBUGOUTHASHDRV(DEBUGLEV_EXIT, ("CreateDevice\n")); return STATUS_SUCCESS; }
void CInputDevice::Destroy() { DestroyDevice(); }