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.

147 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. lpcquery.c
  5. Abstract:
  6. Local Inter-Process Communication (LPC) query services
  7. Author:
  8. Steve Wood (stevewo) 15-May-1989
  9. Revision History:
  10. --*/
  11. #include "lpcp.h"
  12. #ifdef ALLOC_PRAGMA
  13. #pragma alloc_text(PAGE,NtQueryInformationPort)
  14. #endif
  15. NTSTATUS
  16. NTAPI
  17. NtQueryInformationPort (
  18. IN HANDLE PortHandle OPTIONAL,
  19. IN PORT_INFORMATION_CLASS PortInformationClass,
  20. OUT PVOID PortInformation,
  21. IN ULONG Length,
  22. OUT PULONG ReturnLength OPTIONAL
  23. )
  24. /*++
  25. Routine Description:
  26. This routine should be used to query an lpc port, but is pretty much a
  27. noop. Currently it can only indicate if the input handle is for a port
  28. object.
  29. Arguments:
  30. PortHandle - Supplies the handle for the port being queried
  31. PortInformationClass - Specifies the type information class being asked
  32. for. Currently ignored.
  33. PortInformation - Supplies a pointer to the buffer to receive the
  34. information. Currently just probed and then ignored.
  35. Length - Specifies, in bytes, the size of the port information buffer.
  36. ReturnLength - Optionally receives the size, in bytes, of the information
  37. being returned. Currently just probed and then ignored.
  38. Return Value:
  39. NTSTATUS - An appropriate status value.
  40. --*/
  41. {
  42. KPROCESSOR_MODE PreviousMode;
  43. NTSTATUS Status;
  44. PLPCP_PORT_OBJECT PortObject;
  45. PAGED_CODE();
  46. UNREFERENCED_PARAMETER ( PortInformationClass );
  47. //
  48. // Get previous processor mode and probe output argument if necessary.
  49. //
  50. PreviousMode = KeGetPreviousMode();
  51. if (PreviousMode != KernelMode) {
  52. try {
  53. ProbeForWrite( PortInformation,
  54. Length,
  55. sizeof( ULONG ));
  56. if (ARGUMENT_PRESENT( ReturnLength )) {
  57. ProbeForWriteUlong( ReturnLength );
  58. }
  59. } except( EXCEPTION_EXECUTE_HANDLER ) {
  60. return( GetExceptionCode() );
  61. }
  62. }
  63. //
  64. // If the user gave us a handle then reference the object. And return
  65. // success if we got a good reference and an error otherwise.
  66. //
  67. if (ARGUMENT_PRESENT( PortHandle )) {
  68. Status = ObReferenceObjectByHandle( PortHandle,
  69. GENERIC_READ,
  70. LpcPortObjectType,
  71. PreviousMode,
  72. &PortObject,
  73. NULL );
  74. if (!NT_SUCCESS( Status )) {
  75. //
  76. // It might be a waitable port object.
  77. // Let's try again as this object type
  78. //
  79. Status = ObReferenceObjectByHandle( PortHandle,
  80. GENERIC_READ,
  81. LpcWaitablePortObjectType,
  82. PreviousMode,
  83. &PortObject,
  84. NULL );
  85. //
  86. // If this one fails too we'll return that status
  87. //
  88. if (!NT_SUCCESS( Status )) {
  89. return( Status );
  90. }
  91. }
  92. ObDereferenceObject( PortObject );
  93. return STATUS_SUCCESS;
  94. } else {
  95. return STATUS_INVALID_INFO_CLASS;
  96. }
  97. }