コード例 #1
0
        private bool InstallHooks(OverlayConfig overlayConfig)
        {
            var isX64Process = RemoteHooking.IsX64Process(RemoteHooking.GetCurrentProcessId());
            Log.Write(MessageType.Information, "Remote process is a {0}-bit process.", isX64Process ? "64" : "32");
            try
            {
                var D3D11Handle = IntPtr.Zero;

                const int delay = 100;
                var retry = 0;

                while (D3D11Handle == IntPtr.Zero)
                {
                    retry++;
                    D3D11Handle = NativeMethods.GetModuleHandle("d3d11.dll");
                    if (retry * delay > 5000)
                    {
                        return false;
                    }
                }

                _hook = new DirectX11(_interface)
                {
                    OverlayConfig = overlayConfig
                };
                _hook.Install(RemoteHooking.GetCurrentProcessId());

                Log.Write(MessageType.Information, "Installed DirectX hook");
                return true;
            }
            catch (Exception ex)
            {
                Log.Write(MessageType.Error, "Failed to install DirectX hooks: {0}", ex.Message);
                return false;
            }
        }
コード例 #2
0
        private bool InstallHooks()
        {
            try {
                IntPtr d3d11 = IntPtr.Zero;

                int delay = 100;
                int retry = 0;

                while (d3d11 == IntPtr.Zero) {
                    retry++;
                    d3d11 = NativeMethods.GetModuleHandle("d3d11.dll");
                    if (retry * delay > 5000) {
                        return false;
                    }
                }

                _hook = new DirectX11();
                _hook.Install(RemoteHooking.GetCurrentProcessId());

                Log.Write("Installed DirectX hook");
                return true;
            } catch(Exception ex) {
                Log.Write("Failed to install DirectX hooks: {0}", ex.Message);
                return false;
            }
        }