NTSTATUS DF_DispatchPower(PDEVICE_OBJECT DeviceObject, PIRP Irp) { PDF_DEVICE_EXTENSION DevExt; PIO_STACK_LOCATION IrpSp; PAGED_CODE(); DevExt = (PDF_DEVICE_EXTENSION)DeviceObject->DeviceExtension; IrpSp = IoGetCurrentIrpStackLocation(Irp); DBG_PRINT(DBG_TRACE_ROUTINES, ("%s: ", __FUNCTION__)); if (IrpSp->Parameters.Power.Type == SystemPowerState) { DBG_PRINT(DBG_TRACE_OPS, ("SystemPowerState...\n")); if (PowerSystemShutdown == IrpSp->Parameters.Power.State.SystemState) { DBG_PRINT(DBG_TRACE_OPS, ("%d-%d: Stopping Device...\n", DevExt->DiskNumber, DevExt->PartitionNumber)); StopDevice(DeviceObject); DBG_PRINT(DBG_TRACE_OPS, ("%d-%d: Device Stopped.\n", DevExt->DiskNumber, DevExt->PartitionNumber)); } } else if (IrpSp->Parameters.Power.Type == DevicePowerState) DBG_PRINT(DBG_TRACE_OPS, ("DevicePowerState...\n")); else DBG_PRINT(DBG_TRACE_OPS, ("\n")); #if WINVER < _WIN32_WINNT_VISTA PoStartNextPowerIrp(Irp); IoSkipCurrentIrpStackLocation(Irp); return PoCallDriver(DevExt->LowerDeviceObject, Irp); #else IoSkipCurrentIrpStackLocation(Irp); return IoCallDriver(DevExt->LowerDeviceObject, Irp); #endif }
void FdNetDevice::DoDispose (void) { NS_LOG_FUNCTION (this); StopDevice (); NetDevice::DoDispose (); }
OMX_ERRORTYPE VideoSource::InstanceDeInit() { OMX_ERRORTYPE ret = OMX_ErrorNone; StopDevice(); return ret; }
void VellemanOut::close(quint32 output) { if (output != 0) return; m_currentlyOpen = false; StopDevice(); }
int UnInstallDriver(HDEVINFO h, SP_DEVINFO_DATA *dev_info_data) { BOOL ret = FALSE; StopDevice(h, dev_info_data); ret = DeleteDevice(h, dev_info_data); return ret; }
OMX_ERRORTYPE AudioSource::FlushComponent( OMX_U32 nPortIndex) { OMX_ERRORTYPE ret = OMX_ErrorNone; StopDevice(); return OMX_ErrorNone; }
OMX_ERRORTYPE AudioSource::ComponentReturnBuffer( OMX_U32 nPortIndex) { OMX_ERRORTYPE ret = OMX_ErrorNone; StopDevice(); return OMX_ErrorNone; }
NS_IMETHODIMP nsGeolocationService::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar* aData) { if (!strcmp("quit-application", aTopic)) { nsCOMPtr<nsIObserverService> obs = do_GetService("@mozilla.org/observer-service;1"); if (obs) { obs->RemoveObserver(this, "quit-application"); } for (PRUint32 i = 0; i< mGeolocators.Length(); i++) mGeolocators[i]->Shutdown(); StopDevice(); return NS_OK; } if (!strcmp("timer-callback", aTopic)) { // decide if we can close down the service. for (PRUint32 i = 0; i< mGeolocators.Length(); i++) if (mGeolocators[i]->HasActiveCallbacks()) { SetDisconnectTimer(); return NS_OK; } // okay to close up. StopDevice(); Update(nsnull); return NS_OK; } return NS_ERROR_FAILURE; }
status_t DavicomDevice::Close() { if (fRemoved) { fOpen = false; return B_OK; } // wait until possible notification handling finished... while (atomic_add(&fInsideNotify, 0) != 0) snooze(100); gUSBModule->cancel_queued_transfers(fNotifyEndpoint); gUSBModule->cancel_queued_transfers(fReadEndpoint); gUSBModule->cancel_queued_transfers(fWriteEndpoint); fOpen = false; return StopDevice(); }
NTSTATUS DispatchPnp( __in PDEVICE_OBJECT DeviceObject, __in PIRP Irp ) { PIO_STACK_LOCATION StackLocation; PDEVICE_EXTENSION pdx; UCHAR MinorFunction; NTSTATUS status; Warning("Received an IRP.\n"); StackLocation = IoGetCurrentIrpStackLocation(Irp); MinorFunction = StackLocation->MinorFunction; pdx = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; switch (StackLocation->MinorFunction) { case IRP_MN_START_DEVICE: Warning("IRP_MN_START_DEVICE IRP received.\n"); status = StartDevice(DeviceObject, Irp); break; case IRP_MN_STOP_DEVICE: Warning("IRP_MN_STOP_DEVICE IRP received.\n"); status = StopDevice(DeviceObject, Irp); break; case IRP_MN_REMOVE_DEVICE: Warning("IRP_MN_REMOVE_DEVICE IRP received.\n"); status = RemoveDevice(DeviceObject, Irp); break; default: Warning("IRP ID = %d.\n", StackLocation->MinorFunction); IoSkipCurrentIrpStackLocation(Irp); status = IoCallDriver(pdx->LowerDeviceObject, Irp); break; } return status; }
status_t Device::Close() { if (fRemoved) { fOpen = false; return B_OK; } for (int i = 0; i < fStreams.Count(); i++) { fStreams[i]->Stop(); } // wait until possible notification handling finished... while (atomic_add(&fInsideNotify, 0) != 0) snooze(100); gUSBModule->cancel_queued_transfers(fControlEndpoint); gUSBModule->cancel_queued_transfers(fInStreamEndpoint); gUSBModule->cancel_queued_transfers(fOutStreamEndpoint); fOpen = false; return StopDevice(); }
/******************************************************************************* * * Function : RemoveDevice * * Description: Remove a functional device object * ******************************************************************************/ int RemoveDevice( DEVICE_OBJECT *fdo ) { DEVICE_OBJECT *pDevice; DEVICE_EXTENSION *pdx; pdx = fdo->DeviceExtension; // Stop device and release its resources StopDevice( fdo ); DebugPrintf(( "Remove device (%s)\n", pdx->LinkName )); // Acquire Device List lock spin_lock( &(fdo->DriverObject->Lock_DeviceList) ); // Get device list head pDevice = fdo->DriverObject->DeviceObject; if (pDevice == NULL) { // Release Device List lock spin_unlock( &(fdo->DriverObject->Lock_DeviceList) ); ErrorPrintf(("ERROR - Unable to remove device, device list is empty\n")); return (-ENODEV); } if (pDevice == fdo) { // Remove device from first in list fdo->DriverObject->DeviceObject = fdo->NextDevice; } else { // Scan list for the device while (pDevice->NextDevice != fdo) { pDevice = pDevice->NextDevice; if (pDevice == NULL) { // Release Device List lock spin_unlock( &(fdo->DriverObject->Lock_DeviceList) ); ErrorPrintf(( "ERROR - Device object (%p) not found in device list\n", fdo )); return (-ENODEV); } } // Remove device from list pDevice->NextDevice = fdo->NextDevice; } // Decrement device count pGbl_DriverObject->DeviceCount--; // Release Device List lock spin_unlock( &(fdo->DriverObject->Lock_DeviceList) ); // Disable the device pci_disable_device( pdx->pPciDevice ); DebugPrintf(("Disabled PCI device\n")); DebugPrintf(( "Delete device object (%p)\n", fdo )); // Release device object kfree( fdo ); return 0; }
NTSTATUS SwdmDispatchPnP( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ) { IO_STACK_LOCATION* pStk; DEVICE_EXTENSION* pCtx; ULONG MinorCode; NTSTATUS Status = STATUS_SUCCESS; DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "IRP_MJ_PNP Received : Begin\n" ); pStk = IoGetCurrentIrpStackLocation(Irp); pCtx = (DEVICE_EXTENSION*)DeviceObject->DeviceExtension; IoAcquireRemoveLock( &pCtx->RemoveLock, Irp); MinorCode = pStk->MinorFunction; DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "Minor code: 0x%x\n", MinorCode ); switch( MinorCode ) { case IRP_MN_START_DEVICE: DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "IRP_MN_START_DEVICE Received : Begin\r\n"); Status = StartDevice( DeviceObject, Irp ); DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "IRP_MN_START_DEVICE Received : End\r\n"); break; case IRP_MN_STOP_DEVICE: DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "IRP_MN_STOP_DEVICE Received : Begin\r\n"); Status = StopDevice( DeviceObject, Irp ); DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "IRP_MN_STOP_DEVICE Received : End\r\n"); break; case IRP_MN_REMOVE_DEVICE: DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "IRP_MN_REMOVE_DEVICE Received : Begin\r\n"); Status = RemoveDevice( DeviceObject, Irp ); DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "IRP_MN_REMOVE_DEVICE Received : End\r\n"); break; case IRP_MN_QUERY_CAPABILITIES : DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "IRP_MN_QUERY_CAPABILITIES Received : Begin\r\n"); Status = QueryCapability( DeviceObject, Irp ); DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "IRP_MN_QUERY_CAPABILITIES Received : End\r\n"); break; case IRP_MN_QUERY_BUS_INFORMATION: DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "IRP_MN_QUERY_BUS_INFORMATION Received : Begin\n"); Status = QueryBus( DeviceObject, Irp ); break; default: break; } IoReleaseRemoveLock( &pCtx->RemoveLock, Irp); if (NT_SUCCESS(Status)) { CompleteRequest( Irp, STATUS_SUCCESS, 0); } DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "IRP_MJ_PNP Received : End\r\n"); return Status; }
NTSTATUS DF_DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp) { NTSTATUS status; PDF_DEVICE_EXTENSION DevExt; PIO_STACK_LOCATION IrpSp; // For handling paging requests. BOOLEAN setPageable; BOOLEAN bAddPageFile; PAGED_CODE(); IrpSp = IoGetCurrentIrpStackLocation(Irp); DevExt = (PDF_DEVICE_EXTENSION)DeviceObject->DeviceExtension; switch(IrpSp->MinorFunction) { case IRP_MN_START_DEVICE: DBG_PRINT(DBG_TRACE_OPS, ("%s: Start Device...\n", __FUNCTION__)); status = Irp->IoStatus.Status; DevExt->CurrentPnpState = IRP_MN_START_DEVICE; break; case IRP_MN_DEVICE_USAGE_NOTIFICATION : setPageable = FALSE; bAddPageFile = IrpSp->Parameters.UsageNotification.InPath; DBG_PRINT(DBG_TRACE_OPS, ("%s: Paging file request...\n", __FUNCTION__)); if (IrpSp->Parameters.UsageNotification.Type == DeviceUsageTypePaging) // Indicated it will create or delete a paging file. { if(bAddPageFile && !DevExt->CurrentPnpState) { status = STATUS_DEVICE_NOT_READY; break; } // Waiting other paging requests. KeWaitForSingleObject(&DevExt->PagingCountEvent, Executive, KernelMode, FALSE, NULL); // Removing last paging device. if (!bAddPageFile && DevExt->PagingCount == 1 ) { // The last paging file is no longer active. // Set the DO_POWER_PAGABLE bit before // forwarding the paging request down the // stack. if (!(DeviceObject->Flags & DO_POWER_INRUSH)) { DeviceObject->Flags |= DO_POWER_PAGABLE; setPageable = TRUE; } } // Waiting lower device complete. IoForwardIrpSynchronously(DevExt->LowerDeviceObject, Irp); if (NT_SUCCESS(Irp->IoStatus.Status)) { IoAdjustPagingPathCount(&DevExt->PagingCount, bAddPageFile); if (bAddPageFile && DevExt->PagingCount == 1) { // Once the lower device objects have succeeded the addition of the paging // file, it is illegal to fail the request. It is also the time to clear // the Filter DO's DO_POWER_PAGABLE flag. DeviceObject->Flags &= ~DO_POWER_PAGABLE; } } else { if (setPageable == TRUE) { DeviceObject->Flags &= ~DO_POWER_PAGABLE; setPageable = FALSE; } } KeSetEvent(&DevExt->PagingCountEvent, IO_NO_INCREMENT, FALSE); status = Irp->IoStatus.Status; IoCompleteRequest(Irp, IO_NO_INCREMENT); return status; } break; case IRP_MN_REMOVE_DEVICE: DBG_PRINT(DBG_TRACE_OPS, ("%s: Removing Device...\n", __FUNCTION__)); IoForwardIrpSynchronously(DevExt->LowerDeviceObject, Irp); status = Irp->IoStatus.Status; if (NT_SUCCESS(status)) { DBG_PRINT(DBG_TRACE_OPS, ("%d-%d: Stopping Device...\n", DevExt->DiskNumber, DevExt->PartitionNumber)); StopDevice(DeviceObject); DBG_PRINT(DBG_TRACE_OPS, ("%d-%d: Device Stopped.\n", DevExt->DiskNumber, DevExt->PartitionNumber)); } IoCompleteRequest(Irp, IO_NO_INCREMENT); return status; } IoSkipCurrentIrpStackLocation(Irp); return IoCallDriver(DevExt->LowerDeviceObject, Irp); }
void CUsbtestDlg::OnClose() { StopDevice(devID); //SendCommand(devID, CMD_SET_TRIG_MODE, 0); ::PostQuitMessage(0); }
/* * * Entry point into program * */ int main() { RAM_DATA_BYTE state[BLOCK_SIZE]; RAM_DATA_BYTE key[KEY_SIZE]; RAM_DATA_BYTE roundKeys[ROUND_KEYS_SIZE]; InitializeDevice(); InitializeState(state); #if defined(DEBUG) && (DEBUG_LOW == (DEBUG_LOW & DEBUG)) DisplayVerifyData(state, BLOCK_SIZE, PLAINTEXT_NAME); #endif InitializeKey(key); #if defined(DEBUG) && (DEBUG_MEDIUM == (DEBUG_MEDIUM & DEBUG)) DisplayVerifyData(key, KEY_SIZE, KEY_NAME); #endif #if defined(DEBUG) && (DEBUG_HIGH == (DEBUG_HIGH & DEBUG)) DisplayData(roundKeys, ROUND_KEYS_SIZE, ROUND_KEYS_NAME); #endif BEGIN_ENCRYPTION_KEY_SCHEDULE(); RunEncryptionKeySchedule(key, roundKeys); END_ENCRYPTION_KEY_SCHEDULE(); #if defined(DEBUG) && (DEBUG_MEDIUM == (DEBUG_MEDIUM & DEBUG)) DisplayVerifyData(key, KEY_SIZE, KEY_NAME); #endif #if defined(DEBUG) && (DEBUG_HIGH == (DEBUG_HIGH & DEBUG)) DisplayData(roundKeys, ROUND_KEYS_SIZE, ROUND_KEYS_NAME); #endif #if defined(DEBUG) && (DEBUG_LOW == (DEBUG_LOW & DEBUG)) DisplayVerifyData(state, BLOCK_SIZE, PLAINTEXT_NAME); #endif BEGIN_ENCRYPTION(); Encrypt(state, roundKeys); END_ENCRYPTION(); #if defined(DEBUG) && (DEBUG_LOW == (DEBUG_LOW & DEBUG)) DisplayVerifyData(state, BLOCK_SIZE, CIPHERTEXT_NAME); #endif BEGIN_DECRYPTION_KEY_SCHEDULE(); RunDecryptionKeySchedule(key, roundKeys); END_DECRYPTION_KEY_SCHEDULE(); #if defined(DEBUG) && (DEBUG_MEDIUM == (DEBUG_MEDIUM & DEBUG)) DisplayVerifyData(key, KEY_SIZE, KEY_NAME); #endif #if defined(DEBUG) && (DEBUG_HIGH == (DEBUG_HIGH & DEBUG)) DisplayData(roundKeys, ROUND_KEYS_SIZE, ROUND_KEYS_NAME); #endif #if defined(DEBUG) && (DEBUG_LOW == (DEBUG_LOW & DEBUG)) DisplayVerifyData(state, BLOCK_SIZE, CIPHERTEXT_NAME); #endif BEGIN_DECRYPTION(); Decrypt(state, roundKeys); END_DECRYPTION(); #if defined(DEBUG) && (DEBUG_LOW == (DEBUG_LOW & DEBUG)) DisplayVerifyData(state, BLOCK_SIZE, PLAINTEXT_NAME); #endif DONE(); StopDevice(); return 0; }