/*++

    Copyright (c) Microsoft Corporation.  All rights reserved.

Rule Name:

    EvtIoStopResume

Domain:

    wdf

Rule ID:

    Not Applicable

Description:

    This rule checks that if a driver registers EvtIoStop and calls WdfRequestStopAcknowledge with $2 equal to false 
    then the driver's should register a EvtIoResume callback, as the framework will deliver requests to the EvtIoResume callback 
	when the device enter D0 state again.

  Rule diagnostics:
  "This rule checks that if a driver registers EvtIoStop and calls WdfRequestStopAcknowledge with $2 equal to false 
   then the driver's should register a EvtIoResume callback. As the framework will deliver requests to the EvtIoResume callback
   when the device enter D0 state again."


Help Link:

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

--*/


#include "slic_base.h"

state{
     enum {INIT, INSTOP} s = INIT;
     enum {INIT1, RESUMEREQUIRED} r = INIT1;
}with guard (sdv_main, hrequest)

[fun_WDF_IO_QUEUE_IO_STOP].entry[guard $2]
{
    s = INSTOP;               
	
}
[fun_WDF_IO_QUEUE_IO_STOP].exit[guard $2]
{   
    s= INIT;
}
[sdv_WdfRequestStopAcknowledge].entry[guard $1]
{
   if((s == INSTOP)&&($2==0))
   {
      r = RESUMEREQUIRED;
   }
   else
   {
      halt;
   }
}

[fun_WDF_IO_QUEUE_IO_RESUME].entry[guard $2]
{
    r = INIT1;
}

sdv_main.exit
{
	   
    if(r==RESUMEREQUIRED) 
    {
      abort "WARNING: if a driver registers EvtIoStop and calls WdfRequestStopAcknowledge with $2 equal to false then the driver should register a EvtIoResume callback. As the framework will deliver requests to the EvtIoResume callback when the device enters D0 state again.";
    }
}

