Пример #1
0
NTSTATUS
MobiUsb_WmiDeRegistration(
    IN OUT PDEVICE_EXTENSION DeviceExtension
    )
/*++

Routine Description:

     Inform WMI to remove this DeviceObject from its 
     list of providers. This function also 
     decrements the reference count of the deviceobject.

Arguments:

Return Value:

--*/
{

    PAGED_CODE();

    return IoWMIRegistrationControl(DeviceExtension->FunctionalDeviceObject,
                                    WMIREG_ACTION_DEREGISTER);

}
Пример #2
0
/*++
Routine Description

     Inform WMI to remove this DeviceObject from its 
     list of providers. This function also 
     decrements the reference count of the deviceobject.

--*/
NTSTATUS
NdasPortWmiDeregister(
	__in PNDASPORT_FDO_EXTENSION FdoExtension)
{
	PAGED_CODE();

    return IoWMIRegistrationControl(
		FdoExtension->DeviceObject,
		WMIREG_ACTION_DEREGISTER);
}
Пример #3
0
Файл: Wmi.c Проект: Shmuma/usbip
NTSTATUS
Bus_WmiRegistration(
    PFDO_DEVICE_DATA               FdoData
)
/*++
Routine Description

    Registers with WMI as a data provider for this
    instance of the device

--*/
{
    NTSTATUS status;

    PAGED_CODE();

    FdoData->WmiLibInfo.GuidCount = sizeof (ToasterBusWmiGuidList) /
                                 sizeof (WMIGUIDREGINFO);
    ASSERT (NUMBER_OF_WMI_GUIDS == FdoData->WmiLibInfo.GuidCount);
    FdoData->WmiLibInfo.GuidList = ToasterBusWmiGuidList;
    FdoData->WmiLibInfo.QueryWmiRegInfo = Bus_QueryWmiRegInfo;
    FdoData->WmiLibInfo.QueryWmiDataBlock = Bus_QueryWmiDataBlock;
    FdoData->WmiLibInfo.SetWmiDataBlock = Bus_SetWmiDataBlock;
    FdoData->WmiLibInfo.SetWmiDataItem = Bus_SetWmiDataItem;
    FdoData->WmiLibInfo.ExecuteWmiMethod = NULL;
    FdoData->WmiLibInfo.WmiFunctionControl = NULL;

    //
    // Register with WMI
    //

    status = IoWMIRegistrationControl(FdoData->Self,
                             WMIREG_ACTION_REGISTER
                             );

    //
    // Initialize the Std device data structure
    //

    FdoData->StdToasterBusData.ErrorCount = 0;
    FdoData->StdToasterBusData.DebugPrintLevel = BusEnumDebugLevel;

    return status;

}
Пример #4
0
NTSTATUS BulkUsb_WmiRegistration(IN OUT PTDeviceExtension DeviceExtension)
{
    NTSTATUS ntStatus;
    
    PAGED_CODE();
    DeviceExtension->WmiLibInfo.GuidCount = 
          sizeof (BulkWmiGuidList) / sizeof (WMIGUIDREGINFO);
    DeviceExtension->WmiLibInfo.GuidList           = (WMIGUIDREGINFO *)BulkWmiGuidList;
    DeviceExtension->WmiLibInfo.QueryWmiRegInfo    = BulkUsb_QueryWmiRegInfo;
    DeviceExtension->WmiLibInfo.QueryWmiDataBlock  = BulkUsb_QueryWmiDataBlock;
    DeviceExtension->WmiLibInfo.SetWmiDataBlock    = BulkUsb_SetWmiDataBlock;
    DeviceExtension->WmiLibInfo.SetWmiDataItem     = BulkUsb_SetWmiDataItem;
    DeviceExtension->WmiLibInfo.ExecuteWmiMethod   = NULL;
    DeviceExtension->WmiLibInfo.WmiFunctionControl = NULL;
    ntStatus = IoWMIRegistrationControl(DeviceExtension->FunctionalDeviceObject,
                                        WMIREG_ACTION_REGISTER);
    return ntStatus;
}
Пример #5
0
NTSTATUS
MobiUsb_WmiRegistration(
    IN OUT PDEVICE_EXTENSION DeviceExtension
    )
/*++

Routine Description:

    Registers with WMI as a data provider for this
    instance of the device

Arguments:

Return Value:

--*/
{
    NTSTATUS ntStatus;
    
    PAGED_CODE();

    DeviceExtension->WmiLibInfo.GuidCount = 
          sizeof (MobiWmiGuidList) / sizeof (WMIGUIDREGINFO);

    DeviceExtension->WmiLibInfo.GuidList           = MobiWmiGuidList;
    DeviceExtension->WmiLibInfo.QueryWmiRegInfo    = MobiUsb_QueryWmiRegInfo;
    DeviceExtension->WmiLibInfo.QueryWmiDataBlock  = MobiUsb_QueryWmiDataBlock;
    DeviceExtension->WmiLibInfo.SetWmiDataBlock    = MobiUsb_SetWmiDataBlock;
    DeviceExtension->WmiLibInfo.SetWmiDataItem     = MobiUsb_SetWmiDataItem;
    DeviceExtension->WmiLibInfo.ExecuteWmiMethod   = NULL;
    DeviceExtension->WmiLibInfo.WmiFunctionControl = NULL;

    //
    // Register with WMI
    //
    
    ntStatus = IoWMIRegistrationControl(DeviceExtension->FunctionalDeviceObject,
                                        WMIREG_ACTION_REGISTER);

    return ntStatus;
    
}
Пример #6
0
Файл: Wmi.c Проект: Shmuma/usbip
NTSTATUS
Bus_WmiDeRegistration(
    PFDO_DEVICE_DATA               FdoData
)
/*++
Routine Description

     Inform WMI to remove this DeviceObject from its
     list of providers. This function also
     decrements the reference count of the deviceobject.

--*/
{

    PAGED_CODE();

    return IoWMIRegistrationControl(FdoData->Self,
                                 WMIREG_ACTION_DEREGISTER
                                 );

}
Пример #7
0
NTSTATUS NTAPI FreeBT_WmiRegistration(IN OUT PDEVICE_EXTENSION DeviceExtension)
{
    NTSTATUS ntStatus;

    PAGED_CODE();

    DeviceExtension->WmiLibInfo.GuidCount = sizeof (FreeBTWmiGuidList) / sizeof (WMIGUIDREGINFO);
    DeviceExtension->WmiLibInfo.GuidList           = FreeBTWmiGuidList;
    DeviceExtension->WmiLibInfo.QueryWmiRegInfo    = FreeBT_QueryWmiRegInfo;
    DeviceExtension->WmiLibInfo.QueryWmiDataBlock  = FreeBT_QueryWmiDataBlock;
    DeviceExtension->WmiLibInfo.SetWmiDataBlock    = FreeBT_SetWmiDataBlock;
    DeviceExtension->WmiLibInfo.SetWmiDataItem     = FreeBT_SetWmiDataItem;
    DeviceExtension->WmiLibInfo.ExecuteWmiMethod   = NULL;
    DeviceExtension->WmiLibInfo.WmiFunctionControl = NULL;

    // Register with WMI
    ntStatus = IoWMIRegistrationControl(DeviceExtension->FunctionalDeviceObject, WMIREG_ACTION_REGISTER);

    return ntStatus;

}
Пример #8
0
/*++

Routine Description

Registers with WMI as a data provider for this
instance of the device

--*/
NTSTATUS
NdasPortWmiRegister(
    __in PNDASPORT_FDO_EXTENSION FdoExtension)
{
    NTSTATUS status;

    PAGED_CODE();

    FdoExtension->WmiLibInfo.GuidCount = 
		sizeof (NdasPortWmiGuidList) /
        sizeof (WMIGUIDREGINFO);

    ASSERT (NUMBER_OF_WMI_GUIDS == FdoExtension->WmiLibInfo.GuidCount);
    FdoExtension->WmiLibInfo.GuidList = NdasPortWmiGuidList;
    FdoExtension->WmiLibInfo.QueryWmiRegInfo = NdasPortQueryWmiRegInfo;
    FdoExtension->WmiLibInfo.QueryWmiDataBlock = NdasPortQueryWmiDataBlock;
    FdoExtension->WmiLibInfo.SetWmiDataBlock = NdasPortSetWmiDataBlock;
    FdoExtension->WmiLibInfo.SetWmiDataItem = NdasPortSetWmiDataItem;
    FdoExtension->WmiLibInfo.ExecuteWmiMethod = NULL;
    FdoExtension->WmiLibInfo.WmiFunctionControl = NULL;

    //
    // Register with WMI
    //
    
    status = IoWMIRegistrationControl(
		FdoExtension->DeviceObject,
        WMIREG_ACTION_REGISTER);

    //
    // Initialize the Std device data structure
    //
                    
    //FdoExtension->NdasPortWmiData.ErrorCount = 0; 
    //FdoExtension->NdasPortWmiData.DebugPrintLevel = BusEnumDebugLevel;

    return status;
    
}
Пример #9
0
NTSTATUS BulkUsb_WmiDeRegistration(IN OUT PTDeviceExtension DeviceExtension)
{
    PAGED_CODE();
    return IoWMIRegistrationControl(DeviceExtension->FunctionalDeviceObject,
                                    WMIREG_ACTION_DEREGISTER);
}
Пример #10
0
NTSTATUS
ScsiPortInitDevice(
    IN PDEVICE_OBJECT DeviceObject
    )

