Esempio n. 1
0
 static void Message(object key, EntryBase entry)
 {
     try
     {
         if (Overlayer != null)
         {
             Overlayer.AddMessage(key, entry);
         }
     }
     catch (Exception e)
     {
         MainWindowViewModel.LogException(e);
     }
 }
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;
            }
        }