How to: Disable Graphics Diagnostics in Your App
You can prevent Graphics Diagnostics and other graphics tools from inspecting your app to help prevent exploitation by a malicious user.
By using Visual Studio Graphics Diagnostics as you develop your app, you can capture detailed graphics information and analyze it so that you can improve the app before you publish it. However, if you don't prevent Graphics Diagnostics from capturing this information before you publish the app, a malicious user could use these tools to extract its art assets, shader code, and other information, and then use them to exploit the app. For example, a malicious user could modify the art assets and shader code to gain an unfair advantage in an online game.
In the Windows SDK for Windows 8, Direct3D 10 support includes additional flags for device creation. In particular, it includes D3D11_CREATE_DEVICE_PREVENT_ALTERING_LAYER_SETTINGS_FROM_REGISTRY, which is used to prevent tools like Graphics Diagnostics from hooking an app. Apps that reference the Direct3D header files included in the Windows SDK for Windows 8 can use these new flags, but apps that reference the Direct3D header files in the June 2010 DirectX SDK cannot. This applies to apps that run on Windows 8 and Windows 7.
In Direct3D 11.1, you can use ID3DUserDefinedAnnotation::GetStatus to prevent Graphics Diagnostics from capturing information about your app. Because this interface is not available to Windows 7 even when referencing the Windows SDK for Windows 8, this applies only to apps that run on Windows 8.
For apps that don't reference the updated Direct3D headers in the Windows SDK for Windows 8, you can prevent Graphics Diagnostics from capturing information by building the app against Direct3D 9Ex and using the D3DPerf_SetOptions API.
Direct3D 11.1 provides two ways to prevent tools such as Graphics Diagnostics from attaching to an app. The first technique is to use ID3DUserDefinedAnnotation::GetStatus to detect whether the app is being observed by a tool such as Graphics Diagnostics, and if it is, then exit the app immediately. Use this technique when you want to perform an action before the app is closed. The second technique is to set the appropriate flag when you create your Direct3D device.
To use Direct3D 11 and the Windows SDK for Windows 8 to prevent capture of graphics information
In your app's source code, before you make any exploitable Direct3D calls—such as those that create resources or perform rendering—call the ID3DUserDefinedAnnotation::GetStatus method and write code that causes the app to close immediately if the return value is non-zero.
- or -
When you create the Direct3D 11 device in your app's source code, pass in the D3D11_CREATE_DEVICE_PREVENT_ALTERING_LAYER_SETTINGS_FROM_REGISTRY flag. For information about how to create a Direct3D 11 device, see D3D11CreateDevice and D3D11CreateDeviceAndSwapChain. For information about the D3D11_CREATE_DEVICE_PREVENT_ALTERING_LAYER_SETTINGS_FROM_REGISTRY flag, see D3D11_CREATE_DEVICE_FLAG enumeration.
Direct3D 10 provides a technique that resembles the second Direct3D 11 technique when you are referencing the Windows SDK for Windows 8 header files.
To use Direct3D 10 and the Windows SDK for Windows 8 to prevent capture of graphics information
When you create the Direct3D 10 device in your app's source code, pass in the D3D10_CREATE_DEVICE_PREVENT_ALTERING_LAYER_SETTINGS_FROM_REGISTRY flag. For information about how to create a Direct3D 10 device or Direct3D 10.1 device, see Direct3D 10 Core Functions. For information about the D3D10_CREATE_DEVICE_PREVENT_ALTERING_LAYER_SETTINGS_FROM_REGISTRY flag, see D3D10_CREATE_DEVICE_FLAG enumeration.
You can also prevent tools such as Graphics Diagnostics from hooking your app by using the June 2010 DirectX SDK instead of the Windows SDK for Windows 8.
To use the June 2010 DirectX SDK to prevent capture of graphics information
Configure your app to build against the DirectX 9Ex header files.
Before you create the Direct3D device in your app's source code, call the D3DPERF_SetOptions API and use a parameter of 1. For more information, see the documentation for the June 2010 DirectX SDK.