Does anyone have any insight or experience with DirectX or Directsound in terms of hotloading C/C++ code? I have a lot of code running inside of a DLL that gets hotloaded at run-time frequently. I've noticed that if I attempt to initialize and setup either DirectX or Directsound within the DLL I seem to hit undefined behavior.
My best guess so far is that these APIs are using some static memory somewhere to implement COM interfaces (like pointers sitting in static memory, but initialized at run-time). For example if I reload my DLL DirectX seems to mostly work, at least locally, until Present is called, which results in a strange NULL pointer access violation within d3d9.dll (from one of my GPU vendor's driver threads).
So far the only workaround I've been able to get working is to initialize DirectX/Directsound from within my main executable and pass along associated pointers to my reloadable DLL. This sort of sucks though, since personally I was hoping to keep these technologies localized to the DLL and avoid extra header inclusions for the executable.
Anyone tried experimenting with this sort of thing before?