1 /*++ 2 3 Copyright (c) Microsoft. All rights reserved. 4 5 Module Name: 6 7 FxRequestBufferUm.cpp 8 9 Abstract: 10 11 This module implements a memory union object 12 13 Author: 14 15 16 17 Environment: 18 19 User mode only 20 21 Revision History: 22 23 --*/ 24 25 #include "FxSupportPch.hpp" 26 27 extern "C" { 28 #include "FxRequestBufferUm.tmh" 29 } 30 31 _Must_inspect_result_ 32 NTSTATUS 33 FxRequestBuffer::GetOrAllocateMdl( 34 __in PFX_DRIVER_GLOBALS FxDriverGlobals, 35 __deref_out_opt PMDL* Mdl, 36 __inout PMDL* MdlToFree, 37 __inout PBOOLEAN UnlockWhenFreed, 38 __in LOCK_OPERATION Operation, 39 __in BOOLEAN ReuseMdl, 40 __inout_opt size_t* SizeOfMdl 41 ) 42 /*++ 43 44 Routine Description: 45 46 This function attempts to reuse the passed-in MDL (if any) or allocates 47 a new MDL if reuse flag isn't passed-in or if the existing MDL isn't 48 big enough. 49 50 Arguments: 51 52 Return Value: 53 FxDriverGlobals - Driver globals 54 55 Mdl - on return it contains the MDL allocated/reused 56 57 MdlToFree - pointer to any MDL 58 * to be reused, if the size is <= current size, or 59 * freed and set to newly allocated MDL 60 61 UnlockWhenFreed - whether to unlock pages when freeing MDL 62 (if FALSE, MDL may represent just MDL buffer but the pages 63 might have already been unlocked) 64 65 Operation - Operation to pass to MmLockPages 66 67 ReuseMdl - whether to reuse *MdlToFree 68 Please note that this can be FALSE even when MDL is supplied 69 70 SizeOfMdl - on input contains size of *MdlToFree, 71 on return contains size of *Mdl 72 73 Remarks: 74 75 *MdlToFree is modified only when this function frees the passed in MDL 76 Otherwise it leaves it untouched. Caller is responsible for storing 77 properly initialized value and/or freeing what's stored in the value. 78 79 --*/ 80 { 81 UNREFERENCED_PARAMETER(FxDriverGlobals); 82 UNREFERENCED_PARAMETER(Mdl); 83 UNREFERENCED_PARAMETER(MdlToFree); 84 UNREFERENCED_PARAMETER(UnlockWhenFreed); 85 UNREFERENCED_PARAMETER(Operation); 86 UNREFERENCED_PARAMETER(ReuseMdl); 87 UNREFERENCED_PARAMETER(SizeOfMdl); 88 89 UfxVerifierTrapNotImpl(); 90 return STATUS_NOT_IMPLEMENTED; 91 } 92 93 VOID 94 FxRequestBuffer::SetMemory( 95 __in IFxMemory* Memory, 96 __in PWDFMEMORY_OFFSET Offsets 97 ) 98 { 99 DataType = FxRequestBufferMemory; 100 u.Memory.Memory = Memory; 101 u.Memory.Offsets = Offsets; 102 } 103 104