/*++

Routine Description:

    This routine will attempt to start the specified device object.

Arguments:

    DeviceObject - a pointer to the PDO being started

Return Value:

    status

--*/

{
    PCOMMON_EXTENSION commonExtension = DeviceObject->DeviceExtension;
    PLOGICAL_UNIT_EXTENSION logicalUnit = DeviceObject->DeviceExtension;
    PADAPTER_EXTENSION adapterExtension = logicalUnit->AdapterExtension;

    HANDLE instanceHandle;

    NTSTATUS status = STATUS_SUCCESS;

    PAGED_CODE();

    //
    // Initialize the idle detection timer.  Tell the system to put us into a
    // D3 state when we're not being used.
    //

    logicalUnit->CommonExtension.IdleTimer =
        PoRegisterDeviceForIdleDetection(DeviceObject,
                                         SpPowerIdleTimeout,
                                         SpPowerIdleTimeout,
                                         PowerDeviceD3);

    //
    // Initialize WMI support.
    //

    if (commonExtension->WmiInitialized == FALSE) {

        //
        // Build the SCSIPORT WMI registration information buffer for this PDO.
        //

        SpWmiInitializeSpRegInfo(DeviceObject);

        //
        // Register this device object only if the miniport supports WMI and/or
        // SCSIPORT will support certain WMI GUIDs on behalf of the miniport.
        //

        if (commonExtension->WmiMiniPortSupport ||
            commonExtension->WmiScsiPortRegInfoBuf) {

            //
            // Register this physical device object as a WMI data provider,
            // instructing WMI that it is ready to receive WMI IRPs.
            //

            IoWMIRegistrationControl(DeviceObject, WMIREG_ACTION_REGISTER);
            commonExtension->WmiInitialized = TRUE;

        }

        //
        // Allocate several WMI_MINIPORT_REQUEST_ITEM blocks to satisfy a
        // potential onslaught of WMIEvent notifications by the miniport.
        //

        if (commonExtension->WmiMiniPortSupport) {

            //
            // Currently we only allocate two per new SCSI target (PDO).
            //
            SpWmiInitializeFreeRequestList(DeviceObject, 2);
        }
    }

    //
    // Build a device map entry for this logical unit.
    //

    SpBuildDeviceMapEntry(DeviceObject);

    return status;
}
Пример #11
0
NTSTATUS NTAPI FreeBT_WmiDeRegistration(IN OUT PDEVICE_EXTENSION DeviceExtension)
{
    PAGED_CODE();
    return IoWMIRegistrationControl(DeviceExtension->FunctionalDeviceObject, WMIREG_ACTION_DEREGISTER);

}
Пример #12
0
VOID
ScsiPortRemoveAdapter(
    IN PDEVICE_OBJECT AdapterObject,
    IN BOOLEAN Surprise
    )
{
    PADAPTER_EXTENSION adapter = AdapterObject->DeviceExtension;
    PCOMMON_EXTENSION commonExtension = AdapterObject->DeviceExtension;

    NTSTATUS status = STATUS_SUCCESS;

    PAGED_CODE();

    ASSERT_FDO(AdapterObject);
    ASSERT(adapter->IsPnp);

    //
    // Set the flag PD_ADAPTER_REMOVED to keep scsiport from calling into the 
    // miniport after we've started this teardown.
    //

    if(Surprise == FALSE) {
        PVOID sectionHandle;
        KIRQL oldIrql;

        //
        // Wait until all outstanding requests have been completed.
        //
    
        SpWaitForRemoveLock(AdapterObject, AdapterObject);

        //
        // If the device is started we should uninitialize the miniport and 
        // release it's resources.  Fortunately this is exactly what stop does.  
        //

        if((commonExtension->CurrentPnpState != IRP_MN_SURPRISE_REMOVAL) &&
           ((commonExtension->CurrentPnpState == IRP_MN_START_DEVICE) ||
            (commonExtension->PreviousPnpState == IRP_MN_START_DEVICE))) {

            //
            // Okay.  If this adapter can't support remove then we're dead
            //

            ASSERT(SpIsAdapterControlTypeSupported(adapter, ScsiStopAdapter) == TRUE);

            //
            // Stop the miniport now that it's safe.
            //

            SpEnableDisableAdapter(adapter, FALSE);

            //
            // Mark the adapter as removed.
            //
    
    #ifdef ALLOC_PRAGMA
            sectionHandle = MmLockPagableCodeSection(ScsiPortRemoveAdapter);
            InterlockedIncrement(&SpPAGELOCKLockCount);
    #endif
            KeAcquireSpinLock(&(adapter->SpinLock), &oldIrql);
            adapter->SynchronizeExecution(adapter->InterruptObject,
                                          SpRemoveAdapterSynchronized,
                                          adapter);
    
            KeReleaseSpinLock(&(adapter->SpinLock), oldIrql);
    
    #ifdef ALLOC_PRAGMA
            InterlockedDecrement(&SpPAGELOCKLockCount);
            MmUnlockPagableImageSection(sectionHandle);
    #endif

        }
        SpReapChildren(adapter);
    }

    if(commonExtension->WmiInitialized == TRUE) {

        //
        // Destroy all our WMI resources and unregister with WMI.
        //

        IoWMIRegistrationControl(AdapterObject, WMIREG_ACTION_DEREGISTER);
        SpWmiRemoveFreeMiniPortRequestItems(adapter);
        commonExtension->WmiInitialized = FALSE;
    }

    //
    // If we were surprise removed then this has already been done once.  
    // In that case don't try to run the cleanup code a second time even though 
    // it's safe to do so.
    //

    SpDeleteDeviceMapEntry(AdapterObject);
    SpDestroyAdapter(adapter, Surprise);

    return;
}
Пример #13
0
VOID
SpDeleteLogicalUnit(
    IN PDEVICE_OBJECT LogicalUnit
    )

