Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FileLocksmith]Query system processes if elevated #21688

Merged
merged 7 commits into from Nov 4, 2022

Conversation

jaimecbernardo
Copy link
Collaborator

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

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
Copy link
Collaborator Author

jaimecbernardo commented Nov 3, 2022

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

Copy link
Collaborator

@yuyoyuppe yuyoyuppe left a comment

Choose a reason for hiding this comment

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

Tested locally, LGTM. Added a suggestion

{
public object Convert(object value, Type targetType, object parameter, string language)
{
return NativeMethods.PidToUser((uint)value);
string user = ((string)value).ToUpperInvariant().TrimEnd('\0').Trim();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe we no longer have to trim \0

@htcfreek
Copy link
Collaborator

htcfreek commented Nov 3, 2022

  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.

<FontIcon
Margin="0,0,8,0"
Glyph="&#xE7BA;"
Foreground="Yellow"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this visible in light mode? If not we should bind against a theme resource for the InfoBarIconBackgrond. You can look at the PT Run plugin list code for an example on how to do it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Foreground="{ThemeResource InfoBarWarningSeverityIconBackground}"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you! :) Very helpful!

@jaimecbernardo
Copy link
Collaborator Author

  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
Copy link
Collaborator Author

  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.

@htcfreek
Copy link
Collaborator

htcfreek commented Nov 3, 2022

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

@jaimecbernardo
Copy link
Collaborator Author

@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
Copy link
Collaborator Author

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!

Copy link
Collaborator

@yuyoyuppe yuyoyuppe left a comment

Choose a reason for hiding this comment

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

Nice!

@htcfreek
Copy link
Collaborator

htcfreek commented Nov 6, 2022

  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.

jaimecbernardo added a commit that referenced this pull request Nov 7, 2022
* [FileLocksmith]Query system processes if elevated

* Show warning if user is a system user

* Make text in the file list selectable

* Update src/modules/FileLocksmith/FileLocksmithLibInterop/NtdllExtensions.cpp

Co-authored-by: Andrey Nekrasov <yuyoyuppe@users.noreply.github.com>

* Trim \0 no longer required

* Correct elevation detection logic

* Use theme approppriate colors

Co-authored-by: Andrey Nekrasov <yuyoyuppe@users.noreply.github.com>
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.

None yet

3 participants