PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

[FileLocksmith]Query system processes if elevated

Open jaimecbernardo opened this issue 3 years ago • 1 comments

Summary of the Pull Request

File Locksmith can't see processes that belong to the system user. This PR allows that when running elevated.

image

PR Checklist

  • [x] Closes: #21661
  • [x] Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • [ ] Tests: Added/updated and all pass
  • [x] Localization: All end user facing strings can be localized
  • [ ] Dev docs: Added/updated
  • [ ] New binaries: Added on the required places
  • [ ] Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

  • When running elevated, ask for SeDebugPrivilege for the File Locksmith process in order to be able to view files used by system processes.
  • The user of each process is now sent with the process results instead of queried from the UI, so moved this function accordingly and removed the interop function from the API.
  • Add a warning in UI when listing a system process.
  • Also make the list of files selected by the context menu selectable as a minor fix.

Validation Steps Performed

Tried it on the Windows folder running as elevated and verified the system processes are shown.

jaimecbernardo avatar Nov 03 '22 17:11 jaimecbernardo

@niels9001 , is the added Glyph="" (warning) icon something we can use safely here? (wondering because of the asian fonts conflict)

jaimecbernardo avatar Nov 03 '22 17:11 jaimecbernardo

  1. Should we show a warning bar (even if results are empty) when running as normal user that maybe some results are missing because of not enough permission?
  2. Can we add a warning/confirmation message that is shown when you close the process owned by a different user or the system/nt-service, ... user?
  3. Small bug also existing in v0.64.0: If you restart it as admin and the uac is disabled the "run elevated" icon isn't shown after restart. It should still be shown if you don't have admin permission.

htcfreek avatar Nov 03 '22 18:11 htcfreek

  1. Should we show a warning bar (even if results are empty) when running as normal user that maybe some results are missing because of not enough permission?
  2. Can we add a warning/confirmation message that is shown when you close the process owned by a different user or the system/nt-service, ... user?

Those are good ideas. Can you please create a UI improvement issue for 1 and 2? Those are a bit more code involved and should be separated.

jaimecbernardo avatar Nov 03 '22 18:11 jaimecbernardo

  1. Small bug also existing in v0.64.0: If you restart it as admin and the uac is disabled the "run elevated" icon isn't shown after restart. It should still be shown if you don't have admin permission.

Yeah, the elevated detection logic could be better.

jaimecbernardo avatar Nov 03 '22 18:11 jaimecbernardo

@jaimecbernardo I will open the ui improvements issues tomorrow or on Sunday. Should I open an issue for the elevation logic improvement too?

htcfreek avatar Nov 03 '22 21:11 htcfreek

@jaimecbernardo I will open the ui improvements issues tomorrow or on Sunday. Should I open an issue for the elevation logic improvement too?

I'll try to include that in this PR, since it also uses elevation. Thank you!

jaimecbernardo avatar Nov 03 '22 21:11 jaimecbernardo

Hi, I've included the requested changes to the username function, added proper elevation detection similar to our other C++ utils and used a theme approppriate color. Thanks for your reviews and help!

jaimecbernardo avatar Nov 04 '22 15:11 jaimecbernardo

  1. Should we show a warning bar (even if results are empty) when running as normal user that maybe some results are missing because of not enough permission?
  2. Can we add a warning/confirmation message that is shown when you close the process owned by a different user or the system/nt-service, ... user?

Those are good ideas. Can you please create a UI improvement issue for 1 and 2? Those are a bit more code involved and should be separated.

@jaimecbernardo I have opened the issues.

htcfreek avatar Nov 06 '22 12:11 htcfreek