Skip to main content
gamedev.net
🔒 Locked

Detect debug run-time

Started by eq Nov 24, 2004 at 11:25 AM 4 replies 550+ views
Original Post
eq
eq
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).
darookie
darookie
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]
eq
eq
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":

boolisDebugRuntime(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);}
eq
eq
Well I tested, it seems that once a device is created in an app, it usese the same runtime.
darookie
darookie
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).

darookie
darookie
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.