RtlAppendUnicode String problem.

Dear All,

I have two Unicode strings named linkFileName and linkFullFileName. I have
to convert an integer to Unicode string (linkFileName), and then append that
Unicode string to the other Unicode String, linkFullFileName.

I have been able to convert the integer to Unicode string but when I append
this Unicode string to other Unicode string, it doesn’t works and the system
crashes with Stop Code:

KMODE_EXCEPTION_NOT_HANDLED 0x1E having first parameter as 0xC0000005

For that I have written following code:
////////////////////////////////////////////////////////////////////////////
////////////////
int dummy;
UNICODE_STRING temp;
UNICODE_STRING linkFileName;
UNICODE_STRING linkFullFileName;

linkFileName.MaximumLength = 30;
linkFileName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
linkFileName.MaximumLength,‘2leM’);

linkFullFileName.MaximumLength = 50 ;
linkFullFileName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
linkFullFileName.MaximumLength,‘2leM’);

LINE1) dummy = 7; // Initialize value of dummy of integer type

LINE2) _itow(dummy,linkFileName.Buffer, 10); // placing it into
linkFileName.Buffer

LINE3) RtlInitUnicodeString(&temp,L"BOND00"); //temp is initialized to BOND

LINE4) RtlCopyUnicodeString(&linkFullFileName, &temp);

LINE5) RtlAppendUnicodeStringToString(&linkFullFileName, &linkFileName); //
NOT WORKING ,Why??

