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.

126 lines
3.5 KiB

  1. /*************************************************************************
  2. *
  3. * mouse.c
  4. *
  5. * This module contains routines for managing the ICA mouse channel.
  6. *
  7. * Copyright 1998, Microsoft.
  8. *
  9. *
  10. *************************************************************************/
  11. /*
  12. * Includes
  13. */
  14. #include <precomp.h>
  15. #pragma hdrstop
  16. #include <ntddmou.h>
  17. NTSTATUS
  18. IcaDeviceControlMouse(
  19. IN PICA_CHANNEL pChannel,
  20. IN PIRP Irp,
  21. IN PIO_STACK_LOCATION IrpSp
  22. )
  23. /*++
  24. Routine Description:
  25. This is the DeviceControl routine for the ICA mouse channel.
  26. Arguments:
  27. pChannel -- pointer to ICA_CHANNEL object
  28. Irp - Pointer to I/O request packet
  29. IrpSp - pointer to the stack location to use for this request.
  30. Return Value:
  31. NTSTATUS -- Indicates whether the request was successfully queued.
  32. --*/
  33. {
  34. ULONG code;
  35. SD_IOCTL SdIoctl;
  36. PICA_STACK pStack;
  37. NTSTATUS Status;
  38. CLONG Method;
  39. /*
  40. * Extract the IOCTL control code and process the request.
  41. */
  42. code = IrpSp->Parameters.DeviceIoControl.IoControlCode;
  43. switch ( code ) {
  44. #if 0 // no longer used
  45. /*
  46. * Special IOCTL to allow mouse input data to be fed
  47. * into the mouse channel.
  48. */
  49. case IOCTL_MOUSE_ICA_INPUT :
  50. /*
  51. * Make sure the input data is the correct size.
  52. */
  53. if ( IrpSp->Parameters.DeviceIoControl.InputBufferLength %
  54. sizeof(MOUSE_INPUT_DATA) )
  55. return( STATUS_BUFFER_TOO_SMALL );
  56. /*
  57. * We need a stack object to pass to IcaChannelInputInternal.
  58. * Any one will do so we grab the head of the stack list.
  59. * (There MUST be one for this IOCTL to succeed.)
  60. */
  61. IcaLockConnection( pChannel->pConnect );
  62. if ( IsListEmpty( &pChannel->pConnect->StackHead ) ) {
  63. IcaUnlockConnection( pChannel->pConnect );
  64. return( STATUS_INVALID_DEVICE_REQUEST );
  65. }
  66. pStack = CONTAINING_RECORD( pChannel->pConnect->StackHead.Flink,
  67. ICA_STACK, StackEntry );
  68. IcaReferenceStack( pStack );
  69. IcaUnlockConnection( pChannel->pConnect );
  70. /*
  71. * Send mouse input
  72. */
  73. IcaChannelInputInternal( pStack, Channel_Mouse, 0, NULL,
  74. (PCHAR)IrpSp->Parameters.DeviceIoControl.Type3InputBuffer,
  75. IrpSp->Parameters.DeviceIoControl.InputBufferLength );
  76. IcaDereferenceStack( pStack );
  77. Status = STATUS_SUCCESS;
  78. break;
  79. #endif
  80. default:
  81. // Verify the buffer method.
  82. Method = code & 0x03;
  83. ASSERT( Method == METHOD_BUFFERED );
  84. if ( Method != METHOD_BUFFERED ) {
  85. Status = STATUS_INVALID_DEVICE_REQUEST;
  86. }
  87. else {
  88. SdIoctl.IoControlCode = code;
  89. SdIoctl.InputBuffer = Irp->AssociatedIrp.SystemBuffer;
  90. SdIoctl.InputBufferLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
  91. SdIoctl.OutputBuffer = Irp->UserBuffer;
  92. SdIoctl.OutputBufferLength = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
  93. Status = IcaCallDriver( pChannel, SD$IOCTL, &SdIoctl );
  94. }
  95. break;
  96. }
  97. return( Status );
  98. }