Fix StylusPointPropertyInfo crash from invalid HID min/max values#11564
Open
sleman wants to merge 1 commit intodotnet:mainfrom
Open
Fix StylusPointPropertyInfo crash from invalid HID min/max values#11564sleman wants to merge 1 commit intodotnet:mainfrom
sleman wants to merge 1 commit intodotnet:mainfrom
Conversation
Some touch digitizers (e.g. Surface Pro 9, Snapdragon ARM devices) report HID descriptors where Logical Maximum is less than Logical Minimum (commonly 0xFF interpreted as signed -1). The StylusPointPropertyInfo constructor throws an ArgumentException when maximum < minimum, crashing the application. Fix by swapping min/max when inverted at both call sites: - WM_POINTER stack: PointerStylusPointPropertyInfoHelper.CreatePropertyInfo - WISP stack: PenContext.InitStylusPointDescription Fixes dotnet#7069, dotnet#8435, dotnet#8826
Author
|
@dotnet-policy-service agree [company="{Lumasoft LLC}"] |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a crash in WPF’s stylus/touch input stacks caused by some devices reporting inverted HID logical min/max values (logical maximum < logical minimum), which can trigger StylusPointPropertyInfo constructor validation and crash on first touch/stylus interaction.
Changes:
- WISP stack: swap
min/maxfromGetPacketPropertyInfowhen inverted before creatingStylusPointPropertyInfo. - WM_POINTER stack: swap
logicalMin/logicalMaxwhen inverted and use the corrected values for both resolution calculation andStylusPointPropertyInfoconstruction.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Wisp/PenContext.cs |
Normalizes inverted min/max from WISP packet properties to prevent StylusPointPropertyInfo exceptions. |
src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Pointer/PointerStylusPointPropertyInfoHelper.cs |
Normalizes inverted logical min/max from WM_POINTER device properties and ensures downstream computations use corrected values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Author
|
@dotnet-policy-service agree |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
WPF applications crash with an
ArgumentExceptioninStylusPointPropertyInfoon touch-enabled devices whose HID descriptors reportLogical Maximum < Logical Minimum(e.g.0xFFinterpreted as signed-1). This affects both the WM_POINTER and WISP stylus stacks, making touch input completely unusable on affected hardware.This is a common issue on Surface Pro devices with Snapdragon/ARM processors and other modern touch-enabled Windows devices.
Root cause
The
StylusPointPropertyInfoconstructor validatesmaximum >= minimumand throws if not. Both stylus stacks pass hardware-reported values directly to this constructor without checking the range:PointerStylusPointPropertyInfoHelper.CreatePropertyInfo()passesprop.logicalMin/prop.logicalMaxPenContext.InitStylusPointDescription()passesmin/maxfromGetPacketPropertyInfo()Fix
Swap
min/maxwhen the hardware reports them inverted, at both call sites. This preserves the range magnitude, avoids changing the public API, and allows touch input to function correctly.For the WM_POINTER stack, the resolution calculation is also updated to use the corrected values.
Affected devices
Logical Maximum < Logical MinimumAffected issues