Beispiel #1
0
 static DX9Hook()
 {
     // Obtain the pointer to the IDirect3DDevice9 instance by creating our own blank windows form and creating a
     // IDirect3DDevice9 targeting that form. The returned device should be the same one as used by the program.
     using var direct3D   = new Direct3D();
     using var renderForm = new Form();
     using var device     = new Device(direct3D, 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.HardwareVertexProcessing, GetParameters(direct3D, renderForm.Handle));
     Direct3D9VTable      = SDK.Hooks.VirtualFunctionTableFromObject(direct3D.NativePointer, Enum.GetNames(typeof(IDirect3D9)).Length);
     DeviceVTable         = SDK.Hooks.VirtualFunctionTableFromObject(device.NativePointer, Enum.GetNames(typeof(IDirect3DDevice9)).Length);
 }
Beispiel #2
0
 public DX9Hook(IReloadedHooks _hooks)
 {
     // Obtain the pointer to the IDirect3DDevice9 instance by creating our own blank windows form and creating a
     // IDirect3DDevice9 targeting that form. The returned device should be the same one as used by the program.
     using (var direct3D = new Direct3D())
         using (var renderForm = new Form())
             using (var device = new Device(direct3D, 0, DeviceType.NullReference, IntPtr.Zero, CreateFlags.HardwareVertexProcessing, new PresentParameters()
             {
                 BackBufferWidth = 1, BackBufferHeight = 1, DeviceWindowHandle = renderForm.Handle
             }))
             {
                 Direct3D9VTable = _hooks.VirtualFunctionTableFromObject(direct3D.NativePointer, Enum.GetNames(typeof(IDirect3D9)).Length);
                 DeviceVTable    = _hooks.VirtualFunctionTableFromObject(device.NativePointer, Enum.GetNames(typeof(IDirect3DDevice9)).Length);
             }
 }
        public DX11Hook(IReloadedHooks _hooks)
        {
            // Define
            Device    dx11Device;
            SwapChain dxgiSwapChain;
            var       renderForm = new Form();

            // Get Table
            Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, GetSwapChainDescription(renderForm.Handle), out dx11Device, out dxgiSwapChain);
            VTable     = _hooks.VirtualFunctionTableFromObject(dx11Device.NativePointer, Enum.GetNames(typeof(ID3D11Device)).Length);
            DXGIVTable = _hooks.VirtualFunctionTableFromObject(dxgiSwapChain.NativePointer, Enum.GetNames(typeof(IDXGISwapChain)).Length);

            // Cleanup
            dxgiSwapChain.Dispose();
            dx11Device.Dispose();
            renderForm.Dispose();
        }
Beispiel #4
0
        public DX9Hook(IReloadedHooks _hooks)
        {
            // Obtain the pointer to the IDirect3DDevice9 instance by creating our own blank windows form and creating a
            // IDirect3DDevice9 targeting that form. The returned device should be the same one as used by the program.
            using (var direct3D = new Direct3D())
                using (var renderForm = new Form())
                    using (var device = new Device(direct3D, 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.HardwareVertexProcessing, GetParameters(direct3D, renderForm.Handle)))
                    {
                        Direct3D9VTable = _hooks.VirtualFunctionTableFromObject(direct3D.NativePointer, Enum.GetNames(typeof(IDirect3D9)).Length);
                        DeviceVTable    = _hooks.VirtualFunctionTableFromObject(device.NativePointer, Enum.GetNames(typeof(IDirect3DDevice9)).Length);

                        using var texture = new Texture(device, 128, 128, 0, Usage.None, Format.X8R8G8B8, Pool.Default);
                        Texture9VTable    = _hooks.VirtualFunctionTableFromObject(texture.NativePointer, Enum.GetNames(typeof(IDirect3DTexture9)).Length);
                    }

            using (var direct3D = new Direct3DEx())
                using (var renderForm = new Form())
                    using (var device = new DeviceEx(direct3D, 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.HardwareVertexProcessing, GetParameters(direct3D, renderForm.Handle)))
                    {
                        DeviceExVTable    = _hooks.VirtualFunctionTableFromObject(direct3D.NativePointer, Enum.GetNames(typeof(IDirect3D9)).Length);
                        Direct3D9ExVTable = _hooks.VirtualFunctionTableFromObject(device.NativePointer, Enum.GetNames(typeof(IDirect3DDevice9)).Length);
                    }
        }