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.

1769 lines
40 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. autoprox.hxx
  5. Abstract:
  6. Contains interface definition for a specialized DLL that automatically configurares WININET proxy
  7. information. The DLL can reroute proxy infromation based on a downloaded set of data that matches
  8. it registered MIME type. The DLL can also control WININET proxy use, on a request by request basis.
  9. Contents:
  10. AUTO_PROXY_LIST_ENTRY
  11. AUTO_PROXY_DLLS
  12. AUTO_PROXY_ASYNC_MSG
  13. PROXY_STATE
  14. Author:
  15. Arthur L Bierer (arthurbi) 01-Dec-1996
  16. Revision History:
  17. 26-Aug-2001 ssulzer
  18. WinHttp Autoproxy
  19. --*/
  20. #ifndef _AUTOPROX_HXX_
  21. #define _AUTOPROX_HXX_
  22. #define WINHTTP_AUTO_DETECT_FLAGS_MASK \
  23. (WINHTTP_AUTO_DETECT_TYPE_DHCP | \
  24. WINHTTP_AUTO_DETECT_TYPE_DNS_A | \
  25. WINHTTP_AUTO_DETECT_ON_NET_CHANGE)
  26. #define CSZMAINSECKEY "AutoProxyTypes"
  27. //
  28. // functions
  29. //
  30. class CAutoProxy
  31. {
  32. INTERNET_HANDLE_OBJECT * _hSession;
  33. CCritSec _CritSec;
  34. RESOURCE_LOCK _ScriptResLock;
  35. //
  36. // Detection information
  37. //
  38. LPSTR _pszAutoConfigUrl;
  39. FILETIME _ftLastDetectionTime;
  40. DWORD * _pdwDetectedInterfaceIp;
  41. int _cDetectedInterfaceIpCount;
  42. LPSTR _pszConfigScript;
  43. //
  44. // Expiry & LastModified timestamps for config script
  45. //
  46. FILETIME _ftExpiryTime;
  47. BOOL _fHasExpiry;
  48. FILETIME _ftLastModifiedTime;
  49. BOOL _fHasLastModifiedTime;
  50. BOOL _fMustRevalidate;
  51. FILETIME _ftLastSyncTime;
  52. BOOL IsDetectionNeeded();
  53. DWORD DetectAutoProxyUrl(
  54. DWORD dwAutoDetectFlags,
  55. LPSTR * ppszAutoConfigUrl);
  56. DWORD DownloadAutoConfigUrl(
  57. LPSTR lpszAutoConfigUrl,
  58. WINHTTP_AUTOPROXY_OPTIONS * pAutoProxyOptions,
  59. LPSTR * ppszConfigScript);
  60. BOOL IsSupportedMimeType(char * szType);
  61. BOOL IsSupportedFileExtension(LPCSTR lpszUrl);
  62. DWORD RunProxyScript(
  63. LPCSTR lpszUrl,
  64. LPCSTR pszProxyScript,
  65. LPSTR * ppszQueryResults);
  66. DWORD ParseProxyQueryResults(
  67. LPSTR pszQueryResults,
  68. WINHTTP_PROXY_INFO * pProxyInfo);
  69. VOID CalculateTimeStampsForCache(HINTERNET hRequest);
  70. BOOL IsCachedProxyScriptExpired();
  71. VOID AddIfModifiedSinceHeaders(HINTERNET hRequest);
  72. static DWORD GetHostAddresses(int * pcInterfaces, DWORD ** ppdwInterfaceIp);
  73. public:
  74. DWORD GetProxyForURL(
  75. LPCWSTR lpcwszUrl,
  76. WINHTTP_AUTOPROXY_OPTIONS * pAutoProxyOptions,
  77. WINHTTP_PROXY_INFO * pProxyInfo);
  78. CAutoProxy(INTERNET_HANDLE_OBJECT * hSession)
  79. {
  80. _hSession = hSession;
  81. }
  82. ~CAutoProxy();
  83. BOOL Initialize();
  84. BOOL IsSessionAborted() const;
  85. };
  86. //
  87. // Callback functions implimented in WINHTTP
  88. //
  89. class AUTO_PROXY_HELPER_APIS {
  90. public:
  91. virtual
  92. BOOL IsResolvable(
  93. IN LPSTR lpszHost
  94. );
  95. virtual
  96. DWORD GetIPAddress(
  97. IN OUT LPSTR lpszIPAddress,
  98. IN OUT LPDWORD lpdwIPAddressSize
  99. );
  100. virtual
  101. DWORD ResolveHostName(
  102. IN LPSTR lpszHostName,
  103. IN OUT LPSTR lpszIPAddress,
  104. IN OUT LPDWORD lpdwIPAddressSize
  105. );
  106. virtual
  107. BOOL IsInNet(
  108. IN LPSTR lpszIPAddress,
  109. IN LPSTR lpszDest,
  110. IN LPSTR lpszMask
  111. );
  112. };
  113. void UnloadAutoProxy();
  114. //
  115. // external func declariations
  116. //
  117. #define AUTO_PROXY_VERSION 0x00010000
  118. #define EXT_PROXY_FUNC *
  119. typedef BOOL
  120. (EXT_PROXY_FUNC PROXY_INFO_INVALID_FN) (
  121. IN LPSTR lpszMime,
  122. IN LPSTR lpszUrl,
  123. IN DWORD dwUrlLength,
  124. IN LPSTR lpszProxyHostName,
  125. IN DWORD dwProxyHostNameLength
  126. );
  127. typedef BOOL
  128. (EXT_PROXY_FUNC PROXY_DLL_DEINIT_FN) (
  129. IN LPSTR lpszMime,
  130. IN DWORD dwReserved
  131. );
  132. typedef BOOL
  133. (EXT_PROXY_FUNC GET_PROXY_INFO_FN) (
  134. IN LPCSTR lpszUrl,
  135. IN DWORD dwUrlLength,
  136. IN LPSTR lpszUrlHostName,
  137. IN DWORD dwUrlHostNameLength,
  138. OUT LPSTR * lplpszProxyHostName,
  139. OUT LPDWORD lpdwProxyHostNameLength
  140. ) ;
  141. typedef BOOL
  142. (EXT_PROXY_FUNC GET_PROXY_INFO_EX_FN) (
  143. IN INTERNET_SCHEME tUrlProtocol,
  144. IN LPCSTR lpszUrl,
  145. IN DWORD dwUrlLength,
  146. IN LPSTR lpszUrlHostName,
  147. IN DWORD dwUrlHostNameLength,
  148. IN INTERNET_PORT nUrlPort,
  149. OUT LPINTERNET_SCHEME lptProxyScheme,
  150. OUT LPSTR * lplpszProxyHostName,
  151. OUT LPDWORD lpdwProxyHostNameLength,
  152. OUT LPINTERNET_PORT lpProxyHostPort
  153. ) ;
  154. typedef BOOL
  155. (EXT_PROXY_FUNC PROXY_DLL_INIT_FN) (
  156. IN DWORD dwVersion,
  157. IN LPSTR lpszDownloadedTempFile,
  158. IN LPSTR lpszMime,
  159. IN AUTO_PROXY_HELPER_APIS *pAutoProxyCallbacks,
  160. IN DWORD_PTR dwReserved
  161. );
  162. #define PROXY_INFO_INVALID_FN_NAME "InternetProxyInfoInvalid"
  163. #define GET_PROXY_INFO_FN_NAME "InternetGetProxyInfo"
  164. #define GET_PROXY_INFO_EX_FN_NAME "InternetGetProxyInfoEx"
  165. #define PROXY_DLL_INIT_FN_NAME "InternetInitializeAutoProxyDll"
  166. #define PROXY_DLL_DEINIT_FN_NAME "InternetDeInitializeAutoProxyDll"
  167. //
  168. // Flags stored in registry for Auto-Proxy Entry
  169. //
  170. #define AUTOPROX_FLAGS_SINGLE_THREAD 0x01
  171. //
  172. // defines ...
  173. //
  174. #define DEFAULT_AUTO_PROXY_THREAD_TIME_OUT 30000 // 30 secs BUGBUG, up before checkin
  175. //
  176. // PROXY_MESSAGE_TYPE - this represents a type of query that is used
  177. // to submit a request through proxy "knowledge-base" ( ie script, db, etc )
  178. // for async processing of Java-Script auto-proxy scripts.
  179. //
  180. typedef enum {
  181. PROXY_MSG_INVALID,
  182. PROXY_MSG_INIT,
  183. PROXY_MSG_DEINIT,
  184. PROXY_MSG_SELF_DESTRUCT,
  185. PROXY_MSG_GET_PROXY_INFO,
  186. PROXY_MSG_SET_BAD_PROXY
  187. } PROXY_MESSAGE_TYPE;
  188. //
  189. // PROXY_MESSAGE_ALLOC_TYPE - this is needed to track what allocation of member vars
  190. // are currently used in my object. This allows us to use stack vars
  191. // for simple, local calls, but then have allocation done-on-the-fly
  192. // when we need to queue the message.
  193. //
  194. typedef enum {
  195. MSG_ALLOC_NONE,
  196. MSG_ALLOC_STACK_ONLY,
  197. MSG_ALLOC_HEAP,
  198. MSG_ALLOC_HEAP_MSG_OBJ_OWNS
  199. } PROXY_MESSAGE_ALLOC_TYPE;
  200. //
  201. // AUTO_PROXY_STATE - is used to track the state of the auto-proxy list object
  202. // in order to maintain syncronization across readers and writers.
  203. //
  204. typedef enum {
  205. AUTO_PROXY_DISABLED,
  206. AUTO_PROXY_BLOCKED,
  207. AUTO_PROXY_PENDING, // blocked, but we can still fallback to static settings
  208. AUTO_PROXY_ENABLED
  209. } AUTO_PROXY_STATE;
  210. class BAD_PROXY_LIST; // forward decl
  211. //
  212. // PROXY_STATE - keeps track of multiple proxies stored in a Netscape Style
  213. // proxy list string format. Ex:
  214. // "PROXY itgproxy:80; PROXY proxy:80; PROXY 192.168.100.2:1080; SOCKS 192.168.100.2; DIRECT"
  215. //
  216. // Can also be used to link the GetProxyInfo return with a failure in the proxies it gave.
  217. // This needed so we call back into an Auto-Proxy DLL letting them know that we failed
  218. // to be able to utilize its auto-proxy that it gave us.
  219. //
  220. class PROXY_STATE {
  221. private:
  222. //
  223. // _lpszAutoProxyList - List, or Proxy that we are tracking.
  224. //
  225. LPSTR _lpszAutoProxyList;
  226. //
  227. // _dwcbAutoProxyList - size of _lpszAutoProxyList.
  228. //
  229. DWORD _dwcbAutoProxyList;
  230. //
  231. // _lpszOffset - Current Offset into _lpszAutoProxyList
  232. //
  233. LPSTR _lpszOffset;
  234. //
  235. // _lpszLastProxyUsed - Tracks the last proxy that was returned.
  236. //
  237. LPSTR _lpszLastProxyUsed;
  238. //
  239. // _LastProxyUsedPort - Last used Internet Port on the Proxy
  240. //
  241. INTERNET_PORT _LastProxyUsedPort;
  242. //
  243. // _Error - Error code in constructor.
  244. //
  245. DWORD _Error;
  246. //
  247. // _fIsMultiProxyList - TRUE if we a Netscape type list of proxies, as opposed to a simple proxyhostname string.
  248. //
  249. BOOL _fIsMultiProxyList;
  250. //
  251. // _fIsAnotherProxyAvail - TRUE if we have another proxy to process
  252. //
  253. BOOL _fIsAnotherProxyAvail;
  254. //
  255. // tProxyScheme - for the non-multi proxy case we track the type of proxy we are storing.
  256. //
  257. INTERNET_SCHEME _tProxyScheme;
  258. //
  259. // ProxyHostPort - for the non-multi proxy case we track the host port.
  260. //
  261. INTERNET_PORT _proxyHostPort;
  262. public:
  263. PROXY_STATE(
  264. LPSTR lpszAutoProxyList,
  265. DWORD dwcbAutoProxyList,
  266. BOOL fIsMultiProxyList,
  267. INTERNET_SCHEME tProxyScheme,
  268. INTERNET_PORT proxyHostPort
  269. )
  270. {
  271. _lpszAutoProxyList = NULL;
  272. _dwcbAutoProxyList = 0;
  273. _lpszOffset = NULL;
  274. _Error = ERROR_SUCCESS;
  275. _lpszLastProxyUsed = NULL;
  276. _LastProxyUsedPort = INTERNET_DEFAULT_HTTP_PORT;
  277. _fIsMultiProxyList = fIsMultiProxyList;
  278. _tProxyScheme = tProxyScheme;
  279. _proxyHostPort = proxyHostPort;
  280. _fIsAnotherProxyAvail = FALSE;
  281. if ( lpszAutoProxyList &&
  282. dwcbAutoProxyList > 0 )
  283. {
  284. _lpszAutoProxyList = (LPSTR)
  285. ALLOCATE_MEMORY(dwcbAutoProxyList+1);
  286. if ( _lpszAutoProxyList )
  287. {
  288. lstrcpyn(_lpszAutoProxyList, lpszAutoProxyList, dwcbAutoProxyList );
  289. _lpszAutoProxyList[dwcbAutoProxyList] = '\0';
  290. _dwcbAutoProxyList = dwcbAutoProxyList;
  291. _lpszOffset = _lpszAutoProxyList;
  292. }
  293. else
  294. {
  295. _Error = ERROR_NOT_ENOUGH_MEMORY;
  296. }
  297. }
  298. }
  299. ~PROXY_STATE()
  300. {
  301. DEBUG_ENTER((DBG_OBJECTS,
  302. None,
  303. "~PROXY_STATE",
  304. NULL
  305. ));
  306. if ( _lpszAutoProxyList )
  307. {
  308. FREE_MEMORY(_lpszAutoProxyList );
  309. _lpszAutoProxyList = NULL;
  310. }
  311. DEBUG_LEAVE(0);
  312. }
  313. DWORD
  314. GetError(VOID) const
  315. {
  316. return _Error;
  317. }
  318. BOOL
  319. IsEmpty(VOID) const
  320. {
  321. return (!_lpszOffset || *_lpszOffset == '\0' ) ? TRUE : FALSE;
  322. }
  323. BOOL
  324. IsAnotherProxyAvail(VOID) const
  325. {
  326. return _fIsAnotherProxyAvail;
  327. }
  328. LPSTR
  329. GetLastProxyUsed(INTERNET_PORT *pProxyPort)
  330. {
  331. *pProxyPort = _LastProxyUsedPort;
  332. return _lpszLastProxyUsed;
  333. }
  334. BOOL
  335. GetNextProxy(
  336. IN INTERNET_SCHEME tUrlScheme,
  337. IN BAD_PROXY_LIST & BadProxyList,
  338. OUT LPINTERNET_SCHEME lptProxyScheme,
  339. OUT LPSTR * lplpszProxyHostName,
  340. OUT LPBOOL lpbFreeProxyHostName,
  341. OUT LPDWORD lpdwProxyHostNameLength,
  342. OUT LPINTERNET_PORT lpProxyHostPort
  343. );
  344. };
  345. //
  346. // AUTO_PROXY_ASYNC_MSG - this object is used to pass queries for proxy information across
  347. // from requestors (HTTP_REQUEST_HANDLE_OBJECT, parseUrl, etc) to responders
  348. // (AutoProxy DLL, PROXY_INFO object) who can process the request.
  349. //
  350. class AUTO_PROXY_ASYNC_MSG {
  351. friend class AUTO_PROXY_LIST_ENTRY;
  352. public:
  353. //
  354. // _List - We're a list entry on a queue. But we don't always have to be,
  355. // We can be borne a structure that justs gets passed around and is never
  356. // queued.
  357. //
  358. LIST_ENTRY _List;
  359. //
  360. // _tUrlProtocol - Protocol that this request is using.
  361. //
  362. INTERNET_SCHEME _tUrlProtocol;
  363. //
  364. // _lpszUrl - The requested URL that we are navigating to.
  365. //
  366. LPSTR _lpszUrl;
  367. //
  368. // _dwUrlLength - The size of the URL.
  369. //
  370. DWORD _dwUrlLength;
  371. //
  372. // _lpszUrlHostName - The host name found in the URL.
  373. //
  374. LPSTR _lpszUrlHostName;
  375. //
  376. // _dwUrlHostNameLength - Host name Length
  377. //
  378. DWORD _dwUrlHostNameLength;
  379. //
  380. // _nUrlPort - Dest port used on this Url.
  381. //
  382. INTERNET_PORT _nUrlPort;
  383. //
  384. // _tProxyScheme - Type of proxy we will use. ( HTTP, HTTPS, etc )
  385. //
  386. INTERNET_SCHEME _tProxyScheme;
  387. //
  388. // _lpszProxyHostName - Host name of the proxy we are to use.
  389. //
  390. LPSTR _lpszProxyHostName;
  391. //
  392. // _bFreeProxyHostName - TRUE if _lpszProxyHostName is a copy
  393. //
  394. BOOL _bFreeProxyHostName;
  395. //
  396. // _dwProxyHostNameLength - Proxy Host name length.
  397. //
  398. DWORD _dwProxyHostNameLength;
  399. //
  400. // _nProxyHostPort - Proxy port to use
  401. //
  402. INTERNET_PORT _nProxyHostPort;
  403. //
  404. // _pProxyState - State for enumerating multiple proxies.
  405. //
  406. PROXY_STATE *_pProxyState;
  407. //
  408. // _pmProxyQuery - The Action aka Query we're are doing with this message.
  409. //
  410. PROXY_MESSAGE_TYPE _pmProxyQuery;
  411. //
  412. // _pmaAllocMode - Used to track who owns the allocated string ptrs.
  413. //
  414. PROXY_MESSAGE_ALLOC_TYPE _pmaAllocMode;
  415. //
  416. // _dwQueryResult - TRUE if we are going through a proxy
  417. //
  418. DWORD _dwQueryResult;
  419. //
  420. // _Error - Return code after this call is made.
  421. //
  422. DWORD _Error;
  423. //
  424. // dwProxyVersion - Proxy Verion this was issue a result for
  425. //
  426. DWORD _dwProxyVersion;
  427. VOID SetVersion(VOID) {
  428. _dwProxyVersion = GlobalProxyVersionCount;
  429. }
  430. DWORD GetVersion(VOID) {
  431. return _dwProxyVersion;
  432. }
  433. //
  434. // _MessageFlags - Various
  435. //
  436. union {
  437. struct {
  438. //
  439. // DontWantProxyStrings, don't waste time with allocating strings for my result,
  440. // since I all I care about is generalized proxy info (ie do I have a proxy for ...).
  441. //
  442. DWORD DontWantProxyStrings : 1;
  443. //
  444. // BlockUntilCompletetion, don't return from an async call until the async thread has
  445. // completed processing my proxy query.
  446. //
  447. DWORD BlockUntilCompletetion : 1;
  448. //
  449. // AvoidAsyncCall, don't go async under any curcumstances, so we will return
  450. // what every we can get, even if this means giving incorrect data.
  451. //
  452. DWORD AvoidAsyncCall : 1;
  453. //
  454. // BlockedOnFsm, true a fsm is blocked on this message to complete
  455. //
  456. DWORD BlockedOnFsm : 1 ;
  457. //
  458. // QueryOnCallback, TRUE if we're making a call with this object
  459. // on a FSM callback. Basically we've received results from
  460. // the async thread, but we need to do a final a call so
  461. // the results can be parsed out.
  462. //
  463. DWORD QueryOnCallback : 1;
  464. //
  465. // ForceRefresh, TRUE if we are to force a refresh of cached settings and scripts.
  466. //
  467. DWORD ForceRefresh : 1;
  468. //
  469. // ShowIndication, TRUE if we indicate via callback
  470. // to the user that we performing auto-detection
  471. //
  472. DWORD ShowIndication : 1;
  473. //
  474. // BackroundDetectionPending, TRUE if a backround detection
  475. // is being done while this page is loading
  476. //
  477. DWORD BackroundDetectionPending : 1;
  478. //
  479. // CanCacheResult - TRUE if this result can be cached
  480. //
  481. DWORD CanCacheResult : 1;
  482. } Flags;
  483. //
  484. // Dword - used in initialization ONLY, do NOT use ELSEWHERE !
  485. //
  486. DWORD Dword;
  487. } _MessageFlags;
  488. //public:
  489. AUTO_PROXY_ASYNC_MSG(
  490. IN INTERNET_SCHEME isUrlScheme,
  491. IN LPSTR lpszUrl,
  492. IN LPSTR lpszUrlHostName,
  493. IN DWORD dwUrlHostNameLength
  494. );
  495. AUTO_PROXY_ASYNC_MSG(
  496. IN INTERNET_SCHEME isUrlScheme,
  497. IN LPSTR lpszUrl,
  498. IN DWORD dwUrlLength,
  499. IN LPSTR lpszUrlHostName,
  500. IN DWORD dwUrlHostNameLength,
  501. IN INTERNET_PORT nUrlPort
  502. );
  503. AUTO_PROXY_ASYNC_MSG(
  504. PROXY_MESSAGE_TYPE pmProxyQuery
  505. );
  506. AUTO_PROXY_ASYNC_MSG(
  507. AUTO_PROXY_ASYNC_MSG *pStaticAutoProxy
  508. );
  509. AUTO_PROXY_ASYNC_MSG(
  510. IN INTERNET_SCHEME isUrlScheme,
  511. IN LPSTR lpszUrlHostName,
  512. IN DWORD dwUrlHostNameLength
  513. );
  514. AUTO_PROXY_ASYNC_MSG(
  515. VOID
  516. )
  517. {
  518. Initalize();
  519. }
  520. ~AUTO_PROXY_ASYNC_MSG(
  521. VOID
  522. );
  523. VOID Initalize(
  524. VOID
  525. )
  526. {
  527. InitializeListHead(&_List);
  528. // this is odd, we should just memset this.
  529. _tUrlProtocol = INTERNET_SCHEME_UNKNOWN;
  530. _lpszUrl = NULL;
  531. _dwUrlLength = 0;
  532. _lpszUrlHostName = NULL;
  533. _dwUrlHostNameLength = 0;
  534. _nUrlPort = INTERNET_INVALID_PORT_NUMBER;
  535. _tProxyScheme = INTERNET_SCHEME_UNKNOWN;
  536. _lpszProxyHostName = NULL;
  537. _bFreeProxyHostName = FALSE;
  538. _dwProxyHostNameLength = 0;
  539. _nProxyHostPort = INTERNET_INVALID_PORT_NUMBER;
  540. _pmProxyQuery = PROXY_MSG_INVALID;
  541. _pmaAllocMode = MSG_ALLOC_NONE;
  542. _pProxyState = NULL;
  543. _dwQueryResult = FALSE;
  544. _Error = ERROR_SUCCESS;
  545. _dwProxyVersion = 0;
  546. _MessageFlags.Dword = 0;
  547. }
  548. VOID
  549. SetProxyMsg(
  550. IN INTERNET_SCHEME isUrlScheme,
  551. IN LPSTR lpszUrl,
  552. IN DWORD dwUrlLength,
  553. IN LPSTR lpszUrlHostName,
  554. IN DWORD dwUrlHostNameLength,
  555. IN INTERNET_PORT nUrlPort
  556. );
  557. BOOL IsProxyEnumeration(VOID) const {
  558. if ( _pProxyState &&
  559. !IsDontWantProxyStrings() &&
  560. !_pProxyState->IsEmpty() )
  561. {
  562. return TRUE;
  563. }
  564. return FALSE;
  565. }
  566. BOOL IsAlloced(VOID) const {
  567. return ( _pmaAllocMode == MSG_ALLOC_HEAP ||
  568. _pmaAllocMode == MSG_ALLOC_HEAP_MSG_OBJ_OWNS ) ?
  569. TRUE : FALSE;
  570. }
  571. BOOL IsUrl(VOID) const {
  572. return (_lpszUrl && _dwUrlLength > 0 );
  573. }
  574. BOOL IsUseProxy(VOID) const {
  575. return _dwQueryResult;
  576. }
  577. VOID SetUseProxy(BOOL Value) {
  578. _dwQueryResult = Value;
  579. }
  580. INTERNET_SCHEME GetProxyScheme(VOID) const {
  581. return _tProxyScheme;
  582. }
  583. INTERNET_SCHEME GetUrlScheme(VOID) const {
  584. return _tUrlProtocol;
  585. }
  586. BOOL IsShowIndication(VOID) const {
  587. return (BOOL) _MessageFlags.Flags.ShowIndication;
  588. }
  589. VOID SetShowIndication(BOOL Value) {
  590. _MessageFlags.Flags.ShowIndication = (Value) ? TRUE : FALSE;
  591. }
  592. BOOL IsBackroundDetectionPending(VOID) const {
  593. return (BOOL) _MessageFlags.Flags.BackroundDetectionPending;
  594. }
  595. VOID SetBackroundDetectionPending(BOOL Value) {
  596. _MessageFlags.Flags.BackroundDetectionPending = (Value) ? TRUE : FALSE;
  597. }
  598. BOOL IsDontWantProxyStrings(VOID) const {
  599. return (BOOL) _MessageFlags.Flags.DontWantProxyStrings;
  600. }
  601. VOID SetDontWantProxyStrings(BOOL Value) {
  602. _MessageFlags.Flags.DontWantProxyStrings = (Value) ? TRUE : FALSE;
  603. }
  604. BOOL IsAvoidAsyncCall(VOID) const {
  605. return (BOOL) _MessageFlags.Flags.AvoidAsyncCall;
  606. }
  607. VOID SetAvoidAsyncCall(BOOL Value) {
  608. _MessageFlags.Flags.AvoidAsyncCall = (Value) ? TRUE : FALSE;
  609. }
  610. BOOL IsQueryOnCallback(VOID) const {
  611. return (BOOL) _MessageFlags.Flags.QueryOnCallback;
  612. }
  613. VOID SetQueryOnCallback(BOOL Value) {
  614. _MessageFlags.Flags.QueryOnCallback = (Value) ? TRUE : FALSE;
  615. }
  616. BOOL IsForceRefresh(VOID) const {
  617. return (BOOL) _MessageFlags.Flags.ForceRefresh;
  618. }
  619. VOID SetForceRefresh(BOOL Value) {
  620. _MessageFlags.Flags.ForceRefresh = (Value) ? TRUE : FALSE;
  621. }
  622. BOOL IsBlockUntilCompletetion(VOID) const {
  623. return (BOOL) _MessageFlags.Flags.BlockUntilCompletetion;
  624. }
  625. VOID SetBlockUntilCompletetion(BOOL Value) {
  626. _MessageFlags.Flags.BlockUntilCompletetion = (Value) ? TRUE : FALSE;
  627. }
  628. BOOL IsCanCacheResult(VOID) const {
  629. return (BOOL) _MessageFlags.Flags.CanCacheResult;
  630. }
  631. VOID SetCanCacheResult(BOOL Value) {
  632. _MessageFlags.Flags.CanCacheResult = (Value) ? TRUE : FALSE;
  633. }
  634. BOOL IsBlockedOnFsm(VOID) const {
  635. return (BOOL) _MessageFlags.Flags.BlockedOnFsm;
  636. }
  637. VOID SetBlockedOnFsm(BOOL Value) {
  638. _MessageFlags.Flags.BlockedOnFsm = (Value) ? TRUE : FALSE;
  639. }
  640. PROXY_MESSAGE_TYPE QueryForInfoMessage(VOID) const {
  641. return _pmProxyQuery;
  642. }
  643. DWORD GetError(VOID) {
  644. return _Error;
  645. }
  646. DWORD GetNextProxy(
  647. IN BAD_PROXY_LIST & BadProxyList
  648. )
  649. {
  650. BOOL fSuccess;
  651. INET_ASSERT(_pProxyState);
  652. fSuccess = _pProxyState->GetNextProxy(
  653. _tUrlProtocol,
  654. BadProxyList,
  655. &_tProxyScheme,
  656. &_lpszProxyHostName,
  657. &_bFreeProxyHostName,
  658. &_dwProxyHostNameLength,
  659. &_nProxyHostPort
  660. );
  661. SetUseProxy(fSuccess);
  662. return ERROR_SUCCESS;
  663. }
  664. };
  665. //
  666. // AUTO_PROXY_LIST_ENTRY - contains DLL entry points, and state information,
  667. // for a particalar Auto-Proxy DLL.
  668. //
  669. class AUTO_PROXY_LIST_ENTRY {
  670. private:
  671. friend class AUTO_PROXY_DLLS;
  672. //
  673. // _fDelayedInitialization - TRUE when we are to have queued initializiation of
  674. // this DLL so, it is not done until the first GetProxyInfo call.
  675. //
  676. BOOL _fDelayedInitialization;
  677. //
  678. // _List - there may be a variable number of bypass entries
  679. //
  680. LIST_ENTRY _List;
  681. //
  682. // _fDefault - TRUE, if this entry is the default auto-proxy entry.
  683. //
  684. BOOL _fDefault;
  685. //
  686. // _fInitializedSuccessfully - TRUE, if we have an initalization function
  687. // in the autoproxy dll that initalized successfully. This is to
  688. // prevent calling other callbacks in the auto-proxy dll if it
  689. // failed to initalize.
  690. //
  691. BOOL _fInitializedSuccessfully;
  692. //
  693. // _lpszDllFilePath - file path of DLL to load
  694. //
  695. LPSTR _lpszDllFilePath;
  696. //
  697. // _lpszFileExtensions - string of ';' delimited file extensions to match against
  698. //
  699. LPSTR _lpszFileExtensions;
  700. //
  701. // _lpszMimeType - Mime type string associated with this Auto-Proxy type.
  702. //
  703. LPSTR _lpszMimeType;
  704. //
  705. // _hAutoConfigDLL - open handle to DLL that we are handling.
  706. //
  707. HINSTANCE _hAutoConfigDLL;
  708. //
  709. // (_pGetProxyInfo) ( ... ) - Callback made into auto-proxy DLL to gather
  710. // what proxy(s) we should use for a specific connection.
  711. //
  712. GET_PROXY_INFO_FN _pGetProxyInfo;
  713. //
  714. // (_pGetProxyInfoEx) ( ... ) - Callback made into auto-proxy DLL to gather
  715. // what proxy(s) we should use for a specific connection. Ex versions
  716. // givers caller more control. If Ex is exported, it is used otherwise
  717. // GetProyInfo is used.
  718. //
  719. GET_PROXY_INFO_EX_FN _pGetProxyInfoEx;
  720. //
  721. // (_pProxyDllInit) ( ... ) - Callback made into auto-proxy DLL to notify
  722. // DLL of initialization.
  723. //
  724. PROXY_DLL_INIT_FN _pProxyDllInit;
  725. //
  726. // (_pProxyDllInit) ( ... ) - Notifies DLL before shutdown
  727. //
  728. PROXY_DLL_DEINIT_FN _pProxyDllDeInit;
  729. //
  730. // (_pProxyInfoInvalid) ( ... ) - A request using the returned proxy in GetProxyInfo was invalid.
  731. //
  732. PROXY_INFO_INVALID_FN _pProxyInfoInvalid;
  733. //
  734. // _dwFlags - DWORD flags stored in the registry for this entry.
  735. //
  736. DWORD _dwFlags;
  737. #ifdef INET_DEBUG
  738. BOOL _fUnInited;
  739. #endif
  740. public:
  741. AUTO_PROXY_LIST_ENTRY(
  742. IN LPSTR lpszDllName,
  743. IN LPSTR lpszExtensions,
  744. IN LPSTR lpszMimeType,
  745. IN BOOL fIsDefault,
  746. IN DWORD dwFlags
  747. )
  748. {
  749. DEBUG_ENTER((DBG_OBJECTS,
  750. None,
  751. "AUTO_PROXY_LIST_ENTRY",
  752. NULL
  753. ));
  754. InitializeListHead(&_List);
  755. _pGetProxyInfo = NULL;
  756. _pGetProxyInfoEx = NULL;
  757. _pProxyDllInit = NULL;
  758. _pProxyDllDeInit = NULL;
  759. _pProxyInfoInvalid = NULL;
  760. _hAutoConfigDLL = NULL;
  761. _lpszDllFilePath = lpszDllName ? NewString(lpszDllName) : NULL;
  762. _lpszFileExtensions = lpszExtensions ? NewString(lpszExtensions) : NULL;
  763. _lpszMimeType = lpszMimeType ? NewString(lpszMimeType) : NULL;
  764. _fDefault = fIsDefault;
  765. _fInitializedSuccessfully = FALSE;
  766. _fDelayedInitialization = FALSE;
  767. _dwFlags = dwFlags;
  768. #ifdef INET_DEBUG
  769. _fUnInited = FALSE;
  770. #endif
  771. DEBUG_LEAVE(0);
  772. }
  773. ~AUTO_PROXY_LIST_ENTRY() {
  774. DEBUG_ENTER((DBG_OBJECTS,
  775. None,
  776. "~AUTO_PROXY_LIST_ENTRY",
  777. NULL
  778. ));
  779. if ( _lpszFileExtensions )
  780. {
  781. _lpszFileExtensions = (LPSTR)
  782. FREE_MEMORY(_lpszFileExtensions);
  783. INET_ASSERT(_lpszFileExtensions == NULL);
  784. }
  785. if ( _lpszDllFilePath )
  786. {
  787. _lpszDllFilePath = (LPSTR) FREE_MEMORY(_lpszDllFilePath );
  788. INET_ASSERT(_lpszDllFilePath == NULL);
  789. }
  790. if ( _lpszMimeType )
  791. {
  792. _lpszMimeType = (LPSTR) FREE_MEMORY(_lpszMimeType);
  793. INET_ASSERT(_lpszMimeType == NULL);
  794. }
  795. //INET_ASSERT(_hAutoConfigDLL == NULL); // should have free libed DLL before calling destructor
  796. DEBUG_LEAVE(0);
  797. }
  798. VOID
  799. SetDllName(
  800. IN LPSTR lpszDllPath
  801. )
  802. {
  803. if ( _lpszDllFilePath )
  804. {
  805. _lpszDllFilePath = (LPSTR)
  806. FREE_MEMORY(_lpszDllFilePath);
  807. INET_ASSERT(_lpszDllFilePath == NULL);
  808. }
  809. _lpszDllFilePath = lpszDllPath;
  810. }
  811. DWORD
  812. LoadEntry(
  813. VOID
  814. );
  815. VOID
  816. UnloadEntry(
  817. VOID
  818. );
  819. BOOL
  820. ProxyInfoInvalid(
  821. IN LPSTR lpszMime,
  822. IN LPSTR lpszUrl,
  823. IN DWORD dwUrlLength,
  824. IN LPSTR lpszProxyHostName,
  825. IN DWORD dwProxyHostNameLength
  826. );
  827. BOOL
  828. ProxyDllDeInit(
  829. IN LPSTR lpszMime,
  830. IN DWORD dwReserved
  831. );
  832. DWORD
  833. GetProxyInfoEx(
  834. IN AUTO_PROXY_ASYNC_MSG *pQueryForProxyInfo
  835. );
  836. DWORD
  837. GetProxyInfo(
  838. IN AUTO_PROXY_ASYNC_MSG *pQueryForProxyInfo
  839. );
  840. BOOL
  841. DelayProxyDllInit(
  842. IN DWORD dwVersion,
  843. IN LPSTR lpszDownloadedTempFile,
  844. IN LPSTR lpszMime,
  845. IN AUTO_PROXY_HELPER_APIS *pAutoProxyCallbacks,
  846. IN DWORD dwReserved,
  847. OUT LPBOOL lpfCleanupFile
  848. );
  849. BOOL
  850. ProxyDllInit (
  851. IN DWORD dwVersion,
  852. IN LPSTR lpszDownloadedTempFile,
  853. IN LPSTR lpszMime,
  854. IN AUTO_PROXY_HELPER_APIS *pAutoProxyCallbacks,
  855. IN DWORD_PTR dwReserved
  856. );
  857. BOOL
  858. IsGetProxyInfoEx(
  859. VOID
  860. )
  861. {
  862. if ( _pGetProxyInfoEx )
  863. {
  864. return TRUE;
  865. }
  866. else
  867. {
  868. return FALSE;
  869. }
  870. }
  871. BOOL
  872. IsGetProxyInfo(
  873. VOID
  874. )
  875. {
  876. if ( _pGetProxyInfo )
  877. {
  878. return TRUE;
  879. }
  880. else
  881. {
  882. return FALSE;
  883. }
  884. }
  885. BOOL
  886. IsLoaded(
  887. VOID
  888. )
  889. {
  890. if ( _hAutoConfigDLL )
  891. {
  892. return TRUE;
  893. }
  894. return FALSE;
  895. }
  896. BOOL
  897. IsDefault(
  898. VOID
  899. )
  900. {
  901. return _fDefault;
  902. }
  903. };
  904. //
  905. // AUTO_PROXY_DLLS - tracks a list of regisitered DLLs that handle auto-proxy.
  906. // Auto-Proxy is the ability to download a specialized configuration file,
  907. // match the file with a registered DLL. The DLL, once matched, will calculate
  908. // which proxy(s) to use.
  909. //
  910. class AUTO_PROXY_DLLS {
  911. private:
  912. //
  913. // _List - serialized list of AUTO_PROXY_LIST_ENTRY objects
  914. //
  915. SERIALIZED_LIST _List;
  916. //
  917. // _Error - errors stored here from initialization
  918. //
  919. DWORD _Error;
  920. //
  921. // _ProxySettings - the various fields to track our proxy settings
  922. //
  923. WINHTTP_AUTOPROXY_RESULTS _ProxySettings;
  924. //
  925. // _pSelectedAutoProxyEntry - selected auto-proxy entry that will
  926. // accept all auto-proxy operations.
  927. //
  928. AUTO_PROXY_LIST_ENTRY * _pSelectedAutoProxyEntry;
  929. //
  930. // _aphAutoProxyAPIs - A V-Table that is passed into to the Auto-ProxyDll
  931. // to allow them to call us for DNS requests.
  932. //
  933. AUTO_PROXY_HELPER_APIS _aphAutoProxyAPIs;
  934. //
  935. // _CritSec - acquire this when accessing header structure - stops multiple
  936. // threads clashing while modifying or changing auto-proxy information
  937. //
  938. CCritSec _CritSec;
  939. //
  940. // _apsState - Used to track the state of this object state, for
  941. // syncronization purposes, ( ie when to go async or not )
  942. //
  943. AUTO_PROXY_STATE _apsState;
  944. //
  945. // _dwWaitTimeOut - time till WaitForSingleObject times out.
  946. //
  947. DWORD _dwWaitTimeOut;
  948. //
  949. // _fEnableReload - Forces a reload of auto-proxy files every X seconds.
  950. //
  951. BOOL _fEnableReload;
  952. //
  953. // _dwLastThreadAccess - Last GetTickCount(). Used to calculate a basic
  954. // timer for reloads of auto-proxy files.
  955. //
  956. DWORD _dwLastThreadAccess;
  957. //
  958. // _lpszUserAgent - User agent passed in.
  959. //
  960. LPSTR _lpszUserAgent;
  961. //
  962. // _fModifiedInProcess - TRUE, if the settings passed in, SHOULD NOT BE PERSISTED to the registry
  963. //
  964. BOOL _fModifiedInProcess;
  965. //
  966. // _dwUpdatedProxySettingsVersion - an counter that is updated to match the current version.
  967. // that has been refreshed to. Used to note when we need to refresh proxy settings.
  968. //
  969. DWORD _dwUpdatedProxySettingsVersion;
  970. VOID
  971. ResetTimerCounter(
  972. BOOL fEnableTimer,
  973. DWORD dwWaitTimeOut
  974. )
  975. {
  976. _fEnableReload = fEnableTimer ;
  977. if ( _fEnableReload )
  978. {
  979. _dwWaitTimeOut = dwWaitTimeOut;
  980. _dwLastThreadAccess = GetTickCountWrap();
  981. INET_ASSERT(_dwWaitTimeOut != 0);
  982. }
  983. else
  984. {
  985. _dwWaitTimeOut = DEFAULT_AUTO_PROXY_THREAD_TIME_OUT;
  986. }
  987. }
  988. BOOL
  989. ChkForAndUpdateTimerCounter(
  990. VOID
  991. )
  992. {
  993. BOOL fTimetoUpdate = FALSE;
  994. if ( _fEnableReload )
  995. {
  996. DWORD dwMsecsElapsed = GetTickCountWrap() - _dwLastThreadAccess;
  997. if ( dwMsecsElapsed >= _dwWaitTimeOut )
  998. {
  999. _dwWaitTimeOut = 0;
  1000. fTimetoUpdate = TRUE;
  1001. }
  1002. else
  1003. {
  1004. fTimetoUpdate = FALSE;
  1005. _dwWaitTimeOut -= dwMsecsElapsed;
  1006. }
  1007. _dwLastThreadAccess = GetTickCountWrap();
  1008. }
  1009. return fTimetoUpdate;
  1010. }
  1011. DWORD
  1012. ReadAutoProxyRegistrySettings(
  1013. VOID
  1014. );
  1015. VOID
  1016. SelectAutoProxy(
  1017. AUTO_PROXY_LIST_ENTRY * pSelectedEntry
  1018. )
  1019. {
  1020. _pSelectedAutoProxyEntry = pSelectedEntry;
  1021. }
  1022. VOID SetState(AUTO_PROXY_STATE apsState) {
  1023. _apsState = apsState;
  1024. }
  1025. AUTO_PROXY_STATE GetState(VOID) {
  1026. return _apsState;
  1027. }
  1028. //
  1029. // _hAutoProxyThread - handle to thread that processes Auto-Proxy commands.
  1030. //
  1031. HANDLE _hAutoProxyThread;
  1032. //
  1033. // _hAutoProxyThreadEvent - handle to event that will become signaled when
  1034. // new auto-proxy messages are to be processed
  1035. //
  1036. HANDLE _hAutoProxyThreadEvent;
  1037. //
  1038. // _hAutoProxyStartEvent - handle to event that will be used to block
  1039. // until the auto-proxy thread starts to run.
  1040. //
  1041. HANDLE _hAutoProxyStartEvent;
  1042. //
  1043. // _dwAutoProxyCurrentThreadId - thread ID of our Auto-Proxy Thread.
  1044. //
  1045. DWORD _dwAutoProxyThreadId;
  1046. DWORD
  1047. DownloadProxyInfo(
  1048. IN LPCSTR lpszAutoProxy
  1049. );
  1050. DWORD
  1051. DoNestedProxyInfoDownload(
  1052. IN LPCSTR lpszAutoProxy,
  1053. IN WINHTTP_AUTOPROXY_RESULTS * lpProxySettings,
  1054. IN BOOL fForceRefresh
  1055. );
  1056. DWORD
  1057. StartBackroundDetectionIfNeeded(
  1058. VOID
  1059. );
  1060. DWORD
  1061. GetAutoProxyStringEntry(
  1062. IN LPSTR lpszRegName,
  1063. IN OUT LPSTR * lplpszAllocatedRegValue
  1064. );
  1065. DWORD
  1066. GetHostAddresses(
  1067. DWORD ** ppdwDetectedInterfaceIp,
  1068. DWORD * pdwDetectedInterfaceIpCount
  1069. ) ;
  1070. BOOL
  1071. IsExpiredUrl(
  1072. LPCSTR lpszUrl
  1073. );
  1074. VOID
  1075. SetExpiredUrl(
  1076. LPCSTR lpszUrl
  1077. );
  1078. BOOL IsModifiedInProcess(VOID) {
  1079. return _fModifiedInProcess;
  1080. }
  1081. public:
  1082. AUTO_PROXY_DLLS() {
  1083. DEBUG_ENTER((DBG_OBJECTS,
  1084. None,
  1085. "AUTO_PROXY_DLLS",
  1086. ""
  1087. ));
  1088. InitializeSerializedList(&_List);
  1089. //
  1090. // Warning: Initalize vars to NULL, BEFORE AddListFromRegistry is called.
  1091. //
  1092. _pSelectedAutoProxyEntry = NULL;
  1093. _hAutoProxyStartEvent = NULL;
  1094. _apsState = AUTO_PROXY_DISABLED;
  1095. _dwWaitTimeOut = DEFAULT_AUTO_PROXY_THREAD_TIME_OUT;
  1096. _fEnableReload = FALSE;
  1097. _dwUpdatedProxySettingsVersion = 0;
  1098. //
  1099. // Zero out our settings structure
  1100. //
  1101. memset((void *) &_ProxySettings, 0, sizeof(_ProxySettings));
  1102. _lpszUserAgent = NULL;
  1103. if (!_CritSec.Init())
  1104. {
  1105. _Error = ERROR_NOT_ENOUGH_MEMORY;
  1106. }
  1107. else
  1108. {
  1109. _Error = ReadAutoProxyRegistrySettings();
  1110. }
  1111. DEBUG_LEAVE(0);
  1112. }
  1113. ~AUTO_PROXY_DLLS() {
  1114. DEBUG_ENTER((DBG_OBJECTS,
  1115. None,
  1116. "~AUTO_PROXY_DLLS",
  1117. NULL
  1118. ));
  1119. DestroyAutoProxyDll(FALSE); // only destroys reg vars.
  1120. WipeProxySettings();
  1121. TerminateSerializedList(&_List);
  1122. _CritSec.FreeLock();
  1123. if ( _lpszUserAgent ) {
  1124. FREE_MEMORY(_lpszUserAgent);
  1125. }
  1126. DEBUG_LEAVE(0);
  1127. }
  1128. VOID
  1129. DestroyAutoProxyDll(
  1130. IN BOOL fUnloadDlls
  1131. )
  1132. {
  1133. LockAutoProxy();
  1134. LockSerializedList(&_List);
  1135. while (!IsSerializedListEmpty(&_List)) {
  1136. //
  1137. // remove the PROXY_BYPASS_LIST_ENTRY at the head of the serialized
  1138. // list
  1139. //
  1140. LPVOID entry = SlDequeueHead(&_List);
  1141. AUTO_PROXY_LIST_ENTRY *pAutoProxyDllEntry;
  1142. //
  1143. // entry should not be NULL - IsSerializedListEmpty() told us we
  1144. // could expect something
  1145. //
  1146. INET_ASSERT(entry != NULL);
  1147. pAutoProxyDllEntry = CONTAINING_RECORD(entry, AUTO_PROXY_LIST_ENTRY, _List);
  1148. if ( fUnloadDlls )
  1149. {
  1150. pAutoProxyDllEntry->UnloadEntry();
  1151. }
  1152. delete pAutoProxyDllEntry;
  1153. }
  1154. UnlockSerializedList(&_List);
  1155. UnlockAutoProxy();
  1156. }
  1157. VOID
  1158. WipeProxySettings(
  1159. WINHTTP_AUTOPROXY_RESULTS * lpProxySettings
  1160. );
  1161. VOID
  1162. WipeProxySettings(VOID) {
  1163. WipeProxySettings(&_ProxySettings);
  1164. }
  1165. DWORD GetError(VOID) const {
  1166. return _Error;
  1167. }
  1168. BOOL
  1169. SelectAutoProxyByFileExtension(
  1170. LPCSTR lpszAutoProxyPath
  1171. );
  1172. BOOL
  1173. SelectAutoProxyByDefault(
  1174. VOID
  1175. );
  1176. BOOL
  1177. SelectAutoProxyByMime(
  1178. IN LPSTR lpszMimeType
  1179. );
  1180. BOOL
  1181. IsAutoProxy(
  1182. VOID
  1183. )
  1184. {
  1185. BOOL fIsAutoProxy;
  1186. LockAutoProxy();
  1187. fIsAutoProxy = ! IsSerializedListEmpty(&_List);
  1188. UnlockAutoProxy();
  1189. return fIsAutoProxy;
  1190. }
  1191. AUTO_PROXY_LIST_ENTRY *
  1192. GetSelectedAutoProxyEntry(
  1193. VOID
  1194. )
  1195. {
  1196. return _pSelectedAutoProxyEntry;
  1197. }
  1198. BOOL LockAutoProxy(VOID) {
  1199. return _CritSec.Lock();
  1200. }
  1201. VOID UnlockAutoProxy(VOID) {
  1202. _CritSec.Unlock();
  1203. }
  1204. BOOL IsProxyAutoDetectEnabled(WINHTTP_AUTOPROXY_RESULTS * lpProxySettings) {
  1205. return (lpProxySettings->dwFlags & PROXY_TYPE_AUTO_DETECT);
  1206. }
  1207. BOOL IsProxyAutoDetectEnabled(VOID) {
  1208. return (IsProxyAutoDetectEnabled(&_ProxySettings));
  1209. }
  1210. BOOL IsProxyAutoConfigEnabled(WINHTTP_AUTOPROXY_RESULTS * lpProxySettings) {
  1211. return (lpProxySettings->dwFlags & PROXY_TYPE_AUTO_PROXY_URL);
  1212. }
  1213. BOOL
  1214. IsConfigValidForAutoProxyThread(
  1215. VOID
  1216. );
  1217. BOOL
  1218. IsProxyAutoDetectNeeded(
  1219. WINHTTP_AUTOPROXY_RESULTS * lpProxySettings
  1220. );
  1221. DWORD
  1222. CheckForTimerConfigChanges(
  1223. IN DWORD dwMinsToPoll
  1224. );
  1225. DWORD
  1226. ProcessProxyQueryForInfo(
  1227. IN OUT AUTO_PROXY_ASYNC_MSG * ppQueryForInfo
  1228. ) ;
  1229. DWORD
  1230. GetProxySettings(
  1231. OUT WINHTTP_AUTOPROXY_RESULTS * lpProxySettings,
  1232. IN BOOL fCheckVersion = FALSE
  1233. );
  1234. DWORD
  1235. QueryProxySettings(
  1236. IN OUT AUTO_PROXY_ASYNC_MSG **ppQueryForInfo
  1237. );
  1238. DWORD
  1239. StartDownloadOfProxyInfo(
  1240. IN WINHTTP_AUTOPROXY_OPTIONS * pAutoProxyOptions
  1241. );
  1242. };
  1243. //
  1244. // external func declariations, note that the DLL does not have to export the full set of these
  1245. // functions, rather the DLL can export only the functions it impliments.
  1246. //
  1247. BOOL
  1248. CALLBACK
  1249. InternetProxyInfoInvalid ( // NOT implimented
  1250. IN LPSTR lpszMime,
  1251. IN LPSTR lpszUrl,
  1252. IN DWORD dwUrlLength,
  1253. IN LPSTR lpszProxyHostName,
  1254. IN DWORD dwProxyHostNameLength
  1255. );
  1256. BOOL
  1257. CALLBACK
  1258. InternetDeInitializeAutoProxyDll(
  1259. IN LPSTR lpszMime,
  1260. IN DWORD dwReserved
  1261. );
  1262. BOOL
  1263. CALLBACK
  1264. InternetGetProxyInfo(
  1265. IN LPCSTR lpszUrl,
  1266. IN DWORD dwUrlLength,
  1267. IN LPSTR lpszUrlHostName,
  1268. IN DWORD dwUrlHostNameLength,
  1269. OUT LPSTR * lplpszProxyHostName,
  1270. OUT LPDWORD lpdwProxyHostNameLength
  1271. ) ;
  1272. BOOL
  1273. CALLBACK
  1274. InternetGetProxyInfoEx(
  1275. IN INTERNET_SCHEME tUrlProtocol,
  1276. IN LPCSTR lpszUrl,
  1277. IN DWORD dwUrlLength,
  1278. IN LPSTR lpszUrlHostName,
  1279. IN DWORD dwUrlHostNameLength,
  1280. IN INTERNET_PORT nUrlPort,
  1281. OUT LPINTERNET_SCHEME lptProxyScheme,
  1282. OUT LPSTR * lplpszProxyHostName,
  1283. OUT LPDWORD lpdwProxyHostNameLength,
  1284. OUT LPINTERNET_PORT lpProxyHostPort
  1285. ) ;
  1286. BOOL
  1287. CALLBACK
  1288. InternetInitializeAutoProxyDll(
  1289. IN DWORD dwVersion,
  1290. IN LPSTR lpszDownloadedTempFile,
  1291. IN LPSTR lpszMime,
  1292. IN AUTO_PROXY_HELPER_APIS *pAutoProxyCallbacks,
  1293. IN DWORD dwReserved
  1294. );
  1295. DWORD
  1296. DetectAutoProxyUrl(
  1297. IN DWORD dwDetectFlags,
  1298. OUT LPSTR * lpszAutoProxyUrl
  1299. );
  1300. #ifdef unix
  1301. extern "C"
  1302. #endif /* unix */
  1303. BOOL
  1304. CALLBACK
  1305. InternetInitializeAutoProxyDll(
  1306. DWORD dwReserved
  1307. );
  1308. #endif /* _AUTOPROX_HXX_ */