驱动开发资料汇总 http://yexin218.javaeye.com/blog/557454

from : http://yexin218.javaeye.com/blog/557454

驱动开发资料汇总

本文主要记录关于网卡驱动从NDIS 5.1移植到6.0过程的错误信以及解决方法息总结。(纯属个人笔记)

  1. To run in the NDIS 6.0 environment, NDIS 5.x miniport drivers must be modified as follows:  Build Environment -->Replace the preprocessor definition NDIS51_MINIPORT_DRIVER with NDIS60_MINIPORT_DRIVER.  主要修改source文件中的两个编译条件    C_DEFINES=$(C_DEFINES) -DNDIS51_MINIPORT=1  C_DEFINES=$(C_DEFINES) -DNDIS51=1  修改成: C_DEFINES=$(C_DEFINES) -DNDIS60_MINIPORT=1C_DEFINES=$(C_DEFINES) -DNDIS60=1

  2. 倘若在更新代码过程中,由于一些旧的函数已经不被使用了,所以你需要重新在.h文件中定义新的函数(比如从MPInitialize到 MPInitializeEX等),而且你也在.c文件中实现了该函数,可是你可能在其他.c文件用到这个函数,可是编译器还是不错说该方法没有申明,比如error C2065: MPInitializeEX: undeclared identifier。=>1、如果你确定你已经申明(实现与否次要),那么没有找到其他的解决方法,试试看把驱动目录下的,objchk_wlh_x86目录删除,重新编译也许就能解决问题了。 2、如果上面的不管用,那还要考虑一种特殊情况:那就是在NDIS5.1的时候,经常会把一些是51特性的函数定义在一个//#ifdef NDIS51_MINIPORT里面,所以你现在是NDIS6.0,如果没有修改这个定义,自然找不到你的函数定义,所以检查看看~
  3. 关于Windows7中是否可以使用WlanEnumInterfaces 来显示虚拟网络接口?答案是:单张无线网卡的不行,如果有多张,未知。参考:On Windows 7 and later, the operating system installs a virtual device if a Hosted Network capable wireless adapter is present on the machine. This virtual device normally shows up in the “Network Connections Folder” as ‘Wireless Network Connection 2’ with a Device Name of ‘Microsoft Virtual WiFi Miniport adapter’ if the computer has a single wireless network adapter. This virtual device is used exclusively for performing software access point (SoftAP) connections and is not present in the list returned by the WlanEnumInterfaces function. The lifetime of this virtual device is tied to the physical wireless adapter. If the physical wireless adapter is disabled, this virtual device will be removed as well. This feature is also available on Windows Server 2008 R2 with the Wireless LAN Service installed.
  4. GUID结构以及输出:GUID结构如下:
    GUID结构如下:
    typedef struct _GUID
    {
    DWORD Data1;
    WORD Data2;
    WORD Data3;
    BYTE Data4[8];
    } GUID;

 GUID就是一个128位的16进制整数,GUID 的格式为“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,其中每个 x 是 0-9 或 a-f 范围内的一个十六进制的数字。参考关于GUID. 如果使用GetAdatperAddress()方法读取出NET_IF_NETWORK_GUID.

 

  1. char szBuf[64];   
  2.     sprintf_s(szBuf, 64, "{%08x-%04x-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}",   
  3.     pCurrAddresses->NetworkGuid->Data1, pCurrAddresses->NetworkGuid->Data2, pCurrAddresses->NetworkGuid->Data3,   
  4.     pCurrAddresses->NetworkGuid->Data4[0], pCurrAddresses->NetworkGuid->Data4[1],   
  5.     pCurrAddresses->NetworkGuid->Data4[2], pCurrAddresses->NetworkGuid->Data4[3],   
  6.     pCurrAddresses->NetworkGuid->Data4[4], pCurrAddresses->NetworkGuid->Data4[5],   
  7.     pCurrAddresses->NetworkGuid->Data4[6], pCurrAddresses->NetworkGuid->Data4[7]);   
  8.     printf("%s", szBuf); 

 输出结果类似:GUID: b568ee76-6d17-4a3a-a2f5-269c52fd6de

      1. Wireless Hosted Network Sample :wireless Hosted Network sample that demonstrates the use of wireless Hosted Network functions is included with the Microsoft Windows Software Development Kit (SDK). Wireless Hosted Network sample can be compiled on the Windows SDK for Windows 7.
      2. 激活Window7 Virtual WiFi: 正如第三点所说的,如果你只有一张无限网卡,虚拟出来的网卡好像只能作为SoftAP用,不能当做真是网卡连接其他网络。如果你的网卡是Intel芯片的,下载最新驱动( 32位64位 )。安装之后就可以看到如图:多一张网络接口:Wireless Network connection2,设备名字:Microsoft Virtual Miniport Driver.
      3. Wireless Hosted Network Sample :wireless Hosted Network sample that demonstrates the use of wireless Hosted Network functions is included with the Microsoft Windows Software Development Kit (SDK). Wireless Hosted Network sample can be compiled on the Windows SDK for Windows 7.
      4. 激活Window7 Virtual WiFi: 正如第三点所说的,如果你只有一张无限网卡,虚拟出来的网卡好像只能作为SoftAP用,不能当做真是网卡连接其他网络。如果你的网卡是Intel芯片的,下载最新驱动( 32位64位 )。安装之后就可以看到如图:多一张网络接口:Wireless Network connection2,设备名字:Microsoft Virtual Miniport Driver.
      5. Wireless Hosted Network Sample :wireless Hosted Network sample that demonstrates the use of wireless Hosted Network functions is included with the Microsoft Windows Software Development Kit (SDK). Wireless Hosted Network sample can be compiled on the Windows SDK for Windows 7.
      6. 激活Window7 Virtual WiFi: 正如第三点所说的,如果你只有一张无限网卡,虚拟出来的网卡好像只能作为SoftAP用,不能当做真是网卡连接其他网络。如果你的网卡是Intel芯片的,下载最新驱动( 32位64位 )。安装之后就可以看到如图:多一张网络接口:Wireless Network connection2,设备名字:Microsoft Virtual Miniport Driver.

         

          参数:

        lpEventAttributes:
              [输入]一个指向 SECURITY_ATTRIBUTES结构的指针,确定返回的句柄是否可被子进程继承。如果lpEventAttributes是NULL,此句柄不能被继承。
              Windows NT/2000:lpEventAttributes的结构中的成员为新的事件指定了一个安全符。如果lpEventAttributes是NULL,事件将获得一个默认的安全符。

        bManualReset:
              [输入]指定将事件对象创建成手动复原还是自动复原。如果是 TRUE,那么必须用ResetEvent函数来手工将事件的状态复原到无信号状态。如果设置为FALSE,当事件被一个等待线程释放以后,系统将会自动将事件状态复原为无信号状态。

        bInitialState:
              [输入]指定事件对象的初始状态。如果为TRUE,初始状态为有信号状态;否则为无信号状态。

        lpName:
              [输入]指定事件的对象的名称,是一个以0结束的字符串指针。名称的字符格式限定在MAX_PATH之内。名字是对大小写敏感的。
        示例代码:
              // 创建一个有名的,不能被继承的,手动复原,初始状态是无信号状态的事件对象
              Handle h = CreateEvent(NULL,TRUE,FALSE,“MyEvent”);
      7. DeviceIoControl函数,这里介绍了关于OVERLAPPED的资料
      8. 线程中CreateEvent和SetEvent及WaitForSingleObject的用法
      9. UNICODE_STRING,在KdPrint中打印方式:
        Cpp代码 复制代码
        1. KdPrint(("%ws",PunicodeBuf->Buffer));   
        2. 或者   
        3. KdPrint(("%S",PunicodeBuf->Buffer))  
        KdPrint(("%ws",PunicodeBuf->Buffer));
        或者
        KdPrint(("%S",PunicodeBuf->Buffer))
          以及
        C代码 复制代码
        1. UNICODE_STRING uniString;   
        2. KdPrint(("%wZ/n",&uniString));  
         
        17
      10. Cloned NET_BUFFER_LIST Structures:

    • HANDLE CreateEvent(   
    •   LPSECURITY_ATTRIBUTES lpEventAttributes,   // 安全属性   
    •   BOOL bManualReset,   // 复位方式   
    •   BOOL bInitialState,   // 初始状态   
    •   LPCTSTR lpName   // 对象名称   
    • );  
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值