Example #1
0
        internal unsafe static bool IsValidTimeForLkgScriptLocation(FILETIME ftLastKnownDetectTime)
        {
            // Get Current System Time.
            FILETIME ftCurrentTime = new FILETIME();

            SafeNclNativeMethods.GetSystemTimeAsFileTime(ref ftCurrentTime);

            UInt64 ftDetect = (UInt64)ftLastKnownDetectTime.dwHighDateTime;

            ftDetect <<= (sizeof(int) * 8);
            ftDetect  |= (UInt64)(uint)ftLastKnownDetectTime.dwLowDateTime;

            UInt64 ftCurrent = (UInt64)ftCurrentTime.dwHighDateTime;

            ftCurrent <<= (sizeof(int) * 8);
            ftCurrent  |= (UInt64)(uint)ftCurrentTime.dwLowDateTime;

            GlobalLog.Print("RegBlobWebProxyDataBuilder::BuildInternal() Detect Time:" + ValidationHelper.ToString(ftDetect));
            GlobalLog.Print("RegBlobWebProxyDataBuilder::BuildInternal() Current Time:" + ValidationHelper.ToString(ftCurrent));
            GlobalLog.Print("RegBlobWebProxyDataBuilder::BuildInternal() 7 days:" + ValidationHelper.ToString(s_lkgScriptValidTime));
            GlobalLog.Print("RegBlobWebProxyDataBuilder::BuildInternal() Delta Time:" + ValidationHelper.ToString((UInt64)(ftCurrent - ftDetect)));

            return((ftCurrent - ftDetect) < s_lkgScriptValidTime);
        }
Example #2
0
        protected override void BuildInternal()
        {
            GlobalLog.Enter("RegBlobWebProxyDataBuilder#" + ValidationHelper.HashString(this) + "::BuildInternal() m_Connectoid:" + ValidationHelper.ToString(m_Connectoid));

            // DON'T TOUCH THE ORDERING OF THE CALLS TO THE INSTANCE OF ProxyRegBlob
            bool success = ReadRegSettings();

            if (success)
            {
                success = ReadInt32() >= IE50StrucSize;
            }
            if (!success)
            {
                // if registry access fails rely on automatic detection
                SetAutoDetectSettings(true);
                return;
            }
            // read the rest of the items out
            ReadInt32();                                             // incremental version# of current settings (ignored)
            ProxyTypeFlags proxyFlags = (ProxyTypeFlags)ReadInt32(); // flags

            GlobalLog.Print("RegBlobWebProxyDataBuilder::BuildInternal() proxyFlags:" + ValidationHelper.ToString(proxyFlags));

            string addressString     = ReadString(); // proxy name
            string proxyBypassString = ReadString(); // proxy bypass

            GlobalLog.Print("RegBlobWebProxyDataBuilder::BuildInternal() proxyAddressString:" + ValidationHelper.ToString(addressString) + " proxyBypassString:" + ValidationHelper.ToString(proxyBypassString));

            //
            // Once we verify that the flag for proxy is enabled,
            // Parse UriString that is stored, may be in the form,
            //  of "http=http://http-proxy;ftp="ftp=http://..." must
            //  handle this case along with just a URI.
            //
            if ((proxyFlags & ProxyTypeFlags.PROXY_TYPE_PROXY) != 0)
            {
                SetProxyAndBypassList(addressString, proxyBypassString);
            }


#if !FEATURE_PAL
            SetAutoDetectSettings((proxyFlags & ProxyTypeFlags.PROXY_TYPE_AUTO_DETECT) != 0);

            string autoConfigUrlString = ReadString(); // autoconfig url
            GlobalLog.Print("RegBlobWebProxyDataBuilder::BuildInternal() scriptLocation:" + ValidationHelper.ToString(addressString));
            if ((proxyFlags & ProxyTypeFlags.PROXY_TYPE_AUTO_PROXY_URL) != 0)
            {
                SetAutoProxyUrl(autoConfigUrlString);
            }

            // The final straw against attempting to use the WinInet LKG script location was, it's invalid when IPs have changed even if the
            // connectoid hadn't.  Doing that validation didn't seem worth it (error-prone, expensive, unsupported).
#if USE_WINIET_AUTODETECT_CACHE
            proxyIE5Settings.ReadInt32(); // autodetect flags (ignored)

            // reuse addressString for lkgScriptLocationString
            addressString = proxyIE5Settings.ReadString(); // last known good auto-proxy url

            // read ftLastKnownDetectTime
            FILETIME ftLastKnownDetectTime = proxyIE5Settings.ReadFileTime();

            // Verify if this lkgScriptLocationString has timed out
            //
            if (IsValidTimeForLkgScriptLocation(ftLastKnownDetectTime))
            {
                // reuse address for lkgScriptLocation
                GlobalLog.Print("RegBlobWebProxyDataBuilder::BuildInternal() lkgScriptLocation:" + ValidationHelper.ToString(addressString));
                if (Uri.TryCreate(addressString, UriKind.Absolute, out address))
                {
                    webProxyData.lkgScriptLocation = address;
                }
            }
            else
            {
#if TRAVE
                SYSTEMTIME st = new SYSTEMTIME();
                bool       f  = SafeNclNativeMethods.FileTimeToSystemTime(ref ftLastKnownDetectTime, ref st);
                if (f)
                {
                    GlobalLog.Print("RegBlobWebProxyDataBuilder::BuildInternal() ftLastKnownDetectTime:" + ValidationHelper.ToString(st));
                }
#endif // TRAVE
                GlobalLog.Print("RegBlobWebProxyDataBuilder::BuildInternal() Ignoring Timed out lkgScriptLocation:" + ValidationHelper.ToString(addressString));

                // Now rely on automatic detection settings set above
                // based on the proxy flags (webProxyData.automaticallyDetectSettings).
                //
            }
#endif

            /*
             * // This is some of the rest of the proxy reg key blob parsing.
             * //
             * // Read Inte---- IPs
             * int iftCount = proxyIE5Settings.ReadInt32();
             * for (int ift = 0; ift < iftCount; ++ift) {
             *  proxyIE5Settings.ReadInt32();
             * }
             *
             * // Read lpszAutoconfigSecondaryUrl
             * string autoconfigSecondaryUrl = proxyIE5Settings.ReadString();
             *
             * // Read dwAutoconfigReloadDelayMins
             * int autoconfigReloadDelayMins = proxyIE5Settings.ReadInt32();
             */
#endif
            GlobalLog.Leave("RegBlobWebProxyDataBuilder#" + ValidationHelper.HashString(this) + "::BuildInternal()");
        }