LINE6) DbgPrint(“\n #NEW CODE linkFileName = %wZ”,&linkFileName); //
Result > #NEW CODE linkFileName = 7

LINE7) DbgPrint(“\n #NEW CODE linkFullFileName = %wZ”,&linkFullFileName);
//NOT WORKING FINE

// Result > #NEW CODE linkFullFileName = BOND00

//Where as it should print “BOND007”

ExFreePoolWithTag(linkFileName.Buffer,‘pmoC’);

ExFreePoolWithTag(linkFullFileName.Buffer,‘pmoC’);

////////////////////////////////////////////////////////////////////////////
////////////////

Please suggest a way out to solve this problem or any alternate way to
achieve the same.

Regards,
Rohit

Rohit

Far as I can see your code does not set temp.Length perhaps this is the
problem?

Cheers
Lyndon

“Rohit Dhamija” wrote in message
news:xxxxx@ntfsd…
> Dear All,
>
>
>
> I have two Unicode strings named linkFileName and linkFullFileName. I have
> to convert an integer to Unicode string (linkFileName), and then append
that
> Unicode string to the other Unicode String, linkFullFileName.
>
>
>
> I have been able to convert the integer to Unicode string but when I
append
> this Unicode string to other Unicode string, it doesn’t works and the
system
> crashes with Stop Code:
>
> KMODE_EXCEPTION_NOT_HANDLED 0x1E having first parameter as 0xC0000005
>
>
>
> For that I have written following code:
>
////////////////////////////////////////////////////////////////////////////
> ////////////////
> int dummy;
> UNICODE_STRING temp;
> UNICODE_STRING linkFileName;
> UNICODE_STRING linkFullFileName;
>
>
>
> linkFileName.MaximumLength = 30;
> linkFileName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
> linkFileName.MaximumLength,‘2leM’);
>
>
>
> linkFullFileName.MaximumLength = 50 ;
> linkFullFileName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
> linkFullFileName.MaximumLength,‘2leM’);
>
>
>
>
>
>
>
> LINE1) dummy = 7; // Initialize value of dummy of integer type
>
>
>
> LINE2) _itow(dummy,linkFileName.Buffer, 10); // placing it into
> linkFileName.Buffer
>
> LINE3) RtlInitUnicodeString(&temp,L"BOND00"); //temp is initialized to
BOND
>
>
>
> LINE4) RtlCopyUnicodeString(&linkFullFileName, &temp);
>
>
>
> LINE5) RtlAppendUnicodeStringToString(&linkFullFileName, &linkFileName);
//
> NOT WORKING ,Why??
>
>
>
> LINE6) DbgPrint(“\n #NEW CODE linkFileName = %wZ”,&linkFileName); //
> Result > #NEW CODE linkFileName = 7
>
>
>
> LINE7) DbgPrint(“\n #NEW CODE linkFullFileName = %wZ”,&linkFullFileName);
> //NOT WORKING FINE
>
>
>
> // Result > #NEW CODE linkFullFileName = BOND00
>
>
>
> //Where as it should print “BOND007”
>
>
>
> ExFreePoolWithTag(linkFileName.Buffer,‘pmoC’);
>
> ExFreePoolWithTag(linkFullFileName.Buffer,‘pmoC’);
>
>
////////////////////////////////////////////////////////////////////////////
> ////////////////
>
>
>
> Please suggest a way out to solve this problem or any alternate way to
> achieve the same.
>
>
>
> Regards,
> Rohit
>
>
>
>
>

Rohit

Oops should have said linkFileName.length instead of temp.Length :wink:

Perhaps RtlAppendUnicodeString uses the Length field? Say you add the line
linkFileName.Length = wcslen(temp.Buffer) * sizeof(WCHAR);

right after the _itow call and see if the code works?

You could look at the NtStrSafe calls also.

Good luck

Lyndon

“Lyndon J Clarke” wrote in message
news:xxxxx@ntfsd…
> Rohit
>
> Far as I can see your code does not set temp.Length perhaps this is the
> problem?
>
> Cheers
> Lyndon
>
> “Rohit Dhamija” wrote in message
> news:xxxxx@ntfsd…
> > Dear All,
> >
> >
> >
> > I have two Unicode strings named linkFileName and linkFullFileName. I
have
> > to convert an integer to Unicode string (linkFileName), and then append
> that
> > Unicode string to the other Unicode String, linkFullFileName.
> >
> >
> >
> > I have been able to convert the integer to Unicode string but when I
> append
> > this Unicode string to other Unicode string, it doesn’t works and the
> system
> > crashes with Stop Code:
> >
> > KMODE_EXCEPTION_NOT_HANDLED 0x1E having first parameter as 0xC0000005
> >
> >
> >
> > For that I have written following code:
> >
>
////////////////////////////////////////////////////////////////////////////
> > ////////////////
> > int dummy;
> > UNICODE_STRING temp;
> > UNICODE_STRING linkFileName;
> > UNICODE_STRING linkFullFileName;
> >
> >
> >
> > linkFileName.MaximumLength = 30;
> > linkFileName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
> > linkFileName.MaximumLength,‘2leM’);
> >
> >
> >
> > linkFullFileName.MaximumLength = 50 ;
> > linkFullFileName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
> > linkFullFileName.MaximumLength,‘2leM’);
> >
> >
> >
> >
> >
> >
> >
> > LINE1) dummy = 7; // Initialize value of dummy of integer type
> >
> >
> >
> > LINE2) _itow(dummy,linkFileName.Buffer, 10); // placing it into
> > linkFileName.Buffer
> >
> > LINE3) RtlInitUnicodeString(&temp,L"BOND00"); //temp is initialized to
> BOND
> >
> >
> >
> > LINE4) RtlCopyUnicodeString(&linkFullFileName, &temp);
> >
> >
> >
> > LINE5) RtlAppendUnicodeStringToString(&linkFullFileName, &linkFileName);
> //
> > NOT WORKING ,Why??
> >
> >
> >
> > LINE6) DbgPrint(“\n #NEW CODE linkFileName = %wZ”,&linkFileName); //
> > Result > #NEW CODE linkFileName = 7
> >
> >
> >
> > LINE7) DbgPrint(“\n #NEW CODE linkFullFileName =
%wZ”,&linkFullFileName);
> > //NOT WORKING FINE
> >
> >
> >
> > // Result > #NEW CODE linkFullFileName = BOND00
> >
> >
> >
> > //Where as it should print “BOND007”
> >
> >
> >
> > ExFreePoolWithTag(linkFileName.Buffer,‘pmoC’);
> >
> > ExFreePoolWithTag(linkFullFileName.Buffer,‘pmoC’);
> >
> >
>
////////////////////////////////////////////////////////////////////////////
> > ////////////////
> >
> >
> >
> > Please suggest a way out to solve this problem or any alternate way to
> > achieve the same.
> >
> >
> >
> > Regards,
> > Rohit
> >
> >
> >
> >
> >
>
>
>

Dear Mr Clarke,

Thanks a lot! This actually worked.

