首页
社区
课程
招聘
[已解决][求助]驱动编译出错,不知道是不是DDK出了问题没有
发表于: 2008-6-25 11:02 6504

[已解决][求助]驱动编译出错,不知道是不是DDK出了问题没有

2008-6-25 11:02
6504
一份很简单的代码,就是用Dbgprint输出一些信息。
代码写成这样可以编译通过
#include <ntddk.h>


NTKERNELAPI
NTSTATUS
PsLookupProcessByProcessId (
    IN PVOID        ProcessId,
    OUT PEPROCESS   *Process
);

NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{    
	DbgPrint("Drv Loading!\n");
	//NTSTATUS st;
	//PEPROCESS eprocess;
	//UNICODE_STRING spath;
	return STATUS_SUCCESS;
}

但是如果把NTSTATUS st这一行的注释符去掉,就会报错。
错误信息是这样的
c:\DDK\test\Test.c(18) : error C2275: 'NTSTATUS' : illegal use of this type as an expression
        c:\DDK\inc\wxp\ntdef.h(560) : see declaration of 'NTSTATUS'
c:\DDK\test\Test.c(18) : error C2146: syntax error : missing ';' before identifier 'st'
c:\DDK\test\Test.c(18) : error C2144: syntax error : '<Unknown>' should be preceded by '<Unknown>'
c:\DDK\test\Test.c(18) : error C2144: syntax error : '<Unknown>' should be preceded by '<Unknown>'
c:\DDK\test\Test.c(18) : error C2143: syntax error : missing ';' before 'identifier'
c:\DDK\test\Test.c(18) : error C2065: 'st' : undeclared identifier

如果把UNICODE_STRING spath;这一行的注释符也去掉的话,错误又变成了
c:\DDK\test\Test.c(17) : error C2275: 'UNICODE_STRING' : illegal use of this type as an expression
        c:\DDK\inc\wxp\ntdef.h(1095) : see declaration of 'UNICODE_STRING'
c:\DDK\test\Test.c(17) : error C2146: syntax error : missing ';' before identifier 'spath'
c:\DDK\test\Test.c(17) : error C2144: syntax error : '<Unknown>' should be preceded by '<Unknown>'
c:\DDK\test\Test.c(17) : error C2144: syntax error : '<Unknown>' should be preceded by '<Unknown>'
c:\DDK\test\Test.c(17) : error C2143: syntax error : missing ';' before 'identifier'
c:\DDK\test\Test.c(17) : error C2065: 'spath' : undeclared identifier

拜托各位帮忙帮忙,我都快要崩溃了......
谢谢!

[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法

收藏
免费 0
支持
分享
最新回复 (8)
雪    币: 224
活跃值: (16)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
2
定义放在最前面,不要放在执行语句的后面
2008-6-25 11:10
0
雪    币: 26
活跃值: (28)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
朋友,试试把“DbgPrint("Drv Loading!\n");”放到“return STATUS_SUCCESS;”这句前面~
2008-6-25 11:13
0
雪    币: 266
活跃值: (50)
能力值: ( LV9,RANK:290 )
在线值:
发帖
回帖
粉丝
4
不要把NTSTATUS st放在dbgprint的后面,变量声明放在最前面
2008-6-25 11:14
0
雪    币: 709
活跃值: (2420)
能力值: ( LV12,RANK:1010 )
在线值:
发帖
回帖
粉丝
5
[已解决]

.
2008-6-25 11:20
0
雪    币: 454
活跃值: (1673)
能力值: ( LV3,RANK:30 )
在线值:
发帖
回帖
粉丝
6
.c代码是按照C语言来编译的,C语言里定义局部变量只能写在函数的最开始
.cpp才是按照C++来编译
用.cpp时记得加
extern "C" NTSTATUS DriverEntry(...)
2008-6-25 12:09
0
雪    币: 287
活跃值: (102)
能力值: ( LV8,RANK:130 )
在线值:
发帖
回帖
粉丝
7
UnLoad都不写
强大
2008-6-25 13:17
0
雪    币: 437
活跃值: (273)
能力值: ( LV12,RANK:240 )
在线值:
发帖
回帖
粉丝
8
变量声明放在DbgPrint函数前即可  如果用VC++配制的驱动环境编译倒能通过
2008-6-25 13:38
0
雪    币: 206
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
9
谢谢各位的指点,问题已经解决了。谢谢谢谢!
2008-6-27 14:56
0
游客
登录 | 注册 方可回帖
返回
//