RtlPrintf v/s sprintf variants

Are sprintf versions also IRQL specific like RtlPrintf’s are?

I read on Doron’s blog that Rtl one’s defined as PAGED_CODE and hence can
bugcheck even if we are calling it higher IRQL wiith no format specifiers in
the format string.
Is that correct?
If yes is that true for sprintf one’s also?

Regards
Deepak

I do not know but to verify this till some one reply, you can acquire a spinlock and than call the said function and run it with verifier forced IRQL option.

do remember to skip all this if someone(with code access) provides some concrete answers. :wink:

Thanks
Aditya

hehehe sure Adi, thanks for the input :slight_smile:

Regards
Deepak

On Tue, Sep 8, 2009 at 1:19 PM, wrote:

> I do not know but to verify this till some one reply, you can acquire a
> spinlock and than call the said function and run it with verifier forced
> IRQL option.
>
> do remember to skip all this if someone(with code access) provides some
> concrete answers. :wink:
>
> Thanks
> Aditya
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

Don’t use wide char format specifiers. The C runtime stuff is not, as
far as I know, afflicted with paged_code macros. Those macros, by the
way, are only enabled in the checked build.

Mark Roddy

On Tue, Sep 8, 2009 at 2:43 AM, Deepak Gupta wrote:
> Are sprintf versions also IRQL specific like RtlPrintf’s are?
>
> I read on Doron’s blog that Rtl one’s defined as PAGED_CODE and hence can
> bugcheck even if we are calling it higher IRQL wiith no format specifiers in
> the format string.
> Is that correct?
> If yes is that true for sprintf one’s also?
>
> Regards
> Deepak
> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the
> List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer

Thanks Mark for the input :slight_smile:

Just to clarify,

You mean to say even “RtlPrintf” ones are also not affected with
“paged_code” macros in release builds?

@Adi

I did the same you said.
It works at dispatch.

Regards
Deepak

And hence “RtlPrintf” can be safely used at DISPATCH if not using wide char
format specifiers?

On Tue, Sep 8, 2009 at 5:27 PM, Mark Roddy wrote:

> Don’t use wide char format specifiers. The C runtime stuff is not, as
> far as I know, afflicted with paged_code macros. Those macros, by the
> way, are only enabled in the checked build.
>
>
> Mark Roddy
>
>
>
> On Tue, Sep 8, 2009 at 2:43 AM, Deepak Gupta wrote:
> > Are sprintf versions also IRQL specific like RtlPrintf’s are?
> >
> > I read on Doron’s blog that Rtl one’s defined as PAGED_CODE and hence can
> > bugcheck even if we are calling it higher IRQL wiith no format specifiers
> in
> > the format string.
> > Is that correct?
> > If yes is that true for sprintf one’s also?
> >
> > Regards
> > Deepak
> > — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> > other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
> the
> > List Server section of OSR Online at
> > http://www.osronline.com/page.cfm?name=ListServer
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

I’m still not completely clear what you are asking. because the RtlStringXXX() functions (I assume that’s what you mean by ‘RtlPrinf()’) have documented IRQL levels (PASSIVE for all, I think), and you’re talking about calling them at a high IRQL level. To me, that sounds like it should bugcheck (in theory), regardless of the arguments or lack thereof, regardless of whether the code is paged or not.

Many (all? most?) of the RtlStringXXX functions are implemented in terms of the traditional C runtime string functions, and moreover, you can find them (inlined) in ntstrsafe.h.

PAGED_CODE() macros expand to in release builds, in all cases; for the same reason, your test doesn’t demonstrate that it is safe unless you’re using a checked build.

Do you have a link to that blog entry by Doron?

mm

mm

>

I’m still not completely clear what you are asking. because the
RtlStringXXX()
functions (I assume that’s what you mean by ‘RtlPrinf()’) have
documented IRQL
levels (PASSIVE for all, I think), and you’re talking about calling
them at a
high IRQL level. To me, that sounds like it should bugcheck (in
theory),
regardless of the arguments or lack thereof, regardless of whether the
code is
paged or not.

I use RtlStringCbVPrintfA at HIGH_LEVEL all the time and have never seen
problems, with a checked build of my driver and the verifier enabled.

