public bool Attach() { if (!this._bIsAttached) { this.CollectConnectoidAndGatewayInfo(); WinINETProxyInfo oNewInfo = new WinINETProxyInfo { bUseManualProxies = true, bAllowDirect = true, sHttpProxy = CONFIG.sFiddlerListenHostPort }; if (CONFIG.bCaptureCONNECT) { oNewInfo.sHttpsProxy = CONFIG.sFiddlerListenHostPort; } else { oNewInfo.sHttpsProxy = this.piPrior.sHttpsProxy; } if (this.piPrior.bUseManualProxies) { oNewInfo.sFtpProxy = this.piPrior.sFtpProxy; oNewInfo.sSocksProxy = this.piPrior.sSocksProxy; } if (CONFIG.bCaptureFTP) { oNewInfo.sFtpProxy = CONFIG.sFiddlerListenHostPort; } oNewInfo.sHostsThatBypass = CONFIG.sHostsThatBypassFiddler; if (CONFIG.bHookWithPAC) { if (FiddlerApplication.Prefs.GetBoolPref("fiddler.proxy.pacfile.usefileprotocol", true)) { oNewInfo.sPACScriptLocation = "file://" + CONFIG.GetPath("Pac"); } else { oNewInfo.sPACScriptLocation = "http://" + CONFIG.sFiddlerListenHostPort + "/proxy.pac"; } } if (!CONFIG.bIsViewOnly) { if (this.oAllConnectoids.HookConnections(oNewInfo)) { this._bIsAttached = true; FiddlerApplication.OnFiddlerAttach(); this.WriteAutoProxyPACFile(true); } else { FiddlerApplication.DoNotifyUser("Failed to register Fiddler as the system proxy.", "Error"); _setDynamicRegistryKey(false); return(false); } _setDynamicRegistryKey(true); } } return(true); }
internal bool Attach(bool bCollectGWInfo) { if (this._bIsAttached) { return(true); } if (CONFIG.bIsViewOnly) { return(false); } if (bCollectGWInfo) { this.CollectConnectoidAndGatewayInfo(); } WinINETProxyInfo winINETProxyInfo = new WinINETProxyInfo(); winINETProxyInfo.bUseManualProxies = true; winINETProxyInfo.bAllowDirect = true; winINETProxyInfo.sHttpProxy = CONFIG.sFiddlerListenHostPort; if (CONFIG.bCaptureCONNECT) { winINETProxyInfo.sHttpsProxy = CONFIG.sFiddlerListenHostPort; } else { if (this.piSystemGateway != null && this.piSystemGateway.bUseManualProxies) { winINETProxyInfo.sHttpsProxy = this.piSystemGateway.sHttpsProxy; } } if (CONFIG.bCaptureFTP) { winINETProxyInfo.sFtpProxy = CONFIG.sFiddlerListenHostPort; } else { if (this.piSystemGateway != null && this.piSystemGateway.bUseManualProxies) { winINETProxyInfo.sFtpProxy = this.piSystemGateway.sFtpProxy; } } if (this.piSystemGateway != null && this.piSystemGateway.bUseManualProxies) { winINETProxyInfo.sSocksProxy = this.piSystemGateway.sSocksProxy; } winINETProxyInfo.sHostsThatBypass = CONFIG.sHostsThatBypassFiddler; if (CONFIG.bHookWithPAC) { if (FiddlerApplication.Prefs.GetBoolPref("fiddler.proxy.pacfile.usefileprotocol", true)) { winINETProxyInfo.sPACScriptLocation = "file://" + CONFIG.GetPath("Pac"); } else { winINETProxyInfo.sPACScriptLocation = "http://" + CONFIG.sFiddlerListenHostPort + "/proxy.pac"; } } if (this.oAllConnectoids == null) { this.CollectConnectoidAndGatewayInfo(); } if (this.oAllConnectoids.HookConnections(winINETProxyInfo)) { this._bIsAttached = true; FiddlerApplication.OnFiddlerAttach(); this.WriteAutoProxyPACFile(true); if (this.oRegistryWatcher == null && FiddlerApplication.Prefs.GetBoolPref("fiddler.proxy.WatchRegistry", true)) { this.oRegistryWatcher = RegistryWatcher.WatchKey(RegistryHive.CurrentUser, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", new EventHandler(this.ProxyRegistryKeysChanged)); } Proxy._setDynamicRegistryKey(true); return(true); } FiddlerApplication.DoNotifyUser("Failed to register Fiddler as the system proxy.", "Error"); Proxy._setDynamicRegistryKey(false); return(false); }