阅读:1546回复:4
编写HELLOWORLD遇到困难了
D:\xx\wl>build
BUILD: Object root set to: ==> objchk BUILD: Adding /Y to COPYCMD so xcopy ops won't hang. BUILD: /i switch ignored BUILD: Compile and Link for i386 BUILD: Loading F:\WINDDK\2600\build.dat... BUILD: Computing Include file dependencies: BUILD: Examining d:\xx\wl directory for files to compile. d:\xx\wl - 1 source files (0 lines) BUILD: Compiling d:\xx\wl directory BUILD: nmake.exe failed - rc = 2 BUILD: Linking d:\xx\wl directory BUILD: nmake.exe failed - rc = 2 BUILD: Done 我源代码是按照网上提供的“驱动版HELLOWORLD”写入的。 但是在用DDK编译的时候才怎么也生成不了.sys文件。 望高手指点下啊 !小弟在此谢过了~~~~~~~ |
|
沙发#
发布于:2007-11-13 22:37
makefile和sources文件是没有后缀的,我的不能生成.sys文件就是这个原因,不知道你的是不是.
|
|
板凳#
发布于:2007-11-19 09:11
我的是能正常生成的``不知道怎么给你```
我就发到这里吧 #ifndef __HELLOWORLD_C__ #define __HELLOWORLD_C__ #define DEBUGMSG #include "HelloWorld.h" //驱动入口 NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING RegistryPath) { NTSTATUS ntStatus=STATUS_SUCCESS; //状态代码(类型为有符号长整型) PDEVICE_OBJECT IpDeviceObject=NULL;//指向设备对象的指针 UNICODE_STRING DeviceNameString; //设备名称 UNICODE_STRING DeviceLinkString; //符号连接 //调试信息 #ifdef DEBUGMSG DbgPrint("hi, Starting DriverEntry()\n"); #endif RtlInitUnicodeString(&DeviceNameString,NT_DEVICE_NAME);//初始化Unicode字符串 //创建设备 ntStatus=IoCreateDevice(DriverObject,0,&DeviceNameString,FILE_DEVICE_UNKNOWN,0,FALSE,&IpDeviceObject); //使用NT_SUCCESS宏检测函数调用是否成功 if(!NT_SUCCESS(ntStatus)) { #ifdef DEBUGMSG DbgPrint("hi, Error IoCreateDevice()\n"); #endif goto Error; } RtlInitUnicodeString(&DeviceLinkString,DOS_DEVICE_NAME);//初始化Unicode字符串 //创建符号连接 ntStatus=IoCreateSymbolicLink(&DeviceLinkString,&DeviceNameString); //使用NT_SUCCESS宏检测函数调用是否成功 if(!NT_SUCCESS(ntStatus)) { #ifdef DEBUGMSG DbgPrint("hi, Error IoCreateSymbolicLink()\n"); #endif goto Error; } //设置IRP派遣例程和卸载例程 DriverObject->MajorFunction[IRP_MJ_CREATE]=HelloWorldDispatch; DriverObject->MajorFunction[IRP_MJ_CLOSE]=HelloWorldDispatch; DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL]=HelloWorldDispatch; DriverObject->DriverUnload=HelloWorldUnload; return ntStatus; Error: #ifdef DEBUGMSG DbgPrint("hi, Error DriverEntry()\n"); #endif return ntStatus; } NTSTATUS HelloWorldDispatch(IN PDEVICE_OBJECT DeviceObject,IN PIRP pIrp) { NTSTATUS ntStatus=STATUS_SUCCESS; ULONG IoControlCodes=0; //I/O控制代码 PIO_STACK_LOCATION IrpStack=NULL; //IRP堆栈 pIrp->IoStatus.Status=STATUS_SUCCESS; pIrp->IoStatus.Information=0; //设置IRP状态 #ifdef DEBUGMSG DbgPrint("hi, Starting HelloWorldDispatch()\n"); #endif //得到当前调用者的IRP IrpStack=IoGetCurrentIrpStackLocation(pIrp); switch(IrpStack->MajorFunction) { case IRP_MJ_CREATE: #ifdef DEBUGMSG DbgPrint("hi, IRP_MJ_CREATE\n"); #endif break; case IRP_MJ_CLOSE: #ifdef DEBUGMSG DbgPrint("hi, IRP_MJ_CLOSE\n"); #endif break; case IRP_MJ_DEVICE_CONTROL: #ifdef DEBUGMSG DbgPrint("hi, IRP_MJ_DEVICE_CONTROL\n"); #endif //取得I/O控制代码 IoControlCodes=IrpStack->Parameters.DeviceIoControl.IoControlCode; switch(IoControlCodes) { //启动 case START_HELLOWORLD: DbgPrint("hi, Starting \"Hello World \"\n"); break; //停止 case STOP_HELLOWORLD: DbgPrint("hi, Stoping \"Hello World \"\n"); break; default: pIrp->IoStatus.Status=STATUS_INVALID_PARAMETER; break; } break; default: break; } ntStatus=pIrp->IoStatus.Status; IoCompleteRequest(pIrp,IO_NO_INCREMENT); return ntStatus; } VOID HelloWorldUnload(IN PDRIVER_OBJECT DriverObject) { UNICODE_STRING DeviceLinkString; PDEVICE_OBJECT DeviceObjectTemp1=NULL; PDEVICE_OBJECT DeviceObjectTemp2=NULL; #ifdef DEBUGMSG DbgPrint("hi,Starting HelloWorldUnload()\n"); #endif RtlInitUnicodeString(&DeviceLinkString,DOS_DEVICE_NAME); IoDeleteSymbolicLink(&DeviceLinkString);//删除符号连接 if(DriverObject) { DeviceObjectTemp1=DriverObject->DeviceObject; //删除设备 while(DeviceObjectTemp1) { DeviceObjectTemp2=DeviceObjectTemp1; DeviceObjectTemp1=DeviceObjectTemp1->NextDevice; IoDeleteDevice(DeviceObjectTemp2); } } } #endif |
|
地板#
发布于:2007-11-19 09:12
TARGETNAME=HelloWorld #驱动名称
TARGETPATH=. #编译后SYS的路径 TARGETTYPE=DRIVER #类型为驱动程序 SOURCES=HelloWorld.c #只有一个源文件 希望对你有帮助 |
|
地下室#
发布于:2007-11-22 21:30
http://bbs.driverdevelop.com/htm_data/11/0709/105823.html
这个里面的helloworld可以 |
|