VirtualBox

Changeset 49150 in vbox for trunk/src/VBox/Runtime/r3/nt


Ignore:
Timestamp:
Oct 17, 2013 7:22:02 AM (11 years ago)
Author:
vboxsync
Message:

SUPR3: Use NtDeviceIoControlFile instead of DeviceIoControl to avoid wasting precious ticks on silly API conversions.

Location:
trunk/src/VBox/Runtime/r3/nt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/nt/direnum-r3-nt.cpp

    r48935 r49150  
    105105    bool fObjDir;
    106106#endif
    107     rc = rtNtPathOpenDir(pszPathBuf,
     107    rc = RTNtPathOpenDir(pszPathBuf,
    108108                         FILE_READ_DATA | SYNCHRONIZE,
    109109                         FILE_SHARE_READ | FILE_SHARE_WRITE,
     
    149149     */
    150150    pDir->u32Magic = ~RTDIR_MAGIC;
    151     if (pDir->hDir != MY_INVALID_HANDLE_VALUE)
    152     {
    153         int rc = rtNtPathClose(pDir->hDir);
     151    if (pDir->hDir != RTNT_INVALID_HANDLE_VALUE)
     152    {
     153        int rc = RTNtPathClose(pDir->hDir);
    154154        AssertRC(rc);
    155         pDir->hDir = MY_INVALID_HANDLE_VALUE;
     155        pDir->hDir = RTNT_INVALID_HANDLE_VALUE;
    156156    }
    157157    RTStrFree(pDir->pszName);
     
    281281     */
    282282    NTSTATUS rcNt;
    283     IO_STATUS_BLOCK Ios = MY_IO_STATUS_BLOCK_INITIALIZER;
     283    IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER;
    284284    if (pThis->enmInfoClass != (FILE_INFORMATION_CLASS)0)
    285285    {
  • trunk/src/VBox/Runtime/r3/nt/fs-nt.cpp

    r48935 r49150  
    5353     */
    5454    HANDLE hFile;
    55     int rc = rtNtPathOpen(pszFsPath,
     55    int rc = RTNtPathOpen(pszFsPath,
    5656                          GENERIC_READ,
    5757                          FILE_ATTRIBUTE_NORMAL,
     
    6868         */
    6969        FILE_FS_SIZE_INFORMATION FsSizeInfo;
    70         IO_STATUS_BLOCK Ios = MY_IO_STATUS_BLOCK_INITIALIZER;
     70        IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER;
    7171        NTSTATUS rcNt = NtQueryVolumeInformationFile(hFile, &Ios, &FsSizeInfo, sizeof(FsSizeInfo), FileFsSizeInformation);
    7272        if (NT_SUCCESS(rcNt))
     
    108108            rc = RTErrConvertFromNtStatus(rcNt);
    109109
    110         rtNtPathClose(hFile);
     110        RTNtPathClose(hFile);
    111111    }
    112112    return rc;
     
    126126     */
    127127    HANDLE hFile;
    128     int rc = rtNtPathOpen(pszFsPath,
     128    int rc = RTNtPathOpen(pszFsPath,
    129129                          GENERIC_READ,
    130130                          FILE_ATTRIBUTE_NORMAL,
     
    145145             uint8_t abBuf[sizeof(FILE_FS_VOLUME_INFORMATION) + 4096];
    146146        } u;
    147         IO_STATUS_BLOCK Ios = MY_IO_STATUS_BLOCK_INITIALIZER;
     147        IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER;
    148148        NTSTATUS rcNt = NtQueryVolumeInformationFile(hFile, &Ios, &u, sizeof(u), FileFsVolumeInformation);
    149149        if (NT_SUCCESS(rcNt))
     
    152152            rc = RTErrConvertFromNtStatus(rcNt);
    153153
    154         rtNtPathClose(hFile);
     154        RTNtPathClose(hFile);
    155155    }
    156156    return rc;
     
    170170     */
    171171    HANDLE hFile;
    172     int rc = rtNtPathOpen(pszFsPath,
     172    int rc = RTNtPathOpen(pszFsPath,
    173173                          GENERIC_READ,
    174174                          FILE_ATTRIBUTE_NORMAL,
     
    189189            uint8_t abBuf[sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 4096];
    190190        } u;
    191         IO_STATUS_BLOCK Ios = MY_IO_STATUS_BLOCK_INITIALIZER;
     191        IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER;
    192192        NTSTATUS rcNt = NtQueryVolumeInformationFile(hFile, &Ios, &u, sizeof(u), FileFsAttributeInformation);
    193193        if (NT_SUCCESS(rcNt))
     
    220220            rc = RTErrConvertFromNtStatus(rcNt);
    221221
    222         rtNtPathClose(hFile);
     222        RTNtPathClose(hFile);
    223223    }
    224224    return rc;
     
    240240     */
    241241    HANDLE hFile;
    242     int rc = rtNtPathOpen(pszFsPath,
     242    int rc = RTNtPathOpen(pszFsPath,
    243243                          GENERIC_READ,
    244244                          FILE_ATTRIBUTE_NORMAL,
     
    259259            uint8_t abBuf[sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 4096];
    260260        } u;
    261         IO_STATUS_BLOCK Ios = MY_IO_STATUS_BLOCK_INITIALIZER;
     261        IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER;
    262262        NTSTATUS rcNt = NtQueryVolumeInformationFile(hFile, &Ios, &u, sizeof(u), FileFsAttributeInformation);
    263263        if (NT_SUCCESS(rcNt))
     
    278278            rc = RTErrConvertFromNtStatus(rcNt);
    279279
    280         rtNtPathClose(hFile);
    281     }
    282     return rc;
    283 }
    284 
     280        RTNtPathClose(hFile);
     281    }
     282    return rc;
     283}
     284
  • trunk/src/VBox/Runtime/r3/nt/internal-r3-nt.h

    r47535 r49150  
    55
    66/*
    7  * Copyright (C) 2010-2012 Oracle Corporation
     7 * Copyright (C) 2010-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3030
    3131
    32 /*******************************************************************************
    33 *   Header Files                                                               *
    34 *******************************************************************************/
    35 #include <ntstatus.h>
    36 #ifdef IPRT_NT_USE_WINTERNL
    37 # define WIN32_NO_STATUS
    38 # include <windef.h>
    39 # include <winnt.h>
    40 # include <winternl.h>
    41 # define IPRT_NT_NEED_API_GROUP_1
    42 
    43 #elif defined(IPRT_NT_USE_WDM)
    44 # include <wdm.h>
    45 # define IPRT_NT_NEED_API_GROUP_1
    46 
    47 #else
    48 # include <ntifs.h>
    49 #endif
     32#include <iprt/nt/nt.h>
    5033#include "internal/iprt.h"
    5134
    52 
    53 /*******************************************************************************
    54 *   Defined Constants And Macros                                               *
    55 *******************************************************************************/
    56 /** Indicates that we're targetting native NT in the current source. */
    57 #define RT_USE_NATIVE_NT                1
    58 /** Initializes a IO_STATUS_BLOCK. */
    59 #define MY_IO_STATUS_BLOCK_INITIALIZER  { STATUS_FAILED_DRIVER_ENTRY, ~(uintptr_t)42 }
    60 /** Similar to INVALID_HANDLE_VALUE in the Windows environment. */
    61 #define MY_INVALID_HANDLE_VALUE         ( (HANDLE)~(uintptr_t)0 )
    6235
    6336#ifdef DEBUG_bird
     
    6639# define IPRT_WITH_NT_PATH_PASSTHRU 1
    6740#endif
    68 
    69 
    70 /*******************************************************************************
    71 *   Internal Functions                                                         *
    72 *******************************************************************************/
    73 int  rtNtPathOpen(const char *pszPath, ACCESS_MASK fDesiredAccess, ULONG fFileAttribs, ULONG fShareAccess,
    74                   ULONG fCreateDisposition, ULONG fCreateOptions, ULONG fObjAttribs,
    75                   PHANDLE phHandle, PULONG_PTR puDisposition);
    76 int  rtNtPathOpenDir(const char *pszPath, ACCESS_MASK fDesiredAccess, ULONG fShareAccess, ULONG fCreateOptions,
    77                      ULONG fObjAttribs, PHANDLE phHandle, bool *pfObjDir);
    78 int  rtNtPathClose(HANDLE hHandle);
    7941
    8042
     
    10264}
    10365
    104 
    105 /*******************************************************************************
    106 *   NT APIs                                                                    *
    107 *******************************************************************************/
    108 
    109 RT_C_DECLS_BEGIN
    110 
    111 #ifdef IPRT_NT_NEED_API_GROUP_1
    112 
    113 typedef struct _FILE_FS_ATTRIBUTE_INFORMATION
    114 {
    115     ULONG   FileSystemAttributes;
    116     LONG    MaximumComponentNameLength;
    117     ULONG   FileSystemNameLength;
    118     WCHAR   FileSystemName[1];
    119 } FILE_FS_ATTRIBUTE_INFORMATION;
    120 typedef FILE_FS_ATTRIBUTE_INFORMATION *PFILE_FS_ATTRIBUTE_INFORMATION;
    121 extern "C" NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG, FS_INFORMATION_CLASS);
    122 
    12366#endif
    12467
    125 NTSTATUS NTAPI NtOpenDirectoryObject(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES);
    126 
    127 typedef struct _OBJECT_DIRECTORY_INFORMATION
    128 {
    129     UNICODE_STRING Name;
    130     UNICODE_STRING TypeName;
    131 } OBJECT_DIRECTORY_INFORMATION;
    132 typedef OBJECT_DIRECTORY_INFORMATION *POBJECT_DIRECTORY_INFORMATION;
    133 
    134 NTSTATUS NTAPI NtQueryDirectoryObject(HANDLE, PVOID, ULONG, BOOLEAN, BOOLEAN, PULONG, PULONG);
    135 
    136 
    137 RT_C_DECLS_END
    138 
    139 #endif
    140 
  • trunk/src/VBox/Runtime/r3/nt/pathint-nt.cpp

    r47535 r49150  
    203203 * @param   puAction            Where to return the action taken. Optional.
    204204 */
    205 int  rtNtPathOpen(const char *pszPath, ACCESS_MASK fDesiredAccess, ULONG fFileAttribs, ULONG fShareAccess,
    206                   ULONG fCreateDisposition, ULONG fCreateOptions, ULONG fObjAttribs,
    207                   PHANDLE phHandle, PULONG_PTR puAction)
    208 {
    209     *phHandle = MY_INVALID_HANDLE_VALUE;
     205RTDECL(int) RTNtPathOpen(const char *pszPath, ACCESS_MASK fDesiredAccess, ULONG fFileAttribs, ULONG fShareAccess,
     206                         ULONG fCreateDisposition, ULONG fCreateOptions, ULONG fObjAttribs,
     207                         PHANDLE phHandle, PULONG_PTR puAction)
     208{
     209    *phHandle = RTNT_INVALID_HANDLE_VALUE;
    210210
    211211    HANDLE         hRootDir;
     
    214214    if (RT_SUCCESS(rc))
    215215    {
    216         HANDLE              hFile = MY_INVALID_HANDLE_VALUE;
    217         IO_STATUS_BLOCK     Ios   = MY_IO_STATUS_BLOCK_INITIALIZER;
     216        HANDLE              hFile = RTNT_INVALID_HANDLE_VALUE;
     217        IO_STATUS_BLOCK     Ios   = RTNT_IO_STATUS_BLOCK_INITIALIZER;
    218218        OBJECT_ATTRIBUTES   ObjAttr;
    219219        InitializeObjectAttributes(&ObjAttr, &NtName, fObjAttribs, hRootDir, NULL);
     
    263263 *                              directory).
    264264 */
    265 int  rtNtPathOpenDir(const char *pszPath, ACCESS_MASK fDesiredAccess, ULONG fShareAccess, ULONG fCreateOptions,
    266                      ULONG fObjAttribs, PHANDLE phHandle, bool *pfObjDir)
    267 {
    268     *phHandle = MY_INVALID_HANDLE_VALUE;
     265RTDECL(int) RTNtPathOpenDir(const char *pszPath, ACCESS_MASK fDesiredAccess, ULONG fShareAccess, ULONG fCreateOptions,
     266                            ULONG fObjAttribs, PHANDLE phHandle, bool *pfObjDir)
     267{
     268    *phHandle = RTNT_INVALID_HANDLE_VALUE;
    269269
    270270    HANDLE         hRootDir;
     
    273273    if (RT_SUCCESS(rc))
    274274    {
    275         HANDLE              hFile = MY_INVALID_HANDLE_VALUE;
    276         IO_STATUS_BLOCK     Ios   = MY_IO_STATUS_BLOCK_INITIALIZER;
     275        HANDLE              hFile = RTNT_INVALID_HANDLE_VALUE;
     276        IO_STATUS_BLOCK     Ios   = RTNT_IO_STATUS_BLOCK_INITIALIZER;
    277277        OBJECT_ATTRIBUTES   ObjAttr;
    278278        InitializeObjectAttributes(&ObjAttr, &NtName, fObjAttribs, hRootDir, NULL);
     
    347347 * @param   hHandle             The handle value.
    348348 */
    349 int rtNtPathClose(HANDLE hHandle)
     349RTDECL(int) RTNtPathClose(HANDLE hHandle)
    350350{
    351351    NTSTATUS rcNt = NtClose(hHandle);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette