Skip to content

[release/v7.4.21] Fix FileOnlyEntry crashing on older versions of Windows - #28043

Open
Aditya Patwardhan (adityapatwardhan) wants to merge 2 commits into
PowerShell:release/v7.4.21from
adityapatwardhan:backport/release/v7.4.21/27880-80fdeb912
Open

Aditya Patwardhan (adityapatwardhan) wants to merge 2 commits into
PowerShell:release/v7.4.21from
adityapatwardhan:backport/release/v7.4.21/27880-80fdeb912

Conversation

@adityapatwardhan

Copy link
Copy Markdown
Member

Backport of #27880 to release/v7.4.21

Triggered by Aditya Patwardhan (@adityapatwardhan) on behalf of Patrick Meinecke (@SeeminglyScience)

Original CL Label: CL-Engine

/cc @PowerShell/powershell-maintainers

Impact

REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.

Tooling Impact

  • Required tooling change
  • Optional tooling change (include reasoning)

Customer Impact

  • Customer reported
  • Found internally

Prevents PowerShell from crashing on older Windows versions when the EnableFileOnlyEntry WLDP support is present but the operating system does not expose the required native entry point. Expected behavior is to treat the unavailable setting as disabled.

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

Fixes the compatibility regression introduced by original PR #26752, which adds EnableFileOnlyEntry support and is the prerequisite backport.

Testing

Validated the stacked prerequisite and fix with git diff --check and a clean worktree. A focused ConsoleHost build was attempted and is blocked by unrelated pre-existing generated-resource errors for DotNetEventingStrings in Microsoft.PowerShell.CoreCLR.Eventing; backport CI will perform full validation.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

High risk because this changes Windows WLDP interop behavior in the engine. The change is narrowly scoped to catching EntryPointNotFoundException on Windows versions that lack the newer WLDP entry point, and it is stacked on the required EnableFileOnlyEntry prerequisite.

Merge Conflicts

The initial cherry-pick conflicted because prerequisite PR #26752 is not yet merged into release/v7.4.21. The cherry-pick was aborted, the validated #26752 backport commit was applied first, and #27880 then cherry-picked cleanly. This PR is therefore stacked on backport PR #28041; after #28041 merges, only the #27880 fix remains in this PR's effective diff.

Copilot AI lite review requested due to automatic review settings September 21, 2026 21:09
@adityapatwardhan Aditya Patwardhan (adityapatwardhan) added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Sep 21, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Valid positional script paths are incorrectly rejected when FileOnlyEntry is enabled.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Backports the WLDP FileOnlyEntry compatibility fix to prevent crashes on older Windows versions when the native entry point is unavailable.

Changes:

  • Safely handles missing WLDP DLL entry points.
  • Enforces file-only policy in console argument parsing.
  • Adds Windows security helpers, resources, and tests.
File Description
HelpersSecurity.psm1 Adds test policy toggles.
FileOnlyEntry.Tests.ps1 Adds policy behavior tests.
wldpNativeMethods.cs Adds safe WLDP setting access.
CommandLineParameterParserStrings.resx Adds policy error messages.
ConsoleHost.cs Blocks policy-incompatible server modes.
CommandLineParameterParser.cs Applies file-only entry validation.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +1300 to +1304
if (_error is null
&& !_showVersion
&& !_showHelp
&& !ParametersUsed.HasFlag(ParameterBitmap.File)
&& IsFileOnlyEntryEnabled)
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Review - Needed The PR is being reviewed label Oct 1, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

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

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log Review - Needed The PR is being reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants