예제 #1
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]);
        }
예제 #2
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
        }