/*++
Copyright(c) 1992-2000 Microsoft Corporation
Module Name:
protocol.c
Abstract:
Ndis Intermediate Miniport driver sample. This is a passthru driver.
Author:
Environment:
Revision History:
--*/
#include "precomp.h"
#pragma hdrstop
#define MAX_PACKET_POOL_SIZE 0x0000FFFF
#define MIN_PACKET_POOL_SIZE 0x000000FF
NDIS_STATUS AnalysisPacket(PNDIS_PACKET Packet, BOOLEAN bRecOrSend);
//
// NDIS version as 0xMMMMmmmm, where M=Major/m=minor (0x00050001 = 5.1);
// initially unknown (0)
//
ULONG NdisDotSysVersion = 0x0;
#define NDIS_SYS_VERSION_51 0x00050001
VOID
PtBindAdapter(
OUT PNDIS_STATUS Status,
IN NDIS_HANDLE BindContext,
IN PNDIS_STRING DeviceName,
IN PVOID SystemSpecific1,
IN PVOID SystemSpecific2
)
/*++
Routine Description:
Called by NDIS to bind to a miniport below.
Arguments:
Status - Return status of bind here.
BindContext - Can be passed to NdisCompleteBindAdapter if this call is pended.
DeviceName - Device name to bind to. This is passed to NdisOpenAdapter.
SystemSpecific1 - Can be passed to NdisOpenProtocolConfiguration to read per-binding information
SystemSpecific2 - Unused
Return Value:
NDIS_STATUS_PENDING if this call is pended. In this case call NdisCompleteBindAdapter
to complete.
Anything else Completes this call synchronously
--*/
{
NDIS_HANDLE ConfigHandle = NULL;
PNDIS_CONFIGURATION_PARAMETER Param;
NDIS_STRING DeviceStr = NDIS_STRING_CONST("UpperBindings");
NDIS_STRING NdisVersionStr = NDIS_STRING_CONST("NdisVersion");
PADAPT pAdapt = NULL;
NDIS_STATUS Sts;
UINT MediumIndex;
ULONG TotalSize;
BOOLEAN NoCleanUpNeeded = FALSE;
UNREFERENCED_PARAMETER(BindContext);
UNREFERENCED_PARAMETER(SystemSpecific2);
DBGPRINT(("==> Protocol BindAdapter\n"));
do
{
//
// Access the configuration section for our binding-specific
// parameters.
//
NdisOpenProtocolConfiguration(Status,
&ConfigHandle,
SystemSpecific1);
if (*Status != NDIS_STATUS_SUCCESS)
{
break;
}
if (NdisDotSysVersion == 0)
{
NdisReadConfiguration(Status,
&Param,
ConfigHandle,
&NdisVersionStr, // "NdisVersion"
NdisParameterInteger);
if (*Status != NDIS_STATUS_SUCCESS)
{
break;
}
NdisDotSysVersion = Param->ParameterData.IntegerData;
}
//
// Read the "UpperBindings" reserved key that contains a list
// of device names representing our miniport instances corresponding
// to this lower binding. Since this is a 1:1 IM driver, this key
// contains exactly one name.
//
// If we want to implement a N:1 mux driver (N adapter instances
// over a single lower binding), then UpperBindings will be a
// MULTI_SZ containing a list of device names - we would loop through
// this list, calling NdisIMInitializeDeviceInstanceEx once for
// each name in it.
//
NdisReadConfiguration(Status,
&Param,
ConfigHandle,
&DeviceStr,
NdisParameterString);
if (*Status != NDIS_STATUS_SUCCESS)
{
break;
}
//
// Allocate memory for the Adapter structure. This represents both the
// protocol context as well as the adapter structure when the miniport
// is initialized.
//
// In addition to the base structure, allocate space for the device
// instance string.
//
TotalSize = sizeof(ADAPT) + Param->ParameterData.StringData.MaximumLength;
NdisAllocateMemoryWithTag(&pAdapt, TotalSize, TAG);
if (pAdapt == NULL)
{
*Status = NDIS_STATUS_RESOURCES;
break;
}
//
// Initialize the adapter structure. We copy in the IM device
// name as well, because we may need to use it in a call to
// NdisIMCancelInitializeDeviceInstance. The string returned
// by NdisReadConfiguration is active (i.e. available) only
// for the duration of this call to our BindAdapter handler.
//
NdisZeroMemory(pAdapt, TotalSize);
pAdapt->DeviceName.MaximumLength = Param->ParameterData.StringData.MaximumLength;
pAdapt->DeviceName.Length = Param->ParameterData.StringData.Length;
pAdapt->DeviceName.Buffer = (PWCHAR)((ULONG_PTR)pAdapt + sizeof(ADAPT));
NdisMoveMemory(pAdapt->DeviceName.Buffer,
Param->ParameterData.StringData.Buffer,
Param->ParameterData.StringData.MaximumLength);
NdisInitializeEvent(&pAdapt->Event);
NdisAllocateSpinLock(&pAdapt->Lock);
//
// Allocate a packet pool for sends. We need this to pass sends down.
// We cannot use the same packet descriptor that came down to our send
// handler (see also NDIS 5.1 packet stacking).
//
NdisAllocatePacketPoolEx(Status,
&pAdapt->SendPacketPoolHandle,
MIN_PACKET_POOL_SIZE,
MAX_PACKET_POOL_SIZE - MIN_PACKET_POOL_SIZE,
sizeof(SEND_RSVD));
if (*Status != NDIS_STATUS_SUCCESS)
{
break;
}
//
// Allocate a packet pool for receives. We need this to indicate receives.
// Same consideration as sends (see also NDIS 5.1 packet stacking).
//
NdisAllocatePacketPoolEx(Status,
&pAdapt->RecvPacketPoolHandle,
MIN_PACKET_POOL_SIZE,
MAX_PACKET_POOL_SIZE - MIN_PACKET_POOL_SIZE,
PROTOCOL_RESERVED_SIZE_IN_PACKET);
if (*Status != NDIS_STATUS_SUCCESS)
{
break;
}
//
// Now open the adapter below and complete the initialization
//
NdisOpenAdapter(Status,
&Sts,
&pAdapt->BindingHandle,
&MediumIndex,
MediumArray,
sizeof(MediumArray)/sizeof(NDIS_MEDIUM),
ProtHandle,
pAdapt,
DeviceName,
0,
NULL);
if (*Status == NDIS_STATUS_PENDING)
{
NdisWaitEvent(&pAdapt->Event, 0);
*Status = pAdapt->Status;
}
if (*Status != NDIS_STATUS_SUCCESS)
{
break;
}
PtReferenceAdapt(pAdapt);
#pragma prefast(suppress: __WARNING_POTENTIAL_BUFFER_OVERFLOW, "Ndis guarantees MediumIndex to be within bounds");
pAdapt->Medium = MediumArray[MediumIndex];
//
// Now ask NDIS to initialize our miniport (upper) edge.
// Set the flag below to synchronize with a
没有合适的资源?快使用搜索试试~ 我知道了~
简单的防火墙驱动程序
共82个文件
obj:11个
h:10个
pdb:6个
4星 · 超过85%的资源 需积分: 10 20 下载量 62 浏览量
2011-08-30
21:29:23
上传
评论
收藏 5.29MB RAR 举报
温馨提示
本程序是通过在小端口层和协议层之间添加一些过滤规则,来实现简单的网络信息过滤
资源推荐
资源详情
资源评论
收起资源包目录
实验4.rar (82个子文件)
实验4
vc
bin
NdisIF.ilk 262KB
netsf_m.inf 3KB
TestNdis.ilk 185KB
NdisIF.dll 220KB
PassthruInstall.exe 24KB
TestNdis.exe 108KB
netsf.inf 5KB
passthruc.dsw 1009B
NdisIF
StdAfx.cpp 293B
NdisIF.plg 2KB
NdisIF.dsp 4KB
NdisIF.h 735B
NdisIF.cpp 2KB
Debug
NdisIF.exp 739B
vc60.pdb 196KB
NdisIF.pch 2.61MB
NdisIF.sbr 1KB
vc60.idb 97KB
StdAfx.obj 65KB
NdisIF.pdb 537KB
NdisIF.lib 2KB
StdAfx.sbr 492KB
NdisIF.obj 5KB
StdAfx.h 1012B
passthruc.opt 60KB
passthruc.ncb 217KB
CommonIO.h 794B
使用说明.doc 39KB
sys
sources 856B
resource.h 455B
protocol.c 48KB
passthru.htm 26KB
netsf_m.inf 3KB
passthruc.plg 1KB
miniport.c 43KB
makefile 689B
passthru.aps 3KB
Build.bat 531B
buildchk_win7_x86.log 4KB
Debug
passthru.rc 3KB
Hook.c 3KB
precomp.h 481B
passthru.c 15KB
objfre_win7_x86
i386
objchk_win7_x86
i386
passthru.res 972B
analysispacket.obj 15KB
precomp.pch 3.06MB
precomp.obj 190KB
passthru.pdb 819KB
pch_hdr.src 22B
protocol.obj 34KB
miniport.obj 27KB
passthru.obj 20KB
hook.obj 9KB
vc90.pdb 508KB
_objects.mac 439B
precomp.oacr.pft.pchast 5.5MB
analysispacket.c 8KB
passthruc.dsp 4KB
netsf.inf 5KB
passthru.h 14KB
TestNdis
TestNdis.cpp 2KB
TestNdis.rc 6KB
StdAfx.cpp 210B
resource.h 1KB
TestNdisDlg.h 2KB
TestNdis.h 1KB
Debug
TestNdisDlg.obj 29KB
vc60.pdb 356KB
TestNdis.obj 13KB
vc60.idb 209KB
TestNdis.res 3KB
TestNdis.pch 5.25MB
StdAfx.obj 103KB
TestNdis.pdb 273KB
TestNdis.plg 753B
TestNdis.aps 35KB
StdAfx.h 1KB
TestNdis.dsp 4KB
TestNdis.clw 1KB
res
TestNdis.rc2 400B
TestNdis.ico 1KB
TestNdisDlg.cpp 6KB
共 82 条
- 1
资源评论
- zj88231292012-12-17程序还不错,但是文档不是很清晰
- y469222013-01-02还可以 有些有用
- kmxierong2012-07-08这个程序不错,可以用
huangjinli73
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功