阅读:939回复:9
驱动程序中使用字串
我仿照ddk得源码使用WCHAR,结果编译通不过的说!why?
|
|
沙发#
发布于:2003-07-23 15:56
是不是设置的问题?
可不可以出错信息贴上来看一下。 |
|
|
板凳#
发布于:2003-07-23 16:07
源代码:WCHAR AA[20];
报错: Compiling e:\\alexkbf directory ******************** \'nmake.exe /c BUILDMSG=Stop. -i NTTEST= UMTEST= NOLINK=1 386=1\' cl -nologo -Ii386\\ -I. -Id:\\NTDDK\\inc -Id:\\NTDDK\\inc -Id:\\NTDDK\\inc\\ddk -Id:\\NTDDK\\inc\\ddk\\wdm -Id:\\NTDDK\\private\\inc -Id:\\NTDDK\\inc -D_X86_=1 -Di386=1 -DSTD_CALL -DCONDITION_HANDLING=1 -DNT_UP=1 -DNT_INST=0 -DWIN32=100 -D_NT1X_=100 -DWINNT=1 -D_WIN32_WINNT=0x0500 -DWINVER=0x0500 -D_WIN32_IE=0x0501 -DWIN32_LEAN_AND_MEAN=1 -DDBG=1 -DDEVL=1 -DFPO=0 -DNDEBUG -D_DLL=1 /c /Zel /Zp8 /Gy -cbstring -W3 -WX /Gz /QIfdiv- /QIf /QI0f /GB /Gi- /Gm- /GX- /GR- /GF -Z7 /Oxs /Oy- -FId:\\NTDDK\\inc\\warning.h .\\alexflr.c alexflr.c e:\\alexkbf\\alexflr.c(64) : error C2143: syntax error : missing \';\' before \'type\' Stop. Compile errors: not linking e:\\alexkbf directory ******************** 请打侠指点 :P |
|
地板#
发布于:2003-07-23 16:39
也许少include了一个头文件?
|
|
地下室#
发布于:2003-07-23 21:37
是哪一行?copy出来看看。
肯定不是少include文件 |
|
5楼#
发布于:2003-07-24 10:37
注意看头像包含的行
#include \"alexflr.h\" #ifdef ALLOC_PRAGMA #pragma alloc_text(INIT,DriverEntry) #pragma alloc_text(PAGE,kbfPassThrough) #pragma alloc_text(PAGE,kbfUnload) #pragma alloc_text(PAGE,kbfAddDevice) #endif NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath) { int i; DriverObject->DriverUnload = kbfUnload; DriverObject->DriverExtension->AddDevice = kbfAddDevice; DriverObject->DriverStartIo = kbfStartIo; for (i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++) { DriverObject->MajorFunction = kbfPassThrough; } /* DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = kbfShutdown; DriverObject->MajorFunction[IRP_MJ_CREATE] = kbfCreate; DriverObject->MajorFunction[IRP_MJ_CLOSE] = kbfClose; DriverObject->MajorFunction[IRP_MJ_READ] = kbfRead; DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = kbfFlushBuffers; DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = kbfDeviceControl; DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = kbfIntDevCtrl DriverObject->MajorFunction[IRP_MJ_CLEANUP] = kbfCleanup; DriverObject->MajorFunction[IRP_MJ_PNP] = kbfPnp; DriverObject->MajorFunction[IRP_MJ_POWER] = kbfPower; DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = kbfSystemControl; */ return STATUS_SUCCESS; } NTSTATUS kbfPassThrough(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { PIO_STACK_LOCATION irpStack = IoGetCurrentIrpStackLocation(Irp); IoSkipCurrentIrpStackLocation(Irp); return IoCallDriver(((PDEVICE_EXTENSION) DeviceObject->DeviceExtension)->TopOfStack, Irp); } VOID kbfUnload( IN PDRIVER_OBJECT Driver) { PAGED_CODE(); UNREFERENCED_PARAMETER(Driver); ASSERT(NULL == Driver->DeviceObject); } NTSTATUS kbfAddDevice(IN PDRIVER_OBJECT Driver, IN PDEVICE_OBJECT PDO) { PDEVICE_EXTENSION devExt; PDEVICE_OBJECT device; NTSTATUS status = STATUS_SUCCESS; UNICODE_STRING ustrDeviceName; const GUID ClassGuid = DEV_CLASS_GUID; :(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:( WCHAR AA[20]; :(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:( PAGED_CODE(); RtlInitUnicodeString(&ustrDeviceName, DEV_NAME); status = IoCreateDevice(Driver, sizeof(DEVICE_EXTENSION), &ustrDeviceName, FILE_DEVICE_KEYBOARD, 0, FALSE, &device); if (!NT_SUCCESS(status)) goto KBFADDDEVICE_EXIT; RtlZeroMemory(device->DeviceExtension, sizeof(DEVICE_EXTENSION)); devExt = (PDEVICE_EXTENSION) device->DeviceExtension; devExt->ustrDeviceName->Length = 0; devExt->ustrDeviceName->MaximumLength = 80; devExt->ustrDeviceName->Buffer = (PWSTR)ExAllocatePool(NonPagedPool,100); if(NULL != devExt->ustrDeviceName->Buffer) RtlCopyUnicodeString(devExt->ustrDeviceName, &ustrDeviceName); devExt->TopOfStack = IoAttachDeviceToDeviceStack(device, PDO); ASSERT(devExt->TopOfStack); devExt->Self = device; devExt->PDO = PDO; device->Flags |= (DO_BUFFERED_IO | DO_POWER_PAGABLE); device->Flags &= ~DO_DEVICE_INITIALIZING; status = IoRegisterDeviceInterface(PDO, &ClassGuid, NULL, devExt->ustrLinkName); if (!NT_SUCCESS(status)) goto KBFADDDEVICE_EXIT; KBFADDDEVICE_EXIT: RtlFreeUnicodeString(&ustrDeviceName); if(!NT_SUCCESS(status)) { RtlFreeUnicodeString(devExt->ustrDeviceName); RtlFreeUnicodeString(devExt->ustrLinkName); IoDetachDevice(devExt->TopOfStack); IoDeleteDevice(devExt->Self); } return status; } |
|
6楼#
发布于:2003-07-24 13:08
是不是DEV_CLASS_GUID有点问题?检查一下?
把WCHAR AA[20]挪到前面看看。 |
|
7楼#
发布于:2003-07-24 13:12
哇赛,真想吻你一下哎!
|
|
8楼#
发布于:2003-07-24 13:19
哇赛,真想吻你一下哎! 问题解决了,就说出来嘛。。。 吻。。。就不要了吧?怕怕 |
|
9楼#
发布于:2003-07-24 13:43
呵呵,来晚了。
出这种错时,一般都是上一句出了问题。 |
|
|