Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 601
DNR Avatar asked Apr 09 '13 09:04

DNR


1 Answers

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.

like image 66
J... Avatar answered Oct 29 '22 02:10

J...