⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myioctl.h

📁 利用C++工具进行编程,NDIS的PASSTHRU层的驱动程序,是非常实用的程序.
💻 H
字号:
#ifndef _MyIoCtl_H_
#define _MyIoCtl_H_

/******************Io_Ctl_code.****************/
#define IOCTL_MYGUI_REINIT_FILTER CTL_CODE(	\
			FILE_DEVICE_UNKNOWN,			\
			0x801,							\
			METHOD_BUFFERED,				\
			FILE_ANY_ACCESS)

#define IOCTL_MYGUI_ADD_FILTER CTL_CODE(	\
			FILE_DEVICE_UNKNOWN,			\
			0x802,							\
			METHOD_BUFFERED,				\
			FILE_ANY_ACCESS)

#define IOCTL_MYGUI_DELETE_FILTER CTL_CODE(	\
			FILE_DEVICE_UNKNOWN,			\
			0x803,							\
			METHOD_BUFFERED,				\
			FILE_ANY_ACCESS)


#define IOCTL_MYGUI_ZERO_PACKET_BUFFER CTL_CODE(	\
			FILE_DEVICE_UNKNOWN,			\
			0x811,							\
			METHOD_BUFFERED,				\
			FILE_ANY_ACCESS)

#define IOCTL_MYGUI_RESIZE_PACKET_BUFFER CTL_CODE(	\
			FILE_DEVICE_UNKNOWN,			\
			0x812,							\
			METHOD_BUFFERED,				\
			FILE_ANY_ACCESS)

/*****************************************************/

/*Define the packet's type*/
#define IP			0x0008

/*Define the protocol 's Id.*/
#define ICMP		0x01
#define IGMP		0x02
#define TCP			0x06
#define UDP			0x11


/*****************Gui Input Command***********************/

/*The Gui Output Buffer Structure.

|--------------|--------------------|
| SuccessOrNot | Output  Paramerter |
|--------------|--------------------|
*/
typedef U32 CmdRetFlag;

#define CmdRetSuccess		(0x00000000)

#define CmdRetFail			(0x80000000)


/*****************Gui Input Filter Item********************/

/*GUI Filter Type Struture*/
typedef struct tagGuiFilterItem
{
	FilterType GuiFilterType;
	U16		   Reserved;//Only to Align.
	U32		   GuiFilterLen;//the size of	(FilterContext) 
								//		And (Param).
}GuiFilterItem;

/*Filter Type.
				(typedef U16 FilterType)

0          1           8         32            
|---------|-----------|---------|
| CpyFlag | Direction | Operate |
|---------|-----------|---------|
*/

#define NullFilter			(0x0000)

//CpyFlag.bit0.
#define CopyFlag	0x8000
#define FilterFlag	0x0000


//Direction.
#define FilterAllDirection	(0x7000)

#define FilterReceive		(0x1000)
#define FilterSend			(0x2000)

//Operate.
#define FilterAllOperate	(0x0fff)

//#define FilterPhycicalIp	(0x0001)
//#define FilterEthProto		(0x0002)
#define FilterIp			(0x0004)
#define FilterIpProto		(0x0005)


//Receive.
//#define FilterPhyIpRec		(FilterReceive | FilterPhycicalIp)
//#define FilterEthProtoRec	(FilterReceive | FilterEthProto)
#define FilterIpRec			(FilterReceive | FilterIp)
#define FilterIpProtoRec	(FilterReceive | FilterIpProto)



//Send.
//#define FilterPhyIpSend		(FilterSend | FilterPhycicalIp)
//#define FilterEthProtoSend	(FilterSend	| FilterEthProto)
#define FilterIpSend		(FilterSend | FilterIp)
#define FilterIpProtoSend	(FilterSend | FilterIpProto)

//Filter All packet.
#define FilterAll			(FilterAllDirection | FilterAllOperate)

//Get the filter type's property.
#define GetFilterTypeCopy(inputFilterType)		\
				((inputFilterType) & 0x8000)

#define GetFilterTypeDirect(inputFilterType)	\
				((inputFilterType) & 0x7000)

#define GetFilterTypeOperate(inputFilterType)	\
				((inputFilterType) & 0x0fff)


/*Define the Operate in the middle of FilterType.*/
typedef U16 OperateType;

/*Operate Type.*/
#define NullOperateType		(0x0000)
#define OrOperateType		(0x0001)
#define AndOperateType		(0x0002)


/*GUI Filter Buffer structure of context.*/
//Indicate which to be filtered.
typedef struct tagFilterContext
{
	U8				Include;//Zero--Exclude.
							//NoZero--Include.
		
	//Region: Min---Max be defined.	

/*	PhycicalAddress MinPhycicalIp;
	PhycicalAddress	MaxPhycicalIp;
	OperateType		PhycicalIpOperate;
	
	U16				MinEtherProto;
	U16				MaxEtherProto;
	OperateType		EtherProtoOperate;
*/	
	IpAddress		MinSrcIp;
	IpAddress		MaxSrcIp;
	OperateType		SrcIpOperate;

	IpAddress		MinDestIp;
	IpAddress		MaxDestIp;
	OperateType		DestIpOperate;

	U8				MinIpProtocol;
	U8				MaxIpProtocol;
	OperateType		IpProtoOperate;

	//Indicate whether have protocol handle.
	//If have be the number of protocol,
	//else be Zero.
	U8				SpecialProtocolFlag;

}FilterContext;

/*Parameter of Special Protocol*/

//Tcp Parameter.
//Note : Remember call the function : LittleToBigEndianShort(port)
//			To let the compare be smart.
typedef struct tagTcpParam{
	U16				MinSrcPort;
	U16				MaxSrcPort;
	OperateType		SrcPortOperate;

	U16				MinDestPort;
	U16				MaxDestPort;
	OperateType		DestPortOperate;
}TcpParam;

//Icmp Parameter.
typedef struct tagIcmpParam{
	U8				MinType;
	U8				MaxType;
	OperateType		TypeOperate;

	U8				MinCode;
	U8				MaxCode;
	OperateType		CodeOperate;
}IcmpParam;


/*The Gui Input Buffer Struture.
|------------|-----------|-----------|-----------------------|-------------|
| FilterType |           | FilterLen |   Gui Filter Context. |     Param   |
|------------|-----------|-----------|-----------------------|-------------|
|     GuiFilterItem                  |                       |     Other   |
|------------------------------------|-----------------------|-------------|
*/

//Get the special data from raw buffer.
#define GetGuiFilterItem(pInputBuf)			\
		((GuiFilterItem *)( (U8*)(pInputBuf) ))

#define GetGuiFilterContext(pInputBuf)		\
		((FilterContext *)( (U8*)(pInputBuf) + sizeof(GuiFilterItem) ))

#define GetGuiFuncParam(pInputBuf)			\
		( (U8*)(pInputBuf) + sizeof(GuiFilterItem) + sizeof(FilterContext) )



#endif//_MyIoCtl_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -