Implementing Global Injection and Hooking in Windows
m417z.com
m417z.com
https://bugs.chromium.org/p/chromium/issues/detail?id=851565...
The flag we (still) can't enable by default is
--enable-features=BrowserDynamicCodeDisabled
For this reason I highly doubt wayland will really work as intended. We're going to end up with a middle shim layer that basically acts as X11 but doesn't look like it.
They are being used in well known security companies and intelligence organizations.
Baby's first keyloggers.
My preferred method was manipulating IAT table (Import Address Table) where the code injected into process is hooking CreateProcess and LoadLibrary (and similar) to further propagate injection into other processes/library spawned by current process(es) and using debug privileges to also inject into system processes (like login process on windows 2000, to survive logoff)
Anyway Microsoft Detours is the way to go, they actually modify the code of hooked function using trampolines, I don't think anything can be more efficient than that.
That said, MS have unintentionally (I think) done a pretty good job of scrubbing the internet clean of useful information about it by breaking all their links multiple times. I keep a personal copy of some things, such as Matt Pietrek's classic two-parter "An In-Depth Look into the Win32 Portable Executable File Format", lest they disappear completely while the technologies they describe continue to run the world.
Edit: MS only appear to have part 2 of that article in their archive, and it contains broken links (of course). Both parts can still be read at [1] and [2] and remain as relevant as they were the day they were written
[1] https://bytepointer.com/resources/pietrek_in_depth_look_into...
[2] https://bytepointer.com/resources/pietrek_in_depth_look_into...
Non elevated process can't inject into elevated process. X user process can't inject into Y user process.
If user has access to process, they have very well access to modify by decompiling or reverse engineering it. Dynamic injection makes it much more seamless and less painful.
https://docs.microsoft.com/en-us/windows/win32/winstation/wi...
https://docs.microsoft.com/en-us/windows/win32/winstation/de...
https://docs.microsoft.com/en-us/windows/win32/procthread/pr...
https://docs.microsoft.com/en-us/windows/win32/procthread/th...
https://docs.microsoft.com/en-us/windows/win32/fileio/file-s...
Here https://news.ycombinator.com/item?id=31092978 suggests its not possible to prevent code injection aka system or app hooks. Preventing system and app hooks is very possible and the MS api's gve you all you need to block them, people just need to come up with innovative ways to deploy them!
A truly fast and documented solution is using PssCaptureSnapshot, it can enumerate only threads of the target process. It uses NtGetNextThread under the hood. The downside: it's only available from Windows 8.1.
Using NtGetNextThread is not only fast and available from Windows Vista, it also allows avoiding race conditions - what happens if a new thread is created after the snapshot is created? A snapshot returns thread ids, what happens if one of the threads is destroyed? What happens if the thread id is reused (unlikely but possible)? I believe all the benefits I'm getting by using NtGetNextThread are worth using an undocumented function.
See also the research that I linked in the blog post: https://github.com/diversenok/Suspending-Techniques#snapshot...