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

Disable winhooks if screen reader is active #3896

Merged
merged 1 commit into from
May 26, 2020

Conversation

ethindp
Copy link
Contributor

@ethindp ethindp commented Nov 14, 2019

This PR adds a detection mechanism that, while primitive, prevents windows hooking when a screen reader is found to be running when Mumble is executed. This is accomplished by enumerating the process list and checking for a (currently hardcoded) set of (only two right now) screen reader binaries. I know that NVDA (denoted by image name nvda.exe) is affected when Mumble loads winhooks, but I don't know if JAWS (denoted with image name jfw.exe) is. Rather than add every screen reader I know of to this list, I feel it might be better to just add them when we come across them.
Note: I have not built this code yet. I am working on automating the build process since I am unable to do it on my local machine at this time, so expect errors. (I tried not to make any, but you know...) Also, I did my best to mantain formatting, though it wasn't easy. :)

@davidebeatrici
Copy link
Member

Executables are only detected when Mumble is started, but it's certainly better than not handling them at all.

Aside from that, the code looks good!

I would use CreateToolhelp32Snapshot() instead of EnumProcesses():

static inline procid_t getProcess(const wchar_t *exename) {
PROCESSENTRY32 pe;
procid_t pid = 0;
pe.dwSize = sizeof(pe);
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnap != INVALID_HANDLE_VALUE) {
BOOL ok = Process32First(hSnap, &pe);
while (ok) {
if (wcscmp(pe.szExeFile, exename)==0) {
pid = pe.th32ProcessID;
break;
}
ok = Process32Next(hSnap, &pe);
}
CloseHandle(hSnap);
}
return pid;
}

@ethindp
Copy link
Contributor Author

ethindp commented Nov 14, 2019

Also, I used the Query* process functions because I wasn't sure how to do this with the snapshot API. Is there a way I can call the plugin frim the GlobalShortcut_win.cpp file?

@davidebeatrici
Copy link
Member

You can use the snapshot functions in GlobalShortcut_win.cpp, you just have to include <tlhelp32.h> instead of <pasapi.h>.

@ethindp
Copy link
Contributor Author

ethindp commented Nov 14, 2019

Should I just #include "mumble_plugin_win32.h" from the .cpp file? Or would that break things? Trying to fix the test failures.

@davidebeatrici
Copy link
Member

No, that's the header we use for plugins, you should include <tlhelp32.h> (a Windows header).

@ethindp
Copy link
Contributor Author

ethindp commented Nov 14, 2019

I just pretty much copy-pasted (and then modified) the getProcess() function from the win32 plugin header file. Let's hope the checks pass this time. I'll fix them if they don't. :)

@davidebeatrici
Copy link
Member

davidebeatrici commented Nov 14, 2019

// Disable hooking if a screen reader is running
bool bFoundSr = false;
const QStringList srList = { QLatin1String("nvda.exe"), QLatin1String("jfw.exe") };

const auto snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (snapshot != INVALID_HANDLE_VALUE) {
	PROCESSENTRY32 processEntry;
	processEntry.dwSize = sizeof(processEntry);
	auto ok = Process32First(snapshot, &processEntry);
	while (ok) {
		if (stList.contains(QString::fromWCharArray(processEntry.szExeFile))) {
			bFoundSr = true;
			break;
		}

		ok = Process32Next(snapshot, &processEntry); 
	}

	CloseHandle(snapshot);
}

// "winhooks" is a hidden setting to disable hooking
bHook = g.qs->value(QLatin1String("winhooks"), true).toBool() || bFoundSr;

@ethindp
Copy link
Contributor Author

ethindp commented Nov 14, 2019

That works too... sorry -- I'm not exactly familiar with this API, so thanks for the help. I'll put that in my function though -- keep all of that code nice and clean.

@davidebeatrici
Copy link
Member

No problem, you're welcome.

@ethindp
Copy link
Contributor Author

ethindp commented Nov 14, 2019

There we go, committed (and credited you of course). Now we wait for these checks to pass and we should be all good to go.

@davidebeatrici
Copy link
Member

Don't worry about the credits, it's fine.

@davidebeatrici
Copy link
Member

I assume you're editing the files on GitHub, right?

Let me squash the commits for you.

@ethindp
Copy link
Contributor Author

ethindp commented Nov 14, 2019

Sure thing. And I'm editing them on my computer, not on git hub, but I push every time I make an edit. Never squashed a commit before though.
Edit: I cannot type today. 🗡

@davidebeatrici
Copy link
Member

Oh, sorry, I assumed you were editing the files on GitHub because all commits are signed, but I just noticed it's your own GPG key.

Would you like to squash the commits?

@ethindp
Copy link
Contributor Author

ethindp commented Nov 14, 2019

Yes

@davidebeatrici
Copy link
Member

Assuming there are 5 commits:

  1. git rebase -i HEAD~5
  2. Change pick to squash (or s) near the commits you want to squash, save and exit from the editor.
  3. Choose a message for the new commit, save and exit from the editor.

@ethindp
Copy link
Contributor Author

ethindp commented Nov 14, 2019

Rebased. Was a bit confused so the rebase commit is a bit confusing, but undersand it now. :)

@davidebeatrici
Copy link
Member

Did you force-push after rebasing the commits? I still see all commits.

