summaryrefslogtreecommitdiff
path: root/filesys/miniFilter/delete
diff options
context:
space:
mode:
authorkarlf <[email protected]>2016-08-11 13:28:13 -0700
committerkarlf <[email protected]>2016-08-11 13:28:13 -0700
commit96eb96dfb613e4c745db6bd1f53a92fe7e2290fc (patch)
treead5f3ede5cbcd6b598677ce41bcf8318471bdd92 /filesys/miniFilter/delete
parent687b274aa38fd05c8c26e3068932121876d7f745 (diff)
Updated for "Windows 10 Anniversary Update" (Version 1607)
Diffstat (limited to 'filesys/miniFilter/delete')
-rw-r--r--filesys/miniFilter/delete/README.md2
-rw-r--r--filesys/miniFilter/delete/delete.c51
-rw-r--r--filesys/miniFilter/delete/delete.sln18
-rw-r--r--filesys/miniFilter/delete/delete.vcxproj4
-rw-r--r--filesys/miniFilter/delete/delete.vcxproj.Filters8
5 files changed, 57 insertions, 26 deletions
diff --git a/filesys/miniFilter/delete/README.md b/filesys/miniFilter/delete/README.md
index 05782834..ad60db1a 100644
--- a/filesys/miniFilter/delete/README.md
+++ b/filesys/miniFilter/delete/README.md
@@ -9,7 +9,7 @@ This sample builds a Universal Windows Driver. It uses only APIs and DDIs that a
Design and Operation
--------------------
-The *delete* minifilter illustrates how to detect deletion of files and streams. It monitors IRP\_MJ\_CREATE requests for the FILE\_DELETE\_ON\_CLOSE flag. Also, it detects IRP\_MJ\_SET\_INFORMATION requests for setting FileDispositionInformation. The sample also illustrates how to handle racing deletes (in the form of multiple parallel IRP\_MJ\_SET\_INFORMATION operations), and how to distinguish deletion of an entire file from deletion of just one stream of the file.
+The *delete* minifilter illustrates how to detect deletion of files and streams. It monitors IRP\_MJ\_CREATE requests for the FILE\_DELETE\_ON\_CLOSE flag. Also, it detects IRP\_MJ\_SET\_INFORMATION requests for setting FileDispositionInformation/FileDispositionInformationEx. The sample also illustrates how to handle racing deletes (in the form of multiple parallel IRP\_MJ\_SET\_INFORMATION operations), and how to distinguish deletion of an entire file from deletion of just one stream of the file.
**Note** Because of the way in which the Windows operating system deletes files, it is not possible for the minifilter to detect in advance that a file or stream will be deleted. The minifilter can only detect operations that may cause a deletion, and then determine if the deletion took place after the operation completes.
diff --git a/filesys/miniFilter/delete/delete.c b/filesys/miniFilter/delete/delete.c
index ec515c81..4050d7d0 100644
--- a/filesys/miniFilter/delete/delete.c
+++ b/filesys/miniFilter/delete/delete.c
@@ -2764,8 +2764,8 @@ Routine Description:
IRP_MJ_SET_INFORMATION in this miniFilter.
The pre-setinfo callback is important because setting
- FileDispositionInformation is another way of putting the file in a
- delete-pending state.
+ FileDispositionInformation/FileDispositionInformationEx is another way of
+ putting the file in a delete-pending state.
Since the delete disposition is a reversible condition, we have to
make sure to do the right thing when multiple operations are racing:
@@ -2790,8 +2790,8 @@ Return Value:
FLT_PREOP_SYNCHRONIZE - we never do any sort of asynchronous processing
here, and we synchronize postop.
- FLT_PREOP_SUCCESS_NO_CALLBACK - if not FileDispositionInformation or we
- can't set a streamcontext.
+ FLT_PREOP_SUCCESS_NO_CALLBACK - if not FileDispositionInformation/FileDispositionInformationEx
+ or we can't set a streamcontext.
--*/
{
@@ -2806,6 +2806,7 @@ Return Value:
switch (Data->Iopb->Parameters.SetFileInformation.FileInformationClass) {
case FileDispositionInformation:
+ case FileDispositionInformationEx:
//
// We're interested when the file delete disposition changes.
@@ -2912,16 +2913,16 @@ Return Value:
PAGED_CODE();
- // assert on FileDispositionInformation
- ASSERT( Data->Iopb->Parameters.SetFileInformation.FileInformationClass
- == FileDispositionInformation );
+ // assert on FileDispositionInformation/FileDispositionInformationEx
+ ASSERT( (Data->Iopb->Parameters.SetFileInformation.FileInformationClass == FileDispositionInformation) ||
+ (Data->Iopb->Parameters.SetFileInformation.FileInformationClass == FileDispositionInformationEx) );
// pass from pre-callback to post-callback
ASSERT( NULL != CompletionContext );
streamContext = (PDF_STREAM_CONTEXT) CompletionContext;
//
- // Reaching a postop for FileDispositionInformation means we
+ // Reaching a postop for FileDispositionInformation/FileDispositionInformationEx means we
// MUST have a stream context passed in the CompletionContext.
//
@@ -2934,9 +2935,38 @@ Return Value:
// file is a delete candidate, so it will be checked at post-
// -cleanup regardless of the value of SetDisp.
//
+
+ //
+ // Using FileDispositinInformationEx -
+ // FILE_DISPOSITION_ON_CLOSE controls delete on close
+ // or set disposition behavior. It uses FILE_DISPOSITION_INFORMATION_EX structure.
+ // FILE_DISPOSITION_ON_CLOSE is set - Set or clear DeleteOnClose
+ // depending on FILE_DISPOSITION_DELETE flag.
+ // FILE_DISPOSITION_ON_CLOSE is NOT set - Set or clear disposition information
+ // depending on the flag FILE_DISPOSITION_DELETE.
+ //
+ //
+ // Using FileDispositionInformation -
+ // Controls only set disposition information behavior. It uses FILE_DISPOSITION_INFORMATION structure.
+ //
- streamContext->SetDisp = ((PFILE_DISPOSITION_INFORMATION)
- Data->Iopb->Parameters.SetFileInformation.InfoBuffer)->DeleteFile;
+ if (Data->Iopb->Parameters.SetFileInformation.FileInformationClass == FileDispositionInformationEx) {
+
+ ULONG Flags = ((PFILE_DISPOSITION_INFORMATION_EX) Data->Iopb->Parameters.SetFileInformation.InfoBuffer)->Flags;
+
+ if (FlagOn( Flags, FILE_DISPOSITION_ON_CLOSE )) {
+
+ streamContext->DeleteOnClose = BooleanFlagOn( Flags, FILE_DISPOSITION_DELETE );
+
+ } else {
+
+ streamContext->SetDisp = BooleanFlagOn( Flags, FILE_DISPOSITION_DELETE );
+ }
+
+ } else {
+
+ streamContext->SetDisp = ((PFILE_DISPOSITION_INFORMATION) Data->Iopb->Parameters.SetFileInformation.InfoBuffer)->DeleteFile;
+ }
}
//
@@ -3112,6 +3142,7 @@ Return Value:
//
// 3. DeleteOnClose. If the file was ever opened with
// FILE_DELETE_ON_CLOSE, we must check to see if it was deleted.
+ // FileDispositionInformationEx allows the this flag to be unset.
//
// Also, if a deletion of this stream was already notified, there is no
// point notifying it again.
diff --git a/filesys/miniFilter/delete/delete.sln b/filesys/miniFilter/delete/delete.sln
index d4cd99a1..1e175659 100644
--- a/filesys/miniFilter/delete/delete.sln
+++ b/filesys/miniFilter/delete/delete.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0
MinimumVisualStudioVersion = 12.0
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "delete", "delete.vcxproj", "{410C84AC-DE40-4A38-9563-058909292244}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "delete", "delete.vcxproj", "{0933F9F0-B579-4691-9611-D28D4D6F6969}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -13,14 +13,14 @@ Global
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {410C84AC-DE40-4A38-9563-058909292244}.Debug|Win32.ActiveCfg = Debug|Win32
- {410C84AC-DE40-4A38-9563-058909292244}.Debug|Win32.Build.0 = Debug|Win32
- {410C84AC-DE40-4A38-9563-058909292244}.Release|Win32.ActiveCfg = Release|Win32
- {410C84AC-DE40-4A38-9563-058909292244}.Release|Win32.Build.0 = Release|Win32
- {410C84AC-DE40-4A38-9563-058909292244}.Debug|x64.ActiveCfg = Debug|x64
- {410C84AC-DE40-4A38-9563-058909292244}.Debug|x64.Build.0 = Debug|x64
- {410C84AC-DE40-4A38-9563-058909292244}.Release|x64.ActiveCfg = Release|x64
- {410C84AC-DE40-4A38-9563-058909292244}.Release|x64.Build.0 = Release|x64
+ {0933F9F0-B579-4691-9611-D28D4D6F6969}.Debug|Win32.ActiveCfg = Debug|Win32
+ {0933F9F0-B579-4691-9611-D28D4D6F6969}.Debug|Win32.Build.0 = Debug|Win32
+ {0933F9F0-B579-4691-9611-D28D4D6F6969}.Release|Win32.ActiveCfg = Release|Win32
+ {0933F9F0-B579-4691-9611-D28D4D6F6969}.Release|Win32.Build.0 = Release|Win32
+ {0933F9F0-B579-4691-9611-D28D4D6F6969}.Debug|x64.ActiveCfg = Debug|x64
+ {0933F9F0-B579-4691-9611-D28D4D6F6969}.Debug|x64.Build.0 = Debug|x64
+ {0933F9F0-B579-4691-9611-D28D4D6F6969}.Release|x64.ActiveCfg = Release|x64
+ {0933F9F0-B579-4691-9611-D28D4D6F6969}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/filesys/miniFilter/delete/delete.vcxproj b/filesys/miniFilter/delete/delete.vcxproj
index a240aa81..8440ee76 100644
--- a/filesys/miniFilter/delete/delete.vcxproj
+++ b/filesys/miniFilter/delete/delete.vcxproj
@@ -19,11 +19,11 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
- <ProjectGuid>{410C84AC-DE40-4A38-9563-058909292244}</ProjectGuid>
+ <ProjectGuid>{0933F9F0-B579-4691-9611-D28D4D6F6969}</ProjectGuid>
<RootNamespace>$(MSBuildProjectName)</RootNamespace>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<Platform Condition="'$(Platform)' == ''">Win32</Platform>
- <SampleGuid>{051F6346-8D3B-4D83-AB05-BB76110E004D}</SampleGuid>
+ <SampleGuid>{3198832E-A446-4372-94A0-5E68D9996027}</SampleGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
diff --git a/filesys/miniFilter/delete/delete.vcxproj.Filters b/filesys/miniFilter/delete/delete.vcxproj.Filters
index 60c84cad..c02436e5 100644
--- a/filesys/miniFilter/delete/delete.vcxproj.Filters
+++ b/filesys/miniFilter/delete/delete.vcxproj.Filters
@@ -3,19 +3,19 @@
<ItemGroup>
<Filter Include="Source Files">
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;*</Extensions>
- <UniqueIdentifier>{0EEAE985-A09E-4685-BAA3-DFD5B6467C4E}</UniqueIdentifier>
+ <UniqueIdentifier>{8C503630-3AF5-46CF-99D5-EB1C7ECE3079}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files">
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
- <UniqueIdentifier>{7C40FC3F-061F-42B5-9ADD-4CC3D3E72944}</UniqueIdentifier>
+ <UniqueIdentifier>{2F8671A8-91BC-45B3-AF3D-ABB984EC9F15}</UniqueIdentifier>
</Filter>
<Filter Include="Resource Files">
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml</Extensions>
- <UniqueIdentifier>{96A10710-A80F-4195-8674-D5C51CC6D15E}</UniqueIdentifier>
+ <UniqueIdentifier>{7E49906A-9C9B-44FA-9264-55D26E938C69}</UniqueIdentifier>
</Filter>
<Filter Include="Driver Files">
<Extensions>inf;inv;inx;mof;mc;</Extensions>
- <UniqueIdentifier>{C3920BC4-FB12-491E-B103-14EB0437F1FA}</UniqueIdentifier>
+ <UniqueIdentifier>{2D0FAEC4-9C8F-4FB9-89E4-4546A2EBE732}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>