@cziter15
There exists no clean way to do what you're asking. If a handle is acquired before your callback is installed then you are at the mercy of the other processes, for the most part. You could however close existing handles by enumerating all currently active processes, attach to their context and enumerate their handle table for the specific handle you're interested in. It's not pretty but works for handles opened pre-callback installation
KeStackAttachProcess(Process, &ApcState) ---> Enum Handle Table ---> ZwSetInformationObject(TargetHandle, ObjectHandleFlagInformation, &HandleData.ProtectFromClose = FALSE, sizeof(HandleData)) ---> ZwClose(TargetHandle) ---> KeUnstackDetachProcess(&ApcState)
P.S: If you don't mind getting dirtier then you could try setting a new granted access for the handle in the table entry but personally I've never modified the access this way, I've always just closed them for the sake of simplicity.
Best Regards,
Brock
Accept nothing less than STATUS_SUCCESS