ndis-drv.rar

  • PUDN用户
    了解作者
  • Visual C++
    开发工具
  • 1.1MB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 6
    下载次数
  • 2011-07-20 17:27
    上传日期
使用visual c++编写的一个ndis驱动程序,功能简单,但是可作为学习编写驱动的案例
ndis-drv.rar
  • ndis-drv
  • pstub.c
    898B
  • config.c
    11.4KB
  • send.h
    1.5KB
  • wdmsup.sbr
    271.9KB
  • status.sbr
    271.3KB
  • config.sbr
    273KB
  • recv.h
    2.2KB
  • ImSamp.sys
    151.6KB
  • globals.c
    2.2KB
  • status.c
    2.1KB
  • main.sbr
    273.3KB
  • send.sbr
    273KB
  • MAKEFILE
    247B
  • pstub.sbr
    270.9KB
  • wdmsup.h
    431B
  • ndisreq.h
    2.9KB
  • Disk1
    27B
  • d.bat
    104B
  • README.doc
    28.5KB
  • MSG00001.bin
    164B
  • globals.h
    12.3KB
  • recv.sbr
    276.6KB
  • config.h
    1.1KB
  • sources
    1KB
  • recv.c
    21.3KB
  • imsamp.h
    630B
  • evtmsg.rc
    37B
  • adapter.sbr
    280.4KB
  • ImSamp.rc
    645B
  • oemsetup.inf
    29.2KB
  • wdmsup.c
    5.5KB
  • globals.sbr
    271.6KB
  • ndisreq.sbr
    273.4KB
  • pstub.h
    554B
  • build.log
    7.4KB
  • packet.ini
    3.9KB
  • ndis.h
    236.2KB
  • debug.h
    14.1KB
  • send.c
    9.6KB
  • Mk_inst.bat
    360B
  • evtmsg.h
    2.7KB
  • ndisreq.c
    12.3KB
  • osdep.h
    1.4KB
  • recv.bak
    21.3KB
  • status.h
    597B
  • adapter.h
    1.7KB
  • adapter.c
    44KB
  • c.bat
    116B
  • main.c
    15.3KB
内容介绍
/*++ Copyright (c) 1996 Microsoft Corporation Module Name: adapter.c Abstract: routines for binding/unbinding to/from underlying miniport drivers Author: Jim Mateer 4-1-97 Environment: Kernel Mode Revision History: --*/ #include "ImSamp.h" #pragma hdrstop PADAPTER CurrentAdapter; VOID BindToLowerMP( OUT PNDIS_STATUS Status, IN NDIS_HANDLE BindContext, IN PNDIS_STRING MPDeviceName, IN PVOID SystemSpecific1, IN PVOID SystemSpecific2 ); STATIC NDIS_STATUS GetAdapterRegistryData( PNDIS_STRING IMParamsKey, PADAPTER Adapter ); STATIC VOID ProcessLowerMPOpenAdapter( IN PADAPTER Adapter, IN NDIS_STATUS Status ); VOID LowerMPOpenAdapterComplete( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_STATUS Status, IN NDIS_STATUS OpenErrorStatus ); STATIC NDIS_STATUS AllocatePacketPool( PADAPTER Adapter ); STATIC NDIS_STATUS AllocateReceiveBufferPools( PADAPTER Adapter ); //NDIS_STATUS //AddPipeToPSA( // PADAPTER Adapter // ); PADAPTER FindAdapterByInstanceNumber( #if BINARY_COMPATIBLE CHAR InstanceNumber #else WCHAR InstanceNumber #endif ); PADAPTER FindAdapterByName( PWCHAR AdapterName ); NDIS_STATUS MPInitialize( OUT PNDIS_STATUS OpenErrorStatus, OUT PUINT SelectedMediumIndex, IN PNDIS_MEDIUM MediumArray, IN UINT MediumArraySize, IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE WrapperConfigurationContext ); VOID UnbindFromLowerMP( OUT PNDIS_STATUS Status, IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE UnbindContext ); VOID DerefAdapter( PADAPTER Adapter ); VOID CleanupAdapter( PADAPTER Adapter ); VOID LowerMPCloseAdapterComplete( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_STATUS Status ); VOID CLUnloadProtocol( VOID ); VOID MPHalt( IN NDIS_HANDLE MiniportAdapterContext ); NDIS_STATUS MPReset( OUT PBOOLEAN AddressingReset, IN NDIS_HANDLE MiniportAdapterContext ); #if DBG VOID DumpAdapter( PADAPTER Adapter ); #endif #pragma NDIS_PAGEABLE_FUNCTION(BindToLowerMP) #pragma NDIS_PAGEABLE_FUNCTION(GetAdapterRegistryData) VOID BindToLowerMP( OUT PNDIS_STATUS Status, IN NDIS_HANDLE BindContext, IN PNDIS_STRING MPDeviceName, IN PVOID SystemSpecific1, IN PVOID SystemSpecific2 ) /*++ Routine Description: Bind to the underlying MP. Allocate space for an adapter structure, initializing its fields. Try to open the adapter indicated in MPDeviceName. Arguments: See the DDK... Return Values: None --*/ { PADAPTER Adapter; NDIS_STATUS OpenAdapterStatus; NDIS_STATUS OpenErrorStatus; NDIS_STATUS LocalStatus; NDIS_MEDIUM MediumArray[] = { NdisMediumFddi, NdisMedium802_5, NdisMedium802_3 }; UINT MediumArraySize = sizeof( MediumArray ) / sizeof( NDIS_MEDIUM ); UINT MediaIndex; ULONG AdapterStructSize; PAGED_CODE(); #if BINARY_COMPATIBLE ImDbgOut( DBG_INFO, DBG_PROTOCOL | DBG_INIT, ("BindToLowerMP: %s\n", MPDeviceName->Buffer )); #else ImDbgOut( DBG_INFO, DBG_PROTOCOL | DBG_INIT, ("BindToLowerMP: %ws\n", MPDeviceName->Buffer )); #endif // // allocate enough space for the structure and two unicode buffers to hold // the IM and underlying MP device names. We add an extra Unicode char to // to the IM device name to hold the instance char that is be appended later // on and another unicode char to separate the two strings for reading // AdapterStructSize = sizeof( ADAPTER ) + IMMPName.Length + MPDeviceName->Length + 2 * sizeof( UNICODE_NULL ); IMAllocatePool( Adapter, AdapterStructSize, Adapter ); if ( Adapter == NULL ) { PWCHAR StringData[2]; StringData[0] = IMDriverName.Buffer; StringData[1] = L"Adapter"; NdisWriteErrorLogEntry(IMDriverObject, (ULONG)EVENT_TRANSPORT_RESOURCE_POOL, 0, 2, &StringData, 0, NULL); *Status = NDIS_STATUS_RESOURCES; return; } // // set our state to initializing // Adapter->IMMPState = ADAPTER_STATE_INITIALIZING; // // make the device name point to the buffer allocated at the back of the // structure. // Adapter->IMDeviceName.MaximumLength = IMMPName.Length + sizeof( UNICODE_NULL ); Adapter->IMDeviceName.Length = Adapter->IMDeviceName.MaximumLength; Adapter->IMDeviceName.Buffer = (PWSTR)( Adapter + 1 ); Adapter->MPDeviceName.MaximumLength = MPDeviceName->Length; Adapter->MPDeviceName.Length = Adapter->MPDeviceName.MaximumLength; Adapter->MPDeviceName.Buffer = (PWSTR)((PCHAR)Adapter->IMDeviceName.Buffer + Adapter->IMDeviceName.MaximumLength + sizeof( UNICODE_NULL )); NdisMoveMemory( Adapter->MPDeviceName.Buffer, MPDeviceName->Buffer, MPDeviceName->Length ); LocalStatus = GetAdapterRegistryData( (PNDIS_STRING)SystemSpecific1, Adapter ); if ( !NT_SUCCESS( LocalStatus )) { #if BINARY_COMPATIBLE ImDbgOut(DBG_FAILURE, DBG_PROTOCOL | DBG_INIT, ("(%08X) BindToLowerMP: Couldn't get registry data %08X (%s)\n", Adapter, LocalStatus, MPDeviceName->Buffer )); #else ImDbgOut(DBG_FAILURE, DBG_PROTOCOL | DBG_INIT, ("(%08X) BindToLowerMP: Couldn't get registry data %08X (%ws)\n", Adapter, LocalStatus, MPDeviceName->Buffer )); #endif *Status = NDIS_STATUS_FAILURE; IMFreePool( Adapter ); return; } // // init the event now since we use it in the completion handler // // remember our binding context so we can complete BindAdapter later on // NdisInitializeEvent( &Adapter->BlockingEvent ); Adapter->BindContext = BindContext; // Open the adapter below us. NdisOpenAdapter(&OpenAdapterStatus, &OpenErrorStatus, &Adapter->LowerMPHandle, &MediaIndex, MediumArray, MediumArraySize, ClientProtocolHandle, Adapter, MPDeviceName, 0, NULL); // // Memphis doesn't like you to do NdisRequests from within the OpenAdapterComplete // handler so wait for OpenAdapterComplete to finish and then do the follow up // processing. // if ( OpenAdapterStatus == NDIS_STATUS_PENDING ) { NdisWaitEvent( &Adapter->BlockingEvent, 0 ); NdisResetEvent( &Adapter->BlockingEvent ); } else { Adapter->FinalStatus = OpenAdapterStatus; } if ( NT_SUCCESS( Adapter->FinalStatus )) { Adapter->MediaType = MediumArray[ MediaIndex ]; } ProcessLowerMPOpenAdapter( Adapter, Adapter->FinalStatus ); *Status = Adapter->FinalStatus; } // BindToLowerMP STATIC NDIS_STATUS GetAdapterRegistryData( PNDIS_STRING IMParamsKey, PADAPTER Adapter ) /*++ Routine Description: Obtain the IMSamp specific info associated with the underlying MP Arguments: IMParamsKey - location in the registry Adapter - pointer to adapter context struct Return Value: NDIS_STATUS_SUCCESS if everything worked ok --*/ { NDIS_STATUS Status; NDIS_HANDLE ConfigHandle; NDIS_STRING IMInstanceNumberKey = NDIS_STRING_CONST( "InstanceNumber" );
评论
    相关推荐
    • ndis.rar
      ndis各方面的函数介绍,没有函数原型,简单的函数名和功能说明
    • ndis.zip
      ndis 6 simple driver
    • wdm usb ndis
      wdm usb ndis windows驱动
    • rtl8139 ndis
      rtl8139 ndis 网卡驱动 windows
    • NDIS2 for Marvell
      联想M7100系列电脑DOS版marvell网卡驱动,网络GHOST必需
    • NDIS函数简明手册
      函数 描述 无连接微端口的上层函数 DriverEntry 由操作系统调用来激活和初始化微端口驱动程序 MiniportAllocateComple 调用它来指示以前调用的NdisMAllocateMemoryAsync 已经完成 MiniportCheckForHang ...
    • 微软的一个ndis驱动程序例子
      其实不只是在远程启动这一层,只要是网卡的驱动盘,大家都会在里面发现有类似 NDISNDIS2、NDIS3、NDIS4一样的目录,只是大家在 Windows 9x 或 NT 中安装、设置网卡时没有注意到它罢了。但即使大搞特搞 RPL 的朋友...
    • NDIS协议驱动开发
      从网上找的。NDIS协议驱动开发的笔记,代码。
    • NDIS 6.0 Filter Driver
      NDIS 6.x LightWeight Filter , Windows Driver , Smaple , Networking , replacement of NDIS 5 Sample Intermediate Driver (Passthru driver)
    • NDIS防火墙以及嗅探
      一个NDIS防火墙项目,支持协议字段过滤器、URL过滤器、进程过滤器,支持捕获原始以太帧、发送以太帧;自定义网络访问控制WINPCAP的所有功能。 使用C++封装了NDIS驱动,开发者可以使用g_FireWall即可实现所有功能...