© 2004 Microsoft Corporation. All rights reserved. 1 Accessing User Buffers.

Slides:



Advertisements
Similar presentations
Question Bank. Explain the syntax of if else statement? Define Union Define global and local variables with example Concept of recursion with example.
Advertisements

Virtual Memory Operating System Concepts chapter 9 CS 355
A Pipeline for Lockless Processing of Sound Data David Thall Insomniac Games.
Loading and Unloading Minifilters
© 2004 Microsoft Corporation. All rights reserved. 1 Context Management.
How to Detect a Memory Leak By Using System Performance Monitor in Windows 2000.
© 2004 Microsoft Corporation. All rights reserved. 1 File Name Management.
Precept 3 COS 461. Concurrency is Useful Multi Processor/Core Multiple Inputs Don’t wait on slow devices.
Structure of Processes
IO Request Flow in WDF Kernel-Mode Drivers
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
I/O Request Flaw in WDF Kernel-Mode Driver
Threads CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
File System. NET+OS 6 File System Architecture Design Goals File System Layer Design Storage Services Layer Design RAM Services Layer Design Flash Services.
Driver Verifier Advancements In Windows 7 Daniel Mihai Principal Software Design Engineer Windows Engineering Tools.
Oracle Memory Configuration on Windows Server Configuring Large Memory for Oracle on 32-bit and 64-bit Windows.
File System and File System Filter Ecosystem Update Neal Christiansen Development Lead File System Filter Team.
Debugging Print And Imaging Drivers. Print driver team philosophy on driver quality There are tools to detect violations Wrongful development assumptions.
Operating Systems Lecture 11 MIPS TLB Structure Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Windows Object Manager CS Spring Overview The object paradigm NT Objects and the Object Manager Object Structure Object Naming Object Handles.
Revealing Stealth Malware UMD CMSC389M Xeno Kovah – Jan xkovah at gmail Subject line starting with "UMD:" 1.
File I/O Applied Component-Based Software Engineering File I/O CSE 668 / ECE 668 Prof. Roger Crawfis.
© Microsoft Corporation1 Windows Kernel Internals I/O Architecture *David B. Probert, Ph.D. Windows Kernel Development Microsoft Corporation.
Copyright 2001 Oxford Consulting, Ltd1 January Storage Classes, Scope and Linkage Overview Focus is on the structure of a C++ program with –Multiple.
Windows NT and Real-Time? Reading: “Inside Microsoft Windows 2000”, (Solomon, Russinovich, Microsoft Programming Series) “Real-Time Systems and Microsoft.
© 2004 Microsoft Corporation. All rights reserved. 1 Modifying Parameters.
1 Records Record aggregate of data elements –Possibly heterogeneous –Elements/slots are identified by names –Elements in same fixed order in all records.
Nachos Project 4 Lecturer: Hao-Hua Chu TA: Chun-Po Wang (Artoo) Date: 2008/10/25.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory.
Lecture 11 Page 1 CS 111 Online Working Sets Give each running process an allocation of page frames matched to its needs How do we know what its needs.
ITFN 3601 Introduction to Operating Systems Lecture 3 Processes, Threads & Scheduling Intro.
© 2004 Microsoft Corporation. All rights reserved. 1 Minifilter Generated IO’s.
Linux Processes Travis Willey Jeff Mihalik. What is a process? A process is a program in execution A process includes: –program counter –stack –data section.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
Best Practices Steve Maillet Chief Software Architect EmbeddedFusion ECE401 Best Practices For Driver Development.
Processes and Virtual Memory
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Files and file allocation.
4P13 Week 12 Talking Points Device Drivers 1.Auto-configuration and initialization routines 2.Routines for servicing I/O requests (the top half)
1 Pintos Virtual Memory Management Project (CS3204 Spring 2006 VT) Yi Ma.
© 2004 Microsoft Corporation. All rights reserved. 1 Rules for Filters (both Legacy and Mini)
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS3: Concurrency 3.3. Advanced Windows Synchronization.
Pintos project 3: Virtual Memory Management
Escape Analysis for Java Will von Rosenberg Noah Wallace.
1 Structure of Processes Chapter 6 Process State and Transition Data Structure for Process Layout of System Memory THE DESIGN OF THE UNIX OPERATING SYSTEM.
Virtual Memory Pranav Shah CS147 - Sin Min Lee. Concept of Virtual Memory Purpose of Virtual Memory - to use hard disk as an extension of RAM. Personal.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples (not covered.
© 2004 Microsoft Corporation. All rights reserved. 1 Processing IO Operations.
CS 140 Lecture Notes: Virtual MemorySlide 1 Load-Time Relocation Process 1 0 ∞ Process 3 Operating System Process 6.
Disk Cache Main memory buffer contains most recently accessed disk sectors Cache is organized by blocks, block size = sector’s A hash table is used to.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
CS 140 Lecture Notes: Virtual Memory
Process concept.
Protecting Memory What is there to protect in memory?
CS 6560: Operating Systems Design
Protecting Memory What is there to protect in memory?
Chapter 9: Virtual Memory
Structure of Processes
Crash Dump Analysis - Santosh Kumar Singh.
Modeling Page Replacement Algorithms
I/O Manager, 64-bit Porting, and New Driver Models
Assembler Design Options
CS 140 Lecture Notes: Virtual Memory
Chapter 9: Virtual-Memory Management
CS 140 Lecture Notes: Virtual Memory
Modeling Page Replacement Algorithms
Processes and Threads.
CS 140 Lecture Notes: Virtual Memory
Structure of Processes
Presentation transcript:

© 2004 Microsoft Corporation. All rights reserved. 1 Accessing User Buffers

© 2004 Microsoft Corporation. All rights reserved. 2 Buffer Handling in the IO Manager DeviceObjects have 3 different buffering methods DO_BUFFERED_IO IoMgr allocates nonPaged pool and copies data to/from users buffer to system buffer Occurs in context of initiating thread DO_DIRECT_IO IoMgr probes and locks the users buffer An MDL is always created Occurs in context of initiating thread NEITHER (meaning neither of the above flags are set) System does nothing to the buffers All standard Microsoft file systems use NEITHER buffering

© 2004 Microsoft Corporation. All rights reserved. 3 Buffer Handling is Operation Specific These operations buffer according to the state of the DeviceObject buffering flags: IRP_MJ_READ IRP_MJ_WRITE IRP_MJ_QUERY_EA IRP_MJ_SET_EA IRP_MJ_DIRECTORY_CONTROL IRP_MJ_QUERY_QUOTA IRP_MJ_SET_QUOTA

© 2004 Microsoft Corporation. All rights reserved. 4 Buffer Handling is Operation Specific (cont’d) These operations are always buffered regardless of the state of the DeviceObject buffering flags: IRP_MJ_CREATE (EA buffer) IRP_MJ_QUERY_INFORMATION IRP_MJ_SET_INFORMATION IRP_MJ_QUERY_VOLUME_INFORMATION IRP_MJ_SET_VOLUME_INFORMATION IRP_MJ_SYSTEM_CONTROL

© 2004 Microsoft Corporation. All rights reserved. 5 Buffer Handling is Operation Specific (cont’d) These operations never look at the state of the DeviceObject buffering flags. Their buffers should be treated as if NEITHER buffering was selected: IRP_MJ_QUERY_SECURITY IRP_MJ_SET_SECURITY IRP_MJ_PNP

© 2004 Microsoft Corporation. All rights reserved. 6 Buffer Handling is Operation Specific (cont’d) These operations have no buffer IRP_MJ_CREATE_NAMED_PIPE IRP_MJ_CREATE_MAILSLOT IRP_MJ_LOCK_CONTROL

© 2004 Microsoft Corporation. All rights reserved. 7 Buffer Handling is Operation Specific (cont’d) These operations define their buffering method inside the IoControlCode parameter: IRP_MJ_FILE_SYSTEM_CONTROL IRP_MJ_DEVICE_CONTROL IRP_MJ_INTERNAL_DEVICE_CONTROL

© 2004 Microsoft Corporation. All rights reserved. 8 Buffer Handling is Operation Specific (cont’d) FastIO operations Never look at the state of the buffering flags in the DeviceObject Should always be treated as NEITHER buffering FsFilter callbacks Don’t have user buffers

© 2004 Microsoft Corporation. All rights reserved. 9 FLT_PARAMETERS Structure Union which defines all parameters for each operation Includes Buffer and MDL parameters Buffer and MDL parameters are stacked

© 2004 Microsoft Corporation. All rights reserved. 10 FLT_PARAMETERS Structure (cont) Buffering method specific parameter definitions for IRP_MJ_FILE_SYSTEM_CONTROL IRP_MJ_DEVICE_CONTROL Parameter definitions for non-IRP operations FastIO only operations FsFilter callbacks New Operations IRP_MJ_VOLUME_MOUNT IRP_MJ_VOLUME_DISMOUNT (not currently implemented)

© 2004 Microsoft Corporation. All rights reserved. 11 Buffer Address vs. MDL You can have the following combinations of the two: MDL only (typically on paging IO) Buffer Address only Buffer Address and MDL Always check for a MDL first If it has one, get a system address for it and use that

© 2004 Microsoft Corporation. All rights reserved. 12 Accessing User Buffer in the PreOperation Callback IRP operation Has MDL Always use system address by calling MmGetSystemAddressForMdlSafe() Does not have MDL Use Try/Except around access FastIO operation Never has a MDL Use Try/Except around access

© 2004 Microsoft Corporation. All rights reserved. 13 Accessing User Buffer in the PostOperation Callback IRP operation Has MDL Always use system address by calling MmGetSystemAddressForMdlSafe() Can do this at DPC level No MDL FLTFL_CALLBACK_DATA_SYSTEM_BUFFER flag set Can directly access the buffer Can do this at DPC level

© 2004 Microsoft Corporation. All rights reserved. 14 Accessing User Buffer in the PostOperation Callback (cont) No MDL (cont) FLTFL_CALLBACK_DATA_SYSTEM_BUFFER flag not set 1)Move to safe IRQL see FltDoCompletionProcessingWhenSafe() 2)Lock the users buffer see FltLockUserBuffer() 3)Get system address by calling MmGetSystemAddressForMdlSafe() Do this because you don’t know what thread context you are in

© 2004 Microsoft Corporation. All rights reserved. 15 Accessing User Buffer in the PostOperation Callback (cont’d) FastIO operation Use Try/Except around access You are always in the correct thread context You are never at DPC level

© 2004 Microsoft Corporation. All rights reserved. 16 FltLockUserBuffer() Restrictions: Can not be called at DPC level If no MDL defined Allocates MDL Updates MdlAddress parameter in CallbackData Marks the CallbackData dirty FLT_SET_CALLBACK_DATA_DIRTY() Properly handles buffers in system address space

© 2004 Microsoft Corporation. All rights reserved. 17 FltLockUserBuffer() (cont) If pages are not already locked, probe and lock the pages Filter must still call MmGetSystemAddressForMdlSafe() to get a system buffer that represents this memory NOTE: This function is expensive – don’t map buffers unless you absolutely need to

© 2004 Microsoft Corporation. All rights reserved. 18 FLTFL_CALLBACK_DATA_ SYSTEM_BUFFER Flag If set, the buffer parameter is BUFFERED. Address is in system address space Flag should never be changed by a filter When creating a MDL for a buffered parameter, always use MmBuildMdlForNonPagedPool() FltLockUserBuffer() properly handles buffers with this flag set

© 2004 Microsoft Corporation. All rights reserved. 19 FltDecodeParameters() Returns pointers into the current IOPB based on the current operation for MDL address parameter Buffer address parameter Length parameter Returns access you have to the buffer IoReadAccess You can look at the buffer, you can’t change it IoWriteAccess & IoModifyAccess You can look at and change the buffer

© 2004 Microsoft Corporation. All rights reserved. 20 FltDecodeParameters() (cont) The returned MDL and length pointers may be NULL for some operations Returns an error for operations that don’t have a buffer Recommended you don’t use for IRP_MJ_FILE_SYSTEM_CONTROL and IRP_MJ_DEVICE_CONTROL Method NEITHER and DIRECT buffering have 2 buffer parameters Use with caution