/*++

    Copyright (c) Microsoft Corporation.  All rights reserved.

Rule Name:

    ForwardedAtBadIrql

Domain:

    wdm

Rule ID:

    Not Applicable

Description:

    The ForwardedAtBadIrql rule specifies that the driver call
    IoCallDriver and PoCallDriver at IRQL<DISPATCH_LEVEL unless
    the IRP major function code being forwarded is one of the
    following:
		IRP_MJ_POWER 
		IRP_MJ_READ 
		IRP_MJ_WRITE 
		IRP_MJ_DEVICE_CONTROL 
		IRP_MJ_INTERNAL_DEVICE_CONTROL

Help Link:

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

--*/






#include "slic_base.h"
state{
   
}with guard(sdv_main,sdv_irp)

[IoCallDriver,PoCallDriver].entry[guard $2]
{
    if(($2->Tail.Overlay.CurrentStackLocation->MajorFunction==IRP_MJ_POWER)
       ||($2->Tail.Overlay.CurrentStackLocation->MajorFunction==IRP_MJ_READ)
       ||($2->Tail.Overlay.CurrentStackLocation->MajorFunction==IRP_MJ_WRITE)
       ||($2->Tail.Overlay.CurrentStackLocation->MajorFunction==IRP_MJ_DEVICE_CONTROL)
       ||($2->Tail.Overlay.CurrentStackLocation->MajorFunction==IRP_MJ_INTERNAL_DEVICE_CONTROL))
    {
        halt;
    }
    else if ( sdv_irql_current >= DISPATCH_LEVEL ) 
    {
         abort "The driver is forwarding an IRP at an IRQL that is illegal for the IRP's major code";
    }
    else
    {
        halt;
    }
}