I have definitely seem problems with RtlXxx functions when dealing with
Unicode strings though.

James

yes - paged_code is a nop in release builds.
However you should not violate explicitly documented IRQL restrictions.

Even when those restrictions are wrong.

Unless you really have to.

Mark Roddy

On Tue, Sep 8, 2009 at 8:34 AM, Deepak Gupta wrote:
> Thanks Mark for the input :slight_smile:
>
> Just to clarify,
>
> You mean to say even “RtlPrintf” ones are also not affected with
> “paged_code” macros in release builds?
>
> @Adi
>
> I did the same you said.
> It works at dispatch.
>
> Regards
> Deepak
>
> And hence “RtlPrintf” can be safely used at DISPATCH if not using wide char
> format specifiers?
>
> On Tue, Sep 8, 2009 at 5:27 PM, Mark Roddy wrote:
>>
>> Don’t use wide char format specifiers. The C runtime stuff is not, as
>> far as I know, afflicted with paged_code macros. Those macros, by the
>> way, are only enabled in the checked build.
>>
>>
>> Mark Roddy
>>
>>
>>
>> On Tue, Sep 8, 2009 at 2:43 AM, Deepak Gupta wrote:
>> > Are sprintf versions also IRQL specific like RtlPrintf’s are?
>> >
>> > I read on Doron’s blog that Rtl one’s defined as PAGED_CODE and hence
>> > can
>> > bugcheck even if we are calling it higher IRQL wiith no format
>> > specifiers in
>> > the format string.
>> > Is that correct?
>> > If yes is that true for sprintf one’s also?
>> >
>> > Regards
>> > Deepak
>> > — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging
>> > and
>> > other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
>> > the
>> > List Server section of OSR Online at
>> > http://www.osronline.com/page.cfm?name=ListServer
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>
> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the
> List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer

@Mark and JamesThanks for the input.

@MM
I have given up on WPP and was thinking of having own logging functionality.
My logging func can be called at dispatch, So I was just exploring all
options that I can use while writing variable argument
logger function. I wanted to print the vars in my logging buffers. I have
plans to write these buffers to a log file through a separate
thread as a flushing operation.

Doron’s blog – http://blogs.msdn.com/doronh/archive/2006/03/03/543140.aspx

Regards
Deepak

On Tue, Sep 8, 2009 at 6:31 PM, Mark Roddy wrote:

> yes - paged_code is a nop in release builds.
> However you should not violate explicitly documented IRQL restrictions.
>
>
> Even when those restrictions are wrong.
>
>
>
> Unless you really have to.
>
> Mark Roddy
>
>
>
> On Tue, Sep 8, 2009 at 8:34 AM, Deepak Gupta wrote:
> > Thanks Mark for the input :slight_smile:
> >
> > Just to clarify,
> >
> > You mean to say even “RtlPrintf” ones are also not affected with
> > “paged_code” macros in release builds?
> >
> > @Adi
> >
> > I did the same you said.
> > It works at dispatch.
> >
> > Regards
> > Deepak
> >
> > And hence “RtlPrintf” can be safely used at DISPATCH if not using wide
> char
> > format specifiers?
> >
> > On Tue, Sep 8, 2009 at 5:27 PM, Mark Roddy wrote:
> >>
> >> Don’t use wide char format specifiers. The C runtime stuff is not, as
> >> far as I know, afflicted with paged_code macros. Those macros, by the
> >> way, are only enabled in the checked build.
> >>
> >>
> >> Mark Roddy
> >>
> >>
> >>
> >> On Tue, Sep 8, 2009 at 2:43 AM, Deepak Gupta
> wrote:
> >> > Are sprintf versions also IRQL specific like RtlPrintf’s are?
> >> >
> >> > I read on Doron’s blog that Rtl one’s defined as PAGED_CODE and hence
> >> > can
> >> > bugcheck even if we are calling it higher IRQL wiith no format
> >> > specifiers in
> >> > the format string.
> >> > Is that correct?
> >> > If yes is that true for sprintf one’s also?
> >> >
> >> > Regards
> >> > Deepak
> >> > — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging
> >> > and
> >> > other seminars visit: http://www.osr.com/seminars To unsubscribe,
> visit
> >> > the
> >> > List Server section of OSR Online at
> >> > http://www.osronline.com/page.cfm?name=ListServer
> >>
> >> —
> >> NTDEV is sponsored by OSR
> >>
> >> For our schedule of WDF, WDM, debugging and other seminars visit:
> >> http://www.osr.com/seminars
> >>
> >> To unsubscribe, visit the List Server section of OSR Online at
> >> http://www.osronline.com/page.cfm?name=ListServer
> >
> > — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> > other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
> the
> > List Server section of OSR Online at
> > http://www.osronline.com/page.cfm?name=ListServer
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

