VirtualBox

Changeset 78326 in vbox for trunk


Ignore:
Timestamp:
Apr 26, 2019 2:45:38 PM (6 years ago)
Author:
vboxsync
Message:

winnt/vboxsf: Cleaned up the vbsfhlp.cpp code, removing a few unused functions and such. bugref:9172

Location:
trunk/src/VBox/Additions/WINNT/SharedFolders/driver
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/file.cpp

    r78321 r78326  
    302302    ByteCount = ctx.cbData;
    303303
    304     Status = VBoxErrorToNTStatus(vrc);
     304    Status = vbsfNtVBoxStatusToNt(vrc);
    305305
    306306    if (Status != STATUS_SUCCESS)
     
    418418    ByteCount = ctx.cbData;
    419419
    420     Status = VBoxErrorToNTStatus(vrc);
     420    Status = vbsfNtVBoxStatusToNt(vrc);
    421421
    422422    if (Status != STATUS_SUCCESS)
     
    516516                       LowIoContext->ParamsFor.Locks.ByteOffset, LowIoContext->ParamsFor.Locks.Length, fu32Lock);
    517517
    518     Status = VBoxErrorToNTStatus(vrc);
     518    Status = vbsfNtVBoxStatusToNt(vrc);
    519519
    520520    Log(("VBOXSF: MRxLocks: Returned 0x%08X\n", Status));
     
    547547    vrc = VbglR0SfFlush(&g_SfClient, &pNetRootExtension->map, pVBoxFobx->hFile);
    548548
    549     Status = VBoxErrorToNTStatus(vrc);
     549    Status = vbsfNtVBoxStatusToNt(vrc);
    550550
    551551    Log(("VBOXSF: MRxFlush: Returned 0x%08X\n", Status));
     
    553553}
    554554
    555 NTSTATUS vbsfSetEndOfFile(IN OUT struct _RX_CONTEXT * RxContext,
     555NTSTATUS vbsfNtSetEndOfFile(IN OUT struct _RX_CONTEXT * RxContext,
    556556                          IN OUT PLARGE_INTEGER pNewFileSize,
    557557                          OUT PLARGE_INTEGER pNewAllocationSize)
     
    569569    int vrc;
    570570
    571     Log(("VBOXSF: vbsfSetEndOfFile: New size = %RX64 (%p), pNewAllocationSize = %p\n",
     571    Log(("VBOXSF: vbsfNtSetEndOfFile: New size = %RX64 (%p), pNewAllocationSize = %p\n",
    572572         pNewFileSize->QuadPart, pNewFileSize, pNewAllocationSize));
    573573
     
    575575
    576576    cbBuffer = sizeof(SHFLFSOBJINFO);
    577     pObjInfo = (SHFLFSOBJINFO *)vbsfAllocNonPagedMem(cbBuffer);
     577    pObjInfo = (SHFLFSOBJINFO *)vbsfNtAllocNonPagedMem(cbBuffer);
    578578    if (!pObjInfo)
    579579    {
     
    588588                         SHFL_INFO_SET | SHFL_INFO_SIZE, &cbBuffer, (PSHFLDIRINFO)pObjInfo);
    589589
    590     Log(("VBOXSF: vbsfSetEndOfFile: VbglR0SfFsInfo returned %Rrc\n", vrc));
    591 
    592     Status = VBoxErrorToNTStatus(vrc);
     590    Log(("VBOXSF: vbsfNtSetEndOfFile: VbglR0SfFsInfo returned %Rrc\n", vrc));
     591
     592    Status = vbsfNtVBoxStatusToNt(vrc);
    593593    if (Status == STATUS_SUCCESS)
    594594    {
    595         Log(("VBOXSF: vbsfSetEndOfFile: VbglR0SfFsInfo new allocation size = %RX64\n",
     595        Log(("VBOXSF: vbsfNtSetEndOfFile: VbglR0SfFsInfo new allocation size = %RX64\n",
    596596             pObjInfo->cbAllocated));
    597597
     
    601601
    602602    if (pObjInfo)
    603         vbsfFreeNonPagedMem(pObjInfo);
    604 
    605     Log(("VBOXSF: vbsfSetEndOfFile: Returned 0x%08X\n", Status));
     603        vbsfNtFreeNonPagedMem(pObjInfo);
     604
     605    Log(("VBOXSF: vbsfNtSetEndOfFile: Returned 0x%08X\n", Status));
    606606    return Status;
    607607}
     
    618618    RT_NOREF(RxContext);
    619619
    620     /* Note: On Windows hosts vbsfSetEndOfFile returns ACCESS_DENIED if the file has been
     620    /* Note: On Windows hosts vbsfNtSetEndOfFile returns ACCESS_DENIED if the file has been
    621621     *       opened in APPEND mode. Writes to a file will extend it anyway, therefore it is
    622622     *       better to not call the host at all and tell the caller that the file was extended.
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/info.cpp

    r78321 r78326  
    9595         cbHGCMBuffer));
    9696
    97     pHGCMBuffer = (uint8_t *)vbsfAllocNonPagedMem(cbHGCMBuffer);
     97    pHGCMBuffer = (uint8_t *)vbsfNtAllocNonPagedMem(cbHGCMBuffer);
    9898    if (!pHGCMBuffer)
    9999    {
     
    134134        Log(("VBOXSF: MrxQueryDirectory: ParsedPathSize = %d\n", ParsedPathSize));
    135135
    136         ParsedPath = (PSHFLSTRING)vbsfAllocNonPagedMem(ParsedPathSize);
     136        ParsedPath = (PSHFLSTRING)vbsfNtAllocNonPagedMem(ParsedPathSize);
    137137        if (!ParsedPath)
    138138        {
     
    226226
    227227        default:
    228             Status = VBoxErrorToNTStatus(vrc);
     228            Status = vbsfNtVBoxStatusToNt(vrc);
    229229            Log(("VBOXSF: MrxQueryDirectory: Error %Rrc from CallDirInfo (cFiles=%d)!\n",
    230230                 vrc, cFiles));
     
    510510end:
    511511    if (pHGCMBuffer)
    512         vbsfFreeNonPagedMem(pHGCMBuffer);
     512        vbsfNtFreeNonPagedMem(pHGCMBuffer);
    513513
    514514    if (ParsedPath)
    515         vbsfFreeNonPagedMem(ParsedPath);
     515        vbsfNtFreeNonPagedMem(ParsedPath);
    516516
    517517    Log(("VBOXSF: MrxQueryDirectory: Returned 0x%08X\n",
     
    596596            /* Query serial number. */
    597597            cbHGCMBuffer = sizeof(SHFLVOLINFO);
    598             pHGCMBuffer = (uint8_t *)vbsfAllocNonPagedMem(cbHGCMBuffer);
     598            pHGCMBuffer = (uint8_t *)vbsfNtAllocNonPagedMem(cbHGCMBuffer);
    599599            if (!pHGCMBuffer)
    600600            {
     
    608608            if (vrc != VINF_SUCCESS)
    609609            {
    610                 Status = VBoxErrorToNTStatus(vrc);
    611                 vbsfFreeNonPagedMem(pHGCMBuffer);
     610                Status = vbsfNtVBoxStatusToNt(vrc);
     611                vbsfNtFreeNonPagedMem(pHGCMBuffer);
    612612                break;
    613613            }
     
    615615            pShflVolInfo = (PSHFLVOLINFO)pHGCMBuffer;
    616616            pInfo->VolumeSerialNumber = pShflVolInfo->ulSerial;
    617             vbsfFreeNonPagedMem(pHGCMBuffer);
     617            vbsfNtFreeNonPagedMem(pHGCMBuffer);
    618618
    619619            pInfo->VolumeCreationTime.QuadPart = 0;
     
    769769
    770770            cbHGCMBuffer = sizeof(SHFLVOLINFO);
    771             pHGCMBuffer = (uint8_t *)vbsfAllocNonPagedMem(cbHGCMBuffer);
     771            pHGCMBuffer = (uint8_t *)vbsfNtAllocNonPagedMem(cbHGCMBuffer);
    772772            if (!pHGCMBuffer)
    773773            {
     
    781781            if (vrc != VINF_SUCCESS)
    782782            {
    783                 Status = VBoxErrorToNTStatus(vrc);
    784                 vbsfFreeNonPagedMem(pHGCMBuffer);
     783                Status = vbsfNtVBoxStatusToNt(vrc);
     784                vbsfNtFreeNonPagedMem(pHGCMBuffer);
    785785                break;
    786786            }
     
    814814            }
    815815
    816             vbsfFreeNonPagedMem(pHGCMBuffer);
     816            vbsfNtFreeNonPagedMem(pHGCMBuffer);
    817817
    818818            Status = STATUS_SUCCESS;
     
    10891089                else
    10901090                {
    1091                     Status = VBoxErrorToNTStatus(vrc);
     1091                    Status = vbsfNtVBoxStatusToNt(vrc);
    10921092                    VbglR0PhysHeapFree(pReq);
    10931093                    break;
     
    13721372
    13731373            cbBuffer = sizeof(SHFLFSOBJINFO);
    1374             pHGCMBuffer = (uint8_t *)vbsfAllocNonPagedMem(cbBuffer);
     1374            pHGCMBuffer = (uint8_t *)vbsfNtAllocNonPagedMem(cbBuffer);
    13751375            AssertReturn(pHGCMBuffer, STATUS_INSUFFICIENT_RESOURCES);
    13761376            RtlZeroMemory(pHGCMBuffer, cbBuffer);
     
    14181418            else
    14191419            {
    1420                 Status = VBoxErrorToNTStatus(vrc);
     1420                Status = vbsfNtVBoxStatusToNt(vrc);
    14211421                goto end;
    14221422            }
     
    14321432
    14331433            if (pInfo->DeleteFile && capFcb->OpenCount == 1)
    1434                 Status = vbsfRemove(RxContext);
     1434                Status = vbsfNtRemove(RxContext);
    14351435            else
    14361436                Status = STATUS_SUCCESS;
     
    14691469                /* Treat the request as a EndOfFile update. */
    14701470                LARGE_INTEGER NewAllocationSize;
    1471                 Status = vbsfSetEndOfFile(RxContext, &pInfo->AllocationSize, &NewAllocationSize);
     1471                Status = vbsfNtSetEndOfFile(RxContext, &pInfo->AllocationSize, &NewAllocationSize);
    14721472            }
    14731473
     
    14831483                 pInfo->EndOfFile.QuadPart, capFcb->Header.FileSize.QuadPart));
    14841484
    1485             Status = vbsfSetEndOfFile(RxContext, &pInfo->EndOfFile, &NewAllocationSize);
     1485            Status = vbsfNtSetEndOfFile(RxContext, &pInfo->EndOfFile, &NewAllocationSize);
    14861486
    14871487            Log(("VBOXSF: MrxSetFileInfo: FileEndOfFileInformation: AllocSize = 0x%RX64, Status 0x%08X\n",
     
    15111511#endif
    15121512
    1513             Status = vbsfRename(RxContext, FileRenameInformation, pInfoBuffer, RxContext->Info.Length);
     1513            Status = vbsfNtRename(RxContext, FileRenameInformation, pInfoBuffer, RxContext->Info.Length);
    15141514            break;
    15151515        }
     
    15241524end:
    15251525    if (pHGCMBuffer)
    1526         vbsfFreeNonPagedMem(pHGCMBuffer);
     1526        vbsfNtFreeNonPagedMem(pHGCMBuffer);
    15271527
    15281528    Log(("VBOXSF: MrxSetFileInfo: Returned 0x%08X\n", Status));
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/net.cpp

    r78321 r78326  
    201201                 RootNameLength, RootNameLength / sizeof(WCHAR), pRootName));
    202202
    203             Status = vbsfShflStringFromUnicodeAlloc(&ParsedPath, pRootName, (uint16_t)RootNameLength);
     203            Status = vbsfNtShflStringFromUnicodeAlloc(&ParsedPath, pRootName, (uint16_t)RootNameLength);
    204204            if (Status != STATUS_SUCCESS)
    205205            {
     
    208208
    209209            vrc = VbglR0SfMapFolder(&g_SfClient, ParsedPath, &pNetRootExtension->map);
    210             vbsfFreeNonPagedMem(ParsedPath);
     210            vbsfNtFreeNonPagedMem(ParsedPath);
    211211            if (RT_SUCCESS(vrc))
    212212            {
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/path.cpp

    r78321 r78326  
    141141
    142142    /* Initialize create parameters. */
    143     pCreateParms = (SHFLCREATEPARMS *)vbsfAllocNonPagedMem(sizeof(SHFLCREATEPARMS));
     143    pCreateParms = (SHFLCREATEPARMS *)vbsfNtAllocNonPagedMem(sizeof(SHFLCREATEPARMS));
    144144    if (!pCreateParms)
    145145    {
     
    265265        if (!bf.SlashHack)
    266266        {
    267             Status = vbsfShflStringFromUnicodeAlloc(&ParsedPath, RemainingName->Buffer, RemainingName->Length);
     267            Status = vbsfNtShflStringFromUnicodeAlloc(&ParsedPath, RemainingName->Buffer, RemainingName->Length);
    268268            if (Status != STATUS_SUCCESS)
    269269                goto failure;
     
    272272        {
    273273            /* Add back the slash we had to hide from RDBSS. */
    274             Status = vbsfShflStringFromUnicodeAlloc(&ParsedPath, NULL, RemainingName->Length + sizeof(RTUTF16));
     274            Status = vbsfNtShflStringFromUnicodeAlloc(&ParsedPath, NULL, RemainingName->Length + sizeof(RTUTF16));
    275275            if (Status != STATUS_SUCCESS)
    276276                goto failure;
     
    288288        vrc = VbglR0SfCreate(&g_SfClient, &pNetRootExtension->map, ParsedPath, pCreateParms);
    289289
    290         vbsfFreeNonPagedMem(ParsedPath);
     290        vbsfNtFreeNonPagedMem(ParsedPath);
    291291    }
    292292
     
    321321            {
    322322                *pulCreateAction = FILE_DOES_NOT_EXIST;
    323                 Status = VBoxErrorToNTStatus(vrc);
     323                Status = vbsfNtVBoxStatusToNt(vrc);
    324324                goto failure;
    325325            }
     
    436436    *pInfo = pCreateParms->Info;
    437437
    438     vbsfFreeNonPagedMem(pCreateParms);
     438    vbsfNtFreeNonPagedMem(pCreateParms);
    439439
    440440    return Status;
     
    452452
    453453    if (pCreateParms)
    454         vbsfFreeNonPagedMem(pCreateParms);
     454        vbsfNtFreeNonPagedMem(pCreateParms);
    455455
    456456    return Status;
     
    689689
    690690    cbBuffer = sizeof(SHFLFSOBJINFO);
    691     pHGCMBuffer = (uint8_t *)vbsfAllocNonPagedMem(cbBuffer);
     691    pHGCMBuffer = (uint8_t *)vbsfNtAllocNonPagedMem(cbBuffer);
    692692    if (!pHGCMBuffer)
    693693    {
     
    714714
    715715    if (vrc != VINF_SUCCESS)
    716         Status = VBoxErrorToNTStatus(vrc);
     716        Status = vbsfNtVBoxStatusToNt(vrc);
    717717
    718718    if (pHGCMBuffer)
    719         vbsfFreeNonPagedMem(pHGCMBuffer);
     719        vbsfNtFreeNonPagedMem(pHGCMBuffer);
    720720
    721721    Log(("VBOXSF: vbsfSetFileInfo: Returned 0x%08X\n", Status));
     
    761761
    762762    if (vrc != VINF_SUCCESS)
    763         Status = VBoxErrorToNTStatus(vrc);
     763        Status = vbsfNtVBoxStatusToNt(vrc);
    764764
    765765    Log(("VBOXSF: vbsfCloseFileHandle: Returned 0x%08X\n", Status));
     
    811811        /* Remove file or directory if delete action is pending. */
    812812        if (capFcb->OpenCount == 0)
    813             Status = vbsfRemove(RxContext);
     813            Status = vbsfNtRemove(RxContext);
    814814    }
    815815
     
    817817}
    818818
    819 NTSTATUS vbsfRemove(IN PRX_CONTEXT RxContext)
     819NTSTATUS vbsfNtRemove(IN PRX_CONTEXT RxContext)
    820820{
    821821    NTSTATUS Status = STATUS_SUCCESS;
     
    832832    PSHFLSTRING ParsedPath = NULL;
    833833
    834     Log(("VBOXSF: vbsfRemove: Delete %.*ls. open count = %d\n",
     834    Log(("VBOXSF: vbsfNtRemove: Delete %.*ls. open count = %d\n",
    835835         RemainingName->Length / sizeof(WCHAR), RemainingName->Buffer, capFcb->OpenCount));
    836836
     
    839839        vbsfCloseFileHandle(pNetRootExtension, pVBoxFobx);
    840840
    841     Log(("VBOXSF: vbsfRemove: RemainingName->Length %d\n", RemainingName->Length));
    842     Status = vbsfShflStringFromUnicodeAlloc(&ParsedPath, RemainingName->Buffer, RemainingName->Length);
     841    Log(("VBOXSF: vbsfNtRemove: RemainingName->Length %d\n", RemainingName->Length));
     842    Status = vbsfNtShflStringFromUnicodeAlloc(&ParsedPath, RemainingName->Buffer, RemainingName->Length);
    843843    if (Status != STATUS_SUCCESS)
    844844        return Status;
     
    850850
    851851    if (ParsedPath)
    852         vbsfFreeNonPagedMem(ParsedPath);
     852        vbsfNtFreeNonPagedMem(ParsedPath);
    853853
    854854    if (vrc == VINF_SUCCESS)
    855855        SetFlag(capFobx->pSrvOpen->Flags, SRVOPEN_FLAG_FILE_DELETED);
    856856
    857     Status = VBoxErrorToNTStatus(vrc);
     857    Status = vbsfNtVBoxStatusToNt(vrc);
    858858    if (vrc != VINF_SUCCESS)
    859         Log(("VBOXSF: vbsfRemove: VbglR0SfRemove failed with %Rrc\n", vrc));
    860 
    861     Log(("VBOXSF: vbsfRemove: Returned 0x%08X\n", Status));
     859        Log(("VBOXSF: vbsfNtRemove: VbglR0SfRemove failed with %Rrc\n", vrc));
     860
     861    Log(("VBOXSF: vbsfNtRemove: Returned 0x%08X\n", Status));
    862862    return Status;
    863863}
    864864
    865 NTSTATUS vbsfRename(IN PRX_CONTEXT RxContext,
     865NTSTATUS vbsfNtRename(IN PRX_CONTEXT RxContext,
    866866                    IN FILE_INFORMATION_CLASS FileInformationClass,
    867867                    IN PVOID pBuffer,
     
    888888    Assert(FileInformationClass == FileRenameInformation);
    889889
    890     Log(("VBOXSF: vbsfRename: FileName = %.*ls\n",
     890    Log(("VBOXSF: vbsfNtRename: FileName = %.*ls\n",
    891891         RenameInformation->FileNameLength / sizeof(WCHAR), &RenameInformation->FileName[0]));
    892892
     
    898898    SetFlag(pSrvOpen->Flags, SRVOPEN_FLAG_FILE_RENAMED);
    899899
    900     Log(("VBOXSF: vbsfRename: RenameInformation->FileNameLength = %d\n", RenameInformation->FileNameLength));
    901     Status = vbsfShflStringFromUnicodeAlloc(&DestPath, RenameInformation->FileName, (uint16_t)RenameInformation->FileNameLength);
     900    Log(("VBOXSF: vbsfNtRename: RenameInformation->FileNameLength = %d\n", RenameInformation->FileNameLength));
     901    Status = vbsfNtShflStringFromUnicodeAlloc(&DestPath, RenameInformation->FileName, (uint16_t)RenameInformation->FileNameLength);
    902902    if (Status != STATUS_SUCCESS)
    903903        return Status;
    904904
    905     Log(("VBOXSF: vbsfRename: Destination path = %.*ls\n",
     905    Log(("VBOXSF: vbsfNtRename: Destination path = %.*ls\n",
    906906         DestPath->u16Length / sizeof(WCHAR), &DestPath->String.ucs2[0]));
    907907
    908     Log(("VBOXSF: vbsfRename: RemainingName->Length = %d\n", RemainingName->Length));
    909     Status = vbsfShflStringFromUnicodeAlloc(&SrcPath, RemainingName->Buffer, RemainingName->Length);
     908    Log(("VBOXSF: vbsfNtRename: RemainingName->Length = %d\n", RemainingName->Length));
     909    Status = vbsfNtShflStringFromUnicodeAlloc(&SrcPath, RemainingName->Buffer, RemainingName->Length);
    910910    if (Status != STATUS_SUCCESS)
    911911    {
    912         vbsfFreeNonPagedMem(DestPath);
     912        vbsfNtFreeNonPagedMem(DestPath);
    913913        return Status;
    914914    }
    915915
    916     Log(("VBOXSF: vbsfRename: Source path = %.*ls\n",
     916    Log(("VBOXSF: vbsfNtRename: Source path = %.*ls\n",
    917917         SrcPath->u16Length / sizeof(WCHAR), &SrcPath->String.ucs2[0]));
    918918
     
    922922        flags |= SHFL_RENAME_REPLACE_IF_EXISTS;
    923923
    924     Log(("VBOXSF: vbsfRename: Calling VbglR0SfRename\n"));
     924    Log(("VBOXSF: vbsfNtRename: Calling VbglR0SfRename\n"));
    925925    vrc = VbglR0SfRename(&g_SfClient, &pNetRootExtension->map, SrcPath, DestPath, flags);
    926926
    927     vbsfFreeNonPagedMem(SrcPath);
    928     vbsfFreeNonPagedMem(DestPath);
    929 
    930     Status = VBoxErrorToNTStatus(vrc);
     927    vbsfNtFreeNonPagedMem(SrcPath);
     928    vbsfNtFreeNonPagedMem(DestPath);
     929
     930    Status = vbsfNtVBoxStatusToNt(vrc);
    931931    if (vrc != VINF_SUCCESS)
    932         Log(("VBOXSF: vbsfRename: VbglR0SfRename failed with %Rrc\n", vrc));
    933 
    934     Log(("VBOXSF: vbsfRename: Returned 0x%08X\n", Status));
     932        Log(("VBOXSF: vbsfNtRename: VbglR0SfRename failed with %Rrc\n", vrc));
     933
     934    Log(("VBOXSF: vbsfNtRename: Returned 0x%08X\n", Status));
    935935    return Status;
    936936}
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsf.cpp

    r78321 r78326  
    7676    PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
    7777    Log(("VBOXSF: MRxFsdDispatch: major %d, minor %d: %s\n",
    78          IrpSp->MajorFunction, IrpSp->MinorFunction, MajorFunctionString(IrpSp->MajorFunction, IrpSp->MinorFunction)));
     78         IrpSp->MajorFunction, IrpSp->MinorFunction, vbsfNtMajorFunctionName(IrpSp->MajorFunction, IrpSp->MinorFunction)));
    7979#endif
    8080
     
    752752                {
    753753                    Log(("VBOXSF: MRxDevFcbXXXControlFile: IOCTL_MRX_VBOX_ADDCONN\n"));
    754                     Status = vbsfCreateConnection(RxContext, &RxContext->PostRequest);
     754                    Status = vbsfNtCreateConnection(RxContext, &RxContext->PostRequest);
    755755                    break;
    756756                }
     
    759759                {
    760760                    Log(("VBOXSF: MRxDevFcbXXXControlFile: IOCTL_MRX_VBOX_DELCONN\n"));
    761                     Status = vbsfDeleteConnection(RxContext, &RxContext->PostRequest);
     761                    Status = vbsfNtDeleteConnection(RxContext, &RxContext->PostRequest);
    762762                    break;
    763763                }
     
    851851                    else
    852852                    {
    853                         Status = VBoxErrorToNTStatus(vrc);
     853                        Status = vbsfNtVBoxStatusToNt(vrc);
    854854                        Log(("VBOXSF: MRxDevFcbXXXControlFile: IOCTL_MRX_VBOX_GETGLOBALLIST failed: 0x%08X\n",
    855855                             Status));
     
    969969
    970970                    /* Allocate empty string where the host can store cbRemoteName bytes. */
    971                     Status = vbsfShflStringFromUnicodeAlloc(&pString, NULL, (uint16_t)cbRemoteName);
     971                    Status = vbsfNtShflStringFromUnicodeAlloc(&pString, NULL, (uint16_t)cbRemoteName);
    972972                    if (Status != STATUS_SUCCESS)
    973973                        break;
     
    999999                    }
    10001000
    1001                     vbsfFreeNonPagedMem(pString);
     1001                    vbsfNtFreeNonPagedMem(pString);
    10021002
    10031003                    break;
     
    12721272}
    12731273
    1274 NTSTATUS vbsfCreateConnection(IN PRX_CONTEXT RxContext, OUT PBOOLEAN PostToFsp)
     1274NTSTATUS vbsfNtCreateConnection(IN PRX_CONTEXT RxContext, OUT PBOOLEAN PostToFsp)
    12751275{
    12761276    NTSTATUS Status = STATUS_SUCCESS;
     
    12871287    BOOLEAN fMutexAcquired = FALSE;
    12881288
    1289     Log(("VBOXSF: vbsfCreateConnection\n"));
     1289    Log(("VBOXSF: vbsfNtCreateConnection\n"));
    12901290
    12911291    if (!BooleanFlagOn(RxContext->Flags, RX_CONTEXT_FLAG_WAIT))
    12921292    {
    1293         Log(("VBOXSF: vbsfCreateConnection: post to file system process\n"));
     1293        Log(("VBOXSF: vbsfNtCreateConnection: post to file system process\n"));
    12941294        *PostToFsp = TRUE;
    12951295        return STATUS_PENDING;
     
    13061306    if (cbConnectName == 0 || !pwcConnectName)
    13071307    {
    1308         Log(("VBOXSF: vbsfCreateConnection: Connection name / length is invalid!\n"));
     1308        Log(("VBOXSF: vbsfNtCreateConnection: Connection name / length is invalid!\n"));
    13091309        return STATUS_INVALID_PARAMETER;
    13101310    }
     
    13121312    __try
    13131313    {
    1314         Log(("VBOXSF: vbsfCreateConnection: Name = %.*ls, Len = %d\n",
     1314        Log(("VBOXSF: vbsfNtCreateConnection: Name = %.*ls, Len = %d\n",
    13151315             cbConnectName / sizeof(WCHAR), pwcConnectName, cbConnectName));
    13161316
     
    13471347                    if (idx >= RTL_NUMBER_OF(pDeviceExtension->cLocalConnections))
    13481348                    {
    1349                         Log(("VBOXSF: vbsfCreateConnection: Index 0x%x is invalid!\n",
     1349                        Log(("VBOXSF: vbsfNtCreateConnection: Index 0x%x is invalid!\n",
    13501350                             idx));
    13511351                        Status = STATUS_BAD_NETWORK_NAME;
     
    13581358                        if (pDeviceExtension->wszLocalConnectionName[idx] != NULL)
    13591359                        {
    1360                             Log(("VBOXSF: vbsfCreateConnection: LocalConnectionName at index %d is NOT empty!\n",
     1360                            Log(("VBOXSF: vbsfNtCreateConnection: LocalConnectionName at index %d is NOT empty!\n",
    13611361                                 idx));
    13621362                        }
    13631363
    1364                         pDeviceExtension->wszLocalConnectionName[idx] = (PUNICODE_STRING)vbsfAllocNonPagedMem(sizeof(UNICODE_STRING) + cbConnectName);
     1364                        pDeviceExtension->wszLocalConnectionName[idx] = (PUNICODE_STRING)vbsfNtAllocNonPagedMem(sizeof(UNICODE_STRING) + cbConnectName);
    13651365
    13661366                        if (!pDeviceExtension->wszLocalConnectionName[idx])
    13671367                        {
    1368                             Log(("VBOXSF: vbsfCreateConnection: LocalConnectionName at index %d NOT allocated!\n",
     1368                            Log(("VBOXSF: vbsfNtCreateConnection: LocalConnectionName at index %d NOT allocated!\n",
    13691369                                 idx));
    13701370                            Status = STATUS_INSUFFICIENT_RESOURCES;
     
    13791379                            RtlCopyMemory(&pRemoteName->Buffer[0], pwc+2, pRemoteName->Length);
    13801380
    1381                             Log(("VBOXSF: vbsfCreateConnection: RemoteName %.*ls, Len = %d\n",
     1381                            Log(("VBOXSF: vbsfNtCreateConnection: RemoteName %.*ls, Len = %d\n",
    13821382                                 pRemoteName->Length / sizeof(WCHAR), pRemoteName->Buffer, pRemoteName->Length));
    13831383
     
    13921392            else
    13931393            {
    1394                 Log(("VBOXSF: vbsfCreateConnection: bad format\n"));
     1394                Log(("VBOXSF: vbsfNtCreateConnection: bad format\n"));
    13951395                Status = STATUS_BAD_NETWORK_NAME;
    13961396            }
     
    13981398        else
    13991399        {
    1400             Log(("VBOXSF: vbsfCreateConnection: connection was not found\n"));
     1400            Log(("VBOXSF: vbsfNtCreateConnection: connection was not found\n"));
    14011401            Status = STATUS_BAD_NETWORK_NAME;
    14021402        }
     
    14161416}
    14171417
    1418 NTSTATUS vbsfDeleteConnection(IN PRX_CONTEXT RxContext, OUT PBOOLEAN PostToFsp)
     1418NTSTATUS vbsfNtDeleteConnection(IN PRX_CONTEXT RxContext, OUT PBOOLEAN PostToFsp)
    14191419{
    14201420    NTSTATUS Status;
     
    14281428    BOOLEAN fMutexAcquired = FALSE;
    14291429
    1430     Log(("VBOXSF: vbsfDeleteConnection\n"));
     1430    Log(("VBOXSF: vbsfNtDeleteConnection\n"));
    14311431
    14321432    if (!BooleanFlagOn(RxContext->Flags, RX_CONTEXT_FLAG_WAIT))
    14331433    {
    1434         Log(("VBOXSF: vbsfDeleteConnection: post to file system process\n"));
     1434        Log(("VBOXSF: vbsfNtDeleteConnection: post to file system process\n"));
    14351435        *PostToFsp = TRUE;
    14361436        return STATUS_PENDING;
     
    14471447    __try
    14481448    {
    1449         Log(("VBOXSF: vbsfDeleteConnection: pwcConnectName = %.*ls\n",
     1449        Log(("VBOXSF: vbsfNtDeleteConnection: pwcConnectName = %.*ls\n",
    14501450             cbConnectName / sizeof(WCHAR), pwcConnectName));
    14511451
     
    14601460            Status = ObReferenceObjectByHandle(Handle, 0L, NULL, KernelMode, (PVOID *)&pFileObject, NULL);
    14611461
    1462             Log(("VBOXSF: vbsfDeleteConnection: ObReferenceObjectByHandle Status 0x%08X\n",
     1462            Log(("VBOXSF: vbsfNtDeleteConnection: ObReferenceObjectByHandle Status 0x%08X\n",
    14631463                 Status));
    14641464
     
    14661466            {
    14671467                PFOBX Fobx = (PFOBX)pFileObject->FsContext2;
    1468                 Log(("VBOXSF: vbsfDeleteConnection: Fobx %p\n", Fobx));
     1468                Log(("VBOXSF: vbsfNtDeleteConnection: Fobx %p\n", Fobx));
    14691469
    14701470                if (Fobx && NodeType(Fobx) == RDBSS_NTC_V_NETROOT)
     
    14801480                else
    14811481                {
    1482                     Log(("VBOXSF: vbsfDeleteConnection: wrong FsContext2\n"));
     1482                    Log(("VBOXSF: vbsfNtDeleteConnection: wrong FsContext2\n"));
    14831483                    Status = STATUS_INVALID_DEVICE_REQUEST;
    14841484                }
     
    15151515                        if (idx >= RTL_NUMBER_OF(pDeviceExtension->cLocalConnections))
    15161516                        {
    1517                             Log(("VBOXSF: vbsfDeleteConnection: Index 0x%x is invalid!\n",
     1517                            Log(("VBOXSF: vbsfNtDeleteConnection: Index 0x%x is invalid!\n",
    15181518                                 idx));
    15191519                            Status = STATUS_BAD_NETWORK_NAME;
     
    15291529                            if (pDeviceExtension->wszLocalConnectionName[idx])
    15301530                            {
    1531                                 vbsfFreeNonPagedMem(pDeviceExtension->wszLocalConnectionName[idx]);
     1531                                vbsfNtFreeNonPagedMem(pDeviceExtension->wszLocalConnectionName[idx]);
    15321532                                pDeviceExtension->wszLocalConnectionName[idx] = NULL;
    15331533                            }
     
    15361536                            fMutexAcquired = FALSE;
    15371537
    1538                             Log(("VBOXSF: vbsfDeleteConnection: deleted index 0x%x\n",
     1538                            Log(("VBOXSF: vbsfNtDeleteConnection: deleted index 0x%x\n",
    15391539                                 idx));
    15401540                        }
     
    15431543                else
    15441544                {
    1545                     Log(("VBOXSF: vbsfCreateConnection: bad format\n"));
     1545                    Log(("VBOXSF: vbsfNtCreateConnection: bad format\n"));
    15461546                    Status = STATUS_BAD_NETWORK_NAME;
    15471547                }
     
    15601560    }
    15611561
    1562     Log(("VBOXSF: vbsfDeleteConnection: Status 0x%08X\n", Status));
     1562    Log(("VBOXSF: vbsfNtDeleteConnection: Status 0x%08X\n", Status));
    15631563    return Status;
    15641564}
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsf.h

    r78321 r78326  
    213213 * @{
    214214 */
    215 NTSTATUS vbsfDeleteConnection(IN PRX_CONTEXT RxContext,
    216                               OUT PBOOLEAN PostToFsp);
    217 NTSTATUS vbsfCreateConnection(IN PRX_CONTEXT RxContext,
    218                               OUT PBOOLEAN PostToFsp);
    219 
    220 NTSTATUS vbsfSetEndOfFile(IN OUT struct _RX_CONTEXT * RxContext,
    221                           IN OUT PLARGE_INTEGER pNewFileSize,
    222                           OUT PLARGE_INTEGER pNewAllocationSize);
    223 NTSTATUS vbsfRename(IN PRX_CONTEXT RxContext,
    224                     IN FILE_INFORMATION_CLASS FileInformationClass,
    225                     IN PVOID pBuffer,
    226                     IN ULONG BufferLength);
    227 NTSTATUS vbsfRemove(IN PRX_CONTEXT RxContext);
     215NTSTATUS vbsfNtDeleteConnection(IN PRX_CONTEXT RxContext,
     216                                OUT PBOOLEAN PostToFsp);
     217NTSTATUS vbsfNtCreateConnection(IN PRX_CONTEXT RxContext,
     218                                OUT PBOOLEAN PostToFsp);
     219
     220NTSTATUS vbsfNtSetEndOfFile(IN OUT struct _RX_CONTEXT * RxContext,
     221                            IN OUT PLARGE_INTEGER pNewFileSize,
     222                            OUT PLARGE_INTEGER pNewAllocationSize);
     223NTSTATUS vbsfNtRename(IN PRX_CONTEXT RxContext,
     224                      IN FILE_INFORMATION_CLASS FileInformationClass,
     225                      IN PVOID pBuffer,
     226                      IN ULONG BufferLength);
     227NTSTATUS vbsfNtRemove(IN PRX_CONTEXT RxContext);
    228228
    229229void     vbsfNtCopyInfoToLegacy(PMRX_VBOX_FOBX pVBoxFobx, PCSHFLFSOBJINFO pInfo);
     
    231231
    232232
    233 NTSTATUS vbsfHlpCreateDriveLetter(WCHAR Letter, UNICODE_STRING *pDeviceName);
    234 NTSTATUS vbsfHlpDeleteDriveLetter(WCHAR Letter);
    235 NTSTATUS VBoxErrorToNTStatus(int vrc);
    236 
    237 PVOID    vbsfAllocNonPagedMem(ULONG ulSize);
    238 void     vbsfFreeNonPagedMem(PVOID lpMem);
     233NTSTATUS vbsfNtVBoxStatusToNt(int vrc);
     234
     235PVOID    vbsfNtAllocNonPagedMem(ULONG ulSize);
     236void     vbsfNtFreeNonPagedMem(PVOID lpMem);
    239237
    240238#if defined(DEBUG) || defined(LOG_ENABLED)
    241 PCHAR MajorFunctionString(UCHAR MajorFunction, LONG MinorFunction);
     239const char *vbsfNtMajorFunctionName(UCHAR MajorFunction, LONG MinorFunction);
    242240#endif
    243241
    244 NTSTATUS vbsfShflStringFromUnicodeAlloc(PSHFLSTRING *ppShflString, const WCHAR *pwc, uint16_t cb);
     242NTSTATUS vbsfNtShflStringFromUnicodeAlloc(PSHFLSTRING *ppShflString, const WCHAR *pwc, uint16_t cb);
    245243
    246244/**
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsfhlp.cpp

    r78321 r78326  
    2828*********************************************************************************************************************************/
    2929#ifdef DEBUG
    30 static int s_iAllocRefCount = 0;
     30static int volatile g_cAllocations = 0;
    3131#endif
    3232
    33 
    34 NTSTATUS vbsfHlpCreateDriveLetter(WCHAR Letter, UNICODE_STRING *pDeviceName)
    35 {
    36     UNICODE_STRING driveName;
    37     RtlInitUnicodeString(&driveName,L"\\??\\_:" );
    38 
    39     /* Replace '_' with actual drive letter */
    40     driveName.Buffer[driveName.Length/sizeof(WCHAR) - 2] = Letter;
    41 
    42     return IoCreateSymbolicLink(&driveName, pDeviceName);
    43 }
    44 
    45 NTSTATUS vbsfHlpDeleteDriveLetter(WCHAR Letter)
    46 {
    47     UNICODE_STRING driveName;
    48     RtlInitUnicodeString(&driveName,L"\\??\\_:" );
    49 
    50     /* Replace '_' with actual drive letter */
    51     driveName.Buffer[driveName.Length/sizeof(WCHAR) - 2] = Letter;
    52 
    53     return IoDeleteSymbolicLink(&driveName);
    54 }
    5533
    5634/**
     
    6139 *
    6240 */
    63 NTSTATUS VBoxErrorToNTStatus(int vrc)
     41NTSTATUS vbsfNtVBoxStatusToNt(int vrc)
    6442{
    6543    NTSTATUS Status;
     
    147125
    148126        default:
    149             /** @todo error handling */
    150127            Status = STATUS_INVALID_PARAMETER;
    151128            Log(("Unexpected vbox error %Rrc\n",
     
    156133}
    157134
    158 PVOID vbsfAllocNonPagedMem(ULONG ulSize)
    159 {
    160     PVOID pMemory = NULL;
    161 
     135/**
     136 * Wrapper around ExAllocatePoolWithTag.
     137 */
     138PVOID vbsfNtAllocNonPagedMem(ULONG cbMemory)
     139{
     140    /* Tag is reversed (a.k.a "SHFL") to display correctly in debuggers, so search for "SHFL" */
     141    PVOID pMemory = ExAllocatePoolWithTag(NonPagedPool, cbMemory, 'LFHS');
     142    if (NULL != pMemory)
     143    {
     144        RtlZeroMemory(pMemory, cbMemory);
    162145#ifdef DEBUG
    163     s_iAllocRefCount = s_iAllocRefCount + 1;
    164     Log(("vbsfAllocNonPagedMem: RefCnt after incrementing: %d\n", s_iAllocRefCount));
     146        int const cAllocations = g_cAllocations += 1;
     147        Log(("vbsfNtAllocNonPagedMem: Allocated %u bytes of memory at %p (g_iAllocRefCount=%d)\n", cbMemory, pMemory, cAllocations));
    165148#endif
    166 
    167     /* Tag is reversed (a.k.a "SHFL") to display correctly in debuggers, so search for "SHFL" */
    168     pMemory = ExAllocatePoolWithTag(NonPagedPool, ulSize, 'LFHS');
    169 
    170     if (NULL != pMemory)
    171     {
    172         RtlZeroMemory(pMemory, ulSize);
     149    }
    173150#ifdef DEBUG
    174         Log(("vbsfAllocNonPagedMem: Allocated %d bytes of memory at %p.\n", ulSize, pMemory));
     151    else
     152        Log(("vbsfNtAllocNonPagedMem: ERROR: Could not allocate %u bytes of memory!\n", cbMemory));
    175153#endif
     154    return pMemory;
     155}
     156
     157/**
     158 * Wrapper around ExFreePoolWithTag.
     159 */
     160void vbsfNtFreeNonPagedMem(PVOID pvMemory)
     161{
     162#ifdef DEBUG
     163    int cAllocations = g_cAllocations -= 1;
     164    Log(("vbsfNtFreeNonPagedMem: %p (g_cAllocations=%d)\n", pvMemory, cAllocations));
     165#endif
     166    AssertPtr(pvMemory);
     167
     168    /* Tagged allocations must be freed using the same tag as used when allocating the memory. */
     169    ExFreePoolWithTag(pvMemory, 'LFHS');
     170}
     171
     172/** Allocate and initialize a SHFLSTRING from a UNICODE string.
     173 *
     174 *  @param ppShflString Where to store the pointer to the allocated SHFLSTRING structure.
     175 *                      The structure must be deallocated with vbsfNtFreeNonPagedMem.
     176 *  @param pwc          The UNICODE string. If NULL then SHFL is only allocated.
     177 *  @param cb           Size of the UNICODE string in bytes without the trailing nul.
     178 *
     179 *  @return Status code.
     180 */
     181NTSTATUS vbsfNtShflStringFromUnicodeAlloc(PSHFLSTRING *ppShflString, const WCHAR *pwc, uint16_t cb)
     182{
     183    NTSTATUS    Status;
     184
     185    /* Calculate length required for the SHFL structure: header + chars + nul. */
     186    ULONG const cbShflString = SHFLSTRING_HEADER_SIZE + cb + sizeof(WCHAR);
     187    PSHFLSTRING pShflString  = (PSHFLSTRING)vbsfNtAllocNonPagedMem(cbShflString);
     188    if (pShflString)
     189    {
     190        if (ShflStringInitBuffer(pShflString, cbShflString))
     191        {
     192            if (pwc)
     193            {
     194                RtlCopyMemory(pShflString->String.ucs2, pwc, cb);
     195                pShflString->String.ucs2[cb / sizeof(WCHAR)] = 0;
     196                pShflString->u16Length = cb; /* without terminating null */
     197                AssertMsg(pShflString->u16Length + sizeof(WCHAR) == pShflString->u16Size,
     198                          ("u16Length %d, u16Size %d\n", pShflString->u16Length, pShflString->u16Size));
     199            }
     200            else
     201            {
     202                /** @todo r=bird: vbsfNtAllocNonPagedMem already zero'ed it...   */
     203                RtlZeroMemory(pShflString->String.ucs2, cb + sizeof(WCHAR));
     204                pShflString->u16Length = 0; /* without terminating null */
     205                AssertMsg(pShflString->u16Size >= sizeof(WCHAR),
     206                          ("u16Size %d\n", pShflString->u16Size));
     207            }
     208
     209            *ppShflString = pShflString;
     210            Status = STATUS_SUCCESS;
     211        }
     212        else
     213        {
     214            vbsfNtFreeNonPagedMem(pShflString);
     215            Status = STATUS_INSUFFICIENT_RESOURCES;
     216        }
    176217    }
    177218    else
    178     {
    179 #ifdef DEBUG
    180         Log(("vbsfAllocNonPagedMem: ERROR: Could not allocate %d bytes of memory!\n", ulSize));
    181 #endif
    182     }
    183 
    184     return pMemory;
    185 }
    186 
    187 void vbsfFreeNonPagedMem(PVOID lpMem)
    188 {
    189 #ifdef DEBUG
    190     s_iAllocRefCount = s_iAllocRefCount - 1;
    191     Log(("vbsfFreeNonPagedMem: RefCnt after decrementing: %d\n", s_iAllocRefCount));
    192 #endif
    193 
    194     Assert(lpMem);
    195 
    196     /* MSDN: The ExFreePoolWithTag routine issues a bug check if the specified value for Tag does not match the tag value passed
    197      to the routine that originally allocated the memory block. Otherwise, the behavior of this routine is identical to ExFreePool. */
    198     ExFreePoolWithTag(lpMem, 'LFHS');
    199     lpMem = NULL;
    200 }
    201 
    202 #if 0 //def DEBUG
    203 /**
    204  * Callback for RTLogFormatV which writes to the backdoor.
    205  * See PFNLOGOUTPUT() for details.
    206  */
    207 static DECLCALLBACK(size_t) rtLogBackdoorOutput(void *pv, const char *pachChars, size_t cbChars)
    208 {
    209     RTLogWriteUser(pachChars, cbChars);
    210     return cbChars;
    211 }
    212 
    213 int RTLogBackdoorPrintf1(const char *pszFormat, ...)
    214 {
    215     va_list args;
    216 
    217     LARGE_INTEGER time;
    218 
    219     KeQueryTickCount(&time);
    220 
    221     RTLogBackdoorPrintf("T=%RX64 ", time.QuadPart);
    222     va_start(args, pszFormat);
    223     RTLogFormatV(rtLogBackdoorOutput, NULL, pszFormat, args);
    224     va_end(args);
    225 
    226     return 0;
    227 }
    228 #endif
     219        Status = STATUS_INSUFFICIENT_RESOURCES;
     220
     221    return Status;
     222}
    229223
    230224#if defined(DEBUG) || defined(LOG_ENABLED)
    231225
    232 static PCHAR PnPMinorFunctionString(LONG MinorFunction)
     226/** Debug routine for translating a minor PNP function to a string.  */
     227static const char *vbsfNtMinorPnpFunctionName(LONG MinorFunction)
    233228{
    234229    switch (MinorFunction)
     
    285280}
    286281
    287 PCHAR MajorFunctionString(UCHAR MajorFunction, LONG MinorFunction)
     282/** Debug routine for translating a major+minor IPR function to a string.  */
     283const char *vbsfNtMajorFunctionName(UCHAR MajorFunction, LONG MinorFunction)
    288284{
    289285    switch (MajorFunction)
    290286    {
    291         case IRP_MJ_CREATE:
    292             return "IRP_MJ_CREATE";
    293         case IRP_MJ_CREATE_NAMED_PIPE:
    294             return "IRP_MJ_CREATE_NAMED_PIPE";
    295         case IRP_MJ_CLOSE:
    296             return "IRP_MJ_CLOSE";
    297         case IRP_MJ_READ:
    298             return "IRP_MJ_READ";
    299         case IRP_MJ_WRITE:
    300             return "IRP_MJ_WRITE";
    301         case IRP_MJ_QUERY_INFORMATION:
    302             return "IRP_MJ_QUERY_INFORMATION";
    303         case IRP_MJ_SET_INFORMATION:
    304             return "IRP_MJ_SET_INFORMATION";
    305         case IRP_MJ_QUERY_EA:
    306             return "IRP_MJ_QUERY_EA";
    307         case IRP_MJ_SET_EA:
    308             return "IRP_MJ_SET_EA";
    309         case IRP_MJ_FLUSH_BUFFERS:
    310             return "IRP_MJ_FLUSH_BUFFERS";
    311         case IRP_MJ_QUERY_VOLUME_INFORMATION:
    312             return "IRP_MJ_QUERY_VOLUME_INFORMATION";
    313         case IRP_MJ_SET_VOLUME_INFORMATION:
    314             return "IRP_MJ_SET_VOLUME_INFORMATION";
    315         case IRP_MJ_DIRECTORY_CONTROL:
    316             return "IRP_MJ_DIRECTORY_CONTROL";
    317         case IRP_MJ_FILE_SYSTEM_CONTROL:
    318             return "IRP_MJ_FILE_SYSTEM_CONTROL";
    319         case IRP_MJ_DEVICE_CONTROL:
    320             return "IRP_MJ_DEVICE_CONTROL";
    321         case IRP_MJ_INTERNAL_DEVICE_CONTROL:
    322             return "IRP_MJ_INTERNAL_DEVICE_CONTROL";
    323         case IRP_MJ_SHUTDOWN:
    324             return "IRP_MJ_SHUTDOWN";
    325         case IRP_MJ_LOCK_CONTROL:
    326             return "IRP_MJ_LOCK_CONTROL";
    327         case IRP_MJ_CLEANUP:
    328             return "IRP_MJ_CLEANUP";
    329         case IRP_MJ_CREATE_MAILSLOT:
    330             return "IRP_MJ_CREATE_MAILSLOT";
    331         case IRP_MJ_QUERY_SECURITY:
    332             return "IRP_MJ_QUERY_SECURITY";
    333         case IRP_MJ_SET_SECURITY:
    334             return "IRP_MJ_SET_SECURITY";
    335         case IRP_MJ_POWER:
    336             return "IRP_MJ_POWER";
    337         case IRP_MJ_SYSTEM_CONTROL:
    338             return "IRP_MJ_SYSTEM_CONTROL";
    339         case IRP_MJ_DEVICE_CHANGE:
    340             return "IRP_MJ_DEVICE_CHANGE";
    341         case IRP_MJ_QUERY_QUOTA:
    342             return "IRP_MJ_QUERY_QUOTA";
    343         case IRP_MJ_SET_QUOTA:
    344             return "IRP_MJ_SET_QUOTA";
     287        RT_CASE_RET_STR(IRP_MJ_CREATE);
     288        RT_CASE_RET_STR(IRP_MJ_CREATE_NAMED_PIPE);
     289        RT_CASE_RET_STR(IRP_MJ_CLOSE);
     290        RT_CASE_RET_STR(IRP_MJ_READ);
     291        RT_CASE_RET_STR(IRP_MJ_WRITE);
     292        RT_CASE_RET_STR(IRP_MJ_QUERY_INFORMATION);
     293        RT_CASE_RET_STR(IRP_MJ_SET_INFORMATION);
     294        RT_CASE_RET_STR(IRP_MJ_QUERY_EA);
     295        RT_CASE_RET_STR(IRP_MJ_SET_EA);
     296        RT_CASE_RET_STR(IRP_MJ_FLUSH_BUFFERS);
     297        RT_CASE_RET_STR(IRP_MJ_QUERY_VOLUME_INFORMATION);
     298        RT_CASE_RET_STR(IRP_MJ_SET_VOLUME_INFORMATION);
     299        RT_CASE_RET_STR(IRP_MJ_DIRECTORY_CONTROL);
     300        RT_CASE_RET_STR(IRP_MJ_FILE_SYSTEM_CONTROL);
     301        RT_CASE_RET_STR(IRP_MJ_DEVICE_CONTROL);
     302        RT_CASE_RET_STR(IRP_MJ_INTERNAL_DEVICE_CONTROL);
     303        RT_CASE_RET_STR(IRP_MJ_SHUTDOWN);
     304        RT_CASE_RET_STR(IRP_MJ_LOCK_CONTROL);
     305        RT_CASE_RET_STR(IRP_MJ_CLEANUP);
     306        RT_CASE_RET_STR(IRP_MJ_CREATE_MAILSLOT);
     307        RT_CASE_RET_STR(IRP_MJ_QUERY_SECURITY);
     308        RT_CASE_RET_STR(IRP_MJ_SET_SECURITY);
     309        RT_CASE_RET_STR(IRP_MJ_POWER);
     310        RT_CASE_RET_STR(IRP_MJ_SYSTEM_CONTROL);
     311        RT_CASE_RET_STR(IRP_MJ_DEVICE_CHANGE);
     312        RT_CASE_RET_STR(IRP_MJ_QUERY_QUOTA);
     313        RT_CASE_RET_STR(IRP_MJ_SET_QUOTA);
    345314        case IRP_MJ_PNP:
    346             return PnPMinorFunctionString(MinorFunction);
    347 
     315            return vbsfNtMinorPnpFunctionName(MinorFunction);
    348316        default:
    349             return "unknown_pnp_irp";
     317            return "IRP_MJ_UNKNOWN";
    350318    }
    351319}
     
    353321#endif /* DEBUG || LOG_ENABLED */
    354322
    355 /** Allocate and initialize a SHFLSTRING from a UNICODE string.
    356  *
    357  *  @param ppShflString Where to store the pointer to the allocated SHFLSTRING structure.
    358  *                      The structure must be deallocated with vbsfFreeNonPagedMem.
    359  *  @param pwc          The UNICODE string. If NULL then SHFL is only allocated.
    360  *  @param cb           Size of the UNICODE string in bytes without the trailing nul.
    361  *
    362  *  @return Status code.
    363  */
    364 NTSTATUS vbsfShflStringFromUnicodeAlloc(PSHFLSTRING *ppShflString, const WCHAR *pwc, uint16_t cb)
    365 {
    366     NTSTATUS Status = STATUS_SUCCESS;
    367 
    368     PSHFLSTRING pShflString;
    369     ULONG cbShflString;
    370 
    371     /* Calculate length required for the SHFL structure: header + chars + nul. */
    372     cbShflString = SHFLSTRING_HEADER_SIZE + cb + sizeof(WCHAR);
    373     pShflString = (PSHFLSTRING)vbsfAllocNonPagedMem(cbShflString);
    374     if (pShflString)
    375     {
    376         if (ShflStringInitBuffer(pShflString, cbShflString))
    377         {
    378             if (pwc)
    379             {
    380                 RtlCopyMemory(pShflString->String.ucs2, pwc, cb);
    381                 pShflString->String.ucs2[cb / sizeof(WCHAR)] = 0;
    382                 pShflString->u16Length = cb; /* without terminating null */
    383                 AssertMsg(pShflString->u16Length + sizeof(WCHAR) == pShflString->u16Size,
    384                           ("u16Length %d, u16Size %d\n", pShflString->u16Length, pShflString->u16Size));
    385             }
    386             else
    387             {
    388                 /** @todo r=bird: vbsfAllocNonPagedMem already zero'ed it...   */
    389                 RtlZeroMemory(pShflString->String.ucs2, cb + sizeof(WCHAR));
    390                 pShflString->u16Length = 0; /* without terminating null */
    391                 AssertMsg(pShflString->u16Size >= sizeof(WCHAR),
    392                           ("u16Size %d\n", pShflString->u16Size));
    393             }
    394 
    395             *ppShflString = pShflString;
    396         }
    397         else
    398         {
    399             vbsfFreeNonPagedMem(pShflString);
    400             Status = STATUS_INSUFFICIENT_RESOURCES;
    401         }
    402     }
    403     else
    404     {
    405         Status = STATUS_INSUFFICIENT_RESOURCES;
    406     }
    407 
    408     return Status;
    409 }
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