diff --git a/D3D9/D3D9Functions.cs b/D3D9/D3D9Functions.cs index 3eaeef4..2f91534 100644 --- a/D3D9/D3D9Functions.cs +++ b/D3D9/D3D9Functions.cs @@ -151,6 +151,27 @@ public enum Direct3DDevice9ExFunctionOrdinals : short GetDisplayModeEx = 133, } + public enum IDirect3DVertexBuffer9FunctionOrdinals : short + { + QueryInterface = 0, + AddRef = 1, + Release = 2, + GetDevice = 3, + SetPrivateData = 4, + GetPrivateData = 5, + FreePrivateData = 6, + SetPriority = 7, + GetPriority = 8, + PreLoad = 9, + GetType = 10, + Lock = 11, + Unlock = 12, + GetDesc = 13, + } + + // Calling convention: DX9 methods are COM (combaseapi.h) and as such, since C-abi has no __thiscall, they are + // strictly stdcall and by-convention push "this" on the stack. + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)] public delegate int Direct3D9Device_BeginSceneDelegate(IntPtr device); @@ -178,11 +199,36 @@ public unsafe delegate int Direct3D9Device_PresentDelegate(IntPtr devicePtr, Rec [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)] public unsafe delegate int Direct3D9DeviceEx_PresentExDelegate(IntPtr devicePtr, Rectangle* pSourceRect, Rectangle* pDestRect, IntPtr hDestWindowOverride, IntPtr pDirtyRegion, Present dwFlags); + + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)] + public unsafe delegate int Direct3D9Device_CreateShader(IntPtr devicePtr, IntPtr pFunction, IntPtr ppShader); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public unsafe delegate int Direct3D9Device_CreateTexture(IntPtr devicePtr, uint width, uint height, uint levels, uint usage, + uint format, uint pool, IntPtr *ppTexture, IntPtr pSharedHandle); + + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)] + public delegate int Direct3D9Device_SetShader(IntPtr devicePtr, IntPtr pShader); + + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)] + public delegate int Direct3D9Device_DrawIndexedPrimitive(IntPtr devicePtr, uint primitiveType, int baseVertexIndex, + uint minVertexIndex, uint numVertices, uint startIndex, uint primCount); + + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)] + public delegate int Direct3DVertexBuffer9_Lock(IntPtr pBuffer, uint offsetToLock, uint sizeToLock, IntPtr ppbData, int flags); + + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)] + public delegate int Direct3DVertexBuffer9_Unlock(IntPtr pBuffer); + + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)] + public delegate int Direct3D9Device_SetIndices(IntPtr devicePtr, IntPtr pIndexBuffer); public static class Functions { public const int D3D9_DEVICE_METHOD_COUNT = 119; public const int D3D9Ex_DEVICE_METHOD_COUNT = 15; + public const int D3D9_METHOD_COUNT = 17; + public const int D3D9_VERTEX_BUFFER_METHOD_COUNT = 14; public static IntPtr[] GetVTblAddresses(IntPtr pointer, int numberOfMethods) { diff --git a/D3D9/D3D9HookManager.cs b/D3D9/D3D9HookManager.cs index 9837cc0..5840c97 100644 --- a/D3D9/D3D9HookManager.cs +++ b/D3D9/D3D9HookManager.cs @@ -82,8 +82,7 @@ public void Load() using (var d3d = new Direct3D()) { using (var device = new Device(d3d, 0, DeviceType.NullReference, IntPtr.Zero, - CreateFlags.HardwareVertexProcessing, - new PresentParameters + CreateFlags.HardwareVertexProcessing, new PresentParameters { BackBufferWidth = 1, BackBufferHeight = 1, DeviceWindowHandle = WindowHandle })) { Logger.Debug("D3D9Hook: Device created");