Before giving up on wpp (and yes it is cumbersome), measure the cost of a sprintf logger with a wpp logger. Processing the format string for varargs can be quite costly, wpp addresses this its preprocessing. The cost difference can be significant.

d

Sent from my phone with no t9, all spilling mistakes are not intentional.


From: Deepak Gupta
Sent: Tuesday, September 08, 2009 7:43 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] RtlPrintf v/s sprintf variants

@Mark and James
Thanks for the input.

@MM
I have given up on WPP and was thinking of having own logging functionality.
My logging func can be called at dispatch, So I was just exploring all options that I can use while writing variable argument
logger function. I wanted to print the vars in my logging buffers. I have plans to write these buffers to a log file through a separate
thread as a flushing operation.

Doron’s blog – http://blogs.msdn.com/doronh/archive/2006/03/03/543140.aspx

Regards
Deepak

On Tue, Sep 8, 2009 at 6:31 PM, Mark Roddy > wrote:
yes - paged_code is a nop in release builds.
However you should not violate explicitly documented IRQL restrictions.

Even when those restrictions are wrong.

Unless you really have to.

Mark Roddy

On Tue, Sep 8, 2009 at 8:34 AM, Deepak Gupta> wrote:
> Thanks Mark for the input :slight_smile:
>
> Just to clarify,
>
> You mean to say even “RtlPrintf” ones are also not affected with
> “paged_code” macros in release builds?
>
> @Adi
>
> I did the same you said.
> It works at dispatch.
>
> Regards
> Deepak
>
> And hence “RtlPrintf” can be safely used at DISPATCH if not using wide char
> format specifiers?
>
> On Tue, Sep 8, 2009 at 5:27 PM, Mark Roddy > wrote:
>>
>> Don’t use wide char format specifiers. The C runtime stuff is not, as
>> far as I know, afflicted with paged_code macros. Those macros, by the
>> way, are only enabled in the checked build.
>>
>>
>> Mark Roddy
>>
>>
>>
>> On Tue, Sep 8, 2009 at 2:43 AM, Deepak Gupta> wrote:
>> > Are sprintf versions also IRQL specific like RtlPrintf’s are?
>> >
>> > I read on Doron’s blog that Rtl one’s defined as PAGED_CODE and hence
>> > can
>> > bugcheck even if we are calling it higher IRQL wiith no format
>> > specifiers in
>> > the format string.
>> > Is that correct?
>> > If yes is that true for sprintf one’s also?
>> >
>> > Regards
>> > Deepak
>> > — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging
>> > and
>> > other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
>> > the
>> > List Server section of OSR Online at
>> > http://www.osronline.com/page.cfm?name=ListServer
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>
> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the
> List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

…which is to say that you only get the nice assert in chk, not that they are nonpageable in fre.

  • S

-----Original Message-----
From: Mark Roddy
Sent: Tuesday, September 08, 2009 04:57
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] RtlPrintf v/s sprintf variants

Don’t use wide char format specifiers. The C runtime stuff is not, as
far as I know, afflicted with paged_code macros. Those macros, by the
way, are only enabled in the checked build.

Mark Roddy

On Tue, Sep 8, 2009 at 2:43 AM, Deepak Gupta wrote:
> Are sprintf versions also IRQL specific like RtlPrintf’s are?
>
> I read on Doron’s blog that Rtl one’s defined as PAGED_CODE and hence can
> bugcheck even if we are calling it higher IRQL wiith no format specifiers in
> the format string.
> Is that correct?
> If yes is that true for sprintf one’s also?
>
> Regards
> Deepak
> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the
> List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

