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

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:
RegisterHotkey - not suitable because it doesn't work while in DirectX windows.
SetWindowsHookEx - works as a general keyboard hook, but only with admin privileges.
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.

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.

Related

Is iOS capable of accessing and manipulating files on a Windows network file share?

I'm planning an app for work and venturing into potential features which I've not used before.
Essentially I need to be able to access files on a network share, read, write and delete files as well as amend the file names. As a pretty closed platform I'm not sure whether iOS is capable of such a thing and if it is, what features should I look for to begin researching?
My Google-Fu hasn't come up with anything thus far so hopefully looking for someone to point me in the right direction.
Thanks.
I know this isn't very secure, but I'd personally create an ASP.NET app on your target Windows Server, or a different Server on the domain. Create web services exposed, and make an iOS app with UIWebView. You can do RPC calls from the web service that do WMI/ADSI/File System manipulation. You can prompt for domain credentials, and do remote calls essentially is the gist.
You could expose the web app so that your app can access it from local network, or URL. If you were to access it from outside I'd suggest using some secure credentials in Windows/IIS.
Some years ago I created a "mobile-friendly" web app that allowed me to manage servers, perform RPC, and do basic Active Directory queries. Also allowed file listing and deletion/moving/copying with some creative scripting. It was essentially a ASP.NET/C# web app that loaded in a iPhone app. UIWebView in iOS was a able to load it, used AJAX and some other client side scripting that looked decent. You'd essentially have to make sure that your web app renders properly in Safari/UIWebView (which is bastardized safari).
Here's a link to a demo of what I created:
https://www.youtube.com/watch?v=czXmubijHwQ&t=12s
I ran it in a browser, but it'd run from my PSP, Android test devices, iPod Touch, Blackberry, etc.

Can I register a custom URL scheme without Administrator elevation?

There are many stack overflow questions about how to register a custom URL scheme (e.g. this one). However, the answer in every case seems to be to write to the privileged registry key HKEY_CLASSES_ROOT. My (wix-based) installer currently runs without elevation, installing per-user. Is there any way I can register a custom URL scheme without elevating to administrator privileges? I don't need to support anything older than Windows 7.
What I'm trying to achieve is to have links on a web page that perform specific actions in my application. My application is mostly .NET. The web page is ASP.NET.
I found the answer in this answer to a similar question. As an alternative to HKEY_CLASSES_ROOT, put the appropriate registry keys under HKEY_CURRENT_USER\Software\Classes. This location does not require elevation to write to.

Windows Service + Run application in System Tray

I have a Delphi application running in a server. This application do some critical work with my DB which is used in other applications and executes when a user logs in to Windows. It all is working fine, but, turns out the server's administrator sometimes reboot the server and does not log in to Windows. The server stays in Windows Login and my application doesn't start.
After a small research I decided to create a Windows Service to start my application even before a user logs in Windows. But, I have two forms. One form shows the Current Process that my application is executing and the other one edite a .ini file that its used to configure the first form.
What I need to be done is to create a service that starts my application before a user logs in Windows and after logging in, show my forms or open it but minimize it to System Tray.
Is it possible to use Windows Service with this behavior and minimize my forms to the System Tray?
A service cannot display a UI at all (including a System Tray icon) in Vista onwards, and it is discouraged in earlier versions. In all versions of Windows, you should be separating the UI out into its own non-service application that can be run by a logged-in user, manages the system tray icon for that user's tray, and communicates with the backend service as needed using any number of available IPC mechanisms (pipes, sockets, COM, RPC, WCF, etc).
Well, you can have a form in a service, but is has to run as Administrator and must be set up as an interactive service.
I've used SVCOM to create nice services with tray icons and a form that can minimize to system tray.
Have a look here: http://www.aldyn.ru/products/index.html
Hope this helps

‘Allow service to interact with desktop’ option not available when configuring windows service with an account other than local system

Why the option ‘Allow service to interact with desktop’ is only available for Local System account and not for any other account while configuring a windows service from control panel? I want to configure the windows service so as to allow interaction with desktop irrespective of the account it is configured to run with. How to achieve it?
that is a good question! I have never seen an official explanation from Microsoft, but I would guess that the reason has to do with permissions and rights and not wanting to mislead users.
Not all users are created equal. Some do not have the rights to display a user interface on session 0, or interact fully with arbitrary programs (and resources) it is running alongside. Having those users able to show GUI elements from a service may lead to confusion. For example, if a user account having limited rights starts an instance of Windows Explorer as a service, that window may not be able to accept dropped files from a "regular" explorer started by the interactive user. This sort of thing may be very difficult to diagnose and explain!
Note that Windows can certainly do what you like and we code it all the time in our service applications (http://www.CoreTechnologies.com/). Windows is simply not making that option available to you for any arbitrary user.
Of course please please take a step back and beware changes in Vista. "Session 0 Isolation" is a game changer for interactive Windows Services!

How to prevent from changing a Windows Service Startup Type?

I created a Windows service and installed into users machine.
That windows service is very important and I do not want to user can change its startup type to "disable".
It seems "Plug and Play" service can disable the Startup drop-down listbox.
How can I make same behavior for my windows service?
I would imagine it has to do with setting the appropriate permissions on the registry key. But a user with sufficient permissions can do anything. If this is for a business application, I would try to stick to using group policy or user permissions. If this is for a commercial application then I would expect a lot of upset users and malware detection.

Resources