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.

234 lines
4.7 KiB

  1. #include <inetreg.h>
  2. #define BLOB_BUFF_GRANULARITY 1024
  3. class CRegBlob
  4. {
  5. private:
  6. HKEY _hkey;
  7. BOOL _fWrite;
  8. BOOL _fCommit;
  9. DWORD _dwOffset;
  10. DWORD _dwBufferLimit;
  11. BYTE * _pBuffer;
  12. LPCSTR _pszValue;
  13. public:
  14. CRegBlob(BOOL fWrite);
  15. ~CRegBlob();
  16. DWORD Init(HKEY hBaseKey, LPCSTR pszSubKey, LPCSTR pszValue);
  17. DWORD Abandon();
  18. DWORD Commit();
  19. DWORD WriteString(LPCSTR pszString);
  20. DWORD ReadString(LPCSTR * ppszString);
  21. DWORD WriteBytes(LPCVOID pBytes, DWORD dwByteCount);
  22. DWORD ReadBytes(LPVOID pBytes, DWORD dwByteCount);
  23. private:
  24. DWORD Encrpyt();
  25. DWORD Decrypt();
  26. };
  27. class CRefdKey
  28. {
  29. public:
  30. ULONG CRefdKey::AddRef()
  31. {
  32. return InterlockedIncrement(&_cRef);
  33. }
  34. ULONG CRefdKey::Release()
  35. {
  36. UINT cNewRef = InterlockedDecrement(&_cRef);
  37. if (cNewRef == 0)
  38. {
  39. delete this;
  40. }
  41. return cNewRef;
  42. }
  43. HKEY GetKey() { return _hkey; }
  44. CRefdKey(HKEY hkey) : _hkey(hkey), _cRef(1) {}
  45. ~CRefdKey()
  46. {
  47. if ((_hkey != NULL) &&
  48. (_hkey != HKEY_LOCAL_MACHINE) &&
  49. (_hkey != HKEY_CURRENT_USER))
  50. {
  51. RegCloseKey(_hkey);
  52. }
  53. }
  54. private:
  55. LONG _cRef;
  56. HKEY _hkey;
  57. };
  58. // NOTE! Changes to the following struct must be made in a backwards-compatible
  59. // manner. Do not remove fields; only add to the end of the struct.
  60. // And if you do change the struct, you must increment
  61. // INTERNET_PROXY_INFO_EX_VERSION and the code in ReadProxySettings to
  62. // support reading in older versions.
  63. typedef struct {
  64. //
  65. // dwStructSize - Structure size to handle growing list of new entries or priv/pub structures
  66. //
  67. DWORD dwStructSize;
  68. //
  69. // dwFlags - Proxy type flags
  70. //
  71. DWORD dwFlags;
  72. //
  73. // dwCurrentSettingsVersion - a counter incremented every time we change our settings
  74. //
  75. DWORD dwCurrentSettingsVersion;
  76. //
  77. // lpszConnectionName - name of the Connectoid for this connection
  78. //
  79. LPCSTR lpszConnectionName;
  80. //
  81. // lpszProxy - proxy server list
  82. //
  83. LPCSTR lpszProxy;
  84. //
  85. // lpszProxyBypass - proxy bypass list
  86. //
  87. LPCSTR lpszProxyBypass;
  88. //
  89. // lpszAutoconfigUrl - autoconfig URL
  90. //
  91. LPCSTR lpszAutoconfigUrl;
  92. LPCSTR lpszAutoconfigSecondaryUrl;
  93. //
  94. // dwAutoDiscoveryFlags - auto detect flags.
  95. //
  96. DWORD dwAutoDiscoveryFlags;
  97. //
  98. // lpszLastKnownGoodAutoConfigUrl - Last Successful Url
  99. //
  100. LPCSTR lpszLastKnownGoodAutoConfigUrl;
  101. //
  102. // dwAutoconfigReloadDelayMins - number of mins until automatic
  103. // refresh of auto-config Url, 0 == disabled.
  104. //
  105. DWORD dwAutoconfigReloadDelayMins;
  106. //
  107. // ftLastKnownDetectTime - When the last known good Url was found with detection.
  108. //
  109. FILETIME ftLastKnownDetectTime;
  110. //
  111. // dwDetectedInterfaceIpCount - Number of IPs detected in last detection
  112. //
  113. DWORD dwDetectedInterfaceIpCount;
  114. //
  115. // dwDetectedInterfaceIp - Array of DWORD of IPs detected in last detection
  116. //
  117. DWORD *pdwDetectedInterfaceIp;
  118. } INTERNET_PROXY_INFO_EX, * LPINTERNET_PROXY_INFO_EX;
  119. // version stamp of INTERNET_PROXY_INFO_EX
  120. #define INTERNET_PROXY_INFO_EX_VERSION 60 // 60 := IE 5.x & 6.0 format
  121. // name of blob for saved legacy settings
  122. #define LEGACY_SAVE_NAME "SavedLegacySettings"
  123. DWORD
  124. WriteProxySettings(
  125. LPINTERNET_PROXY_INFO_EX pInfo,
  126. BOOL fForceUpdate
  127. );
  128. DWORD
  129. ReadProxySettings(
  130. LPINTERNET_PROXY_INFO_EX pInfo
  131. );
  132. void
  133. CleanProxyStruct(
  134. LPINTERNET_PROXY_INFO_EX pInfo
  135. );
  136. BOOL
  137. ReadLegacyProxyInfo(
  138. IN LPCTSTR pszKey,
  139. LPINTERNET_PROXY_INFO_EX pProxy
  140. );
  141. BOOL
  142. WriteLegacyProxyInfo(
  143. IN LPCTSTR pszKey,
  144. LPINTERNET_PROXY_INFO_EX pProxy,
  145. IN BOOL fOverwrite
  146. );
  147. DWORD
  148. SetPerConnOptions(
  149. HINTERNET hInternet,
  150. BOOL fIsAutoProxyThread,
  151. LPINTERNET_PER_CONN_OPTION_LISTA pList
  152. );
  153. DWORD
  154. QueryPerConnOptions(
  155. HINTERNET hInternet,
  156. BOOL fIsAutoProxyThread,
  157. LPINTERNET_PER_CONN_OPTION_LISTA pList
  158. );
  159. BOOL
  160. IsConnectionMatch(
  161. LPCSTR lpszConnection1,
  162. LPCSTR lpszConnection2
  163. );
  164. CRefdKey*
  165. FindBaseProxyKey(
  166. VOID
  167. );
  168. BOOL
  169. CloseBaseProxyKey(
  170. CRefdKey* prk
  171. );
  172. BOOL
  173. EnableAutodiscoverForDialup(
  174. VOID
  175. );
  176. VOID
  177. CheckForUpgrade(
  178. VOID
  179. );