paged_code does not in itself make a routine pageable. It is an
assertion by the code author that this routine touches pageable data
or is pageable and should not be called at >= DISPATCH_LEVEL.
Sometimes those author assertions are incorrect - for example see some
of the bitmap functions. It is a coding error to assert PAGED_CODE
because an input parameter *might* be pageable or might refer to
pageable data, and unfortunately that coding error happens.

The distinction might be subtle, unfortunately that subtle distinction
renders the checked build OS unusable for some drivers.

Mark Roddy

On Tue, Sep 8, 2009 at 1:12 PM, Skywing wrote:
> …which is to say that you only get the nice assert in chk, ?not that they are nonpageable in fre.
>
> - S
>
> -----Original Message-----
> From: Mark Roddy
> Sent: Tuesday, September 08, 2009 04:57
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] RtlPrintf v/s sprintf variants
>
>
> Don’t use wide char format specifiers. The C runtime stuff is not, as
> far as I know, afflicted with paged_code macros. Those macros, by the
> way, are only enabled in the checked build.
>
>
> Mark Roddy
>
>
>
> On Tue, Sep 8, 2009 at 2:43 AM, Deepak Gupta wrote:
>> Are sprintf versions also IRQL specific like RtlPrintf’s are?
>>
>> I read on Doron’s blog that Rtl one’s defined as PAGED_CODE and hence can
>> bugcheck even if we are calling it higher IRQL wiith no format specifiers in
>> the format string.
>> Is that correct?
>> If yes is that true for sprintf one’s also?
>>
>> Regards
>> Deepak
>> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
>> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the
>> List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>

Yep, just wanted to post and solidify that as “PAGED_CODE … is only enabled on checked” may have generated some archives-searching momentary confusion for those not in the know.

  • S

-----Original Message-----
From: Mark Roddy
Sent: Tuesday, September 08, 2009 10:25
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] RtlPrintf v/s sprintf variants

paged_code does not in itself make a routine pageable. It is an
assertion by the code author that this routine touches pageable data
or is pageable and should not be called at >= DISPATCH_LEVEL.
Sometimes those author assertions are incorrect - for example see some
of the bitmap functions. It is a coding error to assert PAGED_CODE
because an input parameter might be pageable or might refer to
pageable data, and unfortunately that coding error happens.

The distinction might be subtle, unfortunately that subtle distinction
renders the checked build OS unusable for some drivers.

Mark Roddy

On Tue, Sep 8, 2009 at 1:12 PM, Skywing wrote:
> …which is to say that you only get the nice assert in chk, not that they are nonpageable in fre.
>
> - S
>
> -----Original Message-----
> From: Mark Roddy
> Sent: Tuesday, September 08, 2009 04:57
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] RtlPrintf v/s sprintf variants
>
>
> Don’t use wide char format specifiers. The C runtime stuff is not, as
> far as I know, afflicted with paged_code macros. Those macros, by the
> way, are only enabled in the checked build.
>
>
> Mark Roddy
>
>
>
> On Tue, Sep 8, 2009 at 2:43 AM, Deepak Gupta wrote:
>> Are sprintf versions also IRQL specific like RtlPrintf’s are?
>>
>> I read on Doron’s blog that Rtl one’s defined as PAGED_CODE and hence can
>> bugcheck even if we are calling it higher IRQL wiith no format specifiers in
>> the format string.
>> Is that correct?
>> If yes is that true for sprintf one’s also?
>>
>> Regards
>> Deepak
>> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
>> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the
>> List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Deepak,
If you have specific questions/problems with WPP please let us know and we can try to help out. In addition to sprintf cost mentioned by Doran doing your own string formatting requires a buffer where final formatted string will go which depending on the size of the data you would like to trace can be quite large and can become a concern if you choose to allocated it on the stack. And if you don’t use stack, you have to deal with managing that buffer which can be quite painful - something you don’t need to worry about if you use WPP for your debug tracing.
Thanks,
Alex

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Tuesday, September 08, 2009 7:54 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] RtlPrintf v/s sprintf variants

