Hello everyone,
I want to compare two unicode string with length in my driver.
It looks like what strnicmp does.
RtlCompareUnicodeString can not do it!
How can I do it?
thank you very much!
No, it doesn’t! UNICODE_STRING is a structure containing three items.
One item is a wide character string, and the other two deal with
lengths. There is no requirement to have the wide character string
terminated with a 16-bit zero. Stay away from the string functions
until you know how to make it safe. The ‘string’ functions are the
primary problem with buffer overruns and should be avoided in drivers.
This is also why the UNICODE_STRING data storage structure was invented.
It is safe if you use the correct functions.
“SCT$B!KM{7uJ?(B” wrote in message news:xxxxx@ntdev…
> Hello everyone,
> I want to compare two unicode string with length in my driver.
> It looks like what strnicmp does.
> RtlCompareUnicodeString can not do it!
> How can I do it?
> thank you very much!
Thank you for your answer!
But if I want to deal with that,how can I realize that function?
----- Original Message -----
From: “David J. Craig”
Newsgroups: ntdev
To: “Windows System Software Devs Interest List”
Sent: Wednesday, March 24, 2004 12:52 PM
Subject: Re:[ntdev] Question about RtlCompareUnicodeString
> No, it doesn’t! UNICODE_STRING is a structure containing three items.
> One item is a wide character string, and the other two deal with
> lengths. There is no requirement to have the wide character string
> terminated with a 16-bit zero. Stay away from the string functions
> until you know how to make it safe. The ‘string’ functions are the
> primary problem with buffer overruns and should be avoided in drivers.
> This is also why the UNICODE_STRING data storage structure was invented.
> It is safe if you use the correct functions.
>
> “SCT$B!KM{7uJ?(B” wrote in message news:xxxxx@ntdev…
> > Hello everyone,
> > I want to compare two unicode string with length in my driver.
> > It looks like what strnicmp does.
> > RtlCompareUnicodeString can not do it!
> > How can I do it?
> > thank you very much!
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: lijp@sh.sct-grp.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
What does it mean “how can I realize that”?
Why don’t you call RtlCompareUnicodeString with two unicode string values and either specify a case sensitive or case insensitive comparison? If you have only buffers, you’ll just have to build two UNICODE_STRING structures (try RtlInitUnicodeString). Or perhaps you’d prefer using RtlEqualUnicodeString, which does a strict equality test and does not provide an ordering between the two strings.
Or perhaps you are asking for code samples that you can cut and paste. If you have the IFS Kit (and surely you must since you posted the same question in NTFSD) there are examples of using RtlCompareUnicodeString (src\filesys\smbmrx\wnet\sys\rename.c for example).
There’s also documentation about string handling (in general) as well as documentation for this particular call on the MSDN web site (try msdn.microsoft.com and doing a search for RtlCompareUnicodeString - you’ll find the only thing that comes up is the documentation from the DDK.)
Regards,
Tony
Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of SCT)???
Sent: Wednesday, March 24, 2004 2:54 AM
To: ntdev redirect
Subject: Re: Re:[ntdev] Question about RtlCompareUnicodeString
Thank you for your answer!
But if I want to deal with that,how can I realize that function?
----- Original Message -----
From: “David J. Craig”
Newsgroups: ntdev
To: “Windows System Software Devs Interest List”
Sent: Wednesday, March 24, 2004 12:52 PM
Subject: Re:[ntdev] Question about RtlCompareUnicodeString
> No, it doesn’t! UNICODE_STRING is a structure containing three items.
> One item is a wide character string, and the other two deal with
> lengths. There is no requirement to have the wide character string
> terminated with a 16-bit zero. Stay away from the string functions
> until you know how to make it safe. The ‘string’ functions are the
> primary problem with buffer overruns and should be avoided in drivers.
> This is also why the UNICODE_STRING data storage structure was invented.
> It is safe if you use the correct functions.
>
> “SCT$B!KM{7uJ?(J” wrote in message news:xxxxx@ntdev…
> > Hello everyone,
> > I want to compare two unicode string with length in my driver.
> > It looks like what strnicmp does.
> > RtlCompareUnicodeString can not do it!
> > How can I do it?
> > thank you very much!
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: lijp@sh.sct-grp.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@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
It appears you are asking how to do a case insensitive compare in the
kernel. Use RtlCompareUnicodeString it has a case insensitive flag.
–
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply
“SCT$B!KM{7uJ?(B” wrote in message news:xxxxx@ntdev…
Hello everyone,
I want to compare two unicode string with length in my driver.
It looks like what strnicmp does.
RtlCompareUnicodeString can not do it!
How can I do it?
thank you very much!
Look at Safe String operations in the online docs, and checkout NtStrSafe.h.
–
Gary G. Little
Seagate Technologies, LLC
“Don Burn” wrote in message news:xxxxx@ntdev…
> It appears you are asking how to do a case insensitive compare in the
> kernel. Use RtlCompareUnicodeString it has a case insensitive flag.
>
>
>
> –
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Remove StopSpam from the email to reply
>
> “SCT$B!KM{7uJ?(B” wrote in message
news:xxxxx@ntdev…
> Hello everyone,
> I want to compare two unicode string with length in my driver.
> It looks like what strnicmp does.
> RtlCompareUnicodeString can not do it!
> How can I do it?
> thank you very much!
>
>
>
Actually, it looks to me like he’s trying to do a strncmp (i.e. compare
the first N characters of a string). RtlCompareUnicodeString can’t do
this directly.
However, OP, if you store away the previous lengths and set the .Length
field of both UNICODE_STRINGs to N, then RtlCompareUnicodeString should
do what you want. Of course, you’ll want to restore the string lengths
to their previous values after doing this.
Don Burn wrote:
It appears you are asking how to do a case insensitive compare in the
kernel. Use RtlCompareUnicodeString it has a case insensitive flag.
–
…/ray..
Dear Ray Trent:
What I want is what you have said! I have done it .
You are so kind and smart, and I am so stupid : )
Thank you very much!
----- Original Message -----
From: “Ray Trent”
Newsgroups: ntdev
To: “Windows System Software Devs Interest List”
Sent: Thursday, March 25, 2004 8:40 AM
Subject: Re:[ntdev] Question about RtlCompareUnicodeString
> Actually, it looks to me like he’s trying to do a strncmp (i.e. compare
> the first N characters of a string). RtlCompareUnicodeString can’t do
> this directly.
>
> However, OP, if you store away the previous lengths and set the .Length
> field of both UNICODE_STRINGs to N, then RtlCompareUnicodeString should
> do what you want. Of course, you’ll want to restore the string lengths
> to their previous values after doing this.
>
> Don Burn wrote:
>
> > It appears you are asking how to do a case insensitive compare in the
> > kernel. Use RtlCompareUnicodeString it has a case insensitive flag.
> >
> >
> >
>
> –
> …/ray..
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: lijp@sh.sct-grp.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>