Skip to content

Conversation

andyleejordan
Copy link
Member

@andyleejordan andyleejordan commented Aug 27, 2025

Since we're not actually making a system call.

try
{
using var mutex = new System.Threading.Mutex(false, name);
return Marshal.GetLastWin32Error() == ERROR_ALREADY_EXISTS;
Copy link
Member Author

Choose a reason for hiding this comment

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

@SeeminglyScience astutely pointed out this is bad, as we're not exactly making a system call when gettingn the mutex. It should be TryOpenExisting.

Copy link
Member Author

Choose a reason for hiding this comment

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

And fixed. Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I just saw this after merging #4854. Please submit a new PR for the fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

I already updated this one 😄

@andyleejordan andyleejordan force-pushed the accessibility branch 2 times, most recently from df27716 to df72935 Compare August 28, 2025 18:39
Since we're not actually making a system call.
@andyleejordan andyleejordan changed the title Improve IsScreenReaderActive() Fix IsMutexPresent() to avoid incorrect use of GetLastWin32Error() Aug 28, 2025
@daxian-dbw daxian-dbw merged commit 1cdbf46 into PowerShell:master Aug 28, 2025
2 checks passed
@andyleejordan andyleejordan deleted the accessibility branch August 28, 2025 21:57
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.

2 participants