Regards,
Rohit
“Lyndon J Clarke” wrote in message
news:xxxxx@ntfsd…
> Rohit
>
> Oops should have said linkFileName.length instead of temp.Length :wink:
>
> Perhaps RtlAppendUnicodeString uses the Length field? Say you add the line
> linkFileName.Length = wcslen(temp.Buffer) * sizeof(WCHAR);
>
> right after the _itow call and see if the code works?
>
> You could look at the NtStrSafe calls also.
>
> Good luck
>
> Lyndon
>
>
>
> “Lyndon J Clarke” wrote in message
> news:xxxxx@ntfsd…
> > Rohit
> >
> > Far as I can see your code does not set temp.Length perhaps this is the
> > problem?
> >
> > Cheers
> > Lyndon
> >
> > “Rohit Dhamija” wrote in message
> > news:xxxxx@ntfsd…
> > > Dear All,
> > >
> > >
> > >
> > > I have two Unicode strings named linkFileName and linkFullFileName. I
> have
> > > to convert an integer to Unicode string (linkFileName), and then
append
> > that
> > > Unicode string to the other Unicode String, linkFullFileName.
> > >
> > >
> > >
> > > I have been able to convert the integer to Unicode string but when I
> > append
> > > this Unicode string to other Unicode string, it doesn’t works and the
> > system
> > > crashes with Stop Code:
> > >
> > > KMODE_EXCEPTION_NOT_HANDLED 0x1E having first parameter as 0xC0000005
> > >
> > >
> > >
> > > For that I have written following code:
> > >
> >
>
////////////////////////////////////////////////////////////////////////////
> > > ////////////////
> > > int dummy;
> > > UNICODE_STRING temp;
> > > UNICODE_STRING linkFileName;
> > > UNICODE_STRING linkFullFileName;
> > >
> > >
> > >
> > > linkFileName.MaximumLength = 30;
> > > linkFileName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
> > > linkFileName.MaximumLength,‘2leM’);
> > >
> > >
> > >
> > > linkFullFileName.MaximumLength = 50 ;
> > > linkFullFileName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
> > > linkFullFileName.MaximumLength,‘2leM’);
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > LINE1) dummy = 7; // Initialize value of dummy of integer type
> > >
> > >
> > >
> > > LINE2) _itow(dummy,linkFileName.Buffer, 10); // placing it into
> > > linkFileName.Buffer
> > >
> > > LINE3) RtlInitUnicodeString(&temp,L"BOND00"); //temp is initialized
to
> > BOND
> > >
> > >
> > >
> > > LINE4) RtlCopyUnicodeString(&linkFullFileName, &temp);
> > >
> > >
> > >
> > > LINE5) RtlAppendUnicodeStringToString(&linkFullFileName,
&linkFileName);
> > //
> > > NOT WORKING ,Why??
> > >
> > >
> > >
> > > LINE6) DbgPrint(“\n #NEW CODE linkFileName = %wZ”,&linkFileName); //
> > > Result > #NEW CODE linkFileName = 7
> > >
> > >
> > >
> > > LINE7) DbgPrint(“\n #NEW CODE linkFullFileName =
> %wZ”,&linkFullFileName);
> > > //NOT WORKING FINE
> > >
> > >
> > >
> > > // Result > #NEW CODE linkFullFileName = BOND00
> > >
> > >
> > >
> > > //Where as it should print “BOND007”
> > >
> > >
> > >
> > > ExFreePoolWithTag(linkFileName.Buffer,‘pmoC’);
> > >
> > > ExFreePoolWithTag(linkFullFileName.Buffer,‘pmoC’);
> > >
> > >
> >
>
////////////////////////////////////////////////////////////////////////////
> > > ////////////////
> > >
> > >
> > >
> > > Please suggest a way out to solve this problem or any alternate way to
> > > achieve the same.
> > >
> > >
> > >
> > > Regards,
> > > Rohit
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
>
>
>

Dear Mr Clarke,

