public override void InstallHook() { SharpDX.Direct3D11.Device device; SwapChain swapChain; var form = new RenderForm(); SharpDX.Direct3D11.Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, new SwapChainDescription { BufferCount = 1, Flags = SwapChainFlags.None, IsWindowed = true, ModeDescription = new ModeDescription(100, 100, new Rational(60, 1), Format.R8G8B8A8_UNorm), OutputHandle = form.Handle, SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput }, out device, out swapChain); if (device != null && swapChain != null) { server.DebugMessage("Device succesfuly created"); swapChainAdresses = GetVTableAdresses(swapChain.NativePointer, SwapChainMethodsCount); deviceContextAddresses = GetVTableAdresses(device.ImmediateContext.NativePointer, DeviceContextMethodsCount); presentHook = new Hook <PresentDelegate>(swapChainAdresses[(int)SwapChainVTbl.Present], new PresentDelegate(MyPresent), this); presentHook.Activate(); drawIndexedHook = new Hook <DrawIndexedDelegate>(deviceContextAddresses[12], new DrawIndexedDelegate(MyDrawIndexed), this); drawIndexedHook.Activate(); server.SendMessage("Hook enabled!"); device.Dispose(); swapChain.Dispose(); } else { server.DebugMessage("Device creation failed!"); } form.Dispose(); }