@@ -154,11 +154,11 @@ private static int SetInformationFileHook(IntPtr hfile, IO_STATUS_BLOCK* ioStatu
154154
155155 private static int SetInformationFileImpl ( IntPtr hfile , IO_STATUS_BLOCK * ioStatusBlock , byte * fileInformation , uint length , FileInformationClass fileInformationClass )
156156 {
157- if ( fileInformationClass != FileInformationClass . FilePositionInformation || ! HandleToInfoMap . ContainsKey ( hfile ) )
157+ if ( fileInformationClass != FileInformationClass . FilePositionInformation || ! HandleToInfoMap . TryGetValue ( hfile , out var info ) )
158158 return _setFilePointerHook . OriginalFunction . Value . Invoke ( hfile , ioStatusBlock , fileInformation , length , fileInformationClass ) ;
159159
160160 var pointer = * ( long * ) fileInformation ;
161- HandleToInfoMap [ hfile ] . FileOffset = pointer ;
161+ info . FileOffset = pointer ;
162162 return _setFilePointerHook . OriginalFunction . Value . Invoke ( hfile , ioStatusBlock , fileInformation , length , fileInformationClass ) ;
163163 }
164164
@@ -174,7 +174,7 @@ private static int NtReadFileImpl(IntPtr handle, IntPtr hEvent, IntPtr* apcRouti
174174 // If it is, prepare to hook it.
175175 long requestedOffset = byteOffset != ( void * ) 0 ? * byteOffset : FileUseFilePointerPosition ; // -1 means use current location
176176 if ( requestedOffset == FileUseFilePointerPosition )
177- requestedOffset = HandleToInfoMap [ handle ] . FileOffset ;
177+ requestedOffset = info . FileOffset ;
178178
179179 if ( _logger . IsEnabled ( LogSeverity . Debug ) )
180180 _logger . Debug ( $ "[FileAccessServer] Read Request, Buffer: { ( long ) buffer : X} , Length: { length } , Offset: { requestedOffset } ") ;
0 commit comments