/*++ Routine Description: In this callback, the driver does whatever is necessary to make the hardware ready to use. In the case of a USB device, this involves reading and selecting descriptors. --*/ NTSTATUS PSDrv_EvtDevicePrepareHardware(IN WDFDEVICE Device, IN WDFCMRESLIST ResourceList, IN WDFCMRESLIST ResourceListTranslated) { NTSTATUS status; PDEVICE_CONTEXT pDeviceContext; WDF_USB_DEVICE_INFORMATION info; UNREFERENCED_PARAMETER(ResourceList); UNREFERENCED_PARAMETER(ResourceListTranslated); PSDrv_DbgPrint(3, ("PSDrv_EvtDevicePrepareHardware - begins\n")); PAGED_CODE(); pDeviceContext = GetDeviceContext(Device); // Read the device descriptor, configuration descriptor and select the interface descriptors status = ReadAndSelectDescriptors(Device); if (!NT_SUCCESS(status)) { PSDrv_DbgPrint(1, ("ReadAndSelectDescriptors failed! (Status = %x)\n", status)); return status; } WDF_USB_DEVICE_INFORMATION_INIT(&info); // Retrieve USBD version information, port driver capabilities and device capabilities such as speed, power, etc. status = WdfUsbTargetDeviceRetrieveInformation(pDeviceContext->WdfUsbTargetDevice, &info); if (NT_SUCCESS(status)) { pDeviceContext->IsDeviceHighSpeed = (info.Traits & WDF_USB_DEVICE_TRAIT_AT_HIGH_SPEED) ? TRUE : FALSE; PSDrv_DbgPrint(3, ("DeviceIsHighSpeed: %s\n", pDeviceContext->IsDeviceHighSpeed ? "TRUE" : "FALSE")); } else { pDeviceContext->IsDeviceHighSpeed = FALSE; } PSDrv_DbgPrint(3, ("IsDeviceSelfPowered: %s\n", (info.Traits & WDF_USB_DEVICE_TRAIT_SELF_POWERED) ? "TRUE" : "FALSE")); pDeviceContext->WaitWakeEnable = info.Traits & WDF_USB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE; PSDrv_DbgPrint(3, ("IsDeviceRemoteWakeable: %s\n", (info.Traits & WDF_USB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE) ? "TRUE" : "FALSE")); // Enable wait-wake and idle timeout if the device supports it if(pDeviceContext->WaitWakeEnable) { status = SetPowerPolicy(Device); if (!NT_SUCCESS (status)) { PSDrv_DbgPrint(3, ("SetPowerPolicy failed! (Status = %x)\n", status)); return status; } } PSDrv_DbgPrint(3, ("PSDrv_EvtDevicePrepareHardware - ends\n")); return status; }
static NTSTATUS UsbChief_EvtDevicePrepareHardware(IN WDFDEVICE Device, IN WDFCMRESLIST ResourceList, IN WDFCMRESLIST ResourceListTranslated) { PDEVICE_CONTEXT pDeviceContext; WDF_USB_DEVICE_INFORMATION info; NTSTATUS Status; UNREFERENCED_PARAMETER(Device); UNREFERENCED_PARAMETER(ResourceList); UNREFERENCED_PARAMETER(ResourceListTranslated); PAGED_CODE(); UsbChief_DbgPrint(DEBUG_CONFIG, ("EvtDevicePrepareHardware\n")); pDeviceContext = GetDeviceContext(Device); Status = UsbChief_ReadAndSelectDescriptors(Device); if (!NT_SUCCESS(Status)) { UsbChief_DbgPrint(0, ("ReadandSelectDescriptors failed\n")); return Status; } WDF_USB_DEVICE_INFORMATION_INIT(&info); Status = WdfUsbTargetDeviceRetrieveInformation(pDeviceContext->WdfUsbTargetDevice, &info); if (NT_SUCCESS(Status)) { pDeviceContext->IsDeviceHighSpeed = (info.Traits & WDF_USB_DEVICE_TRAIT_AT_HIGH_SPEED) ? TRUE : FALSE; UsbChief_DbgPrint(DEBUG_CONFIG, ("DeviceIsHighSpeed: %s\n", pDeviceContext->IsDeviceHighSpeed ? "TRUE" : "FALSE")); } else { pDeviceContext->IsDeviceHighSpeed = FALSE; } UsbChief_DbgPrint(DEBUG_CONFIG, ("IsDeviceSelfPowered: %s\n", (info.Traits & WDF_USB_DEVICE_TRAIT_SELF_POWERED) ? "TRUE" : "FALSE")); pDeviceContext->WaitWakeEnable = info.Traits & WDF_USB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE; UsbChief_DbgPrint(DEBUG_CONFIG, ("IsDeviceRemoteWakeable: %s\n", (info.Traits & WDF_USB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE) ? "TRUE" : "FALSE")); if(pDeviceContext->WaitWakeEnable){ Status = UsbChief_SetPowerPolicy(Device); if (!NT_SUCCESS (Status)) { UsbChief_DbgPrint(0, ("UsbChiefSetPowerPolicy failed\n")); return Status; } } return STATUS_SUCCESS; }
// 配置设备驱动的电源管理功能 NTSTATUS DrvClass::InitPowerManagement() { NTSTATUS status = STATUS_SUCCESS; WDF_USB_DEVICE_INFORMATION usbInfo; KDBG(DPFLTR_INFO_LEVEL, "[InitPowerManagement]"); // 获取设备信息 WDF_USB_DEVICE_INFORMATION_INIT(&usbInfo); WdfUsbTargetDeviceRetrieveInformation(m_hUsbDevice, &usbInfo); // USB设备信息以掩码形式被保存在Traits中。 KDBG( DPFLTR_INFO_LEVEL, "Device self powered: %s", usbInfo.Traits & WDF_USB_DEVICE_TRAIT_SELF_POWERED ? "TRUE" : "FALSE"); KDBG( DPFLTR_INFO_LEVEL, "Device remote wake capable: %s", usbInfo.Traits & WDF_USB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE ? "TRUE" : "FALSE"); KDBG( DPFLTR_INFO_LEVEL, "Device high speed: %s", usbInfo.Traits & WDF_USB_DEVICE_TRAIT_AT_HIGH_SPEED ? "TRUE" : "FALSE"); m_bIsDeviceHighSpeed = usbInfo.Traits & WDF_USB_DEVICE_TRAIT_AT_HIGH_SPEED; // 设置设备的休眠和远程唤醒功能 if(usbInfo.Traits & WDF_USB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE) { WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS idleSettings; WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS wakeSettings; // 设置设备为闲时休眠。闲时超过10S,自动进入休眠状态。 WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_INIT(&idleSettings, IdleUsbSelectiveSuspend); idleSettings.IdleTimeout = 10000; status = WdfDeviceAssignS0IdleSettings(m_hDevice, &idleSettings); if(!NT_SUCCESS(status)) { KDBG( DPFLTR_ERROR_LEVEL, "WdfDeviceAssignS0IdleSettings failed with status 0x%0.8x!!!", status); return status; } // 设置为可远程唤醒。包含设备自身醒来,已经当PC系统进入休眠后,设备可以将系统唤醒,两个方面。 WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS_INIT(&wakeSettings); status = WdfDeviceAssignSxWakeSettings(m_hDevice, &wakeSettings); if(!NT_SUCCESS(status)) { KDBG( DPFLTR_ERROR_LEVEL, "WdfDeviceAssignSxWakeSettings failed with status 0x%0.8x!!!", status); return status; } } return status; }
NTSTATUS OsrFxEvtDevicePrepareHardware( WDFDEVICE Device, WDFCMRESLIST ResourceList, WDFCMRESLIST ResourceListTranslated ) /*++ Routine Description: In this callback, the driver does whatever is necessary to make the hardware ready to use. In the case of a USB device, this involves reading and selecting descriptors. Arguments: Device - handle to a device ResourceList - handle to a resource-list object that identifies the raw hardware resources that the PnP manager assigned to the device ResourceListTranslated - handle to a resource-list object that identifies the translated hardware resources that the PnP manager assigned to the device Return Value: NT status value --*/ { NTSTATUS status; PDEVICE_CONTEXT pDeviceContext; WDF_USB_DEVICE_INFORMATION deviceInfo; ULONG waitWakeEnable; UNREFERENCED_PARAMETER(ResourceList); UNREFERENCED_PARAMETER(ResourceListTranslated); waitWakeEnable = FALSE; PAGED_CODE(); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "--> EvtDevicePrepareHardware\n"); pDeviceContext = GetDeviceContext(Device); // // Create a USB device handle so that we can communicate with the // underlying USB stack. The WDFUSBDEVICE handle is used to query, // configure, and manage all aspects of the USB device. // These aspects include device properties, bus properties, // and I/O creation and synchronization. We only create device the first // the PrepareHardware is called. If the device is restarted by pnp manager // for resource rebalance, we will use the same device handle but then select // the interfaces again because the USB stack could reconfigure the device on // restart. // if (pDeviceContext->UsbDevice == NULL) { status = WdfUsbTargetDeviceCreate(Device, WDF_NO_OBJECT_ATTRIBUTES, &pDeviceContext->UsbDevice); if (!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, "WdfUsbTargetDeviceCreate failed with Status code %!STATUS!\n", status); return status; } } // // Retrieve USBD version information, port driver capabilites and device // capabilites such as speed, power, etc. // WDF_USB_DEVICE_INFORMATION_INIT(&deviceInfo); status = WdfUsbTargetDeviceRetrieveInformation( pDeviceContext->UsbDevice, &deviceInfo); if (NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "IsDeviceHighSpeed: %s\n", (deviceInfo.Traits & WDF_USB_DEVICE_TRAIT_AT_HIGH_SPEED) ? "TRUE" : "FALSE"); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "IsDeviceSelfPowered: %s\n", (deviceInfo.Traits & WDF_USB_DEVICE_TRAIT_SELF_POWERED) ? "TRUE" : "FALSE"); waitWakeEnable = deviceInfo.Traits & WDF_USB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE; TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "IsDeviceRemoteWakeable: %s\n", waitWakeEnable ? "TRUE" : "FALSE"); // // Save these for use later. // pDeviceContext->UsbDeviceTraits = deviceInfo.Traits; } else { pDeviceContext->UsbDeviceTraits = 0; } status = SelectInterfaces(Device); if (!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, "SelectInterfaces failed 0x%x\n", status); return status; } // // Enable wait-wake and idle timeout if the device supports it // if (waitWakeEnable) { status = OsrFxSetPowerPolicy(Device); if (!NT_SUCCESS (status)) { TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, "OsrFxSetPowerPolicy failed %!STATUS!\n", status); return status; } } status = OsrFxConfigContReaderForInterruptEndPoint(pDeviceContext); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "<-- EvtDevicePrepareHardware\n"); return status; }
NTSTATUS OsrFxEvtDevicePrepareHardware( IN WDFDEVICE Device, IN WDFCMRESLIST ResourceList, IN WDFCMRESLIST ResourceListTranslated ) /*++ Routine Description: In this callback, the driver does whatever is necessary to make the hardware ready to use. In the case of a USB device, this involves reading descriptors and selecting interfaces. Arguments: Device - handle to a device Return Value: NT status value --*/ { NTSTATUS status, tempStatus; PDEVICE_CONTEXT pDeviceContext; WDF_USB_DEVICE_SELECT_CONFIG_PARAMS configParams; UNREFERENCED_PARAMETER(ResourceList); UNREFERENCED_PARAMETER(ResourceListTranslated); PAGED_CODE(); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "--> EvtDevicePrepareHardware\n"); pDeviceContext = GetDeviceContext(Device); // // Create a USB device handle so that we can communicate with the // underlying USB stack. The WDFUSBDEVICE handle is used to query, // configure, and manage all aspects of the USB device. // These aspects include device properties, bus properties, // and I/O creation and synchronization. We only create device the first // the PrepareHardware is called. If the device is restarted by pnp manager // for resource rebalance, we will use the same device handle but then select // the interfaces again because the USB stack could reconfigure the device on // restart. // if (pDeviceContext->UsbDevice == NULL) { status = WdfUsbTargetDeviceCreate(Device, WDF_NO_OBJECT_ATTRIBUTES, &pDeviceContext->UsbDevice); if (!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, "WdfUsbTargetDeviceCreate failed with Status code %!STATUS!\n", status); return status; } } WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_SINGLE_INTERFACE( &configParams); status = WdfUsbTargetDeviceSelectConfig(pDeviceContext->UsbDevice, WDF_NO_OBJECT_ATTRIBUTES, &configParams); if(!NT_SUCCESS(status)) { WDF_USB_DEVICE_INFORMATION deviceInfo; TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, "WdfUsbTargetDeviceSelectConfig failed %!STATUS! \n", status); // // detect if we are connected to a 1.1 USB port // WDF_USB_DEVICE_INFORMATION_INIT(&deviceInfo); tempStatus = WdfUsbTargetDeviceRetrieveInformation(pDeviceContext->UsbDevice, &deviceInfo); if (NT_SUCCESS(tempStatus)) { // // Since the Osr USB fx2 device is capable of working at high speed, the only reason // the device would not be working at high speed is if the port doesn't // support it. If the port doesn't support high speed it is a 1.1 port // if ((deviceInfo.Traits & WDF_USB_DEVICE_TRAIT_AT_HIGH_SPEED) == 0) { TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, " On a 1.1 USB port on Windows Vista" " this is expected as the OSR USB Fx2 board's Interrupt EndPoint descriptor" " doesn't conform to the USB specification. Windows Vista detects this and" " returns an error. \n" ); } } return status; } pDeviceContext->UsbInterface = configParams.Types.SingleInterface.ConfiguredUsbInterface; status = OsrFxConfigContReaderForInterruptEndPoint(pDeviceContext); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "<-- EvtDevicePrepareHardware\n"); return status; }
NTSTATUS InitPowerManagement( IN WDFDEVICE Device, IN PDEVICE_CONTEXT Context) { NTSTATUS status = STATUS_SUCCESS; WDF_USB_DEVICE_INFORMATION usbInfo; KdPrint((__DRIVER_NAME "Device init power management\n")); // Lay thong tin cua thiet bi USB WDF_USB_DEVICE_INFORMATION_INIT(&usbInfo); // init object status = WdfUsbTargetDeviceRetrieveInformation( Context->UsbDevice, &usbInfo); if(!NT_SUCCESS(status)) { KdPrint((__DRIVER_NAME "WdfUsbTargetDeviceRetrieveInformation failed with status 0x%08x\n", status)); return status; } // Xem cac thong tin debug, thiet bi co ho tro self powered, wakeup hay high speed khong? KdPrint((__DRIVER_NAME "Device self powered: %d\n", usbInfo.Traits & WDF_USB_DEVICE_TRAIT_SELF_POWERED ? 1 : 0)); KdPrint((__DRIVER_NAME "Device remote wake capable: %d\n", usbInfo.Traits & WDF_USB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE ? 1 : 0)); KdPrint((__DRIVER_NAME "Device high speed: %d\n", usbInfo.Traits & WDF_USB_DEVICE_TRAIT_AT_HIGH_SPEED ? 1 : 0)); if(usbInfo.Traits & WDF_USB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE) { WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS idleSettings; WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS wakeSettings; WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_INIT(&idleSettings, IdleUsbSelectiveSuspend); idleSettings.IdleTimeout = 10000; status = WdfDeviceAssignS0IdleSettings(Device, &idleSettings); if(!NT_SUCCESS(status)) { KdPrint((__DRIVER_NAME "WdfDeviceAssignS0IdleSettings failed with status 0x%08x\n", status)); return status; } WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS_INIT(&wakeSettings); wakeSettings.DxState = PowerDeviceD2; status = WdfDeviceAssignSxWakeSettings(Device, &wakeSettings); if(!NT_SUCCESS(status)) { KdPrint((__DRIVER_NAME "WdfDeviceAssignSxWakeSettings failed with status 0x%08x\n", status)); return status; } } return status; }
NTSTATUS AndroidUsbDeviceObject::OnEvtDevicePrepareHardware( WDFCMRESLIST resources_raw, WDFCMRESLIST resources_translated) { ASSERT_IRQL_PASSIVE(); // Create a USB device handle so that we can communicate with the underlying // USB stack. The wdf_target_device_ handle is used to query, configure, and // manage all aspects of the USB device. These aspects include device // properties, bus properties, and I/O creation and synchronization. This // call gets the device and configuration descriptors and stores them in // wdf_target_device_ object. NTSTATUS status = WdfUsbTargetDeviceCreate(wdf_device(), WDF_NO_OBJECT_ATTRIBUTES, &wdf_target_device_); ASSERT(NT_SUCCESS(status) && (NULL != wdf_target_device_)); if (!NT_SUCCESS(status)) return status; // Retrieve USBD version information, port driver capabilites and device // capabilites such as speed, power, etc. WDF_USB_DEVICE_INFORMATION_INIT(&usb_device_info_); status = WdfUsbTargetDeviceRetrieveInformation(wdf_target_device(), &usb_device_info_); ASSERT(NT_SUCCESS(status)); if (!NT_SUCCESS(status)) return status; WdfUsbTargetDeviceGetDeviceDescriptor(wdf_target_device(), &usb_device_descriptor_); #if DBG PrintUsbTargedDeviceInformation(usb_device_info()); PrintUsbDeviceDescriptor(&usb_device_descriptor_); #endif // DBG // Save device serial number status = WdfUsbTargetDeviceAllocAndQueryString(wdf_target_device(), WDF_NO_OBJECT_ATTRIBUTES, &serial_number_handle_, &serial_number_char_len_, usb_device_descriptor_.iSerialNumber, 0x0409); // English (US) if (!NT_SUCCESS(status)) return status; #if DBG UNICODE_STRING ser_num; ser_num.Length = serial_number_byte_len(); ser_num.MaximumLength = ser_num.Length; ser_num.Buffer = const_cast<WCHAR*> (serial_number()); GoogleDbgPrint("\n*** Device serial number %wZ", &ser_num); #endif // DBG // Configure our device now status = ConfigureDevice(); ASSERT(NT_SUCCESS(status)); if (!NT_SUCCESS(status)) return status; // Select device interfaces status = SelectInterfaces(); if (!NT_SUCCESS(status)) return status; return status; }
NTSTATUS CyEvtDevicePrepareHardware ( IN WDFDEVICE Device, IN WDFCMRESLIST ResourcesRaw, IN WDFCMRESLIST ResourcesTranslated ) { NTSTATUS NTStatus; PDEVICE_CONTEXT pDeviceContext; WDF_USB_DEVICE_INFORMATION UsbDeviceInfo; ULONG ulWaitWakeEnable; UNICODE_STRING unicodeSCRIPTFILE; WDF_OBJECT_ATTRIBUTES attributes; WDFMEMORY hScriptFileNameBufMem; PVOID pScriptFNBuf=NULL; ULONG ScripFileNtBufferlen=0; UNREFERENCED_PARAMETER(ResourcesRaw); UNREFERENCED_PARAMETER(ResourcesTranslated); ulWaitWakeEnable = FALSE; PAGED_CODE(); CyTraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "Start CyEvtDevicePrepareHardware\n"); pDeviceContext = CyGetDeviceContext(Device); // // Create a USB device handle so that we can communicate with the // underlying USB stack. The WDFUSBDEVICE handle is used to query, // configure, and manage all aspects of the USB device. // These aspects include device properties, bus properties, // and I/O creation and synchronization. We only create device the first // the PrepareHardware is called. If the device is restarted by pnp manager // for resource rebalance, we will use the same device handle but then select // the interfaces again because the USB stack could reconfigure the device on // restart. // if (pDeviceContext->CyUsbDevice == NULL) { NTStatus = WdfUsbTargetDeviceCreate(Device, WDF_NO_OBJECT_ATTRIBUTES, &pDeviceContext->CyUsbDevice); if (!NT_SUCCESS(NTStatus)) { CyTraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, "WdfUsbTargetDeviceCreate failed with Status code %!STATUS!\n", NTStatus); return NTStatus; } } // // Retrieve USBD version information, port driver capabilites and device // capabilites such as speed, power, etc. // WDF_USB_DEVICE_INFORMATION_INIT(&UsbDeviceInfo); NTStatus = WdfUsbTargetDeviceRetrieveInformation( pDeviceContext->CyUsbDevice, &UsbDeviceInfo); if (NT_SUCCESS(NTStatus)) { CyTraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "IsDeviceHighSpeed: %s\n", (UsbDeviceInfo.Traits & WDF_USB_DEVICE_TRAIT_AT_HIGH_SPEED) ? "TRUE" : "FALSE"); CyTraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "IsDeviceSelfPowered: %s\n", (UsbDeviceInfo.Traits & WDF_USB_DEVICE_TRAIT_SELF_POWERED) ? "TRUE" : "FALSE"); ulWaitWakeEnable = UsbDeviceInfo.Traits & WDF_USB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE; CyTraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "IsDeviceRemoteWakeable: %s\n", ulWaitWakeEnable ? "TRUE" : "FALSE"); pDeviceContext->ulUSBDeviceTrait = UsbDeviceInfo.Traits; pDeviceContext->ulUSBDIVersion = UsbDeviceInfo.UsbdVersionInformation.USBDI_Version; pDeviceContext->ulWaitWakeEnable = ulWaitWakeEnable; } //Get device descriptor WdfUsbTargetDeviceGetDeviceDescriptor( pDeviceContext->CyUsbDevice, &pDeviceContext->UsbDeviceDescriptor ); NTStatus = CySelectInterfaces(Device); if (!NT_SUCCESS(NTStatus)) { CyTraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, "SelectInterfaces failed 0x%x\n", NTStatus); return NTStatus; } if (ulWaitWakeEnable) { NTStatus = CySetPowerPolicy(Device); if (!NT_SUCCESS (NTStatus)) { CyTraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, "Set power policy failed %!STATUS!\n", NTStatus); return NTStatus; } } // Check for the script file in the registry and execute if it is exist // Allocate buffer to get the registry key WDF_OBJECT_ATTRIBUTES_INIT(&attributes); NTStatus = WdfMemoryCreate( &attributes, NonPagedPool, 0, CYREGSCRIPT_BUFFER_SIZE, &hScriptFileNameBufMem, &pScriptFNBuf ); if (!NT_SUCCESS(NTStatus)) { CyTraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, "WdfMemoryCreate failed %!STATUS!\n",NTStatus); return FALSE; } if(GetRegistryKey(Device, NULL, REG_SZ, CYREG_SCRIPTFILE, pScriptFNBuf,&ScripFileNtBufferlen)) { CyExecuteScriptFile(Device, pScriptFNBuf); } CyTraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "End CyEvtDevicePrepareHardware\n"); //// CyTraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "End CyEvtDevicePrepareHardware\n"); return NTStatus; }