#include <wdm.h>



#define EFLAGS_IF_MASK 512


#define FILE_AUTOGENERATED_DEVICE_NAME  128
#define FILE_DEVICE_DISK_FILE_SYSTEM    8
#define FILE_DEVICE_NETWORK_FILE_SYSTEM 20
#define FILE_DEVICE_SECURE_OPEN         256
#define FILE_DEVICE_TAPE_FILE_SYSTEM    32

#define IRP_MJ_CREATE 0
#define IRP_MJ_CREATE_NAMED_PIPE 1
#define IRP_MJ_CLOSE 2
#define IRP_MJ_READ 3
#define IRP_MJ_WRITE 4
#define IRP_MJ_DEVICE_CONTROL 14
#define IRP_MJ_INTERNAL_DEVICE_CONTROL 15
#define IRP_MJ_POWER 22


#define IRP_MN_REMOVE_DEVICE 2
#define IRP_MN_START_DEVICE 0
#define IRP_MN_SURPRISE_REMOVAL 23

#define IRP_MN_CANCEL_STOP_DEVICE 6
#define IRP_MN_CANCEL_REMOVE_DEVICE 3

#define IRP_MN_WAIT_WAKE         0
#define IRP_MN_QUERY_STOP_DEVICE 5
#define IRP_MN_QUERY_REMOVE_DEVICE 1
#define IRP_MN_QUERY_DEVICE_RELATIONS 7
#define IRP_MN_QUERY_INTERFACE 8
#define IRP_MN_QUERY_CAPABILITIES 9
#define IRP_MN_QUERY_RESOURCES 10
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS 11
#define IRP_MN_QUERY_DEVICE_TEXT 12
#define IRP_MN_QUERY_ID 19
#define IRP_MN_QUERY_PNP_DEVICE_STATE 20
#define IRP_MN_QUERY_BUS_INFORMATION 21
#define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 24

#define IO_TYPE_ADAPTER                 1
#define IO_TYPE_CONTROLLER              2
#define IO_TYPE_DEVICE                  3
#define IO_TYPE_DRIVER                  4
#define IO_TYPE_FILE                    5
#define IO_TYPE_IRP                     6
#define IO_TYPE_MASTER_ADAPTER          7
#define IO_TYPE_OPEN_PACKET             8
#define IO_TYPE_TIMER                   9
#define IO_TYPE_VPB                     10
#define IO_TYPE_ERROR_LOG               11
#define IO_TYPE_ERROR_MESSAGE           12
#define IO_TYPE_DEVICE_OBJECT_EXTENSION 13

#define NT_SUCCESS(Status) (Status >= 0)
#define NULL 0

#define PowerDeviceD3 4
#define PowerDeviceD2 3
#define PowerDeviceD1 2
#define PowerDeviceD0 1

#define STATUS_NOT_SUPPORTED 3221225659
#define STATUS_PENDING 259
#define STATUS_SUCCESS 0

#define IRP_MJ_PNP 27

#define WMIREG_ACTION_REGISTER      1
#define WMIREG_ACTION_DEREGISTER    2

#define KernelMode 0
#define UserMode 1
#define MaximumMode 2

#define BusRelations 0
#define EjectionRelations 1
#define PowerRelations 2
#define RemovalRelations 3
#define TargetDeviceRelation 4
#define SingleBusRelations 5



#define NonPagedPool 0
#define PagedPool 1
#define NonPagedPoolMustSucceed 2
#define DontUseThisType 3
#define NonPagedPoolCacheAligned 4
#define PagedPoolCacheAligned 5
#define NonPagedPoolCacheAlignedMustS 6
#define MaxPoolType 7

#define  NonPagedPoolBase 0
#define  NonPagedPoolBaseMustSucceed 2
#define  NonPagedPoolBaseCacheAligned 4
#define  NonPagedPoolBaseCacheAlignedMustS 6


#define  NonPagedPoolSession 32
#define  PagedPoolSession 33
#define  NonPagedPoolMustSucceedSession 34
#define  DontUseThisTypeSession 35
#define  NonPagedPoolCacheAlignedSession 36
#define  PagedPoolCacheAlignedSession 37
#define  NonPagedPoolCacheAlignedMustSSession 38
#define  NonPagedPoolNx 512
#define  NonPagedPoolNxCacheAligned 516
#define  NonPagedPoolSessionNx 544

#define NonPagedPool ExDefaultNonPagedPoolType

#define OBJ_KERNEL_HANDLE 512


/*
  IRQL

  The SDV Rules specifies IRQL requirements for various DDIs.

  The IRQLs are positive ordered numbers starting from 0.  The actual
  numbers are processer specific, on X86 ranging from 0 to 31 and on
  AMD64 and IA64 ranging from 0 to 15.  For all three platforms
  PASSIVE_LEVEL, APC_LEVEL and DISPATCH_LEVEL are respectively 0, 1
  and 2.

  SDV rules only distinguish between the concrete values
  PASSIVE_LEVEL, APC_LEVEL, DISPATCH_LEVEL and the predicate
  SDV_IRQL_ELEVATED_LEVEL for 'everything else' (3-31 on X86, 3-15 on
  AMD64 or IA64).  The SDV rules are unable to distinguish between
  DIRQL, CMC_LEVEL, HIGH_LEVEL, etc.  The OS header files provide the
  equivalent macro definitions except for the SDV_IRQL_ELEVATED_LEVEL
  predicate.

  The SDV OS Model declares the SDV_DIRQL macro for elevating to an
  arbitrary Device IRQL.  The definition of SDV_DIRQL and the
  definition of SDV_IRQL_ELEVATED_LEVEL implies that
  SDV_IRQL_ELEVATED_LEVEL(SDV_DIRQL)==TRUE.

  See the article "Scheduling, Thread Context, and IRQL" for more
  details.
*/

