/*++

    Copyright (c) Microsoft Corporation.  All rights reserved.

Rule Name:

    IoAllocateForward

Domain:

    wdm

Rule ID:

    Not Applicable

Description:

    A completion routine must be set before call IoCallDriver or PoCallDriver if the IRP is generated by a call to IoAllocateIrp.

Help Link:

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

--*/


#include "slic_base.h"

state
{
    enum {initial,completion_set} forward_state = initial;
}
watch IoAllocateIrp.exit.$return;

IoAllocateIrp.exit[guard $return]
{
    if($return==NULL)
    {
        halt;
    }
}

IoSetCompletionRoutineEx.exit[guard $2]
{
    forward_state=completion_set;
}

IoSetCompletionRoutine.exit[guard $1]
{
    forward_state=completion_set;
}

[IoCallDriver,PoCallDriver].entry[guard $2]
{
    if(forward_state!=completion_set)
    {
        abort "A completion routine must be set before call $fname if the irp is generated by a call to IoAllocateIrp.";
    }
    else
    {
        halt;
    }
}
