Author: hbelusca
Date: Mon Jul 4 22:27:35 2016
New Revision: 71816
URL:
http://svn.reactos.org/svn/reactos?rev=71816&view=rev
Log:
[NTOS]
- Document ObKillProcess.
- Implement and document ObClearProcessHandleTable (based on ObKillProcess).
Modified:
trunk/reactos/ntoskrnl/ob/obhandle.c
Modified: trunk/reactos/ntoskrnl/ob/obhandle.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obhandle.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obhandle.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ob/obhandle.c [iso-8859-1] Mon Jul 4 22:27:35 2016
@@ -2004,17 +2004,69 @@
return Ret;
}
+/*++
+* @name ObClearProcessHandleTable
+*
+* The ObClearProcessHandleTable routine clears the handle table
+* of the given process.
+*
+* @param Process
+* The process of which the handle table should be cleared.
+*
+* @return None.
+*
+* @remarks None.
+*
+*--*/
VOID
NTAPI
ObClearProcessHandleTable(IN PEPROCESS Process)
{
- /* FIXME */
+ PHANDLE_TABLE HandleTable;
+ OBP_CLOSE_HANDLE_CONTEXT Context;
+ KAPC_STATE ApcState;
+ BOOLEAN AttachedToProcess = FALSE;
+
+ ASSERT(Process);
+
+ /* Ensure the handle table doesn't go away while we use it */
+ HandleTable = ObReferenceProcessHandleTable(Process);
+ if (!HandleTable) return;
+
+ /* Attach to the current process if needed */
+ if (PsGetCurrentProcess() != Process)
+ {
+ KeStackAttachProcess(&Process->Pcb, &ApcState);
+ AttachedToProcess = TRUE;
+ }
+
+ /* Enter a critical region */
+ KeEnterCriticalRegion();
+
+ /* Fill out the context */
+ Context.AccessMode = UserMode;
+ Context.HandleTable = HandleTable;
+
+ /* Sweep the handle table to close all handles */
+ ExSweepHandleTable(HandleTable,
+ ObpCloseHandleCallback,
+ &Context);
+
+ /* Leave the critical region */
+ KeLeaveCriticalRegion();
+
+ /* Detach if needed */
+ if (AttachedToProcess)
+ KeUnstackDetachProcess(&ApcState);
+
+ /* Let the handle table go */
+ ObDereferenceProcessHandleTable(Process);
}
/*++
-* @name ObpCreateHandleTable
-*
-* The ObpCreateHandleTable routine <FILLMEIN>
+* @name ObInitProcess
+*
+* The ObInitProcess routine <FILLMEIN>
*
* @param Parent
* <FILLMEIN>.
@@ -2085,14 +2137,16 @@
/*++
* @name ObKillProcess
*
-* The ObKillProcess routine <FILLMEIN>
+* The ObKillProcess routine performs rundown operations on the process,
+* then clears and destroys its handle table.
*
* @param Process
-* <FILLMEIN>.
+* The process to be killed.
*
* @return None.
*
-* @remarks None.
+* @remarks Called by the Object Manager cleanup code (kernel)
+* when a process is to be destroyed.
*
*--*/
VOID