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.

1221 lines
28 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. handle.hxx
  5. Abstract:
  6. Contains client-side internet handle class
  7. Author:
  8. Madan Appiah (madana) 16-Nov-1994
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. Sophia Chung (sophiac) 12-Feb-1995 (added FTP handle obj. class defs)
  13. --*/
  14. #ifndef _HINET_
  15. #define _HINET_
  16. //
  17. // manifests
  18. //
  19. #define OBJECT_SIGNATURE 0x41414141 // "AAAA"
  20. #define DESTROYED_OBJECT_SIGNATURE 0x5A5A5A5A // "ZZZZ"
  21. #define LOCAL_INET_HANDLE (HINTERNET)-2
  22. #define INET_INVALID_HANDLE_VALUE (NULL)
  23. #define MAX_PROXY_BYPASS_BUCKETS 256
  24. //
  25. // types
  26. //
  27. typedef
  28. DWORD
  29. (*URLGEN_FUNC)(
  30. INTERNET_SCHEME,
  31. LPSTR,
  32. LPSTR,
  33. LPSTR,
  34. LPSTR,
  35. DWORD,
  36. LPSTR *,
  37. LPDWORD
  38. );
  39. //
  40. // typedef virtual close function
  41. //
  42. typedef BOOL (*CLOSE_HANDLE_FUNC)(HINTERNET);
  43. typedef BOOL (*CONNECT_CLOSE_HANDLE_FUNC)(HINTERNET, DWORD);
  44. //
  45. // forward references
  46. //
  47. class ICSocket;
  48. //
  49. // class implementations
  50. //
  51. /*++
  52. Class Description:
  53. This is generic HINTERNET class definition.
  54. Private Member functions:
  55. None.
  56. Public Member functions:
  57. IsValid : Validates handle pointer.
  58. GetStatus : Gets status of the object.
  59. GetInternetHandle : Virtual function that gets the internet handle
  60. value form the generic object handle.
  61. GetHandle : Virtual function that gets the service handle value from
  62. the generic object handle.
  63. --*/
  64. class HANDLE_OBJECT {
  65. private:
  66. //
  67. // _List - doubly-linked list of all handle objects
  68. //
  69. LIST_ENTRY _List;
  70. //
  71. // _Children - serialized list of all child handle objects
  72. //
  73. SERIALIZED_LIST _Children;
  74. //
  75. // _Siblings - doubly-linked list of all handle objects at the current level
  76. // and descended from a particular parent - e.g. all InternetConnect handles
  77. // belonging to InternetOpen handle. Linked to the parent's _Children list
  78. //
  79. LIST_ENTRY _Siblings;
  80. //
  81. // _Parent - this member has the address of the parent object. Mainly used
  82. // when we create an INTERNET_CONNECT_HANDLE_OBJECT on behalf of the object
  83. // created with InternetOpenUrl().
  84. // We also need this field to locate the INTERNET_CONNECT_HANDLE_OBJECT that
  85. // is the parent of a HTTP request object: if the caller requests Keep-Alive
  86. // then the parent INTERNET_CONNECT_HANDLE_OBJECT will have the socket that
  87. // we must use
  88. //
  89. HANDLE_OBJECT* _Parent;
  90. //
  91. // _DeleteWithChild - used in conjunction with _Parent. In the case of an
  92. // INTERNET_CONNECT_HANDLE_OBJECT created on behalf of a HTTP, gopher or
  93. // FTP object created by InternetOpenUrl(), we need to delete the parent
  94. // handle when the child is closed via InternetCloseHandle(). If we don't
  95. // do this then the connect handle object will be orphaned (i.e. we will
  96. // have a memory leak)
  97. //
  98. //
  99. // BUGBUG - combine into bitfield
  100. //
  101. BOOL _DeleteWithChild;
  102. //
  103. // _Handle - the non-address pseudo-handle value returned at the API
  104. //
  105. HINTERNET _Handle;
  106. //
  107. // _ObjectType - type of handle object (mainly for debug purposes)
  108. //
  109. HINTERNET_HANDLE_TYPE _ObjectType;
  110. //
  111. // _ReferenceCount - number of references of this object. Used to protect
  112. // object against multi-threaded operations and can be used to delete
  113. // object when count is decremented to 0
  114. //
  115. LONG _ReferenceCount;
  116. //
  117. // _Invalid - when this is TRUE the handle has been closed although it may
  118. // still be alive. The app cannot perform any further actions on this
  119. // handle object - it will soon be destroyed
  120. //
  121. //
  122. // BUGBUG - combine into bitfield
  123. //
  124. BOOL _Invalid;
  125. //
  126. // _Error - optionally set when invalidating the handle. If set (non-zero)
  127. // then this is the preferred error to return from an invalidated request
  128. //
  129. DWORD _Error;
  130. //
  131. // _Signature - used to perform sanity test of object
  132. //
  133. DWORD _Signature;
  134. protected:
  135. //
  136. // _Context - the context value specified in the API that created this
  137. // object. This member is inherited by all derived objects
  138. //
  139. DWORD_PTR _Context;
  140. //
  141. // _Status - used to store return codes whilst creating the object. If not
  142. // ERROR_SUCCESS when new() returns, the object is deleted
  143. //
  144. DWORD _Status;
  145. public:
  146. HANDLE_OBJECT(
  147. HANDLE_OBJECT * Parent
  148. );
  149. virtual
  150. ~HANDLE_OBJECT(
  151. VOID
  152. );
  153. DWORD
  154. Reference(
  155. VOID
  156. );
  157. BOOL
  158. Dereference(
  159. VOID
  160. );
  161. VOID Invalidate(VOID) {
  162. //
  163. // just mark the object as invalidated
  164. //
  165. DEBUG_PRINT(THRDINFO,
  166. INFO,
  167. ("HANDLE_OBJECT[%#x]::Invalidate()\n",
  168. this
  169. ));
  170. _Invalid = TRUE;
  171. }
  172. BOOL IsInvalidated(VOID) const {
  173. DEBUG_PRINT(THRDINFO,
  174. INFO,
  175. ("HANDLE_OBJECT[%#x]::IsInvalidated() returning %B\n",
  176. this,
  177. _Invalid
  178. ));
  179. return _Invalid;
  180. }
  181. VOID InvalidateWithError(DWORD dwError) {
  182. _Error = dwError;
  183. Invalidate();
  184. }
  185. DWORD GetError(VOID) const {
  186. return _Error;
  187. }
  188. DWORD ReferenceCount(VOID) const {
  189. return _ReferenceCount;
  190. }
  191. VOID AddChild(PLIST_ENTRY Child) {
  192. DEBUG_ENTER((DBG_OBJECTS,
  193. None,
  194. "AddChild",
  195. "%#x",
  196. Child
  197. ));
  198. InsertAtTailOfSerializedList(&_Children, Child);
  199. //
  200. // each time we add a child object, we increase the reference count, and
  201. // correspondingly decrease it when we remove the child. This stops us
  202. // leaving orphaned child objects
  203. //
  204. Reference();
  205. DEBUG_LEAVE(0);
  206. }
  207. VOID RemoveChild(PLIST_ENTRY Child) {
  208. DEBUG_ENTER((DBG_OBJECTS,
  209. None,
  210. "RemoveChild",
  211. "%#x",
  212. Child
  213. ));
  214. RemoveFromSerializedList(&_Children, Child);
  215. INET_DEBUG_ASSERT((Child->Flink == NULL) && (Child->Blink == NULL));
  216. //
  217. // if this object was previously invalidated but could not be deleted
  218. // in case we orphaned child objects, then this dereference is going to
  219. // close this object
  220. //
  221. Dereference();
  222. DEBUG_LEAVE(0);
  223. }
  224. BOOL HaveChildren(VOID) {
  225. return IsSerializedListEmpty(&_Children) ? FALSE : TRUE;
  226. }
  227. HINTERNET NextChild(VOID) {
  228. PLIST_ENTRY link = HeadOfSerializedList(&_Children);
  229. INET_ASSERT(link != (PLIST_ENTRY)&_Children.List.Flink);
  230. //
  231. // link points at _Siblings.Flink in the child object
  232. //
  233. HANDLE_OBJECT * pHandle;
  234. pHandle = CONTAINING_RECORD(link, HANDLE_OBJECT, _Siblings.Flink);
  235. //
  236. // return the pseudo handle of the child object
  237. //
  238. return pHandle->GetPseudoHandle();
  239. }
  240. HINTERNET GetPseudoHandle(VOID) {
  241. return _Handle;
  242. }
  243. DWORD_PTR GetContext(VOID) {
  244. return _Context;
  245. }
  246. //
  247. // BUGBUG - rfirth 04/05/96 - remove virtual functions
  248. //
  249. // See similar BUGBUG in INTERNET_HANDLE_OBJECT
  250. //
  251. virtual HINTERNET GetInternetHandle(VOID) {
  252. return INET_INVALID_HANDLE_VALUE;
  253. }
  254. virtual HINTERNET GetHandle(VOID) {
  255. return INET_INVALID_HANDLE_VALUE;
  256. }
  257. virtual HINTERNET_HANDLE_TYPE GetHandleType(VOID) {
  258. return TypeGenericHandle;
  259. }
  260. virtual VOID SetHtml(VOID) {
  261. }
  262. virtual VOID SetHtmlState(HTML_STATE) {
  263. }
  264. virtual HTML_STATE GetHtmlState(VOID) {
  265. return HTML_STATE_INVALID;
  266. }
  267. virtual LPSTR GetUrl(VOID) {
  268. return NULL;
  269. }
  270. virtual VOID SetUrl(LPSTR Url) {
  271. UNREFERENCED_PARAMETER(Url);
  272. }
  273. virtual VOID SetDirEntry(LPSTR DirEntry) {
  274. UNREFERENCED_PARAMETER(DirEntry);
  275. }
  276. virtual LPSTR GetDirEntry(VOID) {
  277. return NULL;
  278. }
  279. DWORD IsValid(HINTERNET_HANDLE_TYPE ExpectedHandleType);
  280. DWORD GetStatus(VOID) {
  281. return _Status;
  282. }
  283. VOID SetParent(HINTERNET Handle, BOOL DeleteWithChild) {
  284. _Parent = (HANDLE_OBJECT *)Handle;
  285. _DeleteWithChild = DeleteWithChild;
  286. }
  287. HINTERNET GetParent() {
  288. return _Parent;
  289. }
  290. BOOL GetDeleteWithChild(VOID) {
  291. return _DeleteWithChild;
  292. }
  293. VOID SetObjectType(HINTERNET_HANDLE_TYPE Type) {
  294. _ObjectType = Type;
  295. }
  296. HINTERNET_HANDLE_TYPE GetObjectType(VOID) const {
  297. return _ObjectType;
  298. }
  299. void OnLastHandleDestroyed (void)
  300. {
  301. HttpFiltClose();
  302. }
  303. virtual VOID AbortSocket(VOID) {
  304. }
  305. //
  306. // friend functions
  307. //
  308. //
  309. // these friend functions are here so that they can get access to _List for
  310. // CONTAINING_RECORD()
  311. //
  312. friend
  313. HINTERNET
  314. FindExistingConnectObject(
  315. IN HINTERNET hInternet,
  316. IN LPSTR lpHostName,
  317. IN INTERNET_PORT nPort,
  318. IN LPSTR lpszUserName,
  319. IN LPSTR lpszPassword,
  320. IN DWORD dwServiceType,
  321. IN DWORD dwFlags,
  322. IN DWORD_PTR dwContext
  323. );
  324. friend
  325. INT
  326. FlushExistingConnectObjects(
  327. IN HINTERNET hInternet
  328. );
  329. friend
  330. HANDLE_OBJECT *
  331. ContainingHandleObject(
  332. IN LPVOID lpAddress
  333. );
  334. };
  335. // The following enables unicode-receiving callbacks.
  336. VOID UnicodeStatusCallbackWrapper(IN HINTERNET hInternet, IN DWORD_PTR dwContext,
  337. IN DWORD dwInternetStatus, IN LPVOID lpvStatusInformation OPTIONAL,
  338. IN DWORD dwStatusInformationLength );
  339. /*++
  340. Class Description:
  341. This class defines the INTERNET_HANDLE_OBJECT.
  342. Private Member functions:
  343. None.
  344. Public Member functions:
  345. GetInternetHandle : Virtual function that gets the Internet handle
  346. value from the generic object handle.
  347. GetHandle : Virtual function that gets the service handle value from
  348. the generic object handle.
  349. --*/
  350. class INTERNET_HANDLE_OBJECT : public HANDLE_OBJECT {
  351. private:
  352. BOOL _fExemptConnLimit;
  353. BOOL _fDisableTweener;
  354. //
  355. // Passport Auth package's "Session Handle"
  356. //
  357. PP_CONTEXT _PPContext;
  358. //
  359. // _INetHandle - BUGBUG - why is this still here?
  360. //
  361. //
  362. // BUGBUG - post-beta cleanup - remove
  363. //
  364. HINTERNET _INetHandle;
  365. //
  366. // _IsCopy - TRUE if this is part of a derived object handle (e.g. a
  367. // connect handle object)
  368. //
  369. //
  370. // BUGBUG - post-beta cleanup - combine into bitfield
  371. //
  372. BOOL _IsCopy;
  373. //
  374. // _UserAgent - name by why which the application wishes to be known to
  375. // HTTP servers. Provides the User-Agent header unless overridden by
  376. // specific User-Agent header from app
  377. //
  378. ICSTRING _UserAgent;
  379. //
  380. // _ProxyInfo - maintains the proxy server and bypass lists
  381. //
  382. PROXY_INFO * _ProxyInfo;
  383. //
  384. // _ProxyInfoResourceLock - must acquire for exclusive access in order to
  385. // modify the proxy info
  386. //
  387. RESOURCE_LOCK _ProxyInfoResourceLock;
  388. VOID AcquireProxyInfo(BOOL bExclusiveMode) {
  389. INET_ASSERT(!IsCopy());
  390. _ProxyInfoResourceLock.Acquire(bExclusiveMode);
  391. }
  392. VOID ReleaseProxyInfo(VOID) {
  393. INET_ASSERT(!IsCopy());
  394. _ProxyInfoResourceLock.Release();
  395. }
  396. VOID SafeDeleteProxyInfo(VOID) {
  397. DEBUG_ENTER((DBG_OBJECTS,
  398. None,
  399. "SafeDeleteProxyInfo",
  400. ""
  401. ));
  402. if (_ProxyInfo != NULL) {
  403. AcquireProxyInfo(TRUE);
  404. if (!IsProxyGlobal()) {
  405. if (_ProxyInfo != NULL) {
  406. delete _ProxyInfo;
  407. }
  408. }
  409. _ProxyInfo = NULL;
  410. ReleaseProxyInfo();
  411. }
  412. DEBUG_LEAVE(0);
  413. }
  414. //
  415. // _dwInternetOpenFlags - flags from InternetOpen()
  416. //
  417. // BUGBUG - there should only be ONE flags DWORD for all handles descended
  418. // from this one. This is it
  419. // Rename to just _Flags, or _OpenFlags
  420. //
  421. DWORD _dwInternetOpenFlags;
  422. #ifdef POST_BETA
  423. //
  424. // _Flags - contains all flags from all handle creation functions. Each
  425. // subsequent derived handle just OR's its flags into the base flags
  426. //
  427. DWORD _Flags;
  428. #endif
  429. //
  430. // _WinsockLoaded - TRUE if we managed to successfully load winsock
  431. //
  432. //
  433. // BUGBUG - post-beta cleanup - combine into bitfield
  434. //
  435. BOOL _WinsockLoaded;
  436. //
  437. // _pICSocket - pointer to ICSocket for new HTTP async code
  438. //
  439. ICSocket * _pICSocket;
  440. DWORD _dwBlockedOnError;
  441. DWORD _dwBlockedOnResult;
  442. LPVOID _lpBlockedResultData;
  443. CRITICAL_SECTION _UiCritSec;
  444. protected:
  445. //
  446. // _dwUiBlocked - count of handles blocked on a request waiting to show UI to the User
  447. //
  448. DWORD _dwUiBlocked;
  449. //
  450. // _dwBlockId - contains the ID that this handle is blocked on for the purpose of
  451. // showing UI to the user.
  452. //
  453. DWORD_PTR _dwBlockId;
  454. //
  455. // timout/retry/back-off values. The app can specify timeouts etc. at
  456. // various levels: global (DLL), Internet handle (from InternetOpen()) and
  457. // Connect handle (from InternetConnect()). The following fields are
  458. // inherited by INTERNET_CONNECT_HANDLE_OBJECT (and derived objects)
  459. //
  460. DWORD _ConnectTimeout;
  461. DWORD _ConnectRetries;
  462. DWORD _SendTimeout;
  463. DWORD _DataSendTimeout;
  464. DWORD _ReceiveTimeout;
  465. DWORD _DataReceiveTimeout;
  466. DWORD _FromCacheTimeout;
  467. DWORD _SocketSendBufferLength;
  468. DWORD _SocketReceiveBufferLength;
  469. //
  470. // _Async - TRUE if the InternetOpen() handle, and all handles descended
  471. // from it, support asynchronous I/O
  472. //
  473. //
  474. // BUGBUG - post-beta cleanup - get from flags
  475. //
  476. BOOL _Async;
  477. //
  478. // _DataAvailable - the number of bytes that can be read from this handle
  479. // (i.e. only protocol handles) immediately. This avoids a read request
  480. // being made asynchronously if it can be satisfied immediately
  481. //
  482. DWORD _DataAvailable;
  483. //
  484. // _EndOfFile - TRUE when we have received all data for this request. This
  485. // is used to avoid the API having to perform an extraneous read (possibly
  486. // asynchronously) just to discover that we reached end-of-file already
  487. //
  488. //
  489. // BUGBUG - post-beta cleanup - combine into bitfield
  490. //
  491. BOOL _EndOfFile;
  492. //
  493. // _StatusCallback - we now maintain callbacks on a per-handle basis. The
  494. // callback address comes from the parent handle or the DLL if this is an
  495. // InternetOpen() handle. The status callback can be changed for an
  496. // individual handle object using the ExchangeStatusCallback() method
  497. // (called from InternetSetStatusCallback())
  498. //
  499. //
  500. // BUGBUG - this should go in HANDLE_OBJECT
  501. //
  502. INTERNET_STATUS_CALLBACK _StatusCallback;
  503. BOOL _StatusCallbackType;
  504. //
  505. // _PendingAsyncRequests - the number of pending async requests on this
  506. // handle object. While this is !0, an app cannot reset the callback
  507. //
  508. //
  509. // BUGBUG - RLF 03/16/98. _PendingAsyncRequests is no longer being modified
  510. // since fibers were removed. This count is used for precautionary
  511. // measure when changing a status callback on a handle that has
  512. // outstanding async requests. I am commenting-out all uses of this
  513. // and _AsyncClashTest for B1. Should be fixed or re-examined after
  514. // B1
  515. //
  516. //LONG _PendingAsyncRequests;
  517. //
  518. // _AsyncClashTest - used with InterlockedIncrement() to ensure that only
  519. // one thread is modifying _PendingAsyncRequests
  520. //
  521. //LONG _AsyncClashTest;
  522. public:
  523. INTERNET_HANDLE_OBJECT(
  524. LPCSTR UserAgent,
  525. DWORD AccessMethod,
  526. LPSTR ProxyName,
  527. LPSTR ProxyBypass,
  528. DWORD Flags
  529. );
  530. INTERNET_HANDLE_OBJECT(INTERNET_HANDLE_OBJECT *INetObj);
  531. virtual ~INTERNET_HANDLE_OBJECT(VOID);
  532. virtual HINTERNET GetInternetHandle(VOID);
  533. virtual HINTERNET GetHandle(VOID);
  534. void ExemptConnLimit(void) {
  535. _fExemptConnLimit = TRUE;
  536. }
  537. BOOL ConnLimitExempted(void) const {
  538. return _fExemptConnLimit;
  539. }
  540. //
  541. // BUGBUG - rfirth 04/05/96 - remove virtual functions
  542. //
  543. // For the most part, these functions aren't required to be
  544. // virtual. They should just be moved to the relevant handle type
  545. // (e.g. FTP_FILE_HANDLE_OBJECT). Even GetHandleType() is overkill.
  546. // Replacing with a method that just returns
  547. // HANDLE_OBJECT::_ObjectType would be sufficient
  548. //
  549. virtual HINTERNET_HANDLE_TYPE GetHandleType(VOID) {
  550. return TypeInternetHandle;
  551. }
  552. virtual VOID SetHtml(VOID) {
  553. }
  554. virtual VOID SetHtmlState(HTML_STATE) {
  555. }
  556. virtual HTML_STATE GetHtmlState(VOID) {
  557. return HTML_STATE_INVALID;
  558. }
  559. virtual LPSTR GetUrl(VOID) {
  560. return NULL;
  561. }
  562. virtual VOID SetUrl(LPSTR Url) {
  563. if (Url != NULL) {
  564. Url = (LPSTR)FREE_MEMORY(Url);
  565. INET_ASSERT(Url == NULL);
  566. }
  567. }
  568. virtual VOID SetDirEntry(LPSTR DirEntry) {
  569. UNREFERENCED_PARAMETER(DirEntry);
  570. }
  571. virtual LPSTR GetDirEntry(VOID) {
  572. return NULL;
  573. }
  574. PP_CONTEXT GetPPContext(void) const {
  575. return _PPContext;
  576. }
  577. void DisableTweener(void) {
  578. _fDisableTweener = TRUE;
  579. }
  580. void EnableTweener(void) {
  581. _fDisableTweener = FALSE;
  582. }
  583. BOOL TweenerDisabled(void) const {
  584. return _fDisableTweener;
  585. }
  586. BOOL IsCopy(VOID) const {
  587. return _IsCopy;
  588. }
  589. VOID LockPopupInfo(VOID) {
  590. DEBUG_PRINT(THRDINFO,
  591. INFO,
  592. ("INTERNET_HANDLE_OBJECT[%#x]::LockPopupInfo()\n",
  593. this
  594. ));
  595. EnterCriticalSection(&_UiCritSec);
  596. }
  597. VOID UnlockPopupInfo(VOID) {
  598. DEBUG_PRINT(THRDINFO,
  599. INFO,
  600. ("INTERNET_HANDLE_OBJECT[%#x]::UnlockPopupInfo()\n",
  601. this
  602. ));
  603. LeaveCriticalSection(&_UiCritSec);
  604. }
  605. VOID BlockOnUserInput(DWORD dwError, DWORD_PTR dwBlockId, LPVOID lpResultData) {
  606. DEBUG_PRINT(THRDINFO,
  607. INFO,
  608. ("INTERNET_HANDLE_OBJECT[%#x]::BlockOnUserInput(dwBlockId=%#x), _dwUiBlocked=%u\n",
  609. this,
  610. dwBlockId,
  611. _dwUiBlocked
  612. ));
  613. INET_ASSERT(!_dwUiBlocked);
  614. _dwBlockedOnError = dwError;
  615. _dwBlockedOnResult = ERROR_SUCCESS;
  616. _dwBlockId = dwBlockId;
  617. _lpBlockedResultData = lpResultData;
  618. _dwUiBlocked++;
  619. }
  620. VOID UnBlockOnUserInput(LPDWORD lpdwResultCode, LPVOID *lplpResultData) {
  621. DEBUG_PRINT(THRDINFO,
  622. INFO,
  623. ("INTERNET_HANDLE_OBJECT[%#x]::UnBlockOnUserInput() _dwBlockedOnResult=%u, _dwUiBlocked=%u\n",
  624. this,
  625. _dwBlockedOnResult,
  626. _dwUiBlocked
  627. ));
  628. INET_ASSERT(_dwUiBlocked);
  629. _dwUiBlocked--;
  630. *lpdwResultCode = _dwBlockedOnResult;
  631. *lplpResultData = _lpBlockedResultData;
  632. }
  633. VOID SetBlockedResultCode(DWORD dwResultCode) {
  634. DEBUG_PRINT(THRDINFO,
  635. INFO,
  636. ("INTERNET_HANDLE_OBJECT[%#x]::SetBlockedResultCode(result = %u)\n",
  637. this,
  638. dwResultCode
  639. ));
  640. INET_ASSERT(_dwUiBlocked);
  641. _dwBlockedOnResult = dwResultCode;
  642. }
  643. BOOL IsBlockedOnUserInput(VOID) {
  644. DEBUG_PRINT(THRDINFO,
  645. INFO,
  646. ("INTERNET_HANDLE_OBJECT[%#x]::IsBlockedOnUserInput() = %B\n",
  647. this,
  648. _dwUiBlocked
  649. ));
  650. return (BOOL) _dwUiBlocked;
  651. }
  652. VOID IncrementBlockedUiCount(VOID) {
  653. DEBUG_PRINT(THRDINFO,
  654. INFO,
  655. ("INTERNET_HANDLE_OBJECT[%#x]::IncrementBlockedUiCount()+1 = %u\n",
  656. this,
  657. (_dwUiBlocked+1)
  658. ));
  659. _dwUiBlocked++;
  660. }
  661. DWORD GetBlockedUiCount(VOID) {
  662. DEBUG_PRINT(THRDINFO,
  663. INFO,
  664. ("INTERNET_HANDLE_OBJECT[%#x]::GetBlockedUiCount() = %u\n",
  665. this,
  666. _dwUiBlocked
  667. ));
  668. INET_ASSERT(_dwUiBlocked);
  669. return _dwUiBlocked;
  670. }
  671. VOID ClearBlockedUiCount(VOID) {
  672. DEBUG_PRINT(THRDINFO,
  673. INFO,
  674. ("INTERNET_HANDLE_OBJECT[%#x]::ClearBlockedUiCount()\n",
  675. this
  676. ));
  677. INET_ASSERT(_dwUiBlocked);
  678. _dwUiBlocked = 0;
  679. }
  680. DWORD_PTR GetBlockId(VOID) {
  681. DEBUG_PRINT(THRDINFO,
  682. INFO,
  683. ("INTERNET_HANDLE_OBJECT[%#x]::GetBlockId() = %u\n",
  684. this,
  685. _dwBlockId
  686. ));
  687. INET_ASSERT(_dwUiBlocked);
  688. return _dwBlockId;
  689. }
  690. VOID GetUserAgent(LPSTR Buffer, LPDWORD BufferLength) {
  691. _UserAgent.CopyTo(Buffer, BufferLength);
  692. }
  693. LPSTR GetUserAgent(VOID) {
  694. return _UserAgent.StringAddress();
  695. }
  696. LPSTR GetUserAgent(LPDWORD lpdwLength) {
  697. *lpdwLength = _UserAgent.StringLength();
  698. return _UserAgent.StringAddress();
  699. }
  700. VOID SetUserAgent(LPSTR lpszUserAgent) {
  701. INET_ASSERT(lpszUserAgent != NULL);
  702. _UserAgent = lpszUserAgent;
  703. }
  704. BOOL IsProxy(VOID) const {
  705. //
  706. // we can return this info without acquiring the critical section
  707. //
  708. return (_ProxyInfo != NULL) ? _ProxyInfo->IsProxySettingsConfigured() : FALSE;
  709. }
  710. BOOL IsProxyGlobal(VOID) const {
  711. return (_ProxyInfo == &GlobalProxyInfo) ? TRUE : FALSE;
  712. }
  713. VOID
  714. CheckGlobalProxyUpdated(
  715. VOID
  716. );
  717. PROXY_INFO * GetProxyInfo(VOID) const {
  718. INET_ASSERT(!IsCopy());
  719. return _ProxyInfo;
  720. }
  721. VOID SetProxyInfo(PROXY_INFO * ProxyInfo) {
  722. INET_ASSERT(!IsCopy());
  723. _ProxyInfo = ProxyInfo;
  724. }
  725. VOID ResetProxyInfo(VOID) {
  726. INET_ASSERT(!IsCopy());
  727. SetProxyInfo(NULL);
  728. }
  729. DWORD
  730. Refresh(
  731. IN DWORD dwInfoLevel
  732. );
  733. DWORD
  734. SetProxyInfo(
  735. IN DWORD dwAccessType,
  736. IN LPCSTR lpszProxy OPTIONAL,
  737. IN LPCSTR lpszProxyBypass OPTIONAL
  738. );
  739. DWORD
  740. GetProxyStringInfo(
  741. OUT LPVOID lpBuffer,
  742. IN OUT LPDWORD lpdwBufferLength
  743. );
  744. DWORD
  745. GetProxyInfo(
  746. IN AUTO_PROXY_ASYNC_MSG **ppQueryForProxyInfo
  747. );
  748. BOOL
  749. RedoSendRequest(
  750. IN OUT LPDWORD lpdwError,
  751. IN AUTO_PROXY_ASYNC_MSG *pQueryForProxyInfo,
  752. IN CServerInfo *pOriginServer,
  753. IN CServerInfo *pProxyServer
  754. );
  755. VOID SetContext(DWORD_PTR NewContext) {
  756. _Context = NewContext;
  757. }
  758. VOID SetTimeout(DWORD TimeoutOption, DWORD TimeoutValue);
  759. DWORD GetTimeout(DWORD TimeoutOption);
  760. BOOL IsAsyncHandle(VOID) {
  761. return _Async;
  762. }
  763. VOID ResetAsync(VOID) {
  764. _Async = FALSE;
  765. }
  766. VOID SetAvailableDataLength(DWORD Amount) {
  767. INET_ASSERT((int)Amount >= 0);
  768. _DataAvailable = Amount;
  769. }
  770. DWORD AvailableDataLength(VOID) const {
  771. INET_ASSERT((int)_DataAvailable >= 0);
  772. return _DataAvailable;
  773. }
  774. BOOL IsDataAvailable(VOID) {
  775. INET_ASSERT((int)_DataAvailable >= 0);
  776. return (_DataAvailable != 0) ? TRUE : FALSE;
  777. }
  778. VOID ReduceAvailableDataLength(DWORD Amount) {
  779. //
  780. // why would Amount be > _DataAvailable?
  781. //
  782. if (Amount > _DataAvailable) {
  783. _DataAvailable = 0;
  784. } else {
  785. _DataAvailable -= Amount;
  786. }
  787. INET_ASSERT((int)_DataAvailable >= 0);
  788. }
  789. VOID IncreaseAvailableDataLength(DWORD Amount) {
  790. _DataAvailable += Amount;
  791. INET_ASSERT((int)_DataAvailable >= 0);
  792. }
  793. VOID SetEndOfFile(VOID) {
  794. _EndOfFile = TRUE;
  795. }
  796. VOID ResetEndOfFile(VOID) {
  797. _EndOfFile = FALSE;
  798. }
  799. BOOL IsEndOfFile(VOID) const {
  800. return _EndOfFile;
  801. }
  802. INTERNET_STATUS_CALLBACK GetStatusCallback(VOID) {
  803. return ((_StatusCallbackType==FALSE) ? _StatusCallback : UnicodeStatusCallbackWrapper);
  804. }
  805. INTERNET_STATUS_CALLBACK GetTrueStatusCallback(VOID) {
  806. return ((_StatusCallbackType==FALSE) ? NULL : _StatusCallback);
  807. }
  808. VOID ResetStatusCallback(VOID) {
  809. _StatusCallback = NULL;
  810. _StatusCallbackType = FALSE;
  811. }
  812. //VOID AcquireAsyncSpinLock(VOID);
  813. //
  814. //VOID ReleaseAsyncSpinLock(VOID);
  815. DWORD ExchangeStatusCallback(LPINTERNET_STATUS_CALLBACK lpStatusCallback, BOOL fType);
  816. //DWORD AddAsyncRequest(BOOL fNoCallbackOK);
  817. //
  818. //VOID RemoveAsyncRequest(VOID);
  819. //
  820. //DWORD GetAsyncRequestCount(VOID) {
  821. //
  822. // //
  823. // // it doesn't matter about locking this variable - it can change before
  824. // // we have returned it to the caller anyway
  825. // //
  826. //
  827. // return _PendingAsyncRequests;
  828. //}
  829. // random methods on flags
  830. DWORD GetInternetOpenFlags() {
  831. return _dwInternetOpenFlags;
  832. }
  833. #ifdef POST_BETA
  834. DWORD GetFlags(VOID) const {
  835. return _Flags;
  836. }
  837. VOID SetFlags(DWORD Flags) {
  838. _Flags |= Flags;
  839. }
  840. VOID ResetFlags(DWORD Flags) {
  841. _Flags &= ~Flags;
  842. }
  843. #endif
  844. VOID
  845. SetAbortHandle(
  846. IN ICSocket * pSocket
  847. );
  848. ICSocket * GetAbortHandle(VOID) const {
  849. return _pICSocket;
  850. }
  851. VOID
  852. ResetAbortHandle(
  853. VOID
  854. );
  855. virtual
  856. VOID
  857. AbortSocket(
  858. VOID
  859. );
  860. DWORD CheckAutoProxyDownloaded(VOID) {
  861. DWORD error = ERROR_SUCCESS;
  862. if (IsProxyGlobal()) {
  863. AcquireProxyInfo(FALSE);
  864. if (! GlobalProxyInfo.IsAutoProxyDownloaded()) {
  865. error = GlobalProxyInfo.RefreshProxySettings(TRUE);
  866. }
  867. ReleaseProxyInfo();
  868. }
  869. return error;
  870. }
  871. BOOL IsFromCacheTimeoutSet(VOID) const {
  872. return _FromCacheTimeout != (DWORD)-1;
  873. }
  874. };
  875. //
  876. // prototypes
  877. //
  878. HANDLE_OBJECT *
  879. ContainingHandleObject(
  880. IN LPVOID lpAddress
  881. );
  882. VOID
  883. CancelActiveSyncRequests(
  884. IN DWORD dwError
  885. );
  886. #endif // _HINET_