Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318/*++
Copyright (c) Microsoft Corporation
Module Name:
FxRequestSystemBuffer.cpp
Abstract:
This module implements class representing the system buffer in an FxRequest
Author:
Environment:
Both kernel and user mode
Revision History:
--*/
#include "coreprivshared.hpp"
// Tracing supportextern "C" {// #include "FxRequestSystemBuffer.tmh"}
size_tFxRequestSystemBuffer::GetBufferSize( VOID )/*++
Routine Description: Returns the size of the buffer returned by GetBuffer()
Arguments: None
Return Value: Buffer length or 0 on error
--*/{ FxIrp* irp = GetRequest()->GetFxIrp();
switch (irp->GetMajorFunction()) { case IRP_MJ_READ: return irp->GetParameterReadLength();
case IRP_MJ_WRITE: return irp->GetParameterWriteLength();
case IRP_MJ_DEVICE_CONTROL: case IRP_MJ_INTERNAL_DEVICE_CONTROL: return irp->GetParameterIoctlInputBufferLength();
default: // should not get here ASSERT(FALSE); return 0; }}
_Must_inspect_result_PMDLFxRequestSystemBuffer::GetMdl( VOID )/*++
Routine Description: Returns the PMDL from the irp if one exists, otherwise NULL
Arguments: None
Return Value: a valid PMDL or NULL (not an error condition)
--*/{ FxDevice* pDevice; FxIrp* irp = GetRequest()->GetFxIrp();
switch (irp->GetMajorFunction()) { case IRP_MJ_READ: case IRP_MJ_WRITE: pDevice = FxDevice::GetFxDevice(irp->GetDeviceObject());
if (pDevice->GetIoType() == WdfDeviceIoDirect) { return m_Mdl; } // || || Fall through || || // \/ \/ \/ \/
case IRP_MJ_DEVICE_CONTROL: case IRP_MJ_INTERNAL_DEVICE_CONTROL: // // For IOCLs, the outbuffer will return the PMDL // // || || Fall through || || // \/ \/ \/ \/
default: return NULL; }}
WDFMEMORYFxRequestSystemBuffer::GetHandle( VOID )/*++
Routine Description: Returns the handle that will represent this object to the driver writer.
Arguments: None
Return Value: Valid WDF handle
--*/{ return GetRequest()->GetMemoryHandle( FIELD_OFFSET(FxRequest, m_SystemBufferOffset));}
USHORTFxRequestSystemBuffer::GetFlags( VOID )/*++
Routine Description: Returns the flags associated with this buffer. This currently only includes whether the buffer is read only or not
Arguments: None
Return Value: flags from IFxMemoryFlags
--*/{ FxIrp* irp = GetRequest()->GetFxIrp();
switch (irp->GetMajorFunction()) { case IRP_MJ_DEVICE_CONTROL: case IRP_MJ_INTERNAL_DEVICE_CONTROL: switch (irp->GetParameterIoctlCodeBufferMethod()) { case METHOD_BUFFERED: case METHOD_NEITHER: return 0;
case METHOD_IN_DIRECT: case METHOD_OUT_DIRECT: return IFxMemoryFlagReadOnly; }
case IRP_MJ_READ: return 0;
case IRP_MJ_WRITE: return IFxMemoryFlagReadOnly;
default: ASSERT(FALSE); return 0; }}
PFX_DRIVER_GLOBALSFxRequestSystemBuffer::GetDriverGlobals( VOID )/*++
Routine Description: Returns the driver globals
Arguments: none
Return Value: Driver globals pointer
--*/{ return GetRequest()->GetDriverGlobals();}
ULONGFxRequestSystemBuffer::AddRef( __in PVOID Tag, __in LONG Line, __in_opt PSTR File )/*++
Routine Description: Adds an irp reference to the owning FxRequest. This object does not maintain its own reference count. A request cannot be completed with outstanding irp references.
Arguments: Tag - the tag to use to track the reference
Line - The line number of the caller
File - the file name of the caller
Return Value: current reference count
--*/{ UNREFERENCED_PARAMETER(Tag); UNREFERENCED_PARAMETER(Line); UNREFERENCED_PARAMETER(File);
GetRequest()->AddIrpReference();
// // This value should never be used by the caller // return 2;}
ULONGFxRequestSystemBuffer::Release( __in PVOID Tag, __in LONG Line, __in_opt PSTR File )/*++
Routine Description: Removes an irp reference to the owning FxRequest. This object does not maintain its own reference count. A request cannot be completed with outstanding irp references.
Arguments: Tag - the tag to use to track the release
Line - The line number of the caller
File - the file name of the caller
Return Value: current reference count
--*/{ UNREFERENCED_PARAMETER(Tag); UNREFERENCED_PARAMETER(Line); UNREFERENCED_PARAMETER(File);
GetRequest()->ReleaseIrpReference();
return 1;}
FxRequest*FxRequestSystemBuffer::GetRequest( VOID )/*++
Routine Description: Return the owning FxRequest based on this object's address
Arguments: None
Return Value: owning FxRequest
--*/{ return CONTAINING_RECORD(this, FxRequest, m_SystemBuffer);}
VOIDFxRequestSystemBuffer::Delete( VOID )/*++
Routine Description: Attempt to delete this interface. Since this is an embedded object, it cannot be deleted. Since this function is only called internally, the internal caller knows if the IFxMemory is deletable because the internal caller allocated the IFxMemory to begin with.
Arguments: None
Return Value: None
--*/{ // this function should never be called ASSERT(FALSE);}