# DXUT getters are always null using DLL

I'm struggling with a problem for a while and I hope some of you can help me out. The title for this question is vague, so I will try to explain my problem as best as I can!

I'm am creating a project (in C++ using Visual studio 2012) with a DLL that has the DirectX toolkit (https://directxtk.codeplex.com) and DXUT as references. I initialize DXUT (the device and all that kind of stuff) in the DLL and create a "GameScene" (GameScene is in the executable) after DXUT is initialized. The GameScene derives from its base class "BaseScene" (BaseScene is in the DLL project).

When I call DXUTGetD3D11Device() to get the DirectX device in the GameScene (in the executable) it is all fine, but when I call DXUTGetD3D11Device() in the BaseScene it returns null.

Note: This counts for all the DXUT functions! Note: The executable has the same references as the dll + the dll!

If you need more information to answer my question, ask me! I find it really hard to explain my problem and I will try my best to make it more clear!

You could work around this by hacking the two DXUTs to share states. Inside DXUT all the state is in the DXUTState class, and there is a global pointer g_pDXUTState that gets set up when you initialize the library. You could copy this pointer from one module to the other. However, it's possible this could cause problems because DXUT wasn't designed for this use case and it might violate some of its internal assumptions.
• @YannickLange I'm not sure, but there's an easy way to check this: go in your debugger, and while stepping through .exe code, put &g_pDXUTState in the watch window and note the address. Then step into some .dll code and see if the address changes. That will prove there are indeed two copies of DXUT in play. – Nathan Reed Jan 10 '14 at 23:34