📄 deviceio.cpp
字号:
#include "WdmUsb.h"
#pragma code_seg("PAGE")
NTSTATUS StartDevice(IN PWDMUSB_DEVICE_EXTENSION dx,
IN PCM_RESOURCE_LIST AllocatedResourcesTranslated)
{
NTSTATUS status;
KdPrint(("StartDevice"));
if(dx->GotResources)
return STATUS_SUCCESS;
//--------------------------USB---------------------------------
UsbResetDevice(dx);
PUSB_DEVICE_DESCRIPTOR DeviceDescriptor;
ULONG size;
status=UsbGetDeviceDescriptor(dx,DeviceDescriptor,size);
if(NT_SUCCESS(status))
{
if(dx->DeviceDescriptor)ExFreePool(dx->DeviceDescriptor);
dx->DeviceDescriptor=DeviceDescriptor;
KdPrint(("DeviceDescriptor size:%x",size));
}
status=UsbSelectConfiguration(dx);
if(!NT_SUCCESS(status))
{
ExFreePool(dx->DeviceDescriptor);
KdPrint(("StartDevice UsbSelectConfiguration fail"));
dx->GotResources=false;
}
else
{
dx->GotResources=true;
UsbBuildPipeList(dx);
KdPrint(("StartDevice UsbSelectConfiguration success"));
}
//--------------------------------------------------------------
return STATUS_SUCCESS;
}
VOID StopDevice(IN PWDMUSB_DEVICE_EXTENSION dx)
{
KdPrint(("StopDevice"));
if(!dx->GotResources)
return;
// UsbCancelAllPendingIrp(dx);
UsbDeselectConfiguration(dx);
dx->GotResources=false;
}
void SetPowerState(IN PWDMUSB_DEVICE_EXTENSION dx,
IN DEVICE_POWER_STATE NewDevicePowerState)
{
KdPrint(("SetPowerState %d", NewDevicePowerState));
dx->PowerState=NewDevicePowerState;
POWER_STATE NewState;
NewState.DeviceState=NewDevicePowerState;
if(KeGetCurrentIrql()==DISPATCH_LEVEL&&NewDevicePowerState!=PowerDeviceD0)
{
KdPrint(("SetPowerState IRQL %d fail", KeGetCurrentIrql()));
}
else
PoSetPowerState(dx->fdo,DevicePowerState,NewState);
}
#pragma code_seg()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -