• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ObReferenceObject函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ObReferenceObject函数的典型用法代码示例。如果您正苦于以下问题:C++ ObReferenceObject函数的具体用法?C++ ObReferenceObject怎么用?C++ ObReferenceObject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ObReferenceObject函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: IoAllocateErrorLogEntry

/*
 * @implemented
 */
PVOID
NTAPI
IoAllocateErrorLogEntry(IN PVOID IoObject,
                        IN UCHAR EntrySize)
{
    PERROR_LOG_ENTRY LogEntry;
    ULONG LogEntrySize;
    PDEVICE_OBJECT DeviceObject;
    PDRIVER_OBJECT DriverObject;

    /* Make sure we have an object */
    if (!IoObject) return NULL;

    /* Check if we're past our buffer */
    if (IopTotalLogSize > PAGE_SIZE) return NULL;

    /* Check if this is a device object or driver object */
    if (((PDEVICE_OBJECT)IoObject)->Type == IO_TYPE_DEVICE)
    {
        /* It's a device, get the driver */
        DeviceObject = (PDEVICE_OBJECT)IoObject;
        DriverObject = DeviceObject->DriverObject;
    }
    else if (((PDEVICE_OBJECT)IoObject)->Type == IO_TYPE_DRIVER)
    {
        /* It's a driver, so we don't have a device */
        DeviceObject = NULL;
        DriverObject = (PDRIVER_OBJECT)IoObject;
    }
    else
    {
        /* Fail */
        return NULL;
    }

    /* Calculate the total size and allocate it */
    LogEntrySize = sizeof(ERROR_LOG_ENTRY) + EntrySize;
    LogEntry = ExAllocatePoolWithTag(NonPagedPool,
                                     LogEntrySize,
                                     TAG_ERROR_LOG);
    if (!LogEntry) return NULL;

    /* Reference the Objects */
    if (DeviceObject) ObReferenceObject(DeviceObject);
    if (DriverObject) ObReferenceObject(DriverObject);

    /* Update log size */
    InterlockedExchangeAdd(&IopTotalLogSize, EntrySize);

    /* Clear the entry and set it up */
    RtlZeroMemory(LogEntry, EntrySize);
    LogEntry->Type = IO_TYPE_ERROR_LOG;
    LogEntry->Size = EntrySize;
    LogEntry->DeviceObject = DeviceObject;
    LogEntry->DriverObject = DriverObject;

    /* Return the entry data */
    return (PVOID)((ULONG_PTR)LogEntry + sizeof(ERROR_LOG_ENTRY));
}
开发者ID:hoangduit,项目名称:reactos,代码行数:62,代码来源:error.c


示例2: IopTraverseDeviceNode

static PDEVICE_OBJECT
IopTraverseDeviceNode(PDEVICE_NODE Node, PUNICODE_STRING DeviceInstance)
{
    PDEVICE_OBJECT DeviceObject;
    PDEVICE_NODE ChildNode;

    if (RtlEqualUnicodeString(&Node->InstancePath,
                              DeviceInstance, TRUE))
    {
        ObReferenceObject(Node->PhysicalDeviceObject);
        return Node->PhysicalDeviceObject;
    }

    /* Traversal of all children nodes */
    for (ChildNode = Node->Child;
         ChildNode != NULL;
         ChildNode = ChildNode->Sibling)
    {
        DeviceObject = IopTraverseDeviceNode(ChildNode, DeviceInstance);
        if (DeviceObject != NULL)
        {
            return DeviceObject;
        }
    }

    return NULL;
}
开发者ID:RPG-7,项目名称:reactos,代码行数:27,代码来源:plugplay.c


示例3: PPJoyBus_JoyDevRelations

