Source code of Windows XP (NT5)
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.

190 lines
4.9 KiB

  1. /*++ BUILD Version: 0002 // Increment this if a change has global effects
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. lpc.h
  5. Abstract:
  6. This module contains the public data structures and procedure
  7. prototypes for the Local Inter-Process Communication (LPC)
  8. sub-component of NTOS.
  9. Author:
  10. Steve Wood (stevewo) 15-May-1989
  11. Revision History:
  12. --*/
  13. #ifndef _LPC_
  14. #define _LPC_
  15. //
  16. // System Initialization procedure for Lpc subcomponent of NTOS
  17. //
  18. BOOLEAN
  19. LpcInitSystem( VOID );
  20. VOID
  21. LpcExitThread(
  22. PETHREAD Thread
  23. );
  24. VOID
  25. LpcDumpThread(
  26. PETHREAD Thread,
  27. IN POB_DUMP_CONTROL Control OPTIONAL
  28. );
  29. // begin_ntosp
  30. NTKERNELAPI
  31. NTSTATUS
  32. LpcRequestPort(
  33. IN PVOID PortAddress,
  34. IN PPORT_MESSAGE RequestMessage
  35. );
  36. NTSTATUS
  37. LpcRequestWaitReplyPort(
  38. IN PVOID PortAddress,
  39. IN PPORT_MESSAGE RequestMessage,
  40. OUT PPORT_MESSAGE ReplyMessage
  41. );
  42. NTSTATUS
  43. LpcRequestWaitReplyPortEx (
  44. IN PVOID PortAddress,
  45. IN PPORT_MESSAGE RequestMessage,
  46. OUT PPORT_MESSAGE ReplyMessage
  47. );
  48. NTSTATUS
  49. LpcDisconnectPort (
  50. IN PVOID Port
  51. );
  52. // end_ntosp
  53. //
  54. // The following are global counters used by the LPC component to indicate
  55. // the amount of LPC calls being performed in the system.
  56. //
  57. extern ULONG LpcCallOperationCount;
  58. extern ULONG LpcCallBackOperationCount;
  59. extern ULONG LpcDatagramOperationCount;
  60. //
  61. // Nonpagable portion of a port queue
  62. //
  63. typedef struct _LPCP_NONPAGED_PORT_QUEUE {
  64. KSEMAPHORE Semaphore; // Counting semaphore that is incremented
  65. // whenever a message is put in receive queue
  66. struct _LPCP_PORT_OBJECT *BackPointer;
  67. } LPCP_NONPAGED_PORT_QUEUE, *PLPCP_NONPAGED_PORT_QUEUE;
  68. typedef struct _LPCP_PORT_QUEUE {
  69. PLPCP_NONPAGED_PORT_QUEUE NonPagedPortQueue;
  70. PKSEMAPHORE Semaphore; // Counting semaphore that is incremented
  71. // whenever a message is put in receive queue
  72. LIST_ENTRY ReceiveHead; // list of messages to receive
  73. } LPCP_PORT_QUEUE, *PLPCP_PORT_QUEUE;
  74. #define LPCP_ZONE_ALIGNMENT 16
  75. #define LPCP_ZONE_ALIGNMENT_MASK ~(LPCP_ZONE_ALIGNMENT-1)
  76. //
  77. // This allows ~96 outstanding messages
  78. //
  79. #define LPCP_ZONE_MAX_POOL_USAGE (8*PAGE_SIZE)
  80. typedef struct _LPCP_PORT_ZONE {
  81. KEVENT FreeEvent; // Autoclearing event that is whenever the
  82. // zone free list goes from empty to non-empty
  83. ULONG MaxPoolUsage;
  84. ULONG GrowSize;
  85. ZONE_HEADER Zone;
  86. } LPCP_PORT_ZONE, *PLPCP_PORT_ZONE;
  87. //
  88. // Data Types and Constants
  89. //
  90. typedef struct _LPCP_PORT_OBJECT {
  91. struct _LPCP_PORT_OBJECT *ConnectionPort;
  92. struct _LPCP_PORT_OBJECT *ConnectedPort;
  93. LPCP_PORT_QUEUE MsgQueue;
  94. CLIENT_ID Creator;
  95. PVOID ClientSectionBase;
  96. PVOID ServerSectionBase;
  97. PVOID PortContext;
  98. PETHREAD ClientThread; // only SERVER_COMMUNICATION_PORT
  99. SECURITY_QUALITY_OF_SERVICE SecurityQos;
  100. SECURITY_CLIENT_CONTEXT StaticSecurity;
  101. LIST_ENTRY LpcReplyChainHead; // Only in _COMMUNICATION ports
  102. LIST_ENTRY LpcDataInfoChainHead; // Only in _COMMUNICATION ports
  103. union {
  104. PEPROCESS ServerProcess; // Only in SERVER_CONNECTION ports
  105. PEPROCESS MappingProcess; // Only in _COMMUNICATION ports
  106. };
  107. USHORT MaxMessageLength;
  108. USHORT MaxConnectionInfoLength;
  109. ULONG Flags;
  110. KEVENT WaitEvent; // Object is truncated for non-waitable ports
  111. } LPCP_PORT_OBJECT, *PLPCP_PORT_OBJECT;
  112. //
  113. // Valid values for Flags field
  114. //
  115. #define PORT_TYPE 0x0000000F
  116. #define SERVER_CONNECTION_PORT 0x00000001
  117. #define UNCONNECTED_COMMUNICATION_PORT 0x00000002
  118. #define SERVER_COMMUNICATION_PORT 0x00000003
  119. #define CLIENT_COMMUNICATION_PORT 0x00000004
  120. #define PORT_WAITABLE 0x20000000
  121. #define PORT_NAME_DELETED 0x40000000
  122. #define PORT_DYNAMIC_SECURITY 0x80000000
  123. typedef struct _LPCP_MESSAGE {
  124. union {
  125. LIST_ENTRY Entry;
  126. struct {
  127. SINGLE_LIST_ENTRY FreeEntry;
  128. ULONG Reserved0;
  129. };
  130. };
  131. PVOID SenderPort;
  132. PETHREAD RepliedToThread; // Filled in when reply is sent so recipient
  133. // of reply can dereference it.
  134. PVOID PortContext; // Captured from senders communication port.
  135. PORT_MESSAGE Request;
  136. } LPCP_MESSAGE, *PLPCP_MESSAGE;
  137. #if DEVL
  138. //
  139. // This bit set in the ZoneIndex field to mark allocated messages.
  140. //
  141. #define LPCP_ZONE_MESSAGE_ALLOCATED (USHORT)0x8000
  142. #endif
  143. //
  144. // This data is placed at the beginning of the Request data for an
  145. // LPC_CONNECTION_REQUEST message.
  146. //
  147. typedef struct _LPCP_CONNECTION_MESSAGE {
  148. PORT_VIEW ClientView;
  149. PLPCP_PORT_OBJECT ClientPort;
  150. PVOID SectionToMap;
  151. REMOTE_PORT_VIEW ServerView;
  152. } LPCP_CONNECTION_MESSAGE, *PLPCP_CONNECTION_MESSAGE;
  153. #endif // _LPC_