What I would like to know if it is possible to write a hypervisor program (not malicious) which runs before the OS and executes kernel and user mode application code inside a virtual environment ? I would like to find out if its possible to evaluate/analyze code while it is executing in real time ? Need to be able to perform some kind of analysis in real time while the code (kernel mode code including the OS or user mode code) is executing in a hypervisor environment or in a sandbox or in some sort of virtual type environment.
Hello,
the answer, in theory, is yes. Your question is quite broad, so I don't seem to understand what exactly you wish to accomplish.
You can find source code of several hypervisors, such as SimpleVisor or HyperPlatform, on Github. For example, SimpleVisor works as a kernel driver that, when loaded, places the currently running operating system into a hypervisor that can control things like access to MSRs, system calls and other events that cause a VM exit.