hi ,
I am using RtlUnicodeStringToAnsiString() to convert a Unicode string to
Ansi string, but the conversion is not working. my Ansi String buffer
contains no data.
The code snippet is given below
UNICODE_STRING tempeunicode;
ANSI_STRING tempansi;
NTSTATUS Status;
ULONG ansilen;
RtlInitUnicodeString(&tempeunicode,L"TEMPDATA");
RtlInitAnsiString(&tempansi,NULL);
ansilen = RtlUnicodeStringToAnsiSize(&tempeunicode);
DbgPrint( “Current IRQL %x \n”,KeGetCurrentIrql());
Status = RtlUnicodeStringToAnsiString(&tempansi,&tempeunicode,TRUE);
if( !NT_SUCCESS( Status ) )
{
DbgPrint( " RtlUnicodeStringToAnsiSize failed \n ");
return Status;
}
DbgPrint( “Current IRQL %x \n”,KeGetCurrentIrql());
RtlFreeAnsiString(&tempansi);
RtlFreeUnicodeString(&tempeunicode);
The data in the unicode string is a value queried from registry. There is
valid data in the unicode string during the call to
RtlUnicodeStringToAnsiString(). The call is getting called at IRQL
PASSIVE_LEVEL. The return status of RtlUnicodeStringToAnsiString() is
STATUS_SUCCESS.
I tried allocating the buffer for the ansi string before the call and
passing FALSE to RtlUnicodeStringToAnsiString(). Then also i observed same
behaviour.
The call to RtlUnicodeStringToAnsiSize() returns the size of the string as
1 .
I would like to know am i missing out something here, or is there some
other way to get this conversion done.
thanks in advance
with regards
San
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com