-
Notifications
You must be signed in to change notification settings - Fork 0
Fix non-finite bounds producing UB via static_cast in XAML/WinUI3 elements #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
77257a3
Initial plan
Copilot 4bec7a8
Fix element bounds validation and safe double-to-int conversion
Copilot 9edf129
Extract safe_double_to_int to shared bounds_util.h and fix screenshot…
Copilot fb440f4
Extract safe_double_to_int to shared bounds_util.h and fix screenshot…
Copilot 29f3095
Remove CodeQL artifact and add to gitignore
Copilot a6725e3
Return std::optional from safe_double_to_int, add annotations test ho…
Copilot aba9c37
Use named constants for bounds thresholds, match annotate_pixels clip…
Copilot 69bb3a6
Guard --annotations-json flag with #ifndef NDEBUG for debug-only builds
Copilot ebbe001
Add controlled Win32 window integration tests for tree structure, bou…
Copilot 5e8898d
Fix integration test file locking: close ifstream before fs::remove
asklar 65265c5
Fix WinUI3 element bounds: layout offset computation and bridge matching
asklar c4df9cb
Remove unreliable layout offset heuristic, add DPI scaling
asklar 9afb265
Fix annotation bounds, exclude own terminal from --title, add build s…
asklar 3d39a10
Fix XAML element positions via TransformToVisual and DPI scaling
asklar 802c42a
Extract important XAML properties into tree dump
asklar e0dd59c
Use C++/WinRT projected types for XAML element inspection
asklar 4c845c9
Fix text property: don't use AutomationProperties.Name as text, remov…
asklar 089c5d6
Reduce annotation clutter: skip layout containers, place labels insid…
asklar f92e151
Fix CI: generate WinUI3 C++/WinRT headers at configure time
asklar 8766bdd
Support UWP/system XAML (Windows.UI.Xaml) for position and text reading
asklar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,3 +15,6 @@ Desktop.ini | |
| .DS_Store | ||
| *.png | ||
| !docs/*.png | ||
| _codeql_detected_source_root | ||
|
|
||
| src/tap/winui3/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| @echo off | ||
| setlocal enabledelayedexpansion | ||
|
|
||
| REM lvt build script — run from a VS Developer Command Prompt (x64) | ||
| REM Requires: VCPKG_ROOT set, cl.exe and ninja.exe on PATH | ||
| REM Usage: build.cmd [clean] | ||
|
|
||
| if "%VCPKG_ROOT%"=="" ( | ||
| echo ERROR: VCPKG_ROOT is not set. | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| where cl.exe >nul 2>&1 || (echo ERROR: cl.exe not found. Run from a VS Developer Command Prompt. & exit /b 1) | ||
| where ninja.exe >nul 2>&1 || (echo ERROR: ninja.exe not found. & exit /b 1) | ||
|
|
||
| if /i "%1"=="clean" ( | ||
| echo Cleaning build directory... | ||
| if exist build rmdir /s /q build | ||
| ) | ||
|
|
||
| REM --- .NET projects (must build before CMake) --- | ||
|
|
||
| echo. | ||
| echo === Building .NET projects === | ||
|
|
||
| echo [1/2] LvtWpfTap (net48)... | ||
| dotnet build src\tap_wpf\LvtWpfTap.csproj -c Release -v:q --nologo | ||
| if errorlevel 1 ( | ||
| echo WARNING: LvtWpfTap build failed (WPF TAP will be unavailable) | ||
| ) | ||
|
|
||
| echo [2/2] LvtAvaloniaTreeWalker (net8.0)... | ||
| dotnet restore src\plugin_avalonia\LvtAvaloniaTreeWalker\LvtAvaloniaTreeWalker.csproj -v:q --nologo | ||
| dotnet publish src\plugin_avalonia\LvtAvaloniaTreeWalker\LvtAvaloniaTreeWalker.csproj -c Release -v:q --nologo | ||
| if errorlevel 1 ( | ||
| echo WARNING: LvtAvaloniaTreeWalker build failed (Avalonia plugin will be unavailable) | ||
| ) | ||
|
|
||
| REM --- CMake configure + build --- | ||
|
|
||
| echo. | ||
| echo === Configuring CMake (x64) === | ||
|
|
||
| if not exist build ( | ||
| cmake --preset default | ||
| if errorlevel 1 ( | ||
| echo ERROR: CMake configure failed. | ||
| exit /b 1 | ||
| ) | ||
| ) | ||
|
|
||
| echo. | ||
| echo === Building C++ targets === | ||
|
|
||
| cmake --build build | ||
| if errorlevel 1 ( | ||
| echo. | ||
| echo ERROR: C++ build failed. | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| echo. | ||
| echo === Build complete === | ||
| echo Output: build\lvt.exe | ||
| echo build\lvt_tap_x64.dll | ||
| echo Tests: build\lvt_unit_tests.exe | ||
| echo build\lvt_integration_tests.exe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #pragma once | ||
| #include <cmath> | ||
| #include <climits> | ||
| #include <optional> | ||
|
|
||
| namespace lvt { | ||
|
|
||
| // Safe double-to-int conversion: clamp to int range and reject non-finite values. | ||
| // Returns std::nullopt for NaN/Infinity so callers can skip bounds entirely. | ||
| // Prevents undefined behavior from static_cast<int> when the double is NaN, Inf, | ||
| // or outside the representable int range. | ||
| inline std::optional<int> safe_double_to_int(double v) { | ||
| if (!std::isfinite(v)) return std::nullopt; | ||
| if (v >= static_cast<double>(INT_MAX)) return INT_MAX; | ||
| if (v <= static_cast<double>(INT_MIN)) return INT_MIN; | ||
| return static_cast<int>(v); | ||
| } | ||
|
|
||
| } // namespace lvt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.