Before giving up on wpp (and yes it is cumbersome), measure the cost of a sprintf logger with a wpp logger. Processing the format string for varargs can be quite costly, wpp addresses this its preprocessing. The cost difference can be significant.

d

Sent from my phone with no t9, all spilling mistakes are not intentional.


From: Deepak Gupta
Sent: Tuesday, September 08, 2009 7:43 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] RtlPrintf v/s sprintf variants
@Mark and James
Thanks for the input.

@MM
I have given up on WPP and was thinking of having own logging functionality.
My logging func can be called at dispatch, So I was just exploring all options that I can use while writing variable argument
logger function. I wanted to print the vars in my logging buffers. I have plans to write these buffers to a log file through a separate
thread as a flushing operation.

Doron’s blog – http://blogs.msdn.com/doronh/archive/2006/03/03/543140.aspx

Regards
Deepak

On Tue, Sep 8, 2009 at 6:31 PM, Mark Roddy > wrote:
yes - paged_code is a nop in release builds.
However you should not violate explicitly documented IRQL restrictions.

Even when those restrictions are wrong.

Unless you really have to.

Mark Roddy

On Tue, Sep 8, 2009 at 8:34 AM, Deepak Gupta> wrote:
> Thanks Mark for the input :slight_smile:
>
> Just to clarify,
>
> You mean to say even “RtlPrintf” ones are also not affected with
> “paged_code” macros in release builds?
>
> @Adi
>
> I did the same you said.
> It works at dispatch.
>
> Regards
> Deepak
>
> And hence “RtlPrintf” can be safely used at DISPATCH if not using wide char
> format specifiers?
>
> On Tue, Sep 8, 2009 at 5:27 PM, Mark Roddy > wrote:
>>
>> Don’t use wide char format specifiers. The C runtime stuff is not, as
>> far as I know, afflicted with paged_code macros. Those macros, by the
>> way, are only enabled in the checked build.
>>
>>
>> Mark Roddy
>>
>>
>>
>> On Tue, Sep 8, 2009 at 2:43 AM, Deepak Gupta> wrote:
>> > Are sprintf versions also IRQL specific like RtlPrintf’s are?
>> >
>> > I read on Doron’s blog that Rtl one’s defined as PAGED_CODE and hence
>> > can
>> > bugcheck even if we are calling it higher IRQL wiith no format
>> > specifiers in
>> > the format string.
>> > Is that correct?
>> > If yes is that true for sprintf one’s also?
>> >
>> > Regards
>> > Deepak
>> > — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging
>> > and
>> > other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
>> > the
>> > List Server section of OSR Online at
>> > http://www.osronline.com/page.cfm?name=ListServer
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>
> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the
> List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

As Doron said, it is cumbersome :wink: Good idea, hideous implementation.
Both complicated to use and limited at once.

Few days before somebody compared developers and CPU time cost. Using
WPP takes a lot of developers’ time comparing to sprintf formatting.
Formatting is no issue in almost all cases with current CPUs even within
drivers. You’re right with other issues but there is a simple answer:
DbgPrint + DebugView. Sufficient is most cases. I don’t see almost any
real advantage of using WPP over DbgPrint which’d justify developer’s
time spent. Yes, user can’t examine WPP logs. And what? We normally send
end users a trace version of our software if there is a problem. They
can see our debug logs. Who cares? Actually, WPP is real disadvantage in
Windows case which decreases checked build usefullness because we don’t
have necessary TMF files. At least WDF messages are public, thanks for
it.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com http:</http:>]


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Alex Bendetov
Sent: Tuesday, September 08, 2009 9:02 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] RtlPrintf v/s sprintf variants

Deepak,

If you have specific questions/problems with WPP please let us
know and we can try to help out. In addition to sprintf cost mentioned
by Doran doing your own string formatting requires a buffer where final
formatted string will go which depending on the size of the data you
would like to trace can be quite large and can become a concern if you
choose to allocated it on the stack. And if you don’t use stack, you
have to deal with managing that buffer which can be quite painful -
something you don’t need to worry about if you use WPP for your debug
tracing.

Thanks,
Alex

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Tuesday, September 08, 2009 7:54 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] RtlPrintf v/s sprintf variants

