当前位置: 首页>>代码示例>>C++>>正文


C++ ObReferenceObject函数代码示例

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


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


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