sprintf-like functions in non-pageable context?

I need to use a formatting function in a context which potentially can be in paging path. RtlStringPrintf* functions seem to cause paging sometimes by allocating from a paged pool (why use a paged pool for ethemeral buffer???), even though their code seems to be in nonpaged section. swprintf function use is actively discouraged by MS, and swprintf_s functions are missing from Win2003.

By the way, in Win7 WDK, the import library for Win2003 build environment has those “_s” functions, even though the’re not exported. This causes a driver load failure.

Any ideas?

write your own or do not use any wchar formating functions.

Mark Roddy

On Fri, Apr 1, 2011 at 3:08 PM, wrote:
> I need to use a formatting function in a context which potentially can be in paging path. RtlStringPrintf* functions seem to cause paging sometimes by allocating from a paged pool (why use a paged pool for ethemeral buffer???), even though their code seems to be in nonpaged section. swprintf function use is actively discouraged by MS, and swprintf_s functions are missing from Win2003.
>
> By the way, in Win7 WDK, the import library for Win2003 build environment has those “_s” functions, even though the’re not exported. This causes a driver load failure.
>
> Any ideas?
>
> —
> 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 just use swprintf (why the _s version??) … its use may be “actively discouraged” but, you know, whatever. They want to encourage the use of the Safe String Functions… I get it, I hear the whole argument about buffer overflows… so how about StringCchPrintf or something?

Or, if the string is simple, you could hand-code the formatting… I’ve done that, too (but it is shockingly easy to get this wrong).

Peter
OSR

I’ll have to roll my own w-functions. Even freaking wsnprintf is calling freaking mbctowcs when there is no slightest reason to do MBCS to UNICODE conversion. The format string only has %02X formats. And mbctowcs is using paged tables.

Yes - or avoid wide chars. Luckily there is lots of open source
software you can model your replacements on.

Mark Roddy

On Sat, Apr 2, 2011 at 10:00 AM, wrote:
> I’ll have to roll my own w-functions. Even freaking wsnprintf is calling freaking mbctowcs when there is no slightest reason to do MBCS to UNICODE conversion. The format string only has %02X formats. And mbctowcs is using paged tables.
>
> —
> 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
>