以前从来没有注意WDK在编译之后,虽然没有在build的时候直接提示警告信息,但是会在ORCA的一个界面中提示程序中存在的一些Warnning,比如:
警告实例1:
warning 28197: Possibly leaking memory 'pMacInfo':
如果你上网查找这个错误:http://msdn.microsoft.com/en-us/library/aa468922.aspx
那你就会发现,在程序中忘记了释放已经分配的内存:
pMacInfo = (PDOT11_MAC_INFO)NdisAllocateMemoryWithTagPriority(pFilter->FilterHandle, sizeof(DOT11_MAC_INFO), FILTER_ALLOC_TAG, LowPoolPriority);
NdisZeroMemory(pMacInfo,sizeof(DOT11_MAC_INFO));
DEBUGP(DL_TEST,("sizeof DOT11_MAC_INFO is%u!\n",sizeof(DOT11_MAC_INFO)));
Status = filterDoInternalRequest(pFilter,
NdisRequestMethod,
Oid,
pMacInfo,
sizeof(DOT11_MAC_INFO),
sizeof(DOT11_MAC_INFO),
MethodId,
&BytesProcessed);
....(略)
}
NdisFreeMemory(pMacInfo,0,0);
如果你没有NdisFreeMemory()这条语句,他就会提示说可能存在内存泄露。
警告实例2:
| 133 DriverObject->DriverUnload = FilterUnload; | ||
|
警告实例3:
28193 - <Variable> holds a value that must be examined
NdisQueryMdl(
pMdl,
(PVOID *)&pCopyData,
&BufferLength,
NormalPagePriority);
FILTER_ASSERT(pCopyData != NULL);// Exception will rise if no this statment
The driver should test the value of the specified variable, which was supplied by a function, but the driver is either not using the value or is overwriting the value without examining it.
WDK编译警告解析
本文探讨了WDK编译过程中出现的警告信息,包括内存泄漏警告、DriverUnload成员访问警告及变量检查警告等,并提供了相应的解决建议。
3215

被折叠的 条评论
为什么被折叠?