/*++

Routine Description:

    This routine will release any resources held for the logical unit, mark the
    device extension as deleted, and call the io system to actually delete
    the object.  The device object will be deleted once it's reference count
    drops to zero.

Arguments:

    LogicalUnit - the device object for the logical unit to be deleted.

Return Value:

    none

--*/

{
    PLOGICAL_UNIT_EXTENSION luExtension = LogicalUnit->DeviceExtension;
    PCOMMON_EXTENSION commonExtension = LogicalUnit->DeviceExtension;

    PAGED_CODE();

    ASSERT(luExtension->ReadyLogicalUnit == NULL);
    ASSERT(luExtension->PendingRequest == NULL);
    ASSERT(luExtension->BusyRequest == NULL);
    ASSERT(luExtension->QueueCount == 0);

    //
    // Unregister with WMI.
    //

    if(commonExtension->WmiInitialized == TRUE) {

        //
        // Destroy all our WMI resources and unregister with WMI.
        //

        IoWMIRegistrationControl(LogicalUnit,
            WMIREG_ACTION_DEREGISTER);

        // BUGBUG
        // We should be asking the WmiFreeRequestList of remove some
        // free cells.

        commonExtension->WmiInitialized = FALSE;
        SpWmiDestroySpRegInfo(LogicalUnit);
    }

    SpDeleteDeviceMapEntry(luExtension->DeviceObject);

    //
    // Yank this out of the logical unit list.
    //

    SpRemoveLogicalUnitFromBin(luExtension->AdapterExtension, luExtension);

#if DBG
    // ASSERT(commonExtension->RemoveTrackingList == NULL);
    ExDeleteNPagedLookasideList(&(commonExtension->RemoveTrackingLookasideList));
#endif

    //
    // If the request sense irp still exists, delete it.
    //

    if(luExtension->RequestSenseIrp != NULL) {
        IoFreeIrp(luExtension->RequestSenseIrp);
        luExtension->RequestSenseIrp = NULL;
    }

    IoDeleteDevice(LogicalUnit);

    return;
}
Пример #14
0
BOOLEAN HidePort(IN PC0C_FDOPORT_EXTENSION pDevExt)
{
    BOOLEAN res;
    NTSTATUS status;

    if (!pDevExt->shown)
        return TRUE;

    res = TRUE;

    if ((pDevExt->shown & C0C_SHOW_WMIREG) != 0) {
        status = IoWMIRegistrationControl(pDevExt->pDevObj, WMIREG_ACTION_DEREGISTER);
        pDevExt->shown &= ~C0C_SHOW_WMIREG;

        if (NT_SUCCESS(status)) {
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Hidden WMIREG");
        } else {
            res = FALSE;
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"HidePort IoWMIRegistrationControl FAIL");
        }
    }

    if (pDevExt->symbolicLinkName.Buffer && (pDevExt->shown & C0C_SHOW_INTERFACE) != 0) {
        status = IoSetDeviceInterfaceState(&pDevExt->symbolicLinkName, FALSE);
        pDevExt->shown &= ~C0C_SHOW_INTERFACE;

        if (NT_SUCCESS(status)) {
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Hidden INTERFACE");
        } else {
            res = FALSE;
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"HidePort IoSetDeviceInterfaceState FAIL");
        }
    }

    if (pDevExt->ntDeviceName.Buffer && (pDevExt->shown & C0C_SHOW_DEVICEMAP) != 0) {
        status = RtlDeleteRegistryValue(RTL_REGISTRY_DEVICEMAP, C0C_SERIAL_DEVICEMAP,
                                        pDevExt->ntDeviceName.Buffer);
        pDevExt->shown &= ~C0C_SHOW_DEVICEMAP;

        if (NT_SUCCESS(status)) {
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Hidden DEVICEMAP");
        } else {
            res = FALSE;
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"HidePort RtlDeleteRegistryValue " C0C_SERIAL_DEVICEMAP L" FAIL");
        }
    }

    if (pDevExt->win32DeviceName.Buffer && (pDevExt->shown & C0C_SHOW_SYMLINK) != 0) {
        status = IoDeleteSymbolicLink(&pDevExt->win32DeviceName);
        pDevExt->shown &= ~C0C_SHOW_SYMLINK;

        if (NT_SUCCESS(status)) {
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Hidden SYMLINK");
        } else {
            res = FALSE;
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"HidePort IoDeleteSymbolicLink FAIL");
        }
    }

    if ((pDevExt->shown & C0C_SHOW_PORTNAME) != 0)
        res = (HidePortName(pDevExt) && res);

    pDevExt->shown &= ~C0C_SHOW_SHOWN;

    Trace00((PC0C_COMMON_EXTENSION)pDevExt, L"HidePort - ", res ? L"OK" : L"FAIL");

    return res;
}
Пример #15
0
BOOLEAN ShowPort(IN PC0C_FDOPORT_EXTENSION pDevExt)
{
    BOOLEAN res;
    NTSTATUS status;

    if ((pDevExt->shown & C0C_SHOW_SHOWN) != 0)
        return TRUE;

    res = TRUE;

    if (!pDevExt->pIoPortLocal->isComClass &&
            (pDevExt->shown & C0C_SHOW_PORTNAME) == 0 &&
            (pDevExt->hide & C0C_SHOW_PORTNAME) == 0)
    {
        HANDLE hKey;

        status = IoOpenDeviceRegistryKey(pDevExt->pIoPortLocal->pPhDevObj,
                                         PLUGPLAY_REGKEY_DEVICE,
                                         STANDARD_RIGHTS_WRITE,
                                         &hKey);

        if (NT_SUCCESS(status)) {
            UNICODE_STRING keyName;

            RtlInitUnicodeString(&keyName, L"PortName");

            status = ZwSetValueKey(hKey,
                                   &keyName,
                                   0,
                                   REG_SZ,
                                   pDevExt->portName,
                                   (ULONG)((wcslen(pDevExt->portName) + 1) * sizeof(WCHAR)));

            if (NT_SUCCESS(status)) {
                pDevExt->shown |= C0C_SHOW_PORTNAME;
                Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Shown PORTNAME");
            } else {
                res = FALSE;
                Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"ShowPort ZwSetValueKey(PortName) FAIL");
            }

            ZwClose(hKey);
        } else {
            res = FALSE;
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"ShowPort IoOpenDeviceRegistryKey(PLUGPLAY_REGKEY_DEVICE) FAIL");
        }
    }

    if (pDevExt->ntDeviceName.Buffer) {
        if (pDevExt->win32DeviceName.Buffer &&
                (pDevExt->shown & C0C_SHOW_SYMLINK) == 0 &&
                (pDevExt->hide & C0C_SHOW_SYMLINK) == 0)
        {
            status = IoCreateSymbolicLink(&pDevExt->win32DeviceName, &pDevExt->ntDeviceName);

            if (NT_SUCCESS(status)) {
                pDevExt->shown |= C0C_SHOW_SYMLINK;
                Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Shown SYMLINK");
            } else {
                res = FALSE;
                Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"ShowPort IoCreateSymbolicLink FAIL");
            }
        }

        if ((pDevExt->shown & C0C_SHOW_SYMLINK) != 0 &&
                (pDevExt->shown & C0C_SHOW_DEVICEMAP) == 0 &&
                (pDevExt->hide & C0C_SHOW_DEVICEMAP) == 0)
        {
            status = RtlWriteRegistryValue(RTL_REGISTRY_DEVICEMAP, C0C_SERIAL_DEVICEMAP,
                                           pDevExt->ntDeviceName.Buffer, REG_SZ,
                                           pDevExt->portName,
                                           (ULONG)((wcslen(pDevExt->portName) + 1) * sizeof(WCHAR)));

            if (NT_SUCCESS(status)) {
                pDevExt->shown |= C0C_SHOW_DEVICEMAP;
                Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Shown DEVICEMAP");
            } else {
                res = FALSE;
                Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"ShowPort RtlWriteRegistryValue " C0C_SERIAL_DEVICEMAP L" FAIL");
            }
        }
    }

    if (pDevExt->symbolicLinkName.Buffer &&
            (pDevExt->shown & C0C_SHOW_INTERFACE) == 0 &&
            (pDevExt->hide & C0C_SHOW_INTERFACE) == 0)
    {
        status = IoSetDeviceInterfaceState(&pDevExt->symbolicLinkName, TRUE);

        if (NT_SUCCESS(status)) {
            pDevExt->shown |= C0C_SHOW_INTERFACE;
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Shown INTERFACE");
        } else {
            res = FALSE;
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"ShowPort IoSetDeviceInterfaceState FAIL");
        }
    }

    if ((pDevExt->shown & C0C_SHOW_WMIREG) == 0 && (pDevExt->hide & C0C_SHOW_WMIREG) == 0) {
        status = IoWMIRegistrationControl(pDevExt->pDevObj, WMIREG_ACTION_REGISTER);

        if (NT_SUCCESS(status)) {
            pDevExt->shown |= C0C_SHOW_WMIREG;
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Shown WMIREG");
        } else {
            res = FALSE;
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"ShowPort IoWMIRegistrationControl FAIL");
        }
    }

    pDevExt->shown |= C0C_SHOW_SHOWN;

    Trace00((PC0C_COMMON_EXTENSION)pDevExt, L"ShowPort - ", res ? L"OK" : L"FAIL");

    return res;
}
Пример #16
0
NTSTATUS
PciDrvWmiRegistration(
    __in PFDO_DATA               FdoData
)
/*++
Routine Description

    Registers with WMI as a data provider for this
    instance of the device

--*/
{
    NTSTATUS status;
    ULONG    guidCount = 0;


    PAGED_CODE();

    //
    // Register a guid to get standard device information.
    //
    PciDrvWmiGuidList[guidCount].Flags = 0;
    PciDrvWmiGuidList[guidCount].InstanceCount = 1;
    PciDrvWmiGuidList[guidCount].Guid = &PCIDRV_WMI_STD_DATA_GUID;
    guidCount++;

    //
    // If upper edge is not NDIS, we will be the power policy
    // owner for this device.
    //
    if(!FdoData->IsUpperEdgeNdis) {

        //
        // If you handle the following two GUIDs, the device manager will
        // show the power-management tab in the device properites dialog.
        //
        PciDrvWmiGuidList[guidCount].Flags = 0;
        PciDrvWmiGuidList[guidCount].InstanceCount = 1;
        PciDrvWmiGuidList[guidCount].Guid = &GUID_POWER_DEVICE_WAKE_ENABLE;
        guidCount++;

        PciDrvWmiGuidList[guidCount].Flags = 0;
        PciDrvWmiGuidList[guidCount].InstanceCount = 1;
        PciDrvWmiGuidList[guidCount].Guid = &GUID_POWER_DEVICE_ENABLE;
        guidCount++;
        //
        // Following two guids are used to get/set the conservation and
        // performance time during idle detection.
        //
        PciDrvWmiGuidList[guidCount].Flags = 0;
        PciDrvWmiGuidList[guidCount].InstanceCount = 1;
        PciDrvWmiGuidList[guidCount].Guid = &GUID_POWER_CONSERVATION_IDLE_TIME;
        guidCount++;

        PciDrvWmiGuidList[guidCount].Flags = 0;
        PciDrvWmiGuidList[guidCount].InstanceCount = 1;
        PciDrvWmiGuidList[guidCount].Guid = &GUID_POWER_PERFORMANCE_IDLE_TIME;
        guidCount++;

    }

#if defined(WIN2K) && defined(EVENT_TRACING)
    //
    // The GUID acts as the control GUID for enabling and disabling
    // the tracing.
    //
    PciDrvWmiGuidList[guidCount].Flags = 0;
    PciDrvWmiGuidList[guidCount].InstanceCount = 1;
    PciDrvWmiGuidList[guidCount].Guid = &WPP_TRACE_CONTROL_NULL_GUID;
    guidCount++;

#endif

    ASSERT(guidCount <= NUMBER_OF_WMI_GUIDS);

    FdoData->WmiLibInfo.GuidCount = guidCount;
    FdoData->WmiLibInfo.GuidList = PciDrvWmiGuidList;
    FdoData->WmiLibInfo.QueryWmiRegInfo = PciDrvQueryWmiRegInfo;
    FdoData->WmiLibInfo.QueryWmiDataBlock = PciDrvQueryWmiDataBlock;
    FdoData->WmiLibInfo.SetWmiDataBlock = PciDrvSetWmiDataBlock;
    FdoData->WmiLibInfo.SetWmiDataItem = NULL;
    FdoData->WmiLibInfo.ExecuteWmiMethod = NULL;
    FdoData->WmiLibInfo.WmiFunctionControl = NULL;

    //
    // Register with WMI
    //

    status = IoWMIRegistrationControl(FdoData->Self,
                             WMIREG_ACTION_REGISTER
                             );

    //
    // Initialize the Std device data structure
    //

    FdoData->StdDeviceData.DebugPrintLevel = DebugLevel;

    return status;

}