NTSTATUS PPJoyBus_JoyDevRelations (IN PJOY_DEVICE_DATA JoyDeviceData, IN PIRP Irp)
{
 PDEVICE_RELATIONS	DeviceRelations;
 NTSTATUS			ntStatus;

 PAGED_CODE ();

 switch (IoGetCurrentIrpStackLocation(Irp)->Parameters.QueryDeviceRelations.Type)
 {
  case TargetDeviceRelation:  
		DeviceRelations= (PDEVICE_RELATIONS) ExAllocatePoolWithTag (PagedPool,sizeof(DEVICE_RELATIONS),PPJOYBUS_POOL_TAG);
		if (!DeviceRelations)
		{
		 ntStatus= STATUS_INSUFFICIENT_RESOURCES;
		 break;
		}
		DeviceRelations->Count= 1;
		DeviceRelations->Objects[0]= JoyDeviceData->Self;
		ObReferenceObject (JoyDeviceData->Self);

		ntStatus = STATUS_SUCCESS;
		Irp->IoStatus.Information= (ULONG_PTR) DeviceRelations;
		break;
        
  case BusRelations:
  case EjectionRelations:
  case RemovalRelations:
  default:
		ntStatus= Irp->IoStatus.Status;
 }

 return ntStatus;
}
开发者ID:Cyborg11,项目名称:PPJoy,代码行数:33,代码来源:JoyPnP.c


示例4: XenM2BPdoQueryDeviceRelations

