RING0 dos path to NT path

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.