I have been asked to port a linux device driver to windows platform.
But i can’t find any run time library routine depicted by ddk can
provide the similar facility
as the sprintf routine in the stdio library. I am reluctant to implement
such a tough
routine. However, I find the ddk provide it’s own “stdio.h” and maybe
the related stdio library.
So, did anyone make use of the sprintf routine in any normal wdm driver?
Is it safe to invoke this routine
in kernel mode?
My problem is rather silly!But any tips will be appreciated!
Best Regards,
hanzhu
Quoting hanzhu :
> I have been asked to port a linux device driver to windows platform.
> But i can’t find any run time library routine depicted by ddk can
> provide the similar facility
> as the sprintf routine in the stdio library. I am reluctant to implement
> such a tough
> routine. However, I find the ddk provide it’s own “stdio.h” and maybe
> the related stdio library.
>
The DDK docs advise the you use of RtlStringCchPrintf or RtlStringCbPrintf from
ntstrsafe.h
There is no stdio in the drivers, in Linux too. In Linux, there is
printk(), which prints to the debugger log. In Windows, you have KdPrint(())
for the same.
Yes, in Linux, printk() also prints to the text formatted “syslogd” log,
but there is no such thing in Windows at all.
In Windows, you have:
a) KdPrint(()) - defunct without the debugger and with the free build of
the driver
b) the binary System event log available to the driver via
IoAllocate/WriteErrorLogEntry
c) the WPP tracing (overly complex, requires some additional files to be
included in the build and has issues). WPP tracing will allow the driver to
print the messages to any WPP consumer app (you can write one), and will be
no-op if there is no consumers.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “hanzhu”
To: “Windows System Software Devs Interest List”
Sent: Friday, November 18, 2005 1:02 PM
Subject: [ntdev] could I use sprintf safely in kernel mode?
> I have been asked to port a linux device driver to windows platform.
> But i can’t find any run time library routine depicted by ddk can
> provide the similar facility
> as the sprintf routine in the stdio library. I am reluctant to implement
> such a tough
> routine. However, I find the ddk provide it’s own “stdio.h” and maybe
> the related stdio library.
>
> So, did anyone make use of the sprintf routine in any normal wdm driver?
> Is it safe to invoke this routine
> in kernel mode?
>
> My problem is rather silly!But any tips will be appreciated!
>
> Best Regards,
> hanzhu
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
hanzhu wrote:
So, did anyone make use of the sprintf routine in any normal wdm
driver? Is it safe to invoke this routine in kernel mode?
sprintf is implemented for the kernel runtime environment but you do
have to be aware of the buffer overrun issues. As others have stated
Microsoft have provided overrun safe versions in ntstrsafe.h.
Mike
Thanks for everyone’s suggestion. However, i just use snprintf to write
strings to
a memory block not to log out my information.
RtlStringCchPrintf may be enough for me!
Best Regards,
hanzhu
Maxim S. Shatskih wrote:
There is no stdio in the drivers, in Linux too. In Linux, there is
printk(), which prints to the debugger log. In Windows, you have KdPrint(())
for the same.
Yes, in Linux, printk() also prints to the text formatted “syslogd” log,
but there is no such thing in Windows at all.
In Windows, you have:
a) KdPrint(()) - defunct without the debugger and with the free build of
the driver
b) the binary System event log available to the driver via
IoAllocate/WriteErrorLogEntry
c) the WPP tracing (overly complex, requires some additional files to be
included in the build and has issues). WPP tracing will allow the driver to
print the messages to any WPP consumer app (you can write one), and will be
no-op if there is no consumers.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “hanzhu”
> To: “Windows System Software Devs Interest List”
> Sent: Friday, November 18, 2005 1:02 PM
> Subject: [ntdev] could I use sprintf safely in kernel mode?
>
>
>
>> I have been asked to port a linux device driver to windows platform.
>> But i can’t find any run time library routine depicted by ddk can
>> provide the similar facility
>> as the sprintf routine in the stdio library. I am reluctant to implement
>> such a tough
>> routine. However, I find the ddk provide it’s own “stdio.h” and maybe
>> the related stdio library.
>>
>> So, did anyone make use of the sprintf routine in any normal wdm driver?
>> Is it safe to invoke this routine
>> in kernel mode?
>>
>> My problem is rather silly!But any tips will be appreciated!
>>
>> Best Regards,
>> hanzhu
>>
>>
>> —
>> Questions? First check the Kernel Driver FAQ at
>>
> http://www.osronline.com/article.cfm?id=256
>
>> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@gmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
Although it is not portable to linux, consider using WPP. Sprintf takes
a significant performance hit in formatting the string.
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of hanzhu
Sent: Friday, November 18, 2005 5:57 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] could I use sprintf safely in kernel mode?
Thanks for everyone’s suggestion. However, i just use snprintf to write
strings to
a memory block not to log out my information.
RtlStringCchPrintf may be enough for me!
Best Regards,
hanzhu
Maxim S. Shatskih wrote:
There is no stdio in the drivers, in Linux too. In Linux, there is
printk(), which prints to the debugger log. In Windows, you have
KdPrint(())
for the same.
Yes, in Linux, printk() also prints to the text formatted
“syslogd” log,
but there is no such thing in Windows at all.
In Windows, you have:
a) KdPrint(()) - defunct without the debugger and with the free
build of
the driver
b) the binary System event log available to the driver via
IoAllocate/WriteErrorLogEntry
c) the WPP tracing (overly complex, requires some additional files
to be
included in the build and has issues). WPP tracing will allow the
driver to
print the messages to any WPP consumer app (you can write one), and
will be
no-op if there is no consumers.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “hanzhu”
> To: “Windows System Software Devs Interest List”
> Sent: Friday, November 18, 2005 1:02 PM
> Subject: [ntdev] could I use sprintf safely in kernel mode?
>
>
>
>> I have been asked to port a linux device driver to windows platform.
>> But i can’t find any run time library routine depicted by ddk can
>> provide the similar facility
>> as the sprintf routine in the stdio library. I am reluctant to
implement
>> such a tough
>> routine. However, I find the ddk provide it’s own “stdio.h” and maybe
>> the related stdio library.
>>
>> So, did anyone make use of the sprintf routine in any normal wdm
driver?
>> Is it safe to invoke this routine
>> in kernel mode?
>>
>> My problem is rather silly!But any tips will be appreciated!
>>
>> Best Regards,
>> hanzhu
>>
>>
>> —
>> Questions? First check the Kernel Driver FAQ at
>>
> http://www.osronline.com/article.cfm?id=256
>
>> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@gmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Don’t all the zero terminated string functions get flagged by prefast as
security problems?
-----Original Message-----
From: Doron Holan [mailto:xxxxx@microsoft.com]
Sent: Friday, November 18, 2005 10:59 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] could I use sprintf safely in kernel mode?
Although it is not portable to linux, consider using WPP. Sprintf takes
a significant performance hit in formatting the string.
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of hanzhu
Sent: Friday, November 18, 2005 5:57 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] could I use sprintf safely in kernel mode?
Thanks for everyone’s suggestion. However, i just use snprintf to write
strings to
a memory block not to log out my information.
RtlStringCchPrintf may be enough for me!
Best Regards,
hanzhu
Maxim S. Shatskih wrote:
> There is no stdio in the drivers, in Linux too. In Linux, there is
> printk(), which prints to the debugger log. In Windows, you have
KdPrint(())
> for the same.
>
> Yes, in Linux, printk() also prints to the text formatted
“syslogd” log,
> but there is no such thing in Windows at all.
>
> In Windows, you have:
> a) KdPrint(()) - defunct without the debugger and with the free
build of
> the driver
> b) the binary System event log available to the driver via
> IoAllocate/WriteErrorLogEntry
> c) the WPP tracing (overly complex, requires some additional files
to be
> included in the build and has issues). WPP tracing will allow the
driver to
> print the messages to any WPP consumer app (you can write one), and
will be
> no-op if there is no consumers.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> ----- Original Message -----
> From: “hanzhu”
> > To: “Windows System Software Devs Interest List”
> > Sent: Friday, November 18, 2005 1:02 PM
> > Subject: [ntdev] could I use sprintf safely in kernel mode?
> >
> >
> >
> >> I have been asked to port a linux device driver to windows platform.
> >> But i can’t find any run time library routine depicted by ddk can
> >> provide the similar facility
> >> as the sprintf routine in the stdio library. I am reluctant to
> implement
> >> such a tough
> >> routine. However, I find the ddk provide it’s own “stdio.h” and maybe
> >> the related stdio library.
> >>
> >> So, did anyone make use of the sprintf routine in any normal wdm
> driver?
> >> Is it safe to invoke this routine
> >> in kernel mode?
> >>
> >> My problem is rather silly!But any tips will be appreciated!
> >>
> >> Best Regards,
> >> hanzhu
> >>
> >>
> >> —
> >> Questions? First check the Kernel Driver FAQ at
> >>
> > http://www.osronline.com/article.cfm?id=256
> >
> >> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> >> To unsubscribe send a blank email to xxxxx@lists.osr.com
> >>
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: xxxxx@gmail.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@microsoft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
Not all, but most do under a certain warning filter level. For
instance, strlen() is still allowed.
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Arthur Kreitman
Sent: Friday, November 18, 2005 11:09 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] could I use sprintf safely in kernel mode?
Don’t all the zero terminated string functions get flagged by prefast as
security problems?
-----Original Message-----
From: Doron Holan [mailto:xxxxx@microsoft.com]
Sent: Friday, November 18, 2005 10:59 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] could I use sprintf safely in kernel mode?
Although it is not portable to linux, consider using WPP. Sprintf
takes
a significant performance hit in formatting the string.
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of hanzhu
Sent: Friday, November 18, 2005 5:57 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] could I use sprintf safely in kernel mode?
Thanks for everyone’s suggestion. However, i just use snprintf to
write
strings to
a memory block not to log out my information.
RtlStringCchPrintf may be enough for me!
Best Regards,
hanzhu
Maxim S. Shatskih wrote:
> There is no stdio in the drivers, in Linux too. In Linux, there
is
> printk(), which prints to the debugger log. In Windows, you have
KdPrint(())
> for the same.
>
> Yes, in Linux, printk() also prints to the text formatted
“syslogd” log,
> but there is no such thing in Windows at all.
>
> In Windows, you have:
> a) KdPrint(()) - defunct without the debugger and with the free
build of
> the driver
> b) the binary System event log available to the driver via
> IoAllocate/WriteErrorLogEntry
> c) the WPP tracing (overly complex, requires some additional
files
to be
> included in the build and has issues). WPP tracing will allow the
driver to
> print the messages to any WPP consumer app (you can write one), and
will be
> no-op if there is no consumers.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> ----- Original Message -----
> From: “hanzhu”
> > To: “Windows System Software Devs Interest List”
> > Sent: Friday, November 18, 2005 1:02 PM
> > Subject: [ntdev] could I use sprintf safely in kernel mode?
> >
> >
> >
> >> I have been asked to port a linux device driver to windows
platform.
> >> But i can’t find any run time library routine depicted by ddk can
> >> provide the similar facility
> >> as the sprintf routine in the stdio library. I am reluctant to
> implement
> >> such a tough
> >> routine. However, I find the ddk provide it’s own “stdio.h” and
maybe
> >> the related stdio library.
> >>
> >> So, did anyone make use of the sprintf routine in any normal wdm
> driver?
> >> Is it safe to invoke this routine
> >> in kernel mode?
> >>
> >> My problem is rather silly!But any tips will be appreciated!
> >>
> >> Best Regards,
> >> hanzhu
> >>
> >>
> >> —
> >> Questions? First check the Kernel Driver FAQ at
> >>
> > http://www.osronline.com/article.cfm?id=256
> >
> >> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> >> To unsubscribe send a blank email to
xxxxx@lists.osr.com
> >>
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: xxxxx@gmail.com
> > To unsubscribe send a blank email to
xxxxx@lists.osr.com
> >
> >
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@microsoft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com