Esempio n. 1
0
        public ProgressWindow(IOverlayer overlayer) : base()
        {
            Overlayer = overlayer;

            IsVisibleChanged += ProgressWindow_IsVisibleChanged;

            AllowsTransparency  = true;
            WindowStyle         = WindowStyle.None;
            ShowInTaskbar       = false;
            ShowActivated       = false;
            SnapsToDevicePixels = true;
            Topmost             = true;
            Background          = Brushes.Transparent;

            MainPanel             = new StackPanel();
            MainPanel.Orientation = Orientation.Vertical;
            AddChild(MainPanel);

            TextBlockStyle = new Style();

            foreach (var setter in new Setter[]
            {
                new Setter(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Center),
                new Setter(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center),
                new Setter(TextBlock.ForegroundProperty, Brushes.Black),
                new Setter(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Center),
                new Setter(TextBlock.FontWeightProperty, FontWeights.DemiBold),
                new Setter(FrameworkElement.MarginProperty, new Thickness(0, 2, 0, 2)),
            })
            {
                TextBlockStyle.Setters.Add(setter);
            }

            Hide();
        }
Esempio n. 2
0
        public void Run(RemoteHooking.IContext context)
        {
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.AssemblyResolve += (sender, args) =>
            {
                return(this.GetType().Assembly.FullName == args.Name ? this.GetType().Assembly : null);
            };

            HookingThreadIds.Add((int)GetCurrentThreadId());

            try
            {
                try
                {
                    // opengl32.dll loaded lazily. wait it.
                    while (Process.GetCurrentProcess().MainWindowHandle == IntPtr.Zero)
                    {
                        Thread.Sleep(100);
                    }

                    // d3d9.dll load always. so tests with opengl32.dll.
                    if (GetModuleHandle("opengl32.dll") == IntPtr.Zero)
                    {
                        var hooker = new D3D9Hooker();

                        // If hook failed, pass to window notifier by exception.
                        hooker.SetHookState(true);

                        // Accepts D3 hook if test passes.
                        Overlayer = hooker;
                    }
                    else
                    {
                        throw new ApplicationException("DirectX9 hook seems unavailable.");
                    }
                }
                catch
                {
                    Overlayer = new WPFOverlayer();
                }
                if (Overlayer != null)
                {
                    InvokeUrlHooker.Overlayer = Overlayer;
                    Overlayer.AddMessage(new object(), new NoticeEntry()
                    {
                        Begin    = DateTime.Now,
                        Duration = TimeSpan.FromSeconds(5),
                        Message  = "비트맵 다운로더가 동작합니다."
                    });
                }

                Downloader = new InvokeUrlHooker();
                Downloader.SetHookState(true);

                RegisterBossKey();

                Foregrounder = new WinEventHooker();
                Foregrounder.OnForegroundChanged += Foregrounder_OnForegroundChanged;
            }
            catch (Exception extInfo)
            {
                MainWindowViewModel.LogException(extInfo);
            }

            RemoteHooking.WakeUpProcess();

            // wait for host process termination...
            try
            {
                new Application().Run();
            }
            catch (Exception e)
            {
                MainWindowViewModel.LogException(e);
            }
            finally
            {
                if (Downloader != null)
                {
                    Downloader.Dispose();
                    Downloader = null;
                }
                if (Blinder != null)
                {
                    Blinder.Dispose();
                    Blinder = null;
                }
                InjecteeHost.Abort();
                InjecteeHost = null;
            }
        }