Beispiel #1
0
        static bool ShellExecuteEx_Hooked(ref SHELLEXECUTEINFO lpExecInfo)
        {
            try
            {
                var uri = new Uri(lpExecInfo.lpFile);

                //"https?://osu\.ppy\.sh/[bsd]/"
                //"https?://bloodcat.com/osu/m/"
                if (uri.Host == "osu.ppy.sh" && "b/d/s/".Contains(uri.Segments[1]) ||
                    uri.Host == "bloodcat.com" && uri.AbsolutePath.StartsWith("/osu/m/"))
                {
                    string request = lpExecInfo.lpFile;

                    var worker = new Thread(() => InvokeUrlHooker.BloodcatDownload(request));
                    worker.SetApartmentState(ApartmentState.STA);
                    worker.Start();

                    return(true);
                }
            }
            catch (Exception e)
            {
            }

            //call original API...
            return(ShellExecuteEx(ref lpExecInfo));
        }
Beispiel #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;
            }
        }