VirtualBox

vbox的更動 63082 路徑 trunk/src/VBox/Additions


忽略:
時間撮記:
2016-8-6 下午02:00:14 (8 年 以前)
作者:
vboxsync
訊息:

vboxmrxnp.cpp: drop the obsolete 'lp' HN prefix where we can.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Additions/WINNT/SharedFolders/np/vboxmrxnp.cpp

    r63081 r63082  
    170170}
    171171
    172 DWORD APIENTRY NPLogonNotify(PLUID lpLogonId,
    173                              LPCWSTR lpAuthentInfoType,
    174                              LPVOID lpAuthentInfo,
    175                              LPCWSTR lpPreviousAuthentInfoType,
    176                              LPVOID lpPreviousAuthentInfo,
    177                              LPWSTR lpStationName,
     172DWORD APIENTRY NPLogonNotify(PLUID pLogonId,
     173                             LPCWSTR pAuthentInfoType,
     174                             LPVOID pAuthentInfo,
     175                             LPCWSTR pPreviousAuthentInfoType,
     176                             LPVOID pPreviousAuthentInfo,
     177                             LPWSTR pStationName,
    178178                             LPVOID StationHandle,
    179                              LPWSTR *lpLogonScript)
     179                             LPWSTR *pLogonScript)
    180180{
    181181    Log(("VBOXNP: NPLogonNotify\n"));
    182     *lpLogonScript = NULL;
     182    *pLogonScript = NULL;
    183183    return WN_SUCCESS;
    184184}
    185185
    186 DWORD APIENTRY NPPasswordChangeNotify(LPCWSTR lpAuthentInfoType,
    187                                       LPVOID lpAuthentInfo,
    188                                       LPCWSTR lpPreviousAuthentInfoType,
    189                                       LPVOID lpPreviousAuthentInfo,
    190                                       LPWSTR lpStationName,
     186DWORD APIENTRY NPPasswordChangeNotify(LPCWSTR pAuthentInfoType,
     187                                      LPVOID pAuthentInfo,
     188                                      LPCWSTR pPreviousAuthentInfoType,
     189                                      LPVOID pPreviousAuthentInfo,
     190                                      LPWSTR pStationName,
    191191                                      LPVOID StationHandle,
    192192                                      DWORD dwChangeInfo)
     
    198198}
    199199
    200 DWORD APIENTRY NPAddConnection(LPNETRESOURCE lpNetResource,
    201                                LPWSTR lpPassword,
    202                                LPWSTR lpUserName)
     200DWORD APIENTRY NPAddConnection(LPNETRESOURCE pNetResource,
     201                               LPWSTR pPassword,
     202                               LPWSTR pUserName)
    203203{
    204204    Log(("VBOXNP: NPAddConnection\n"));
    205     return NPAddConnection3(NULL, lpNetResource, lpPassword, lpUserName, 0);
     205    return NPAddConnection3(NULL, pNetResource, pPassword, pUserName, 0);
    206206}
    207207
    208208DWORD APIENTRY NPAddConnection3(HWND hwndOwner,
    209                                 LPNETRESOURCE lpNetResource,
    210                                 LPWSTR lpPassword,
    211                                 LPWSTR lpUserName,
     209                                LPNETRESOURCE pNetResource,
     210                                LPWSTR pPassword,
     211                                LPWSTR pUserName,
    212212                                DWORD dwFlags)
    213213{
     
    218218
    219219    Log(("VBOXNP: NPAddConnection3: dwFlags = 0x%x\n", dwFlags));
    220     Log(("VBOXNP: NPAddConnection3: Local Name:  %ls\n", lpNetResource->lpLocalName ));
    221     Log(("VBOXNP: NPAddConnection3: Remote Name: %ls\n", lpNetResource->lpRemoteName ));
    222 
    223     if (   lpNetResource->dwType != RESOURCETYPE_DISK
    224         && lpNetResource->dwType != RESOURCETYPE_ANY)
    225     {
    226         Log(("VBOXNP: NPAddConnection3: Incorrect net resource type %d\n", lpNetResource->dwType));
     220    Log(("VBOXNP: NPAddConnection3: Local Name:  %ls\n", pNetResource->lpLocalName ));
     221    Log(("VBOXNP: NPAddConnection3: Remote Name: %ls\n", pNetResource->lpRemoteName ));
     222
     223    if (   pNetResource->dwType != RESOURCETYPE_DISK
     224        && pNetResource->dwType != RESOURCETYPE_ANY)
     225    {
     226        Log(("VBOXNP: NPAddConnection3: Incorrect net resource type %d\n", pNetResource->dwType));
    227227        return WN_BAD_NETNAME;
    228228    }
     
    233233    lstrcat(ConnectionName, L"\\;");
    234234
    235     if (lpNetResource->lpLocalName == NULL)
     235    if (pNetResource->lpLocalName == NULL)
    236236    {
    237237        LocalName[0] = L'\0';
     
    240240    else
    241241    {
    242         if (   lpNetResource->lpLocalName[0]
    243             && lpNetResource->lpLocalName[1] == L':')
    244         {
    245             LocalName[0] = vboxToUpper(lpNetResource->lpLocalName[0]);
     242        if (   pNetResource->lpLocalName[0]
     243            && pNetResource->lpLocalName[1] == L':')
     244        {
     245            LocalName[0] = vboxToUpper(pNetResource->lpLocalName[0]);
    246246            LocalName[1] = L':';
    247247            LocalName[2] = L'\0';
     
    259259    {
    260260        /* Append the remote name. */
    261         if (   lpNetResource->lpRemoteName
    262             && lpNetResource->lpRemoteName[0] == L'\\'
    263             && lpNetResource->lpRemoteName[1] == L'\\' )
     261        if (   pNetResource->lpRemoteName
     262            && pNetResource->lpRemoteName[0] == L'\\'
     263            && pNetResource->lpRemoteName[1] == L'\\' )
    264264        {
    265265            /* No need for (lstrlen + 1), because 'lpNetResource->lpRemoteName' leading \ is not copied. */
    266             if (lstrlen(ConnectionName) + lstrlen(lpNetResource->lpRemoteName) <= sizeof(ConnectionName) / sizeof(WCHAR))
    267             {
    268                 lstrcat(ConnectionName, &lpNetResource->lpRemoteName[1]);
     266            if (lstrlen(ConnectionName) + lstrlen(pNetResource->lpRemoteName) <= sizeof(ConnectionName) / sizeof(WCHAR))
     267            {
     268                lstrcat(ConnectionName, &pNetResource->lpRemoteName[1]);
    269269            }
    270270            else
     
    310310                    if (   fLocalName
    311311                        && !DefineDosDevice(DDD_RAW_TARGET_PATH | DDD_NO_BROADCAST_SYSTEM,
    312                                             lpNetResource->lpLocalName,
     312                                            pNetResource->lpLocalName,
    313313                                            ConnectionName))
    314314                    {
     
    333333}
    334334
    335 DWORD APIENTRY NPCancelConnection(LPWSTR lpName,
     335DWORD APIENTRY NPCancelConnection(LPWSTR pName,
    336336                                  BOOL fForce)
    337337{
     
    339339
    340340    Log(("VBOXNP: NPCancelConnection: Name = %ls\n",
    341          lpName));
    342 
    343     if (lpName && lpName[0] != 0)
     341         pName));
     342
     343    if (pName && pName[0] != 0)
    344344    {
    345345        WCHAR ConnectionName[256];
    346346
    347         if (lpName[1] == L':')
     347        if (pName[1] == L':')
    348348        {
    349349            WCHAR RemoteName[128];
    350350            WCHAR LocalName[3];
    351351
    352             LocalName[0] = vboxToUpper(lpName[0]);
     352            LocalName[0] = vboxToUpper(pName[0]);
    353353            LocalName[1] = L':';
    354354            LocalName[2] = L'\0';
     
    404404            BOOLEAN Verifier;
    405405
    406             Verifier  = ( lpName[0] == L'\\' );
    407             Verifier &= ( lpName[1] == L'V' ) || ( lpName[1] == L'v' );
    408             Verifier &= ( lpName[2] == L'B' ) || ( lpName[2] == L'b' );
    409             Verifier &= ( lpName[3] == L'O' ) || ( lpName[3] == L'o' );
    410             Verifier &= ( lpName[4] == L'X' ) || ( lpName[4] == L'x' );
    411             Verifier &= ( lpName[5] == L'S' ) || ( lpName[5] == L's' );
     406            Verifier  = ( pName[0] == L'\\' );
     407            Verifier &= ( pName[1] == L'V' ) || ( pName[1] == L'v' );
     408            Verifier &= ( pName[2] == L'B' ) || ( pName[2] == L'b' );
     409            Verifier &= ( pName[3] == L'O' ) || ( pName[3] == L'o' );
     410            Verifier &= ( pName[4] == L'X' ) || ( pName[4] == L'x' );
     411            Verifier &= ( pName[5] == L'S' ) || ( pName[5] == L's' );
    412412            /* Both vboxsvr & vboxsrv are now accepted */
    413             if (( lpName[6] == L'V' ) || ( lpName[6] == L'v'))
    414             {
    415                 Verifier &= ( lpName[6] == L'V' ) || ( lpName[6] == L'v' );
    416                 Verifier &= ( lpName[7] == L'R' ) || ( lpName[7] == L'r' );
     413            if (( pName[6] == L'V' ) || ( pName[6] == L'v'))
     414            {
     415                Verifier &= ( pName[6] == L'V' ) || ( pName[6] == L'v' );
     416                Verifier &= ( pName[7] == L'R' ) || ( pName[7] == L'r' );
    417417            }
    418418            else
    419419            {
    420                 Verifier &= ( lpName[6] == L'R' ) || ( lpName[6] == L'r' );
    421                 Verifier &= ( lpName[7] == L'V' ) || ( lpName[7] == L'v' );
    422             }
    423             Verifier &= ( lpName[8] == L'\\') || ( lpName[8] == 0 );
     420                Verifier &= ( pName[6] == L'R' ) || ( pName[6] == L'r' );
     421                Verifier &= ( pName[7] == L'V' ) || ( pName[7] == L'v' );
     422            }
     423            Verifier &= ( pName[8] == L'\\') || ( pName[8] == 0 );
    424424
    425425            if (Verifier)
    426426            {
    427427                /* Full remote path */
    428                 if (lstrlen(DD_MRX_VBOX_FS_DEVICE_NAME_U) + 2 + lstrlen(lpName) + 1 > sizeof(ConnectionName) / sizeof(WCHAR))
     428                if (lstrlen(DD_MRX_VBOX_FS_DEVICE_NAME_U) + 2 + lstrlen(pName) + 1 > sizeof(ConnectionName) / sizeof(WCHAR))
    429429                {
    430430                    dwStatus = WN_BAD_NETNAME;
     
    434434                    lstrcpy(ConnectionName, DD_MRX_VBOX_FS_DEVICE_NAME_U);
    435435                    lstrcat(ConnectionName, L"\\;");
    436                     lstrcat(ConnectionName, lpName);
     436                    lstrcat(ConnectionName, pName);
    437437
    438438                    dwStatus = vbsfIOCTL(IOCTL_MRX_VBOX_DELCONN,
     
    455455}
    456456
    457 DWORD APIENTRY NPGetConnection(LPWSTR lpLocalName,
    458                                LPWSTR lpRemoteName,
    459                                LPDWORD lpBufferSize)
     457DWORD APIENTRY NPGetConnection(LPWSTR pLocalName,
     458                               LPWSTR pRemoteName,
     459                               LPDWORD pBufferSize)
    460460{
    461461    DWORD dwStatus = WN_NOT_CONNECTED;
     
    464464    ULONG cbOut = 0;
    465465
    466     Log(("VBOXNP: NPGetConnection: lpLocalName = %ls\n",
    467          lpLocalName));
    468 
    469     if (lpLocalName && lpLocalName[0] != 0)
    470     {
    471         if (lpLocalName[1] == L':')
     466    Log(("VBOXNP: NPGetConnection: pLocalName = %ls\n",
     467         pLocalName));
     468
     469    if (pLocalName && pLocalName[0] != 0)
     470    {
     471        if (pLocalName[1] == L':')
    472472        {
    473473            WCHAR LocalName[3];
     
    476476            RemoteName[cbOut / sizeof(WCHAR)] = 0;
    477477
    478             LocalName[0] = vboxToUpper(lpLocalName[0]);
     478            LocalName[0] = vboxToUpper(pLocalName[0]);
    479479            LocalName[1] = L':';
    480480            LocalName[2] = L'\0';
     
    488488            if (dwStatus != NO_ERROR)
    489489            {
    490                 /* The device specified by lpLocalName is not redirected by this provider. */
     490                /* The device specified by pLocalName is not redirected by this provider. */
    491491                dwStatus = WN_NOT_CONNECTED;
    492492            }
     
    512512        DWORD len = sizeof(WCHAR) + cbRemoteName; /* Including the leading '\'. */
    513513
    514         if (*lpBufferSize >= len)
    515         {
    516             lpRemoteName[0] = L'\\';
    517             CopyMemory(&lpRemoteName[1], RemoteName, cbRemoteName);
    518 
    519             Log(("VBOXNP: NPGetConnection: returning lpRemoteName: %ls\n",
    520                  lpRemoteName));
     514        if (*pBufferSize >= len)
     515        {
     516            pRemoteName[0] = L'\\';
     517            CopyMemory(&pRemoteName[1], RemoteName, cbRemoteName);
     518
     519            Log(("VBOXNP: NPGetConnection: returning pRemoteName: %ls\n",
     520                 pRemoteName));
    521521        }
    522522        else
    523523        {
    524             if (*lpBufferSize != 0)
     524            if (*pBufferSize != 0)
    525525            {
    526526                /* Log only real errors. Do not log a 0 bytes try. */
    527                 Log(("VBOXNP: NPGetConnection: Buffer overflow: *lpBufferSize = %d, len = %d\n",
    528                      *lpBufferSize, len));
     527                Log(("VBOXNP: NPGetConnection: Buffer overflow: *pBufferSize = %d, len = %d\n",
     528                     *pBufferSize, len));
    529529            }
    530530
     
    532532        }
    533533
    534         *lpBufferSize = len;
     534        *pBufferSize = len;
    535535    }
    536536
     
    545545}
    546546
    547 static const WCHAR *vboxSkipServerPrefix(const WCHAR *lpRemoteName, const WCHAR *lpPrefix)
    548 {
    549     while (*lpPrefix)
    550     {
    551         if (vboxToUpper(*lpPrefix) != vboxToUpper(*lpRemoteName))
     547static const WCHAR *vboxSkipServerPrefix(const WCHAR *pRemoteName, const WCHAR *pPrefix)
     548{
     549    while (*pPrefix)
     550    {
     551        if (vboxToUpper(*pPrefix) != vboxToUpper(*pRemoteName))
    552552        {
    553553            /* Not a prefix */
     
    555555        }
    556556
    557         lpPrefix++;
    558         lpRemoteName++;
    559     }
    560 
    561     return lpRemoteName;
    562 }
    563 
    564 static const WCHAR *vboxSkipServerName(const WCHAR *lpRemoteName)
     557        pPrefix++;
     558        pRemoteName++;
     559    }
     560
     561    return pRemoteName;
     562}
     563
     564static const WCHAR *vboxSkipServerName(const WCHAR *pRemoteName)
    565565{
    566566    int cLeadingBackslashes = 0;
    567     while (*lpRemoteName == L'\\')
    568     {
    569         lpRemoteName++;
     567    while (*pRemoteName == L'\\')
     568    {
     569        pRemoteName++;
    570570        cLeadingBackslashes++;
    571571    }
     
    573573    if (cLeadingBackslashes == 0 || cLeadingBackslashes == 2)
    574574    {
    575         const WCHAR *lpAfterPrefix = vboxSkipServerPrefix(lpRemoteName, MRX_VBOX_SERVER_NAME_U);
    576 
    577         if (!lpAfterPrefix)
    578         {
    579             lpAfterPrefix = vboxSkipServerPrefix(lpRemoteName, MRX_VBOX_SERVER_NAME_ALT_U);
    580         }
    581 
    582         return lpAfterPrefix;
     575        const WCHAR *pAfterPrefix = vboxSkipServerPrefix(pRemoteName, MRX_VBOX_SERVER_NAME_U);
     576
     577        if (!pAfterPrefix)
     578        {
     579            pAfterPrefix = vboxSkipServerPrefix(pRemoteName, MRX_VBOX_SERVER_NAME_ALT_U);
     580        }
     581
     582        return pAfterPrefix;
    583583    }
    584584
     
    605605                          DWORD dwType,
    606606                          DWORD dwUsage,
    607                           LPNETRESOURCE lpNetResource,
     607                          LPNETRESOURCE pNetResource,
    608608                          LPHANDLE lphEnum)
    609609{
    610610    DWORD dwStatus;
    611611
    612     Log(("VBOXNP: NPOpenEnum: dwScope 0x%08X, dwType 0x%08X, dwUsage 0x%08X, lpNetResource %p\n",
    613          dwScope, dwType, dwUsage, lpNetResource));
     612    Log(("VBOXNP: NPOpenEnum: dwScope 0x%08X, dwType 0x%08X, dwUsage 0x%08X, pNetResource %p\n",
     613         dwScope, dwType, dwUsage, pNetResource));
    614614
    615615    if (dwUsage == 0)
     
    630630    else
    631631    {
    632         if (lpNetResource && lpNetResource->lpRemoteName)
    633         {
    634             Log(("VBOXNP: NPOpenEnum: lpRemoteName %ls\n",
    635                  lpNetResource->lpRemoteName));
     632        if (pNetResource && pNetResource->lpRemoteName)
     633        {
     634            Log(("VBOXNP: NPOpenEnum: pRemoteName %ls\n",
     635                 pNetResource->lpRemoteName));
    636636        }
    637637
     
    642642                     */
    643643            {
    644                 if (lpNetResource == NULL || lpNetResource->lpRemoteName == NULL)
     644                if (pNetResource == NULL || pNetResource->lpRemoteName == NULL)
    645645                {
    646                     /* If it is NULL or if the lpRemoteName field of the NETRESOURCE is NULL,
     646                    /* If it is NULL or if the pRemoteName field of the NETRESOURCE is NULL,
    647647                     * the provider should enumerate the top level of its network.
    648648                     * But system shares can't be on top level.
     
    652652                }
    653653
    654                 const WCHAR *lpAfterName = vboxSkipServerName(lpNetResource->lpRemoteName);
    655                 if (   lpAfterName == NULL
    656                     || (*lpAfterName != L'\\' && *lpAfterName != 0))
     654                const WCHAR *pAfterName = vboxSkipServerName(pNetResource->lpRemoteName);
     655                if (   pAfterName == NULL
     656                    || (*pAfterName != L'\\' && *pAfterName != 0))
    657657                {
    658658                    dwStatus = WN_NOT_CONTAINER;
     
    673673            case RESOURCE_GLOBALNET: /* All resources on the network. */
    674674            {
    675                 if (lpNetResource == NULL || lpNetResource->lpRemoteName == NULL)
     675                if (pNetResource == NULL || pNetResource->lpRemoteName == NULL)
    676676                {
    677                     /* If it is NULL or if the lpRemoteName field of the NETRESOURCE is NULL,
     677                    /* If it is NULL or if the pRemoteName field of the NETRESOURCE is NULL,
    678678                     * the provider should enumerate the top level of its network.
    679679                     */
     
    682682                else
    683683                {
    684                     /* Enumerate lpNetResource->lpRemoteName container, which can be only the VBOXSVR container. */
    685                     const WCHAR *lpAfterName = vboxSkipServerName(lpNetResource->lpRemoteName);
    686                     if (   lpAfterName == NULL
    687                         || (*lpAfterName != L'\\' && *lpAfterName != 0))
     684                    /* Enumerate pNetResource->lpRemoteName container, which can be only the VBOXSVR container. */
     685                    const WCHAR *pAfterName = vboxSkipServerName(pNetResource->lpRemoteName);
     686                    if (   pAfterName == NULL
     687                        || (*pAfterName != L'\\' && *pAfterName != 0))
    688688                    {
    689689                        dwStatus = WN_NOT_CONTAINER;
     
    748748DWORD APIENTRY NPEnumResource(HANDLE hEnum,
    749749                              LPDWORD lpcCount,
    750                               LPVOID lpBuffer,
    751                               LPDWORD lpBufferSize)
     750                              LPVOID pBuffer,
     751                              LPDWORD pBufferSize)
    752752{
    753753    DWORD dwStatus = WN_SUCCESS;
     
    762762    ULONG cbEntry = 0;
    763763
    764     Log(("VBOXNP: NPEnumResource: hEnum %p, lpcCount %p, lpBuffer %p, lpBufferSize %p.\n",
    765          hEnum, lpcCount, lpBuffer, lpBufferSize));
     764    Log(("VBOXNP: NPEnumResource: hEnum %p, lpcCount %p, pBuffer %p, pBufferSize %p.\n",
     765         hEnum, lpcCount, pBuffer, pBufferSize));
    766766
    767767    if (pCtx == NULL)
     
    771771    }
    772772
    773     if (lpcCount == NULL || lpBuffer == NULL)
     773    if (lpcCount == NULL || pBuffer == NULL)
    774774    {
    775775        Log(("VBOXNP: NPEnumResource: WN_BAD_VALUE\n"));
     
    777777    }
    778778
    779     Log(("VBOXNP: NPEnumResource: *lpcCount 0x%x, *lpBufferSize 0x%x, pCtx->index %d\n",
    780          *lpcCount, *lpBufferSize, pCtx->index));
    781 
    782     LPNETRESOURCE pNetResource = (LPNETRESOURCE)lpBuffer;
    783     ULONG cbRemaining = *lpBufferSize;
     779    Log(("VBOXNP: NPEnumResource: *lpcCount 0x%x, *pBufferSize 0x%x, pCtx->index %d\n",
     780         *lpcCount, *pBufferSize, pCtx->index));
     781
     782    LPNETRESOURCE pNetResource = (LPNETRESOURCE)pBuffer;
     783    ULONG cbRemaining = *pBufferSize;
    784784    ULONG cEntriesCopied = 0;
    785     PWCHAR pStrings = (PWCHAR)((PBYTE)lpBuffer + *lpBufferSize);
     785    PWCHAR pStrings = (PWCHAR)((PBYTE)pBuffer + *pBufferSize);
    786786    PWCHAR pDst;
    787787
     
    862862                    CopyMemory(pDst, MRX_VBOX_PROVIDER_NAME_U, sizeof(MRX_VBOX_PROVIDER_NAME_U));
    863863
    864                     Log(("VBOXNP: NPEnumResource: lpRemoteName: %ls\n",
     864                    Log(("VBOXNP: NPEnumResource: pRemoteName: %ls\n",
    865865                         pNetResource->lpRemoteName));
    866866
     
    10071007                        CopyMemory(pDst, MRX_VBOX_PROVIDER_NAME_U, sizeof(MRX_VBOX_PROVIDER_NAME_U));
    10081008
    1009                         Log(("VBOXNP: NPEnumResource: lpRemoteName: %ls\n",
     1009                        Log(("VBOXNP: NPEnumResource: pRemoteName: %ls\n",
    10101010                             pNetResource->lpRemoteName));
    10111011
     
    10471047            Log(("VBOXNP: NPEnumResource: More Data Needed - %d\n",
    10481048                 cbEntry));
    1049             *lpBufferSize = cbEntry;
     1049            *pBufferSize = cbEntry;
    10501050            dwStatus = WN_MORE_DATA;
    10511051        }
     
    10741074}
    10751075
    1076 DWORD APIENTRY NPGetResourceParent(LPNETRESOURCE lpNetResource,
    1077                                    LPVOID lpBuffer,
    1078                                    LPDWORD lpBufferSize)
    1079 {
    1080     Log(("VBOXNP: NPGetResourceParent: lpNetResource %p, lpBuffer %p, lpBufferSize %p\n",
    1081          lpNetResource, lpBuffer, lpBufferSize));
    1082 
    1083     /* Construct a new NETRESOURCE which is syntactically a parent of lpNetResource,
     1076DWORD APIENTRY NPGetResourceParent(LPNETRESOURCE pNetResource,
     1077                                   LPVOID pBuffer,
     1078                                   LPDWORD pBufferSize)
     1079{
     1080    Log(("VBOXNP: NPGetResourceParent: pNetResource %p, pBuffer %p, pBufferSize %p\n",
     1081         pNetResource, pBuffer, pBufferSize));
     1082
     1083    /* Construct a new NETRESOURCE which is syntactically a parent of pNetResource,
    10841084     * then call NPGetResourceInformation to actually fill the buffer.
    10851085     */
    1086     if (!lpNetResource || !lpNetResource->lpRemoteName || !lpBufferSize)
     1086    if (!pNetResource || !pNetResource->lpRemoteName || !pBufferSize)
    10871087    {
    10881088        return WN_BAD_NETNAME;
    10891089    }
    10901090
    1091     const WCHAR *lpAfterName = vboxSkipServerName(lpNetResource->lpRemoteName);
    1092     if (   lpAfterName == NULL
    1093         || (*lpAfterName != L'\\' && *lpAfterName != 0))
     1091    const WCHAR *pAfterName = vboxSkipServerName(pNetResource->lpRemoteName);
     1092    if (   pAfterName == NULL
     1093        || (*pAfterName != L'\\' && *pAfterName != 0))
    10941094    {
    10951095        Log(("VBOXNP: NPGetResourceParent: WN_BAD_NETNAME\n"));
     
    10971097    }
    10981098
    1099     DWORD RemoteNameLength = lstrlen(lpNetResource->lpRemoteName);
     1099    DWORD RemoteNameLength = lstrlen(pNetResource->lpRemoteName);
    11001100
    11011101    DWORD cbEntry = sizeof (NETRESOURCE);
     
    11101110
    11111111    pParent->lpRemoteName = (WCHAR *)((PBYTE)pParent + sizeof (NETRESOURCE));
    1112     lstrcpy(pParent->lpRemoteName, lpNetResource->lpRemoteName);
     1112    lstrcpy(pParent->lpRemoteName, pNetResource->lpRemoteName);
    11131113
    11141114    /* Remove last path component of the pParent->lpRemoteName. */
     
    11361136    {
    11371137        /* It is a leading backslash. Construct "no parent" NETRESOURCE. */
    1138         NETRESOURCE *pNetResource = (NETRESOURCE *)lpBuffer;
     1138        NETRESOURCE *pNetResource = (NETRESOURCE *)pBuffer;
    11391139
    11401140        cbEntry = sizeof(NETRESOURCE);
     
    11421142        cbEntry += sizeof(MRX_VBOX_PROVIDER_NAME_U); /* provider name */
    11431143
    1144         if (cbEntry > *lpBufferSize)
     1144        if (cbEntry > *pBufferSize)
    11451145        {
    11461146            Log(("VBOXNP: NPGetResourceParent: WN_MORE_DATA 0x%x\n", cbEntry));
    1147             *lpBufferSize = cbEntry;
     1147            *pBufferSize = cbEntry;
    11481148            dwStatus = WN_MORE_DATA;
    11491149        }
     
    11561156            pNetResource->dwUsage = RESOURCEUSAGE_CONTAINER;
    11571157
    1158             WCHAR *pStrings = (WCHAR *)((PBYTE)lpBuffer + *lpBufferSize);
     1158            WCHAR *pStrings = (WCHAR *)((PBYTE)pBuffer + *pBufferSize);
    11591159            pStrings = (PWCHAR)((PBYTE)pStrings - (cbEntry - sizeof(NETRESOURCE)));
    11601160
     
    11681168
    11691169            Log(("VBOXNP: NPGetResourceParent: no parent, strings %p/%p\n",
    1170                  pStrings, (PBYTE)lpBuffer + *lpBufferSize));
     1170                 pStrings, (PBYTE)pBuffer + *pBufferSize));
    11711171        }
    11721172    }
     
    11761176        *pLastSlash = 0;
    11771177
    1178         LPWSTR lpSystem = NULL;
    1179         dwStatus = NPGetResourceInformation (pParent, lpBuffer, lpBufferSize, &lpSystem);
     1178        LPWSTR pSystem = NULL;
     1179        dwStatus = NPGetResourceInformation (pParent, pBuffer, pBufferSize, &pSystem);
    11801180    }
    11811181
     
    11881188}
    11891189
    1190 DWORD APIENTRY NPGetResourceInformation(LPNETRESOURCE lpNetResource,
    1191                                         LPVOID lpBuffer,
    1192                                         LPDWORD lpBufferSize,
     1190DWORD APIENTRY NPGetResourceInformation(LPNETRESOURCE pNetResource,
     1191                                        LPVOID pBuffer,
     1192                                        LPDWORD pBufferSize,
    11931193                                        LPWSTR *lplpSystem)
    11941194{
    1195     Log(("VBOXNP: NPGetResourceInformation: lpNetResource %p, lpBuffer %p, lpBufferSize %p, lplpSystem %p\n",
    1196          lpNetResource, lpBuffer, lpBufferSize, lplpSystem));
    1197 
    1198     if (   lpNetResource == NULL
    1199         || lpNetResource->lpRemoteName == NULL
    1200         || lpBufferSize == NULL)
     1195    Log(("VBOXNP: NPGetResourceInformation: pNetResource %p, pBuffer %p, pBufferSize %p, lplpSystem %p\n",
     1196         pNetResource, pBuffer, pBufferSize, lplpSystem));
     1197
     1198    if (   pNetResource == NULL
     1199        || pNetResource->lpRemoteName == NULL
     1200        || pBufferSize == NULL)
    12011201    {
    12021202        Log(("VBOXNP: NPGetResourceInformation: WN_BAD_VALUE\n"));
     
    12041204    }
    12051205
    1206     Log(("VBOXNP: NPGetResourceInformation: lpRemoteName %ls, *lpBufferSize 0x%x\n",
    1207          lpNetResource->lpRemoteName, *lpBufferSize));
    1208 
    1209     const WCHAR *lpAfterName = vboxSkipServerName(lpNetResource->lpRemoteName);
    1210     if (   lpAfterName == NULL
    1211         || (*lpAfterName != L'\\' && *lpAfterName != 0))
     1206    Log(("VBOXNP: NPGetResourceInformation: pRemoteName %ls, *pBufferSize 0x%x\n",
     1207         pNetResource->lpRemoteName, *pBufferSize));
     1208
     1209    const WCHAR *pAfterName = vboxSkipServerName(pNetResource->lpRemoteName);
     1210    if (   pAfterName == NULL
     1211        || (*pAfterName != L'\\' && *pAfterName != 0))
    12121212    {
    12131213        Log(("VBOXNP: NPGetResourceInformation: WN_BAD_NETNAME\n"));
     
    12151215    }
    12161216
    1217     if (lpNetResource->dwType != 0 && lpNetResource->dwType != RESOURCETYPE_DISK)
     1217    if (pNetResource->dwType != 0 && pNetResource->dwType != RESOURCETYPE_DISK)
    12181218    {
    12191219        /* The caller passed in a nonzero dwType that does not match
     
    12261226     * If the input remote resource name was "\\server\share\dir1\dir2",
    12271227     * then the output NETRESOURCE contains information about the resource "\\server\share".
    1228      * The lpRemoteName, lpProvider, dwType, dwDisplayType, and dwUsage fields are returned
     1228     * The pRemoteName, pProvider, dwType, dwDisplayType, and dwUsage fields are returned
    12291229     * containing values, all other fields being set to NULL.
    12301230     */
    12311231    DWORD cbEntry;
    1232     WCHAR *pStrings = (WCHAR *)((PBYTE)lpBuffer + *lpBufferSize);
    1233     NETRESOURCE *pNetResourceInfo = (NETRESOURCE *)lpBuffer;
     1232    WCHAR *pStrings = (WCHAR *)((PBYTE)pBuffer + *pBufferSize);
     1233    NETRESOURCE *pNetResourceInfo = (NETRESOURCE *)pBuffer;
    12341234
    12351235    /* Check what kind of the resource is that by parsing path components.
    1236      * lpAfterName points to first WCHAR after a valid server name.
     1236     * pAfterName points to first WCHAR after a valid server name.
    12371237     */
    12381238
    1239     if (lpAfterName[0] == 0 || lpAfterName[1] == 0)
     1239    if (pAfterName[0] == 0 || pAfterName[1] == 0)
    12401240    {
    12411241        /* "\\VBOXSVR" or "\\VBOXSVR\" */
     
    12441244        cbEntry += sizeof(MRX_VBOX_PROVIDER_NAME_U); /* provider name */
    12451245
    1246         if (cbEntry > *lpBufferSize)
     1246        if (cbEntry > *pBufferSize)
    12471247        {
    12481248            Log(("VBOXNP: NPGetResourceInformation: WN_MORE_DATA 0x%x\n", cbEntry));
    1249             *lpBufferSize = cbEntry;
     1249            *pBufferSize = cbEntry;
    12501250            return WN_MORE_DATA;
    12511251        }
     
    12691269        pStrings += sizeof(MRX_VBOX_PROVIDER_NAME_U) / sizeof(WCHAR);
    12701270
    1271         Log(("VBOXNP: NPGetResourceInformation: lpRemoteName: %ls, strings %p/%p\n",
    1272              pNetResourceInfo->lpRemoteName, pStrings, (PBYTE)lpBuffer + *lpBufferSize));
     1271        Log(("VBOXNP: NPGetResourceInformation: pRemoteName: %ls, strings %p/%p\n",
     1272             pNetResourceInfo->lpRemoteName, pStrings, (PBYTE)pBuffer + *pBufferSize));
    12731273
    12741274        if (lplpSystem)
     
    12801280    }
    12811281
    1282     /* *lpAfterName == L'\\', could be share or share + path.
     1282    /* *pAfterName == L'\\', could be share or share + path.
    12831283     * Check if there are more path components after the share name.
    12841284     */
    1285     const WCHAR *lp = lpAfterName + 1;
     1285    const WCHAR *lp = pAfterName + 1;
    12861286    while (*lp && *lp != L'\\')
    12871287    {
     
    12941294        cbEntry = sizeof(NETRESOURCE);
    12951295        cbEntry += 2 * sizeof(WCHAR) + sizeof(MRX_VBOX_SERVER_NAME_U); /* \\ + server name with trailing nul */
    1296         cbEntry += (DWORD)((lp - lpAfterName) * sizeof(WCHAR)); /* The share name with leading \\ */
     1296        cbEntry += (DWORD)((lp - pAfterName) * sizeof(WCHAR)); /* The share name with leading \\ */
    12971297        cbEntry += sizeof(MRX_VBOX_PROVIDER_NAME_U); /* provider name */
    12981298
    1299         if (cbEntry > *lpBufferSize)
     1299        if (cbEntry > *pBufferSize)
    13001300        {
    13011301            Log(("VBOXNP: NPGetResourceInformation: WN_MORE_DATA 0x%x\n", cbEntry));
    1302             *lpBufferSize = cbEntry;
     1302            *pBufferSize = cbEntry;
    13031303            return WN_MORE_DATA;
    13041304        }
     
    13171317        CopyMemory(pStrings, MRX_VBOX_SERVER_NAME_U, sizeof(MRX_VBOX_SERVER_NAME_U) - sizeof (WCHAR));
    13181318        pStrings += sizeof(MRX_VBOX_SERVER_NAME_U) / sizeof(WCHAR) - 1;
    1319         CopyMemory (pStrings, lpAfterName, (lp - lpAfterName + 1) * sizeof(WCHAR));
    1320         pStrings += lp - lpAfterName + 1;
     1319        CopyMemory (pStrings, pAfterName, (lp - pAfterName + 1) * sizeof(WCHAR));
     1320        pStrings += lp - pAfterName + 1;
    13211321
    13221322        pNetResourceInfo->lpProvider = pStrings;
     
    13241324        pStrings += sizeof(MRX_VBOX_PROVIDER_NAME_U) / sizeof(WCHAR);
    13251325
    1326         Log(("VBOXNP: NPGetResourceInformation: lpRemoteName: %ls, strings %p/%p\n",
    1327              pNetResourceInfo->lpRemoteName, pStrings, (PBYTE)lpBuffer + *lpBufferSize));
     1326        Log(("VBOXNP: NPGetResourceInformation: pRemoteName: %ls, strings %p/%p\n",
     1327             pNetResourceInfo->lpRemoteName, pStrings, (PBYTE)pBuffer + *pBufferSize));
    13281328
    13291329        if (lplpSystem)
     
    13381338    cbEntry = sizeof(NETRESOURCE);
    13391339    cbEntry += 2 * sizeof(WCHAR) + sizeof(MRX_VBOX_SERVER_NAME_U); /* \\ + server name with trailing nul */
    1340     cbEntry += (DWORD)((lp - lpAfterName) * sizeof(WCHAR)); /* The share name with leading \\ */
     1340    cbEntry += (DWORD)((lp - pAfterName) * sizeof(WCHAR)); /* The share name with leading \\ */
    13411341    cbEntry += sizeof(MRX_VBOX_PROVIDER_NAME_U); /* provider name */
    13421342    cbEntry += (lstrlen(lp) + 1) * sizeof (WCHAR); /* path string for lplpSystem */
    13431343
    1344     if (cbEntry > *lpBufferSize)
     1344    if (cbEntry > *pBufferSize)
    13451345    {
    13461346        Log(("VBOXNP: NPGetResourceInformation: WN_MORE_DATA 0x%x\n", cbEntry));
    1347         *lpBufferSize = cbEntry;
     1347        *pBufferSize = cbEntry;
    13481348        return WN_MORE_DATA;
    13491349    }
     
    13631363    CopyMemory (pStrings, MRX_VBOX_SERVER_NAME_U, sizeof(MRX_VBOX_SERVER_NAME_U) - sizeof (WCHAR));
    13641364    pStrings += sizeof(MRX_VBOX_SERVER_NAME_U) / sizeof(WCHAR) - 1;
    1365     CopyMemory(pStrings, lpAfterName, (lp - lpAfterName) * sizeof(WCHAR));
    1366     pStrings += lp - lpAfterName;
     1365    CopyMemory(pStrings, pAfterName, (lp - pAfterName) * sizeof(WCHAR));
     1366    pStrings += lp - pAfterName;
    13671367    *pStrings++ = 0;
    13681368
     
    13791379    pStrings += lstrlen(lp) + 1;
    13801380
    1381     Log(("VBOXNP: NPGetResourceInformation: lpRemoteName: %ls, strings %p/%p\n",
    1382          pNetResourceInfo->lpRemoteName, pStrings, (PBYTE)lpBuffer + *lpBufferSize));
     1381    Log(("VBOXNP: NPGetResourceInformation: pRemoteName: %ls, strings %p/%p\n",
     1382         pNetResourceInfo->lpRemoteName, pStrings, (PBYTE)pBuffer + *pBufferSize));
    13831383    Log(("VBOXNP: NPGetResourceInformation: *lplpSystem: %ls\n", *lplpSystem));
    13841384
     
    13861386}
    13871387
    1388 DWORD APIENTRY NPGetUniversalName(LPCWSTR lpLocalPath,
     1388DWORD APIENTRY NPGetUniversalName(LPCWSTR pLocalPath,
    13891389                                  DWORD dwInfoLevel,
    1390                                   LPVOID lpBuffer,
    1391                                   LPDWORD lpBufferSize)
     1390                                  LPVOID pBuffer,
     1391                                  LPDWORD pBufferSize)
    13921392{
    13931393    DWORD dwStatus;
     
    13991399    WCHAR LocalDrive[3];
    14001400
    1401     const WCHAR *lpRemainingPath;
    1402     WCHAR *lpString;
    1403 
    1404     Log(("VBOXNP: NPGetUniversalName: lpLocalPath = %ls, InfoLevel = %d, *lpBufferSize = %d\n",
    1405          lpLocalPath, dwInfoLevel, *lpBufferSize));
     1401    const WCHAR *pRemainingPath;
     1402    WCHAR *pString;
     1403
     1404    Log(("VBOXNP: NPGetUniversalName: pLocalPath = %ls, InfoLevel = %d, *pBufferSize = %d\n",
     1405         pLocalPath, dwInfoLevel, *pBufferSize));
    14061406
    14071407    /* Check is input parameter is OK. */
     
    14151415
    14161416    /* The 'lpLocalPath' is "X:\something". Extract the "X:" to pass to NPGetConnection. */
    1417     if (   lpLocalPath == NULL
    1418         || lpLocalPath[0] == 0
    1419         || lpLocalPath[1] != L':')
    1420     {
    1421         Log(("VBOXNP: NPGetUniversalName: Bad lpLocalPath.\n"));
     1417    if (   pLocalPath == NULL
     1418        || pLocalPath[0] == 0
     1419        || pLocalPath[1] != L':')
     1420    {
     1421        Log(("VBOXNP: NPGetUniversalName: Bad pLocalPath.\n"));
    14221422        return WN_BAD_LOCALNAME;
    14231423    }
    14241424
    1425     LocalDrive[0] = lpLocalPath[0];
    1426     LocalDrive[1] = lpLocalPath[1];
     1425    LocalDrive[0] = pLocalPath[0];
     1426    LocalDrive[1] = pLocalPath[1];
    14271427    LocalDrive[2] = 0;
    14281428
    14291429    /* Length of the original path without the driver letter, including trailing NULL. */
    1430     lpRemainingPath = &lpLocalPath[2];
    1431     RemainingPathLength = (DWORD)((wcslen(lpRemainingPath) + 1) * sizeof(WCHAR));
     1430    pRemainingPath = &pLocalPath[2];
     1431    RemainingPathLength = (DWORD)((wcslen(pRemainingPath) + 1) * sizeof(WCHAR));
    14321432
    14331433    /* Build the required structure in place of the supplied buffer. */
    14341434    if (dwInfoLevel == UNIVERSAL_NAME_INFO_LEVEL)
    14351435    {
    1436         LPUNIVERSAL_NAME_INFOW pUniversalNameInfo = (LPUNIVERSAL_NAME_INFOW)lpBuffer;
     1436        LPUNIVERSAL_NAME_INFOW pUniversalNameInfo = (LPUNIVERSAL_NAME_INFOW)pBuffer;
    14371437
    14381438        BufferRequired = sizeof (UNIVERSAL_NAME_INFOW);
    14391439
    1440         if (*lpBufferSize >= BufferRequired)
     1440        if (*pBufferSize >= BufferRequired)
    14411441        {
    14421442            /* Enough place for the structure. */
    1443             pUniversalNameInfo->lpUniversalName = (PWCHAR)((PBYTE)lpBuffer + sizeof(UNIVERSAL_NAME_INFOW));
     1443            pUniversalNameInfo->lpUniversalName = (PWCHAR)((PBYTE)pBuffer + sizeof(UNIVERSAL_NAME_INFOW));
    14441444
    14451445            /* At least so many bytes are available for obtaining the remote name. */
    1446             RemoteNameLength = *lpBufferSize - BufferRequired;
     1446            RemoteNameLength = *pBufferSize - BufferRequired;
    14471447        }
    14481448        else
     
    14791479        BufferRequired += RemainingPathLength;
    14801480
    1481         if (*lpBufferSize < BufferRequired)
     1481        if (*pBufferSize < BufferRequired)
    14821482        {
    14831483            Log(("VBOXNP: NPGetUniversalName: WN_MORE_DATA BufferRequired: %d\n",
    14841484                 BufferRequired));
    1485             *lpBufferSize = BufferRequired;
     1485            *pBufferSize = BufferRequired;
    14861486            return WN_MORE_DATA;
    14871487        }
    14881488
    14891489        /* Enough memory in the buffer. Add '\' and remaining path to the remote name. */
    1490         lpString = &pUniversalNameInfo->lpUniversalName[RemoteNameLength / sizeof (WCHAR)];
    1491         lpString--; /* Trailing NULL */
    1492 
    1493         CopyMemory(lpString, lpRemainingPath, RemainingPathLength);
     1490        pString = &pUniversalNameInfo->lpUniversalName[RemoteNameLength / sizeof (WCHAR)];
     1491        pString--; /* Trailing NULL */
     1492
     1493        CopyMemory(pString, pRemainingPath, RemainingPathLength);
    14941494    }
    14951495    else
    14961496    {
    1497         LPREMOTE_NAME_INFOW pRemoteNameInfo = (LPREMOTE_NAME_INFOW)lpBuffer;
    1498         WCHAR *lpDelimiter;
     1497        LPREMOTE_NAME_INFOW pRemoteNameInfo = (LPREMOTE_NAME_INFOW)pBuffer;
     1498        WCHAR *pDelimiter;
    14991499
    15001500        BufferRequired = sizeof (REMOTE_NAME_INFOW);
    15011501
    1502         if (*lpBufferSize >= BufferRequired)
     1502        if (*pBufferSize >= BufferRequired)
    15031503        {
    15041504            /* Enough place for the structure. */
    1505             pRemoteNameInfo->lpUniversalName = (PWCHAR)((PBYTE)lpBuffer + sizeof(REMOTE_NAME_INFOW));
     1505            pRemoteNameInfo->lpUniversalName = (PWCHAR)((PBYTE)pBuffer + sizeof(REMOTE_NAME_INFOW));
    15061506            pRemoteNameInfo->lpConnectionName = NULL;
    15071507            pRemoteNameInfo->lpRemainingPath = NULL;
    15081508
    15091509            /* At least so many bytes are available for obtaining the remote name. */
    1510             RemoteNameLength = *lpBufferSize - BufferRequired;
     1510            RemoteNameLength = *pBufferSize - BufferRequired;
    15111511        }
    15121512        else
     
    15401540        BufferRequired += RemainingPathLength;
    15411541
    1542         /* lpConnectionName, which is the remote name. */
     1542        /* pConnectionName, which is the remote name. */
    15431543        BufferRequired += RemoteNameLength;
    15441544
    1545         /* lpRemainingPath. */
     1545        /* pRemainingPath. */
    15461546        BufferRequired += RemainingPathLength;
    15471547
    1548         if (*lpBufferSize < BufferRequired)
     1548        if (*pBufferSize < BufferRequired)
    15491549        {
    15501550            Log(("VBOXNP: NPGetUniversalName: WN_MORE_DATA BufferRequired: %d\n",
    15511551                 BufferRequired));
    1552             *lpBufferSize = BufferRequired;
     1552            *pBufferSize = BufferRequired;
    15531553            return WN_MORE_DATA;
    15541554        }
    15551555
    15561556        /* Enough memory in the buffer. Add \ and remaining path to the remote name. */
    1557         lpString = &pRemoteNameInfo->lpUniversalName[RemoteNameLength / sizeof (WCHAR)];
    1558         lpString--; /* Trailing NULL */
    1559 
    1560         lpDelimiter = lpString; /* Delimiter between the remote name and the remaining path.
     1557        pString = &pRemoteNameInfo->lpUniversalName[RemoteNameLength / sizeof (WCHAR)];
     1558        pString--; /* Trailing NULL */
     1559
     1560        pDelimiter = pString; /* Delimiter between the remote name and the remaining path.
    15611561                                 * May be 0 if the remaining path is empty.
    15621562                                 */
    15631563
    1564         CopyMemory( lpString, lpRemainingPath, RemainingPathLength);
    1565         lpString += RemainingPathLength / sizeof (WCHAR);
    1566 
    1567         *lpDelimiter = 0; /* Keep NULL terminated remote name. */
    1568 
    1569         pRemoteNameInfo->lpConnectionName = lpString;
    1570         CopyMemory( lpString, pRemoteNameInfo->lpUniversalName, RemoteNameLength);
    1571         lpString += RemoteNameLength / sizeof (WCHAR);
    1572 
    1573         pRemoteNameInfo->lpRemainingPath = lpString;
    1574         CopyMemory( lpString, lpRemainingPath, RemainingPathLength);
     1564        CopyMemory( pString, pRemainingPath, RemainingPathLength);
     1565        pString += RemainingPathLength / sizeof (WCHAR);
     1566
     1567        *pDelimiter = 0; /* Keep NULL terminated remote name. */
     1568
     1569        pRemoteNameInfo->lpConnectionName = pString;
     1570        CopyMemory( pString, pRemoteNameInfo->lpUniversalName, RemoteNameLength);
     1571        pString += RemoteNameLength / sizeof (WCHAR);
     1572
     1573        pRemoteNameInfo->lpRemainingPath = pString;
     1574        CopyMemory( pString, pRemainingPath, RemainingPathLength);
    15751575
    15761576        /* If remaining path was not empty, restore the delimiter in the universal name. */
    15771577        if (RemainingPathLength > sizeof(WCHAR))
    15781578        {
    1579            *lpDelimiter = L'\\';
     1579           *pDelimiter = L'\\';
    15801580        }
    15811581    }
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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