protected override void OnStartup(StartupEventArgs e)
        {
            DispatcherHelper.UIDispatcher = this.Dispatcher;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            // 証明書インストール
            if (!CertMaker.rootCertExists())
            {
                CertMaker.createRootCert();
                CertMaker.trustRootCert();
            }

            // プロキシサーバー開始
            FiddlerApplication.Startup(24791, true, true);

            this.MainWindow = new MainWindow()
            {
                DataContext = new MainWindowViewModel()
            };
            this.MainWindow.ShowDialog();


            // プロキシサーバー終了
            URLMonInterop.ResetProxyInProcessToDefault();
            FiddlerApplication.Shutdown();
        }
        //集約エラーハンドラ
        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            URLMonInterop.ResetProxyInProcessToDefault();
            FiddlerApplication.Shutdown();

            if (e.ExceptionObject is Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                File.AppendAllText("log.txt", $"{ex.Message}{ex.StackTrace}");
            }
            else
            {
                Console.WriteLine(e.ToString());
            }

            //TODO:ロギング処理など
            MessageBox.Show(
                $"不明なエラーが発生しました。アプリケーションを終了します。{e.ToString()}",
                "エラー",
                MessageBoxButton.OK,
                MessageBoxImage.Error);

            Environment.Exit(1);
        }
Example #3
0
        public KanColleModel()
        {
            FiddlerApplication.Startup(0, FiddlerCoreStartupFlags.ChainToUpstreamGateway);
            URLMonInterop.SetProxyInProcess(string.Format("127.0.0.1:{0}", FiddlerApplication.oProxy.ListenPort), "<local>");

            kclib = new KanColleNotifier(true);

            kclib.GameStart += (_, __) => OnGameStart(new EventArgs());

            kclib.GetStart2                      += kclib_GetStart2;
            kclib.GetPortPort                    += kclib_GetPortPort;
            kclib.GetGetmemberBasic              += kclib_GetGetmemberBasic;
            kclib.GetGetmemberShip2              += kclib_GetGetmemberShip2;
            kclib.GetGetmemberShip3              += kclib_GetGetmemberShip3;
            kclib.GetGetmemberDeck               += kclib_GetGetmemberDeck;
            kclib.GetReqmissionStart             += kclib_GetReqmissionStart;
            kclib.GetReqmissionReturnInstruction += kclib_GetReqmissionReturnInstruction;
            kclib.GetGetmemberKdock              += kclib_GetGetmemberKdock;
            kclib.GetReqkousyouGetship           += kclib_GetReqkousyouGetship;
            kclib.GetGetmemberNdock              += kclib_GetGetmemberNdock;
            kclib.GetReqkousyouDestroyship       += kclib_GetReqkousyouDestroyship;
            kclib.GetGetmemberMaterial           += kclib_GetGetmemberMaterial;
            kclib.GetReqhenseiChange             += kclib_GetReqhenseiChange;
            kclib.GetGetmemberSlotItem           += kclib_GetGetmemberSlotItem;
            kclib.GetReqkousyouCreateitem        += kclib_GetReqkousyouCreateitem;

            shipdata.CollectionChanged += shipdata_CollectionChanged;
            slotdata.CollectionChanged += slotdata_CollectionChanged;
        }
Example #4
0
 private void Form1_Formclosed(object sender, FormClosedEventArgs e)
 {
     try
     {
         URLMonInterop.ResetProxyInProcessToDefault();
         FiddlerApplication.Shutdown();
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
Example #5
0
        public Form1()
        {
            InitializeComponent();

            Fiddler.FiddlerApplication.AfterSessionComplete
                += new Fiddler.SessionStateHandler(FiddlerApplication_AfterSessionComplete);

            Fiddler.FiddlerApplication.Startup(PROXY_PORT, Fiddler.FiddlerCoreStartupFlags.ChainToUpstreamGateway);             //プロキシの設定(この場合は、ローカルのプロキシで第1引数のポート番号で通信)

            //FiddlerApplication.Startup(0, Fiddler.FiddlerCoreStartupFlags.RegisterAsSystemProxy);  //システムのプロキシの設定全部乗っ取る

            URLMonInterop.SetProxyInProcess(string.Format("127.0.0.1:{0}", Fiddler.FiddlerApplication.oProxy.ListenPort), "<local>");
            //oSession["x-overrideGateway"] = string.Format("localhost:{0:D}", proxy.UpstreamPort); // 上流プロキシの設定?
        }
        /// <summary>
        /// Initializes FiddlerApplication
        /// </summary>
        public static void Run()
        {
            System.Diagnostics.Debug.WriteLine("Starting FiddlerCore...");
            CONFIG.IgnoreServerCertErrors = false;
            try
            {
                //do not register as system proxy to avoid interfering with the machine proxy
                FiddlerApplication.Startup(8888, false, true);

                //assign fiddler to the current application only
                //SetProxyInProcess only impacts the WinINET proxy settings for the current process
                URLMonInterop.SetProxyInProcess("127.0.0.1:8888", null);
            }
            catch { }

            //assign AfterSessionComplete event handler to capture requests
            //AfterSessionComplete event is chosen to get all necessary data from both the request and its response
            FiddlerApplication.AfterSessionComplete += FiddlerAfterSessionCompleteEventHandler;
        }
 public void Stop()
 {
     // プロキシサーバー終了
     URLMonInterop.ResetProxyInProcessToDefault();
     FiddlerApplication.Shutdown();
 }