Before giving up on wpp (and yes it is cumbersome), measure the
cost of a sprintf logger with a wpp logger. Processing the format string
for varargs can be quite costly, wpp addresses this its preprocessing.
The cost difference can be significant.

d

Sent from my phone with no t9, all spilling mistakes are not
intentional.


From: Deepak Gupta
Sent: Tuesday, September 08, 2009 7:43 AM
To: Windows System Software Devs Interest List

Subject: Re: [ntdev] RtlPrintf v/s sprintf variants

@Mark and James

Thanks for the input.

@MM

I have given up on WPP and was thinking of having own logging
functionality.

My logging func can be called at dispatch, So I was just
exploring all options that I can use while writing variable argument

logger function. I wanted to print the vars in my logging
buffers. I have plans to write these buffers to a log file through a
separate

thread as a flushing operation.

Doron’s blog –
http://blogs.msdn.com/doronh/archive/2006/03/03/543140.aspx

Regards

Deepak

On Tue, Sep 8, 2009 at 6:31 PM, Mark Roddy
wrote:

yes - paged_code is a nop in release builds.
However you should not violate explicitly documented IRQL
restrictions.

Even when those restrictions are wrong.

Unless you really have to.

Mark Roddy

On Tue, Sep 8, 2009 at 8:34 AM, Deepak
Gupta wrote:
> Thanks Mark for the input :slight_smile:
>
> Just to clarify,
>
> You mean to say even “RtlPrintf” ones are also not affected
with
> “paged_code” macros in release builds?
>
> @Adi
>
> I did the same you said.
> It works at dispatch.
>
> Regards
> Deepak
>
> And hence “RtlPrintf” can be safely used at DISPATCH if not
using wide char
> format specifiers?
>
> On Tue, Sep 8, 2009 at 5:27 PM, Mark Roddy
wrote:
>>
>> Don’t use wide char format specifiers. The C runtime stuff is
not, as
>> far as I know, afflicted with paged_code macros. Those
macros, by the
>> way, are only enabled in the checked build.
>>
>>
>> Mark Roddy
>>
>>
>>
>> On Tue, Sep 8, 2009 at 2:43 AM, Deepak
Gupta wrote:
>> > Are sprintf versions also IRQL specific like RtlPrintf’s
are?
>> >
>> > I read on Doron’s blog that Rtl one’s defined as PAGED_CODE
and hence
>> > can
>> > bugcheck even if we are calling it higher IRQL wiith no
format
>> > specifiers in
>> > the format string.
>> > Is that correct?
>> > If yes is that true for sprintf one’s also?
>> >
>> > Regards
>> > Deepak
>> > — NTDEV is sponsored by OSR For our schedule of WDF, WDM,
debugging
>> > and
>> > other seminars visit: http://www.osr.com/seminars To
unsubscribe, visit
>> > the
>> > List Server section of OSR Online at
>> > http://www.osronline.com/page.cfm?name=ListServer
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> For our schedule of WDF, WDM, debugging and other seminars
visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online
at
>> http://www.osronline.com/page.cfm?name=ListServer
>
> — NTDEV is sponsored by OSR For our schedule of WDF, WDM,
debugging and
> other seminars visit: http://www.osr.com/seminars To
unsubscribe, visit the
> List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars
visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

— NTDEV is sponsored by OSR For our schedule of WDF, WDM,
debugging and other seminars visit: http://www.osr.com/seminars To
unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars
visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars
visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

“PAGED_CODE” as a noun is confusing, It gives an impression that this macro can be used to put a piece of code in PAGE section. But the documentation is clear and to the point.

"
If the IRQL > APC_LEVEL, PAGED_CODE() causes the system to ASSERT.

A call to this macro should be made at the beginning of every driver routine that either contains pageable code or accesses pageable code.

The PAGED_CODE macro only checks IRQL at the point the code executes the macro. If the code subsequently raises IRQL, it will not be detected. Driver writers should use the driver verifier to detect when the IRQL is raised improperly.

PAGED_CODE only works in checked builds.
"

So I guess it is just a check which asserts using KeGetCurrentIrql and hence has no role in controlling the memory (paged/nonpaged) of code piece.