Xxx
NTSTATUS Ntapi Rtlpwin32ntnametontpathname_u (in Punicode_string Dospath, Out Punicode_string Ntpath, out Pcwstr*PartName, out Prtl_relative_name_u relativename) {ULONG doslength; Pwstr Newbuffer, p; /*Validate the input*/ if(! Dospath)returnStatus_object_name_invalid; /*Validate the DOS length*/Doslength= dospath->Length; if(Doslength >= unicode_string_max_bytes)returnStatus_name_too_long; /*Make space for the new path*/Newbuffer=rtlallocateheap (Rtlgetprocessheap (),0, Doslength+sizeof(Unicode_null)); if(! Newbuffer)returnstatus_no_memory; /*Copy the prefix, and then the rest of the DOS path, and Null-terminate*/rtlcopymemory (Newbuffer, Rtlpdosdevicesprefix.buffer, rtlpdosdevicesprefix.length); Rtlcopymemory ((PCHAR) Newbuffer+Rtlpdosdevicesprefix.length, Dospath->buffer + rtlpdosdevicesprefix.length/sizeof(WCHAR), Dospath->length-rtlpdosdevicesprefix.length); Newbuffer[doslength/sizeof(WCHAR)] =Unicode_null; /*did the caller send a relative name?*/ if(relativename) {/*Zero Initialize it*/rtlinitemptyunicodestring (&relativename->relativename, NULL,0); Relativename->containingdirectory =NULL; Relativename->curdirref =0; } /*did the caller request a partial name?*/ if(partname) {/*Loop from the back until we find a path separator*/P= &newbuffer[(Doslength-1) /sizeof(WCHAR)]; while(P > Newbuffer)if(*p--= ='\\') Break; /*was one found?*/ if(P >Newbuffer) { /*Move past it--anything left?*/P++; if(!*p) {/*the path ends with a path separator, no part name*/*partname =NULL; } Else { /*What follows the path separator are the part name*/*partname =p; } } } /*Build The final NT path string*/Ntpath->length =(USHORT) doslength; Ntpath->buffer =Newbuffer; Ntpath->maximumlength = (USHORT) Doslength +sizeof(Unicode_null); returnstatus_success;}
RING0 dos path to NT path