#define PASSIVE_LEVEL 0 
#define APC_LEVEL 1 
#define DISPATCH_LEVEL 2 

#define SDV_IRQL_ELEVATED_LEVEL(irql) ((irql)!=PASSIVE_LEVEL && (irql)!=APC_LEVEL && (irql)!=DISPATCH_LEVEL)


#define STACKL Tail.Overlay.CurrentStackLocation


#define	FILE_DEVICE_8042_PORT	39
#define	FILE_DEVICE_ACPI	50
#define	FILE_DEVICE_BATTERY	41
#define	FILE_DEVICE_BEEP	1
#define	FILE_DEVICE_BUS_EXTENDER	42
#define	FILE_DEVICE_CD_ROM	2
#define	FILE_DEVICE_CD_ROM_FILE_SYSTEM	3
#define	FILE_DEVICE_CHANGER	48
#define	FILE_DEVICE_CONTROLLER	4
#define	FILE_DEVICE_DATALINK	5
#define	FILE_DEVICE_DFS	6
#define	FILE_DEVICE_DFS_FILE_SYSTEM	53
#define	FILE_DEVICE_DFS_VOLUME	54
#define	FILE_DEVICE_DISK	7
#define	FILE_DEVICE_DISK_FILE_SYSTEM	8
#define	FILE_DEVICE_DVD	51
#define	FILE_DEVICE_FILE_SYSTEM	9
#define	FILE_DEVICE_FIPS	58
#define	FILE_DEVICE_FULLSCREEN_VIDEO	52
#define	FILE_DEVICE_INPORT_PORT	10
#define	FILE_DEVICE_KEYBOARD	11
#define	FILE_DEVICE_KS	47
#define	FILE_DEVICE_KSEC	57
#define	FILE_DEVICE_MAILSLOT	12
#define	FILE_DEVICE_MASS_STORAGE	45
#define	FILE_DEVICE_MIDI_IN	13
#define	FILE_DEVICE_MIDI_OUT	14
#define	FILE_DEVICE_MODEM	43
#define	FILE_DEVICE_MOUSE	15
#define	FILE_DEVICE_MULTI_UNC_PROVIDER	16
#define	FILE_DEVICE_NAMED_PIPE	17
#define	FILE_DEVICE_NETWORK	18
#define	FILE_DEVICE_NETWORK_BROWSER	19
#define	FILE_DEVICE_NETWORK_FILE_SYSTEM	20
#define	FILE_DEVICE_NETWORK_REDIRECTOR	40
#define	FILE_DEVICE_NULL	21
#define	FILE_DEVICE_PARALLEL_PORT	22
#define	FILE_DEVICE_PHYSICAL_NETCARD	23
#define	FILE_DEVICE_PRINTER	24
#define	FILE_DEVICE_SCANNER	25
#define	FILE_DEVICE_SCREEN	28
#define	FILE_DEVICE_SERENUM	55
#define	FILE_DEVICE_SERIAL_MOUSE_PORT	26
#define	FILE_DEVICE_SERIAL_PORT	27
#define	FILE_DEVICE_SMARTCARD	49
#define	FILE_DEVICE_SMB	46
#define	FILE_DEVICE_SOUND	29
#define	FILE_DEVICE_STREAMS	30
#define	FILE_DEVICE_TAPE	31
#define	FILE_DEVICE_TAPE_FILE_SYSTEM	32
#define	FILE_DEVICE_TERMSRV	57
#define	FILE_DEVICE_TRANSPORT	33
#define	FILE_DEVICE_UNKNOWN	34
#define	FILE_DEVICE_VDM	44
#define	FILE_DEVICE_VIDEO	35
#define	FILE_DEVICE_VIRTUAL_DISK	36
#define	FILE_DEVICE_WAVE_IN	37
#define	FILE_DEVICE_WAVE_OUT	38


#define DO_VERIFY_VOLUME                    2      
#define DO_BUFFERED_IO                      4      
#define DO_EXCLUSIVE                        8      
#define DO_DIRECT_IO                        16      
#define DO_MAP_IO_BUFFER                    32      
#define DO_DEVICE_INITIALIZING              128      
#define DO_SHUTDOWN_REGISTERED              2048      
#define DO_BUS_ENUMERATED_DEVICE            4096      
#define DO_POWER_PAGABLE                    8192      
#define DO_POWER_INRUSH                     16384

/*

#define PowerSystemUnspecified    0
#define	PowerSystemWorking        1
#define	PowerSystemSleeping1      2
#define	PowerSystemSleeping2      3
#define	PowerSystemSleeping3      4
#define	PowerSystemHibernate      5
#define	PowerSystemShutdown       6
#define	PowerSystemMaximum        7 


#define  PowerDeviceUnspecified  0
#define  PowerDeviceD0 1
#define  PowerDeviceD1 2
#define  PowerDeviceD2 3
#define  PowerDeviceD3 4
#define  PowerDeviceMaximum 5*/
