Skip to content

Fix StylusPointPropertyInfo crash from invalid HID min/max values#11564

Open
sleman wants to merge 1 commit intodotnet:mainfrom
sleman:fix/stylus-invalid-min-max
Open

Fix StylusPointPropertyInfo crash from invalid HID min/max values#11564
sleman wants to merge 1 commit intodotnet:mainfrom
sleman:fix/stylus-invalid-min-max

Conversation

@sleman
Copy link
Copy Markdown

@sleman sleman commented Apr 4, 2026

Summary

WPF applications crash with an ArgumentException in StylusPointPropertyInfo on touch-enabled devices whose HID descriptors report Logical Maximum < Logical Minimum (e.g. 0xFF interpreted 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 StylusPointPropertyInfo constructor validates maximum >= minimum and throws if not. Both stylus stacks pass hardware-reported values directly to this constructor without checking the range:

  • WM_POINTER stack: PointerStylusPointPropertyInfoHelper.CreatePropertyInfo() passes prop.logicalMin/prop.logicalMax
  • WISP stack: PenContext.InitStylusPointDescription() passes min/max from GetPacketPropertyInfo()

Fix

Swap min/max when 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

  • Microsoft Surface Pro 9, 10, 11th Edition (Snapdragon/ARM variants)
  • Other Snapdragon ARM-based Windows devices
  • Any device whose touch digitizer HID descriptor has Logical Maximum < Logical Minimum

Affected issues

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
@sleman sleman requested review from a team and Copilot April 4, 2026 05:45
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Apr 4, 2026
@sleman
Copy link
Copy Markdown
Author

sleman commented Apr 4, 2026

@dotnet-policy-service agree [company="{Lumasoft LLC}"]

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/max from GetPacketPropertyInfo when inverted before creating StylusPointPropertyInfo.
  • WM_POINTER stack: swap logicalMin/logicalMax when inverted and use the corrected values for both resolution calculation and StylusPointPropertyInfo construction.

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.

@sleman
Copy link
Copy Markdown
Author

sleman commented Apr 4, 2026

@dotnet-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage

Projects

None yet

2 participants