Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

943 lines
23 KiB

  1. /*****************************************************************************\
  2. * MODULE: inetwrap.c
  3. *
  4. * This module contains wrapper routines to translate internet calls from
  5. * Unicode to Ansi. This is necessary right now since the WININET routines
  6. * do not support Unicode for Windows NT.
  7. *
  8. *
  9. * Copyright (C) 1996-1997 Microsoft Corporation
  10. * Copyright (C) 1996-1997 Hewlett Packard
  11. *
  12. * History:
  13. * 07-Oct-1996 HWP-Guys Initiated port from win95 to winNT
  14. * 15-Jul-1998 v-chrisw Allow safe DelayLoad of wininet.
  15. *
  16. \*****************************************************************************/
  17. #include "precomp.h"
  18. #include "priv.h"
  19. /*****************************************************************************\
  20. * wrapInternetOpen
  21. *
  22. *
  23. \*****************************************************************************/
  24. HINTERNET wrapInternetOpen(
  25. LPCTSTR lpszAgent,
  26. DWORD dwAccess,
  27. LPCTSTR lpszProxyName,
  28. LPCTSTR lpszProxyBypass,
  29. DWORD dwFlags)
  30. {
  31. HINTERNET hRet = NULL;
  32. #ifdef UNICODE
  33. UINT uSize;
  34. LPSTR lpszAnsiAgent = NULL;
  35. LPSTR lpszAnsiProxyName = NULL;
  36. LPSTR lpszAnsiProxyBypass = NULL;
  37. BOOL bRet = TRUE;
  38. if (lpszAgent && (uSize = WCtoMB(lpszAgent, NULL, 0))) {
  39. if (lpszAnsiAgent = new CHAR[uSize])
  40. bRet = WCtoMB(lpszAgent, lpszAnsiAgent, uSize);
  41. else
  42. bRet = FALSE;
  43. }
  44. if (bRet && lpszProxyName && (uSize = WCtoMB(lpszProxyName, NULL, 0))) {
  45. if (lpszAnsiProxyName = new CHAR[uSize])
  46. bRet = WCtoMB(lpszProxyName, lpszAnsiProxyName, uSize);
  47. else
  48. bRet = FALSE;
  49. }
  50. if (bRet && lpszProxyBypass && (uSize = WCtoMB(lpszProxyBypass, NULL, 0))) {
  51. if (lpszAnsiProxyBypass = new CHAR[uSize])
  52. bRet = WCtoMB(lpszProxyBypass, lpszAnsiProxyBypass, uSize);
  53. else
  54. bRet = FALSE;
  55. }
  56. if (bRet) {
  57. __try {
  58. hRet = g_pfnInternetOpen((LPCTSTR)lpszAnsiAgent,
  59. dwAccess,
  60. (LPCTSTR)lpszAnsiProxyName,
  61. (LPCTSTR)lpszAnsiProxyBypass,
  62. dwFlags);
  63. } __except(1) {
  64. DBG_ASSERT(FALSE, (TEXT("inetwrap : InternetOpen exception!")));
  65. hRet = NULL;
  66. }
  67. }
  68. if (lpszAnsiAgent)
  69. delete [](lpszAnsiAgent);
  70. if (lpszAnsiProxyName)
  71. delete [](lpszAnsiProxyName);
  72. if (lpszAnsiProxyBypass)
  73. delete [](lpszAnsiProxyBypass);
  74. #else
  75. __try {
  76. hRet = g_pfnInternetOpen(lpszAgent,
  77. dwAccess,
  78. lpszProxyName,
  79. lpszProxyBypass,
  80. dwFlags);
  81. } __except(1) {
  82. DBG_ASSERT(FALSE, (TEXT("inetwrap : InternetOpen exception!")));
  83. hRet = NULL;
  84. }
  85. #endif
  86. return hRet;
  87. }
  88. /*****************************************************************************\
  89. * wrapInternetOpenUrl
  90. *
  91. *
  92. \*****************************************************************************/
  93. HINTERNET wrapInternetOpenUrl(
  94. HINTERNET hInternet,
  95. LPCTSTR lpszUrl,
  96. LPCTSTR lpszHeaders,
  97. DWORD dwHeaderLen,
  98. DWORD dwFlags,
  99. DWORD_PTR dwContext)
  100. {
  101. HINTERNET hRet = NULL;
  102. #ifdef UNICODE
  103. UINT uSize;
  104. LPSTR lpszAnsiUrl = NULL;
  105. LPSTR lpszAnsiHeaders = NULL;
  106. BOOL bRet = TRUE;
  107. if (lpszUrl && (uSize = WCtoMB(lpszUrl, NULL, 0))) {
  108. if (lpszAnsiUrl = new CHAR[uSize])
  109. bRet = WCtoMB(lpszUrl, lpszAnsiUrl, uSize);
  110. else
  111. bRet = FALSE;
  112. }
  113. if (bRet && lpszHeaders && (uSize = WCtoMB(lpszHeaders, NULL, 0))) {
  114. if (lpszAnsiHeaders = new CHAR[uSize])
  115. bRet = WCtoMB(lpszHeaders, lpszAnsiHeaders, uSize);
  116. else
  117. bRet = FALSE;
  118. }
  119. if (bRet) {
  120. __try {
  121. hRet = g_pfnInternetOpenUrl(hInternet,
  122. (LPCTSTR)lpszAnsiUrl,
  123. (LPCTSTR)lpszAnsiHeaders,
  124. dwHeaderLen,
  125. dwFlags,
  126. dwContext);
  127. } __except(1) {
  128. DBG_ASSERT(FALSE, (TEXT("inetwrap : InternetOpenUrl exception!")));
  129. hRet = NULL;
  130. }
  131. }
  132. if (lpszAnsiUrl)
  133. delete [](lpszAnsiUrl);
  134. if (lpszAnsiHeaders)
  135. delete [](lpszAnsiHeaders);
  136. #else
  137. __try {
  138. hRet = g_pfnInternetOpenUrl(hInternet,
  139. lpszUrl,
  140. lpszHeaders,
  141. dwHeaderLen,
  142. dwFlags,
  143. dwContext);
  144. } __except(1) {
  145. DBG_ASSERT(FALSE, (TEXT("inetwrap : InternetOpenUrl exception!")));
  146. hRet = NULL;
  147. }
  148. #endif
  149. return hRet;
  150. }
  151. /*****************************************************************************\
  152. * wrapInternetConnect
  153. *
  154. *
  155. \*****************************************************************************/
  156. HINTERNET wrapInternetConnect(
  157. HINTERNET hSession,
  158. LPCTSTR lpszServerName,
  159. INTERNET_PORT nServerPort,
  160. LPCTSTR lpszUserName,
  161. LPCTSTR lpszPassword,
  162. DWORD dwService,
  163. DWORD dwFlags,
  164. DWORD_PTR dwContext)
  165. {
  166. HINTERNET hRet = NULL;
  167. #ifdef UNICODE
  168. UINT uSize;
  169. LPSTR lpszAnsiServerName = NULL;
  170. LPSTR lpszAnsiUserName = NULL;
  171. LPSTR lpszAnsiPassword = NULL;
  172. BOOL bRet = TRUE;
  173. if (lpszServerName && (uSize = WCtoMB(lpszServerName, NULL, 0))) {
  174. if (lpszAnsiServerName = new CHAR[uSize])
  175. bRet = WCtoMB(lpszServerName, lpszAnsiServerName, uSize);
  176. else
  177. bRet = FALSE;
  178. }
  179. if (bRet && lpszUserName && (uSize = WCtoMB(lpszUserName, NULL, 0))) {
  180. if (lpszAnsiUserName = new CHAR[uSize])
  181. bRet = WCtoMB(lpszUserName, lpszAnsiUserName, uSize);
  182. else
  183. bRet = FALSE;
  184. }
  185. if (bRet && lpszPassword && (uSize = WCtoMB(lpszPassword, NULL, 0))) {
  186. if (lpszAnsiPassword = new CHAR[uSize])
  187. bRet = WCtoMB(lpszPassword, lpszAnsiPassword, uSize);
  188. else
  189. bRet = FALSE;
  190. }
  191. if (bRet) {
  192. __try {
  193. hRet = g_pfnInternetConnect(hSession,
  194. (LPCTSTR)lpszAnsiServerName,
  195. nServerPort,
  196. (LPCTSTR)lpszAnsiUserName,
  197. (LPCTSTR)lpszAnsiPassword,
  198. dwService,
  199. dwFlags,
  200. dwContext);
  201. } __except(1) {
  202. DBG_ASSERT(FALSE, (TEXT("inetwrap : InternetConnect exception!")));
  203. hRet = NULL;
  204. }
  205. }
  206. if (lpszAnsiServerName)
  207. delete [](lpszAnsiServerName);
  208. if (lpszAnsiUserName)
  209. delete [](lpszAnsiUserName);
  210. if (lpszAnsiPassword)
  211. delete [](lpszAnsiPassword);
  212. #else
  213. __try {
  214. hRet = g_pfnInternetConnect(hSession,
  215. lpszServerName,
  216. nServerPort,
  217. lpszUserName,
  218. lpszPassword,
  219. dwService,
  220. dwFlags,
  221. dwContext);
  222. } __except(1) {
  223. DBG_ASSERT(FALSE, (TEXT("inetwrap : InternetConnect exception!")));
  224. hRet = NULL;
  225. }
  226. #endif
  227. return hRet;
  228. }
  229. /*****************************************************************************\
  230. * wrapHttpQueryInfo
  231. *
  232. *
  233. \*****************************************************************************/
  234. BOOL wrapHttpQueryInfo(
  235. HINTERNET hRequest,
  236. DWORD dwInfoLevel,
  237. LPVOID lpvBuffer,
  238. LPDWORD lpdwBufferLen,
  239. LPDWORD lpdwIndex)
  240. {
  241. BOOL bRet;
  242. __try {
  243. bRet = g_pfnHttpQueryInfo(hRequest,
  244. dwInfoLevel,
  245. lpvBuffer,
  246. lpdwBufferLen,
  247. lpdwIndex);
  248. } __except(1) {
  249. DBG_ASSERT(FALSE, (TEXT("inetwrap : HttpQueryInfo exception!")));
  250. bRet = FALSE;
  251. }
  252. return bRet;
  253. }
  254. /*****************************************************************************\
  255. * wrapHttpSendRequest
  256. *
  257. *
  258. \*****************************************************************************/
  259. BOOL wrapHttpSendRequest(
  260. HINTERNET hRequest,
  261. LPCTSTR lpszHeaders,
  262. DWORD dwHeaderLen,
  263. LPVOID lpvOptional,
  264. DWORD dwOptionalLen)
  265. {
  266. BOOL bRet = TRUE;
  267. #ifdef UNICODE
  268. UINT uSize;
  269. LPSTR lpszAnsiHeaders = NULL;
  270. if (lpszHeaders && (uSize = WCtoMB(lpszHeaders, NULL, 0))) {
  271. if (lpszAnsiHeaders = new CHAR[uSize])
  272. bRet = WCtoMB(lpszHeaders, lpszAnsiHeaders, uSize);
  273. else
  274. bRet = FALSE;
  275. }
  276. if (bRet) {
  277. __try {
  278. bRet = g_pfnHttpSendRequest(hRequest,
  279. (LPCTSTR)lpszAnsiHeaders,
  280. dwHeaderLen,
  281. lpvOptional,
  282. dwOptionalLen);
  283. } __except(1) {
  284. DBG_ASSERT(FALSE, (TEXT("inetwrap : HttpSendRequest exception!")));
  285. bRet = FALSE;
  286. }
  287. }
  288. if (lpszAnsiHeaders)
  289. delete [](lpszAnsiHeaders);
  290. #else
  291. __try {
  292. bRet = g_pfnHttpSendRequest(hRequest,
  293. lpszHeaders,
  294. dwHeaderLen,
  295. lpvOptional,
  296. dwOptionalLen);
  297. } __except(1) {
  298. DBG_ASSERT(FALSE, (TEXT("inetwrap : HttpSendRequest exception!")));
  299. bRet = FALSE;
  300. }
  301. #endif
  302. return bRet;
  303. }
  304. /*****************************************************************************\
  305. * wrapHttpSendRequestEx
  306. *
  307. *
  308. \*****************************************************************************/
  309. BOOL wrapHttpSendRequestEx(
  310. HINTERNET hRequest,
  311. LPINTERNET_BUFFERS lpBufIn,
  312. LPINTERNET_BUFFERS lpBufOut,
  313. DWORD dwFlags,
  314. DWORD_PTR dwContext)
  315. {
  316. BOOL bRet = TRUE;
  317. // NOTE : This now works for Header values defined in lpBufIn and lpBufOut, we assume that
  318. // the "size" of the header in the structure is not set by the calling routine, if it is we
  319. // overwrite the size when we convert it....
  320. //
  321. // NOTE2: We do not support linked Buffer Strucures, only 1!!!!!
  322. // NOTE3: We do not support lpBufOut to return values. It must be NULL
  323. #ifdef UNICODE
  324. UINT uSize = 0;
  325. LPSTR lpszAnsiHeaders = NULL;
  326. LPCWSTR lpcszHeader;
  327. INTERNET_BUFFERSA ConvertBuf;
  328. DBG_ASSERT((lpBufOut == NULL) , (TEXT("inetwrap : We do not support output buffers!")));
  329. DBG_ASSERT((lpBufIn->Next == NULL) , (TEXT("inetwrap : We do not support chained input buffers!")));
  330. lpcszHeader = lpBufIn->lpcszHeader;
  331. if (lpcszHeader && (uSize = WCtoMB(lpcszHeader, NULL, 0))) {
  332. if (lpszAnsiHeaders = new CHAR[uSize])
  333. bRet = WCtoMB(lpcszHeader, lpszAnsiHeaders, uSize--);
  334. else
  335. bRet = FALSE;
  336. }
  337. if (bRet) {
  338. ConvertBuf.dwStructSize = sizeof(ConvertBuf);
  339. ConvertBuf.Next = NULL;
  340. ConvertBuf.lpcszHeader = lpszAnsiHeaders;
  341. ConvertBuf.dwHeadersLength = (DWORD)uSize;
  342. ConvertBuf.dwHeadersTotal = lpBufIn->dwHeadersTotal;
  343. ConvertBuf.lpvBuffer = lpBufIn->lpvBuffer;
  344. ConvertBuf.dwBufferLength = lpBufIn->dwBufferLength;
  345. ConvertBuf.dwBufferTotal = lpBufIn->dwBufferTotal;
  346. ConvertBuf.dwOffsetLow = lpBufIn->dwOffsetLow;
  347. ConvertBuf.dwOffsetHigh = lpBufIn->dwOffsetHigh;
  348. __try {
  349. bRet = g_pfnHttpSendRequestEx(hRequest,
  350. &ConvertBuf,
  351. lpBufOut,
  352. dwFlags,
  353. dwContext);
  354. } __except(1) {
  355. DBG_ASSERT(FALSE, (TEXT("inetwrap : HttpSendRequestEx exception!")));
  356. bRet = FALSE;
  357. }
  358. }
  359. if (lpszAnsiHeaders)
  360. delete [](lpszAnsiHeaders);
  361. #else
  362. __try {
  363. bRet = g_pfnHttpSendRequestEx(hRequest,
  364. lpBufIn,
  365. lpBufOut,
  366. dwFlags,
  367. dwContext);
  368. } __except(1) {
  369. DBG_ASSERT(FALSE, (TEXT("inetwrap : HttpSendRequestEx exception!")));
  370. bRet = FALSE;
  371. }
  372. #endif
  373. return bRet;
  374. }
  375. /*****************************************************************************\
  376. * wrapHttpOpenRequest
  377. *
  378. *
  379. \*****************************************************************************/
  380. HINTERNET wrapHttpOpenRequest(
  381. HINTERNET hConnect,
  382. LPCTSTR lpszVerb,
  383. LPCTSTR lpszObjectName,
  384. LPCTSTR lpszVersion,
  385. LPCTSTR lpszReferer,
  386. LPCTSTR *lplpszAccept,
  387. DWORD dwFlags,
  388. DWORD_PTR dwContext)
  389. {
  390. HINTERNET hRet = NULL;
  391. #ifdef UNICODE
  392. UINT uSize;
  393. LPSTR lpszAnsiVerb = NULL;
  394. LPSTR lpszAnsiObjectName = NULL;
  395. LPSTR lpszAnsiVersion = NULL;
  396. LPSTR lpszAnsiReferer = NULL;
  397. BOOL bRet = TRUE;
  398. if (lpszVerb && (uSize = WCtoMB(lpszVerb, NULL, 0))) {
  399. if (lpszAnsiVerb = new CHAR[uSize])
  400. bRet = WCtoMB(lpszVerb, lpszAnsiVerb, uSize);
  401. }
  402. if (bRet && lpszObjectName && (uSize = WCtoMB(lpszObjectName, NULL, 0))) {
  403. if (lpszAnsiObjectName = new CHAR[uSize])
  404. bRet = WCtoMB(lpszObjectName, lpszAnsiObjectName, uSize);
  405. else
  406. bRet = FALSE;
  407. }
  408. if (bRet && lpszVersion && (uSize = WCtoMB(lpszVersion, NULL, 0))) {
  409. if (lpszAnsiVersion = new CHAR[uSize])
  410. bRet = WCtoMB(lpszVersion, lpszAnsiVersion, uSize);
  411. else
  412. bRet = FALSE;
  413. }
  414. if (bRet && lpszReferer && (uSize = WCtoMB(lpszReferer, NULL, 0))) {
  415. if (lpszAnsiReferer = new CHAR[uSize])
  416. bRet = WCtoMB(lpszReferer, lpszAnsiReferer, uSize);
  417. else
  418. bRet = FALSE;
  419. }
  420. if (bRet) {
  421. __try {
  422. hRet = g_pfnHttpOpenRequest(hConnect,
  423. (LPCTSTR)lpszAnsiVerb,
  424. (LPCTSTR)lpszAnsiObjectName,
  425. (LPCTSTR)lpszAnsiVersion,
  426. (LPCTSTR)lpszAnsiReferer,
  427. (LPCTSTR *)lplpszAccept,
  428. dwFlags,
  429. dwContext);
  430. } __except(1) {
  431. DBG_ASSERT(FALSE, (TEXT("inetwrap : HttpOpenRequest exception!")));
  432. hRet = NULL;
  433. }
  434. }
  435. if (lpszAnsiVerb)
  436. delete [](lpszAnsiVerb);
  437. if (lpszAnsiObjectName)
  438. delete [](lpszAnsiObjectName);
  439. if (lpszAnsiVersion)
  440. delete [](lpszAnsiVersion);
  441. if (lpszAnsiReferer)
  442. delete [](lpszAnsiReferer);
  443. #else
  444. __try {
  445. hRet = g_pfnHttpOpenRequest(hConnect,
  446. lpszVerb,
  447. lpszObjectName,
  448. lpszVersion,
  449. lpszReferer,
  450. lplpszAccept,
  451. dwFlags,
  452. dwContext);
  453. } __except(1) {
  454. DBG_ASSERT(FALSE, (TEXT("inetwrap : HttpOpenRequest exception!")));
  455. hRet = NULL;
  456. }
  457. #endif
  458. return hRet;
  459. }
  460. /*****************************************************************************\
  461. * wrapHttpAddRequestHeaders
  462. *
  463. *
  464. \*****************************************************************************/
  465. BOOL wrapHttpAddRequestHeaders(
  466. HINTERNET hRequest,
  467. LPCTSTR lpszHeaders,
  468. DWORD cbLength,
  469. DWORD dwModifiers)
  470. {
  471. BOOL bRet = TRUE;
  472. #ifdef UNICODE
  473. UINT uSize;
  474. LPSTR lpszAnsiHeaders = NULL;
  475. if (lpszHeaders && (uSize = WCtoMB(lpszHeaders, NULL, 0))) {
  476. if (lpszAnsiHeaders = new CHAR[uSize])
  477. WCtoMB(lpszHeaders, lpszAnsiHeaders, uSize);
  478. else
  479. bRet = FALSE;
  480. }
  481. if (bRet) {
  482. __try {
  483. bRet = g_pfnHttpAddRequestHeaders(hRequest,
  484. (LPCTSTR)lpszAnsiHeaders,
  485. cbLength,
  486. dwModifiers);
  487. } __except(1) {
  488. DBG_ASSERT(FALSE, (TEXT("inetwrap : HttpAddRequestHeaders exception!")));
  489. bRet = FALSE;
  490. }
  491. }
  492. if (lpszAnsiHeaders)
  493. delete [](lpszAnsiHeaders);
  494. #else
  495. __try {
  496. bRet = g_pfnHttpAddRequestHeaders(hRequest,
  497. lpszHeaders,
  498. cbLength,
  499. dwModifiers);
  500. } __except(1) {
  501. DBG_ASSERT(FALSE, (TEXT("inetwrap : HttpAdRequestHeaders exception!")));
  502. bRet = FALSE;
  503. }
  504. #endif
  505. return bRet;
  506. }
  507. /*****************************************************************************\
  508. * wrapHttpEndRequest
  509. *
  510. *
  511. \*****************************************************************************/
  512. BOOL wrapHttpEndRequest(
  513. HINTERNET hRequest,
  514. LPINTERNET_BUFFERS lpBuf,
  515. DWORD dwFlags,
  516. DWORD_PTR dwContext)
  517. {
  518. BOOL bRet;
  519. __try {
  520. #ifdef UNICODE
  521. DBG_ASSERT((lpBuf == NULL), (TEXT("Assert: NULL Buffer is only support")));
  522. bRet = g_pfnHttpEndRequest(hRequest, lpBuf, dwFlags, dwContext);
  523. #else
  524. bRet = g_pfnHttpEndRequest(hRequest, lpBuf, dwFlags, dwContext);
  525. #endif
  526. } __except(1) {
  527. DBG_ASSERT(FALSE, (TEXT("inetwrap : HttpOpenRequest exception!")));
  528. bRet = FALSE;
  529. }
  530. return bRet;
  531. }
  532. /*****************************************************************************\
  533. * wrapInternetSetOption
  534. *
  535. *
  536. \*****************************************************************************/
  537. BOOL wrapInternetSetOption(
  538. HINTERNET hRequest,
  539. IN DWORD dwOption,
  540. IN LPVOID lpBuffer,
  541. IN DWORD dwBufferLength)
  542. {
  543. BOOL bRet = TRUE;
  544. #ifdef UNICODE
  545. UINT uSize;
  546. LPSTR lpszAnsiBuffer = NULL;
  547. switch (dwOption) {
  548. case INTERNET_OPTION_USERNAME:
  549. case INTERNET_OPTION_PASSWORD:
  550. case INTERNET_OPTION_PROXY_USERNAME:
  551. case INTERNET_OPTION_PROXY_PASSWORD:
  552. if (lpBuffer && (uSize = WCtoMB(lpBuffer, NULL, 0))) {
  553. if (lpszAnsiBuffer = new CHAR[uSize])
  554. bRet = WCtoMB(lpBuffer, lpszAnsiBuffer, uSize);
  555. else
  556. bRet = FALSE;
  557. }
  558. if (bRet) {
  559. __try {
  560. bRet = g_pfnInternetSetOption(hRequest,
  561. dwOption,
  562. lpszAnsiBuffer,
  563. dwBufferLength);
  564. } __except(1) {
  565. DBG_ASSERT(FALSE, (TEXT("inetwrap : InternetSetOption exception!")));
  566. bRet = FALSE;
  567. }
  568. }
  569. if (lpszAnsiBuffer)
  570. delete [](lpszAnsiBuffer);
  571. break;
  572. default:
  573. __try {
  574. bRet = g_pfnInternetSetOption(hRequest,
  575. dwOption,
  576. lpBuffer,
  577. dwBufferLength);
  578. } __except(1) {
  579. DBG_ASSERT(FALSE, (TEXT("inetwrap : InternetSetOption exception!")));
  580. bRet = FALSE;
  581. }
  582. break;
  583. }
  584. #else
  585. __try {
  586. bRet = g_pfnInternetSetOption(hRequest,
  587. dwOption,
  588. lpBuffer,
  589. dwBufferLength);
  590. } __except(1) {
  591. DBG_ASSERT(FALSE, (TEXT("inetwrap : InternetSetOption exception!")));
  592. bRet = FALSE;
  593. }
  594. #endif
  595. return bRet;
  596. }
  597. /*****************************************************************************\
  598. * wrapInternetCloseHandle
  599. *
  600. *
  601. \*****************************************************************************/
  602. BOOL wrapInternetCloseHandle(
  603. HINTERNET hHandle)
  604. {
  605. BOOL bRet;
  606. __try {
  607. bRet = g_pfnInternetCloseHandle(hHandle);
  608. } __except(1) {
  609. DBG_ASSERT(FALSE, (TEXT("inetwrap : InternetCloseHandle exception!")));
  610. bRet = FALSE;
  611. }
  612. return bRet;
  613. }
  614. /*****************************************************************************\
  615. * wrapInternetReadFile
  616. *
  617. *
  618. \*****************************************************************************/
  619. BOOL wrapInternetReadFile(
  620. HINTERNET hReq,
  621. LPVOID lpvBuffer,
  622. DWORD cbBuffer,
  623. LPDWORD lpcbRd)
  624. {
  625. BOOL bRet;
  626. __try {
  627. bRet = g_pfnInternetReadFile(hReq, lpvBuffer, cbBuffer, lpcbRd);
  628. } __except(1) {
  629. DBG_ASSERT(FALSE, (TEXT("inetwrap : InternetReadFile exception!")));
  630. bRet = FALSE;
  631. }
  632. return bRet;
  633. }
  634. /*****************************************************************************\
  635. * wrapInternetWriteFile
  636. *
  637. *
  638. \*****************************************************************************/
  639. BOOL wrapInternetWriteFile(
  640. HINTERNET hReq,
  641. LPVOID lpvBuffer,
  642. DWORD cbBuffer,
  643. LPDWORD lpcbWr)
  644. {
  645. BOOL bRet;
  646. __try {
  647. bRet = g_pfnInternetWriteFile(hReq, lpvBuffer, cbBuffer, lpcbWr);
  648. } __except(1) {
  649. DBG_ASSERT(FALSE, (TEXT("inetwrap : InternetWriteFile exception!")));
  650. bRet = FALSE;
  651. }
  652. return bRet;
  653. }
  654. /*****************************************************************************\
  655. * wrapInternetErrorDlg
  656. *
  657. *
  658. \*****************************************************************************/
  659. DWORD wrapInternetErrorDlg(
  660. HWND hWnd,
  661. HINTERNET hReq,
  662. DWORD dwError,
  663. DWORD dwFlags,
  664. LPVOID pvParam)
  665. {
  666. DWORD dwRet;
  667. __try {
  668. dwRet = g_pfnInternetErrorDlg(hWnd, hReq, dwError, dwFlags, pvParam);
  669. } __except(1) {
  670. DBG_ASSERT(FALSE, (TEXT("inetwrap : InternetErrorDlg exception!")));
  671. dwRet = 0;
  672. }
  673. return dwRet;
  674. }