阅读:979回复:0
ds共享内存问题
我想在驱动中分配10k的内存然后映射到应用程序,可是不知为什么得到的数据却不对,而在驱动中看到数据是对的,不明白怎么回事?
我的应用程序映射部分如下所示: if (!DeviceIoControl(hDevice,P9054_IOCTL_801, bufInput, IOCTL_INBUF_SIZE, &DataBuf, sizeof(DataBuf), &nOutput, NULL) ) { printf("ERROR: DeviceIoControl returns %0x.", GetLastError()); Exit(1); } if((fp=fopen("data","a+"))==NULL) { printf("file not open"); Exit(1); } iNum=fwrite(&DataBuf,4,1024,fp); fclose(fp); 驱动部分如下所示: m_pBuffer = new (NonPagedPool) long [BUFFER_SIZE]; m_pBuffer= (LONG *)((LONG)m_pBuffer&0xfffff000 + 0x1000); m_Mdl = new (NonPagedPool) KMemory(m_pBuffer, BUFFER_SIZE*4,FALSE, FALSE, NULL); m_Mdl->SetPageArray(); UserSpaceAddress=MmMapLockedPages(dMdl, UserMode); I.UserBuffer()=UserSpaceAddress; 请大家帮帮忙,特别着急!!!!! 不知道问题出在那。 |
|