`StretchRect` incorrectly called when using `EnableWindowMode = 1`
The game Freelancer (2003) allows players to take in-game screenshots using the PrtScn key. After taking the screenshot, it is stored in the user's Pictures folder in BMP format.
I ran the game using dxwrapper v1.2.7200.25 with the following config:
[Compatibility]
D3d8to9 = 1
[d3d9]
EnableWindowMode = 1
Every time I take an in-game screenshot, the game cashes. The crash occurs in d3d9's CBaseDevice::StretchRect function, which is called by dxwrapper. The reason why the crash occurs is because the pSourceSurface and pDestSurface parameters are not set correctly. Instead of these parameters being pointers, both are set as the hex number 0x15 on my end, which clearly causes an access violation when either of these are dereferenced. CBaseDevice::StretchRect doesn't seem to be called when using EnableWindowMode = 0.
I currently don't have Visual Studio installed on this PC, so besides the assembly that x64dbg shows me, I unfortunately won't be able to provide more elaborate debug information.
Also for me it's not imperative that this issue gets resolved since I use a plugin that replaces the game's original screenshot functionality to allow for PNG screenshots instead of BMP; with this new code the CBaseDevice::StretchRect function is not called either. Though it would still be nice to fix for anyone who plays the original game in windowed mode with dxwrapper.
Edit:
I tried running the game with the latest master build artifact (https://github.com/elishacloud/dxwrapper/commit/fb34d62aee86addbf5a8d902effef1290376f5a5) and thanks to the provided debug symbols, I can now see that StretchRect is called with the incorrect params by m_IDirect3DDevice9Ex::StretchRect which in turn is called by m_IDirect3DDevice9Ex::FakeGetFrontBufferData. Hopefully this helps.