Windows NT 4.0 source code leak
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.

154 lines
3.7 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. lpcinit.c
  5. Abstract:
  6. Initialization module for the LPC subcomponent of NTOS
  7. Author:
  8. Steve Wood (stevewo) 15-May-1989
  9. Revision History:
  10. --*/
  11. #include "lpcp.h"
  12. POBJECT_TYPE LpcPortObjectType;
  13. GENERIC_MAPPING LpcpPortMapping = {
  14. READ_CONTROL | PORT_CONNECT,
  15. DELETE | PORT_CONNECT,
  16. 0,
  17. PORT_ALL_ACCESS
  18. };
  19. FAST_MUTEX LpcpLock;
  20. BOOLEAN LpcpRequestMsgType[] = {
  21. FALSE,
  22. TRUE, // LPC_REQUEST
  23. FALSE, // LPC_REPLY
  24. FALSE, // LPC_DATAGRAM
  25. FALSE, // LPC_LOST_REPLY
  26. FALSE, // LPC_PORT_CLOSED
  27. FALSE, // LPC_CLIENT_DIED
  28. TRUE, // LPC_EXCEPTION
  29. TRUE, // LPC_DEBUG_EVENT
  30. TRUE // LPC_ERROR_EVENT
  31. };
  32. #if ENABLE_LPC_TRACING
  33. char *LpcpMessageTypeName[] = {
  34. "UNUSED_MSG_TYPE",
  35. "LPC_REQUEST",
  36. "LPC_REPLY",
  37. "LPC_DATAGRAM",
  38. "LPC_LOST_REPLY",
  39. "LPC_PORT_CLOSED",
  40. "LPC_CLIENT_DIED",
  41. "LPC_EXCEPTION",
  42. "LPC_DEBUG_EVENT",
  43. "LPC_ERROR_EVENT",
  44. "LPC_CONNECTION_REQUEST"
  45. };
  46. char *
  47. LpcpGetCreatorName(
  48. PLPCP_PORT_OBJECT PortObject
  49. )
  50. {
  51. NTSTATUS Status;
  52. PEPROCESS Process;
  53. Status = PsLookupProcessByProcessId( PortObject->Creator.UniqueProcess, &Process );
  54. if (NT_SUCCESS( Status )) {
  55. return Process->ImageFileName;
  56. }
  57. else {
  58. return "Unknown";
  59. }
  60. }
  61. #endif // ENABLE_LPC_TRACING
  62. #ifdef ALLOC_PRAGMA
  63. #pragma alloc_text(INIT,LpcInitSystem)
  64. #endif
  65. BOOLEAN
  66. LpcInitSystem( VOID )
  67. /*++
  68. Routine Description:
  69. This function performs the system initialization for the LPC package.
  70. LPC stands for Local Inter-Process Communication.
  71. Arguments:
  72. None.
  73. Return Value:
  74. TRUE if successful and FALSE if an error occurred.
  75. The following errors can occur:
  76. - insufficient memory
  77. --*/
  78. {
  79. OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
  80. UNICODE_STRING PortTypeName;
  81. ULONG ZoneElementSize;
  82. NTSTATUS Status;
  83. ExInitializeFastMutex( &LpcpLock );
  84. RtlInitUnicodeString( &PortTypeName, L"Port" );
  85. RtlZeroMemory( &ObjectTypeInitializer, sizeof( ObjectTypeInitializer ) );
  86. ObjectTypeInitializer.Length = sizeof( ObjectTypeInitializer );
  87. ObjectTypeInitializer.GenericMapping = LpcpPortMapping;
  88. ObjectTypeInitializer.MaintainTypeList = TRUE;
  89. ObjectTypeInitializer.PoolType = PagedPool;
  90. ObjectTypeInitializer.DefaultPagedPoolCharge = sizeof( LPCP_PORT_OBJECT );
  91. ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof( LPCP_NONPAGED_PORT_QUEUE );
  92. ObjectTypeInitializer.InvalidAttributes = OBJ_VALID_ATTRIBUTES ^
  93. PORT_VALID_OBJECT_ATTRIBUTES;
  94. ObjectTypeInitializer.ValidAccessMask = PORT_ALL_ACCESS;
  95. ObjectTypeInitializer.CloseProcedure = LpcpClosePort;
  96. ObjectTypeInitializer.DeleteProcedure = LpcpDeletePort;
  97. ObjectTypeInitializer.UseDefaultObject = TRUE;
  98. ObCreateObjectType( &PortTypeName,
  99. &ObjectTypeInitializer,
  100. (PSECURITY_DESCRIPTOR)NULL,
  101. &LpcPortObjectType
  102. );
  103. ZoneElementSize = PORT_MAXIMUM_MESSAGE_LENGTH +
  104. sizeof( LPCP_MESSAGE ) +
  105. sizeof( LPCP_CONNECTION_MESSAGE );
  106. ZoneElementSize = (ZoneElementSize + LPCP_ZONE_ALIGNMENT - 1) &
  107. LPCP_ZONE_ALIGNMENT_MASK;
  108. LpcpNextMessageId = 1;
  109. LpcpNextCallbackId = 1;
  110. Status = LpcpInitializePortZone( ZoneElementSize,
  111. PAGE_SIZE,
  112. LPCP_ZONE_MAX_POOL_USAGE
  113. );
  114. if (!NT_SUCCESS( Status )) {
  115. return( FALSE );
  116. }
  117. return( TRUE );
  118. }