Exemple #1
0
        public void startHook()
        {
            IntPtr d3D9Loaded  = IntPtr.Zero;
            IntPtr d3D10Loaded = IntPtr.Zero;
            //IntPtr d3D10_1Loaded = IntPtr.Zero;
            IntPtr d3D11Loaded = IntPtr.Zero;

            //IntPtr d3D11_1Loaded = IntPtr.Zero;

            d3D9Loaded  = DXTools.GetModuleHandle("d3d9.dll");
            d3D10Loaded = DXTools.GetModuleHandle("d3d10.dll");
            //d3D10_1Loaded = Tools.GetModuleHandle("d3d10_1.dll");
            d3D11Loaded = DXTools.GetModuleHandle("d3d11.dll");
            //d3D11_1Loaded = Tools.GetModuleHandle("d3d11_1.dll");

            if (d3D9Loaded != IntPtr.Zero)
            {
                loadedControl = new HookD3D_09();
            }
            else if (d3D10Loaded != IntPtr.Zero)
            {
                loadedControl = new HookD3D_10();
            }
            else if (d3D11Loaded != IntPtr.Zero)
            {
                loadedControl = new HookD3D_11();
            }

            if (loadedControl != null)
            {
                Core.Log("Found: " + loadedControl.Name);

                try
                {
                    int dxv = D3DHook.connection.dxVersion;
                    Core.Log("Connection check: " + dxv.ToString());

                    loadedControl.Hook();
                    Core.Log("Hook started!");

                    while (!D3DHook.closed)
                    {
                        System.Threading.Thread.Sleep(10);
                    }
                }
                catch (Exception e)
                {
                    Core.Log("ERROR:" + e.Message);
                }
            }
        }
Exemple #2
0
        public override void Hook()
        {
            _d3d11VTblAddresses         = new List <IntPtr>();
            _dxgiSwapChainVTblAddresses = new List <IntPtr>();
            SharpDX.Direct3D11.Device device;
            SwapChain swapChain;

            using (SharpDX.Windows.RenderForm renderForm = new SharpDX.Windows.RenderForm())
            {
                SharpDX.Direct3D11.Device.CreateWithSwapChain(
                    DriverType.Hardware,
                    DeviceCreationFlags.None,
                    CreateSwapChainDescription(renderForm.Handle),
                    out device,
                    out swapChain);

                if (device != null && swapChain != null)
                {
                    using (device)
                    {
                        _d3d11VTblAddresses.AddRange(DXTools.GetVTblAddresses(device.NativePointer, 43));
                        using (swapChain)
                        {
                            _dxgiSwapChainVTblAddresses.AddRange(DXTools.GetVTblAddresses(swapChain.NativePointer, 18));
                        }
                    }
                }
                else
                {
                    Core.Log("Hook: Device creation failed");
                }
            }

            DXGISwapChain_PresentHook = LocalHook.Create(
                _dxgiSwapChainVTblAddresses[(int)DXGISwapChainVTbl.Present],
                new DXGISwapChain_PresentDelegate(PresentHook),
                this);

            /*DXGISwapChain_ResizeTargetHook = LocalHook.Create(
             * _dxgiSwapChainVTblAddresses[(int)DXGI.DXGISwapChainVTbl.ResizeTarget],
             * new DXGISwapChain_ResizeTargetDelegate(ResizeTargetHook),
             * this);*/

            DXGISwapChain_PresentHook.ThreadACL.SetExclusiveACL(new Int32[1]);
            //DXGISwapChain_ResizeTargetHook.ThreadACL.SetExclusiveACL(new Int32[1]);
        }
Exemple #3
0
        public override void Hook()
        {
            List <IntPtr> id3dDeviceFunctionAddresses = new List <IntPtr>();
            Device        device;

            using (Direct3D d3d = new Direct3D())
            {
                using (device = new Device(d3d, 0, DeviceType.NullReference, IntPtr.Zero, CreateFlags.HardwareVertexProcessing, new PresentParameters()
                {
                    BackBufferWidth = 1, BackBufferHeight = 1
                }))
                {
                    id3dDeviceFunctionAddresses.AddRange(DXTools.GetVTblAddresses(device.NativePointer, 119));
                }
            }

            //System.Windows.Forms.MessageBox.Show(id3dDeviceFunctionAddresses[42].ToString());
            Direct3DDevice_EndSceneHook = LocalHook.Create(
                id3dDeviceFunctionAddresses[42],
                new Direct3D9Device_EndSceneDelegate(EndSceneHook),
                this);

            Direct3DDevice_ResetHook = LocalHook.Create(
                id3dDeviceFunctionAddresses[16],
                new Direct3D9Device_ResetDelegate(ResetHook),
                this);

            Direct3DDevice_EndSceneHook.ThreadACL.SetExclusiveACL(new Int32[1]);
            Direct3DDevice_ResetHook.ThreadACL.SetExclusiveACL(new Int32[1]);

            #region fontsinit
            fdesc = new FontDescription()
            {
                Height          = 25,
                FaceName        = "Arial",
                Italic          = false,
                Width           = 12,
                MipLevels       = 1,
                CharacterSet    = FontCharacterSet.Default,
                OutputPrecision = FontPrecision.Default,
                Quality         = FontQuality.Antialiased,
                PitchAndFamily  = FontPitchAndFamily.Default | FontPitchAndFamily.DontCare,
                Weight          = FontWeight.Normal,
            };
            #endregion
        }