Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

lpcinit.c File Reference

#include "lpcp.h"

Go to the source code of this file.

Functions

BOOLEAN LpcInitSystem (VOID)
char * LpcpGetCreatorName (PLPCP_PORT_OBJECT PortObject)

Variables

POBJECT_TYPE LpcPortObjectType
POBJECT_TYPE LpcWaitablePortObjectType
GENERIC_MAPPING LpcpPortMapping
LPC_MUTEX LpcpLock


Function Documentation

BOOLEAN LpcInitSystem VOID   ) 
 

Definition at line 76 of file lpcinit.c.

References FALSE, L, LPCP_ZONE_ALIGNMENT, LPCP_ZONE_ALIGNMENT_MASK, LPCP_ZONE_MAX_POOL_USAGE, LpcpClosePort(), LpcpDeletePort(), LpcpInitializeLpcpLock, LpcpInitializePortZone(), LpcpNextCallbackId, LpcpNextMessageId, LpcPortObjectType, LpcpPortMapping, LpcWaitablePortObjectType, NonPagedPool, NT_SUCCESS, NTSTATUS(), NULL, ObCreateObjectType(), PAGE_SIZE, PagedPool, RtlInitUnicodeString(), Status, and TRUE.

00082 : 00083 00084 This function performs the system initialization for the LPC package. 00085 LPC stands for Local Inter-Process Communication. 00086 00087 Arguments: 00088 00089 None. 00090 00091 Return Value: 00092 00093 TRUE if successful and FALSE if an error occurred. 00094 00095 The following errors can occur: 00096 00097 - insufficient memory 00098 00099 --*/ 00100 00101 { 00102 OBJECT_TYPE_INITIALIZER ObjectTypeInitializer; 00103 UNICODE_STRING PortTypeName; 00104 ULONG ZoneElementSize; 00105 NTSTATUS Status; 00106 00107 // 00108 // Initialize our global lpc lock 00109 // 00110 00111 LpcpInitializeLpcpLock(); 00112 00113 // 00114 // Create the object type for the port object 00115 // 00116 00117 RtlInitUnicodeString( &PortTypeName, L"Port" ); 00118 00119 RtlZeroMemory( &ObjectTypeInitializer, sizeof( ObjectTypeInitializer )); 00120 00121 ObjectTypeInitializer.Length = sizeof( ObjectTypeInitializer ); 00122 ObjectTypeInitializer.GenericMapping = LpcpPortMapping; 00123 ObjectTypeInitializer.MaintainTypeList = TRUE; 00124 ObjectTypeInitializer.PoolType = PagedPool; 00125 ObjectTypeInitializer.DefaultPagedPoolCharge = sizeof( LPCP_PORT_OBJECT ); 00126 ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof( LPCP_NONPAGED_PORT_QUEUE ); 00127 ObjectTypeInitializer.InvalidAttributes = OBJ_VALID_ATTRIBUTES ^ PORT_VALID_OBJECT_ATTRIBUTES; 00128 ObjectTypeInitializer.ValidAccessMask = PORT_ALL_ACCESS; 00129 ObjectTypeInitializer.CloseProcedure = LpcpClosePort; 00130 ObjectTypeInitializer.DeleteProcedure = LpcpDeletePort; 00131 ObjectTypeInitializer.UseDefaultObject = TRUE ; 00132 00133 ObCreateObjectType( &PortTypeName, 00134 &ObjectTypeInitializer, 00135 (PSECURITY_DESCRIPTOR)NULL, 00136 &LpcPortObjectType ); 00137 00138 // 00139 // Create the object type for the waitable port object 00140 // 00141 00142 RtlInitUnicodeString( &PortTypeName, L"WaitablePort" ); 00143 ObjectTypeInitializer.PoolType = NonPagedPool ; 00144 ObjectTypeInitializer.UseDefaultObject = FALSE ; 00145 00146 ObCreateObjectType( &PortTypeName, 00147 &ObjectTypeInitializer, 00148 (PSECURITY_DESCRIPTOR)NULL, 00149 &LpcWaitablePortObjectType ); 00150 00151 // 00152 // Initialize the lpc message and callback id counters 00153 // 00154 00155 LpcpNextMessageId = 1; 00156 LpcpNextCallbackId = 1; 00157 00158 // 00159 // Initialize the lpc port zone. Each element can contain a max 00160 // message, plus an LPCP message structure, plus an LPCP connection 00161 // message 00162 // 00163 00164 ZoneElementSize = PORT_MAXIMUM_MESSAGE_LENGTH + 00165 sizeof( LPCP_MESSAGE ) + 00166 sizeof( LPCP_CONNECTION_MESSAGE ); 00167 00168 // 00169 // Round up the size to the next 16 byte alignment 00170 // 00171 00172 ZoneElementSize = (ZoneElementSize + LPCP_ZONE_ALIGNMENT - 1) & 00173 LPCP_ZONE_ALIGNMENT_MASK; 00174 00175 // 00176 // Initialize the zone 00177 // 00178 00179 Status = LpcpInitializePortZone( ZoneElementSize, 00180 PAGE_SIZE, 00181 LPCP_ZONE_MAX_POOL_USAGE ); 00182 00183 if (!NT_SUCCESS( Status )) { 00184 00185 return( FALSE ); 00186 } 00187 00188 return( TRUE ); 00189 }

char* LpcpGetCreatorName PLPCP_PORT_OBJECT  PortObject  ) 
 

Definition at line 193 of file lpcinit.c.

References _LPCP_PORT_OBJECT::Creator, _EPROCESS::ImageFileName, NT_SUCCESS, NTSTATUS(), PsLookupProcessByProcessId(), and Status.

Referenced by LpcRequestPort(), LpcRequestWaitReplyPort(), NtReplyWaitReceivePort(), NtReplyWaitReceivePortEx(), NtRequestPort(), and NtRequestWaitReplyPort().

00199 : 00200 00201 This routine returns the name of the process that created the specified 00202 port object 00203 00204 Arguments: 00205 00206 PortObject - Supplies the port object being queried 00207 00208 Return Value: 00209 00210 char * - The image name of the process that created the port process 00211 00212 --*/ 00213 00214 { 00215 NTSTATUS Status; 00216 PEPROCESS Process; 00217 00218 // 00219 // First find the process that created the port object 00220 // 00221 00222 Status = PsLookupProcessByProcessId( PortObject->Creator.UniqueProcess, &Process ); 00223 00224 // 00225 // If we were able to get the process then return the name of the process 00226 // to our caller 00227 // 00228 00229 if (NT_SUCCESS( Status )) { 00230 00231 return Process->ImageFileName; 00232 00233 } else { 00234 00235 // 00236 // Otherwise tell our caller we don't know the name 00237 // 00238 00239 return "Unknown"; 00240 } 00241 }


Variable Documentation

LPC_MUTEX LpcpLock
 

Definition at line 45 of file lpcinit.c.

POBJECT_TYPE LpcPortObjectType
 

Definition at line 27 of file lpcinit.c.

Referenced by IopConnectLinkTrackingPort(), LpcInitSystem(), LpcpCreatePort(), NtAcceptConnectPort(), NtQueryInformationPort(), NtRegisterThreadTerminatePort(), NtSecureConnectPort(), NtSetDefaultHardErrorPort(), NtSetInformationProcess(), ObfDereferenceObject(), and PspCreateProcess().

GENERIC_MAPPING LpcpPortMapping
 

Initial value:

{ READ_CONTROL | PORT_CONNECT, DELETE | PORT_CONNECT, 0, PORT_ALL_ACCESS }

Definition at line 34 of file lpcinit.c.

Referenced by LpcInitSystem().

POBJECT_TYPE LpcWaitablePortObjectType
 

Definition at line 28 of file lpcinit.c.

Referenced by LpcInitSystem(), LpcpCreatePort(), NtReplyWaitReceivePort(), NtReplyWaitReceivePortEx(), NtSecureConnectPort(), and ObfDereferenceObject().


Generated on Sat May 15 19:44:34 2004 for test by doxygen 1.3.7