Can you please tell me how can ntstrsafe.h help me in further understading
of such types of errors, especially to this one ?
Regards,
Rohit
“Rohit Dhamija” wrote in message
news:xxxxx@ntfsd…
> Dear Mr Clarke,
>
> Thanks a lot! This actually worked.
>
> Regards,
> Rohit
> “Lyndon J Clarke” wrote in message
> news:xxxxx@ntfsd…
> > Rohit
> >
> > Oops should have said linkFileName.length instead of temp.Length :wink:
> >
> > Perhaps RtlAppendUnicodeString uses the Length field? Say you add the
line
> > linkFileName.Length = wcslen(temp.Buffer) * sizeof(WCHAR);
> >
> > right after the _itow call and see if the code works?
> >
> > You could look at the NtStrSafe calls also.
> >
> > Good luck
> >
> > Lyndon
> >
> >
> >
> > “Lyndon J Clarke” wrote in message
> > news:xxxxx@ntfsd…
> > > Rohit
> > >
> > > Far as I can see your code does not set temp.Length perhaps this is
the
> > > problem?
> > >
> > > Cheers
> > > Lyndon
> > >
> > > “Rohit Dhamija” wrote in message
> > > news:xxxxx@ntfsd…
> > > > Dear All,
> > > >
> > > >
> > > >
> > > > I have two Unicode strings named linkFileName and linkFullFileName.
I
> > have
> > > > to convert an integer to Unicode string (linkFileName), and then
> append
> > > that
> > > > Unicode string to the other Unicode String, linkFullFileName.
> > > >
> > > >
> > > >
> > > > I have been able to convert the integer to Unicode string but when I
> > > append
> > > > this Unicode string to other Unicode string, it doesn’t works and
the
> > > system
> > > > crashes with Stop Code:
> > > >
> > > > KMODE_EXCEPTION_NOT_HANDLED 0x1E having first parameter as
0xC0000005
> > > >
> > > >
> > > >
> > > > For that I have written following code:
> > > >
> > >
> >
>
////////////////////////////////////////////////////////////////////////////
> > > > ////////////////
> > > > int dummy;
> > > > UNICODE_STRING temp;
> > > > UNICODE_STRING linkFileName;
> > > > UNICODE_STRING linkFullFileName;
> > > >
> > > >
> > > >
> > > > linkFileName.MaximumLength = 30;
> > > > linkFileName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
> > > > linkFileName.MaximumLength,‘2leM’);
> > > >
> > > >
> > > >
> > > > linkFullFileName.MaximumLength = 50 ;
> > > > linkFullFileName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
> > > > linkFullFileName.MaximumLength,‘2leM’);
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > LINE1) dummy = 7; // Initialize value of dummy of integer type
> > > >
> > > >
> > > >
> > > > LINE2) _itow(dummy,linkFileName.Buffer, 10); // placing it into
> > > > linkFileName.Buffer
> > > >
> > > > LINE3) RtlInitUnicodeString(&temp,L"BOND00"); //temp is initialized
> to
> > > BOND
> > > >
> > > >
> > > >
> > > > LINE4) RtlCopyUnicodeString(&linkFullFileName, &temp);
> > > >
> > > >
> > > >
> > > > LINE5) RtlAppendUnicodeStringToString(&linkFullFileName,
> &linkFileName);
> > > //
> > > > NOT WORKING ,Why??
> > > >
> > > >
> > > >
> > > > LINE6) DbgPrint(“\n #NEW CODE linkFileName = %wZ”,&linkFileName);
//
> > > > Result > #NEW CODE linkFileName = 7
> > > >
> > > >
> > > >
> > > > LINE7) DbgPrint(“\n #NEW CODE linkFullFileName =
> > %wZ”,&linkFullFileName);
> > > > //NOT WORKING FINE
> > > >
> > > >
> > > >
> > > > // Result > #NEW CODE linkFullFileName = BOND00
> > > >
> > > >
> > > >
> > > > //Where as it should print “BOND007”
> > > >
> > > >
> > > >
> > > > ExFreePoolWithTag(linkFileName.Buffer,‘pmoC’);
> > > >
> > > > ExFreePoolWithTag(linkFullFileName.Buffer,‘pmoC’);
> > > >
> > > >
> > >
> >
>
////////////////////////////////////////////////////////////////////////////
> > > > ////////////////
> > > >
> > > >
> > > >
> > > > Please suggest a way out to solve this problem or any alternate way
to
> > > > achieve the same.
> > > >
> > > >
> > > >
> > > > Regards,
> > > > Rohit
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> >
> >
> >
>
>
>

Delighted that your code now works. Regarding ntstrsafe.h its just that
there are a bunch of safer string functions there that tend to fail instead
of bugcheck.

“Rohit Dhamija” wrote in message
news:xxxxx@ntfsd…
> Dear Mr Clarke,
>
> Can you please tell me how can ntstrsafe.h help me in further understading
> of such types of errors, especially to this one ?
> Regards,
> Rohit
> “Rohit Dhamija” wrote in message
> news:xxxxx@ntfsd…
> > Dear Mr Clarke,
> >
> > Thanks a lot! This actually worked.
> >
> > Regards,
> > Rohit
> > “Lyndon J Clarke” wrote in message
> > news:xxxxx@ntfsd…
> > > Rohit
> > >
> > > Oops should have said linkFileName.length instead of temp.Length :wink:
> > >
> > > Perhaps RtlAppendUnicodeString uses the Length field? Say you add the
> line
> > > linkFileName.Length = wcslen(temp.Buffer) * sizeof(WCHAR);
> > >
> > > right after the _itow call and see if the code works?
> > >
> > > You could look at the NtStrSafe calls also.
> > >
> > > Good luck
> > >
> > > Lyndon
> > >
> > >
> > >
> > > “Lyndon J Clarke” wrote in message
> > > news:xxxxx@ntfsd…
> > > > Rohit
> > > >
> > > > Far as I can see your code does not set temp.Length perhaps this is
> the
> > > > problem?
> > > >
> > > > Cheers
> > > > Lyndon
> > > >
> > > > “Rohit Dhamija” wrote in message
> > > > news:xxxxx@ntfsd…
> > > > > Dear All,
> > > > >
> > > > >
> > > > >
> > > > > I have two Unicode strings named linkFileName and
linkFullFileName.
> I
> > > have
> > > > > to convert an integer to Unicode string (linkFileName), and then
> > append
> > > > that
> > > > > Unicode string to the other Unicode String, linkFullFileName.
> > > > >
> > > > >
> > > > >
> > > > > I have been able to convert the integer to Unicode string but when
I
> > > > append
> > > > > this Unicode string to other Unicode string, it doesn’t works and
> the
> > > > system
> > > > > crashes with Stop Code:
> > > > >
> > > > > KMODE_EXCEPTION_NOT_HANDLED 0x1E having first parameter as
> 0xC0000005
> > > > >
> > > > >
> > > > >
> > > > > For that I have written following code:
> > > > >
> > > >
> > >
> >
>
////////////////////////////////////////////////////////////////////////////
> > > > > ////////////////
> > > > > int dummy;
> > > > > UNICODE_STRING temp;
> > > > > UNICODE_STRING linkFileName;
> > > > > UNICODE_STRING linkFullFileName;
> > > > >
> > > > >
> > > > >
> > > > > linkFileName.MaximumLength = 30;
> > > > > linkFileName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
> > > > > linkFileName.MaximumLength,‘2leM’);
> > > > >
> > > > >
> > > > >
> > > > > linkFullFileName.MaximumLength = 50 ;
> > > > > linkFullFileName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
> > > > > linkFullFileName.MaximumLength,‘2leM’);
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > LINE1) dummy = 7; // Initialize value of dummy of integer type
> > > > >
> > > > >
> > > > >
> > > > > LINE2) _itow(dummy,linkFileName.Buffer, 10); // placing it into
> > > > > linkFileName.Buffer
> > > > >
> > > > > LINE3) RtlInitUnicodeString(&temp,L"BOND00"); //temp is
initialized
> > to
> > > > BOND
> > > > >
> > > > >
> > > > >
> > > > > LINE4) RtlCopyUnicodeString(&linkFullFileName, &temp);
> > > > >
> > > > >
> > > > >
> > > > > LINE5) RtlAppendUnicodeStringToString(&linkFullFileName,
> > &linkFileName);
> > > > //
> > > > > NOT WORKING ,Why??
> > > > >
> > > > >
> > > > >
> > > > > LINE6) DbgPrint(“\n #NEW CODE linkFileName = %wZ”,&linkFileName);
> //
> > > > > Result > #NEW CODE linkFileName = 7
> > > > >
> > > > >
> > > > >
> > > > > LINE7) DbgPrint(“\n #NEW CODE linkFullFileName =
> > > %wZ”,&linkFullFileName);
> > > > > //NOT WORKING FINE
> > > > >
> > > > >
> > > > >
> > > > > // Result > #NEW CODE linkFullFileName = BOND00
> > > > >
> > > > >
> > > > >
> > > > > //Where as it should print “BOND007”
> > > > >
> > > > >
> > > > >
> > > > > ExFreePoolWithTag(linkFileName.Buffer,‘pmoC’);
> > > > >
> > > > > ExFreePoolWithTag(linkFullFileName.Buffer,‘pmoC’);
> > > > >
> > > > >
> > > >
> > >
> >
>
////////////////////////////////////////////////////////////////////////////
> > > > > ////////////////
> > > > >
> > > > >
> > > > >
> > > > > Please suggest a way out to solve this problem or any alternate
way
> to
> > > > > achieve the same.
> > > > >
> > > > >
> > > > >
> > > > > Regards,
> > > > > Rohit
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> >
> >
> >
>
>
>

Oops I still have this temp mixup thing … should be

linkFileName.Length = wcslen(linkFileName.Buffer) * sizeof(WCHAR);

I’ll get my coat.

“Lyndon J Clarke” wrote in message
news:xxxxx@ntfsd…
> Rohit
>
> Oops should have said linkFileName.length instead of temp.Length :wink:
>
> Perhaps RtlAppendUnicodeString uses the Length field? Say you add the line
> linkFileName.Length = wcslen(temp.Buffer) * sizeof(WCHAR);
>
> right after the _itow call and see if the code works?
>
> You could look at the NtStrSafe calls also.
>
> Good luck
>
> Lyndon
>
>
>
> “Lyndon J Clarke” wrote in message
> news:xxxxx@ntfsd…
> > Rohit
> >
> > Far as I can see your code does not set temp.Length perhaps this is the
> > problem?
> >
> > Cheers
> > Lyndon
> >
> > “Rohit Dhamija” wrote in message
> > news:xxxxx@ntfsd…
> > > Dear All,
> > >
> > >
> > >
> > > I have two Unicode strings named linkFileName and linkFullFileName. I
> have
> > > to convert an integer to Unicode string (linkFileName), and then
append
> > that
> > > Unicode string to the other Unicode String, linkFullFileName.
> > >
> > >
> > >
> > > I have been able to convert the integer to Unicode string but when I
> > append
> > > this Unicode string to other Unicode string, it doesn’t works and the
> > system
> > > crashes with Stop Code:
> > >
> > > KMODE_EXCEPTION_NOT_HANDLED 0x1E having first parameter as 0xC0000005
> > >
> > >
> > >
> > > For that I have written following code:
> > >
> >
>
////////////////////////////////////////////////////////////////////////////
> > > ////////////////
> > > int dummy;
> > > UNICODE_STRING temp;
> > > UNICODE_STRING linkFileName;
> > > UNICODE_STRING linkFullFileName;
> > >
> > >
> > >
> > > linkFileName.MaximumLength = 30;
> > > linkFileName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
> > > linkFileName.MaximumLength,‘2leM’);
> > >
> > >
> > >
> > > linkFullFileName.MaximumLength = 50 ;
> > > linkFullFileName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
> > > linkFullFileName.MaximumLength,‘2leM’);
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > LINE1) dummy = 7; // Initialize value of dummy of integer type
> > >
> > >
> > >
> > > LINE2) _itow(dummy,linkFileName.Buffer, 10); // placing it into
> > > linkFileName.Buffer
> > >
> > > LINE3) RtlInitUnicodeString(&temp,L"BOND00"); //temp is initialized
to
> > BOND
> > >
> > >
> > >
> > > LINE4) RtlCopyUnicodeString(&linkFullFileName, &temp);
> > >
> > >
> > >
> > > LINE5) RtlAppendUnicodeStringToString(&linkFullFileName,
&linkFileName);
> > //
> > > NOT WORKING ,Why??
> > >
> > >
> > >
> > > LINE6) DbgPrint(“\n #NEW CODE linkFileName = %wZ”,&linkFileName); //
> > > Result > #NEW CODE linkFileName = 7
> > >
> > >
> > >
> > > LINE7) DbgPrint(“\n #NEW CODE linkFullFileName =
> %wZ”,&linkFullFileName);
> > > //NOT WORKING FINE
> > >
> > >
> > >
> > > // Result > #NEW CODE linkFullFileName = BOND00
> > >
> > >
> > >
> > > //Where as it should print “BOND007”
> > >
> > >
> > >
> > > ExFreePoolWithTag(linkFileName.Buffer,‘pmoC’);
> > >
> > > ExFreePoolWithTag(linkFullFileName.Buffer,‘pmoC’);
> > >
> > >
> >
>
////////////////////////////////////////////////////////////////////////////
> > > ////////////////
> > >
> > >
> > >
> > > Please suggest a way out to solve this problem or any alternate way to
> > > achieve the same.
> > >
> > >
> > >
> > > Regards,
> > > Rohit
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
>
>
>

