2012-10-19 3 views
2

WDK가있는 Visual Studio 2012에서 가장 간단한 "hello world"드라이버를 만들려고합니다. Device.c 파일의 코드는 이것이다 :Visual Studio wdk로 가장 간단한 드라이버

#include <ntddk.h>

NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) 
{ 
    DbgPrint("Hello, World"); 

    return STATUS_SUCCESS; 
} 

오류가의 구축 :

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. 

무엇 이러한 오류의 원인은?

답변

5

WDK에 "경고 경고로 처리"가 활성화되어 있으며 사용되지 않은 매개 변수로 인해 경고가 표시됩니다. 당신이 코드를 변경하는 경우

그래서 :

NTSTATUS DriverEntry(PDRIVER_OBJECT /*DriverObject*/, PUNICODE_STRING /*RegistryPath*/) 
{ 
    DbgPrint("Hello, World"); 

    return STATUS_SUCCESS; 
} 

는 컴파일해야한다.

+0

당신이 옳아 요, 나는 단지 경고를 오류로 처리하도록 설정 했으므로 괜찮습니다. – Sergey

7

더 권장되는 방법은 UNREFERENCED_PARAMETER() 매크로를 사용하고, 그래서 당신의 기능을 변경할 수 있습니다 t을 할 수

NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) 
{ 
    UNREFERENCED_PARAMETER(DriverObject); 
    UNREFERENCED_PARAMETER(RegistryPath); 

    DbgPrint("Hello, World"); 

    return STATUS_SUCCESS; 
} 
1

더 짧은 방법으로 사용하는 것입니다 :

#include <ntddk.h> 

NTSTATUS DriverEntry(IN PDRIVER_OBJECT theDriverObject, IN PUNICODE_STRING theRegistryPath) { 
    DbgPrint("Hello World!\n"); 
    return STATUS_SUCCESS; 
} 

출처 : 윈도우 전복은 커널 : Greg Hoglund의 루트킷 & 제임스 버틀러