RtlInitUnicodeString memory allocation

RtlInitUnicodeString function , will only initialize the members of structure.
For example;
RtlInitUnicodeString(&sysini, L"System.ini");

The above function will modify the Buffer member of sysini to point to the “System.ini” string. My doubt is, the source string, i.e. “System.ini” is stored in which memory segment ? Is it stored in stack, heap or data section ? Because if it is in stack then sysini.Buffer will be pointing to a location from stack , which will be invalid as soon as the function exits. Thus I cannot initialize a global UNICODE_STRING using this function. Whereas if the source string is stored in heap or data section then I can use the sysini ( the unicode_string ) in other functions as well.
Can anyone put light on location of data storage for the source string in RtlInitUnicodeString ? ( heap, stack or data section ? )

Thanks in advance.

It’s just set to point to whatever buffer you pass in. Here, it’d be pointing to a string literal which is in the constant data section that resides within your .sys.

  • S

-----Original Message-----
From: xxxxx@yahoo.com
Sent: Tuesday, June 16, 2009 00:26
To: Windows File Systems Devs Interest List
Subject: [ntfsd] RtlInitUnicodeString memory allocation

RtlInitUnicodeString function , will only initialize the members of structure.
For example;
RtlInitUnicodeString(&sysini, L"System.ini");

The above function will modify the Buffer member of sysini to point to the “System.ini” string. My doubt is, the source string, i.e. “System.ini” is stored in which memory segment ? Is it stored in stack, heap or data section ? Because if it is in stack then sysini.Buffer will be pointing to a location from stack , which will be invalid as soon as the function exits. Thus I cannot initialize a global UNICODE_STRING using this function. Whereas if the source string is stored in heap or data section then I can use the sysini ( the unicode_string ) in other functions as well.
Can anyone put light on location of data storage for the source string in RtlInitUnicodeString ? ( heap, stack or data section ? )

Thanks in advance.


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Thank you very much.