So I have been trying to create something like discord game activity: When you open an app, discord displays it as the game you are currently playing. Now I don't want to query all open applications every second, so I was wondering whether there were alternatives like a callback when an application starts(I don't own the program, so I can not modify it). At first, I would like it to work on windows, but if you have solutions for other platforms I won't mind. I'm also using electron.js
CodePudding user response:
You will get a loads more callbacks than you might expect from anything in win32 land that notifies you that a process has started. There used to be such an api a long way back [http://www.rohitab.com/discuss/topic/40418-process-notification-on-81/?p=10093378] . So... The only way I suspect you can do it now is through DDL hooking - which as far I recall requires admin privilege to install the hook. It's pretty low level thing to want to do here, so you will need to be writing some IPC code to talk between your hook and your Electron app. Probably a decent place that lays out your options is here https://www.apriorit.com/dev-blog/679-windows-dll-injection-for-api-hooks Note: Most AV will want to flag your app as malicious depending on which route you do follow.