Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

sprintf-like functions in non-pageable context?

Alex_GrigAlex_Grig Member Posts: 3,238
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?

Comments

  • Mark_RoddyMark_Roddy Member - All Emails Posts: 4,305
    write your own or do not use any wchar formating functions.

    Mark Roddy



    On Fri, Apr 1, 2011 at 3:08 PM, <xxxxx@broadcom.com> 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
    >
  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,138
    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

    Peter Viscarola
    OSR
    @OSRDrivers

  • Alex_GrigAlex_Grig Member Posts: 3,238
    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.
  • Mark_RoddyMark_Roddy Member - All Emails Posts: 4,305
    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, <xxxxx@broadcom.com> 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
    >
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Writing WDF Drivers 25 Feb 2019 OSR Seminar Space
Developing Minifilters 8 April 2019 OSR Seminar Space