Hi All,
We are developing a AV engine to monitor process creation. Software driver hooks to PsSetCreateProcessNotifyRoutineEx and informs the user-mode about process creation event, and then waits for the decision by user-mode service.
The current design is to create a data-structure which describes the process creation in a data structure (PID, image path, MD5, etc along with a event) and then insert in to a driver specific queue. Once inserted in the queue, process creation callback will block on the event created.
The user-mode service will continuously keep reading the pending items in the queue using an IOCTL.
The user-mode service will then run the decision engine, and sends back response to driver using a IOCTL. Once driver receives response inside another IOCTL handler, it will set the corresponding event in the queue item which will unblock callback routing.
Need your help in below considerations:
-
What should be the size of the driver queue? My understanding is that process creation/deletion is not serialized by Windows. Hence, we can have multiple process creation requests at the same time.
Idea is to create a LINKED LIST with fixed number of elements, and each LIST element will have a unique number, service-program final decision and an EVENT. But, this might result in LIST overflow if service program takes more time to provide decision. What is the best way to make the LINKED LIST dynamic. Is it a good idea to allocate LIST ITEM dynamically for each process create callback with ExAllocatePoolWithTag?? or follow some other method to make LIST truly dynamic. And also, thoughts on memory fragmentation and how to avoid?? -
Creating an event for each creation call, is it a good idea? I am worried about large number of events that we will have to create.
-
And need to handle the cases where user-mode service program dies because of a crash or manual sc stop. In that case, driver should not be blocked to create the processes.
Thanks for your help in advance,
Reddy