internal bool Detach(bool bDontCheckIfAttached) { if (!bDontCheckIfAttached && !this._bIsAttached) { return(true); } if (CONFIG.bIsViewOnly) { return(true); } bool result; try { this._bDetaching = true; Proxy._setDynamicRegistryKey(false); if (this.oAllConnectoids.UnhookAllConnections()) { this._bIsAttached = false; FiddlerApplication.OnFiddlerDetach(); this.WriteAutoProxyPACFile(false); return(true); } result = false; } finally { this._bDetaching = false; } return(result); }
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); }