vbox的更動 63082 路徑 trunk/src/VBox/Additions
- 時間撮記:
- 2016-8-6 下午02:00:14 (8 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Additions/WINNT/SharedFolders/np/vboxmrxnp.cpp
r63081 r63082 170 170 } 171 171 172 DWORD APIENTRY NPLogonNotify(PLUID lpLogonId,173 LPCWSTR lpAuthentInfoType,174 LPVOID lpAuthentInfo,175 LPCWSTR lpPreviousAuthentInfoType,176 LPVOID lpPreviousAuthentInfo,177 LPWSTR lpStationName,172 DWORD APIENTRY NPLogonNotify(PLUID pLogonId, 173 LPCWSTR pAuthentInfoType, 174 LPVOID pAuthentInfo, 175 LPCWSTR pPreviousAuthentInfoType, 176 LPVOID pPreviousAuthentInfo, 177 LPWSTR pStationName, 178 178 LPVOID StationHandle, 179 LPWSTR * lpLogonScript)179 LPWSTR *pLogonScript) 180 180 { 181 181 Log(("VBOXNP: NPLogonNotify\n")); 182 * lpLogonScript = NULL;182 *pLogonScript = NULL; 183 183 return WN_SUCCESS; 184 184 } 185 185 186 DWORD APIENTRY NPPasswordChangeNotify(LPCWSTR lpAuthentInfoType,187 LPVOID lpAuthentInfo,188 LPCWSTR lpPreviousAuthentInfoType,189 LPVOID lpPreviousAuthentInfo,190 LPWSTR lpStationName,186 DWORD APIENTRY NPPasswordChangeNotify(LPCWSTR pAuthentInfoType, 187 LPVOID pAuthentInfo, 188 LPCWSTR pPreviousAuthentInfoType, 189 LPVOID pPreviousAuthentInfo, 190 LPWSTR pStationName, 191 191 LPVOID StationHandle, 192 192 DWORD dwChangeInfo) … … 198 198 } 199 199 200 DWORD APIENTRY NPAddConnection(LPNETRESOURCE lpNetResource,201 LPWSTR lpPassword,202 LPWSTR lpUserName)200 DWORD APIENTRY NPAddConnection(LPNETRESOURCE pNetResource, 201 LPWSTR pPassword, 202 LPWSTR pUserName) 203 203 { 204 204 Log(("VBOXNP: NPAddConnection\n")); 205 return NPAddConnection3(NULL, lpNetResource, lpPassword, lpUserName, 0);205 return NPAddConnection3(NULL, pNetResource, pPassword, pUserName, 0); 206 206 } 207 207 208 208 DWORD APIENTRY NPAddConnection3(HWND hwndOwner, 209 LPNETRESOURCE lpNetResource,210 LPWSTR lpPassword,211 LPWSTR lpUserName,209 LPNETRESOURCE pNetResource, 210 LPWSTR pPassword, 211 LPWSTR pUserName, 212 212 DWORD dwFlags) 213 213 { … … 218 218 219 219 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_DISK224 && 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)); 227 227 return WN_BAD_NETNAME; 228 228 } … … 233 233 lstrcat(ConnectionName, L"\\;"); 234 234 235 if ( lpNetResource->lpLocalName == NULL)235 if (pNetResource->lpLocalName == NULL) 236 236 { 237 237 LocalName[0] = L'\0'; … … 240 240 else 241 241 { 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]); 246 246 LocalName[1] = L':'; 247 247 LocalName[2] = L'\0'; … … 259 259 { 260 260 /* Append the remote name. */ 261 if ( lpNetResource->lpRemoteName262 && lpNetResource->lpRemoteName[0] == L'\\'263 && lpNetResource->lpRemoteName[1] == L'\\' )261 if ( pNetResource->lpRemoteName 262 && pNetResource->lpRemoteName[0] == L'\\' 263 && pNetResource->lpRemoteName[1] == L'\\' ) 264 264 { 265 265 /* 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]); 269 269 } 270 270 else … … 310 310 if ( fLocalName 311 311 && !DefineDosDevice(DDD_RAW_TARGET_PATH | DDD_NO_BROADCAST_SYSTEM, 312 lpNetResource->lpLocalName,312 pNetResource->lpLocalName, 313 313 ConnectionName)) 314 314 { … … 333 333 } 334 334 335 DWORD APIENTRY NPCancelConnection(LPWSTR lpName,335 DWORD APIENTRY NPCancelConnection(LPWSTR pName, 336 336 BOOL fForce) 337 337 { … … 339 339 340 340 Log(("VBOXNP: NPCancelConnection: Name = %ls\n", 341 lpName));342 343 if ( lpName && lpName[0] != 0)341 pName)); 342 343 if (pName && pName[0] != 0) 344 344 { 345 345 WCHAR ConnectionName[256]; 346 346 347 if ( lpName[1] == L':')347 if (pName[1] == L':') 348 348 { 349 349 WCHAR RemoteName[128]; 350 350 WCHAR LocalName[3]; 351 351 352 LocalName[0] = vboxToUpper( lpName[0]);352 LocalName[0] = vboxToUpper(pName[0]); 353 353 LocalName[1] = L':'; 354 354 LocalName[2] = L'\0'; … … 404 404 BOOLEAN Verifier; 405 405 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' ); 412 412 /* 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' ); 417 417 } 418 418 else 419 419 { 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 ); 424 424 425 425 if (Verifier) 426 426 { 427 427 /* 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)) 429 429 { 430 430 dwStatus = WN_BAD_NETNAME; … … 434 434 lstrcpy(ConnectionName, DD_MRX_VBOX_FS_DEVICE_NAME_U); 435 435 lstrcat(ConnectionName, L"\\;"); 436 lstrcat(ConnectionName, lpName);436 lstrcat(ConnectionName, pName); 437 437 438 438 dwStatus = vbsfIOCTL(IOCTL_MRX_VBOX_DELCONN, … … 455 455 } 456 456 457 DWORD APIENTRY NPGetConnection(LPWSTR lpLocalName,458 LPWSTR lpRemoteName,459 LPDWORD lpBufferSize)457 DWORD APIENTRY NPGetConnection(LPWSTR pLocalName, 458 LPWSTR pRemoteName, 459 LPDWORD pBufferSize) 460 460 { 461 461 DWORD dwStatus = WN_NOT_CONNECTED; … … 464 464 ULONG cbOut = 0; 465 465 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':') 472 472 { 473 473 WCHAR LocalName[3]; … … 476 476 RemoteName[cbOut / sizeof(WCHAR)] = 0; 477 477 478 LocalName[0] = vboxToUpper( lpLocalName[0]);478 LocalName[0] = vboxToUpper(pLocalName[0]); 479 479 LocalName[1] = L':'; 480 480 LocalName[2] = L'\0'; … … 488 488 if (dwStatus != NO_ERROR) 489 489 { 490 /* The device specified by lpLocalName is not redirected by this provider. */490 /* The device specified by pLocalName is not redirected by this provider. */ 491 491 dwStatus = WN_NOT_CONNECTED; 492 492 } … … 512 512 DWORD len = sizeof(WCHAR) + cbRemoteName; /* Including the leading '\'. */ 513 513 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)); 521 521 } 522 522 else 523 523 { 524 if (* lpBufferSize != 0)524 if (*pBufferSize != 0) 525 525 { 526 526 /* 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)); 529 529 } 530 530 … … 532 532 } 533 533 534 * lpBufferSize = len;534 *pBufferSize = len; 535 535 } 536 536 … … 545 545 } 546 546 547 static const WCHAR *vboxSkipServerPrefix(const WCHAR * lpRemoteName, const WCHAR *lpPrefix)548 { 549 while (* lpPrefix)550 { 551 if (vboxToUpper(* lpPrefix) != vboxToUpper(*lpRemoteName))547 static const WCHAR *vboxSkipServerPrefix(const WCHAR *pRemoteName, const WCHAR *pPrefix) 548 { 549 while (*pPrefix) 550 { 551 if (vboxToUpper(*pPrefix) != vboxToUpper(*pRemoteName)) 552 552 { 553 553 /* Not a prefix */ … … 555 555 } 556 556 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 564 static const WCHAR *vboxSkipServerName(const WCHAR *pRemoteName) 565 565 { 566 566 int cLeadingBackslashes = 0; 567 while (* lpRemoteName == L'\\')568 { 569 lpRemoteName++;567 while (*pRemoteName == L'\\') 568 { 569 pRemoteName++; 570 570 cLeadingBackslashes++; 571 571 } … … 573 573 if (cLeadingBackslashes == 0 || cLeadingBackslashes == 2) 574 574 { 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; 583 583 } 584 584 … … 605 605 DWORD dwType, 606 606 DWORD dwUsage, 607 LPNETRESOURCE lpNetResource,607 LPNETRESOURCE pNetResource, 608 608 LPHANDLE lphEnum) 609 609 { 610 610 DWORD dwStatus; 611 611 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)); 614 614 615 615 if (dwUsage == 0) … … 630 630 else 631 631 { 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)); 636 636 } 637 637 … … 642 642 */ 643 643 { 644 if ( lpNetResource == NULL || lpNetResource->lpRemoteName == NULL)644 if (pNetResource == NULL || pNetResource->lpRemoteName == NULL) 645 645 { 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, 647 647 * the provider should enumerate the top level of its network. 648 648 * But system shares can't be on top level. … … 652 652 } 653 653 654 const WCHAR * lpAfterName = vboxSkipServerName(lpNetResource->lpRemoteName);655 if ( lpAfterName == NULL656 || (* lpAfterName != L'\\' && *lpAfterName != 0))654 const WCHAR *pAfterName = vboxSkipServerName(pNetResource->lpRemoteName); 655 if ( pAfterName == NULL 656 || (*pAfterName != L'\\' && *pAfterName != 0)) 657 657 { 658 658 dwStatus = WN_NOT_CONTAINER; … … 673 673 case RESOURCE_GLOBALNET: /* All resources on the network. */ 674 674 { 675 if ( lpNetResource == NULL || lpNetResource->lpRemoteName == NULL)675 if (pNetResource == NULL || pNetResource->lpRemoteName == NULL) 676 676 { 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, 678 678 * the provider should enumerate the top level of its network. 679 679 */ … … 682 682 else 683 683 { 684 /* Enumerate lpNetResource->lpRemoteName container, which can be only the VBOXSVR container. */685 const WCHAR * lpAfterName = vboxSkipServerName(lpNetResource->lpRemoteName);686 if ( lpAfterName == NULL687 || (* 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)) 688 688 { 689 689 dwStatus = WN_NOT_CONTAINER; … … 748 748 DWORD APIENTRY NPEnumResource(HANDLE hEnum, 749 749 LPDWORD lpcCount, 750 LPVOID lpBuffer,751 LPDWORD lpBufferSize)750 LPVOID pBuffer, 751 LPDWORD pBufferSize) 752 752 { 753 753 DWORD dwStatus = WN_SUCCESS; … … 762 762 ULONG cbEntry = 0; 763 763 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)); 766 766 767 767 if (pCtx == NULL) … … 771 771 } 772 772 773 if (lpcCount == NULL || lpBuffer == NULL)773 if (lpcCount == NULL || pBuffer == NULL) 774 774 { 775 775 Log(("VBOXNP: NPEnumResource: WN_BAD_VALUE\n")); … … 777 777 } 778 778 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; 784 784 ULONG cEntriesCopied = 0; 785 PWCHAR pStrings = (PWCHAR)((PBYTE) lpBuffer + *lpBufferSize);785 PWCHAR pStrings = (PWCHAR)((PBYTE)pBuffer + *pBufferSize); 786 786 PWCHAR pDst; 787 787 … … 862 862 CopyMemory(pDst, MRX_VBOX_PROVIDER_NAME_U, sizeof(MRX_VBOX_PROVIDER_NAME_U)); 863 863 864 Log(("VBOXNP: NPEnumResource: lpRemoteName: %ls\n",864 Log(("VBOXNP: NPEnumResource: pRemoteName: %ls\n", 865 865 pNetResource->lpRemoteName)); 866 866 … … 1007 1007 CopyMemory(pDst, MRX_VBOX_PROVIDER_NAME_U, sizeof(MRX_VBOX_PROVIDER_NAME_U)); 1008 1008 1009 Log(("VBOXNP: NPEnumResource: lpRemoteName: %ls\n",1009 Log(("VBOXNP: NPEnumResource: pRemoteName: %ls\n", 1010 1010 pNetResource->lpRemoteName)); 1011 1011 … … 1047 1047 Log(("VBOXNP: NPEnumResource: More Data Needed - %d\n", 1048 1048 cbEntry)); 1049 * lpBufferSize = cbEntry;1049 *pBufferSize = cbEntry; 1050 1050 dwStatus = WN_MORE_DATA; 1051 1051 } … … 1074 1074 } 1075 1075 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,1076 DWORD 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, 1084 1084 * then call NPGetResourceInformation to actually fill the buffer. 1085 1085 */ 1086 if (! lpNetResource || !lpNetResource->lpRemoteName || !lpBufferSize)1086 if (!pNetResource || !pNetResource->lpRemoteName || !pBufferSize) 1087 1087 { 1088 1088 return WN_BAD_NETNAME; 1089 1089 } 1090 1090 1091 const WCHAR * lpAfterName = vboxSkipServerName(lpNetResource->lpRemoteName);1092 if ( lpAfterName == NULL1093 || (* lpAfterName != L'\\' && *lpAfterName != 0))1091 const WCHAR *pAfterName = vboxSkipServerName(pNetResource->lpRemoteName); 1092 if ( pAfterName == NULL 1093 || (*pAfterName != L'\\' && *pAfterName != 0)) 1094 1094 { 1095 1095 Log(("VBOXNP: NPGetResourceParent: WN_BAD_NETNAME\n")); … … 1097 1097 } 1098 1098 1099 DWORD RemoteNameLength = lstrlen( lpNetResource->lpRemoteName);1099 DWORD RemoteNameLength = lstrlen(pNetResource->lpRemoteName); 1100 1100 1101 1101 DWORD cbEntry = sizeof (NETRESOURCE); … … 1110 1110 1111 1111 pParent->lpRemoteName = (WCHAR *)((PBYTE)pParent + sizeof (NETRESOURCE)); 1112 lstrcpy(pParent->lpRemoteName, lpNetResource->lpRemoteName);1112 lstrcpy(pParent->lpRemoteName, pNetResource->lpRemoteName); 1113 1113 1114 1114 /* Remove last path component of the pParent->lpRemoteName. */ … … 1136 1136 { 1137 1137 /* It is a leading backslash. Construct "no parent" NETRESOURCE. */ 1138 NETRESOURCE *pNetResource = (NETRESOURCE *) lpBuffer;1138 NETRESOURCE *pNetResource = (NETRESOURCE *)pBuffer; 1139 1139 1140 1140 cbEntry = sizeof(NETRESOURCE); … … 1142 1142 cbEntry += sizeof(MRX_VBOX_PROVIDER_NAME_U); /* provider name */ 1143 1143 1144 if (cbEntry > * lpBufferSize)1144 if (cbEntry > *pBufferSize) 1145 1145 { 1146 1146 Log(("VBOXNP: NPGetResourceParent: WN_MORE_DATA 0x%x\n", cbEntry)); 1147 * lpBufferSize = cbEntry;1147 *pBufferSize = cbEntry; 1148 1148 dwStatus = WN_MORE_DATA; 1149 1149 } … … 1156 1156 pNetResource->dwUsage = RESOURCEUSAGE_CONTAINER; 1157 1157 1158 WCHAR *pStrings = (WCHAR *)((PBYTE) lpBuffer + *lpBufferSize);1158 WCHAR *pStrings = (WCHAR *)((PBYTE)pBuffer + *pBufferSize); 1159 1159 pStrings = (PWCHAR)((PBYTE)pStrings - (cbEntry - sizeof(NETRESOURCE))); 1160 1160 … … 1168 1168 1169 1169 Log(("VBOXNP: NPGetResourceParent: no parent, strings %p/%p\n", 1170 pStrings, (PBYTE) lpBuffer + *lpBufferSize));1170 pStrings, (PBYTE)pBuffer + *pBufferSize)); 1171 1171 } 1172 1172 } … … 1176 1176 *pLastSlash = 0; 1177 1177 1178 LPWSTR lpSystem = NULL;1179 dwStatus = NPGetResourceInformation (pParent, lpBuffer, lpBufferSize, &lpSystem);1178 LPWSTR pSystem = NULL; 1179 dwStatus = NPGetResourceInformation (pParent, pBuffer, pBufferSize, &pSystem); 1180 1180 } 1181 1181 … … 1188 1188 } 1189 1189 1190 DWORD APIENTRY NPGetResourceInformation(LPNETRESOURCE lpNetResource,1191 LPVOID lpBuffer,1192 LPDWORD lpBufferSize,1190 DWORD APIENTRY NPGetResourceInformation(LPNETRESOURCE pNetResource, 1191 LPVOID pBuffer, 1192 LPDWORD pBufferSize, 1193 1193 LPWSTR *lplpSystem) 1194 1194 { 1195 Log(("VBOXNP: NPGetResourceInformation: lpNetResource %p, lpBuffer %p, lpBufferSize %p, lplpSystem %p\n",1196 lpNetResource, lpBuffer, lpBufferSize, lplpSystem));1197 1198 if ( lpNetResource == NULL1199 || lpNetResource->lpRemoteName == NULL1200 || 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) 1201 1201 { 1202 1202 Log(("VBOXNP: NPGetResourceInformation: WN_BAD_VALUE\n")); … … 1204 1204 } 1205 1205 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 == NULL1211 || (* 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)) 1212 1212 { 1213 1213 Log(("VBOXNP: NPGetResourceInformation: WN_BAD_NETNAME\n")); … … 1215 1215 } 1216 1216 1217 if ( lpNetResource->dwType != 0 && lpNetResource->dwType != RESOURCETYPE_DISK)1217 if (pNetResource->dwType != 0 && pNetResource->dwType != RESOURCETYPE_DISK) 1218 1218 { 1219 1219 /* The caller passed in a nonzero dwType that does not match … … 1226 1226 * If the input remote resource name was "\\server\share\dir1\dir2", 1227 1227 * then the output NETRESOURCE contains information about the resource "\\server\share". 1228 * The lpRemoteName, lpProvider, dwType, dwDisplayType, and dwUsage fields are returned1228 * The pRemoteName, pProvider, dwType, dwDisplayType, and dwUsage fields are returned 1229 1229 * containing values, all other fields being set to NULL. 1230 1230 */ 1231 1231 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; 1234 1234 1235 1235 /* 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. 1237 1237 */ 1238 1238 1239 if ( lpAfterName[0] == 0 || lpAfterName[1] == 0)1239 if (pAfterName[0] == 0 || pAfterName[1] == 0) 1240 1240 { 1241 1241 /* "\\VBOXSVR" or "\\VBOXSVR\" */ … … 1244 1244 cbEntry += sizeof(MRX_VBOX_PROVIDER_NAME_U); /* provider name */ 1245 1245 1246 if (cbEntry > * lpBufferSize)1246 if (cbEntry > *pBufferSize) 1247 1247 { 1248 1248 Log(("VBOXNP: NPGetResourceInformation: WN_MORE_DATA 0x%x\n", cbEntry)); 1249 * lpBufferSize = cbEntry;1249 *pBufferSize = cbEntry; 1250 1250 return WN_MORE_DATA; 1251 1251 } … … 1269 1269 pStrings += sizeof(MRX_VBOX_PROVIDER_NAME_U) / sizeof(WCHAR); 1270 1270 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)); 1273 1273 1274 1274 if (lplpSystem) … … 1280 1280 } 1281 1281 1282 /* * lpAfterName == L'\\', could be share or share + path.1282 /* *pAfterName == L'\\', could be share or share + path. 1283 1283 * Check if there are more path components after the share name. 1284 1284 */ 1285 const WCHAR *lp = lpAfterName + 1;1285 const WCHAR *lp = pAfterName + 1; 1286 1286 while (*lp && *lp != L'\\') 1287 1287 { … … 1294 1294 cbEntry = sizeof(NETRESOURCE); 1295 1295 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 \\ */ 1297 1297 cbEntry += sizeof(MRX_VBOX_PROVIDER_NAME_U); /* provider name */ 1298 1298 1299 if (cbEntry > * lpBufferSize)1299 if (cbEntry > *pBufferSize) 1300 1300 { 1301 1301 Log(("VBOXNP: NPGetResourceInformation: WN_MORE_DATA 0x%x\n", cbEntry)); 1302 * lpBufferSize = cbEntry;1302 *pBufferSize = cbEntry; 1303 1303 return WN_MORE_DATA; 1304 1304 } … … 1317 1317 CopyMemory(pStrings, MRX_VBOX_SERVER_NAME_U, sizeof(MRX_VBOX_SERVER_NAME_U) - sizeof (WCHAR)); 1318 1318 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; 1321 1321 1322 1322 pNetResourceInfo->lpProvider = pStrings; … … 1324 1324 pStrings += sizeof(MRX_VBOX_PROVIDER_NAME_U) / sizeof(WCHAR); 1325 1325 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)); 1328 1328 1329 1329 if (lplpSystem) … … 1338 1338 cbEntry = sizeof(NETRESOURCE); 1339 1339 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 \\ */ 1341 1341 cbEntry += sizeof(MRX_VBOX_PROVIDER_NAME_U); /* provider name */ 1342 1342 cbEntry += (lstrlen(lp) + 1) * sizeof (WCHAR); /* path string for lplpSystem */ 1343 1343 1344 if (cbEntry > * lpBufferSize)1344 if (cbEntry > *pBufferSize) 1345 1345 { 1346 1346 Log(("VBOXNP: NPGetResourceInformation: WN_MORE_DATA 0x%x\n", cbEntry)); 1347 * lpBufferSize = cbEntry;1347 *pBufferSize = cbEntry; 1348 1348 return WN_MORE_DATA; 1349 1349 } … … 1363 1363 CopyMemory (pStrings, MRX_VBOX_SERVER_NAME_U, sizeof(MRX_VBOX_SERVER_NAME_U) - sizeof (WCHAR)); 1364 1364 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; 1367 1367 *pStrings++ = 0; 1368 1368 … … 1379 1379 pStrings += lstrlen(lp) + 1; 1380 1380 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)); 1383 1383 Log(("VBOXNP: NPGetResourceInformation: *lplpSystem: %ls\n", *lplpSystem)); 1384 1384 … … 1386 1386 } 1387 1387 1388 DWORD APIENTRY NPGetUniversalName(LPCWSTR lpLocalPath,1388 DWORD APIENTRY NPGetUniversalName(LPCWSTR pLocalPath, 1389 1389 DWORD dwInfoLevel, 1390 LPVOID lpBuffer,1391 LPDWORD lpBufferSize)1390 LPVOID pBuffer, 1391 LPDWORD pBufferSize) 1392 1392 { 1393 1393 DWORD dwStatus; … … 1399 1399 WCHAR LocalDrive[3]; 1400 1400 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)); 1406 1406 1407 1407 /* Check is input parameter is OK. */ … … 1415 1415 1416 1416 /* The 'lpLocalPath' is "X:\something". Extract the "X:" to pass to NPGetConnection. */ 1417 if ( lpLocalPath == NULL1418 || lpLocalPath[0] == 01419 || 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")); 1422 1422 return WN_BAD_LOCALNAME; 1423 1423 } 1424 1424 1425 LocalDrive[0] = lpLocalPath[0];1426 LocalDrive[1] = lpLocalPath[1];1425 LocalDrive[0] = pLocalPath[0]; 1426 LocalDrive[1] = pLocalPath[1]; 1427 1427 LocalDrive[2] = 0; 1428 1428 1429 1429 /* 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)); 1432 1432 1433 1433 /* Build the required structure in place of the supplied buffer. */ 1434 1434 if (dwInfoLevel == UNIVERSAL_NAME_INFO_LEVEL) 1435 1435 { 1436 LPUNIVERSAL_NAME_INFOW pUniversalNameInfo = (LPUNIVERSAL_NAME_INFOW) lpBuffer;1436 LPUNIVERSAL_NAME_INFOW pUniversalNameInfo = (LPUNIVERSAL_NAME_INFOW)pBuffer; 1437 1437 1438 1438 BufferRequired = sizeof (UNIVERSAL_NAME_INFOW); 1439 1439 1440 if (* lpBufferSize >= BufferRequired)1440 if (*pBufferSize >= BufferRequired) 1441 1441 { 1442 1442 /* 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)); 1444 1444 1445 1445 /* At least so many bytes are available for obtaining the remote name. */ 1446 RemoteNameLength = * lpBufferSize - BufferRequired;1446 RemoteNameLength = *pBufferSize - BufferRequired; 1447 1447 } 1448 1448 else … … 1479 1479 BufferRequired += RemainingPathLength; 1480 1480 1481 if (* lpBufferSize < BufferRequired)1481 if (*pBufferSize < BufferRequired) 1482 1482 { 1483 1483 Log(("VBOXNP: NPGetUniversalName: WN_MORE_DATA BufferRequired: %d\n", 1484 1484 BufferRequired)); 1485 * lpBufferSize = BufferRequired;1485 *pBufferSize = BufferRequired; 1486 1486 return WN_MORE_DATA; 1487 1487 } 1488 1488 1489 1489 /* 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); 1494 1494 } 1495 1495 else 1496 1496 { 1497 LPREMOTE_NAME_INFOW pRemoteNameInfo = (LPREMOTE_NAME_INFOW) lpBuffer;1498 WCHAR * lpDelimiter;1497 LPREMOTE_NAME_INFOW pRemoteNameInfo = (LPREMOTE_NAME_INFOW)pBuffer; 1498 WCHAR *pDelimiter; 1499 1499 1500 1500 BufferRequired = sizeof (REMOTE_NAME_INFOW); 1501 1501 1502 if (* lpBufferSize >= BufferRequired)1502 if (*pBufferSize >= BufferRequired) 1503 1503 { 1504 1504 /* 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)); 1506 1506 pRemoteNameInfo->lpConnectionName = NULL; 1507 1507 pRemoteNameInfo->lpRemainingPath = NULL; 1508 1508 1509 1509 /* At least so many bytes are available for obtaining the remote name. */ 1510 RemoteNameLength = * lpBufferSize - BufferRequired;1510 RemoteNameLength = *pBufferSize - BufferRequired; 1511 1511 } 1512 1512 else … … 1540 1540 BufferRequired += RemainingPathLength; 1541 1541 1542 /* lpConnectionName, which is the remote name. */1542 /* pConnectionName, which is the remote name. */ 1543 1543 BufferRequired += RemoteNameLength; 1544 1544 1545 /* lpRemainingPath. */1545 /* pRemainingPath. */ 1546 1546 BufferRequired += RemainingPathLength; 1547 1547 1548 if (* lpBufferSize < BufferRequired)1548 if (*pBufferSize < BufferRequired) 1549 1549 { 1550 1550 Log(("VBOXNP: NPGetUniversalName: WN_MORE_DATA BufferRequired: %d\n", 1551 1551 BufferRequired)); 1552 * lpBufferSize = BufferRequired;1552 *pBufferSize = BufferRequired; 1553 1553 return WN_MORE_DATA; 1554 1554 } 1555 1555 1556 1556 /* 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. 1561 1561 * May be 0 if the remaining path is empty. 1562 1562 */ 1563 1563 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); 1575 1575 1576 1576 /* If remaining path was not empty, restore the delimiter in the universal name. */ 1577 1577 if (RemainingPathLength > sizeof(WCHAR)) 1578 1578 { 1579 * lpDelimiter = L'\\';1579 *pDelimiter = L'\\'; 1580 1580 } 1581 1581 }
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器