You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adopt wil/resource.h RAII wrappers for raw Win32 handles across the codebase, replacing manual CloseHandle/FreeLibrary/DeleteObject/RegCloseKey/etc. This complements the COM-pointer cleanup (#10) — same "use WIL RAII" theme, handles instead of interfaces.
Do it as one PR once #23 (WinForms) and #24 (COM ptrs) have landed (so it also covers src/tap_winforms/winforms_tap_native.cpp and doesn't collide with #24's TAP edits).
TAP DLLs (lvt_tap, wpf_tap_native, winforms_tap_native, avalonia_tap_native) use static CRT (/MT) and avoid C++ exceptions — use the non-throwing WIL forms there; do not introduce throwing helpers.
Watch for handles whose ownership is intentionally transferred (e.g. a named-pipe handle handed to a fire-and-forget worker thread, or handles closed on another thread) — don't wrap in a way that double-closes or closes early.
Behavior must be identical; this is a leak-hygiene/RAII refactor, not a functional change. Keep build\lvt_unit_tests.exe + integration tests green.
Goal
Adopt
wil/resource.hRAII wrappers for raw Win32 handles across the codebase, replacing manualCloseHandle/FreeLibrary/DeleteObject/RegCloseKey/etc. This complements the COM-pointer cleanup (#10) — same "use WIL RAII" theme, handles instead of interfaces.Do it as one PR once #23 (WinForms) and #24 (COM ptrs) have landed (so it also covers
src/tap_winforms/winforms_tap_native.cppand doesn't collide with #24's TAP edits).Scope (audit: ~160 sites across ~14 files)
Map raw handles to the appropriate
wil::unique_*:HANDLE(named pipes, events, files,CreateToolhelp32Snapshot) →wil::unique_handle/wil::unique_hfile/wil::unique_eventOpenProcess,CreateProcessPROCESS_INFORMATION) →wil::unique_process_handle/wil::unique_handleHMODULEfromLoadLibrary→wil::unique_hmoduleHKEY→wil::unique_hkeyscreenshot.cpp(HDC/HBITMAP/HFONT/HPEN/HBRUSH) →wil::unique_hdc/wil::unique_hbitmap/wil::unique_hgdiobjFiles (raw-handle site counts)
src/plugin_avalonia/lvt_avalonia_plugin.cpp(~22),avalonia_tap_native.cpp(~7)src/providers/wpf_inject.cpp(~21),xaml_diag_common.cpp(~21),winui3_provider.cpp(~4),comctl_provider.cpp(~2)src/plugin_chromium/chromium_host.cpp(~20),lvt_chromium_plugin.cpp(~19)src/tap_wpf/wpf_tap_native.cpp(~12),src/tap/lvt_tap.cpp(~5),src/tap_winforms/winforms_tap_native.cpp(after Add WinForms provider (+ sample app) #23)src/plugin_loader.cpp(~4),src/target.cpp(~2),src/framework_detector.cpp(~1)src/screenshot.cpp(GDI objects)Caveats
lvt_tap,wpf_tap_native,winforms_tap_native,avalonia_tap_native) use static CRT (/MT) and avoid C++ exceptions — use the non-throwing WIL forms there; do not introduce throwing helpers.build\lvt_unit_tests.exe+ integration tests green.Relates to #10.