从头开始了解和使用Hypervisor(第1部分)

来源:岁月联盟 编辑:猪蛋儿 时间:2020-01-29
#pragma alloc_text(INIT, DriverEntry)
#pragma alloc_text(PAGE, DrvUnload)
#pragma alloc_text(PAGE, DrvCreate)
#pragma alloc_text(PAGE, DrvRead)
#pragma alloc_text(PAGE, DrvWrite)
#pragma alloc_text(PAGE, DrvClose)
#pragma alloc_text(PAGE, DrvUnsupported)
#pragma alloc_text(PAGE, DrvIOCTLDispatcher)
// IOCTL Codes and Its meanings
#define IOCTL_TEST 0x1 // In case of testing
现在,只需编译驱动程序即可。
加载驱动程序并检查设备是否存在
为了加载我们的驱动程序(MyHypervisorDriver),首先下载OSR驱动程序加载程序,然后以管理员身份运行Sysinternals DbgView,确保你的DbgView捕获了内核(你可以通过Capture-> Capture Kernel进行检查)。

之后,打开OSR Driver Loader(转到OsrLoader-> kit-> WNET-> AMD64-> FRE)并打开OSRLOADER.exe(在x64环境中)。现在,如果你构建了驱动程序,则在OSR驱动程序加载程序中找到.sys文件(在MyHypervisorDriver/x64/Debug/ 应该是一个名为“MyHypervisorDriver.sys”的文件),单击浏览并选择MyHypervisorDriver.sys,然后点击“登记服务”后,消息框显示你的驱动注册成功,此时点击“启动服务”即可。
请注意,你应该为Visual Studio安装WDK,以便能够构建未来的项目。

现在返回DbgView,你应该能够看到驱动程序已成功加载,并显示一条“[*] DriverEntry Called. ”消息。
如果没有问题,那就很好了;否则,如果DbgView有问题,还要进一步检查。
请记住,现在你已经注册了驱动程序,因此可以使用SysInternals WinObj来查看“ MyHypervisorDevice”是否可用。

上一页  [1] [2] [3] [4] [5] [6]