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

CreateUniqueGuidForProcessPath() can fail on systems that have memory protection enabled #188

Open
Difegue opened this issue Jan 9, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Difegue
Copy link
Contributor

Difegue commented Jan 9, 2025

Describe the bug

On some machines, the mechanism to derive a unique Guid from the process path fails.
We're unsure what causes this to happen at the moment -- The most likely cause is malware protection software that's a bit too overeager in its memory protection.

Steps to reproduce the bug

  1. Instantiate a TaskbarIcon on the affected systems
  2. App instantly throws when trying to get the process information.
System.ComponentModel.Win32Exception (HRESULT #-2147467259)

Only part of a ReadProcessMemory or WriteProcessMemory request was completed

    System.Diagnostics.NtProcessManager in GetModuleInfos at line 1
    System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly)
    System.Diagnostics.NtProcessManager.GetFirstModuleInfo(Int32 processId)
    System.Diagnostics.Process.get_MainModule()
    H.NotifyIcon.Core.TrayIcon.GetProcessPath() in /_/src/libs/H.NotifyIcon/Core/TrayIcon.cs:line 230
    H.NotifyIcon.Core.TrayIcon.CreateUniqueGuidForProcessPath(String postfix) in /_/src/libs/H.NotifyIcon/Core/TrayIcon.cs:line 259
    H.NotifyIcon.TaskbarIcon..ctor() in /_/src/libs/H.NotifyIcon.Shared/TaskbarIcon.cs:line 54
    xxxxxx.yyyyy.InitializeTaskbarIcon()

Expected behavior

The library should not throw.

I imagine this might be a bit difficult to fix considering the design -- It would be helpful if the TaskbarIcon constructor allowed us to set an arbitrary Guid ourselves.

Currently it can only use the empty constructor for TrayIcon, instead of the one that takes an Guid or a String.

Screenshots

No response

NuGet package version

2.1.0

Platform

WPF

IDE

Visual Studio 2022

Windows Version

Windows 11

WindowsAppSDK Version

No response

WindowsAppSDK Type

None

Manifest

No response

Additional context

No response

@Difegue Difegue added the bug Something isn't working label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant