Skip to content

Report an actionable error when the PrjFlt driver service is disabled - #2122

Merged
Tyrie Vella (tyrielv) merged 2 commits into
microsoft:masterfrom
tyrielv:tyrielv/fix-prjflt-disabled-start
Nov 3, 2026
Merged

Tyrie Vella (tyrielv) merged 2 commits into
microsoft:masterfrom
tyrielv:tyrielv/fix-prjflt-disabled-start

Conversation

@tyrielv

@tyrielv Tyrie Vella (tyrielv) commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem and Context

VFS for Git requires the PrjFlt ProjFS minifilter driver on every volume. A security baseline, an anti-virus or EDR product, Group Policy, or manual troubleshooting can set its service Start type to Disabled. Then VFS for Git cannot start the driver.

Today ProjFSFilter.TryStartService calls ServiceController.Start() on the disabled service. The call fails with ERROR_SERVICE_DISABLED (1058). EnableAndAttachProjFSHandler.TryEnablePrjFlt then reports only "Failed to start prjflt service", with no hint that the driver is disabled. The installer shows an equally generic error after gvfs service --mount-all fails.

This change reports the disabled state with an actionable message. It does not re-enable the driver. An administrator or security tool often disables it on purpose, so re-enabling it would change the machine's security posture without consent.

Changes

  • TryStartService checks ServiceController.StartType only when the service is not running, so a running service succeeds regardless of its start type. When the service is not running and is Disabled, it returns an error that names the driver and gives the elevated re-enable command (sc.exe config prjflt start= auto).
  • ServiceController reports a failed native call as an InvalidOperationException that wraps the Win32Exception. TryStartService unwraps it and maps the native code to a ServiceStartFailureReason: 1058 is ServiceDisabled, 1060 is ServiceNotFound, and any other code is StartFailed. Only a missing service reports "not found".
  • TryStartService returns the reason and message through out parameters. TryEnablePrjFlt shows that message instead of the generic one.
  • TryEnablePrjFlt records the ServiceStartFailureReason name in the TryEnablePrjFlt_Summary telemetry. It is a stable code, so rewording the message does not change the metric.
  • Setup.iss appends the output of gvfs service --mount-all to the error it raises on FilterError, and writes it to the setup log. Installs and upgrades now show the reason.
  • Add unit tests for TryGetDisabledStartTypeError and for GetStartFailureReason. The GetStartFailureReason tests build the wrapped InvalidOperationException shape for codes 1058, 1060, 5, and 1056.

Known gaps and deliberate decisions

  • No end-to-end test of TryStartService — it calls a live ServiceController, which has no seam. Deferred because an injectable service wrapper is more machinery than this diagnostic change needs. The decision logic is in pure helpers with tests. No follow-up planned.
  • No test of the TryEnablePrjFlt message and telemetry path — the handler has no existing test fixture and calls static ProjFSFilter methods. Deferred for the same reason. No follow-up planned.
  • No automated test of the installer change — Setup.iss has no test harness. The CI build compiles it. No follow-up planned.

@tyrielv
Tyrie Vella (tyrielv) marked this pull request as ready for review October 6, 2026 16:20

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review pass over this PR. 5 comment(s).

@tyrielv
Tyrie Vella (tyrielv) force-pushed the tyrielv/fix-prjflt-disabled-start branch from d0efb6b to 3187f0f Compare October 13, 2026 20:03

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Re-review of the amended commit. All five of my earlier threads are genuinely addressed — thank you. Two new findings below; the first one I think inverts the PR's premise, so flagging it before this lands.

CI is green across every leg.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The current head is unchanged since the prior review. Requesting changes for the existing High finding: wrapped native service-start failures still enter the InvalidOperationException handler and are reported as "service was not found," bypassing the intended Win32 error mapping. Please address the existing thread and cover the wrapped-exception shape before merge:
#2122 (comment)

The existing Medium request for stable telemetry reason codes also remains:
#2122 (comment)

These are references to the original findings, not new duplicate inline threads.

VFS for Git requires the PrjFlt ProjFS minifilter driver on every volume.
Its load behavior is governed by its service Start type. When a security
baseline, an anti-virus product, Group Policy, or manual troubleshooting
disables the service, the driver cannot start.

Today ProjFSFilter.TryStartService calls ServiceController.Start() on the
disabled service. That fails with ERROR_SERVICE_DISABLED (1058), which is
caught by a generic Win32Exception handler and surfaces to the user as the
dead-end message "Failed to start prjflt service" with no indication that
the driver is disabled and no way to fix it. Nothing else in the product
detects this state (the existing AutoLogger Start handling is an unrelated
ETW logging key).

Detect the disabled state and report it, rather than silently re-enabling a
driver that an administrator or security tool may have disabled on purpose.

Changes:
- TryStartService checks the service start type only when the service is not
  already running, so an already-running service succeeds regardless of its
  start type. When the service is not running and its start type is Disabled,
  it returns a specific error naming the driver and the exact elevated command
  to re-enable it.
