本帖最后由 温馨小屋 于 2013-7-26 21:17 编辑
我声明了一个UNICODE_STRING变量,就报c2065,但是上面那个UNICODE_STRING变量就没报,而且这样的问题时有时无,困扰多日,求解决。
代码:
#include <ntddk.h>
//#include <wdm.h>
#include "dev.h"
VOID DriverUnload(PDRIVER_OBJECT driver)
{
DbgPrint("aaaaaaaaaaaa");
}
NTSTATUS CreateDevice(PDRIVER_OBJECT drv)
{
NTSTATUS status;
PDEVICE_OBJECT pDevObj;
PDEVICE_EXTENSION pDevEx;
UNICODE_STRING devname;//?没事
RtlInitUnicodeString(&devname,L"\\Device\\mydev");
status = IoCreateDevice(drv,sizeof(pDevEx),&devname,FILE_DEVICE_UNKNOWN,0,0,&pDevObj);//创建设备
if (!NT_SUCCESS(status))
return status;
pDevObj->Flags=DO_BUFFERED_IO;//设置设备为缓冲区
DbgPrint("succeed");
pDevEx=(PDEVICE_EXTENSION)pDevObj->DeviceExtension;//得到设备扩展!!!!!!!!!!1
pDevEx->ustrDeviceName=devname;
UNICODE_STRING link;//error 2065 "link":未声明的标识符?
RtlInitUnicodeString(&link,L"\\??\\HELDEV");
pDevEx->ustrSymLinkName=link;
status=IoCreateSymbolicLink(&link,&devname);//链接名,设备名
if (!NT_SUCCESS(status))
{
DbgPrint("error");
return status;
}
return STATUS_SUCCESS;
}
VOID exe(PDRIVER_OBJECT driver,PUNICODE_STRING reg)
{
NTSTATUS status;
status=CreateDevice(driver);
if (!NT_SUCCESS(status))
DbgPrint("error");
}
NTSTATUS DriverEntry(PDRIVER_OBJECT driver,PUNICODE_STRING reg)
{
DbgPrint("%ws\n",driver->DriverName);
DbgPrint("aassss");
DbgPrint("%ws\n",reg->Buffer);
DbgPrint("lllllll");
driver->DriverUnload=DriverUnload;
/*UNICODE_STRING devname;
RtlInitUnicodeString(&devname,L"\\Device\\mydev");
PDEVICE_OBJECT dev;
PDEVOBJ_EXTENSION pdevext;
NTSTATUS sata=IoCreateDevice(driver,sizeof(pdevext),&devname,FILE_DEVICE_UNKNOWN,0,0,&dev);*/
//NTSTATUS status;
exe(driver,reg);
return STATUS_SUCCESS;
}
|