About the merge commit: I always recommend to enable autorebase, so that when you pull from a remote Git doesn't create it:

git config --global pull.rebase true

@ethindp
Copy link
Contributor Author

ethindp commented Nov 14, 2019

had to pull and then push. The server disallowed me from pushing until I pulled.

@ethindp
Copy link
Contributor Author

ethindp commented Nov 14, 2019

Just saw some checks fail. I'll fix those when I get back from dinner.

@davidebeatrici
Copy link
Member

had to pull and then push. The server disallowed me from pushig until I pulled.

Because when you rewrite history you have to force-push, either with git push --force or with the more recommended git push --force-with-lease.

Just saw some checks fail. I'll fix those when I get back from dinner.

No problem, see #3896 (review).

@ethindp
Copy link
Contributor Author

ethindp commented Nov 15, 2019

OK, just pushed new changes, let's see if checks pass this time.

@ethindp
Copy link
Contributor Author

ethindp commented Nov 15, 2019

Submitted that fix about 5-6 minutes (or more, dunno) ago. Waiting for checks to pass now.

@ethindp
Copy link
Contributor Author

ethindp commented Nov 15, 2019

Working on fixing that failure now.

@Krzmbrzl
Copy link
Member

Yes - it worked ^^

Note however that while looking through the code I encountered that I think you are doing the opposite of what you wanted to achieve (I think). Please see my code-review for details :)

@ethindp
Copy link
Contributor Author

ethindp commented Jan 20, 2020 via email

@ethindp
Copy link
Contributor Author

ethindp commented Jan 20, 2020

Updated and fixed. Hopefully this works.

… of winhooks if a screen reader was found to be running at app startup
@Krzmbrzl
Copy link
Member

I squashed the commits together again.

Btw.: What does this change have to do with the overlay? I only see that this is related to shortcuts, but I don't see a relationship to the overlay-feature of mumble 🤔

@ethindp
Copy link
Contributor Author

ethindp commented Jan 20, 2020

The global shortcuts files, if I'm not mistaken, deal with the overlay as well, since the overlay uses windows hooks for it to work, no?

@Krzmbrzl
Copy link
Member

Hm could be. Dunno though. That's something we'll have to ask @davidebeatrici

In the meantime I'd ask you to force-pull (git pull - f) the current state from your branch to your local machine and test whether this now works as expected :)

@ethindp
Copy link
Contributor Author

ethindp commented Jan 20, 2020

It should, not sure why tests are failing.

@Krzmbrzl
Copy link
Member

CI is failing because it has trouble installing dependencies. That happens from time to time and is not related to the code changes.

I'm not referring to whether the code compiles. I'm talking about testing if the code does what it is supposed to do. Compiling is only half the story.
So please compile the code and verify that the hooking is disabled if you are using Mumble with a screen reader (and that it is enabled if opening it without a reader).

@ethindp
Copy link
Contributor Author

ethindp commented Jan 20, 2020

That will be kinda hard. I can't test it without a screen reader (as I myself anvisually impaired) and I can't build it on the windows side so will need to build with MinGW. But once I've done that I can test to see if winhooks are disabled when a screen reader is active.

@Krzmbrzl
Copy link
Member

Ah okay - no problem I guess that testing whether the hooks are disabled if a screen reader is active is enough. And MinGW should be fine :)

@ethindp
Copy link
Contributor Author

ethindp commented Jan 20, 2020

It'll take me a bit, but I'll get back to you today.

@davidebeatrici
Copy link
Member

Thank you very much for pushing this forward!

I confirm that the changes only afflict global shortcuts.

@Krzmbrzl
Copy link
Member

In that case, I'll adapt the commit message accordingly before this will be merged eventually :)

@Krzmbrzl Krzmbrzl changed the title Overlay, winhooks: add screen reader detection to prevent the setting… Disable winhooks if screen reader is active Jan 22, 2020
@Krzmbrzl
Copy link
Member

@ethindp did you already get to test your changes?

@ethindp
Copy link
Contributor Author

ethindp commented Jan 31, 2020 via email

@Krzmbrzl Krzmbrzl added the needs-testing A feature or fix that is ready but still needs testing before it can be used. label Feb 8, 2020
Copy link
Member

@Krzmbrzl Krzmbrzl left a comment

Choose a reason for hiding this comment

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

Now that I have had a bit more experience with the code base I'm confident that the changes made here should be fine.

@Krzmbrzl Krzmbrzl merged commit 1d7fbd9 into mumble-voip:master May 26, 2020
@Krzmbrzl
Copy link
Member

Thank you for your contribution :)
(And sorry that it took so long to process this PR)

@ethindp
Copy link
Contributor Author

ethindp commented May 26, 2020 via email

@Krzmbrzl
Copy link
Member

it seems as though its
in a sort-of stasis mode.

*was
We're already starting to increase the pace of development again :)

@ethindp
Copy link
Contributor Author

ethindp commented May 27, 2020 via email

@Krzmbrzl
Copy link
Member

Yeah we had to remove sbcelt for that reason. You should be able to just go to a branch you haven't made any changes and then run

git pull https://github.com/mumble-voip/mumble.git master

to update to the latest and greatest version :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility Everything related to accessibility-features (like screen-readers) client GlobalShortcuts needs-testing A feature or fix that is ready but still needs testing before it can be used.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants