How to handle exceptions thrown in GraphicsCapture.dll

Derek Lu 0 Reputation points
2025-08-05T11:42:40.21+00:00

(I also post this question here: https://github.com/MicrosoftDocs/winrt-api/issues/2499)

I use WinRT Windows.Graphics.Capture to capture screens or windows. My code is almost identical to WebRTC's implementation. However, our customers are experiencing crashes.

Stack trace:

KERNELBASE!RaiseException+0x69
ucrtbase!CxxThrowException+0xad
GraphicsCapture!winrt::throw_hresult+0x1de
GraphicsCapture!winrt::Windows::Graphics::Capture::implementation::Direct3D11CaptureFramePool::PresentThread+0x145
KERNEL32!BaseThreadInitThunk+0x14
ntdll!RtlUserThreadStart+0x21

Some basic information I found

I find the PresentThread was started in ABI::Windows::Graphics::Capture::IGraphicsCaptureSession::StartCapture

The calling codes: https://webrtc.googlesource.com/src/+/refs/heads/main/modules/desktop_capture/win/wgc_capture_session.cc#217

I investigated the crash information:

ExceptionAddress: 00007fff2f3fb699 (KERNELBASE!RaiseException+0x0000000000000069)
ExceptionCode: e06d7363 (C++ EH exception)
ExceptionFlags: 00000001
NumberParameters: 4
Parameter[0]: 0000000019930520
Parameter[1]: 000000d7662ff760
Parameter[2]: 00007ffef8f7e788
Parameter[3]: 00007ffef8f60000

Checking Parameter[1], which is pExceptionObject:

dd 000000d7662ff760
000000d7662ff760 00000000 00000000 aabbccdd 887a0005
000000d7662ff770 9018c0e8 0000023b f150c3a8 0000023b

0x887a0005 indicates "device lost".

The function that throws this exception in GraphicsCapture.dll isxxxDirect3D11CaptureFramePool::ProcessFrame

How can I catch this type of exception (which occurs in a thread created by Windows)? Should I use VEH?

Windows development | Windows API - Win32
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.