This is a sample from a project I did, I am no expert here but this works.
I can then use
TraceFailure( status, IO_OPS, …);
And it will only trigger if the status was not successful.
–
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply
#define WPP_CONTROL_GUIDS \
WPP_DEFINE_CONTROL_GUID(CtlGuid, \
(9EB7EFEF, 4CF6, 4dc5, BC7D, E0A0EE65AC38), \
WPP_DEFINE_BIT(SUPPORT) \
WPP_DEFINE_BIT(LOAD_UNLOAD) \
WPP_DEFINE_BIT(MESSAGING) \
WPP_DEFINE_BIT(IO_OPS) \
WPP_DEFINE_BIT(INSTANCE) \
WPP_DEFINE_BIT(STREAM) \
WPP_DEFINE_BIT(HANDLE) )
#define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) WPP_LEVEL_LOGGER(flags)
#define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) (WPP_LEVEL_ENABLED(flags) \
&& WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl)
// MACRO: TraceFailure
//
// begin_wpp config
// FUNC TraceFailure(TraceFailure_EXP,flags,MSG,…);
// end_wpp
#define WPP_TraceFailure_EXP_flags_PRE(HR,flags) {if( !NT_SUCCESS(HR) ) {
#define WPP_TraceFailure_EXP_flags_POST(HR,flags) ; } }
#define WPP_TraceFailure_EXP_flags_ENABLED(HR, flags) \
(WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= \
TRACE_LEVEL_ERROR)
#define WPP_TraceFailure_EXP_flags_LOGGER(HR,flags) WPP_LEVEL_LOGGER(flags)
“Yossi Leybovich” wrote in message
news:xxxxx@ntdev…
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Don Burn
> Sent: Wednesday, January 31, 2007 4:08 PM
> To: Windows System Software Devs Interest List
> Subject: Re:[ntdev] Using WPP with condition (or from within macro)
>
> You need to use the PRE and POST macros to code for “if(
> status != SUCCESS) …” the tracedrv sample has a example of this.
I don’t see that in the tracedrv ( I use DDK 3790.1830)
I read about the pre/post MACROs in the DDK but I was not able to define
the right macros for the pre post WPP macros
I tries to use the DDK example but it didn’t work.
Can you attached your example if its from newer DDK
Thanks
Yossi
>
>
> –
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> http://www.windrvr.com
> Remove StopSpam from the email to reply
>
>
>
> “Yossi Leybovich” wrote in message
> news:xxxxx@ntdev…
> Hi
>
> I want to call WPP from within macro (to print only in case of error)
>
> I have the following macro in my driver
>
> #define DBG_PRINT(level,flag,msg) <br>> { <br>> if (g_dbg_level >= (level) && <br>> (g_dbg_flags & (flag))) { <br>>
> DbgPrint msg; <br>> } <br>> }
> g_dbg_level and g-_dbg_flags are variables that define in the registry
>
> #define DBG_EXIT(flags)<br>> DBG_PRINT(TRACE_LEVEL_VERBOSE, flags, (“<===\n” ));
>
>
>
> #define DBG_PRINT_EXIT(level,flag,msg) <br>> {<br>> if (status != SUCCESS) {<br>> DBG_PRINT(level,flag,msg);<br>> }<br>> DBG_EXIT(flag);<br>> }
>
>
>
> I also implement the WPP version of DBG_PRINT and DBG_EXIT
> and its work
> .
> How can implement the DBG_PRIN_EXIT macro in the WPP version? The WPP
> preprocessor is called before the compiler preprocessor
>
> Thanks
> Yossi
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online
> at http://www.osronline.com/page.cfm?name=ListServer
>