阅读:3965回复:5
这些错误是什么意思啊,前辈们来指点一下啊,谢谢
一段很简单的程序:
extern "C" { # include <NTDDK.h> } extern "C" NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING RegstryPath) { UNICODE_STRING namestring; NTSTSTUS status; PDEVICE_OBJECT fcdo; RtlInitUcicodeString(&namestring,L"\\FileSystem\\Filters\\SFilter"); status=IoCreateDevice( DriverObject, 0, &namestring, FILE_DEVICE_DISK_FILE_SYSTEM, FILE_DEVICE_SECURE_OPEN, 0, &fcdo); if(status==STATUS_OBJECT_PATH_NOT_FOUND) { RtlUnicodeString(&namestring,L"\\FileSystem\\SFilterCDO"); status=IoCreateDevice( DriverObject, 0, &namestring, FILE_DEVICE_DISK_FILE_SYSTEM, FILE_DEVICE_SECURE_OPEN, 0, &fcdo); } if(!NT_SUCCESS(status)) { KdPrint(( "SFilter!DriverEntry: Error creating control device object \"%wZ\", status=%08x\n", &nameString, status )); } else if(!NT_SUCCESS(status)) { KdPrint(( "SFilter!DriverEntry: Error creating control device object \"%wZ\", status=%08x\n", &nameString, status )); } return status; } 编译时出些这些错误,不知道错在那: 1>cpp1.cpp(9) : error C2065: 'NTSTSTUS' : undeclared identifier 1>cpp1.cpp(9) : error C2146: syntax error : missing ';' before identifier 'status' 1>cpp1.cpp(9) : error C2065: 'status' : undeclared identifier 1>cpp1.cpp(11) : error C2065: 'RtlInitUcicodeString' : undeclared identifier 1>cpp1.cpp(22) : error C2065: 'RtlUnicodeString' : undeclared identifier 1>cpp1.cpp(30) : error C2001: newline in constant 1>cpp1.cpp(31) : error C2001: newline in constant 1>cpp1.cpp(35) : error C2001: newline in constant 1>cpp1.cpp(36) : error C2001: newline in constant 1>cpp1.cpp(30) : error C1057: unexpected end of file in macro expansion |
|
沙发#
发布于:2008-08-07 10:54
1>cpp1.cpp(9) : error C2065: 'NTSTSTUS' : undeclared identifier
A: NTSTSTUS -> NTSTATUS 拼写错误 1>cpp1.cpp(9) : error C2146: syntax error : missing ';' before identifier 'status' 和前一个错误一起的。。。 1>cpp1.cpp(9) : error C2065: 'status' : undeclared identifier 和前一个错误一起的。。。 1>cpp1.cpp(11) : error C2065: 'RtlInitUcicodeString' : undeclared identifier 拼写错误:RtlInitUcicodeString -> RtlInitUnicodeString 并检查是否缺少头文件:winternl.h 1>cpp1.cpp(22) : error C2065: 'RtlUnicodeString' : undeclared identifier 疑似:应该为RtlInitUnicodeString 1>cpp1.cpp(30) : error C2001: newline in constant 1>cpp1.cpp(31) : error C2001: newline in constant 1>cpp1.cpp(35) : error C2001: newline in constant 1>cpp1.cpp(36) : error C2001: newline in constant 1>cpp1.cpp(30) : error C1057: unexpected end of file in macro expansion 以上这堆错误都是由于KdPrint的括号使用错误引起的: =%08x\n" -> =%08x\n") &nameString, status )) -> &nameString, status ) 写程序既需要技巧,也要心细啊。。。 |
|
|
板凳#
发布于:2008-08-08 08:32
批评得是,以后好好改正!
|
|
地板#
发布于:2009-04-09 16:48
LZ你一定要用C++写驱动吗?
|
|
地下室#
发布于:2009-05-01 11:23
extern "C" 也可以是说在.cpp文件里啊,不是用c++写代码,楼上小弟弟
|
|
|
5楼#
发布于:2009-07-08 06:43
兄弟有很多原因的!!最好把代码上传一份!!
VC默认C++ extern "C" 说明是以C方式编译!! 自己看看基础!! |
|