protected override void InitD3D(out IntPtr d3DDevicePtr) { _pD3D = Direct3DCreate9(D3D9SdkVersion); if (_pD3D == IntPtr.Zero) { throw new Exception("Failed to create D3D."); } D3DPresentParameters parameters = new D3DPresentParameters { Windowed = true, SwapEffect = 1, BackBufferFormat = 0 }; IntPtr createDevicePtr = GetVTableFuncAddress(_pD3D, VTableIndexes.Direct3D9CreateDevice); CreateDeviceDelegate createDevice = Marshal.GetDelegateForFunctionPointer <CreateDeviceDelegate>(createDevicePtr); if (createDevice(_pD3D, 0, 1, Form.Handle, D3DCREATE_SOFTWARE_VERTEXPROCESSING, ref parameters, out d3DDevicePtr) < 0) { throw new Exception("Failed to create device."); } IntPtr deviceReleasePtr = GetVTableFuncAddress(D3DDevicePtr, VTableIndexes.Direct3DDevice9Release); _d3DDeviceRelease = Marshal.GetDelegateForFunctionPointer <VTableFuncDelegate>(deviceReleasePtr); IntPtr releasePtr = GetVTableFuncAddress(_pD3D, VTableIndexes.Direct3D9Release); _d3DRelease = Marshal.GetDelegateForFunctionPointer <VTableFuncDelegate>(releasePtr); }
public void InjectSelf(IntPtr obj) { _Original = this.InjectFunctionPointer<CreateDeviceDelegate>(AddressHelper.VirtualTable(obj, 16), 28); }
public void InjectSelf() { _Original = this.InjectFunctionPointer<CreateDeviceDelegate>(AddressHelper.CodeOffset(0x20E2D0), 4); }