Thanks for the correction :slight_smile:
“Rohit Dhamija” wrote in message
news:xxxxx@ntfsd…
> Dear Mr Clarke,
>
> Thanks a lot! This actually worked.
>
> Regards,
> Rohit
> “Lyndon J Clarke” wrote in message
> news:xxxxx@ntfsd…
> > Rohit
> >
> > Oops should have said linkFileName.length instead of temp.Length :wink:
> >
> > Perhaps RtlAppendUnicodeString uses the Length field? Say you add the
line
> > linkFileName.Length = wcslen(temp.Buffer) * sizeof(WCHAR);
> >
> > right after the _itow call and see if the code works?
> >
> > You could look at the NtStrSafe calls also.
> >
> > Good luck
> >
> > Lyndon
> >
> >
> >
> > “Lyndon J Clarke” wrote in message
> > news:xxxxx@ntfsd…
> > > Rohit
> > >
> > > Far as I can see your code does not set temp.Length perhaps this is
the
> > > problem?
> > >
> > > Cheers
> > > Lyndon
> > >
> > > “Rohit Dhamija” wrote in message
> > > news:xxxxx@ntfsd…
> > > > Dear All,
> > > >
> > > >
> > > >
> > > > I have two Unicode strings named linkFileName and linkFullFileName.
I
> > have
> > > > to convert an integer to Unicode string (linkFileName), and then
> append
> > > that
> > > > Unicode string to the other Unicode String, linkFullFileName.
> > > >
> > > >
> > > >
> > > > I have been able to convert the integer to Unicode string but when I
> > > append
> > > > this Unicode string to other Unicode string, it doesn’t works and
the
> > > system
> > > > crashes with Stop Code:
> > > >
> > > > KMODE_EXCEPTION_NOT_HANDLED 0x1E having first parameter as
0xC0000005
> > > >
> > > >
> > > >
> > > > For that I have written following code:
> > > >
> > >
> >
>
////////////////////////////////////////////////////////////////////////////
> > > > ////////////////
> > > > int dummy;
> > > > UNICODE_STRING temp;
> > > > UNICODE_STRING linkFileName;
> > > > UNICODE_STRING linkFullFileName;
> > > >
> > > >
> > > >
> > > > linkFileName.MaximumLength = 30;
> > > > linkFileName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
> > > > linkFileName.MaximumLength,‘2leM’);
> > > >
> > > >
> > > >
> > > > linkFullFileName.MaximumLength = 50 ;
> > > > linkFullFileName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
> > > > linkFullFileName.MaximumLength,‘2leM’);
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > LINE1) dummy = 7; // Initialize value of dummy of integer type
> > > >
> > > >
> > > >
> > > > LINE2) _itow(dummy,linkFileName.Buffer, 10); // placing it into
> > > > linkFileName.Buffer
> > > >
> > > > LINE3) RtlInitUnicodeString(&temp,L"BOND00"); //temp is initialized
> to
> > > BOND
> > > >
> > > >
> > > >
> > > > LINE4) RtlCopyUnicodeString(&linkFullFileName, &temp);
> > > >
> > > >
> > > >
> > > > LINE5) RtlAppendUnicodeStringToString(&linkFullFileName,
> &linkFileName);
> > > //
> > > > NOT WORKING ,Why??
> > > >
> > > >
> > > >
> > > > LINE6) DbgPrint(“\n #NEW CODE linkFileName = %wZ”,&linkFileName);
//
> > > > Result > #NEW CODE linkFileName = 7
> > > >
> > > >
> > > >
> > > > LINE7) DbgPrint(“\n #NEW CODE linkFullFileName =
> > %wZ”,&linkFullFileName);
> > > > //NOT WORKING FINE
> > > >
> > > >
> > > >
> > > > // Result > #NEW CODE linkFullFileName = BOND00
> > > >
> > > >
> > > >
> > > > //Where as it should print “BOND007”
> > > >
> > > >
> > > >
> > > > ExFreePoolWithTag(linkFileName.Buffer,‘pmoC’);
> > > >
> > > > ExFreePoolWithTag(linkFullFileName.Buffer,‘pmoC’);
> > > >
> > > >
> > >
> >
>
////////////////////////////////////////////////////////////////////////////
> > > > ////////////////
> > > >
> > > >
> > > >
> > > > Please suggest a way out to solve this problem or any alternate way
to
> > > > achieve the same.
> > > >
> > > >
> > > >
> > > > Regards,
> > > > Rohit
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> >
> >
> >
>
>
>