How to receive keyboard input from application with admin privileges to a non-admin application?

你说的曾经没有我的故事 提交于 2019-12-10 12:36:16

问题


I have programmed an application that has an overlay-kind of window that can be shown and hidden via hotkey while another application has the focus. Said other application is a DirectX game that runs with admin privileges.

I have already tried 3 possible solutions to get notified when my hotkey is pressed in the other application, 2 of them kind of work, but require my application to have administrative privileges too. That is kind of acceptable, but I'd much rather have a solution that does not require those privileges. I am sure that there has to be a way, since applications like TeamSpeak do manage to receive input without being run as admin.

What I have tried already:

  1. RegisterHotkey - not suitable because it doesn't work while in DirectX windows.
  2. SetWindowsHookEx - works as a general keyboard hook, but only with admin privileges.
  3. GetAsyncKeyState - works to check the specified hotkey, but not without admin privileges yet again.

So yeah, I'd be really grateful if someone could provide an idea for a different solution since there is nothing more I could think of ... I am using Delphi, but since I'm relying on Windows API anyways I don't think the solution will be language specific.


回答1:


I think TeamSpeak uses DirectInput for its hotkeys (a nice fit for you if you are already using DirectX). As for interacting with elevated programs, I think the only solution, and I believe the one TeamSpeak uses, is to embed an application manifest that sets uiAccess=true. This allows you to bypass UIPI without needing to run the application as administrator.

http://msdn.microsoft.com/en-us/library/bb756929.aspx

For this to work there are a few caveats

  • The application must be authenticode signed
  • The application must reside in a protected directory (\ProgramFiles\,\system32)

You can self-sign the application (as the alternative is expensive!) but you have to distribute the certificate manually and install it on any system running the application in question.



来源:https://stackoverflow.com/questions/15898769/how-to-receive-keyboard-input-from-application-with-admin-privileges-to-a-non-ad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!