Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328/*++
Copyright (c) Microsoft Corporation
Module Name:
FxRequestOutputBuffer.cpp
Abstract:
This module implements class representing the output buffer in an FxRequest
Author:
Environment:
Both kernel and user mode
Revision History:
--*/
#include "coreprivshared.hpp"
// Tracing supportextern "C" {// #include "FxRequestOutputBuffer.tmh"}
PVOIDFxRequestOutputBuffer::GetBuffer( VOID )/*++
Routine Description: Returns the output buffer that has been cached away by the call to SetBuffer()
Arguments: None
Return Value: Valid memory or NULL on error
--*/{ FxIrp* irp = GetRequest()->GetFxIrp();
ASSERT(irp->GetMajorFunction() == IRP_MJ_DEVICE_CONTROL || irp->GetMajorFunction() == IRP_MJ_INTERNAL_DEVICE_CONTROL);
switch (irp->GetParameterIoctlCodeBufferMethod()) { case METHOD_BUFFERED: // // For buffered ioctls, input and output buffer pointers are same. // return m_Buffer;
case METHOD_IN_DIRECT: case METHOD_OUT_DIRECT: // // FxRequest::GetDeviceControlOutputMemoryObject has already called // MmGetSystemAddressForMdlSafe and returned success, so we know that // we can safely call MmGetSystemAddressForMdlSafe again to get a // valid VA pointer. // return Mx::MxGetSystemAddressForMdlSafe(m_Mdl, NormalPagePriority);
case METHOD_NEITHER: return m_Buffer;
default: ASSERT(FALSE); return NULL; }}
size_tFxRequestOutputBuffer::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();
ASSERT(irp->GetMajorFunction() == IRP_MJ_DEVICE_CONTROL || irp->GetMajorFunction() == IRP_MJ_INTERNAL_DEVICE_CONTROL);
return irp->GetParameterIoctlOutputBufferLength();}
_Must_inspect_result_PMDLFxRequestOutputBuffer::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)
--*/{ FxIrp* irp = GetRequest()->GetFxIrp();
ASSERT(irp->GetMajorFunction() == IRP_MJ_DEVICE_CONTROL || irp->GetMajorFunction() == IRP_MJ_INTERNAL_DEVICE_CONTROL);
switch (irp->GetParameterIoctlCodeBufferMethod()) { case METHOD_IN_DIRECT: case METHOD_OUT_DIRECT: return m_Mdl;
default: return NULL; }}
WDFMEMORYFxRequestOutputBuffer::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_OutputBufferOffset));}
USHORTFxRequestOutputBuffer::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();
ASSERT(irp->GetMajorFunction() == IRP_MJ_DEVICE_CONTROL || irp->GetMajorFunction() == IRP_MJ_INTERNAL_DEVICE_CONTROL);
switch (irp->GetParameterIoctlCodeBufferMethod()) { case METHOD_IN_DIRECT: return IFxMemoryFlagReadOnly;
case METHOD_BUFFERED: case METHOD_OUT_DIRECT: case METHOD_NEITHER: // since it is neither, we can't tell, so leave it as 0 default: return 0; }}
PFX_DRIVER_GLOBALSFxRequestOutputBuffer::GetDriverGlobals( VOID )/*++
Routine Description: Returns the driver globals
Arguments: none
Return Value: Driver globals pointer
--*/{ return GetRequest()->GetDriverGlobals();}
ULONGFxRequestOutputBuffer::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();
return 2;}
ULONGFxRequestOutputBuffer::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*FxRequestOutputBuffer::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_OutputBuffer);}
VOIDFxRequestOutputBuffer::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);}