I want to hook certain API calls, e.g. CreateFile (or NtCreateFile if I hook ntdll.dll), but there are some issues.
I can use several methods to achieve this goal, e.g. DLL injection, Inline hooking etc. But I think the most pragmatic way would be to use Microsoft Detours, as it handles some functions, e.g. trampolines, for me. However, the issue is that I don't know which processes I want to hook beforehand, so my custom DLL should be loaded into the virtual address space of the process, when the path of the DLL is set to Kernel32.dll or when it specifically calls for the functions CreateFile, ReadFile etc.
However, since this is in the context of ransomware detection, I don't know which processes will invoke these API calls.. so actually I want to have a system-wide hook. I read articles etc. about this topic, and one of the approaches is to change the registry entries, but then it will only work for proceses that use user32.dll, have a GUI etc.
Can I anyone advise me on this case? Thank you in advance.
EDIT: I did some additional research. I think inline hooking makes the most sense. But unfortunately I can't use Detours for that, as this paper states (page 7), which I find a little bit strange because I would think that inline hooking is by definition system-wide (as each process that wants to use the function CreateFile from Kernel32.dll invokes the real DLL).