Hi,
I am part of a new start-up in a security domain, my goal is to protect specific processes ( generally speaking all processes ) by changing the process memory snapshot in a specific way ( i can’t reveal how the snapshot will be changed, sorry).
I have two main issues, i need (1) catch the process after it is created and loaded but before it runs -> all modules should be already loaded. (2) executing my code which should change the process memory snapshot before it starts to run.
My General idea was :
(1) Kernel driver that tracks pscreateprocess routine, sees that this is one of my goal processes, register the handle in my homemade list, tracking psloadimage routine only for the relevant process handles.
(2) when psloadimage sees ntdll , i find the address of LdrLoadDll ( i actually can use kernel32 and find the address of loadlibraryEx function which is documented ),
(3) i register APC that instructs the main thread to inject my dll when the thread will return to user mode.
(4) in user mode, my dll will be injected by APC and my dllmain function will be executed -> there i do the magic.
Questions:
I read a lot about different techniques of injecting Dll’s , including from kernel mode, even in this forum i read critics about APC ( since it is undocumented )
There is additional option of hooking the crss but this is also undocumented.
I am familiar with users32 registry option but i need to support also processes that do not use user32.
Additionally i am forbidden to change the PE or the dll files statically ( everything must be in runtime).
Additionally i am not sure that dll injection is the best way to do it, what are the alternatives?
Generally speaking, i really want to create a generic framework which uses documented api, works for both 64 bit and 32 bit Windows, this framework will allow me to gradually develop more and more components that will work with the process memory snapshot.
CAN YOU RECOMMEND ON THE BEST DESIGN ?