Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

kernel mode version of sprintf?

862 views
Skip to first unread message

Bill Ryder

unread,
Aug 19, 1998, 3:00:00 AM8/19/98
to
Another kernel newbie question. Is there a kernel mode version of
sprintf? I want to initialize a UCHAR str[100] using a format string,
ie:

sprintf( str, "0x%X\n", someU32Address );

When I try this I get a Second Chance (Access Error), which I assume is
because I'm not calling sprintf from user space. Is there some method
for using a printf style string specification in NT kernel land?

TIA,
Bill Ryder


Jamey Kirby

unread,
Aug 19, 1998, 3:00:00 AM8/19/98
to
Yes, sprintf()


Bill Ryder wrote in message <35DB43BA...@bugs.cs.wcupa.edu>...

pazi

unread,
Aug 20, 1998, 3:00:00 AM8/20/98
to
In article <35DB43BA...@bugs.cs.wcupa.edu>, wry...@bugs.cs.wcupa.edu
wrote:

>Is there a kernel mode version of sprintf?

wsprintf()?

-zi

Bill Ryder

unread,
Aug 21, 1998, 3:00:00 AM8/21/98
to
But you didn't address the error. any ideas why I'm getting it? (Obviously
I still haven't solved this. . .)

-Bill

Matt Arnold

unread,
Aug 21, 1998, 3:00:00 AM8/21/98
to
Bill Ryder wrote in message <35DDAD95...@bugs.cs.wcupa.edu>...

>But you didn't address the error. any ideas why I'm getting it?
(Obviously
>I still haven't solved this. . .)

Could it be because you're passing a function that expects a kernel-space
address a user-space one?

I think you need to map the memory pointed to by 'someU32Address' into
kernel-space and then pass the address of *that* to your kernel sprintf().
Otherwise, you're just passing it a bogus address.


Regards,

Matt Arnold
Professional Music Products
Mark of the Unicorn, Inc.
http://www.motu.com

Remove all the X's from Reply-To: to obtain my valid e-mail address.

---------

Pursuant to US Code, Title 47, Chapter 5, Subchapter II, Sec. 227,
any and all unsolicited commercial e-mail sent to this address is
subject to a download and archival fee in the amount of $500 US.
E-mailing this address denotes acceptance of these terms.

>Jamey Kirby wrote:
>
>> Yes, sprintf()
>>
>> Bill Ryder wrote in message <35DB43BA...@bugs.cs.wcupa.edu>...
>> >Another kernel newbie question. Is there a kernel mode version of
>> >sprintf? I want to initialize a UCHAR str[100] using a format string,
>> >ie:
>> >
>> >sprintf( str, "0x%X\n", someU32Address );
>> >
>> >When I try this I get a Second Chance (Access Error), which I assume is
>> >because I'm not calling sprintf from user space. Is there some method
>> >for using a printf style string specification in NT kernel land?

[snip]

Bill Ryder

unread,
Aug 24, 1998, 3:00:00 AM8/24/98
to
Okay, let me ask you guys this: I think I have this narrowed down to being
a memory problem. I try to allocate the buffer into which the sprintf data
goes, from non-paged pool. I suspect my problem may have something to do
with accessing the buffer while at an inapproprite IRQL. The Baker book
("The Windows NT Device Driver Book") says you have to use non-paged pool
at or above DISPATCH_LEVEL, and paged below this level (pg. 87-88).
Sprintf seems to be sucessful a few times before failing later about the
8th time its called in my case, making me suspect the IRQL thing, though in
trying to print the IRQL level to windbg, it seems I never leave PASSIVE.
(??)

The problem is, the error I get when it fails is damn vague. It literally
says "Stopped at unexpected exception: code=80000003
address:81-something." Not "page fault" or "bad IRQL" or "bad pointer" or
anything that might give me a clue.

So my general question at this point is, is there any way to locally
allocate a small chunk of memory that I can allocate, access, and
deallocate regardless of IRQL? And, if anyone has comments specific to
what I descibe, please chime in, but I think its getting to the point where
someone who implimented the kernel itself might be the only one to know
what my problem is off the top of their head.

And BTW - I really appreciate all the replies up until this point but
nothing has worked. I verified things, tried alternate calls, etc. No
dice. Quite frustrating when everyone says there should be no problem
using sprintf in the kernel.

If I get no replies I'll know I'm boring eveyone w/ this discussion and
drop it.

Thanks again,
Bill

Bill Ryder wrote:

> Another kernel newbie question. Is there a kernel mode version of
> sprintf? I want to initialize a UCHAR str[100] using a format string,
> ie:
>
> sprintf( str, "0x%X\n", someU32Address );
>
> When I try this I get a Second Chance (Access Error), which I assume is
> because I'm not calling sprintf from user space. Is there some method
> for using a printf style string specification in NT kernel land?
>

> TIA,
> Bill Ryder


Andrew Tucker

unread,
Aug 24, 1998, 3:00:00 AM8/24/98
to

Exception 0x80000003 is a breakpoint exception. Do you perhapss have a
hardcoded DebugBreak in your code?

HTH

Bill Ryder (wry...@bugs.cs.wcupa.edu) wrote:
: Okay, let me ask you guys this: I think I have this narrowed down to being

:
:
:

--
--
/* Andrew */
WWW: http://www.halcyon.com/ast
Email: a...@halcyon.com


0 new messages