本文整理汇总了C++中IoDeleteDevice函数的典型用法代码示例。如果您正苦于以下问题:C++ IoDeleteDevice函数的具体用法?C++ IoDeleteDevice怎么用?C++ IoDeleteDevice使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IoDeleteDevice函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: driver_unload
static
VOID
NTAPI
driver_unload(IN PDRIVER_OBJECT DriverObject)
{
WCHAR deviceLinkBuffer[] = L"\\DosDevices\\"CO_DRIVER_NAME;
UNICODE_STRING deviceLinkUnicodeString;
co_manager_t *manager;
manager = DriverObject->DeviceObject->DeviceExtension;
if (manager) {
co_manager_unload(manager);
}
RtlInitUnicodeString(&deviceLinkUnicodeString, deviceLinkBuffer);
IoDeleteSymbolicLink(&deviceLinkUnicodeString);
IoDeleteDevice(DriverObject->DeviceObject);
}
示例2: CreateDevice
NTSTATUS CreateDevice (
IN PDRIVER_OBJECT pDriverObject)
{
NTSTATUS status;
PDEVICE_OBJECT pDevObj;
PDEVICE_EXTENSION pDevExt;
//创建设备名称
UNICODE_STRING devName;
RtlInitUnicodeString(&devName,L"\\Device\\MyDDKDevice");
//创建设备
status = IoCreateDevice( pDriverObject,
sizeof(DEVICE_EXTENSION),
&(UNICODE_STRING)devName,
FILE_DEVICE_UNKNOWN,
0, TRUE,
&pDevObj );
if (!NT_SUCCESS(status))
return status;
pDevObj->Flags |= DO_DIRECT_IO;
pDevExt = (PDEVICE_EXTENSION)pDevObj->DeviceExtension;
pDevExt->pDevice = pDevObj;
pDevExt->ustrDeviceName = devName;
//申请模拟文件的缓冲区
pDevExt->buffer = (PUCHAR)ExAllocatePool(PagedPool,MAX_FILE_LENGTH);
//设置模拟文件大小
pDevExt->file_length = 0;
//创建符号链接
UNICODE_STRING symLinkName;
RtlInitUnicodeString(&symLinkName,L"\\??\\HelloDDK");
pDevExt->ustrSymLinkName = symLinkName;
status = IoCreateSymbolicLink( &symLinkName,&devName );
if (!NT_SUCCESS(status))
{
IoDeleteDevice( pDevObj );
return status;
}
return STATUS_SUCCESS;
}
示例3: BBUnload
VOID BBUnload( IN PDRIVER_OBJECT DriverObject )
{
UNICODE_STRING deviceLinkUnicodeString;
// Unregister notification
PsSetCreateProcessNotifyRoutine( BBProcessNotify, TRUE );
// Cleanup physical regions
BBCleanupProcessPhysList();
// Cleanup process mapping info
BBCleanupProcessTable();
RtlUnicodeStringInit( &deviceLinkUnicodeString, DOS_DEVICE_NAME );
IoDeleteSymbolicLink( &deviceLinkUnicodeString );
IoDeleteDevice( DriverObject->DeviceObject );
return;
}
示例4: i8042RemoveDevice
static VOID
i8042RemoveDevice(
IN PDEVICE_OBJECT DeviceObject)
{
PI8042_DRIVER_EXTENSION DriverExtension;
KIRQL OldIrql;
PFDO_DEVICE_EXTENSION DeviceExtension;
DriverExtension = (PI8042_DRIVER_EXTENSION)IoGetDriverObjectExtension(DeviceObject->DriverObject, DeviceObject->DriverObject);
DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
KeAcquireSpinLock(&DriverExtension->DeviceListLock, &OldIrql);
RemoveEntryList(&DeviceExtension->ListEntry);
KeReleaseSpinLock(&DriverExtension->DeviceListLock, OldIrql);
IoDetachDevice(DeviceExtension->LowerDevice);
IoDeleteDevice(DeviceObject);
}
示例5: HelloDDKUnload
VOID HelloDDKUnload (IN PDRIVER_OBJECT pDriverObject)
{
PDEVICE_OBJECT pNextObj;
KdPrint(("DriverB:Enter B DriverUnload\n"));
pNextObj = pDriverObject->DeviceObject;
while (pNextObj != NULL)
{
PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)
pNextObj->DeviceExtension;
//删除符号链接
UNICODE_STRING pLinkName = pDevExt->ustrSymLinkName;
IoDeleteSymbolicLink(&pLinkName);
pNextObj = pNextObj->NextDevice;
IoDeleteDevice( pDevExt->pDevice );
}
KdPrint(("DriverB:Enter B DriverUnload\n"));
}
示例6: DriverEntry
NTSTATUS DriverEntry(PDRIVER_OBJECT DrvObj, PUNICODE_STRING RegPath)
{
PDEVICE_OBJECT DevObj;
NTSTATUS status;
status = IoCreateDevice(DrvObj, 0, &deviceName, FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN,
FALSE, &DevObj);
if(NT_SUCCESS(status)) {
status = IoCreateSymbolicLink (&deviceLink, &deviceName);
DrvObj->MajorFunction[IRP_MJ_CREATE] = DtraceOpen;
DrvObj->MajorFunction[IRP_MJ_CLOSE] = DtraceClose;
DrvObj->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DtraceIoctl;
DrvObj->DriverUnload = DtraceUnload;
}
if (!NT_SUCCESS(status)) {
IoDeleteSymbolicLink(&deviceLink);
if(DevObj)
IoDeleteDevice( DevObj);
return status;
}
status = IoCreateSymbolicLink(&deviceHelperLink, &deviceName);
if (!NT_SUCCESS(status))
dprintf("DriverEntry: dtrace helper creation failed\n");
DtraceGetSystemHertz();
DtraceWinOSKernelModuleInfo();
DtraceWinOSInitFunctions();
if (DtraceWinOSHackData() == 0)
dprintf("DriverEntry: DtraceWinOSPortData() hack data failure\n");
if (PsSetLoadImageNotifyRoutine(ProcKernelModuleLoaded) != STATUS_SUCCESS)
dprintf("DriverEntry: failed to register PsSetLoadImageNotifyRoutine\n");
WorkItem1 = IoAllocateWorkItem(DevObj);
WorkItem2 = IoAllocateWorkItem(DevObj);
int_morecore();
(void) dtrace_load((void *) RegPath);
return status;
}
示例7: ParUnload
VOID
ParUnload(
IN PDRIVER_OBJECT DriverObject
)
/*++
Routine Description:
This routine loops through the device list and cleans up after
each of the devices.
Arguments:
DriverObject - Supplies the driver object.
Return Value:
None.
--*/
{
PDEVICE_OBJECT currentDevice;
PDEVICE_EXTENSION extension;
KEVENT event;
PARALLEL_INTERRUPT_SERVICE_ROUTINE interruptService;
PIRP irp;
IO_STATUS_BLOCK ioStatus;
while (currentDevice = DriverObject->DeviceObject) {
extension = currentDevice->DeviceExtension;
if (extension->CreatedSymbolicLink) {
IoDeleteSymbolicLink(&extension->SymbolicLinkName);
ExFreePool(extension->SymbolicLinkName.Buffer);
}
IoDeleteDevice(currentDevice);
}
}
示例8: DestroySoundDevice
NTSTATUS
DestroySoundDevice(
IN PDEVICE_OBJECT DeviceObject,
IN PCWSTR WideDosDeviceName,
IN UCHAR Index)
{
NTSTATUS Status;
UNICODE_STRING DosDeviceName;
/* Check for NULL parameters */
if ( ( ! WideDosDeviceName ) || ( ! DeviceObject ) )
{
DPRINT("Unexpected NULL parameter");
return STATUS_INVALID_PARAMETER;
}
/* Range-check */
if ( Index >= SOUND_MAX_DEVICES )
{
DPRINT("Device %d exceeds maximum", Index);
return STATUS_INVALID_PARAMETER;
}
Status = ConstructDeviceName(WideDosDeviceName, Index, &DosDeviceName);
if ( ! NT_SUCCESS(Status) )
{
return Status;
}
DPRINT("Deleting symlink %ws\n", DosDeviceName.Buffer);
Status = IoDeleteSymbolicLink(&DosDeviceName);
DPRINT("Status of symlink deletion is 0x%08x\n", Status);
/*
ASSERT(NT_SUCCESS(Status));
*/
IoDeleteDevice(DeviceObject);
return STATUS_SUCCESS;
}
示例9: VBoxIrpPnP
NTSTATUS VBoxIrpPnP(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
{
PIO_STACK_LOCATION pStack;
PVBOXMOUSE_DEVEXT pDevExt;
NTSTATUS rc;
LOGF_ENTER();
pStack = IoGetCurrentIrpStackLocation(Irp);
pDevExt = (PVBOXMOUSE_DEVEXT) DeviceObject->DeviceExtension;
switch (pStack->MinorFunction)
{
case IRP_MN_REMOVE_DEVICE:
{
LOGF(("IRP_MN_REMOVE_DEVICE"));
IoReleaseRemoveLockAndWait(&pDevExt->RemoveLock, pDevExt);
VBoxDeviceRemoved(pDevExt);
Irp->IoStatus.Status = STATUS_SUCCESS;
rc = VBoxIrpPassthrough(DeviceObject, Irp);
IoDetachDevice(pDevExt->pdoParent);
IoDeleteDevice(DeviceObject);
break;
}
default:
{
rc = VBoxIrpPassthrough(DeviceObject, Irp);
break;
}
}
if (!NT_SUCCESS(rc) && rc != STATUS_NOT_SUPPORTED)
{
WARN(("rc=%#x", rc));
}
LOGF_LEAVE();
return rc;
}
示例10: PassThruAddDevice
NTSTATUS PassThruAddDevice( IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT pdo)
{
DebugPrint("AddDevice");
NTSTATUS status;
PDEVICE_OBJECT fdo;
// Create our Functional Device Object in fdo
status = IoCreateDevice (DriverObject,
sizeof(PASSTHRU_DEVICE_EXTENSION),
NULL, // No Name
FILE_DEVICE_UNKNOWN,
0,
FALSE, // Not exclusive
&fdo);
if( !NT_SUCCESS(status))
return status;
// Remember fdo in our device extension
PPASSTHRU_DEVICE_EXTENSION dx = (PPASSTHRU_DEVICE_EXTENSION)fdo->DeviceExtension;
dx->fdo = fdo;
DebugPrint("FDO is %x",fdo);
// Register and enable our device interface
status = IoRegisterDeviceInterface(pdo, &WDM1_GUID, NULL, &dx->ifSymLinkName);
if( !NT_SUCCESS(status))
{
IoDeleteDevice(fdo);
return status;
}
IoSetDeviceInterfaceState(&dx->ifSymLinkName, TRUE);
DebugPrint("Symbolic Link Name is %T",&dx->ifSymLinkName);
// Attach to the driver stack below us
dx->NextStackDevice = IoAttachDeviceToDeviceStack(fdo,pdo);
// Set fdo flags appropriately
fdo->Flags |= DO_BUFFERED_IO|DO_POWER_PAGABLE;
fdo->Flags &= ~DO_DEVICE_INITIALIZING;
return STATUS_SUCCESS;
}
示例11: AoeBusIrpDispatch
/* Handle an IRP. */
NTSTATUS AoeBusIrpDispatch(
IN PDEVICE_OBJECT dev_obj,
IN PIRP irp
) {
PIO_STACK_LOCATION io_stack_loc;
NTSTATUS status;
ULONG POINTER_ALIGNMENT code;
io_stack_loc = IoGetCurrentIrpStackLocation(irp);
switch (io_stack_loc->MajorFunction) {
case IRP_MJ_PNP:
status = WvlBusPnp(&AoeBusMain, irp);
/* Did the bus detach? */
if (AoeBusMain.State == WvlBusStateDeleted) {
AoeStop();
/* Delete. */
IoDeleteDevice(AoeBusMain.Fdo);
/* Disassociate. */
AoeBusMain.Fdo = NULL;
}
return status;
case IRP_MJ_DEVICE_CONTROL:
code = io_stack_loc->Parameters.DeviceIoControl.IoControlCode;
return AoeBusDevCtl(irp, code);
case IRP_MJ_POWER:
return WvlBusPower(&AoeBusMain, irp);
case IRP_MJ_CREATE:
case IRP_MJ_CLOSE:
/* Always succeed with nothing to do. */
return WvlIrpComplete(irp, 0, STATUS_SUCCESS);
case IRP_MJ_SYSTEM_CONTROL:
return WvlBusSysCtl(&AoeBusMain, irp);
default:
;
}
return WvlIrpComplete(irp, 0, STATUS_NOT_SUPPORTED);
}
示例12: DriverEntry
NTSTATUS DriverEntry(
IN PDRIVER_OBJECT InDriverObject,
IN PUNICODE_STRING InRegistryPath)
{
UNREFERENCED_PARAMETER(InRegistryPath);
NTSTATUS Status;
PDEVICE_OBJECT DeviceObject = NULL;
/*
Create device...
*/
if (!NT_SUCCESS(Status = IoCreateDevice(
InDriverObject,
0, // DeviceExtensionSize
NULL,
0x893D, // DeviceType
0, // DeviceCharacteristics
TRUE, // Exclusive
&DeviceObject // [OUT]
)))
goto ERROR_ABORT;
InDriverObject->MajorFunction[IRP_MJ_CREATE] = TestDriverDispatchCreate;
InDriverObject->MajorFunction[IRP_MJ_CLOSE] = TestDriverDispatchClose;
InDriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = TestDriverDispatchDeviceControl;
InDriverObject->DriverUnload = TestDriverUnload;
// run test code...
return RunTestSuite();
ERROR_ABORT:
/*
Rollback in case of errors...
*/
if (DeviceObject != NULL)
IoDeleteDevice(DeviceObject);
return Status;
}
示例13: DriverEntry
//entry point
STDCALL NTSTATUS DriverEntry (IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING RegistryPath){
UNICODE_STRING DeviceNameUnicodeString;
UNICODE_STRING DeviceLinkUnicodeString;
NTSTATUS ntStatus;
PDEVICE_OBJECT DeviceObject = NULL;
OutputDebugString ("dhahelper: entering DriverEntry");
RtlInitUnicodeString (&DeviceNameUnicodeString, L"\\Device\\DHAHELPER");
// Create an EXCLUSIVE device object (only 1 thread at a time
// can make requests to this device).
ntStatus = IoCreateDevice(DriverObject,0,&DeviceNameUnicodeString,FILE_DEVICE_DHAHELPER,0,TRUE,&DeviceObject);
if (NT_SUCCESS(ntStatus)){
// Create dispatch points for device control, create, close.
DriverObject->MajorFunction[IRP_MJ_CREATE] =
DriverObject->MajorFunction[IRP_MJ_CLOSE] =
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = dhahelperdispatch;
DriverObject->DriverUnload = dhahelperunload;
// Create a symbolic link, e.g. a name that a Win32 app can specify
// to open the device.
RtlInitUnicodeString (&DeviceLinkUnicodeString, L"\\DosDevices\\DHAHELPER");
ntStatus = IoCreateSymbolicLink(&DeviceLinkUnicodeString,&DeviceNameUnicodeString);
if (!NT_SUCCESS(ntStatus)){
// Symbolic link creation failed- note this & then delete the
// device object (it's useless if a Win32 app can't get at it).
OutputDebugString ("dhahelper: IoCreateSymbolicLink failed");
IoDeleteDevice (DeviceObject);
}
}
else{
OutputDebugString ("dhahelper: IoCreateDevice failed");
}
OutputDebugString ("dhahelper: leaving DriverEntry");
return ntStatus;
}
示例14: RwPortsUnload
//
// Delete the associated device and return
//
static STDCALL void RwPortsUnload(IN PDRIVER_OBJECT DriverObject)
{
UNICODE_STRING DeviceLinkUnicodeString;
NTSTATUS ntStatus=STATUS_SUCCESS;
OutputDebugString ("rwports: entering RwPortsUnload");
OutputDebugString ("rwports: unmapping remaining memory");
RtlInitUnicodeString (&DeviceLinkUnicodeString, L"\\DosDevices\\rwports");
ntStatus = IoDeleteSymbolicLink (&DeviceLinkUnicodeString);
if (NT_SUCCESS(ntStatus))
{
IoDeleteDevice (DriverObject->DeviceObject);
}
else
{
OutputDebugString ("rwports: IoDeleteSymbolicLink failed");
}
OutputDebugString ("rwports: leaving RwPortsUnload");
}
示例15: UnloadDriver
VOID UnloadDriver(PDRIVER_OBJECT DriverObject)
{
UNICODE_STRING uniLinkName;
PDEVICE_OBJECT CurrentDeviceObject;
PDEVICE_OBJECT NextDeviceObject;
RtlInitUnicodeString(&uniLinkName,LINK_NAME);
IoDeleteSymbolicLink(&uniLinkName);
if (DriverObject->DeviceObject!=NULL)
{
CurrentDeviceObject = DriverObject->DeviceObject;
while(CurrentDeviceObject!=NULL)
{
NextDeviceObject = CurrentDeviceObject->NextDevice;
IoDeleteDevice(CurrentDeviceObject);
CurrentDeviceObject = NextDeviceObject;
}
}
DbgPrint("UnloadDriver\r\n");
}