阅读:1525回复:2
关于.h和.cpp的调试问题?图片:1.jpg 我看驱动开发技术详解的书,跟着里面第一个例子做,错误如上 好像.cpp文件里面哪里写错了,但是在VC里面好像没驱动的类库,编译会出现一些错误,无法调试,怎么办?谢谢! Driver.h #pragma once ifdef _cplusplus extern "C" { #endif #include <NTDDK.h> #ifdef _cplusplus } #endif #define PAGEDCODE code_seg("PAGE") #define LOCKEDCODE code_seg() #define INITCODE code_seg("INIT") #define PAGEDDATA daa_seg("PAGE") #define LOCKEDDATA data_seg() #define INITDATA data_seg("INIT") #define arraysize(p) (sizeof(p)/sizeof((p)[0])) typedef struct _DEVICE_EXTENSION{ PDEVICE_OBJECT pDevice; UNICODE_STRING ustrDeviceName; UNICODE_STRING ustrSymLinkName; }DEVICE_EXTENSION,*PDEVICE_EXTENSION; NTSTATUS CreateDevice(IN PDRIVER_OBJECT pDriverObject); VOID HelloDDKUnload(IN PDRIVER_OBJECT pDriverObject); NTSTATUS HelloDDKDispatchRoutine(IN PDEVICE_OBJECT pDevObj,IN PIRP pIrp); Driver.c #include "Driver.h" #pragma INITCODE extern "C" NTSTATUS DriverEntry(IN PDRIVER_OBJECT pDriverObject,IN PUNICODE_STRING pRegistryPath) { NTSTATUS status; KdPrint(("Enter DriverEntry\n")); pDriverObject->DriverUnload=HelloDDKUnload; pDriverObject->MajorFunction[IRP_MJ_CREATE]=HelloDDKDispatchRoutine; pDriverObject->MajorFunction[IRP_MJ_CLOSE]=HelloDDKDispatchRoutine; pDriverObject->MajorFunction[IRP_MJ_WRITE]=HelloDDKDispatchRoutine; pDriverObject->MajorFunction[IRP_MJ_READ]=HelloDDKDispatchRoutine; status=CreateDevice(pDriverObject); KbPrint(("DriverEntry end\n")); return status; } #pragma INITCODE NTSTATUS CreatDevice(IN PDEVICE_OBJECT pDriverObject) { NTSTATUS status; PDEVICE_OBJECT pDevObj; PDEVICE_EXTENSION pDevExt; UNICODE_STRING devName; RtkInitUnicodeString(&devName,L"\\Device\\MyDDKDevice"); status=IoCreateDevice(pDriverObject,sizeof(DEVICE_EXTENSION),&(UNICODE_STRING)devName,FILE_DEVICE_UNKNOWN,0,TRUE,&pDevObj); if (!NT_SUCCESS(status)) return status; pDevObj->Flags|=DO_BUFFERED_IO; pDevExt=(PDEVICE_EXTENSION)pDevObj->DeviceExtension; pDevExt->pDevice=pDevObj; pDevExt->ustrDeviceName=devName; UNICODE_STRING symLinkName; RtlInitUnicodeString(&symLinkName,L"\\??\\HelloDDK"); pDevExt->ustrSymLinkName=symLinkName; status=IoCreateSymbolicLink(&symLinkName,&devName); if(!NT_SUCCESS(status)) { IoDeleteDevice(pDevObj); return status; } return STATUS_SUCCESS; } #pragma PAGEDCODE NTSTATUS HelloDDKUnload(IN PDRIVER_OBJECT pDriverObject) { PDEVICE_OBJECT pNextObj; KbPrint(("Enter DriverUnload\n")); pNextObj=pDriverObject->DeviceObject; while (pNextObj!=NULL) { PDEVICE_EXTENSION pDevExt=(PDEVICE_EXTENSION) pNextObj->DeviceExtension; UNICODE_STRING pLinkName=pDevExt->ustrSymLingName; IoDeleteSymbolicLink(&pLinkName); pNextObj=pNextObj->NextDevice; IoDeleteDevice(pDevExt->pDevice); } } #pragma PAGEDCODE NTSTATUS HelloDDKDispatchRoutine(IN PDEVICE_OBJECT pDevObj,IN PIRP pIrp) { KbPrint(("Enter HelloDDKDispatchRoutine\n")); NTSTATUS status=STATUS_SUCCESS; pIrp->IoStatus.Status=status; pIrp->IoStatus.Information=0; IoCompleteRequest(pIrp,IO_NO_INCREMENT); KdPrint(("Leave HelloDDKDispatchRoutine\n")); return status; } |
|
沙发#
发布于:2009-11-09 17:20
你的sources这个文件里,没有对targetpath赋值
|
|
板凳#
发布于:2009-11-09 17:22
你的sources文件里targetpath没有赋值
|
|