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

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

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


IDebugControl::OutputVaList and %I broken?

AndersAnders Member Posts: 5
I'm unable to use the documented %I specifier to output ULONG64 parameters as 64 or 32 bit numbers.

Simple test code looks like this:

void Test(IDebugControl*pDC, PCSTR Fmt, ...)
{
va_list val;
va_start(val, Fmt);
pDC->OutputVaList(DEBUG_OUTPUT_NORMAL, Fmt, val);
va_end(val);
}

IDebugControl*pDbgCtl = ...;
Test(pDbgCtl, "Value=%I\n", 0x1122334455667788ull);

In a 64-bit extension it prints "Field formatting string too long" and "Unknown format character" in 32-bit.

I'm specifically looking for the supposed ability to print fewer leading zeros when the 64-bit value is <= 0xffffffff. I don't want to convert to a string on my own first, I just want to replace %p in a few places...

Comments

  • raj_rraj_r Member - All Emails Posts: 983
    not sure if %i is documented i use %I64x normally and it appears to work

    Out("Rva For Inaddress %I64x is %I64X\n" ,inaddr ,(inaddr - Modbase));

    On 11/25/16, [email protected] <[email protected]> wrote:
    > I'm unable to use the documented %I specifier to output ULONG64 parameters
    > as 64 or 32 bit numbers.
    >
    > Simple test code looks like this:
    >
    > void Test(IDebugControl*pDC, PCSTR Fmt, ...)
    > {
    > va_list val;
    > va_start(val, Fmt);
    > pDC->OutputVaList(DEBUG_OUTPUT_NORMAL, Fmt, val);
    > va_end(val);
    > }
    >
    > IDebugControl*pDbgCtl = ...;
    > Test(pDbgCtl, "Value=%I\n", 0x1122334455667788ull);
    >
    > In a 64-bit extension it prints "Field formatting string too long" and
    > "Unknown format character" in 32-bit.
    >
    > I'm specifically looking for the supposed ability to print fewer leading
    > zeros when the 64-bit value is <= 0xffffffff. I don't want to convert to a
    > string on my own first, I just want to replace %p in a few places...
    >
    > ---
    > WINDBG is sponsored by OSR
    >
    > OSR is hiring!! Info at http://www.osr.com/careers
    >
    >
    > MONTHLY seminars on crash dump analysis, WDF, Windows internals and software
    > drivers!
    > Details at <http://www.osr.com/seminars&gt;
    >
    > To unsubscribe, visit the List Server section of OSR Online at
    > <http://www.osronline.com/page.cfm?name=ListServer&gt;
    >
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,483
    On Nov 24, 2016, at 2:37 PM, [email protected] wrote:
    >
    > I'm unable to use the documented %I specifier to output ULONG64 parameters as 64 or 32 bit
    > numbers.

    The capital-I thing in a Microsoft printf string is not a specifier. It is a modifier. You need to follow it with the actual specifier, as in "%Id" or "%Ix".

    However, %Id is the wrong thing to use for ULONG64. A ULONG64 is always 64 bits. "%Id" tells printf "you should expect a 32-bit thing in a 32-bit build". That's not what you are providing.

    You should use "%I64d" or "%I64x" in this case.
    ?
    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    *sigh*

    I know %I is normally a Microsoft specific modifier but OutputVaList is not in any way a normal printf function (%p is always ULONG64 and it supports strange things like %msa, %y etc.).

    If you look at the documentation for OutputVaList which is currently located @ https://msdn.microsoft.com/en-us/library/windows/hardware/ff553280(v=vs.85).aspx you will see a table of _specifiers_ including "%I" and it specifically says the argument is always ULONG64 and "If this is greater than 0xFFFFFFFF, it is printed as a 64-bit value; otherwise, it is printed as a 32-bit value." which is exactly what I want, I just can't get it to work.

    So my question is, is the documentation wrong or is the implementation broken?
  • aluhrsaluhrs Member - All Emails Posts: 32
    I can verify that this is a bug in?the debugger. We've filed it but I don't have an ETA on when we'll have a?fix available.
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Thank you for confirming this.

    Has it always been broken or does it work in some versions?
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
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 15 Jun 2020 LIVE ONLINE
Writing WDF Drivers 22 June 2020 LIVE ONLINE
Internals & Software Drivers 28 Sept 2020 Dulles, VA