static NTSTATUS
XenM2BPdoQueryDeviceRelations(PXENM2B_PDO_EXTENSION pPdoExt,
                              PIRP pIrp)
{
    PIO_STACK_LOCATION pIrpStack;
    PDEVICE_RELATIONS  pRelations;
    DEVICE_RELATION_TYPE Type;

    pIrpStack = IoGetCurrentIrpStackLocation(pIrp);
    Type = pIrpStack->Parameters.QueryDeviceRelations.Type;
    if (Type != TargetDeviceRelation) {
        TraceDebug(("%s: Relations Type: %d\n", __FUNCTION__, Type));
        return STATUS_SUCCESS;
    }

    if (XenM2BGetPnPState(&pPdoExt->DevicePnPState) == PnPStateDeleted) {
        TraceDebug(("%s: Target deleted\n", __FUNCTION__));
        return STATUS_NO_SUCH_DEVICE;
    }

    pRelations = ExAllocatePoolWithTag(PagedPool,
                                       sizeof(DEVICE_RELATIONS),
                                       XENM2B_POOL_TAG);
    if (pRelations == NULL) {
        TraceDebug(("%s: Relations alloc failed\n", __FUNCTION__));
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    pRelations->Count = 1;
    pRelations->Objects[0] = pPdoExt->pDevice;
    ObReferenceObject(pPdoExt->pDevice);

    pIrp->IoStatus.Information = (ULONG_PTR)pRelations;
    return STATUS_SUCCESS;
}
开发者ID:OpenXT,项目名称:xc-windows,代码行数:35,代码来源:pdo.c


示例5: ObFastReferenceObjectLocked

NTKERNELAPI
PVOID
FASTCALL
ObFastReferenceObjectLocked (
    IN PEX_FAST_REF FastRef
    )
/*++

Routine Description:

    This routine does a slow object reference. This must be called while
    holding a lock.

Arguments:

    FastRef - Rundown block to be used to reference the object

Return Value:

    PVOID - Object that was referenced or NULL if there was no object.

--*/
{
    PVOID Object;
    EX_FAST_REF OldRef;

    OldRef = *FastRef;
    Object = ExFastRefGetObject (OldRef);
    if (Object != NULL) {
        ObReferenceObject (Object);
    }
    return Object;
}
开发者ID:BaoYu0721,项目名称:WRK-1.2,代码行数:33,代码来源:fastref.c


示例6: GetNextProcessThread

//载自ReactOS-0.3.4-REL-src
PETHREAD
NTAPI
GetNextProcessThread(IN PEPROCESS Process,
					 IN PETHREAD Thread OPTIONAL)
{
    PETHREAD FoundThread = NULL;
    PLIST_ENTRY ListHead, Entry;
    PAGED_CODE();
    
    if (Thread)
    {
		//  Entry = Thread->ThreadListEntry.Flink;;//   +0x22c ThreadListEntry  : _LIST_ENTRY
		Entry = (PLIST_ENTRY)((ULONG)(Thread)+0x224);
		Entry=Entry->Flink;
    }
    else
    {
        Entry = (PLIST_ENTRY)((ULONG)(Process)+0x180);//+0x190 ThreadListHead   : _LIST_ENTRY
        Entry = Entry->Flink; 
    }
	// ListHead = &Process->ThreadListHead;
	ListHead = (PLIST_ENTRY)((ULONG)Process + 0x180);
    while (ListHead != Entry)
    {
		//   FoundThread = CONTAINING_RECORD(Entry, ETHREAD, ThreadListEntry);
		FoundThread = (PETHREAD)((ULONG)Entry - 0x224);
		//    if (ObReferenceObjectSafe(FoundThread)) break;
		if (ObReferenceObject(FoundThread)) break;
        FoundThread = NULL;
        Entry = Entry->Flink;
    }
    if (Thread) ObDereferenceObject(Thread);
    return FoundThread;
}
开发者ID:340211173,项目名称:Gold,代码行数:35,代码来源:ssdt.c


示例7: flush_thread

void STDCALL flush_thread(void* context) {
    DEVICE_OBJECT* devobj = context;
    device_extension* Vcb = devobj->DeviceExtension;
    LARGE_INTEGER due_time;
    
    ObReferenceObject(devobj);
    
    KeInitializeTimer(&Vcb->flush_thread_timer);
    
    due_time.QuadPart = -INTERVAL * 10000;
    
    KeSetTimer(&Vcb->flush_thread_timer, due_time, NULL);
    
    while (TRUE) {
        KeWaitForSingleObject(&Vcb->flush_thread_timer, Executive, KernelMode, FALSE, NULL);

        if (!(devobj->Vpb->Flags & VPB_MOUNTED) || Vcb->removing)
            break;
            
        do_flush(Vcb);
        
        KeSetTimer(&Vcb->flush_thread_timer, due_time, NULL);
    }
    
    ObDereferenceObject(devobj);
    KeCancelTimer(&Vcb->flush_thread_timer);
    
    KeSetEvent(&Vcb->flush_thread_finished, 0, FALSE);
    
    PsTerminateSystemThread(STATUS_SUCCESS);
}
开发者ID:mvardan,项目名称:reactos,代码行数:31,代码来源:flushthread.c


示例8: LookupPdoData

//
//	Increment the reference count to a PDO.
//
PPDO_DEVICE_DATA
LookupPdoData(
	PFDO_DEVICE_DATA	FdoData,
	ULONG				SystemIoBusNumber
	)
{
	PPDO_DEVICE_DATA	pdoData = NULL;
    PLIST_ENTRY         entry;

    PAGED_CODE ();

    KeEnterCriticalRegion();
	ExAcquireFastMutex (&FdoData->Mutex);

    for (entry = FdoData->ListOfPDOs.Flink;
         entry != &FdoData->ListOfPDOs;
         entry = entry->Flink) {

			 pdoData = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link);
             if(pdoData->SlotNo == SystemIoBusNumber)
				 break;
			pdoData = NULL;
		 }
	 if(pdoData) {
		 //
		 //	increment the reference count to the PDO.
		 //
		 ObReferenceObject(pdoData->Self);
	 }

	ExReleaseFastMutex (&FdoData->Mutex);
    KeLeaveCriticalRegion();

	return pdoData;
}
开发者ID:JanD1943,项目名称:ndas4windows,代码行数:38,代码来源:busenum.c


示例9: CcScheduleReadAhead

