/*++

    Copyright (c) Microsoft Corporation.  All rights reserved.

Rule Name:

    OutputBufferAPI

Domain:

    wdf

Rule ID:

    Not Applicable

Description:

    This rule verifies that the correct APIs for buffer retrieval are used in the
    EvtIoWrite callback function.

    Within EvtIoWrite callback function, the following
    APIs cannot be called for buffer retrieval: WdfRequestRetrieveOutputBuffer,      
    WdfRequestRetrieveUnsafeUserOutputBuffer, WdfRequestRetrieveOutputWdmMdl, 
    WdfRequestRetrieveOutputMemory.

    Rule diagnostics: 
    "<name of the API> cannot be called for Request Buffer retrieval in EvtIoWrite callback."    


Help Link:

    https://go.microsoft.com/fwlink/?LinkId=507113

--*/




#include "slic_base.h"

state{
     enum {INIT, WRITE} s = INIT;
}with guard (sdv_main, hrequest)

fun_WDF_IO_QUEUE_IO_WRITE.entry[guard $2]
{
   s = WRITE;
}
fun_WDF_IO_QUEUE_IO_WRITE.exit[guard $2]
{
	halt;
}
[sdv_WdfRequestRetrieveOutputBuffer
,sdv_WdfRequestRetrieveUnsafeUserOutputBuffer
,sdv_WdfRequestRetrieveOutputWdmMdl
,sdv_WdfRequestRetrieveOutputMemory
].entry[guard $1]
{
   if (s == WRITE) 
   {
      abort "$fname cannot be called for Request Buffer retrieval in EvtIoWrite callback.";
   }
   
}
