Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2004 Microsoft Corporation. All rights reserved. 1 Modifying Parameters.

Similar presentations


Presentation on theme: "© 2004 Microsoft Corporation. All rights reserved. 1 Modifying Parameters."— Presentation transcript:

1 © 2004 Microsoft Corporation. All rights reserved. 1 Modifying Parameters

2 © 2004 Microsoft Corporation. All rights reserved. 2 Changing Operation Parameters Only fields in FLT_CALLBACK_DATA.Iopb structure can be changed Includes TargetInstance, TargetFileObject, and operation specific parameters (including buffer address and MDL) TargetInstance can only be changed to an instance of your filter at the same altitude on another volume TargetFileObject must be to a file on the same volume as TargetInstance MajorFunction may not be changed – generate another IO

3 © 2004 Microsoft Corporation. All rights reserved. 3 Changing Operation Parameters (cont) FltSetCallbackDataDirty() Must be called to signify that parameters have been changed If FLT_CALLBACK_DATA is not marked DIRTY, changes are ignored FltClearCallbackDataDirty() FltIsCallbackDataDirty()

4 © 2004 Microsoft Corporation. All rights reserved. 4 Changing Operation Parameters (cont) Parameters received in postOperation callback are the parameters received in preOperation These parameters DO NOT reflect any parameter changes filter may have made If filter needs to know changes made to parameters in postOperation callback, it should record the changes in the context passed from the preOperation callback

5 © 2004 Microsoft Corporation. All rights reserved. 5 Changing Operation Parameters (cont) FLT_CALLBACK_DATA.IoStatus may also be changed This is an exception to the previous rule May be changed in pre operation callback if completing the operation May be changed in post operation callback if undoing operation If changing a successful operation to a failure, it is filters responsibility to undo the operation Do not need to call FLT_SET_CALLBACK_DATA_DIRTY()

6 © 2004 Microsoft Corporation. All rights reserved. 6 Swapping Buffers Always keep the MDL and buffer fields in sync After making a buffer or MDL change, always call FltSetCallbackDataDirty() Never change the state of the FLTFL_CALLBACK_DATA_SYSTEM_BUFFER flag Should only be set by Filter Manager

7 © 2004 Microsoft Corporation. All rights reserved. 7 Swapping Buffers (cont) If you swap buffers you must have a postOperation callback Do not free the Buffer or MDL you are replacing Do not free MDLs you have successfully inserted into a callback data structure FltMgr will free them for you In your postOperation callback, free the buffer you allocated Again, do not free the MDL

8 © 2004 Microsoft Corporation. All rights reserved. 8 Swapping Buffers (cont) IRP operation If FLTFL_CALLBACK_DATA_SYSTEM_BUFFER flag is set: New buffer must be allocated from nonPaged pool Set the MDL field to NULL Call FLT_SET_CALLBACK_DATA_DIRTY() If FLTFL_CALLBACK_DATA_SYSTEM_BUFFER flag is not set: New buffer can be from paged or nonPaged pool PagingIO operation buffers must be from nonPaged pool Always create and set a MDL See MmBuildMdlForNonPagedPool() Call FLT_SET_CALLBACK_DATA_DIRTY()

9 © 2004 Microsoft Corporation. All rights reserved. 9 Swapping Buffers (cont) FastIO New buffer can be from paged or nonPaged pool Set the MDL to NULL MDL should already be NULL Call FltSetCallbackDataDirty()

10 © 2004 Microsoft Corporation. All rights reserved. 10 Swapping Buffers (cont) WARNING: Non-Cached IO operations MM violates the rule that the length of non-cached IO operations must be rounded to a sector boundary The file systems round the length up to the next sector size below the filter When swapping buffers in this scenario, the filter must round the length up to the sector size (use SectorSize field in DeviceObject) before allocating/copying data. If you don’t the system may crash or you may corrupt the file

11 © 2004 Microsoft Corporation. All rights reserved. 11 Swapped Buffer Support Routines FltGetSwappedBufferMdlAddress() Only callable from postOperation callback Returns the MDL for the buffer that you set in the preOperation callback This may return NULL FltRetainSwappedBufferMdlAddress() Only callable from postOperation callback Tells FltMgr to not free the current operations MDL It is now the filters responsibility to free this MDL

12 © 2004 Microsoft Corporation. All rights reserved. 12 Unloading Filters with Swapped Buffers These operations are not “drainable” Instead, the operation is canceled After canceling, FltMgr waits for the operation to complete. Whether the operation has a cancel routine or not, it is assumed it will complete soon

13 © 2004 Microsoft Corporation. All rights reserved. 13 Sample See the SwapBuffers minifilter sample


Download ppt "© 2004 Microsoft Corporation. All rights reserved. 1 Modifying Parameters."

Similar presentations


Ads by Google