• Advertisement
Sign in to follow this  

Detect debug run-time

This topic is 4842 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'd like to detect if the user uses the debug runtime or not. I'm doing some lowlevel stuff (read assembly) and the two differs. For instance: A SetTexture call using the debug-runtime destroys one extra element of the stack, etc. Is there a "nice" way to detect if it's a debug-runtime? (It's quite simple to detect knowing the above is true, for instance).

Share this post


Link to post
Share on other sites
Advertisement
Query the registry: HKEY_LOCAL_MACHINE\SOFTWARE\ Microsoft\Direct3D\LoadDebugRuntime
[edit]
The value is a DWORD and non-zero if the debug runtime is active[smile]
[/edit]

Share this post


Link to post
Share on other sites
If I create a device and then switches the debug/release runtime, does it change the device behavior of the running app?

For instance start an application using one device using release runtime, marking my device as release. Then switch to debug runtime. Do I need to test for changes in the registry key or can I assume that once a device is created it uses the same runtime?


Currently I'm using this "hack":


bool
isDebugRuntime(IDirect3DDevice9* const dev)
{
// Warning! Does a SetTexture(0, null)
IDirect3DDevice9* device = dev;
uint callAddress = *((DWORD*)(*((u8**)device) + 0x104));
__asm
{
push 0
push 0
push device
call callAddress
push DWORD PTR [esp - 12]
pop DWORD PTR device
};
return (device != dev);
}


Share this post


Link to post
Share on other sites
Well I tested, it seems that once a device is created in an app, it usese the same runtime.

Share this post


Link to post
Share on other sites
Quote:
Original post by eq
Well I tested, it seems that once a device is created in an app, it usese the same runtime.

It has to. Otherwise the device would have to be destroyed and re-created, which is something an application cannot know about (e.g. the device isn't just 'lost' but completely trashed and reset).

Share this post


Link to post
Share on other sites
Regarding your hack: don't do that! You rely on an undocumented behaviour that may change at any time without notice. Use the documented and reliable methods (like the registry key) unless there are no other options.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement