Re: kernel mode equivalent of strrchr
- From: "David J. Craig" <SeniorDriversWriter@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 18 Jun 2006 04:02:48 GMT
What is complete? How much text processing is done in the kernel? How much
should be done? Since MS owns the OS, I guess they get to decide what are
the limits. I guess parsing a pathname in kernel mode might find that
routine useful, but you can just do it by scanning for a character saving
the position of each search loop. When you can't find it, then you have
saved the location of the last one. I noticed that there appears to be no
string search routines documented in the DDK. Maybe MS just wants keep the
string routines out of the kernel. They are not written, as we know from
experience, to be safe for kernel mode where any overrun or underrun can
cause the pretty BSOD.
"Mark Roddy" <markr@xxxxxxxxxxxxxx> wrote in message
news:uTNLg%23kOFHA.244@xxxxxxxxxxxxxxxxxxxxxxx
David J. Craig wrote:
The code modification is far too easy. The code in the CRT has a loop
that seeks to the end of the string. Since the ANSI_STRING has the
length of the string, just change the routine to use that information and
it will be even faster. The amount of code for such a routine is so
small and simple to understand that modifications to make it work in
drivers is trivial. Of course, it helps if you understand what makes
string functions safe so you don't create your own unsafe routine. Not
that hard. Run it under windbg and try different strings looking for any
place something can go wrong.
Well and good, however the kernel safe string library is revealed again to
be incomplete as it is missing basic string functions. Developers really
ought not to be wasting their time re-inventing the wheel.
"Doron Holan [MS]" <doronh@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:ObV%23KqaOFHA.2132@xxxxxxxxxxxxxxxxxxxxxxx
also note that the buffer in ANSI_STRING is *not* NULL terminated, it's
length is given in the structure. as such, you cannot use CRT functions
reliably.
d
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no
rights.
"David J. Craig" <SeniorDriversWriter@xxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:%23Esa7aaOFHA.1176@xxxxxxxxxxxxxxxxxxxxxxx
Very bad idea. Try it at raised IRQL with driver verifier running.
This will be a good thing ;) Why not just use the source code that
ships with VC7 and adapt it to be safe using the techniques from
ntstrsafe.h? This is so easy, why even ask? School project?
"Bajamani" <bajamani@xxxxxxxxxxx> wrote in message
news:1112679603.328266.273920@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
thank you.
i could not get safe equivalent of strchr. so converted the
UNICODE_STRING to ANSI_STRING and used strchr.
any other way anybody can think of ?
...Mani
--
=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com
.
- References:
- Re: kernel mode equivalent of strrchr
- From: Mark Roddy
- Re: kernel mode equivalent of strrchr
- Prev by Date: Re: Where's IOCTL_SET_TIMEOUT ?
- Next by Date: Re: Talking to HID minidriver from usermode
- Previous by thread: Re: kernel mode equivalent of strrchr
- Next by thread: Re: Where's IOCTL_SET_TIMEOUT ?
- Index(es):
Relevant Pages
|