From 8076b5e6f85667916a4ed50a191c4caef8da25b6 Mon Sep 17 00:00:00 2001 From: midipix Date: Dec 08 2016 21:32:31 +0000 Subject: __ntapi_tt_open_physical_parent_directory(): fix device root dir detection. --- diff --git a/src/fs/ntapi_tt_open_physical_parent_directory.c b/src/fs/ntapi_tt_open_physical_parent_directory.c index e80a21a..d28eb1b 100644 --- a/src/fs/ntapi_tt_open_physical_parent_directory.c +++ b/src/fs/ntapi_tt_open_physical_parent_directory.c @@ -21,6 +21,7 @@ int32_t __stdcall __ntapi_tt_open_physical_parent_directory( nt_oa oa; nt_iosb iosb; wchar16_t * wch; + wchar16_t * root; nt_unicode_string * path; uint32_t len; @@ -35,17 +36,33 @@ int32_t __stdcall __ntapi_tt_open_physical_parent_directory( buffer_size, &len))) return status; - else if (len == sizeof(nt_unicode_string)) + + /* integrity */ + if (len == sizeof(nt_unicode_string)) return NT_STATUS_BAD_FILE_TYPE; - wch = path->buffer + (path->strlen / sizeof(uint16_t)); + /* device root directory */ + root = path->buffer; + wch = path->buffer + (path->strlen / sizeof(uint16_t)); + - for (; (wch > path->buffer) && (wch[-1] != '\\'); wch--) - (void)0; + if ((root[0] != '\\') + || (root[1] != 'D') || (root[2] != 'e') + || (root[3] != 'v') || (root[4] != 'i') + || (root[5] != 'c') || (root[6] != 'e') + || (root[7] != '\\')) + return NT_STATUS_INTERNAL_ERROR; - if (wch == path->buffer) + for (root=&root[8]; (rootbuffer) * sizeof(uint16_t)) == path->strlen) return NT_STATUS_MORE_PROCESSING_REQUIRED; + /* physical parent directory path */ + for (; (wch>root) && (wch[-1]!='\\'); ) + wch--; + path->strlen = sizeof(uint16_t) * (uint16_t)(wch-path->buffer); path->maxlen = 0;