delphi-screen-capture-dxgi-wgc
Detection fingerprint and defensive notes for Delphi/Embarcadero binaries that embed dual-engine screen capture via DXGI Desktop Duplication API and Windows Graphics Capture (WGC).
What It Does
This technique provides real-time, low-overhead screen capture by:
- Probing OS capability (
TOSCapswithHasDXGI,HasExcludeFromCapture,HasWGC). - Using DXGI Desktop Duplication API (
uCaptureDXGI) to capture delta rectangles (only changed regions) and encode them as JPEG (DirtyJpegs). - Falling back to Windows Graphics Capture (
uCaptureWGC) on newer Windows builds. - Falling back further to GDI
BitBlt/GetDIBitsif both modern APIs are unavailable.
Detection / Fingerprint
Look for these string clusters in a Delphi PE32:
uCaptureDXGIuCaptureWGCTDXGIDeltaResultDirtyRectsDirtyJpegsMoveRectsScreenW/ScreenHTOSCapswithHasDXGI/HasWGC/HasExcludeFromCapture
Import-wise, the binary will reference gdi32.dll BitBlt, StretchBlt, GetDIBits, CreateCompatibleDC, CreateCompatibleBitmap even when using DXGI/WGC, because GDI is the ultimate fallback.
Implementation Patterns
In the bromechokucom sample, the capture stack is custom-written (not a standard Delphi component). It exposes:
- Delta-result objects (
TDXGIDeltaResult) withHasDataflag - JPEG-encoded dirty rectangles
- Move rectangles for cursor/window motion
This suggests the attacker intends to stream screen deltas to a C2 operator in real time, not merely take periodic screenshots.
Defensive Countermeasures
- API hooking / EDR telemetry: Monitor
D3D11CreateDevice+IDXGIOutputDuplication::AcquireNextFramecalls. - Process monitoring: Unexpected
BitBlt/GetDIBitsspikes from a non-presentation process. - Display affinity: The sample delay-imports
SetWindowDisplayAffinity, which can be used to mark windows as non-capturable; defenders can invert this by ensuring sensitive banking apps setWDA_EXCLUDEFROMCAPTURE. - Network detection: Real-time delta streams produce sustained outbound JPEG-like traffic (high entropy, variable size, bursty).
Reproduce on Your Own VMs
To build a comparable capture stack in Delphi:
- Create a new VCL Forms application in RAD Studio.
- Import
Winapi.DXGIandWinapi.D3D11units. - Use
D3D11CreateDeviceto obtain anIDXGIDevice, thenIDXGIOutput::QueryInterfaceforIDXGIOutput1. - Call
IDXGIOutput1::DuplicateOutputto getIDXGIOutputDuplication. - Loop
AcquireNextFrame→GetFrameDirtyRects→ JPEG-encode viaTJPEGEncoder. - On failure, fall back to
GetDC(0)→BitBlt→GetDIBits.
Verification: strings in the resulting EXE will contain IDXGIOutputDuplication, AcquireNextFrame, and DirtyRects.
Pages Where Observed
- bromechokucom —
36a4bca2sample