- Timestamp:
- Nov 14, 2017 3:27:52 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/nt/nt.h
r69688 r69691 264 264 RTDECL(int) RTNtPathOpenDir(const char *pszPath, ACCESS_MASK fDesiredAccess, ULONG fShareAccess, ULONG fCreateOptions, 265 265 ULONG fObjAttribs, PHANDLE phHandle, bool *pfObjDir); 266 RTDECL(int) RTNtPathOpenDirEx(HANDLE hRootDir, struct _UNICODE_STRING *pNtName, ACCESS_MASK fDesiredAccess, 267 ULONG fShareAccess, ULONG fCreateOptions, ULONG fObjAttribs, PHANDLE phHandle, bool *pfObjDir); 266 268 RTDECL(int) RTNtPathClose(HANDLE hHandle); 267 269 -
trunk/src/VBox/Runtime/Makefile.kmk
r69674 r69691 680 680 r3/tcp.cpp \ 681 681 r3/udp.cpp \ 682 r3/generic/dirrel-r3-generic.cpp \683 682 r3/generic/semspinmutex-r3-generic.cpp \ 684 683 r3/xml.cpp \ … … 818 817 nt/RTNtPathExpand8dot3Path.cpp \ 819 818 nt/RTNtPathFindPossible8dot3Name.cpp \ 819 nt/fileioutils-nt.cpp \ 820 820 r3/generic/RTLocaleQueryLocaleName-r3-generic.cpp \ 821 r3/nt/dirrel-r3-nt.cpp \ 821 822 r3/nt/fs-nt.cpp \ 822 823 r3/nt/pathint-nt.cpp \ … … 899 900 r3/generic/RTLocaleQueryUserCountryCode-r3-generic.cpp \ 900 901 r3/generic/RTTimeZoneGetCurrent-generic.cpp \ 902 r3/generic/dirrel-r3-generic.cpp \ 901 903 r3/posix/allocex-r3-posix.cpp \ 902 904 r3/linux/RTThreadGetNativeState-linux.cpp \ … … 1011 1013 r3/generic/RTLocaleQueryUserCountryCode-r3-generic.cpp \ 1012 1014 r3/generic/RTTimeZoneGetCurrent-generic.cpp \ 1015 r3/generic/dirrel-r3-generic.cpp \ 1013 1016 r3/os2/filelock-os2.cpp \ 1014 1017 r3/os2/mp-os2.cpp \ … … 1094 1097 r3/generic/RTLocaleQueryUserCountryCode-r3-generic.cpp \ 1095 1098 r3/generic/RTTimeZoneGetCurrent-generic.cpp \ 1099 r3/generic/dirrel-r3-generic.cpp \ 1096 1100 r3/posix/RTFileQueryFsSizes-posix.cpp \ 1097 1101 r3/posix/RTHandleGetStandard-posix.cpp \ … … 1168 1172 r3/generic/RTLocaleQueryUserCountryCode-r3-generic.cpp \ 1169 1173 r3/generic/RTTimeZoneGetCurrent-generic.cpp \ 1174 r3/generic/dirrel-r3-generic.cpp \ 1170 1175 r3/posix/RTFileQueryFsSizes-posix.cpp \ 1171 1176 r3/posix/RTHandleGetStandard-posix.cpp \ … … 1241 1246 r3/generic/RTLocaleQueryUserCountryCode-r3-generic.cpp \ 1242 1247 r3/generic/RTTimeZoneGetCurrent-generic.cpp \ 1248 r3/generic/dirrel-r3-generic.cpp \ 1243 1249 r3/posix/RTFileQueryFsSizes-posix.cpp \ 1244 1250 r3/posix/RTHandleGetStandard-posix.cpp \ … … 1307 1313 r3/generic/RTLocaleQueryUserCountryCode-r3-generic.cpp \ 1308 1314 r3/generic/RTTimeZoneGetCurrent-generic.cpp \ 1315 r3/generic/dirrel-r3-generic.cpp \ 1309 1316 r3/posix/RTFileQueryFsSizes-posix.cpp \ 1310 1317 r3/posix/RTFileSetAllocationSize-posix.cpp \ … … 1398 1405 r3/generic/RTLocaleQueryUserCountryCode-r3-generic.cpp \ 1399 1406 r3/generic/RTTimeZoneGetCurrent-generic.cpp \ 1407 r3/generic/dirrel-r3-generic.cpp \ 1400 1408 r3/posix/RTFileQueryFsSizes-posix.cpp \ 1401 1409 r3/posix/RTHandleGetStandard-posix.cpp \ -
trunk/src/VBox/Runtime/include/internal/dir.h
r69674 r69691 159 159 * 160 160 * @returns IPRT status code. 161 * @param pDir The directory to open. The pszPath member contains the 162 * path to the directory. 163 * @param pszPathBuf Pointer to a RTPATH_MAX sized buffer containing pszPath. 164 * Find-first style systems can use this to setup the 165 * wildcard expression. 161 * @param pDir The directory to open. The pszPath member contains the 162 * path to the directory. 163 * @param pszPathBuf Pointer to a RTPATH_MAX sized buffer containing 164 * pszPath. Find-first style systems can use this 165 * to setup the wildcard expression. 166 * @param hRelativeDir The directory @a pvNativeRelative is relative, 167 * ~(uintptr_t)0 if absolute. 168 * @param pvNativeRelative The native relative path. NULL if absolute. 166 169 */ 167 int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf );170 int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf, uintptr_t hRelativeDir, void *pvNativeRelative); 168 171 169 172 /** … … 175 178 size_t rtDirNativeGetStructSize(const char *pszPath); 176 179 180 181 DECLHIDDEN(int) rtDirOpenRelative(PRTDIR *ppDir, const char *pszRelativeAndFilter, RTDIRFILTER enmFilter, uint32_t fFlags, 182 uintptr_t hRelativeDir, void *pvNativeRelative); 183 177 184 #endif -
trunk/src/VBox/Runtime/include/internal/file.h
r69474 r69691 56 56 RTFILE rtFileGetStandard(RTHANDLESTD enmStdHandle); 57 57 58 #ifdef RT_OS_WINDOWS 59 /** 60 * Helper for converting RTFILE_O_XXX to the various NtCreateFile flags. 61 * 62 * @returns IPRT status code 63 * @param fOpen The RTFILE_O_XXX flags to convert. 64 * @param pfDesiredAccess Where to return the desired access mask. 65 * @param pfObjAttribs Where to return the NT object attributes. 66 * @param pfFileAttribs Where to return the file attributes (create). 67 * @param pfShareAccess Where to return the file sharing access mask. 68 * @param pfCreateDisposition Where to return the file create disposition. 69 * @param pfCreateOptions Where to return the file open/create options. 70 */ 71 DECLHIDDEN(int) rtFileNtValidateAndConvertFlags(uint64_t fOpen, uint32_t *pfDesiredAccess, uint32_t *pfObjAttribs, 72 uint32_t *pfFileAttribs, uint32_t *pfShareAccess, uint32_t *pfCreateDisposition, 73 uint32_t *pfCreateOptions); 74 #endif 75 58 76 RT_C_DECLS_END 59 77 -
trunk/src/VBox/Runtime/r3/dir.cpp
r69674 r69691 506 506 * 507 507 * @returns IPRT status code. 508 * @param ppDir Where to store the directory handle. 509 * @param pszPath The specified path. 510 * @param pszFilter Pointer to where the filter start in the path. NULL if no filter. 511 * @param enmFilter The type of filter to apply. 512 * @param fFlags RTDIR_F_XXX. 513 */ 514 static int rtDirOpenCommon(PRTDIR *ppDir, const char *pszPath, const char *pszFilter, RTDIRFILTER enmFilter, uint32_t fFlags) 508 * @param ppDir Where to store the directory handle. 509 * @param pszPath The specified path. 510 * @param pszFilter Pointer to where the filter start in the path. 511 * NULL if no filter. 512 * @param enmFilter The type of filter to apply. 513 * @param fFlags RTDIR_F_XXX. 514 * @param hRelativeDir The directory @a pvNativeRelative is relative, 515 * ~(uintptr_t)0 if absolute. 516 * @param pvNativeRelative The native relative path. NULL if absolute. 517 */ 518 static int rtDirOpenCommon(PRTDIR *ppDir, const char *pszPath, const char *pszFilter, RTDIRFILTER enmFilter, uint32_t fFlags, 519 uintptr_t hRelativeDir, void *pvNativeRelative) 515 520 { 516 521 /* … … 623 628 * Hand it over to the native part. 624 629 */ 625 rc = rtDirNativeOpen(pDir, szRealPath );630 rc = rtDirNativeOpen(pDir, szRealPath, hRelativeDir, pvNativeRelative); 626 631 if (RT_SUCCESS(rc)) 627 632 *ppDir = pDir; … … 633 638 634 639 635 636 640 RTDECL(int) RTDirOpen(PRTDIR *ppDir, const char *pszPath) 637 641 { … … 645 649 * Take common cause with RTDirOpenFiltered(). 646 650 */ 647 int rc = rtDirOpenCommon(ppDir, pszPath, NULL, RTDIRFILTER_NONE, 0 /*fFlags*/ );651 int rc = rtDirOpenCommon(ppDir, pszPath, NULL, RTDIRFILTER_NONE, 0 /*fFlags*/, ~(uintptr_t)0, NULL); 648 652 LogFlow(("RTDirOpen(%p:{%p}, %p:{%s}): return %Rrc\n", ppDir, *ppDir, pszPath, pszPath, rc)); 649 653 return rc; … … 651 655 652 656 653 RTDECL(int) RTDirOpenFiltered(PRTDIR *ppDir, const char *pszPath, RTDIRFILTER enmFilter, uint32_t fFlags) 657 DECLHIDDEN(int) rtDirOpenRelative(PRTDIR *ppDir, const char *pszPath, RTDIRFILTER enmFilter, uint32_t fFlags, 658 uintptr_t hRelativeDir, void *pvNativeRelative) 654 659 { 655 660 /* … … 689 694 * and initialize the handle, and finally call the backend. 690 695 */ 691 int rc = rtDirOpenCommon(ppDir, pszPath, pszFilter, enmFilter, fFlags );692 693 LogFlow(("RTDirOpenFiltered(%p:{%p}, %p:{%s}, %d, %#x ): return %Rrc\n",694 ppDir, *ppDir, pszPath, pszPath, enmFilter, fFlags, rc));696 int rc = rtDirOpenCommon(ppDir, pszPath, pszFilter, enmFilter, fFlags, hRelativeDir, pvNativeRelative); 697 698 LogFlow(("RTDirOpenFiltered(%p:{%p}, %p:{%s}, %d, %#x, %p, %p): return %Rrc\n", 699 ppDir,*ppDir, pszPath, pszPath, enmFilter, fFlags, hRelativeDir, pvNativeRelative, rc)); 695 700 return rc; 701 } 702 703 704 RTDECL(int) RTDirOpenFiltered(PRTDIR *ppDir, const char *pszPath, RTDIRFILTER enmFilter, uint32_t fFlags) 705 { 706 return rtDirOpenRelative(ppDir, pszPath, enmFilter, fFlags, ~(uintptr_t)0, NULL); 696 707 } 697 708 -
trunk/src/VBox/Runtime/r3/nt/direnum-r3-nt.cpp
r69111 r69691 80 80 81 81 82 int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf )82 int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf, uintptr_t hRelativeDir, void *pvNativeRelative) 83 83 { 84 84 /* … … 103 103 */ 104 104 #ifdef IPRT_WITH_NT_PATH_PASSTHRU 105 bool fObjDir; 106 #endif 107 rc = RTNtPathOpenDir(pszPathBuf, 108 FILE_LIST_DIRECTORY | FILE_TRAVERSE | SYNCHRONIZE, 109 FILE_SHARE_READ | FILE_SHARE_WRITE, 110 FILE_DIRECTORY_FILE | FILE_OPEN_FOR_BACKUP_INTENT | FILE_SYNCHRONOUS_IO_NONALERT, 111 OBJ_CASE_INSENSITIVE, 112 &pDir->hDir, 113 #ifdef IPRT_WITH_NT_PATH_PASSTHRU 114 &fObjDir 105 bool fObjDir = false; 106 #endif 107 if (pvNativeRelative == NULL) 108 rc = RTNtPathOpenDir(pszPathBuf, 109 FILE_LIST_DIRECTORY | FILE_TRAVERSE | SYNCHRONIZE, 110 FILE_SHARE_READ | FILE_SHARE_WRITE, 111 FILE_DIRECTORY_FILE | FILE_OPEN_FOR_BACKUP_INTENT | FILE_SYNCHRONOUS_IO_NONALERT, 112 OBJ_CASE_INSENSITIVE, 113 &pDir->hDir, 114 #ifdef IPRT_WITH_NT_PATH_PASSTHRU 115 &fObjDir 115 116 #else 116 NULL 117 #endif 118 ); 117 NULL 118 #endif 119 ); 120 else 121 rc = RTNtPathOpenDirEx((HANDLE)hRelativeDir, 122 (struct _UNICODE_STRING *)pvNativeRelative, 123 FILE_LIST_DIRECTORY | FILE_TRAVERSE | SYNCHRONIZE, 124 FILE_SHARE_READ | FILE_SHARE_WRITE, 125 FILE_DIRECTORY_FILE | FILE_OPEN_FOR_BACKUP_INTENT | FILE_SYNCHRONOUS_IO_NONALERT, 126 OBJ_CASE_INSENSITIVE, 127 &pDir->hDir, 128 NULL); 119 129 if (RT_SUCCESS(rc)) 120 130 { -
trunk/src/VBox/Runtime/r3/nt/pathint-nt.cpp
r69688 r69691 763 763 if (RT_SUCCESS(rc)) 764 764 { 765 HANDLE hFile = RTNT_INVALID_HANDLE_VALUE; 766 IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER; 767 OBJECT_ATTRIBUTES ObjAttr; 768 InitializeObjectAttributes(&ObjAttr, &NtName, fObjAttribs, hRootDir, NULL); 769 770 NTSTATUS rcNt = NtCreateFile(&hFile, 771 fDesiredAccess, 772 &ObjAttr, 773 &Ios, 774 NULL /* AllocationSize*/, 775 FILE_ATTRIBUTE_NORMAL, 776 fShareAccess, 777 FILE_OPEN, 778 fCreateOptions, 779 NULL /*EaBuffer*/, 780 0 /*EaLength*/); 765 if (pfObjDir) 766 { 767 *pfObjDir = false; 768 #ifdef IPRT_WITH_NT_PATH_PASSTHRU 769 if ( !RTPATH_IS_SLASH(pszPath[0]) 770 || !RTPATH_IS_SLASH(pszPath[1]) 771 || pszPath[2] != '!' 772 || RTPATH_IS_SLASH(pszPath[3])) 773 #endif 774 pfObjDir = NULL; 775 } 776 rc = RTNtPathOpenDirEx(hRootDir, &NtName, fDesiredAccess, fShareAccess, fCreateOptions, fObjAttribs, phHandle, pfObjDir); 777 rtNtPathFreeNative(&NtName, &hRootDir); 778 } 779 return rc; 780 } 781 782 783 784 /** 785 * Wrapper around NtCreateFile, extended version. 786 * 787 * @returns IPRT status code. 788 * @param hRootDir The root director the path is relative to. NULL 789 * if none. 790 * @param pNtName The NT path. 791 * @param fDesiredAccess See NtCreateFile. 792 * @param fShareAccess See NtCreateFile. 793 * @param fCreateOptions See NtCreateFile. 794 * @param fObjAttribs The OBJECT_ATTRIBUTES::Attributes value, see 795 * NtCreateFile and InitializeObjectAttributes. 796 * @param phHandle Where to return the handle. 797 * @param pfObjDir If not NULL, the variable pointed to will be set 798 * to @c true if we opened an object directory and 799 * @c false if we opened an directory file (normal 800 * directory). 801 */ 802 RTDECL(int) RTNtPathOpenDirEx(HANDLE hRootDir, struct _UNICODE_STRING *pNtName, ACCESS_MASK fDesiredAccess, ULONG fShareAccess, 803 ULONG fCreateOptions, ULONG fObjAttribs, PHANDLE phHandle, bool *pfObjDir) 804 { 805 *phHandle = RTNT_INVALID_HANDLE_VALUE; 806 807 HANDLE hFile = RTNT_INVALID_HANDLE_VALUE; 808 IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER; 809 OBJECT_ATTRIBUTES ObjAttr; 810 InitializeObjectAttributes(&ObjAttr, pNtName, fObjAttribs, hRootDir, NULL); 811 812 NTSTATUS rcNt = NtCreateFile(&hFile, 813 fDesiredAccess, 814 &ObjAttr, 815 &Ios, 816 NULL /* AllocationSize*/, 817 FILE_ATTRIBUTE_NORMAL, 818 fShareAccess, 819 FILE_OPEN, 820 fCreateOptions, 821 NULL /*EaBuffer*/, 822 0 /*EaLength*/); 823 if (NT_SUCCESS(rcNt)) 824 { 825 if (pfObjDir) 826 *pfObjDir = false; 827 *phHandle = hFile; 828 return VINF_SUCCESS; 829 } 830 831 if ( pfObjDir 832 && (rcNt == STATUS_OBJECT_NAME_INVALID || rcNt == STATUS_OBJECT_TYPE_MISMATCH)) 833 { 834 /* Strip trailing slash. */ 835 struct _UNICODE_STRING NtName2 = *pNtName; 836 if ( NtName2.Length > 2 837 && RTPATH_IS_SLASH(NtName2.Buffer[(NtName2.Length / 2) - 1])) 838 NtName2.Length -= 2; 839 ObjAttr.ObjectName = &NtName2; 840 841 /* Rought conversion of the access flags. */ 842 ULONG fObjDesiredAccess = 0; 843 if (fDesiredAccess & (GENERIC_ALL | STANDARD_RIGHTS_ALL)) 844 fObjDesiredAccess = DIRECTORY_ALL_ACCESS; 845 else 846 { 847 if (fDesiredAccess & (FILE_GENERIC_WRITE | GENERIC_WRITE | STANDARD_RIGHTS_WRITE)) 848 fObjDesiredAccess |= DIRECTORY_CREATE_OBJECT | DIRECTORY_CREATE_OBJECT; 849 if ( (fDesiredAccess & (FILE_LIST_DIRECTORY | FILE_GENERIC_READ | GENERIC_READ | STANDARD_RIGHTS_READ)) 850 || !fObjDesiredAccess) 851 fObjDesiredAccess |= DIRECTORY_QUERY | FILE_LIST_DIRECTORY; 852 } 853 854 rcNt = NtOpenDirectoryObject(&hFile, fObjDesiredAccess, &ObjAttr); 781 855 if (NT_SUCCESS(rcNt)) 782 856 { 783 if (pfObjDir) 784 *pfObjDir = false; 857 *pfObjDir = true; 785 858 *phHandle = hFile; 786 rc = VINF_SUCCESS; 787 } 788 #ifdef IPRT_WITH_NT_PATH_PASSTHRU 789 else if ( pfObjDir 790 && (rcNt == STATUS_OBJECT_NAME_INVALID || rcNt == STATUS_OBJECT_TYPE_MISMATCH) 791 && RTPATH_IS_SLASH(pszPath[0]) 792 && RTPATH_IS_SLASH(pszPath[1]) 793 && pszPath[2] == '!' 794 && RTPATH_IS_SLASH(pszPath[3])) 795 { 796 /* Strip trailing slash. */ 797 if ( NtName.Length > 2 798 && RTPATH_IS_SLASH(NtName.Buffer[(NtName.Length / 2) - 1])) 799 NtName.Length -= 2; 800 801 /* Rought conversion of the access flags. */ 802 ULONG fObjDesiredAccess = 0; 803 if (fDesiredAccess & (GENERIC_ALL | STANDARD_RIGHTS_ALL)) 804 fObjDesiredAccess = DIRECTORY_ALL_ACCESS; 805 else 806 { 807 if (fDesiredAccess & (FILE_GENERIC_WRITE | GENERIC_WRITE | STANDARD_RIGHTS_WRITE)) 808 fObjDesiredAccess |= DIRECTORY_CREATE_OBJECT | DIRECTORY_CREATE_OBJECT; 809 if ( (fDesiredAccess & (FILE_LIST_DIRECTORY | FILE_GENERIC_READ | GENERIC_READ | STANDARD_RIGHTS_READ)) 810 || !fObjDesiredAccess) 811 fObjDesiredAccess |= DIRECTORY_QUERY | FILE_LIST_DIRECTORY; 812 } 813 814 rcNt = NtOpenDirectoryObject(&hFile, fObjDesiredAccess, &ObjAttr); 815 if (NT_SUCCESS(rcNt)) 816 { 817 *pfObjDir = true; 818 *phHandle = hFile; 819 rc = VINF_SUCCESS; 820 } 821 else 822 rc = RTErrConvertFromNtStatus(rcNt); 823 } 824 #endif 825 else 826 rc = RTErrConvertFromNtStatus(rcNt); 827 rtNtPathFreeNative(&NtName, &hRootDir); 828 } 829 return rc; 830 } 859 return VINF_SUCCESS; 860 } 861 } 862 863 return RTErrConvertFromNtStatus(rcNt); 864 } 865 831 866 832 867 -
trunk/src/VBox/Runtime/r3/posix/dir-posix.cpp
r69111 r69691 224 224 225 225 226 int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf )226 int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf, uintptr_t hRelativeDir, void *pvNativeRelative) 227 227 { 228 228 NOREF(pszPathBuf); /* only used on windows */ 229 NOREF(hRelativeDir); 230 NOREF(pvNativeRelative); 229 231 230 232 /* -
trunk/src/VBox/Runtime/r3/win/direnum-win.cpp
r69111 r69691 51 51 52 52 53 int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf) 54 { 53 int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf, uintptr_t hRelativeDir, void *pvNativeRelative)) 54 { 55 RT_NOREF(hRelativeDir, pvNativeRelative); 56 55 57 /* 56 58 * Setup the search expression.
Note:
See TracChangeset
for help on using the changeset viewer.