阅读:884回复:0
Bug in NdisQueryBufferSafe macro(转)
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. |
|
|