Skip to content

Decode Win32 HRESULT messages before formatting#6321

Open
starSumi wants to merge 1 commit into
microsoft:masterfrom
starSumi:fix/6319-wininet-hresult-message
Open

Decode Win32 HRESULT messages before formatting#6321
starSumi wants to merge 1 commit into
microsoft:masterfrom
starSumi:fix/6319-wininet-hresult-message

Conversation

@starSumi

@starSumi starSumi commented Jun 23, 2026

Copy link
Copy Markdown

Summary

Fixes #6319.

When a Win32 error is wrapped as an HRESULT via HRESULT_FROM_WIN32, GetUserPresentableMessageForHR currently passes the full HRESULT value to std::system_category().message(...). For errors such as 0x80072efd (ERROR_INTERNET_CANNOT_CONNECT), this can render as unknown error instead of the underlying Win32/WinINet message.

This change decodes FACILITY_WIN32 HRESULTs with HRESULT_CODE(hr) before asking std::system_category for the message.

Changes

  • Decode FACILITY_WIN32 HRESULTs before formatting unknown external error messages.
  • Add a regression test for HRESULT_FROM_WIN32(ERROR_INTERNET_CANNOT_CONNECT).

Validation

  • git diff --check passed locally.
  • I could not run AppInstallerCLITests.exe locally because this environment does not have Visual Studio/MSBuild or an already-built test binary available.

Opened as draft for maintainer feedback and CI validation.

Microsoft Reviewers: Open in CodeFlow

Decode HRESULT_FROM_WIN32 values before asking std::system_category for user-facing text so WinINet errors do not render as unknown error.

Adds a regression test for ERROR_INTERNET_CANNOT_CONNECT.
@starSumi

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@starSumi starSumi marked this pull request as ready for review June 23, 2026 09:46
@starSumi starSumi requested a review from a team as a code owner June 23, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Network failures should decode WinINet HRESULTs and include actionable proxy context

1 participant