mirror of
https://github.com/reactos/reactos.git
synced 2024-06-27 16:31:30 +00:00
[NTOSKRNL] Implement IoChangeFileObjectFilterContext()
This commit is contained in:
parent
a43fb5e054
commit
5f0d02eb52
|
@ -2458,14 +2458,41 @@ IoChangeFileObjectFilterContext(IN PFILE_OBJECT FileObject,
|
|||
IN PVOID FilterContext,
|
||||
IN BOOLEAN Define)
|
||||
{
|
||||
ULONG_PTR Success;
|
||||
PFILE_OBJECT_EXTENSION FileObjectExtension;
|
||||
|
||||
if (!(FileObject->Flags & FO_FILE_OBJECT_HAS_EXTENSION))
|
||||
{
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
UNIMPLEMENTED;
|
||||
FileObjectExtension = FileObject->FileObjectExtension;
|
||||
if (Define)
|
||||
{
|
||||
/* If define, just set the new value if not value is set
|
||||
* Success will only contain old value. It is valid if it is NULL
|
||||
*/
|
||||
Success = InterlockedCompareExchange((volatile LONG *)&FileObjectExtension->FilterContext, (ULONG_PTR)FilterContext, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If not define, we want to reset filter context.
|
||||
* We will remove value (provided by the caller) and set NULL instead.
|
||||
* This will only success if caller provides correct previous value.
|
||||
* To catch whether it worked, we substract previous value to expect value:
|
||||
* If it matches (and thus, we reset), Success will contain 0
|
||||
* Otherwise, it will contain a non-zero value.
|
||||
*/
|
||||
Success = InterlockedCompareExchange((volatile LONG *)&FileObjectExtension->FilterContext, 0, (ULONG_PTR)FilterContext) - (ULONG_PTR)FilterContext;
|
||||
}
|
||||
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
/* If success isn't 0, it means we failed somewhere (set or unset) */
|
||||
if (Success != 0)
|
||||
{
|
||||
return STATUS_ALREADY_COMMITTED;
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
|
Loading…
Reference in a new issue