Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.7 KiB

  1. #include "pch.h"
  2. #ifdef ALLOC_PRAGMA
  3. #pragma alloc_text(PAGE, HidIrPower)
  4. #endif
  5. /*
  6. ************************************************************
  7. * HidIrPower
  8. ************************************************************
  9. *
  10. * Process Power IRPs sent to this device.
  11. * Don't have to call PoStartNextPowerIrp, since hidclass does it for us.
  12. *
  13. */
  14. NTSTATUS HidIrPower(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
  15. {
  16. NTSTATUS status;
  17. PIO_STACK_LOCATION irpSp;
  18. PHIDIR_EXTENSION deviceExtension;
  19. HidIrKdPrint((3, "HidIrPower Entry"));
  20. deviceExtension = GET_MINIDRIVER_HIDIR_EXTENSION( DeviceObject );
  21. irpSp = IoGetCurrentIrpStackLocation(Irp);
  22. switch (irpSp->MinorFunction) {
  23. case IRP_MN_SET_POWER:
  24. if (irpSp->Parameters.Power.Type == DevicePowerState) {
  25. if (deviceExtension->DevicePowerState != PowerDeviceD0 &&
  26. irpSp->Parameters.Power.State.DeviceState == PowerDeviceD0) {
  27. // We are returning from a low power state.
  28. // Set a timer that will cause hidir to ignore any standby buttons until it triggers
  29. LARGE_INTEGER timeout;
  30. timeout.HighPart = -1;
  31. timeout.LowPart = -50000000; // 5 seconds should be plenty
  32. KeSetTimer(&deviceExtension->IgnoreStandbyTimer, timeout, NULL);
  33. }
  34. deviceExtension->DevicePowerState = irpSp->Parameters.Power.State.DeviceState;
  35. }
  36. }
  37. IoSkipCurrentIrpStackLocation(Irp);
  38. status = PoCallDriver(GET_NEXT_DEVICE_OBJECT(DeviceObject), Irp);
  39. HidIrKdPrint((3, "HidIrPower Exit: %x", status));
  40. return status;
  41. }