PHANDLE_TABLE HandleTable;
OBJECT_HANDLE_INFORMATION HandleInformation;
ULONG AuditMask;
+ BOOLEAN KernelHandle = FALSE;
+
PAGED_CODE();
OBTRACE(OB_HANDLE_DEBUG,
"%s - Duplicating handle: %p for %p into %p\n",
return Status;
}
+ /* Create a kernel handle if asked, but only in the system process */
+ if (PreviousMode == KernelMode &&
+ HandleAttributes & OBJ_KERNEL_HANDLE &&
+ TargetProcess == PsInitialSystemProcess)
+ {
+ KernelHandle = TRUE;
+ }
+
/* Get the target handle table */
HandleTable = ObReferenceProcessHandleTable(TargetProcess);
if (!HandleTable)
Status = STATUS_INSUFFICIENT_RESOURCES;
}
+ /* Mark it as a kernel handle if requested */
+ if (KernelHandle)
+ {
+ NewHandle = ObMarkHandleAsKernelHandle(NewHandle);
+ }
+
/* Return the handle */
if (TargetHandle) *TargetHandle = NewHandle;