- ServiceController reports a failed native service call as an
  InvalidOperationException that wraps the Win32Exception. TryStartService
  unwraps it and maps the native error code to a ServiceStartFailureReason:
  ERROR_SERVICE_DISABLED is ServiceDisabled, ERROR_SERVICE_DOES_NOT_EXIST is
  ServiceNotFound, and any other code is StartFailed. Only a missing service
  is reported as "not found".
- TryStartService reports its result through out parameters, so the caller
  surfaces the specific message instead of the generic "Failed to start prjflt
  service".
- EnableAndAttachProjFSHandler.TryEnablePrjFlt records the
  ServiceStartFailureReason in the TryEnablePrjFlt_Summary health telemetry.
  The reason is a stable code, so rewording the user-facing message does not
  change the metric.
- Added unit tests that cover the disabled and enabled start types, and the
  error-code mapping through the wrapped InvalidOperationException shape.

Assisted-by: Claude Opus 4.8
Signed-off-by: Tyrie Vella <[email protected]>
@tyrielv
Tyrie Vella (tyrielv) force-pushed the tyrielv/fix-prjflt-disabled-start branch from 3187f0f to c248802 Compare October 28, 2026 22:35
@KeithIsSleeping

Copy link
Copy Markdown

[KeithBot]: 🟡 Medium · Design — Installer drops this message: exit code 4 still shows a dead-end fatal error

Location: /GVFS/GVFS.Installers/Setup.iss:563

After install or upgrade, Setup.iss runs gvfs service --mount-all; with PrjFlt disabled it exits 4 and prints this new remedy. The exit-4 branch raises a fixed 'Fatal: Could not configure and start Windows Projected File System.' and never shows the captured MountOutput, so installs and reinstalls on such machines still end in the dead-end error.

Evidence:
gvfs service --mount-all (built at c248802), stdout redirected like ExecWithResult, against a stub service pipe returning the handler's disabled-driver error:
exit code: 4
stdout: Failed to enable PrjFlt: The PrjFlt driver service is disabled and cannot be started. [...] sc.exe config prjflt start= auto
Setup.iss:563-565 then runs RaiseException('Fatal: Could not configure and start Windows Projected File System.'); MountOutput is only shown by the non-4 branch (567-570).

Fix: Include the captured output in the FilterError branch, e.g. RaiseException('Fatal: Could not configure and start Windows Projected File System.' + #13#10 + MountOutput);. Optionally also Log(MountOutput) so silent installs keep the remedy in the setup log.

🤖 KeithBot · 1/3 models · verified locally

@KeithIsSleeping

Copy link
Copy Markdown

[KeithBot]: ⚠️ 1 issue · iteration 1 (c248802)

  1. 🟡 Medium Installer drops this message: exit code 4 still shows a dead-end fatal error

Validated: ✅ Build GVFS.UnitTests at source + base · ✅ ProjFSFilterTests 17/17 at source · ⚠️ Full unit suite 984/996 at source · ⚠️ Mutation of fix parts vs new tests · ✅ Real-SCM harness, read-only · ⚠️ Mocked-SCM error matrix 25/25 · ✅ gvfs service --mount-all via stub pipe · ✅ NativeAOT keeps enum names · ⏭️ Installer (Inno Setup) exit-4 path · ⏭️ Functional tests (ServiceTests)

🤖 KeithBot · claude-opus-5.5, gpt-6.1-sol, gemini-4-argon · reply on a thread to dispute

When the PrjFlt driver service cannot start, "gvfs service --mount-all"
exits with ReturnCode.FilterError (4) and prints the reason, including the
command that re-enables a disabled driver.

The installer captured that output but dropped it on the exit-4 path. It
raised only the fixed text "Could not configure and start Windows Projected
File System", so an install or upgrade on such a machine still ended in a
dead-end error.

Append the captured output to the error text that the installer raises, and
write it to the setup log so silent installs keep the reason.

Assisted-by: Claude Sonnet 5.5
Signed-off-by: Tyrie Vella <[email protected]>
@KeithIsSleeping

Copy link
Copy Markdown

[KeithBot]: Re: this earlier comment: Verified at 0be8fcf: a probe installer built from this commit's real MountRepos code, fed exit 4 by gvfs service --mount-all, now logs the FilterError line and shows the full sc.exe config prjflt start= auto remedy in the fatal message (c248802 showed only the fixed text).

🤖 KeithBot · recheck at iteration 2 (0be8fcf)

@KeithIsSleeping

Copy link
Copy Markdown

[KeithBot]: ✅ Resolved · iteration 2 (0be8fcf)

  • Installer drops this message: exit code 4 still shows a dead-end fatal error: fixed
  • New changes since iteration 1: no new issues

Validation

  • ✅ Inno probe of MountRepos exit-4 path
  • ✅ gvfs --mount-all exit 4 via stub pipe
  • ✅ CI run on head 0be8fcf

Approving.

🤖 KeithBot · recheck by claude-opus-5.5 · reply on a thread to dispute

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the current head: the previous concerns are addressed and current-head validation passed.

@tyrielv
Tyrie Vella (tyrielv) merged commit 0f21fc5 into microsoft:master Nov 3, 2026
35 checks passed
This was referenced Nov 9, 2026
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.

3 participants