My function calls to D3D9Ex don't work – either they return strange errors or they crash. I have figured out that it's because the vtable is not mapped correctly – the function pointers are mapped to different functions. This is what I see in the VS debugger:

pD3D is LPDIRECT3D9EX. So, I think that maybe the cause is some version mismatch. At some point they added the RegisterSoftwareDevice function but my d3d9.h (and the library?) does not count on it. Anyway, how it should work normally? How does the vtable mapping works so it is aligned with the dll installed on the system?
How do I fix this?
Some more details:
- d3d9.dll is loaded from
C:\Windows\System32\d3d9.dll - lib is (probably?) linked from
c:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64\d3d9.lib - header is from
C:\Program Files (x86)\Windows Kits\8.1\Include\shared\d3d9.h - Windows 10, Visual Studio 2019
- The app is 64-bit managed code (.NET+WPF) + unmanaged code: GStreamer pipeline with custom gstd3dwpf element, which is the one trying to access the D3D9Ex functions
Many thanks