Dear All,(and assuming I have the right category for my problem) I will give you the long version in...
By peneann
ylafon (AT) w3 (DOT) org changed: What |Removed |Added Status|NEW |RESLVED Resolution| |FIXED Additi...
By bugzilla
JS <d44sf@44ada.com> writes:> I have downloaded swbuff from:> http://sourceforge.net/pro...
By timx
Hi:I apologize profusely for my persistance on this topic. Hopefully thiswill be the last time -- un...
By radium
Hi:Here is my hypothetical scenario:A two-hour movie is made using the finest video recording equipm...
By radium
HiyaMicrosoft .NET Passport is a suite of Web-based services that help make using the Internet and p...
By eddie5659
GreetingsI'am assuming ZwQueryInformationFile(..FileAlignmentInformation..) to always return FILE_B...
By anonymous
We would like to try to use Kupu instead of Epoz in a ZWiki without Plone.Has it been done?Zope mail...
By karl_eklund, 3 Comments
Hello all, I am new to project, so please forgive me if this is a simple item. I have looked, but ju...
By anonymous, 1 Comments
I've updated phase III of a 4-phase project. New resources were added, some resources were dele...
By anonymous, 7 Comments
Hi all If I boot the PC with the Ndis WDM device inserted, I get the following BSOD when ZwCreateFil...
By anonymous, 7 Comments
Hi, From my driver I want to allocate some virtual memory within a process if a particular DLL is lo...
By anonymous, 1 Comments
Hi, I'm trying to install an installshield script (the file is called ISScript.exe) in XP. When...
By yougottawanna, 1 Comments
Hey all,Recently, ZWiki stopped working on my zope 2.9.2 intel mac os x 10.4 box(python 2.4.2). It w...
By joshstephenson, 3 Comments
This is an article which I can see in the print edition but not onlineand hence have not posted it.D...
By kamal_r_prasad, 9 Comments
Why do you use PANSI_STRING and PUNICODE_STRING casts? It looks like
lHostname and/or valueInfoP->Data are not valid pointers to valid
ANSI_STRING and UNICODE_STRING structures. You need to intialize all members
in both structures.
"John Thompson" <johnthompson1...hotmail.com> wrote in message
news:4106c732$1...news.xetron.com...
> Hello,
> I'm trying to query the computer name from the following registry key:
> L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\ComputerName\\Act
> iveComputerName
> The key is:
> ComputerName
> I can successfully pull this value out of the registry. However, it is in
> the following format:
> Name[0] = J 0x4a
> Name[1] = \0 0x0
> Name[2] = I 0x49
> Name[3] = \0 0x0
> .
> .
> .
> Name[n-1] = \0 0x0
> Name[n] = \0 0x0
> I want to convert this unicode string to a regular string. However, when
> I
> call RtlUnicodeStringToAnsiString, I get an NTSTATUS error indicating that
> I
> have a buffer overrun.
> Here is my call to RtlUnicodeStringToAnsiString:
> RtlUnicodeStringToAnsiString((PANSI_STRING) lHostname, (PUNICODE_STRING)
> valueInfoP->Data, FALSE);
> I have done an ExAllocatePoolWithTag for the lHostname variable. Why
> doesn't this successfully convert to a regular string though?
> I've tried everything (well, obviously not everything). Any help would be
> greatly appreciated.
> Thank you,
> -- John
>
nospam | Tues, 20 May 2008 08:03:00 GMT |
How to CAST from PUNICODE_STRING to PANSI_STRING?
<nospam...cristalink.com> дÈëÏûÏ¢ÐÂÎÅ
:ukxoyZCdEHA.3016...tk2msftngp13.phx.gbl...
> Why do you use PANSI_STRING and PUNICODE_STRING casts? It looks like
> lHostname and/or valueInfoP->Data are not valid pointers to valid
> ANSI_STRING and UNICODE_STRING structures. You need to intialize all
members
> in both structures.
> "John Thompson" <johnthompson1...hotmail.com> wrote in message
> news:4106c732$1...news.xetron.com...
> > Hello,
> >
> > I'm trying to query the computer name from the following registry key:
> >
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\ComputerName\\Act
> > iveComputerName
> > The key is:
> > ComputerName
> >
> > I can successfully pull this value out of the registry. However, it is
in
> > the following format:
> > Name[0] = J 0x4a
> > Name[1] = \0 0x0
> > Name[2] = I 0x49
> > Name[3] = \0 0x0
> > .
> > .
> > .
> > Name[n-1] = \0 0x0
> > Name[n] = \0 0x0
> >
> > I want to convert this unicode string to a regular string. However,
when
> > I
> > call RtlUnicodeStringToAnsiString, I get an NTSTATUS error indicating
that
> > I
> > have a buffer overrun.
> >
> > Here is my call to RtlUnicodeStringToAnsiString:
> > RtlUnicodeStringToAnsiString((PANSI_STRING) lHostname, (PUNICODE_STRING)
> > valueInfoP->Data, FALSE);
> >
> > I have done an ExAllocatePoolWithTag for the lHostname variable. Why
> > doesn't this successfully convert to a regular string though?
> >
> > I've tried everything (well, obviously not everything). Any help would
be
> > greatly appreciated.
> >
> > Thank you,
> > -- John
> >
> >
>
sean | Tues, 20 May 2008 08:04:00 GMT |
You cannot "cast" but you can "convert" with RtlUnicodeStringToAnsiString().
You have to properly initialize parameters for
RtlUnicodeStringToAnsiString(), which are structures, not pointers to
zero-terminated strings. Can you feel the difference?
Copy-paste from ddk\src\wdm\videocap\atiwdm\atishare\registry.cpp:
char g_DebugComponent[]="Long long long output buffer";
ANSI_STRING stringDriverName;
UNICODE_STRING unicodeDriverName;
RtlInitAnsiString(&stringDriverName, g_DebugComponent);
RtlInitUnicodeString(&unicodeDriverName, L"Unicode string to be coverted");
RtlUnicodeStringToAnsiString(&stringDriverName, &unicodeDriverName, FALSE);
"sean" <sigang...mti.xidian.edu.cn> wrote in message
news:ce76t4$a07$1...mail.cn99.com...
> How to CAST from PUNICODE_STRING to PANSI_STRING?
> <nospam...cristalink.com> дÈëÏûÏ¢ÐÂÎÅ
> :ukxoyZCdEHA.3016...tk2msftngp13.phx.gbl...
>> Why do you use PANSI_STRING and PUNICODE_STRING casts? It looks like
>> lHostname and/or valueInfoP->Data are not valid pointers to valid
>> ANSI_STRING and UNICODE_STRING structures. You need to intialize all
> members
>> in both structures.
>> "John Thompson" <johnthompson1...hotmail.com> wrote in message
>> news:4106c732$1...news.xetron.com...
>> > Hello,
>> >
>> > I'm trying to query the computer name from the following registry key:
>> >
> L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\ComputerName\\Act
>> > iveComputerName
>> > The key is:
>> > ComputerName
>> >
>> > I can successfully pull this value out of the registry. However, it is
> in
>> > the following format:
>> > Name[0] = J 0x4a
>> > Name[1] = \0 0x0
>> > Name[2] = I 0x49
>> > Name[3] = \0 0x0
>> > .
>> > .
>> > .
>> > Name[n-1] = \0 0x0
>> > Name[n] = \0 0x0
>> >
>> > I want to convert this unicode string to a regular string. However,
> when
>> > I
>> > call RtlUnicodeStringToAnsiString, I get an NTSTATUS error indicating
> that
>> > I
>> > have a buffer overrun.
>> >
>> > Here is my call to RtlUnicodeStringToAnsiString:
>> > RtlUnicodeStringToAnsiString((PANSI_STRING) lHostname,
>> > (PUNICODE_STRING)
>> > valueInfoP->Data, FALSE);
>> >
>> > I have done an ExAllocatePoolWithTag for the lHostname variable. Why
>> > doesn't this successfully convert to a regular string though?
>> >
>> > I've tried everything (well, obviously not everything). Any help would
> be
>> > greatly appreciated.
>> >
>> > Thank you,
>> > -- John
>> >
>> >
>>
>
nospam | Tues, 20 May 2008 08:05:00 GMT |
Thanks guys,
I think I'm getting closer. This is what I have now:
ANSI_STRING lHostname;
UNICODE_STRING lUniHostname;
PKEY_VALUE_PARTIAL_INFORMATION PValueInfo;
RtlInitAnsiString(&lHostname, "Bla");
RtlInitUnicodeString(&lUniHostname, (PCWSTR) PValueInfo->Data);
// PValueInfo holds the value returned from the call to ZwQueryValueKey
status = RtlUnicodeStringToAnsiString(&lHostname, &lUniHostname, FALSE);
DbgPrint("ANSI = %s\n", lHostname.Buffer);
The DbgPrint seems to print out the first three letters of the computer's
name. However, status is still equal to:
0x80000005
This is still indicating a buffer overrun. Any other ideas?
Thanks again,
-- John
<nospam...cristalink.com> wrote in message
news:Orf29mFdEHA.3632...TK2MSFTNGP11.phx.gbl...
> You cannot "cast" but you can "convert" with
RtlUnicodeStringToAnsiString().
> You have to properly initialize parameters for
> RtlUnicodeStringToAnsiString(), which are structures, not pointers to
> zero-terminated strings. Can you feel the difference?
> Copy-paste from ddk\src\wdm\videocap\atiwdm\atishare\registry.cpp:
> char g_DebugComponent[]="Long long long output buffer";
> ANSI_STRING stringDriverName;
> UNICODE_STRING unicodeDriverName;
> RtlInitAnsiString(&stringDriverName, g_DebugComponent);
> RtlInitUnicodeString(&unicodeDriverName, L"Unicode string to be
coverted");
> RtlUnicodeStringToAnsiString(&stringDriverName, &unicodeDriverName,
FALSE);
>
> "sean" <sigang...mti.xidian.edu.cn> wrote in message
> news:ce76t4$a07$1...mail.cn99.com...
> > How to CAST from PUNICODE_STRING to PANSI_STRING?
> > <nospam...cristalink.com> дÈëÏûÏ¢ÐÂÎÅ
> > :ukxoyZCdEHA.3016...tk2msftngp13.phx.gbl...
> >> Why do you use PANSI_STRING and PUNICODE_STRING casts? It looks like
> >> lHostname and/or valueInfoP->Data are not valid pointers to valid
> >> ANSI_STRING and UNICODE_STRING structures. You need to intialize all
> > members
> >> in both structures.
> >>
> >> "John Thompson" <johnthompson1...hotmail.com> wrote in message
> >> news:4106c732$1...news.xetron.com...
> >> > Hello,
> >> >
> >> > I'm trying to query the computer name from the following registry
key:
> >> >
> >
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\ComputerName\\Act
> >> > iveComputerName
> >> > The key is:
> >> > ComputerName
> >> >
> >> > I can successfully pull this value out of the registry. However, it
is
> > in
> >> > the following format:
> >> > Name[0] = J 0x4a
> >> > Name[1] = \0 0x0
> >> > Name[2] = I 0x49
> >> > Name[3] = \0 0x0
> >> > .
> >> > .
> >> > .
> >> > Name[n-1] = \0 0x0
> >> > Name[n] = \0 0x0
> >> >
> >> > I want to convert this unicode string to a regular string. However,
> > when
> >> > I
> >> > call RtlUnicodeStringToAnsiString, I get an NTSTATUS error indicating
> > that
> >> > I
> >> > have a buffer overrun.
> >> >
> >> > Here is my call to RtlUnicodeStringToAnsiString:
> >> > RtlUnicodeStringToAnsiString((PANSI_STRING) lHostname,
> >> > (PUNICODE_STRING)
> >> > valueInfoP->Data, FALSE);
> >> >
> >> > I have done an ExAllocatePoolWithTag for the lHostname variable. Why
> >> > doesn't this successfully convert to a regular string though?
> >> >
> >> > I've tried everything (well, obviously not everything). Any help
would
> > be
> >> > greatly appreciated.
> >> >
> >> > Thank you,
> >> > -- John
> >> >
> >> >
> >>
> >>
> >
> >
>
john | Tues, 20 May 2008 08:06:00 GMT |
Whoops. Thank you no spam. :-) It's times like these I feel like I forgot
my brain. I just initialized the ANSI_STRING to a bigger buffer (hence the
buffer overrun), and now it works.
Thanks again,
-- John
"John Thompson" <johnthompson1...hotmail.com> wrote in message
news:4107a358$1...news.xetron.com...
> Thanks guys,
> I think I'm getting closer. This is what I have now:
> ANSI_STRING lHostname;
> UNICODE_STRING lUniHostname;
> PKEY_VALUE_PARTIAL_INFORMATION PValueInfo;
> RtlInitAnsiString(&lHostname, "Bla");
> RtlInitUnicodeString(&lUniHostname, (PCWSTR) PValueInfo->Data);
> // PValueInfo holds the value returned from the call to ZwQueryValueKey
> status = RtlUnicodeStringToAnsiString(&lHostname, &lUniHostname, FALSE);
> DbgPrint("ANSI = %s\n", lHostname.Buffer);
> The DbgPrint seems to print out the first three letters of the computer's
> name. However, status is still equal to:
> 0x80000005
> This is still indicating a buffer overrun. Any other ideas?
> Thanks again,
> -- John
>
> <nospam...cristalink.com> wrote in message
> news:Orf29mFdEHA.3632...TK2MSFTNGP11.phx.gbl...
> > You cannot "cast" but you can "convert" with
> RtlUnicodeStringToAnsiString().
> > You have to properly initialize parameters for
> > RtlUnicodeStringToAnsiString(), which are structures, not pointers to
> > zero-terminated strings. Can you feel the difference?
> >
> > Copy-paste from ddk\src\wdm\videocap\atiwdm\atishare\registry.cpp:
> >
> > char g_DebugComponent[]="Long long long output buffer";
> > ANSI_STRING stringDriverName;
> > UNICODE_STRING unicodeDriverName;
> >
> > RtlInitAnsiString(&stringDriverName, g_DebugComponent);
> > RtlInitUnicodeString(&unicodeDriverName, L"Unicode string to be
> coverted");
> > RtlUnicodeStringToAnsiString(&stringDriverName, &unicodeDriverName,
> FALSE);
> >
> >
> >
> > "sean" <sigang...mti.xidian.edu.cn> wrote in message
> > news:ce76t4$a07$1...mail.cn99.com...
> > > How to CAST from PUNICODE_STRING to PANSI_STRING?
> > > <nospam...cristalink.com> дÈëÏûÏ¢ÐÂÎÅ
> > > :ukxoyZCdEHA.3016...tk2msftngp13.phx.gbl...
> > >> Why do you use PANSI_STRING and PUNICODE_STRING casts? It looks like
> > >> lHostname and/or valueInfoP->Data are not valid pointers to valid
> > >> ANSI_STRING and UNICODE_STRING structures. You need to intialize all
> > > members
> > >> in both structures.
> > >>
> > >> "John Thompson" <johnthompson1...hotmail.com> wrote in message
> > >> news:4106c732$1...news.xetron.com...
> > >> > Hello,
> > >> >
> > >> > I'm trying to query the computer name from the following registry
> key:
> > >> >
> > >
>
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\ComputerName\\Act
> > >> > iveComputerName
> > >> > The key is:
> > >> > ComputerName
> > >> >
> > >> > I can successfully pull this value out of the registry. However,
it
> is
> > > in
> > >> > the following format:
> > >> > Name[0] = J 0x4a
> > >> > Name[1] = \0 0x0
> > >> > Name[2] = I 0x49
> > >> > Name[3] = \0 0x0
> > >> > .
> > >> > .
> > >> > .
> > >> > Name[n-1] = \0 0x0
> > >> > Name[n] = \0 0x0
> > >> >
> > >> > I want to convert this unicode string to a regular string.
However,
> > > when
> > >> > I
> > >> > call RtlUnicodeStringToAnsiString, I get an NTSTATUS error
indicating
> > > that
> > >> > I
> > >> > have a buffer overrun.
> > >> >
> > >> > Here is my call to RtlUnicodeStringToAnsiString:
> > >> > RtlUnicodeStringToAnsiString((PANSI_STRING) lHostname,
> > >> > (PUNICODE_STRING)
> > >> > valueInfoP->Data, FALSE);
> > >> >
> > >> > I have done an ExAllocatePoolWithTag for the lHostname variable.
Why
> > >> > doesn't this successfully convert to a regular string though?
> > >> >
> > >> > I've tried everything (well, obviously not everything). Any help
> would
> > > be
> > >> > greatly appreciated.
> > >> >
> > >> > Thank you,
> > >> > -- John
> > >> >
> > >> >
> > >>
> > >>
> > >
> > >
> >
> >
>
john | Tues, 20 May 2008 08:07:00 GMT |
Don't use a string constant to initialize ANSI_STRING (and UNICODE_STRING)
if you plan to modify this string. It may be placed to read-only memory.
"John Thompson" <johnthompson1...hotmail.com> wrote in message
news:4107a358$1...news.xetron.com...
> Thanks guys,
> I think I'm getting closer. This is what I have now:
> ANSI_STRING lHostname;
> UNICODE_STRING lUniHostname;
> PKEY_VALUE_PARTIAL_INFORMATION PValueInfo;
> RtlInitAnsiString(&lHostname, "Bla");
> RtlInitUnicodeString(&lUniHostname, (PCWSTR) PValueInfo->Data);
> // PValueInfo holds the value returned from the call to ZwQueryValueKey
> status = RtlUnicodeStringToAnsiString(&lHostname, &lUniHostname, FALSE);
> DbgPrint("ANSI = %s\n", lHostname.Buffer);
> The DbgPrint seems to print out the first three letters of the computer's
> name. However, status is still equal to:
> 0x80000005
> This is still indicating a buffer overrun. Any other ideas?
> Thanks again,
> -- John
>
> <nospam...cristalink.com> wrote in message
> news:Orf29mFdEHA.3632...TK2MSFTNGP11.phx.gbl...
> > You cannot "cast" but you can "convert" with
> RtlUnicodeStringToAnsiString().
> > You have to properly initialize parameters for
> > RtlUnicodeStringToAnsiString(), which are structures, not pointers to
> > zero-terminated strings. Can you feel the difference?
> >
> > Copy-paste from ddk\src\wdm\videocap\atiwdm\atishare\registry.cpp:
> >
> > char g_DebugComponent[]="Long long long output buffer";
> > ANSI_STRING stringDriverName;
> > UNICODE_STRING unicodeDriverName;
> >
> > RtlInitAnsiString(&stringDriverName, g_DebugComponent);
> > RtlInitUnicodeString(&unicodeDriverName, L"Unicode string to be
> coverted");
> > RtlUnicodeStringToAnsiString(&stringDriverName, &unicodeDriverName,
> FALSE);
> >
> >
> >
> > "sean" <sigang...mti.xidian.edu.cn> wrote in message
> > news:ce76t4$a07$1...mail.cn99.com...
> > > How to CAST from PUNICODE_STRING to PANSI_STRING?
> > > <nospam...cristalink.com> дÈëÏûÏ¢ÐÂÎÅ
> > > :ukxoyZCdEHA.3016...tk2msftngp13.phx.gbl...
> > >> Why do you use PANSI_STRING and PUNICODE_STRING casts? It looks like
> > >> lHostname and/or valueInfoP->Data are not valid pointers to valid
> > >> ANSI_STRING and UNICODE_STRING structures. You need to intialize all
> > > members
> > >> in both structures.
> > >>
> > >> "John Thompson" <johnthompson1...hotmail.com> wrote in message
> > >> news:4106c732$1...news.xetron.com...
> > >> > Hello,
> > >> >
> > >> > I'm trying to query the computer name from the following registry
> key:
> > >> >
> > >
>
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\ComputerName\\Act
> > >> > iveComputerName
> > >> > The key is:
> > >> > ComputerName
> > >> >
> > >> > I can successfully pull this value out of the registry. However,
it
> is
> > > in
> > >> > the following format:
> > >> > Name[0] = J 0x4a
> > >> > Name[1] = \0 0x0
> > >> > Name[2] = I 0x49
> > >> > Name[3] = \0 0x0
> > >> > .
> > >> > .
> > >> > .
> > >> > Name[n-1] = \0 0x0
> > >> > Name[n] = \0 0x0
> > >> >
> > >> > I want to convert this unicode string to a regular string.
However,
> > > when
> > >> > I
> > >> > call RtlUnicodeStringToAnsiString, I get an NTSTATUS error
indicating
> > > that
> > >> > I
> > >> > have a buffer overrun.
> > >> >
> > >> > Here is my call to RtlUnicodeStringToAnsiString:
> > >> > RtlUnicodeStringToAnsiString((PANSI_STRING) lHostname,
> > >> > (PUNICODE_STRING)
> > >> > valueInfoP->Data, FALSE);
> > >> >
> > >> > I have done an ExAllocatePoolWithTag for the lHostname variable.
Why
> > >> > doesn't this successfully convert to a regular string though?
> > >> >
> > >> > I've tried everything (well, obviously not everything). Any help
> would
> > > be
> > >> > greatly appreciated.
> > >> >
> > >> > Thank you,
> > >> > -- John
> > >> >
> > >> >
> > >>
> > >>
> > >
> > >
> >
> >
>
alexander | Tues, 20 May 2008 08:08:00 GMT |
these are constant
1 RtlInitAnsiString(IHostname, "Bla");
2 PUCHAR pBla = "Bla";
this on the other hand is not constant and is safe b/c it is declared on the
stack in its entirety.
UCHAR bla[] = "Bla"
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.
"Alexander Grigoriev" <alegr...earthlink.net> wrote in message
news:e3BMomKdEHA.2408...tk2msftngp13.phx.gbl...
> Don't use a string constant to initialize ANSI_STRING (and UNICODE_STRING)
> if you plan to modify this string. It may be placed to read-only memory.
> "John Thompson" <johnthompson1...hotmail.com> wrote in message
> news:4107a358$1...news.xetron.com...
> > Thanks guys,
> >
> > I think I'm getting closer. This is what I have now:
> > ANSI_STRING lHostname;
> > UNICODE_STRING lUniHostname;
> > PKEY_VALUE_PARTIAL_INFORMATION PValueInfo;
> >
> > RtlInitAnsiString(&lHostname, "Bla");
> > RtlInitUnicodeString(&lUniHostname, (PCWSTR) PValueInfo->Data);
> > // PValueInfo holds the value returned from the call to ZwQueryValueKey
> >
> > status = RtlUnicodeStringToAnsiString(&lHostname, &lUniHostname, FALSE);
> > DbgPrint("ANSI = %s\n", lHostname.Buffer);
> >
> > The DbgPrint seems to print out the first three letters of the
computer's
> > name. However, status is still equal to:
> > 0x80000005
> > This is still indicating a buffer overrun. Any other ideas?
> >
> > Thanks again,
> > -- John
> >
> >
> >
> > <nospam...cristalink.com> wrote in message
> > news:Orf29mFdEHA.3632...TK2MSFTNGP11.phx.gbl...
> > > You cannot "cast" but you can "convert" with
> > RtlUnicodeStringToAnsiString().
> > > You have to properly initialize parameters for
> > > RtlUnicodeStringToAnsiString(), which are structures, not pointers to
> > > zero-terminated strings. Can you feel the difference?
> > >
> > > Copy-paste from ddk\src\wdm\videocap\atiwdm\atishare\registry.cpp:
> > >
> > > char g_DebugComponent[]="Long long long output buffer";
> > > ANSI_STRING stringDriverName;
> > > UNICODE_STRING unicodeDriverName;
> > >
> > > RtlInitAnsiString(&stringDriverName, g_DebugComponent);
> > > RtlInitUnicodeString(&unicodeDriverName, L"Unicode string to be
> > coverted");
> > > RtlUnicodeStringToAnsiString(&stringDriverName, &unicodeDriverName,
> > FALSE);
> > >
> > >
> > >
> > > "sean" <sigang...mti.xidian.edu.cn> wrote in message
> > > news:ce76t4$a07$1...mail.cn99.com...
> > > > How to CAST from PUNICODE_STRING to PANSI_STRING?
> > > > <nospam...cristalink.com> дÈëÏûÏ¢ÐÂÎÅ
> > > > :ukxoyZCdEHA.3016...tk2msftngp13.phx.gbl...
> > > >> Why do you use PANSI_STRING and PUNICODE_STRING casts? It looks
like
> > > >> lHostname and/or valueInfoP->Data are not valid pointers to valid
> > > >> ANSI_STRING and UNICODE_STRING structures. You need to intialize
all
> > > > members
> > > >> in both structures.
> > > >>
> > > >> "John Thompson" <johnthompson1...hotmail.com> wrote in message
> > > >> news:4106c732$1...news.xetron.com...
> > > >> > Hello,
> > > >> >
> > > >> > I'm trying to query the computer name from the following registry
> > key:
> > > >> >
> > > >
> >
>
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\ComputerName\\Act
> > > >> > iveComputerName
> > > >> > The key is:
> > > >> > ComputerName
> > > >> >
> > > >> > I can successfully pull this value out of the registry. However,
> it
> > is
> > > > in
> > > >> > the following format:
> > > >> > Name[0] = J 0x4a
> > > >> > Name[1] = \0 0x0
> > > >> > Name[2] = I 0x49
> > > >> > Name[3] = \0 0x0
> > > >> > .
> > > >> > .
> > > >> > .
> > > >> > Name[n-1] = \0 0x0
> > > >> > Name[n] = \0 0x0
> > > >> >
> > > >> > I want to convert this unicode string to a regular string.
> However,
> > > > when
> > > >> > I
> > > >> > call RtlUnicodeStringToAnsiString, I get an NTSTATUS error
> indicating
> > > > that
> > > >> > I
> > > >> > have a buffer overrun.
> > > >> >
> > > >> > Here is my call to RtlUnicodeStringToAnsiString:
> > > >> > RtlUnicodeStringToAnsiString((PANSI_STRING) lHostname,
> > > >> > (PUNICODE_STRING)
> > > >> > valueInfoP->Data, FALSE);
> > > >> >
> > > >> > I have done an ExAllocatePoolWithTag for the lHostname variable.
> Why
> > > >> > doesn't this successfully convert to a regular string though?
> > > >> >
> > > >> > I've tried everything (well, obviously not everything). Any help
> > would
> > > > be
> > > >> > greatly appreciated.
> > > >> >
> > > >> > Thank you,
> > > >> > -- John
> > > >> >
> > > >> >
> > > >>
> > > >>
> > > >
> > > >
> > >
> > >
> >
> >
>
doron | Tues, 20 May 2008 08:09:00 GMT |
Good to know. Thanks guys. I suppose you can tell I'm a little new to
driver development. :-)
Thanks for the help.
"Doron Holan [MS]" <doronh...nospam.microsoft.com> wrote in message
news:uRFe6WLdEHA.3728...TK2MSFTNGP09.phx.gbl...
> these are constant
> 1 RtlInitAnsiString(IHostname, "Bla");
> 2 PUCHAR pBla = "Bla";
> this on the other hand is not constant and is safe b/c it is declared on
the
> stack in its entirety.
> UCHAR bla[] = "Bla"
> 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.
>
> "Alexander Grigoriev" <alegr...earthlink.net> wrote in message
> news:e3BMomKdEHA.2408...tk2msftngp13.phx.gbl...
> > Don't use a string constant to initialize ANSI_STRING (and
UNICODE_STRING)
> > if you plan to modify this string. It may be placed to read-only memory.
> >
> > "John Thompson" <johnthompson1...hotmail.com> wrote in message
> > news:4107a358$1...news.xetron.com...
> > > Thanks guys,
> > >
> > > I think I'm getting closer. This is what I have now:
> > > ANSI_STRING lHostname;
> > > UNICODE_STRING lUniHostname;
> > > PKEY_VALUE_PARTIAL_INFORMATION PValueInfo;
> > >
> > > RtlInitAnsiString(&lHostname, "Bla");
> > > RtlInitUnicodeString(&lUniHostname, (PCWSTR) PValueInfo->Data);
> > > // PValueInfo holds the value returned from the call to
ZwQueryValueKey
> > >
> > > status = RtlUnicodeStringToAnsiString(&lHostname, &lUniHostname,
FALSE);
> > > DbgPrint("ANSI = %s\n", lHostname.Buffer);
> > >
> > > The DbgPrint seems to print out the first three letters of the
> computer's
> > > name. However, status is still equal to:
> > > 0x80000005
> > > This is still indicating a buffer overrun. Any other ideas?
> > >
> > > Thanks again,
> > > -- John
> > >
> > >
> > >
> > > <nospam...cristalink.com> wrote in message
> > > news:Orf29mFdEHA.3632...TK2MSFTNGP11.phx.gbl...
> > > > You cannot "cast" but you can "convert" with
> > > RtlUnicodeStringToAnsiString().
> > > > You have to properly initialize parameters for
> > > > RtlUnicodeStringToAnsiString(), which are structures, not pointers
to
> > > > zero-terminated strings. Can you feel the difference?
> > > >
> > > > Copy-paste from ddk\src\wdm\videocap\atiwdm\atishare\registry.cpp:
> > > >
> > > > char g_DebugComponent[]="Long long long output buffer";
> > > > ANSI_STRING stringDriverName;
> > > > UNICODE_STRING unicodeDriverName;
> > > >
> > > > RtlInitAnsiString(&stringDriverName, g_DebugComponent);
> > > > RtlInitUnicodeString(&unicodeDriverName, L"Unicode string to be
> > > coverted");
> > > > RtlUnicodeStringToAnsiString(&stringDriverName, &unicodeDriverName,
> > > FALSE);
> > > >
> > > >
> > > >
> > > > "sean" <sigang...mti.xidian.edu.cn> wrote in message
> > > > news:ce76t4$a07$1...mail.cn99.com...
> > > > > How to CAST from PUNICODE_STRING to PANSI_STRING?
> > > > > <nospam...cristalink.com> дÈëÏûÏ¢ÐÂÎÅ
> > > > > :ukxoyZCdEHA.3016...tk2msftngp13.phx.gbl...
> > > > >> Why do you use PANSI_STRING and PUNICODE_STRING casts? It looks
> like
> > > > >> lHostname and/or valueInfoP->Data are not valid pointers to valid
> > > > >> ANSI_STRING and UNICODE_STRING structures. You need to intialize
> all
> > > > > members
> > > > >> in both structures.
> > > > >>
> > > > >> "John Thompson" <johnthompson1...hotmail.com> wrote in message
> > > > >> news:4106c732$1...news.xetron.com...
> > > > >> > Hello,
> > > > >> >
> > > > >> > I'm trying to query the computer name from the following
registry
> > > key:
> > > > >> >
> > > > >
> > >
> >
>
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\ComputerName\\Act
> > > > >> > iveComputerName
> > > > >> > The key is:
> > > > >> > ComputerName
> > > > >> >
> > > > >> > I can successfully pull this value out of the registry.
However,
> > it
> > > is
> > > > > in
> > > > >> > the following format:
> > > > >> > Name[0] = J 0x4a
> > > > >> > Name[1] = \0 0x0
> > > > >> > Name[2] = I 0x49
> > > > >> > Name[3] = \0 0x0
> > > > >> > .
> > > > >> > .
> > > > >> > .
> > > > >> > Name[n-1] = \0 0x0
> > > > >> > Name[n] = \0 0x0
> > > > >> >
> > > > >> > I want to convert this unicode string to a regular string.
> > However,
> > > > > when
> > > > >> > I
> > > > >> > call RtlUnicodeStringToAnsiString, I get an NTSTATUS error
> > indicating
> > > > > that
> > > > >> > I
> > > > >> > have a buffer overrun.
> > > > >> >
> > > > >> > Here is my call to RtlUnicodeStringToAnsiString:
> > > > >> > RtlUnicodeStringToAnsiString((PANSI_STRING) lHostname,
> > > > >> > (PUNICODE_STRING)
> > > > >> > valueInfoP->Data, FALSE);
> > > > >> >
> > > > >> > I have done an ExAllocatePoolWithTag for the lHostname
variable.
> > Why
> > > > >> > doesn't this successfully convert to a regular string though?
> > > > >> >
> > > > >> > I've tried everything (well, obviously not everything). Any
help
> > > would
> > > > > be
> > > > >> > greatly appreciated.
> > > > >> >
> > > > >> > Thank you,
> > > > >> > -- John
> > > > >> >
> > > > >> >
> > > > >>
> > > > >>
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
john | Tues, 20 May 2008 08:10:00 GMT |