@@ -272,9 +272,9 @@ VOID SetupIOEventForProcessing(PDOKAN_IO_EVENT IoEvent) {
272
272
IoEvent -> DokanFileInfo .DokanOptions = IoEvent -> DokanInstance -> DokanOptions ;
273
273
274
274
if (IoEvent -> DokanOpenInfo ) {
275
- EnterCriticalSection (& IoEvent -> DokanInstance -> CriticalSection );
275
+ EnterCriticalSection (& IoEvent -> DokanOpenInfo -> CriticalSection );
276
276
IoEvent -> DokanOpenInfo -> OpenCount ++ ;
277
- LeaveCriticalSection (& IoEvent -> DokanInstance -> CriticalSection );
277
+ LeaveCriticalSection (& IoEvent -> DokanOpenInfo -> CriticalSection );
278
278
IoEvent -> DokanFileInfo .Context =
279
279
InterlockedAdd64 (& IoEvent -> DokanOpenInfo -> UserContext , 0 );
280
280
IoEvent -> DokanFileInfo .IsDirectory =
@@ -865,20 +865,22 @@ VOID CreateDispatchCommon(PDOKAN_IO_EVENT IoEvent, ULONG SizeOfEventInfo) {
865
865
VOID ReleaseDokanOpenInfo (PDOKAN_IO_EVENT IoEvent ) {
866
866
LPWSTR fileNameForClose = NULL ;
867
867
868
- if ( IoEvent -> DokanOpenInfo != NULL ) {
869
- EnterCriticalSection ( & IoEvent -> DokanOpenInfo -> CriticalSection ) ;
870
- IoEvent -> DokanOpenInfo -> OpenCount -- ;
871
- if (IoEvent -> DokanOpenInfo -> OpenCount < 1 ) {
872
- if ( IoEvent -> DokanOpenInfo -> FileName ) {
873
- fileNameForClose = IoEvent -> DokanOpenInfo -> FileName ;
874
- IoEvent -> DokanOpenInfo -> FileName = NULL ;
875
- }
876
- LeaveCriticalSection ( & IoEvent -> DokanOpenInfo -> CriticalSection );
877
- PushFileOpenInfo ( IoEvent -> DokanOpenInfo ) ;
878
- IoEvent -> DokanOpenInfo = NULL ;
879
- } else {
880
- LeaveCriticalSection ( & IoEvent -> DokanOpenInfo -> CriticalSection ) ;
868
+ EnterCriticalSection ( & IoEvent -> DokanOpenInfo -> CriticalSection );
869
+ IoEvent -> DokanOpenInfo -> OpenCount -- ;
870
+ if ( IoEvent -> DokanOpenInfo -> OpenCount < 1 ) {
871
+ if (IoEvent -> DokanOpenInfo -> FileName ) {
872
+ fileNameForClose = IoEvent -> DokanOpenInfo -> FileName ;
873
+ IoEvent -> DokanOpenInfo -> FileName = NULL ;
874
+ }
875
+ LeaveCriticalSection ( & IoEvent -> DokanOpenInfo -> CriticalSection );
876
+ PushFileOpenInfo ( IoEvent -> DokanOpenInfo );
877
+ IoEvent -> DokanOpenInfo = NULL ;
878
+ if ( IoEvent -> EventResult ) {
879
+ // Reset the Kernel UserContext if we can. Close events do not have one.
880
+ IoEvent -> EventResult -> Context = 0 ;
881
881
}
882
+ } else {
883
+ LeaveCriticalSection (& IoEvent -> DokanOpenInfo -> CriticalSection );
882
884
}
883
885
884
886
if (fileNameForClose ) {
0 commit comments