VOID
NTAPI
CcScheduleReadAhead(IN PFILE_OBJECT FileObject,
                    IN PLARGE_INTEGER FileOffset,
                    IN ULONG Length)
{
    PWORK_QUEUE_WITH_READ_AHEAD WorkItem;

    DPRINT("Schedule read ahead %08x%08x:%x %wZ\n",
           FileOffset->HighPart,
           FileOffset->LowPart,
           Length,
           &FileObject->FileName);

    WorkItem = ExAllocatePool(NonPagedPool, sizeof(*WorkItem));
    if (!WorkItem) KeBugCheck(0);
    ObReferenceObject(FileObject);
    WorkItem->FileObject = FileObject;
    WorkItem->FileOffset = *FileOffset;
    WorkItem->Length = Length;

    ExInitializeWorkItem(((PWORK_QUEUE_ITEM)WorkItem),
                         (PWORKER_THREAD_ROUTINE)CcpReadAhead,
                         WorkItem);

    ExQueueWorkItem((PWORK_QUEUE_ITEM)WorkItem, DelayedWorkQueue);
    DPRINT("Done\n");
}
开发者ID:RPG-7,项目名称:reactos,代码行数:28,代码来源:cachesub.c


示例10: vboxNewProtDeviceRemoved

static NTSTATUS vboxNewProtDeviceRemoved(PVBOXMOUSE_DEVEXT pDevExt)
{
    if (!vboxNewProtIsEnabled())
    {
        WARN(("New Protocol is disabled"));
        return STATUS_UNSUCCESSFUL;
    }

    KIRQL Irql;
    NTSTATUS Status = STATUS_SUCCESS;
    KeAcquireSpinLock(&g_ctx.SyncLock, &Irql);
    RemoveEntryList(&pDevExt->ListEntry);
    if (g_ctx.pCurrentDevExt == pDevExt)
    {
        ObDereferenceObject(pDevExt->pdoSelf);
        g_ctx.pCurrentDevExt = NULL;
        for (PLIST_ENTRY pCur = g_ctx.DevExtList.Flink; pCur != &g_ctx.DevExtList; pCur = pCur->Flink)
        {
            PVBOXMOUSE_DEVEXT pNewCurDevExt = PVBOXMOUSE_DEVEXT_FROM_LE(pCur);
            ASMAtomicWritePtr(&g_ctx.pCurrentDevExt, pNewCurDevExt);
            /* ensure the object is not deleted while it is being used by a poller thread */
            ObReferenceObject(pNewCurDevExt->pdoSelf);
            break;
        }
    }

    KeReleaseSpinLock(&g_ctx.SyncLock, Irql);

    return Status;
}
开发者ID:virendramishra,项目名称:VirtualBox4.1.18,代码行数:30,代码来源:VBoxMFInternal.cpp


示例11: IoBuildDeviceIoControlRequest

