Changeset 70195 in vbox for trunk/src/VBox/Runtime/r3
- Timestamp:
- Dec 18, 2017 1:40:26 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 119769
- Location:
- trunk/src/VBox/Runtime/r3
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/nt/RTPathQueryInfo-nt.cpp
r69705 r70195 46 46 ( (a_UniStr)->Length == sizeof(a_wszType) - sizeof(RTUTF16) \ 47 47 && memcmp((a_UniStr)->Buffer, a_wszType, sizeof(a_wszType) - sizeof(RTUTF16)) == 0) 48 49 50 /********************************************************************************************************************************* 51 * Global Variables * 52 *********************************************************************************************************************************/ 53 extern decltype(NtQueryFullAttributesFile) *g_pfnNtQueryFullAttributesFile; /* init-win.cpp */ 48 54 49 55 … … 378 384 */ 379 385 int rc = VINF_TRY_AGAIN; 380 if (enmAddAttr != RTFSOBJATTRADD_UNIX) 386 if ( enmAddAttr != RTFSOBJATTRADD_UNIX 387 && g_pfnNtQueryFullAttributesFile) 381 388 { 382 389 InitializeObjectAttributes(&ObjAttr, pNtName, OBJ_CASE_INSENSITIVE, hRootDir, NULL); 383 rcNt = NtQueryFullAttributesFile(&ObjAttr, &uBuf.NetOpenInfo);390 rcNt = g_pfnNtQueryFullAttributesFile(&ObjAttr, &uBuf.NetOpenInfo); 384 391 if (NT_SUCCESS(rcNt)) 385 392 { -
trunk/src/VBox/Runtime/r3/nt/pathint-nt.cpp
r69705 r70195 38 38 #include <iprt/assert.h> 39 39 40 #include "../win/internal-r3-win.h" 41 40 42 41 43 /********************************************************************************************************************************* 42 44 * Global Variables * 43 45 *********************************************************************************************************************************/ 44 static char const g_szPrefixUnc[] = "\\??\\UNC\\"; 45 static char const g_szPrefix[] = "\\??\\"; 46 static char const g_szPrefixUnc[] = "\\??\\UNC\\"; 47 static char const g_szPrefix[] = "\\??\\"; 48 static char const g_szPrefixNt3xUnc[] = "\\DosDevices\\UNC\\"; 49 static char const g_szPrefixNt3x[] = "\\DosDevices\\"; 46 50 47 51 … … 64 68 if (cwcLen < _32K - 1) 65 69 { 66 pwszPath[0] = '\\'; 67 pwszPath[1] = '?'; 68 pwszPath[2] = '?'; 69 pwszPath[3] = '\\'; 70 70 *phRootDir = NULL; 71 if ( g_enmWinVer >= kRTWinOSType_NT4 72 || g_enmWinVer == kRTWinOSType_UNKNOWN) 73 { 74 pwszPath[0] = '\\'; 75 pwszPath[1] = '?'; 76 pwszPath[2] = '?'; 77 pwszPath[3] = '\\'; 78 79 pNtName->Buffer = pwszPath; 80 pNtName->Length = (uint16_t)(cwcLen * sizeof(RTUTF16)); 81 pNtName->MaximumLength = pNtName->Length + sizeof(RTUTF16); 82 return VINF_SUCCESS; 83 } 84 85 rc = RTUtf16Realloc(&pwszPath, cwcLen + sizeof(g_szPrefixNt3x)); 86 if (RT_SUCCESS(rc)) 87 { 88 memmove(&pwszPath[sizeof(g_szPrefixNt3x) - 1], &pwszPath[4], (cwcLen - 4 + 1) * sizeof(RTUTF16)); 89 for (uint32_t i = 0; i < sizeof(g_szPrefixNt3x) - 1; i++) 90 pwszPath[i] = g_szPrefixNt3x[i]; 91 92 pNtName->Buffer = pwszPath; 93 pNtName->Length = (uint16_t)((cwcLen - 4 + sizeof(g_szPrefixNt3x) - 1) * sizeof(RTUTF16)); 94 pNtName->MaximumLength = pNtName->Length + sizeof(RTUTF16); 95 return VINF_SUCCESS; 96 } 97 } 98 99 RTUtf16Free(pwszPath); 100 rc = VERR_FILENAME_TOO_LONG; 101 } 102 return rc; 103 } 104 105 106 /** 107 * Handles the pass thru case for UTF-16 input. 108 * Win32 path uses "\\?\" prefix which is converted to "\??\" NT prefix. 109 * 110 * @returns IPRT status code. 111 * @param pNtName Where to return the NT name. 112 * @param phRootDir Stores NULL here, as we don't use it. 113 * @param pwszWinPath The UTF-16 windows-style path. 114 * @param cwcWinPath The length of the windows-style input path. 115 */ 116 static int rtNtPathFromWinUtf16PassThru(struct _UNICODE_STRING *pNtName, PHANDLE phRootDir, 117 PCRTUTF16 pwszWinPath, size_t cwcWinPath) 118 { 119 /* Check length and allocate memory for it. */ 120 int rc; 121 if (cwcWinPath < _32K - 1) 122 { 123 size_t const cwcExtraPrefix = g_enmWinVer >= kRTWinOSType_NT4 || g_enmWinVer == kRTWinOSType_UNKNOWN 124 ? 0 : sizeof(g_szPrefixNt3x) - 1 - 4; 125 PRTUTF16 pwszNtPath = (PRTUTF16)RTUtf16Alloc((cwcExtraPrefix + cwcWinPath + 1) * sizeof(RTUTF16)); 126 if (pwszNtPath) 127 { 128 /* Intialize the path. */ 129 if (!cwcExtraPrefix) 130 { 131 pwszNtPath[0] = '\\'; 132 pwszNtPath[1] = '?'; 133 pwszNtPath[2] = '?'; 134 pwszNtPath[3] = '\\'; 135 } 136 else 137 for (uint32_t i = 0; i < sizeof(g_szPrefixNt3x) - 1; i++) 138 pwszNtPath[i] = g_szPrefixNt3x[i]; 139 memcpy(pwszNtPath + cwcExtraPrefix + 4, pwszWinPath + 4, (cwcWinPath - 4) * sizeof(RTUTF16)); 140 pwszNtPath[cwcExtraPrefix + cwcWinPath] = '\0'; 141 142 /* Initialize the return values. */ 143 pNtName->Buffer = pwszNtPath; 144 pNtName->Length = (uint16_t)(cwcExtraPrefix + cwcWinPath * sizeof(RTUTF16)); 145 pNtName->MaximumLength = pNtName->Length + sizeof(RTUTF16); 146 *phRootDir = NULL; 147 148 rc = VINF_SUCCESS; 149 } 150 else 151 rc = VERR_NO_UTF16_MEMORY; 152 } 153 else 154 rc = VERR_FILENAME_TOO_LONG; 155 return rc; 156 } 157 158 159 160 161 162 /** 163 * Converts the path to UTF-16 and sets all the return values. 164 * 165 * @returns IPRT status code. 166 * @param pNtName Where to return the NT name. 167 * @param phRootDir Where to return the root handle, if applicable. 168 * @param pszPath The UTF-8 path. 169 */ 170 static int rtNtPathUtf8ToUniStr(struct _UNICODE_STRING *pNtName, PHANDLE phRootDir, const char *pszPath) 171 { 172 PRTUTF16 pwszPath = NULL; 173 size_t cwcLen; 174 int rc = RTStrToUtf16Ex(pszPath, RTSTR_MAX, &pwszPath, 0, &cwcLen); 175 if (RT_SUCCESS(rc)) 176 { 177 if (cwcLen < _32K - 1) 178 { 71 179 pNtName->Buffer = pwszPath; 72 180 pNtName->Length = (uint16_t)(cwcLen * sizeof(RTUTF16)); … … 84 192 85 193 /** 86 * Handles the pass thru case for UTF-16 input.87 * Win32 path uses "\\?\" prefix which is converted to "\??\" NT prefix.88 *89 * @returns IPRT status code.90 * @param pNtName Where to return the NT name.91 * @param phRootDir Stores NULL here, as we don't use it.92 * @param pwszWinPath The UTF-16 windows-style path.93 * @param cwcWinPath The length of the windows-style input path.94 */95 static int rtNtPathFromWinUtf16PassThru(struct _UNICODE_STRING *pNtName, PHANDLE phRootDir,96 PCRTUTF16 pwszWinPath, size_t cwcWinPath)97 {98 /* Check length and allocate memory for it. */99 int rc;100 if (cwcWinPath < _32K - 1)101 {102 PRTUTF16 pwszNtPath = (PRTUTF16)RTUtf16Alloc((cwcWinPath + 1) * sizeof(RTUTF16));103 if (pwszNtPath)104 {105 /* Intialize the path. */106 pwszNtPath[0] = '\\';107 pwszNtPath[1] = '?';108 pwszNtPath[2] = '?';109 pwszNtPath[3] = '\\';110 memcpy(pwszNtPath + 4, pwszWinPath + 4, (cwcWinPath - 4) * sizeof(RTUTF16));111 pwszNtPath[cwcWinPath] = '\0';112 113 /* Initialize the return values. */114 pNtName->Buffer = pwszNtPath;115 pNtName->Length = (uint16_t)(cwcWinPath * sizeof(RTUTF16));116 pNtName->MaximumLength = pNtName->Length + sizeof(RTUTF16);117 *phRootDir = NULL;118 119 rc = VINF_SUCCESS;120 }121 else122 rc = VERR_NO_UTF16_MEMORY;123 }124 else125 rc = VERR_FILENAME_TOO_LONG;126 return rc;127 }128 129 130 131 132 133 /**134 * Converts the path to UTF-16 and sets all the return values.135 *136 * @returns IPRT status code.137 * @param pNtName Where to return the NT name.138 * @param phRootDir Where to return the root handle, if applicable.139 * @param pszPath The UTF-8 path.140 */141 static int rtNtPathUtf8ToUniStr(struct _UNICODE_STRING *pNtName, PHANDLE phRootDir, const char *pszPath)142 {143 PRTUTF16 pwszPath = NULL;144 size_t cwcLen;145 int rc = RTStrToUtf16Ex(pszPath, RTSTR_MAX, &pwszPath, 0, &cwcLen);146 if (RT_SUCCESS(rc))147 {148 if (cwcLen < _32K - 1)149 {150 pNtName->Buffer = pwszPath;151 pNtName->Length = (uint16_t)(cwcLen * sizeof(RTUTF16));152 pNtName->MaximumLength = pNtName->Length + sizeof(RTUTF16);153 *phRootDir = NULL;154 return VINF_SUCCESS;155 }156 157 RTUtf16Free(pwszPath);158 rc = VERR_FILENAME_TOO_LONG;159 }160 return rc;161 }162 163 164 /**165 194 * Converts a windows-style path to NT format and encoding. 166 195 * … … 179 208 * Very simple conversion of a win32-like path into an NT path. 180 209 */ 181 const char *pszPrefix = g_szPrefix; 182 size_t cchPrefix = sizeof(g_szPrefix) - 1; 210 const char *pszPrefix; 211 size_t cchPrefix; 212 if ( g_enmWinVer >= kRTWinOSType_NT4 213 || g_enmWinVer == kRTWinOSType_UNKNOWN) 214 { 215 pszPrefix = g_szPrefix; 216 cchPrefix = sizeof(g_szPrefix) - 1; 217 } 218 else 219 { 220 pszPrefix = g_szPrefixNt3x; 221 cchPrefix = sizeof(g_szPrefixNt3x) - 1; 222 } 223 183 224 size_t cchSkip = 0; 184 185 225 if ( RTPATH_IS_SLASH(pszPath[0]) 186 226 && RTPATH_IS_SLASH(pszPath[1]) … … 211 251 { 212 252 /* UNC */ 213 pszPrefix = g_szPrefixUnc; 214 cchPrefix = sizeof(g_szPrefixUnc) - 1; 253 if ( g_enmWinVer >= kRTWinOSType_NT4 254 || g_enmWinVer == kRTWinOSType_UNKNOWN) 255 { 256 pszPrefix = g_szPrefixUnc; 257 cchPrefix = sizeof(g_szPrefixUnc) - 1; 258 } 259 else 260 { 261 pszPrefix = g_szPrefixNt3xUnc; 262 cchPrefix = sizeof(g_szPrefixNt3xUnc) - 1; 263 } 215 264 cchSkip = 2; 216 265 } -
trunk/src/VBox/Runtime/r3/socket.cpp
r69111 r70195 71 71 #include "internal/socket.h" 72 72 #include "internal/string.h" 73 #ifdef RT_OS_WINDOWS 74 # include "win/internal-r3-win.h" 75 #endif 73 76 74 77 … … 187 190 { 188 191 #ifdef RT_OS_WINDOWS 189 return RTErrConvertFromWin32(WSAGetLastError()); 192 if (g_pfnWSAGetLastError) 193 return RTErrConvertFromWin32(g_pfnWSAGetLastError()); 194 return VERR_NET_IO_ERROR; 190 195 #else 191 196 return RTErrConvertFromErrno(errno); … … 200 205 { 201 206 #ifdef RT_OS_WINDOWS 202 WSASetLastError(0); 207 if (g_pfnWSASetLastError) 208 g_pfnWSASetLastError(0); 203 209 #else 204 210 errno = 0; … … 215 221 { 216 222 #ifdef RT_OS_WINDOWS 217 return RTErrConvertFromWin32(WSAGetLastError()); 223 if (g_pfnWSAGetLastError) 224 return RTErrConvertFromWin32(g_pfnWSAGetLastError()); 225 return VERR_UNRESOLVED_ERROR; 218 226 #else 219 227 switch (h_errno) … … 355 363 { 356 364 #ifdef RT_OS_WINDOWS 357 u_long uBlocking = fBlocking ? 0 : 1; 358 if (ioctlsocket(pThis->hNative, FIONBIO, &uBlocking)) 365 AssertReturn(g_pfnioctlsocket, VERR_NOT_SUPPORTED); 366 u_long uBlocking = fBlocking ? 0 : 1; 367 if (g_pfnioctlsocket(pThis->hNative, FIONBIO, &uBlocking)) 359 368 return rtSocketError(); 360 369 361 370 #else 362 int fFlags= fcntl(pThis->hNative, F_GETFL, 0);371 int fFlags = fcntl(pThis->hNative, F_GETFL, 0); 363 372 if (fFlags == -1) 364 373 return rtSocketError(); … … 448 457 DECLHIDDEN(int) rtSocketCreate(PRTSOCKET phSocket, int iDomain, int iType, int iProtocol) 449 458 { 459 #ifdef RT_OS_WINDOWS 460 AssertReturn(g_pfnsocket, VERR_NOT_SUPPORTED); 461 AssertReturn(g_pfnclosesocket, VERR_NOT_SUPPORTED); 462 #endif 463 450 464 /* 451 465 * Create the socket. 452 466 */ 467 #ifdef RT_OS_WINDOWS 468 RTSOCKETNATIVE hNative = g_pfnsocket(iDomain, iType, iProtocol); 469 #else 453 470 RTSOCKETNATIVE hNative = socket(iDomain, iType, iProtocol); 471 #endif 454 472 if (hNative == NIL_RTSOCKETNATIVE) 455 473 return rtSocketError(); … … 462 480 { 463 481 #ifdef RT_OS_WINDOWS 464 closesocket(hNative);482 g_pfnclosesocket(hNative); 465 483 #else 466 484 close(hNative); … … 510 528 511 529 #ifdef RT_OS_WINDOWS 512 if (closesocket(hNative)) 530 AssertReturn(g_pfnclosesocket, VERR_NOT_SUPPORTED); 531 if (g_pfnclosesocket(hNative)) 513 532 #else 514 533 if (close(hNative)) … … 532 551 { 533 552 pThis->hEvent = WSA_INVALID_EVENT; 534 WSACloseEvent(hEvent); 553 Assert(g_pfnWSACloseEvent); 554 if (g_pfnWSACloseEvent) 555 g_pfnWSACloseEvent(hEvent); 535 556 } 536 557 #endif … … 644 665 AssertPtrNullReturn(pszAddress, VERR_INVALID_POINTER); 645 666 646 #ifdef RT_OS_WINDOWS647 /*648 * Initialize WinSock and check version.649 */650 WORD wVersionRequested = MAKEWORD(1, 1);651 WSADATA wsaData;652 rc = WSAStartup(wVersionRequested, &wsaData);653 if (wsaData.wVersion != wVersionRequested)654 {655 AssertMsgFailed(("Wrong winsock version\n"));656 return VERR_NOT_SUPPORTED;657 }658 #endif659 660 667 /* 661 668 * Resolve the address. Pretty crude at the moment, but we have to make … … 676 683 } 677 684 685 #ifdef RT_OS_WINDOWS 686 /* Initialize WinSock and check version before we call gethostbyname. */ 687 if ( !g_pfnWSAStartup 688 || !g_pfngethostbyname) 689 return VERR_NOT_SUPPORTED; 690 WORD wVersionRequested = MAKEWORD(1, 1); 691 WSADATA wsaData; 692 RT_ZERO(wsaData); 693 rc = g_pfnWSAStartup(wVersionRequested, &wsaData); 694 if (wsaData.wVersion != wVersionRequested) 695 { 696 AssertMsgFailed(("Wrong winsock version\n")); 697 return VERR_NOT_SUPPORTED; 698 } 699 # define gethostbyname g_pfngethostbyname 700 #endif 701 678 702 struct hostent *pHostEnt; 679 703 pHostEnt = gethostbyname(pszAddress); … … 696 720 return VERR_NET_ADDRESS_FAMILY_NOT_SUPPORTED; 697 721 722 #ifdef RT_OS_WINDOWS 723 # undef gethostbyname 724 #endif 698 725 return VINF_SUCCESS; 699 726 } … … 748 775 * Winsock2 init 749 776 */ 777 if ( !g_pfnWSAStartup 778 || !g_pfngetaddrinfo 779 || !g_pfnfreeaddrinfo) 780 return VERR_NOT_SUPPORTED; 750 781 /** @todo someone should check if we really need 2, 2 here */ 751 782 WORD wVersionRequested = MAKEWORD(2, 2); 752 783 WSADATA wsaData; 784 RT_ZERO(wszData); 753 785 rc = WSAStartup(wVersionRequested, &wsaData); 754 786 if (wsaData.wVersion != wVersionRequested) … … 757 789 return VERR_NOT_SUPPORTED; 758 790 } 791 # define getaddrinfo g_pfngetaddrinfo 792 # define freeaddrinfo g_pfnfreeaddrinfo 759 793 # endif 760 794 761 795 /** @todo r=bird: getaddrinfo and freeaddrinfo breaks the additions on NT4. */ 762 796 struct addrinfo *pgrResults = NULL; 763 rc = g etaddrinfo(pszHost, "", &grHints, &pgrResults);797 rc = g_pfngetaddrinfo(pszHost, "", &grHints, &pgrResults); 764 798 if (rc != 0) 765 799 return VERR_NET_ADDRESS_NOT_AVAILABLE; … … 822 856 *penmAddrType = enmAddrType; 823 857 return rc; 858 859 # ifdef RT_OS_WINDOWS 860 # undef getaddrinfo 861 # undef freeaddrinfo 862 # endif 824 863 #endif /* !RT_OS_OS2 */ 825 864 } … … 836 875 AssertReturn(cbBuffer > 0, VERR_INVALID_PARAMETER); 837 876 AssertPtr(pvBuffer); 877 #ifdef RT_OS_WINDOWS 878 AssertReturn(g_pfnrecv, VERR_NOT_SUPPORTED); 879 # define recv g_pfnrecv 880 #endif 838 881 AssertReturn(rtSocketTryLock(pThis), VERR_CONCURRENT_ACCESS); 839 882 … … 890 933 891 934 rtSocketUnlock(pThis); 935 #ifdef RT_OS_WINDOWS 936 # undef recv 937 #endif 892 938 return rc; 893 939 } … … 905 951 AssertPtr(pvBuffer); 906 952 AssertPtr(pcbRead); 953 #ifdef RT_OS_WINDOWS 954 AssertReturn(g_pfnrecvfrom, VERR_NOT_SUPPORTED); 955 # define recvfrom g_pfnrecvfrom 956 #endif 907 957 AssertReturn(rtSocketTryLock(pThis), VERR_CONCURRENT_ACCESS); 908 958 … … 944 994 945 995 rtSocketUnlock(pThis); 996 #ifdef RT_OS_WINDOWS 997 # undef recvfrom 998 #endif 946 999 return rc; 947 1000 } … … 956 1009 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 957 1010 AssertReturn(pThis->u32Magic == RTSOCKET_MAGIC, VERR_INVALID_HANDLE); 1011 #ifdef RT_OS_WINDOWS 1012 AssertReturn(g_pfnsend, VERR_NOT_SUPPORTED); 1013 # define send g_pfnsend 1014 #endif 958 1015 AssertReturn(rtSocketTryLock(pThis), VERR_CONCURRENT_ACCESS); 959 1016 … … 1013 1070 1014 1071 rtSocketUnlock(pThis); 1072 #ifdef RT_OS_WINDOWS 1073 # undef send 1074 #endif 1015 1075 return rc; 1016 1076 } … … 1025 1085 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 1026 1086 AssertReturn(pThis->u32Magic == RTSOCKET_MAGIC, VERR_INVALID_HANDLE); 1087 #ifdef RT_OS_WINDOWS 1088 AssertReturn(g_pfnsendto, VERR_NOT_SUPPORTED); 1089 # define sendto g_pfnsendto 1090 #endif 1027 1091 1028 1092 /* no locking since UDP reads may be done concurrently to writes, and … … 1066 1130 rc = VERR_TOO_MUCH_DATA; 1067 1131 1068 rtSocketUnlock(pThis); 1132 ///@todo rtSocketUnlock(pThis); 1133 #ifdef RT_OS_WINDOWS 1134 # undef sendto 1135 #endif 1069 1136 return rc; 1070 1137 } … … 1079 1146 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 1080 1147 AssertReturn(pThis->u32Magic == RTSOCKET_MAGIC, VERR_INVALID_HANDLE); 1148 #ifdef RT_OS_WINDOWS 1149 AssertReturn(g_pfnsendto, VERR_NOT_SUPPORTED); 1150 # define sendto g_pfnsendto 1151 #endif 1081 1152 1082 1153 /* no locking since UDP reads may be done concurrently to writes, and … … 1120 1191 rc = VERR_TOO_MUCH_DATA; 1121 1192 1122 rtSocketUnlock(pThis); 1193 /// @todo rtSocketUnlock(pThis); 1194 #ifdef RT_OS_WINDOWS 1195 # undef sendto 1196 #endif 1123 1197 return rc; 1124 1198 } … … 1146 1220 rc = VERR_NO_TMP_MEMORY; 1147 1221 #ifdef RT_OS_WINDOWS 1148 AssertCompileSize(WSABUF, sizeof(RTSGSEG));1149 AssertCompileMemberSize(WSABUF, buf, RT_SIZEOFMEMB(RTSGSEG, pvSeg));1150 1151 LPWSABUF paMsg = (LPWSABUF)RTMemTmpAllocZ(pSgBuf->cSegs * sizeof(WSABUF));1152 if (paMsg) 1153 {1154 for (unsigned i = 0; i < pSgBuf->cSegs; i++)1222 if (g_pfnWSASend) 1223 { 1224 AssertCompileSize(WSABUF, sizeof(RTSGSEG)); 1225 AssertCompileMemberSize(WSABUF, buf, RT_SIZEOFMEMB(RTSGSEG, pvSeg)); 1226 1227 LPWSABUF paMsg = (LPWSABUF)RTMemTmpAllocZ(pSgBuf->cSegs * sizeof(WSABUF)); 1228 if (paMsg) 1155 1229 { 1156 paMsg[i].buf = (char *)pSgBuf->paSegs[i].pvSeg; 1157 paMsg[i].len = (u_long)pSgBuf->paSegs[i].cbSeg; 1230 for (unsigned i = 0; i < pSgBuf->cSegs; i++) 1231 { 1232 paMsg[i].buf = (char *)pSgBuf->paSegs[i].pvSeg; 1233 paMsg[i].len = (u_long)pSgBuf->paSegs[i].cbSeg; 1234 } 1235 1236 DWORD dwSent; 1237 int hrc = g_pfnWSASend(pThis->hNative, paMsg, pSgBuf->cSegs, &dwSent, MSG_NOSIGNAL, NULL, NULL); 1238 if (!hrc) 1239 rc = VINF_SUCCESS; 1240 /** @todo check for incomplete writes */ 1241 else 1242 rc = rtSocketError(); 1243 1244 RTMemTmpFree(paMsg); 1158 1245 } 1159 1160 DWORD dwSent; 1161 int hrc = WSASend(pThis->hNative, paMsg, pSgBuf->cSegs, &dwSent, 1162 MSG_NOSIGNAL, NULL, NULL); 1163 if (!hrc) 1164 rc = VINF_SUCCESS; 1165 /** @todo check for incomplete writes */ 1166 else 1167 rc = rtSocketError(); 1168 1169 RTMemTmpFree(paMsg); 1170 } 1246 } 1247 else if (g_pfnsend) 1248 { 1249 rc = VINF_SUCCESS; 1250 for (uint32_t iSeg = 0; iSeg < pSgBuf->cSegs; iSeg++) 1251 { 1252 uint8_t const *pbSeg = (uint8_t const *)pSgBuf->paSegs[iSeg].pvSeg; 1253 size_t cbSeg = pSgBuf->paSegs[iSeg].cbSeg; 1254 int cbNow; 1255 ssize_t cbWritten; 1256 for (;;) 1257 { 1258 cbNow = cbSeg >= RTSOCKET_MAX_WRITE ? RTSOCKET_MAX_WRITE : (int)cbSeg; 1259 cbWritten = g_pfnsend(pThis->hNative, (const char *)pbSeg, cbNow, MSG_NOSIGNAL); 1260 if ((size_t)cbWritten >= cbSeg || cbWritten < 0) 1261 break; 1262 pbSeg += cbWritten; 1263 cbSeg -= cbWritten; 1264 } 1265 if (cbWritten < 0) 1266 { 1267 rc = rtSocketError(); 1268 break; 1269 } 1270 } 1271 } 1272 else 1273 rc = VERR_NOT_SUPPORTED; 1171 1274 1172 1275 #else /* !RT_OS_WINDOWS */ … … 1246 1349 AssertPtr(pvBuffer); 1247 1350 AssertPtrReturn(pcbRead, VERR_INVALID_PARAMETER); 1351 #ifdef RT_OS_WINDOWS 1352 AssertReturn(g_pfnrecv, VERR_NOT_SUPPORTED); 1353 #endif 1248 1354 AssertReturn(rtSocketTryLock(pThis), VERR_CONCURRENT_ACCESS); 1249 1355 … … 1260 1366 1261 1367 #ifdef RT_OS_WINDOWS 1262 int cbRead = recv(pThis->hNative, (char *)pvBuffer, cbNow, MSG_NOSIGNAL);1368 int cbRead = g_pfnrecv(pThis->hNative, (char *)pvBuffer, cbNow, MSG_NOSIGNAL); 1263 1369 if (cbRead >= 0) 1264 1370 { … … 1309 1415 AssertReturn(pThis->u32Magic == RTSOCKET_MAGIC, VERR_INVALID_HANDLE); 1310 1416 AssertPtrReturn(pcbWritten, VERR_INVALID_PARAMETER); 1417 #ifdef RT_OS_WINDOWS 1418 AssertReturn(g_pfnsend, VERR_NOT_SUPPORTED); 1419 #endif 1311 1420 AssertReturn(rtSocketTryLock(pThis), VERR_CONCURRENT_ACCESS); 1312 1421 … … 1322 1431 size_t cbNow = cbBuffer; 1323 1432 # endif 1324 int cbWritten = send(pThis->hNative, (const char *)pvBuffer, cbNow, MSG_NOSIGNAL);1433 int cbWritten = g_pfnsend(pThis->hNative, (const char *)pvBuffer, cbNow, MSG_NOSIGNAL); 1325 1434 if (cbWritten >= 0) 1326 1435 { … … 1381 1490 rc = VERR_NO_TMP_MEMORY; 1382 1491 #ifdef RT_OS_WINDOWS 1383 LPWSABUF paMsg = NULL; 1384 1385 RTSgBufMapToNative(paMsg, pSgBuf, WSABUF, buf, char *, len, u_long, cSegsToSend); 1386 if (paMsg) 1387 { 1388 DWORD dwSent = 0; 1389 int hrc = WSASend(pThis->hNative, paMsg, cSegsToSend, &dwSent, 1390 MSG_NOSIGNAL, NULL, NULL); 1391 if (!hrc) 1392 rc = VINF_SUCCESS; 1393 else 1394 rc = rtSocketError(); 1395 1396 *pcbWritten = dwSent; 1397 1398 RTMemTmpFree(paMsg); 1399 } 1492 if (g_pfnWSASend) 1493 { 1494 LPWSABUF paMsg = NULL; 1495 RTSgBufMapToNative(paMsg, pSgBuf, WSABUF, buf, char *, len, u_long, cSegsToSend); 1496 if (paMsg) 1497 { 1498 DWORD dwSent = 0; 1499 int hrc = g_pfnWSASend(pThis->hNative, paMsg, cSegsToSend, &dwSent, MSG_NOSIGNAL, NULL, NULL); 1500 if (!hrc) 1501 rc = VINF_SUCCESS; 1502 else 1503 rc = rtSocketError(); 1504 1505 *pcbWritten = dwSent; 1506 1507 RTMemTmpFree(paMsg); 1508 } 1509 } 1510 else if (g_pfnsend) 1511 { 1512 size_t cbWrittenTotal = 0; 1513 rc = VINF_SUCCESS; 1514 for (uint32_t iSeg = 0; iSeg < pSgBuf->cSegs; iSeg++) 1515 { 1516 uint8_t const *pbSeg = (uint8_t const *)pSgBuf->paSegs[iSeg].pvSeg; 1517 size_t cbSeg = pSgBuf->paSegs[iSeg].cbSeg; 1518 int cbNow; 1519 ssize_t cbWritten; 1520 for (;;) 1521 { 1522 cbNow = cbSeg >= RTSOCKET_MAX_WRITE ? RTSOCKET_MAX_WRITE : (int)cbSeg; 1523 cbWritten = g_pfnsend(pThis->hNative, (const char *)pbSeg, cbNow, MSG_NOSIGNAL); 1524 if ((size_t)cbWritten >= cbSeg || cbWritten < 0) 1525 break; 1526 cbWrittenTotal += cbWrittenTotal; 1527 pbSeg += cbWritten; 1528 cbSeg -= cbWritten; 1529 } 1530 if (cbWritten < 0) 1531 { 1532 rc = rtSocketError(); 1533 break; 1534 } 1535 if (cbWritten != cbNow) 1536 break; 1537 } 1538 *pcbWritten = cbWrittenTotal; 1539 } 1540 else 1541 rc = VERR_NOT_SUPPORTED; 1400 1542 1401 1543 #else /* !RT_OS_WINDOWS */ … … 1469 1611 int const fdMax = (int)pThis->hNative + 1; 1470 1612 AssertReturn((RTSOCKETNATIVE)(fdMax - 1) == pThis->hNative, VERR_INTERNAL_ERROR_5); 1613 #ifdef RT_OS_WINDOWS 1614 AssertReturn(g_pfnselect, VERR_NOT_SUPPORTED); 1615 # define select g_pfnselect 1616 #endif 1471 1617 1472 1618 /* … … 1496 1642 rc = rtSocketError(); 1497 1643 1644 #ifdef RT_OS_WINDOWS 1645 # undef select 1646 #endif 1498 1647 return rc; 1499 1648 } … … 1523 1672 int const fdMax = (int)hNative + 1; 1524 1673 AssertReturn((RTSOCKETNATIVE)(fdMax - 1) == hNative, VERR_INTERNAL_ERROR_5); 1674 #ifdef RT_OS_WINDOWS 1675 AssertReturn(g_pfnselect, VERR_NOT_SUPPORTED); 1676 AssertReturn(g_pfn__WSAFDIsSet, VERR_NOT_SUPPORTED); 1677 # define select g_pfnselect 1678 # define __WSAFDIsSet g_pfn__WSAFDIsSet 1679 #endif 1525 1680 1526 1681 *pfEvents = 0; … … 1577 1732 rc = rtSocketError(); 1578 1733 1734 #ifdef RT_OS_WINDOWS 1735 # undef select 1736 # undef __WSAFDIsSet 1737 #endif 1579 1738 return rc; 1580 1739 } … … 1592 1751 AssertReturn(RTMemPoolRefCount(pThis) >= (pThis->cUsers ? 2U : 1U), VERR_CALLER_NO_REFERENCE); 1593 1752 AssertReturn(fRead || fWrite, VERR_INVALID_PARAMETER); 1753 #ifdef RT_OS_WINDOWS 1754 AssertReturn(g_pfnshutdown, VERR_NOT_SUPPORTED); 1755 # define shutdown g_pfnshutdown 1756 #endif 1594 1757 1595 1758 /* … … 1607 1770 rc = rtSocketError(); 1608 1771 1772 #ifdef RT_OS_WINDOWS 1773 # undef shutdown 1774 #endif 1609 1775 return rc; 1610 1776 } … … 1620 1786 AssertReturn(pThis->u32Magic == RTSOCKET_MAGIC, VERR_INVALID_HANDLE); 1621 1787 AssertReturn(RTMemPoolRefCount(pThis) >= (pThis->cUsers ? 2U : 1U), VERR_CALLER_NO_REFERENCE); 1788 #ifdef RT_OS_WINDOWS 1789 AssertReturn(g_pfngetsockname, VERR_NOT_SUPPORTED); 1790 # define getsockname g_pfngetsockname 1791 #endif 1622 1792 1623 1793 /* … … 1637 1807 rc = rtSocketError(); 1638 1808 1809 #ifdef RT_OS_WINDOWS 1810 # undef getsockname 1811 #endif 1639 1812 return rc; 1640 1813 } … … 1650 1823 AssertReturn(pThis->u32Magic == RTSOCKET_MAGIC, VERR_INVALID_HANDLE); 1651 1824 AssertReturn(RTMemPoolRefCount(pThis) >= (pThis->cUsers ? 2U : 1U), VERR_CALLER_NO_REFERENCE); 1825 #ifdef RT_OS_WINDOWS 1826 AssertReturn(g_pfngetpeername, VERR_NOT_SUPPORTED); 1827 # define getpeername g_pfngetpeername 1828 #endif 1652 1829 1653 1830 /* … … 1667 1844 rc = rtSocketError(); 1668 1845 1846 #ifdef RT_OS_WINDOWS 1847 # undef getpeername 1848 #endif 1669 1849 return rc; 1670 1850 } … … 1708 1888 AssertReturn(pThis->u32Magic == RTSOCKET_MAGIC, VERR_INVALID_HANDLE); 1709 1889 AssertPtrReturn(pvAddr, VERR_INVALID_POINTER); 1890 #ifdef RT_OS_WINDOWS 1891 AssertReturn(g_pfnbind, VERR_NOT_SUPPORTED); 1892 # define bind g_pfnbind 1893 #endif 1710 1894 AssertReturn(rtSocketTryLock(pThis), VERR_CONCURRENT_ACCESS); 1711 1895 … … 1717 1901 1718 1902 rtSocketUnlock(pThis); 1903 #ifdef RT_OS_WINDOWS 1904 # undef bind 1905 #endif 1719 1906 return rc; 1720 1907 } … … 1737 1924 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 1738 1925 AssertReturn(pThis->u32Magic == RTSOCKET_MAGIC, VERR_INVALID_HANDLE); 1926 #ifdef RT_OS_WINDOWS 1927 AssertReturn(g_pfnlisten, VERR_NOT_SUPPORTED); 1928 # define listen g_pfnlisten 1929 #endif 1739 1930 AssertReturn(rtSocketTryLock(pThis), VERR_CONCURRENT_ACCESS); 1740 1931 … … 1744 1935 1745 1936 rtSocketUnlock(pThis); 1937 #ifdef RT_OS_WINDOWS 1938 # undef listen 1939 #endif 1746 1940 return rc; 1747 1941 } … … 1770 1964 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 1771 1965 AssertReturn(pThis->u32Magic == RTSOCKET_MAGIC, VERR_INVALID_HANDLE); 1966 #ifdef RT_OS_WINDOWS 1967 AssertReturn(g_pfnaccept, VERR_NOT_SUPPORTED); 1968 AssertReturn(g_pfnclosesocket, VERR_NOT_SUPPORTED); 1969 # define accept g_pfnaccept 1970 #endif 1772 1971 AssertReturn(rtSocketTryLock(pThis), VERR_CONCURRENT_ACCESS); 1773 1972 … … 1794 1993 { 1795 1994 #ifdef RT_OS_WINDOWS 1796 closesocket(hNativeClient);1995 g_pfnclosesocket(hNativeClient); 1797 1996 #else 1798 1997 close(hNativeClient); … … 1804 2003 1805 2004 rtSocketUnlock(pThis); 2005 #ifdef RT_OS_WINDOWS 2006 # undef accept 2007 #endif 1806 2008 return rc; 1807 2009 } … … 1827 2029 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 1828 2030 AssertReturn(pThis->u32Magic == RTSOCKET_MAGIC, VERR_INVALID_HANDLE); 2031 #ifdef RT_OS_WINDOWS 2032 AssertReturn(g_pfnconnect, VERR_NOT_SUPPORTED); 2033 AssertReturn(g_pfnselect, VERR_NOT_SUPPORTED); 2034 AssertReturn(g_pfngetsockopt, VERR_NOT_SUPPORTED); 2035 # define connect g_pfnconnect 2036 # define select g_pfnselect 2037 # define getsockopt g_pfngetsockopt 2038 #endif 1829 2039 AssertReturn(rtSocketTryLock(pThis), VERR_CONCURRENT_ACCESS); 1830 2040 … … 1904 2114 1905 2115 rtSocketUnlock(pThis); 2116 #ifdef RT_OS_WINDOWS 2117 # undef connect 2118 # undef select 2119 # undef getsockopt 2120 #endif 1906 2121 return rc; 1907 2122 } … … 1924 2139 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 1925 2140 AssertReturn(pThis->u32Magic == RTSOCKET_MAGIC, VERR_INVALID_HANDLE); 2141 #ifdef RT_OS_WINDOWS 2142 AssertReturn(g_pfnconnect, VERR_NOT_SUPPORTED); 2143 # define connect g_pfnconnect 2144 #endif 1926 2145 AssertReturn(rtSocketTryLock(pThis), VERR_CONCURRENT_ACCESS); 1927 2146 … … 1933 2152 1934 2153 rtSocketUnlock(pThis); 2154 #ifdef RT_OS_WINDOWS 2155 # undef connect 2156 #endif 1935 2157 return rc; 1936 2158 } … … 1955 2177 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 1956 2178 AssertReturn(pThis->u32Magic == RTSOCKET_MAGIC, VERR_INVALID_HANDLE); 2179 #ifdef RT_OS_WINDOWS 2180 AssertReturn(g_pfnsetsockopt, VERR_NOT_SUPPORTED); 2181 # define setsockopt g_pfnsetsockopt 2182 #endif 1957 2183 AssertReturn(rtSocketTryLock(pThis), VERR_CONCURRENT_ACCESS); 1958 2184 … … 1962 2188 1963 2189 rtSocketUnlock(pThis); 2190 #ifdef RT_OS_WINDOWS 2191 # undef setsockopt 2192 #endif 1964 2193 return rc; 1965 2194 } … … 1987 2216 if (pThis->hEvent != WSA_INVALID_EVENT) 1988 2217 *phNative = (RTHCINTPTR)pThis->hEvent; 1989 else 1990 { 1991 pThis->hEvent = WSACreateEvent();2218 else if (g_pfnWSACreateEvent) 2219 { 2220 pThis->hEvent = g_pfnWSACreateEvent(); 1992 2221 *phNative = (RTHCINTPTR)pThis->hEvent; 1993 2222 if (pThis->hEvent == WSA_INVALID_EVENT) 1994 2223 rc = rtSocketError(); 1995 2224 } 2225 else 2226 rc = VERR_NOT_SUPPORTED; 1996 2227 1997 2228 rtSocketUnlock(pThis); … … 2017 2248 if (pThis->fSubscribedEvts) 2018 2249 { 2019 if ( WSAEventSelect(pThis->hNative, WSA_INVALID_EVENT, 0) == 0)2250 if (g_pfnWSAEventSelect && g_pfnioctlsocket) 2020 2251 { 2021 pThis->fSubscribedEvts = 0; 2022 2023 /* 2024 * Switch back to blocking mode if that was the state before the 2025 * operation. 2026 */ 2027 if (pThis->fBlocking) 2252 if (g_pfnWSAEventSelect(pThis->hNative, WSA_INVALID_EVENT, 0) == 0) 2028 2253 { 2029 u_long fNonBlocking = 0; 2030 int rc2 = ioctlsocket(pThis->hNative, FIONBIO, &fNonBlocking); 2031 if (rc2 != 0) 2254 pThis->fSubscribedEvts = 0; 2255 2256 /* 2257 * Switch back to blocking mode if that was the state before the 2258 * operation. 2259 */ 2260 if (pThis->fBlocking) 2032 2261 { 2033 rc = rtSocketError(); 2034 AssertMsgFailed(("%Rrc; rc2=%d\n", rc, rc2)); 2262 u_long fNonBlocking = 0; 2263 int rc2 = g_pfnioctlsocket(pThis->hNative, FIONBIO, &fNonBlocking); 2264 if (rc2 != 0) 2265 { 2266 rc = rtSocketError(); 2267 AssertMsgFailed(("%Rrc; rc2=%d\n", rc, rc2)); 2268 } 2035 2269 } 2270 } 2271 else 2272 { 2273 rc = rtSocketError(); 2274 AssertMsgFailed(("%Rrc\n", rc)); 2036 2275 } 2037 2276 } 2038 2277 else 2039 { 2040 rc = rtSocketError(); 2041 AssertMsgFailed(("%Rrc\n", rc)); 2042 } 2278 rc = VERR_NOT_SUPPORTED; 2043 2279 } 2044 2280 return rc; … … 2063 2299 fNetworkEvents |= FD_CLOSE; 2064 2300 LogFlowFunc(("fNetworkEvents=%#x\n", fNetworkEvents)); 2065 if (WSAEventSelect(pThis->hNative, pThis->hEvent, fNetworkEvents) == 0) 2066 { 2067 pThis->fSubscribedEvts = fEvents; 2068 return VINF_SUCCESS; 2069 } 2070 2071 int rc = rtSocketError(); 2072 AssertMsgFailed(("fNetworkEvents=%#x rc=%Rrc\n", fNetworkEvents, rtSocketError())); 2301 int rc; 2302 if (g_pfnWSAEventSelect) 2303 { 2304 if (g_pfnWSAEventSelect(pThis->hNative, pThis->hEvent, fNetworkEvents) == 0) 2305 { 2306 pThis->fSubscribedEvts = fEvents; 2307 return VINF_SUCCESS; 2308 } 2309 rc = rtSocketError(); 2310 AssertMsgFailed(("fNetworkEvents=%#x rc=%Rrc\n", fNetworkEvents, rtSocketError())); 2311 } 2312 else 2313 rc = VERR_NOT_SUPPORTED; 2073 2314 return rc; 2074 2315 } … … 2099 2340 2100 2341 /* Get the event mask, ASSUMES that WSAEnumNetworkEvents doesn't clear stuff. */ 2101 WSANETWORKEVENTS NetEvts; 2102 RT_ZERO(NetEvts); 2103 if (WSAEnumNetworkEvents(pThis->hNative, pThis->hEvent, &NetEvts) == 0) 2104 { 2105 if ( (NetEvts.lNetworkEvents & FD_READ) 2106 && (fEvents & RTPOLL_EVT_READ) 2107 && NetEvts.iErrorCode[FD_READ_BIT] == 0) 2108 fRetEvents |= RTPOLL_EVT_READ; 2109 2110 if ( (NetEvts.lNetworkEvents & FD_WRITE) 2111 && (fEvents & RTPOLL_EVT_WRITE) 2112 && NetEvts.iErrorCode[FD_WRITE_BIT] == 0) 2113 fRetEvents |= RTPOLL_EVT_WRITE; 2114 2115 if (fEvents & RTPOLL_EVT_ERROR) 2342 if (g_pfnWSAEnumNetworkEvents) 2343 { 2344 WSANETWORKEVENTS NetEvts; 2345 RT_ZERO(NetEvts); 2346 if (g_pfnWSAEnumNetworkEvents(pThis->hNative, pThis->hEvent, &NetEvts) == 0) 2116 2347 { 2117 if (NetEvts.lNetworkEvents & FD_CLOSE) 2118 fRetEvents |= RTPOLL_EVT_ERROR; 2119 else 2120 for (uint32_t i = 0; i < FD_MAX_EVENTS; i++) 2121 if ( (NetEvts.lNetworkEvents & (1L << i)) 2122 && NetEvts.iErrorCode[i] != 0) 2123 fRetEvents |= RTPOLL_EVT_ERROR; 2348 if ( (NetEvts.lNetworkEvents & FD_READ) 2349 && (fEvents & RTPOLL_EVT_READ) 2350 && NetEvts.iErrorCode[FD_READ_BIT] == 0) 2351 fRetEvents |= RTPOLL_EVT_READ; 2352 2353 if ( (NetEvts.lNetworkEvents & FD_WRITE) 2354 && (fEvents & RTPOLL_EVT_WRITE) 2355 && NetEvts.iErrorCode[FD_WRITE_BIT] == 0) 2356 fRetEvents |= RTPOLL_EVT_WRITE; 2357 2358 if (fEvents & RTPOLL_EVT_ERROR) 2359 { 2360 if (NetEvts.lNetworkEvents & FD_CLOSE) 2361 fRetEvents |= RTPOLL_EVT_ERROR; 2362 else 2363 for (uint32_t i = 0; i < FD_MAX_EVENTS; i++) 2364 if ( (NetEvts.lNetworkEvents & (1L << i)) 2365 && NetEvts.iErrorCode[i] != 0) 2366 fRetEvents |= RTPOLL_EVT_ERROR; 2367 } 2124 2368 } 2125 } 2126 else 2127 rc = rtSocketError(); 2369 else 2370 rc = rtSocketError(); 2371 } 2372 else if (RT_SUCCESS(rc)) 2373 rc = VERR_NOT_SUPPORTED; 2128 2374 2129 2375 /* Fall back on select if we hit an error above. */ 2130 2376 if (RT_FAILURE(rc)) 2131 2377 { 2132 2378 rc = RTSocketSelectOneEx(pThis, fEvents, &fRetEvents, 0); 2379 if (RT_FAILURE(rc)) 2380 fRetEvents = 0; 2133 2381 } 2134 2382 -
trunk/src/VBox/Runtime/r3/win/errvars-win.cpp
r69111 r70195 37 37 #include <iprt/assert.h> 38 38 #include "internal/magics.h" 39 #include "internal-r3-win.h" 39 40 40 41 … … 44 45 pVars->ai32Vars[0] = RTERRVARS_MAGIC; 45 46 pVars->ai32Vars[1] = GetLastError(); 46 pVars->ai32Vars[2] = WSAGetLastError();47 pVars->ai32Vars[2] = g_pfnWSAGetLastError ? g_pfnWSAGetLastError() : WSANOTINITIALISED; 47 48 pVars->ai32Vars[3] = errno; 48 49 return pVars; … … 54 55 AssertReturnVoid(pVars->ai32Vars[0] == RTERRVARS_MAGIC); 55 56 errno = pVars->ai32Vars[3]; 56 if (pVars->ai32Vars[2] != WSANOTINITIALISED) /* just an idea... */ 57 WSASetLastError(pVars->ai32Vars[2]); 57 if ( pVars->ai32Vars[2] != WSANOTINITIALISED 58 && g_pfnWSASetLastError) 59 g_pfnWSASetLastError(pVars->ai32Vars[2]); 58 60 SetLastError(pVars->ai32Vars[1]); 59 61 } … … 78 80 return pVars->ai32Vars[0] != RTERRVARS_MAGIC 79 81 || (uint32_t)pVars->ai32Vars[1] != GetLastError() 80 || pVars->ai32Vars[2] != WSAGetLastError()82 || pVars->ai32Vars[2] != (g_pfnWSAGetLastError ? g_pfnWSAGetLastError() : WSANOTINITIALISED) 81 83 || pVars->ai32Vars[3] != errno; 82 84 } -
trunk/src/VBox/Runtime/r3/win/init-win.cpp
r69434 r70195 40 40 #include <iprt/assert.h> 41 41 #include <iprt/err.h> 42 #include <iprt/ldr.h> 42 43 #include <iprt/log.h> 43 44 #include <iprt/param.h> … … 63 64 /** Extended windows version information. */ 64 65 DECLHIDDEN(OSVERSIONINFOEXW) g_WinOsInfoEx; 66 65 67 /** The native kernel32.dll handle. */ 66 DECLHIDDEN(HMODULE) g_hModKernel32 = NULL; 68 DECLHIDDEN(HMODULE) g_hModKernel32 = NULL; 69 /** GetSystemWindowsDirectoryW or GetWindowsDirectoryW (NT4). */ 70 DECLHIDDEN(PFNGETWINSYSDIR) g_pfnGetSystemWindowsDirectoryW = NULL; 71 /** The GetCurrentThreadStackLimits API. */ 72 static PFNGETCURRENTTHREADSTACKLIMITS g_pfnGetCurrentThreadStackLimits = NULL; 73 /** SetUnhandledExceptionFilter. */ 74 static PFNSETUNHANDLEDEXCEPTIONFILTER g_pfnSetUnhandledExceptionFilter = NULL; 75 /** The previous unhandled exception filter. */ 76 static LPTOP_LEVEL_EXCEPTION_FILTER g_pfnUnhandledXcptFilter = NULL; 77 67 78 /** The native ntdll.dll handle. */ 68 DECLHIDDEN(HMODULE) g_hModNtDll = NULL; 69 /** GetSystemWindowsDirectoryW or GetWindowsDirectoryW (NT4). */ 70 DECLHIDDEN(PFNGETWINSYSDIR) g_pfnGetSystemWindowsDirectoryW = NULL; 71 /** The GetCurrentThreadStackLimits API. */ 72 static PFNGETCURRENTTHREADSTACKLIMITS g_pfnGetCurrentThreadStackLimits = NULL; 73 /** SetUnhandledExceptionFilter. */ 74 static PFNSETUNHANDLEDEXCEPTIONFILTER g_pfnSetUnhandledExceptionFilter = NULL; 75 /** The previous unhandled exception filter. */ 76 static LPTOP_LEVEL_EXCEPTION_FILTER g_pfnUnhandledXcptFilter = NULL; 79 DECLHIDDEN(HMODULE) g_hModNtDll = NULL; 80 /** NtQueryFullAttributesFile */ 81 DECLHIDDEN(PFNNTQUERYFULLATTRIBUTESFILE) g_pfnNtQueryFullAttributesFile = NULL; 82 /** NtDuplicateToken (NT 3.51). */ 83 DECLHIDDEN(PFNNTDUPLICATETOKEN) g_pfnNtDuplicateToken = NULL; 84 85 /** Either ws2_32.dll (NT4+) or wsock32.dll (NT3.x). */ 86 DECLHIDDEN(HMODULE) g_hModWinSock = NULL; 87 /** Set if we're dealing with old winsock. */ 88 DECLHIDDEN(bool) g_fOldWinSock = false; 89 /** WSAStartup */ 90 DECLHIDDEN(PFNWSASTARTUP) g_pfnWSAStartup = NULL; 91 /** WSACleanup */ 92 DECLHIDDEN(PFNWSACLEANUP) g_pfnWSACleanup = NULL; 93 /** Pointner to WSAGetLastError (for RTErrVarsSave). */ 94 DECLHIDDEN(PFNWSAGETLASTERROR) g_pfnWSAGetLastError = NULL; 95 /** Pointner to WSASetLastError (for RTErrVarsRestore). */ 96 DECLHIDDEN(PFNWSASETLASTERROR) g_pfnWSASetLastError = NULL; 97 /** WSACreateEvent */ 98 DECLHIDDEN(PFNWSACREATEEVENT) g_pfnWSACreateEvent = NULL; 99 /** WSACloseEvent */ 100 DECLHIDDEN(PFNWSACLOSEEVENT) g_pfnWSACloseEvent = NULL; 101 /** WSAEventSelect */ 102 DECLHIDDEN(PFNWSAEVENTSELECT) g_pfnWSAEventSelect = NULL; 103 /** WSAEnumNetworkEvents */ 104 DECLHIDDEN(PFNWSAENUMNETWORKEVENTS) g_pfnWSAEnumNetworkEvents = NULL; 105 /** WSASend */ 106 DECLHIDDEN(PFNWSASend) g_pfnWSASend = NULL; 107 /** socket */ 108 DECLHIDDEN(PFNWINSOCKSOCKET) g_pfnsocket = NULL; 109 /** closesocket */ 110 DECLHIDDEN(PFNWINSOCKCLOSESOCKET) g_pfnclosesocket = NULL; 111 /** recv */ 112 DECLHIDDEN(PFNWINSOCKRECV) g_pfnrecv = NULL; 113 /** send */ 114 DECLHIDDEN(PFNWINSOCKSEND) g_pfnsend = NULL; 115 /** recvfrom */ 116 DECLHIDDEN(PFNWINSOCKRECVFROM) g_pfnrecvfrom = NULL; 117 /** sendto */ 118 DECLHIDDEN(PFNWINSOCKSENDTO) g_pfnsendto = NULL; 119 /** bind */ 120 DECLHIDDEN(PFNWINSOCKBIND) g_pfnbind = NULL; 121 /** listen */ 122 DECLHIDDEN(PFNWINSOCKLISTEN) g_pfnlisten = NULL; 123 /** accept */ 124 DECLHIDDEN(PFNWINSOCKACCEPT) g_pfnaccept = NULL; 125 /** connect */ 126 DECLHIDDEN(PFNWINSOCKCONNECT) g_pfnconnect = NULL; 127 /** shutdown */ 128 DECLHIDDEN(PFNWINSOCKSHUTDOWN) g_pfnshutdown = NULL; 129 /** getsockopt */ 130 DECLHIDDEN(PFNWINSOCKGETSOCKOPT) g_pfngetsockopt = NULL; 131 /** setsockopt */ 132 DECLHIDDEN(PFNWINSOCKSETSOCKOPT) g_pfnsetsockopt = NULL; 133 /** ioctlsocket */ 134 DECLHIDDEN(PFNWINSOCKIOCTLSOCKET) g_pfnioctlsocket = NULL; 135 /** getpeername */ 136 DECLHIDDEN(PFNWINSOCKGETPEERNAME) g_pfngetpeername = NULL; 137 /** getsockname */ 138 DECLHIDDEN(PFNWINSOCKGETSOCKNAME) g_pfngetsockname = NULL; 139 /** __WSAFDIsSet */ 140 DECLHIDDEN(PFNWINSOCK__WSAFDISSET) g_pfn__WSAFDIsSet = NULL; 141 /** select */ 142 DECLHIDDEN(PFNWINSOCKSELECT) g_pfnselect = NULL; 143 /** gethostbyname */ 144 DECLHIDDEN(PFNWINSOCKGETHOSTBYNAME) g_pfngethostbyname = NULL; 77 145 78 146 … … 153 221 { 154 222 if ( dwMajorVersion == 3 223 && dwMinorVersion == 1) 224 enmVer = kRTWinOSType_NT31; 225 else if ( dwMajorVersion == 3 155 226 && dwMinorVersion == 51) 156 227 enmVer = kRTWinOSType_NT351; … … 271 342 272 343 344 /** 345 * Resolves the winsock error APIs. 346 */ 347 static void rtR3InitWinSockApis(void) 348 { 349 /* 350 * Try get ws2_32.dll, then try load it, then finally fall back to the old 351 * wsock32.dll. We use RTLdrLoadSystem to the loading as it has all the fancy 352 * logic for safely doing that. 353 */ 354 g_hModWinSock = GetModuleHandleW(L"ws2_32.dll"); 355 if (g_hModWinSock == NULL) 356 { 357 RTLDRMOD hLdrMod; 358 int rc = RTLdrLoadSystem("ws2_32.dll", true /*fNoUnload*/, &hLdrMod); 359 if (RT_FAILURE(rc)) 360 { 361 rc = RTLdrLoadSystem("wsock32.dll", true /*fNoUnload*/, &hLdrMod); 362 if (RT_FAILURE(rc)) 363 { 364 AssertMsgFailed(("rc=%Rrc\n", rc)); 365 return; 366 } 367 g_fOldWinSock = true; 368 } 369 g_hModWinSock = (HMODULE)RTLdrGetNativeHandle(hLdrMod); 370 RTLdrClose(hLdrMod); 371 } 372 RTAssertMsg2("g_hModWinSock=%p\n", g_hModWinSock); 373 374 g_pfnWSAStartup = (decltype(g_pfnWSAStartup)) GetProcAddress(g_hModWinSock, "WSAStartup"); 375 g_pfnWSACleanup = (decltype(g_pfnWSACleanup)) GetProcAddress(g_hModWinSock, "WSACleanup"); 376 g_pfnWSAGetLastError = (decltype(g_pfnWSAGetLastError)) GetProcAddress(g_hModWinSock, "WSAGetLastError"); 377 g_pfnWSASetLastError = (decltype(g_pfnWSASetLastError)) GetProcAddress(g_hModWinSock, "WSASetLastError"); 378 g_pfnWSACreateEvent = (decltype(g_pfnWSACreateEvent)) GetProcAddress(g_hModWinSock, "WSACreateEvent"); 379 g_pfnWSACloseEvent = (decltype(g_pfnWSACloseEvent)) GetProcAddress(g_hModWinSock, "WSACloseEvent"); 380 g_pfnWSAEventSelect = (decltype(g_pfnWSAEventSelect)) GetProcAddress(g_hModWinSock, "WSAEventSelect"); 381 g_pfnWSAEnumNetworkEvents = (decltype(g_pfnWSAEnumNetworkEvents))GetProcAddress(g_hModWinSock,"WSAEnumNetworkEvents"); 382 g_pfnWSASend = (decltype(g_pfnWSASend)) GetProcAddress(g_hModWinSock, "WSASend"); 383 g_pfnsocket = (decltype(g_pfnsocket)) GetProcAddress(g_hModWinSock, "socket"); 384 g_pfnclosesocket = (decltype(g_pfnclosesocket)) GetProcAddress(g_hModWinSock, "closesocket"); 385 g_pfnrecv = (decltype(g_pfnrecv)) GetProcAddress(g_hModWinSock, "recv"); 386 g_pfnsend = (decltype(g_pfnsend)) GetProcAddress(g_hModWinSock, "send"); 387 g_pfnrecvfrom = (decltype(g_pfnrecvfrom)) GetProcAddress(g_hModWinSock, "recvfrom"); 388 g_pfnsendto = (decltype(g_pfnsendto)) GetProcAddress(g_hModWinSock, "sendto"); 389 g_pfnbind = (decltype(g_pfnbind)) GetProcAddress(g_hModWinSock, "bind"); 390 g_pfnlisten = (decltype(g_pfnlisten)) GetProcAddress(g_hModWinSock, "listen"); 391 g_pfnaccept = (decltype(g_pfnaccept)) GetProcAddress(g_hModWinSock, "accept"); 392 g_pfnconnect = (decltype(g_pfnconnect)) GetProcAddress(g_hModWinSock, "connect"); 393 g_pfnshutdown = (decltype(g_pfnshutdown)) GetProcAddress(g_hModWinSock, "shutdown"); 394 g_pfngetsockopt = (decltype(g_pfngetsockopt)) GetProcAddress(g_hModWinSock, "getsockopt"); 395 g_pfnsetsockopt = (decltype(g_pfnsetsockopt)) GetProcAddress(g_hModWinSock, "setsockopt"); 396 g_pfnioctlsocket = (decltype(g_pfnioctlsocket)) GetProcAddress(g_hModWinSock, "ioctlsocket"); 397 g_pfngetpeername = (decltype(g_pfngetpeername)) GetProcAddress(g_hModWinSock, "getpeername"); 398 g_pfngetsockname = (decltype(g_pfngetsockname)) GetProcAddress(g_hModWinSock, "getsockname"); 399 g_pfn__WSAFDIsSet = (decltype(g_pfn__WSAFDIsSet)) GetProcAddress(g_hModWinSock, "__WSAFDIsSet"); 400 g_pfnselect = (decltype(g_pfnselect)) GetProcAddress(g_hModWinSock, "select"); 401 g_pfngethostbyname = (decltype(g_pfngethostbyname)) GetProcAddress(g_hModWinSock, "gethostbyname"); 402 403 Assert(g_pfnWSAStartup); 404 Assert(g_pfnWSACleanup); 405 Assert(g_pfnWSAGetLastError); 406 Assert(g_pfnWSASetLastError); 407 Assert(g_pfnWSACreateEvent || g_fOldWinSock); 408 Assert(g_pfnWSACloseEvent || g_fOldWinSock); 409 Assert(g_pfnWSAEventSelect || g_fOldWinSock); 410 Assert(g_pfnWSAEnumNetworkEvents || g_fOldWinSock); 411 Assert(g_pfnWSASend || g_fOldWinSock); 412 Assert(g_pfnsocket); 413 Assert(g_pfnclosesocket); 414 Assert(g_pfnrecv); 415 Assert(g_pfnsend); 416 Assert(g_pfnrecvfrom); 417 Assert(g_pfnsendto); 418 Assert(g_pfnbind); 419 Assert(g_pfnlisten); 420 Assert(g_pfnaccept); 421 Assert(g_pfnconnect); 422 Assert(g_pfnshutdown); 423 Assert(g_pfngetsockopt); 424 Assert(g_pfnsetsockopt); 425 Assert(g_pfnioctlsocket); 426 Assert(g_pfngetpeername); 427 Assert(g_pfngetsockname); 428 Assert(g_pfn__WSAFDIsSet); 429 Assert(g_pfnselect); 430 Assert(g_pfngethostbyname); 431 } 432 433 273 434 static int rtR3InitNativeObtrusiveWorker(uint32_t fFlags) 274 435 { … … 362 523 if (g_pfnGetSystemWindowsDirectoryW) 363 524 g_pfnGetSystemWindowsDirectoryW = (PFNGETWINSYSDIR)GetProcAddress(g_hModKernel32, "GetWindowsDirectoryW"); 525 526 /* 527 * Resolve some ntdll.dll APIs that weren't there in early NT versions. 528 */ 529 g_pfnNtQueryFullAttributesFile = (PFNNTQUERYFULLATTRIBUTESFILE)GetProcAddress(g_hModNtDll, "NtQueryFullAttributesFile"); 530 g_pfnNtDuplicateToken = (PFNNTDUPLICATETOKEN)GetProcAddress( g_hModNtDll, "NtDuplicateToken"); 531 532 /* 533 * Resolve the winsock error getter and setter so assertions can save those too. 534 */ 535 rtR3InitWinSockApis(); 364 536 365 537 return rc; -
trunk/src/VBox/Runtime/r3/win/internal-r3-win.h
r69111 r70195 98 98 extern DECLHIDDEN(HMODULE) g_hModKernel32; 99 99 extern DECLHIDDEN(HMODULE) g_hModNtDll; 100 100 101 extern DECLHIDDEN(OSVERSIONINFOEXW) g_WinOsInfoEx; 101 102 typedef UINT (WINAPI *PFNGETWINSYSDIR)(LPWSTR,UINT); 102 103 extern DECLHIDDEN(PFNGETWINSYSDIR) g_pfnGetSystemWindowsDirectoryW; 104 typedef NTSTATUS (NTAPI *PFNNTQUERYFULLATTRIBUTESFILE)(struct _OBJECT_ATTRIBUTES *, struct _FILE_NETWORK_OPEN_INFORMATION *); 105 extern DECLHIDDEN(PFNNTQUERYFULLATTRIBUTESFILE) g_pfnNtQueryFullAttributesFile; 106 typedef NTSTATUS (NTAPI *PFNNTDUPLICATETOKEN)(HANDLE, ACCESS_MASK, struct _OBJECT_ATTRIBUTES *, BOOLEAN, TOKEN_TYPE, PHANDLE); 107 extern DECLHIDDEN(PFNNTDUPLICATETOKEN) g_pfnNtDuplicateToken; 108 109 extern DECLHIDDEN(HMODULE) g_hModWinSock; 110 111 /** WSAStartup */ 112 typedef int (WINAPI *PFNWSASTARTUP)(WORD, struct WSAData *); 113 /** WSACleanup */ 114 typedef int (WINAPI *PFNWSACLEANUP)(void); 115 /** WSAGetLastError */ 116 typedef int (WINAPI *PFNWSAGETLASTERROR)(void); 117 /** WSASetLastError */ 118 typedef int (WINAPI *PFNWSASETLASTERROR)(int); 119 /** WSACreateEvent */ 120 typedef HANDLE (WINAPI *PFNWSACREATEEVENT)(void); 121 /** WSACloseEvent */ 122 typedef BOOL (WINAPI *PFNWSACLOSEEVENT)(HANDLE); 123 /** WSAEventSelect */ 124 typedef BOOL (WINAPI *PFNWSAEVENTSELECT)(UINT_PTR, HANDLE, LONG); 125 /** WSAEnumNetworkEvents */ 126 typedef int (WINAPI *PFNWSAENUMNETWORKEVENTS)(UINT_PTR, HANDLE, struct _WSANETWORKEVENTS *); 127 /** WSASend */ 128 typedef int (WINAPI *PFNWSASend)(UINT_PTR, struct _WSABUF *, DWORD, LPDWORD, DWORD dwFlags, struct _OVERLAPPED *, PFNRT /*LPWSAOVERLAPPED_COMPLETION_ROUTINE*/); 129 130 /** socket */ 131 typedef UINT_PTR (WINAPI *PFNWINSOCKSOCKET)(int, int, int); 132 /** closesocket */ 133 typedef int (WINAPI *PFNWINSOCKCLOSESOCKET)(UINT_PTR); 134 /** recv */ 135 typedef int (WINAPI *PFNWINSOCKRECV)(UINT_PTR, char *, int, int); 136 /** send */ 137 typedef int (WINAPI *PFNWINSOCKSEND)(UINT_PTR, const char *, int, int); 138 /** recvfrom */ 139 typedef int (WINAPI *PFNWINSOCKRECVFROM)(UINT_PTR, char *, int, int, struct sockaddr *, int *); 140 /** sendto */ 141 typedef int (WINAPI *PFNWINSOCKSENDTO)(UINT_PTR, const char *, int, int, const struct sockaddr *, int); 142 /** bind */ 143 typedef int (WINAPI *PFNWINSOCKBIND)(UINT_PTR, const struct sockaddr *, int); 144 /** listen */ 145 typedef int (WINAPI *PFNWINSOCKLISTEN)(UINT_PTR, int); 146 /** accept */ 147 typedef UINT_PTR (WINAPI *PFNWINSOCKACCEPT)(UINT_PTR, struct sockaddr *, int *); 148 /** connect */ 149 typedef int (WINAPI *PFNWINSOCKCONNECT)(UINT_PTR, const struct sockaddr *, int); 150 /** shutdown */ 151 typedef int (WINAPI *PFNWINSOCKSHUTDOWN)(UINT_PTR, int); 152 /** getsockopt */ 153 typedef int (WINAPI *PFNWINSOCKGETSOCKOPT)(UINT_PTR, int, int, char *, int *); 154 /** setsockopt */ 155 typedef int (WINAPI *PFNWINSOCKSETSOCKOPT)(UINT_PTR, int, int, const char *, int); 156 /** ioctlsocket */ 157 typedef int (WINAPI *PFNWINSOCKIOCTLSOCKET)(UINT_PTR, long, unsigned long *); 158 /** getpeername */ 159 typedef int (WINAPI *PFNWINSOCKGETPEERNAME)(UINT_PTR, struct sockaddr *, int *); 160 /** getsockname */ 161 typedef int (WINAPI *PFNWINSOCKGETSOCKNAME)(UINT_PTR, struct sockaddr *, int *); 162 /** __WSAFDIsSet */ 163 typedef int (WINAPI *PFNWINSOCK__WSAFDISSET)(UINT_PTR, struct fd_set *); 164 /** select */ 165 typedef int (WINAPI *PFNWINSOCKSELECT)(int, struct fd_set *, struct fd_set *, struct fd_set *, const struct timeval *); 166 /** gethostbyname */ 167 typedef struct hostent *(WINAPI *PFNWINSOCKGETHOSTBYNAME)(const char *); 168 169 extern DECLHIDDEN(PFNWSASTARTUP) g_pfnWSAStartup; 170 extern DECLHIDDEN(PFNWSACLEANUP) g_pfnWSACleanup; 171 extern PFNWSAGETLASTERROR g_pfnWSAGetLastError; 172 extern PFNWSASETLASTERROR g_pfnWSASetLastError; 173 extern DECLHIDDEN(PFNWSACREATEEVENT) g_pfnWSACreateEvent; 174 extern DECLHIDDEN(PFNWSACLOSEEVENT) g_pfnWSACloseEvent; 175 extern DECLHIDDEN(PFNWSAEVENTSELECT) g_pfnWSAEventSelect; 176 extern DECLHIDDEN(PFNWSAENUMNETWORKEVENTS) g_pfnWSAEnumNetworkEvents; 177 extern DECLHIDDEN(PFNWSASend) g_pfnWSASend; 178 extern DECLHIDDEN(PFNWINSOCKSOCKET) g_pfnsocket; 179 extern DECLHIDDEN(PFNWINSOCKCLOSESOCKET) g_pfnclosesocket; 180 extern DECLHIDDEN(PFNWINSOCKRECV) g_pfnrecv; 181 extern DECLHIDDEN(PFNWINSOCKSEND) g_pfnsend; 182 extern DECLHIDDEN(PFNWINSOCKRECVFROM) g_pfnrecvfrom; 183 extern DECLHIDDEN(PFNWINSOCKSENDTO) g_pfnsendto; 184 extern DECLHIDDEN(PFNWINSOCKBIND) g_pfnbind; 185 extern DECLHIDDEN(PFNWINSOCKLISTEN) g_pfnlisten; 186 extern DECLHIDDEN(PFNWINSOCKACCEPT) g_pfnaccept; 187 extern DECLHIDDEN(PFNWINSOCKCONNECT) g_pfnconnect; 188 extern DECLHIDDEN(PFNWINSOCKSHUTDOWN) g_pfnshutdown; 189 extern DECLHIDDEN(PFNWINSOCKGETSOCKOPT) g_pfngetsockopt; 190 extern DECLHIDDEN(PFNWINSOCKSETSOCKOPT) g_pfnsetsockopt; 191 extern DECLHIDDEN(PFNWINSOCKIOCTLSOCKET) g_pfnioctlsocket; 192 extern DECLHIDDEN(PFNWINSOCKGETPEERNAME) g_pfngetpeername; 193 extern DECLHIDDEN(PFNWINSOCKGETSOCKNAME) g_pfngetsockname; 194 extern DECLHIDDEN(PFNWINSOCK__WSAFDISSET) g_pfn__WSAFDIsSet; 195 extern DECLHIDDEN(PFNWINSOCKSELECT) g_pfnselect; 196 extern DECLHIDDEN(PFNWINSOCKGETHOSTBYNAME) g_pfngethostbyname; 103 197 #endif 104 198 -
trunk/src/VBox/Runtime/r3/win/process-win.cpp
r70172 r70195 428 428 && EqualSid(pTokenUser->User.Sid, pSid)) 429 429 { 430 if (DuplicateTokenEx(hTokenProc, MAXIMUM_ALLOWED, 431 NULL, SecurityIdentification, TokenPrimary, phToken)) 430 /* 431 * The following NT call is for v3.51 and does the equivalent of: 432 * DuplicateTokenEx(hTokenProc, MAXIMUM_ALLOWED, NULL, 433 * SecurityIdentification, TokenPrimary, phToken); 434 */ 435 if (g_pfnNtDuplicateToken) 432 436 { 433 /* 434 * So we found the process instance which belongs to the user we want to 435 * to run our new process under. This duplicated token will be used for 436 * the actual CreateProcessAsUserW() call then. 437 */ 438 rc = VINF_SUCCESS; 437 SECURITY_QUALITY_OF_SERVICE SecQoS; 438 SecQoS.Length = sizeof(SecQoS); 439 SecQoS.ImpersonationLevel = SecurityIdentification; 440 SecQoS.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING; 441 SecQoS.EffectiveOnly = FALSE; 442 443 OBJECT_ATTRIBUTES ObjAttr; 444 InitializeObjectAttributes(&ObjAttr, NULL /*Name*/, 0 /*OBJ_XXX*/, NULL /*Root*/, NULL /*SecDesc*/); 445 ObjAttr.SecurityQualityOfService = &SecQoS; 446 447 NTSTATUS rcNt = g_pfnNtDuplicateToken(hTokenProc, MAXIMUM_ALLOWED, &ObjAttr, FALSE, 448 TokenPrimary, phToken); 449 if (NT_SUCCESS(rcNt)) 450 { 451 /* 452 * So we found the process instance which belongs to the user we want to 453 * to run our new process under. This duplicated token will be used for 454 * the actual CreateProcessAsUserW() call then. 455 */ 456 rc = VINF_SUCCESS; 457 } 458 else 459 rc = RTErrConvertFromNtStatus(rcNt); 460 439 461 } 440 462 else 441 rc = RTErrConvertFromWin32(GetLastError());463 rc = VERR_SYMBOL_NOT_FOUND; /** @todo do we really need to duplicate the token? */ 442 464 } 443 465 else -
trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakes.cpp
r69111 r70195 29 29 * Header Files * 30 30 *********************************************************************************************************************************/ 31 #define RT_NO_STRICT /* Minimal deps so that it works on NT 3.51 too. */ 31 32 #include <iprt/cdefs.h> 32 33 #include <iprt/types.h> 33 34 #include <iprt/asm.h> 35 #include <iprt/assert.h> 34 36 #include <iprt/string.h> 35 37 … … 53 55 #define VerifyVersionInfoA Ignore_VerifyVersionInfoA 54 56 #define VerSetConditionMask Ignore_VerSetConditionMask 55 56 #include <iprt/win/windows.h> 57 #define IsProcessorFeaturePresent Ignore_IsProcessorFeaturePresent /* NT 3.51 start */ 58 #define CancelIo Ignore_CancelIo 59 60 #include <iprt/nt/nt-and-windows.h> 57 61 58 62 #undef DecodePointer … … 71 75 #undef VerifyVersionInfoA 72 76 #undef VerSetConditionMask 77 #undef IsProcessorFeaturePresent 78 #undef CancelIo 73 79 74 80 … … 90 96 s_pfnApi = pfnApi; \ 91 97 s_fInitialized = true; \ 92 } do {} while (0) \ 98 } do {} while (0) 99 100 101 /** Dynamically resolves an NTDLL API we need. */ 102 #define RESOLVE_NTDLL_API(ApiNm) \ 103 static bool volatile s_fInitialized##ApiNm = false; \ 104 static decltype(ApiNm) *s_pfn##ApiNm = NULL; \ 105 decltype(ApiNm) *pfn##ApiNm; \ 106 if (!s_fInitialized##ApiNm) \ 107 pfn##ApiNm = s_pfn##ApiNm; \ 108 else \ 109 { \ 110 pfn##ApiNm = (decltype(pfn##ApiNm))GetProcAddress(GetModuleHandleW(L"ntdll"), #ApiNm); \ 111 s_pfn##ApiNm = pfn##ApiNm; \ 112 s_fInitialized##ApiNm = true; \ 113 } do {} while (0) 93 114 94 115 … … 401 422 } 402 423 424 403 425 extern "C" 404 426 __declspec(dllexport) … … 422 444 423 445 446 /* 447 * NT 3.51 stuff. 448 */ 449 450 extern "C" DECLEXPORT(BOOL) WINAPI IsProcessorFeaturePresent(DWORD enmProcessorFeature) 451 { 452 RESOLVE_ME(IsProcessorFeaturePresent); 453 if (pfnApi) 454 return pfnApi(enmProcessorFeature); 455 456 /* Could make more of an effort here... */ 457 return FALSE; 458 } 459 460 461 extern "C" DECLEXPORT(BOOL) WINAPI CancelIo(HANDLE hHandle) 462 { 463 RESOLVE_ME(CancelIo); 464 if (pfnApi) 465 return pfnApi(hHandle); 466 467 /* NT 3.51 have the NTDLL API this corresponds to. */ 468 RESOLVE_NTDLL_API(NtCancelIoFile); 469 if (pfnNtCancelIoFile) 470 { 471 IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER; 472 NTSTATUS rcNt = pfnNtCancelIoFile(hHandle, &Ios); 473 if (RT_SUCCESS(rcNt)) 474 return TRUE; 475 if (rcNt == STATUS_INVALID_HANDLE) 476 SetLastError(ERROR_INVALID_HANDLE); 477 else 478 SetLastError(ERROR_INVALID_FUNCTION); 479 } 480 else 481 SetLastError(ERROR_NOT_SUPPORTED); 482 return FALSE; 483 } 484 424 485 425 486 /* Dummy to force dragging in this object in the link, so the linker -
trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakesA.asm
r69434 r70195 60 60 MAKE_IMPORT_ENTRY VerifyVersionInfoA, 16 61 61 MAKE_IMPORT_ENTRY VerSetConditionMask, 16 62 MAKE_IMPORT_ENTRY IsProcessorFeaturePresent, 4 63 MAKE_IMPORT_ENTRY CancelIo, 4 62 64
Note:
See TracChangeset
for help on using the changeset viewer.