/*++

    Copyright (c) Microsoft Corporation.  All rights reserved.

Rule Name:

    NoIoQueuePurgeSynchronously

Domain:

    wdf

Rule ID:

    Not Applicable

Description:


    WDF Drivers shouldn't call WdfIoQueueStopSynchronously,WdfIoQueueDrainSynchronously,WdfIoQueueStopAndPurgeSynchronously and WdfIoQueuePurgeSynchronously from the following EvtIO queue object event callback functions

    EvtIoDefault 
    EvtIoDeviceControl 
    EvtIoInternalDeviceControl 
    EvtIoRead 
    EvtIoWrite 


Help Link:

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

--*/




#include "slic_base.h"

state
{
    enum {initial, EvtIoCallbacks} queue_callback_state = initial;
}

[fun_fun_WDF_IO_QUEUE_IO_DEFAULT,
 fun_WDF_IO_QUEUE_IO_READ,
 fun_WDF_IO_QUEUE_IO_WRITE,
 fun_WDF_IO_QUEUE_IO_DEVICE_CONTROL,
 fun_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL].entry
{
    queue_callback_state = EvtIoCallbacks;
}

[fun_fun_WDF_IO_QUEUE_IO_DEFAULT,
 fun_WDF_IO_QUEUE_IO_READ,
 fun_WDF_IO_QUEUE_IO_WRITE,
 fun_WDF_IO_QUEUE_IO_DEVICE_CONTROL,
 fun_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL].exit
{
    queue_callback_state=initial;
}



[WdfIoQueuePurgeSynchronously].entry
{
    if (queue_callback_state == EvtIoCallbacks) 
    {
        abort "$fname is shouldn't be called from the EvtIo callbacks.";
    }
}
