/*++

    Copyright (c) Microsoft Corporation.  All rights reserved.

Rule Name:

    StartIoCancel

Domain:

    wdm

Rule ID:

    Not Applicable

Description:

    This rule verifies that if IoSetCancelRoutine is called with a
    non-null cancel routine then IoSetStartIoAttributes should
    have been called earlier with the noncancellable attribute set
    to false.

Help Link:

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

--*/

#include "slic_base.h"


state {

    int setNonCancellable  = 0; 


    int nonCancellableAttr = 0;
}



IoSetStartIoAttributes.entry 
{ 
    setNonCancellable = 1;
    nonCancellableAttr = $3;
}



IoSetCancelRoutine.entry 
{
    if (  setNonCancellable==1
       && nonCancellableAttr==0 
       && $2!=NULL
       )
    {
        abort "There is a potential for cancellation race. IoSetStartIoAttributes is being called with NonCancellable set to false. Then a non-NULL cancel routine has been passed to IoSetCancelRoutine.";
    }
}
