Visual studio 2012 使用VisualStudioWDK的最简单驱动程序
我正在尝试使用WDK在Visual Studio 2012中创建一个最简单的“hello world”驱动程序。 Device.c文件的代码如下:Visual studio 2012 使用VisualStudioWDK的最简单驱动程序,visual-studio-2012,driver,wdk,Visual Studio 2012,Driver,Wdk,我正在尝试使用WDK在Visual Studio 2012中创建一个最简单的“hello world”驱动程序。 Device.c文件的代码如下: #包括 构建时出现错误: 1>Driver.c(3): error C2220: warning treated as error - no 'object' file generated 1>Driver.c(3): warning C4100: 'RegistryPath' : unreferenced formal paramete
#包括
构建时出现错误:
1>Driver.c(3): error C2220: warning treated as error - no 'object' file generated
1>Driver.c(3): warning C4100: 'RegistryPath' : unreferenced formal parameter
1>Driver.c(3): warning C4100: 'DriverObject' : unreferenced formal parameter
2>------ Build started: Project: KMDFSmall Package, Configuration: Win7 Debug x64 ------
2>C:\Program Files (x86)\Windows Kits\8.0\build\WindowsDriver8.0.common.targets(1347,5): error MSB3030: Could not copy the file "Path\To\Projects\SimpleDriver\x64\Win7Debug\KMDFSmall.sys" because it was not found.
是什么导致这些错误?WDK已激活“将警告视为错误”,未使用的参数会触发警告
因此,如果您将代码更改为:
NTSTATUS DriverEntry(PDRIVER_OBJECT /*DriverObject*/, PUNICODE_STRING /*RegistryPath*/)
{
DbgPrint("Hello, World");
return STATUS_SUCCESS;
}
它应该编译。更推荐的方法是使用
未引用的\u参数()
宏,这样您的函数可以更改为:
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
UNREFERENCED_PARAMETER(DriverObject);
UNREFERENCED_PARAMETER(RegistryPath);
DbgPrint("Hello, World");
return STATUS_SUCCESS;
}
执行t的较短方法是在中使用:
#include <ntddk.h>
NTSTATUS DriverEntry(IN PDRIVER_OBJECT theDriverObject, IN PUNICODE_STRING theRegistryPath) {
DbgPrint("Hello World!\n");
return STATUS_SUCCESS;
}
#包括
NTSTATUS DriverEntry(在PDRIVER\u对象的DriverObject中,在注册表路径的PUNICODE\u字符串中){
DbgPrint(“你好,世界!\n”);
返回状态\成功;
}
来源:颠覆Windows内核:Greg Hoglund&James Butler的Rootkits你是对的,我只是将Treat warning as error设置为NO,没问题
#include <ntddk.h>
NTSTATUS DriverEntry(IN PDRIVER_OBJECT theDriverObject, IN PUNICODE_STRING theRegistryPath) {
DbgPrint("Hello World!\n");
return STATUS_SUCCESS;
}