smourier / DirectN

Direct interop Code for .NET Framework, .NET Core and .NET 5+ : DXGI, WIC, DirectX 9 to 12, Direct2D, Direct Write, Direct Composition, Media Foundation, WASAPI, CodecAPI, GDI, Spatial Audio, DVD, Windows Media Player, UWP DXInterop, WinUI3, etc.
MIT License
311 stars 28 forks source link

"Attempted to read or write protected memory" in DirectN.Temp #44

Closed ahdung closed 12 months ago

ahdung commented 1 year ago

Test on windows10 22h2 and windows server 2008 R2 sp1. https://github.com/smourier/DirectN/blob/cc5b3918e0ca755219372203e7220c287e67931e/DirectN/DirectN.Temp/Program.cs#L56

ahdung commented 1 year ago

I solved, in 64bit system, should not specify Pack=4 here: https://github.com/smourier/DirectN/blob/cc5b3918e0ca755219372203e7220c287e67931e/DirectN/DirectN/Generated/_D3DLOCKED_RECT.cs#L7

smourier commented 1 year ago

Hi,

Yes. The problem is DirectX9 support in DirectN is pretty much hardcoded for x86 (it's not only D3DLOCKED_RECT...)

If you use the source and not the .dll you can change that yourself, but I would like to modify the code to support both x86 and x64. I'll keep the issue open and will try to fix that in a near future...

Thanks :-)

smourier commented 12 months ago

This commit https://github.com/smourier/DirectN/commit/a15d399dc2311ce812038f517d5bca3aba2878ee should improve all that. Note it may change the way to call some DirectX9 interfaces.