NTSTATUS CIoControlIrp::Create(PDEVICE_OBJECT TargetDevice,
                               ULONG IoControlCode,
                               bool IsInternal,
                               PVOID InputBuffer,
                               ULONG InputBufferLength,
                               PVOID OutputBuffer,
                               ULONG OutputBufferLength)
{
    m_Irp = IoBuildDeviceIoControlRequest(IoControlCode,
                                          TargetDevice,
                                          InputBuffer,
                                          InputBufferLength,
                                          OutputBuffer,
                                          OutputBufferLength,
                                          IsInternal ? TRUE : FALSE,
                                          m_Event,
                                          &m_IoControlStatus);

    if (m_Irp == nullptr)
    {
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    ObReferenceObject(TargetDevice);
    m_TargetDevice = TargetDevice;
    return STATUS_SUCCESS;
}
开发者ID:daynix,项目名称:UsbDk,代码行数:27,代码来源:Irp.cpp


示例12: GetDosDeviceName

VOID
GetDosDeviceName(PDEVICE_OBJECT pDeviceObject,
				 PUNICODE_STRING pShareName,
				 PUNICODE_STRING pDosName)
{
	NTSTATUS status;
	UNICODE_STRING tempDosDrive;

	ObReferenceObject(pDeviceObject);

	status = IoVolumeDeviceToDosName(
		(PVOID)pDeviceObject,
		&tempDosDrive);

	pDosName->Length = 0;

	if(NT_SUCCESS(status))
	{
		int i = 0;
		int wchars = tempDosDrive.Length/2;
		int pos = 0;
		
		pDosName->MaximumLength = tempDosDrive.MaximumLength + 2;
		pDosName->Buffer = ExAllocatePoolWithTag(NonPagedPool, pDosName->MaximumLength, FILE_POOL_TAG);
		
		if(pDosName->Buffer != NULL)
		{
			pDosName->Buffer[pos++] = '\\';
			pDosName->Length += sizeof(WCHAR);
			for(i = 0; i < wchars; i++)
			{
				if(tempDosDrive.Buffer[i] != 0x003A)
				{
					pDosName->Buffer[pos++] = tempDosDrive.Buffer[i];
					pDosName->Length += sizeof(WCHAR); // Unicode is 2-bytes
				}
			}
			ExFreePool(tempDosDrive.Buffer);
		}
	} else {
		if(pShareName != NULL)
		{
			pDosName->MaximumLength = pShareName->MaximumLength;
			pDosName->Buffer = ExAllocatePoolWithTag(NonPagedPool, pDosName->MaximumLength, FILE_POOL_TAG);
			if(pDosName->Buffer != NULL)
			{
				RtlUnicodeStringCopy(pDosName, pShareName);
			}
		} else {
			pDosName->MaximumLength = 30; // Dont change this
			pDosName->Buffer = ExAllocatePoolWithTag(NonPagedPool, pDosName->MaximumLength, FILE_POOL_TAG);
			if(pDosName->Buffer != NULL)
			{
				RtlUnicodeStringCatString(pDosName, L"\\UNKNOWN DRIVE");
			}
		}
	}
	ObDereferenceObject(pDeviceObject);
}
开发者ID:340211173,项目名称:capture-hpc,代码行数:59,代码来源:CaptureFileMonitor.c


示例13: InitCsrProcess

VOID
InitCsrProcess(VOID /*IN PEPROCESS CsrProcess*/)
{
    /* Save the EPROCESS of CSRSS */
    gpepCSRSS = PsGetCurrentProcess();
    // gpepCSRSS = CsrProcess;
    ObReferenceObject(gpepCSRSS);
}
开发者ID:Strongc,项目名称:reactos,代码行数:8,代码来源:csr.c


示例14: ExpShutdownWorker

VOID
ExpShutdownWorker (
    IN PVOID Parameter
    )
{
    PETHREAD CurrentThread;
    PSHUTDOWN_WORK_ITEM  ShutdownItem;

    ShutdownItem = (PSHUTDOWN_WORK_ITEM) Parameter;

    ASSERT (ShutdownItem != NULL);

    if (ShutdownItem->PrevThread != NULL) {

        //
        // Wait for the previous thread to exit -- if it's in the same
        // queue, it probably has already, but we need to make sure
        // (and if it's not, we *definitely* need to make sure).
        //

        KeWaitForSingleObject (ShutdownItem->PrevThread,
                               Executive,
                               KernelMode,
                               FALSE,
                               NULL);

        ObDereferenceObject (ShutdownItem->PrevThread);

        ShutdownItem->PrevThread = NULL;
    }

    //
    // Decrement the worker count.
    //

    InterlockedDecrement (&ExWorkerQueue[ShutdownItem->QueueType].Info.QueueWorkerInfo);

    CurrentThread = PsGetCurrentThread();

    if ((!ExpCheckQueueShutdown(DelayedWorkQueue, ShutdownItem)) &&
        (!ExpCheckQueueShutdown(CriticalWorkQueue, ShutdownItem))) {

        //
        // We're the last worker to exit
        //

        ASSERT (!ExpLastWorkerThread);
        ExpLastWorkerThread = CurrentThread;
        ObReferenceObject (ExpLastWorkerThread);
        KeSetEvent (&ExpThreadSetManagerShutdownEvent, 0, FALSE);
    }

    KeSetKernelStackSwapEnable (TRUE);
    CurrentThread->ActiveExWorker = 0;

    PsTerminateSystemThread (STATUS_SYSTEM_SHUTDOWN);
}
开发者ID:BaoYu0721,项目名称:WRK-1.2,代码行数:57,代码来源:worker.c


示例15: HidClassFDO_CopyDeviceRelations

NTSTATUS
HidClassFDO_CopyDeviceRelations(
    IN PDEVICE_OBJECT DeviceObject,
    OUT PDEVICE_RELATIONS *OutRelations)
{
    PDEVICE_RELATIONS DeviceRelations;
    PHIDCLASS_FDO_EXTENSION FDODeviceExtension;
    ULONG Index;

    //
    // get device extension
    //
    FDODeviceExtension = DeviceObject->DeviceExtension;
    ASSERT(FDODeviceExtension->Common.IsFDO);

    //
    // allocate result
    //
    DeviceRelations = ExAllocatePoolWithTag(NonPagedPool,
                                            sizeof(DEVICE_RELATIONS) + (FDODeviceExtension->DeviceRelations->Count - 1) * sizeof(PDEVICE_OBJECT),
                                            HIDCLASS_TAG);
    if (!DeviceRelations)
    {
        //
        // no memory
        //
        *OutRelations = NULL;
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    //
    // copy device objects
    //
    for (Index = 0; Index < FDODeviceExtension->DeviceRelations->Count; Index++)
    {
        //
        // reference pdo
        //
        ObReferenceObject(FDODeviceExtension->DeviceRelations->Objects[Index]);

        //
        // store object
        //
        DeviceRelations->Objects[Index] = FDODeviceExtension->DeviceRelations->Objects[Index];
    }

    //
    // set object count
    //
    DeviceRelations->Count = FDODeviceExtension->DeviceRelations->Count;

    //
    // store result
    //
    *OutRelations = DeviceRelations;
    return STATUS_SUCCESS;
}
开发者ID:GYGit,项目名称:reactos,代码行数:57,代码来源:fdo.c


示例16: IopShutdownBaseFileSystems

/*
 * @implemented
 */
VOID
NTAPI
IopShutdownBaseFileSystems(IN PLIST_ENTRY ListHead)
{
    PLIST_ENTRY ListEntry;
    PDEVICE_OBJECT DeviceObject;
    IO_STATUS_BLOCK StatusBlock;
    PIRP Irp;
    KEVENT Event;
    NTSTATUS Status;

    KeInitializeEvent(&Event, NotificationEvent, FALSE);

    /* Get the first entry and start looping */
    ListEntry = ListHead->Flink;
    while (ListEntry != ListHead)
    {
        /* Get the device object */
        DeviceObject = CONTAINING_RECORD(ListEntry,
                                         DEVICE_OBJECT,
                                         Queue.ListEntry);

        ObReferenceObject(DeviceObject);
        IopInterlockedIncrementUlong(LockQueueIoDatabaseLock, (PULONG)&DeviceObject->ReferenceCount);

        /* Check if we're attached */
        if (DeviceObject->AttachedDevice)
        {
            /* Get the attached device */
            DeviceObject = IoGetAttachedDevice(DeviceObject);
        }

        /* Build the shutdown IRP and call the driver */
        Irp = IoBuildSynchronousFsdRequest(IRP_MJ_SHUTDOWN,
                                           DeviceObject,
                                           NULL,
                                           0,
                                           NULL,
                                           &Event,
                                           &StatusBlock);
        Status = IoCallDriver(DeviceObject, Irp);
        if (Status == STATUS_PENDING)
        {
            /* Wait on the driver */
            KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
        }

        /* Reset the event */
        KeClearEvent(&Event);

        IopDecrementDeviceObjectRef(DeviceObject, FALSE);
        ObDereferenceObject(DeviceObject);

        /* Go to the next entry */
        ListEntry = ListEntry->Flink;
    }
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:60,代码来源:volume.c


示例17: ImScsiGetControllerObject

NTSTATUS
ImScsiGetControllerObject()
{
    PDEVICE_OBJECT dev_obj;

    if (pMPDrvInfoGlobal->ControllerObject != NULL)
    {
        return STATUS_SUCCESS;
    }

    KdBreakPoint();

    for (dev_obj = pMPDrvInfoGlobal->pDriverObj->DeviceObject;
        dev_obj != NULL;
#pragma warning(suppress: 28175)
        dev_obj = dev_obj->NextDevice)
    {
        if (dev_obj->DeviceType == FILE_DEVICE_CONTROLLER)
        {
            ObReferenceObject(dev_obj);

            pMPDrvInfoGlobal->ControllerObject = dev_obj;

#if DBG
            {
                POBJECT_NAME_INFORMATION objstr = (POBJECT_NAME_INFORMATION)
                    ExAllocatePoolWithTag(NonPagedPool,
                        1024, MP_TAG_GENERAL);

                if (objstr != NULL)
                {
                    ULONG retl;
                    NTSTATUS status;

                    status = ObQueryNameString(pMPDrvInfoGlobal->ControllerObject,
                        objstr, 1024, &retl);

                    if (NT_SUCCESS(status))
                    {
                        DbgPrint("PhDskMnt::ImScsiGetControllerObject: Successfully opened '%wZ'.\n",
                            &objstr->Name);
                    }

                    ExFreePoolWithTag(objstr, MP_TAG_GENERAL);
                }
            }
#endif

            return STATUS_SUCCESS;
        }
    }
    

    DbgPrint("PhDskMnt::ImScsiGetControllerObject: Could not locate SCSI adapter device object by name.\n");

    return STATUS_DEVICE_DOES_NOT_EXIST;
}
开发者ID:ArsenalRecon,项目名称:Arsenal-Image-Mounter,代码行数:57,代码来源:phdskmnt.cpp


示例18: create_part0

static NTSTATUS create_part0(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT DeviceObject, PUNICODE_STRING pardir, PUNICODE_STRING nameus,
                             BTRFS_UUID* uuid) {
    PDEVICE_OBJECT newdevobj;
    UNICODE_STRING name;
    NTSTATUS Status;
    part0_device_extension* p0de;
    
    static const WCHAR btrfs_partition[] = L"\\BtrfsPartition";
    
    name.Length = name.MaximumLength = pardir->Length + (wcslen(btrfs_partition) * sizeof(WCHAR));
    name.Buffer = ExAllocatePoolWithTag(PagedPool, name.Length, ALLOC_TAG);
    if (!name.Buffer) {
        ERR("out of memory\n");
        return STATUS_INSUFFICIENT_RESOURCES;
    }
    
    RtlCopyMemory(name.Buffer, pardir->Buffer, pardir->Length);
    RtlCopyMemory(&name.Buffer[pardir->Length / sizeof(WCHAR)], btrfs_partition, wcslen(btrfs_partition) * sizeof(WCHAR));
    
    Status = IoCreateDevice(DriverObject, sizeof(part0_device_extension), &name, FILE_DEVICE_DISK, FILE_DEVICE_SECURE_OPEN, FALSE, &newdevobj);
    if (!NT_SUCCESS(Status)) {
        ERR("IoCreateDevice returned %08x\n", Status);
        ExFreePool(name.Buffer);
        return Status;
    }
    
    p0de = newdevobj->DeviceExtension;
    p0de->type = VCB_TYPE_PARTITION0;
    p0de->devobj = DeviceObject;
    RtlCopyMemory(&p0de->uuid, uuid, sizeof(BTRFS_UUID));
    
    p0de->name.Length = name.Length;
    p0de->name.MaximumLength = name.MaximumLength;
    p0de->name.Buffer = ExAllocatePoolWithTag(PagedPool, p0de->name.MaximumLength, ALLOC_TAG);
    
    if (!p0de->name.Buffer) {
        ERR("out of memory\b");
        ExFreePool(name.Buffer);
        ExFreePool(p0de->name.Buffer);
        IoDeleteDevice(newdevobj);
        return STATUS_INSUFFICIENT_RESOURCES;
    }
    
    RtlCopyMemory(p0de->name.Buffer, name.Buffer, name.Length);
    
    ObReferenceObject(DeviceObject);
    
    newdevobj->StackSize = DeviceObject->StackSize + 1;
    
    newdevobj->Flags |= DO_DIRECT_IO;
    newdevobj->Flags &= ~DO_DEVICE_INITIALIZING;
    
    *nameus = name;
    
    return STATUS_SUCCESS;
}
开发者ID:mvardan,项目名称:reactos,代码行数:56,代码来源:search.c


示例19: KdbpCaptureFileForSymbols

static PROSSYM_KM_OWN_CONTEXT
KdbpCaptureFileForSymbols(PFILE_OBJECT FileObject)
{
    PROSSYM_KM_OWN_CONTEXT Context = ExAllocatePool(NonPagedPool, sizeof(*Context));
    if (!Context) return NULL;
    ObReferenceObject(FileObject);
    Context->FileOffset.QuadPart = 0;
    Context->FileObject = FileObject;
    return Context;
}
开发者ID:GYGit,项目名称:reactos,代码行数:10,代码来源:kdb_symbols.cmake.c


示例20: DokanCreateGlobalDiskDevice

NTSTATUS
DokanCreateGlobalDiskDevice(
	__in PDRIVER_OBJECT DriverObject,
	__out PDOKAN_GLOBAL* DokanGlobal
	)
{
	WCHAR	deviceNameBuf[] = DOKAN_GLOBAL_DEVICE_NAME; 
	WCHAR	symbolicLinkBuf[] = DOKAN_GLOBAL_SYMBOLIC_LINK_NAME;
	NTSTATUS		status;
	UNICODE_STRING	deviceName;
	UNICODE_STRING	symbolicLinkName;
	PDEVICE_OBJECT	deviceObject;
	PDOKAN_GLOBAL	dokanGlobal;

	RtlInitUnicodeString(&deviceName, deviceNameBuf);
	RtlInitUnicodeString(&symbolicLinkName, symbolicLinkBuf);

	status = IoCreateDeviceSecure(
				DriverObject,		// DriverObject
				sizeof(DOKAN_GLOBAL),// DeviceExtensionSize
				&deviceName,		// DeviceName
				FILE_DEVICE_UNKNOWN,// DeviceType
				0,					// DeviceCharacteristics
				FALSE,				// Not Exclusive
				&sddl, // Default SDDL String
				NULL,				// Device Class GUID
				&deviceObject);		// DeviceObject

	if (!NT_SUCCESS(status)) {
		DDbgPrint("  IoCreateDevice returned 0x%x\n", status);
		return status;
	}
	DDbgPrint("DokanGlobalDevice: %wZ created\n", &deviceName);
	ObReferenceObject(deviceObject);

	status = IoCreateSymbolicLink(&symbolicLinkName, &deviceName);
	if (!NT_SUCCESS(status)) {
		DDbgPrint("  IoCreateSymbolicLink returned 0x%x\n", status);
		IoDeleteDevice(deviceObject);
		return status;
	}
	DDbgPrint("SymbolicLink: %wZ -> %wZ created\n", &deviceName, &symbolicLinkName);
	dokanGlobal = deviceObject->DeviceExtension;
	dokanGlobal->DeviceObject = deviceObject;

	RtlZeroMemory(dokanGlobal, sizeof(DOKAN_GLOBAL));
	DokanInitIrpList(&dokanGlobal->PendingService);
	DokanInitIrpList(&dokanGlobal->NotifyService);

	dokanGlobal->Identifier.Type = DGL;
	dokanGlobal->Identifier.Size = sizeof(DOKAN_GLOBAL);

	*DokanGlobal = dokanGlobal;
	return STATUS_SUCCESS;
}
开发者ID:liuk9662,项目名称:dokany,代码行数:55,代码来源:init.c



注:本文中的ObReferenceObject函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ObReferenceObjectByHandle函数代码示例发布时间:2022-05-30
下一篇:
C++ ObDereferenceObject函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap