00116 :
00117
00118 This routine
is the callback used
for deleting a port object.
00119
00120 Arguments:
00121
00122 Object - Supplies a pointer to
the port object being deleted
00123
00124 Return Value:
00125
00126 None.
00127
00128 --*/
00129
00130 {
00131
PLPCP_PORT_OBJECT Port = Object;
00132
PLPCP_PORT_OBJECT ConnectionPort;
00133 LPC_CLIENT_DIED_MSG ClientPortClosedDatagram;
00134
PLPCP_MESSAGE Msg;
00135 PLIST_ENTRY Head, Next;
00136 HANDLE CurrentProcessId;
00137
00138
PAGED_CODE();
00139
00140
00141
00142
00143
00144
00145
00146
00147
LpcpPortExtraDataDestroy( Port );
00148
00149
if ((Port->
Flags &
PORT_TYPE) ==
SERVER_COMMUNICATION_PORT) {
00150
00151
PETHREAD ClientThread;
00152
00153
LpcpAcquireLpcpLock();
00154
00155
if ((
ClientThread = Port->
ClientThread) !=
NULL) {
00156
00157 Port->
ClientThread =
NULL;
00158
00159
LpcpReleaseLpcpLock();
00160
00161
ObDereferenceObject( ClientThread );
00162
00163 }
else {
00164
00165
LpcpReleaseLpcpLock();
00166 }
00167 }
00168
00169
00170
00171
00172
00173
00174
if ((Port->
Flags &
PORT_TYPE) ==
CLIENT_COMMUNICATION_PORT) {
00175
00176 ClientPortClosedDatagram.PortMsg.u1.s1.TotalLength =
sizeof( ClientPortClosedDatagram );
00177 ClientPortClosedDatagram.PortMsg.u1.s1.DataLength =
sizeof( ClientPortClosedDatagram.CreateTime );
00178
00179 ClientPortClosedDatagram.PortMsg.u2.s2.Type = LPC_PORT_CLOSED;
00180 ClientPortClosedDatagram.PortMsg.u2.s2.DataInfoOffset = 0;
00181
00182 ClientPortClosedDatagram.CreateTime =
PsGetCurrentProcess()->CreateTime;
00183
00184
LpcRequestPort( Port, (PPORT_MESSAGE)&ClientPortClosedDatagram );
00185 }
00186
00187
00188
00189
00190
00191
00192
LpcpDestroyPortQueue( Port, TRUE );
00193
00194
00195
00196
00197
00198
if (Port->
ClientSectionBase !=
NULL) {
00199
00200
MmUnmapViewOfSection(
PsGetCurrentProcess(),
00201 Port->
ClientSectionBase );
00202
00203 }
00204
00205
00206
00207
00208
00209
if (Port->
ServerSectionBase !=
NULL) {
00210
00211
MmUnmapViewOfSection(
PsGetCurrentProcess(),
00212 Port->
ServerSectionBase );
00213
00214 }
00215
00216
00217
00218
00219
00220
00221
if (ConnectionPort = Port->
ConnectionPort) {
00222
00223 CurrentProcessId =
PsGetCurrentThread()->Cid.UniqueProcess;
00224
00225
LpcpAcquireLpcpLock();
00226
00227 Head = &ConnectionPort->
LpcDataInfoChainHead;
00228 Next = Head->Flink;
00229
00230
while (Next != Head) {
00231
00232 Msg = CONTAINING_RECORD( Next,
LPCP_MESSAGE, Entry );
00233 Next = Next->Flink;
00234
00235
if (Msg->
Request.ClientId.UniqueProcess == CurrentProcessId) {
00236
00237
LpcpTrace((
"%s Freeing DataInfo Message %lx (%u.%u) Port: %lx\n",
00238
PsGetCurrentProcess()->ImageFileName,
00239 Msg,
00240 Msg->
Request.MessageId,
00241 Msg->
Request.CallbackId,
00242 ConnectionPort ));
00243
00244 RemoveEntryList( &Msg->
Entry );
00245
00246
LpcpFreeToPortZone( Msg, TRUE );
00247 }
00248 }
00249
00250
LpcpReleaseLpcpLock();
00251
00252
if (ConnectionPort != Port) {
00253
00254
ObDereferenceObject( ConnectionPort );
00255 }
00256 }
00257
00258
if (((Port->
Flags &
PORT_TYPE) ==
SERVER_CONNECTION_PORT) &&
00259 (ConnectionPort->
ServerProcess !=
NULL)) {
00260
00261
ObDereferenceObject( ConnectionPort->
ServerProcess );
00262
00263 ConnectionPort->
ServerProcess =
NULL;
00264 }
00265
00266
00267
00268
00269
00270
LpcpFreePortClientSecurity( Port );
00271
00272
00273
00274
00275
00276
return;
00277 }