The call RtlInitUnicodeString() simply points the unicode.buffer value AT
the string you pass in. Hence there is no need to perform the allocation you
are doing. Do this:
UNICODE_STRING uniString;
RtlInitUnicodeString(&uniString, L".doc");
if (RtlCompareUnicodeString( &uniString, AnotherUnicodeString, TRUE) == 0)
do_something_that_might_or_not_blue_screen_my_system();
Pete
Kernel Drivers
Windows Filesystem and Device Driver Consulting
www.KernelDrivers.com
(303)546-0300
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Friday, November 03, 2006 12:52 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Kernel Mode is Stringing Me Along
So far, my experience with strings in kernel mode is very weird. Here’s
what I want to do:
WCHAR stringA = L".doc";
WCHAR *stringB = (get this from a function call of some sort);
if (stricmp(stringA, stringB) == 0)
do_something_marginally_intersting();
Here is how I am able to do this in my driver;
PUNICODE_STRING puString = NULL;
puString = ExAllocatePoolWithTag(NonPagedPool, sizeof(UNICODE_STRING),
TAGNAME);
RtlInitUnicodeString(puString, L".doc");
if (RtlCompareUnicodeString(puString, AnotherUnicodeString, TRUE) == 0)
do_something_that_might_or_not_blue_screen_my_system();
ExFreePoolWithTag(puString, TAGNAME);
What we have here is an explosion of code to do the simplest thing. I’m
using *the* RTL library, but it seems to suck for what you might think is
simple stuff.
Is there a better way or am I stuck converting every single little string I
want to use into a UNICODE_STRING?
Thanks!
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@kerneldrivers.com
To unsubscribe send a blank email to xxxxx@lists.osr.com