阅读:1704回复:6
请大家总结以下宏的作用
ASSERT
C_ASSERT UNREFERENCED_PARAMETER ARGUMENT_PRESENT PAGED_CODE alloc_text(INIT/PAGE/PAGESRP0/PAGESER/...,FuncName) 以及打印语句 DbgPrint |
|
|
沙发#
发布于:2003-07-14 15:51
ASSERT:
VOID ASSERT(Expression); The ASSERT routine tests an expression. If the expression is false, a breakpoint occurs. On a free build, ASSERT has no effect. C_ASSERT: This handy macro will perform compile time assertion checking in your code. UNREFERENCED_PARAMETER: ??? ARGUMENT_PRESENT: ARGUMENT_PRESENT is a macro that takes an argument pointer and returns FALSE if the pointer is NULL, TRUE otherwise. PAGED_CODE: The PAGED_CODE macro ensures that the calling thread is running at an IRQL that is low enough to permit paging. If the IRQL > APC_LEVEL, PAGED_CODE() causes the system to ASSERT. alloc_text: ??? 还有RtlAssert??? 我只找到这么多,其中似懂非懂,不是很明确,希望大家来补充 :D :D :D |
|
|
板凳#
发布于:2003-07-14 16:16
UNREFERENCED_PARAMETER:
我记得是为了把参数用一下,免得warning出来,说参数没有用。其实什么也没有干。 alloc_text 多了。alloc_text(INIT, DriverEntry)把DriverEntry放到初始化节,等等。 |
|
地板#
发布于:2003-07-14 16:46
PAGED_CODE其实也是assert的用法
|
|
地下室#
发布于:2003-07-15 15:08
ASSERT: for making ensure that the expression provided as an argument is
TRUE. If it is false, ur program will exit. ARGUMENT_PRESENT- to check whether the pointer provided is non NULL. If yes, then return TRUE otherwise FALSE. PAGED_CODE: by default the code lies in non paged area. but that is a very scarce thing in kernel. so we can specify some part of code as paged. Marking the text as PAGED, we are telling the kernel that the code can be swapped out of the memory. You MUST be careful while using this. DbgPrint: it\'s just like printf in user mode application. The string is displayed in the application like DbgView. |
|
|
5楼#
发布于:2003-07-15 15:10
The first four of these (and a number of other macros) are described in my
article \"Simplifying Development with DDK Macros\" at http://www.osronline.com. RtlAssert, PAGED_CODE and DbgPrint are well documented in the DDK. Don Burn (MVP, Windows DDK) Windows 2k/XP/2k3 Filesystem and Driver Consulting |
|
|
6楼#
发布于:2003-07-16 14:08
> ASSERT
Debug print and int 3 if the condition is false in runtime. > C_ASSERT Compiler error if condition is false in compile time. > UNREFERENCED_PARAMETER Suppress the \"parameter not use\" compiler warning. > ARGUMENT_PRESENT Compares the parameter to NULL. > PAGED_CODE ASSERT( KeGetCurrentIrql() < DISPATCH_LEVEL ) Must be used in any function which is declared in pageable code segment, to catch the cases if it is called on high IRQL - which is a catastrophic bug. > alloc_text(INIT/PAGE/PAGESRP0/PAGESER/...,FuncName) Declares the code or the global variables as pageable. > RtlAssert Nearly same as ASSERT. > DbgPrint Prints something to the attached kernel debugger, no-op if no such debugger. Note KdPrint is more correct. > bugcheck Emergency OS stop with blue screen of death. You can cause it in your code by calling KeBugCheck or KeBugCheckEx. Max . |
|
|