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.

64 lines
1.9 KiB

  1. #include "spsim.h"
  2. #include "spsimioct.h"
  3. NTSTATUS
  4. SpSimNotifyDeviceIoctl(
  5. PSPSIM_EXTENSION SpSim,
  6. PIRP Irp,
  7. PIO_STACK_LOCATION IrpStack
  8. )
  9. {
  10. PACPI_EVAL_INPUT_BUFFER_COMPLEX input;
  11. PSPSIM_NOTIFY_DEVICE notify;
  12. NTSTATUS status;
  13. ULONG size;
  14. PAGED_CODE();
  15. if (Irp->AssociatedIrp.SystemBuffer == NULL) {
  16. return STATUS_INVALID_PARAMETER;
  17. }
  18. if (IrpStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(SPSIM_NOTIFY_DEVICE)) {
  19. return STATUS_INVALID_PARAMETER;
  20. }
  21. if (SpSim->StaNames == NULL) {
  22. return STATUS_INVALID_PARAMETER;
  23. }
  24. notify = Irp->AssociatedIrp.SystemBuffer;
  25. if ((notify->Device >= SpSim->StaCount) || (notify->Device > 255)) {
  26. return STATUS_INVALID_PARAMETER;
  27. }
  28. size = sizeof(ACPI_EVAL_INPUT_BUFFER_COMPLEX) +
  29. sizeof(ACPI_METHOD_ARGUMENT) * (2 - ANYSIZE_ARRAY);
  30. input = ExAllocatePool(PagedPool, size);
  31. if (input == NULL) {
  32. return STATUS_INSUFFICIENT_RESOURCES;
  33. }
  34. RtlZeroMemory(input, size);
  35. input->Signature = ACPI_EVAL_INPUT_BUFFER_COMPLEX_SIGNATURE;
  36. input->MethodNameAsUlong = SPSIM_NOTIFY_DEVICE_METHOD;
  37. input->Size = size;
  38. input->ArgumentCount = 2;
  39. input->Argument[0].Type = input->Argument[1].Type =
  40. ACPI_METHOD_ARGUMENT_INTEGER;
  41. input->Argument[0].DataLength = input->Argument[1].DataLength =
  42. sizeof(ULONG);
  43. input->Argument[0].Argument = notify->Device;
  44. input->Argument[1].Argument = notify->NotifyValue;
  45. status = SpSimSendIoctl(SpSim->PhysicalDeviceObject,
  46. IOCTL_ACPI_EVAL_METHOD,
  47. input,
  48. size,
  49. NULL,
  50. 0
  51. );
  52. ExFreePool(input);
  53. return status;
  54. }