sirroom
驱动大牛
驱动大牛
  • 注册日期2001-07-30
  • 最后登录2018-05-29
  • 粉丝0
  • 关注0
  • 积分6分
  • 威望11点
  • 贡献值1点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:884回复:0

Bug in NdisQueryBufferSafe macro(转)

楼主#
更多 发布于:2002-05-25 11:23
The macro definition of NdisQueryBufferSafe, meant for non-binary compatible
driver, in Win2K DDK NDIS.H header file is wrong. This macro is defined as

#define NdisQueryBufferSafe(_Buffer, _VirtualAddress, _Length,
_Priority) \\
{ \\
PVOID _VA; \\
\\
_VA = MmGetSystemAddressForMdlSafe(_Buffer, _Priority); \\
if (ARGUMENT_PRESENT(_VirtualAddress)) \\
{ \\
*(PVOID *)(_VirtualAddress) = _VA; \\
} \\
*(_Length) = (_VA != NULL) ? MmGetMdlByteCount(_Buffer) : 0; \\
}

The problem here is that MmGetSystemAddressForMdlSafe is called
unconditionally, regardless of whether the _VirtualAddress argument is
present or not. The only time the driver passes a _VirtualAddress argument
is when it has to copy user data (i.e., for coalescing of the entire packet
or just the first 54 bytes for the MAC/IP/TCP header). Unconditionally
calling MmGetSystemAddressForMdlSafe can cause huge performance degradation.

The macro definition should be:

#define NdisQueryBufferSafe(_Buffer, _VirtualAddress, _Length, _Priority)
\\
{
\\
    if (ARGUMENT_PRESENT(_VirtualAddress))
\\

{                                                                       \\
        *(PVOID *)(_VirtualAddress) = MmGetSystemAddressForMdlSafe(_Buffer,
_Priority); \\
    }
\\
    *(_Length) = MmGetMdlByteCount(_Buffer);
\\
}

You can either update the ndis.h or redefine the macro in your project
header file. Please note that this bug has been corrected in the XP DDK
NDIS.H file. There will be a KB on this early next week.

--
-Eliyas
This posting is provided \"AS IS\" with no warranties, and confers no rights.


--
-Eliyas
This posting is provided \"AS IS\" with no warranties, and confers no rights.







111
游客

返回顶部