Re: 请问张老师,内存虚拟磁盘加密失败,能否指点? 谢谢!《寒江独钓》ramdisk例子(WDK7600,storage里的源码),

Windows驱动开发

请问张老师,内存虚拟磁盘加密失败,能否指点? 谢谢!《寒江独钓》ramdisk例子(WDK7600,storage里的源码),


静水流深 2010-04-22, 12:45 下午

1. WDK7600里的ramdisk示例只实现1M的虚拟内存,改了ramdisk.inx和ramdisk.h里的内存设置,比如32M,还是不行。

2. 想实现加密存储,为了查看效果,先试图在写文件时加密,修改ramdisk.c中的RamDiskEvtIoWrite函数,但加载后蓝屏。

VOID
RamDiskEvtIoWrite(
    IN WDFQUEUE Queue,
    IN WDFREQUEST Request,
    IN size_t Length
    )
{
    PDEVICE_EXTENSION      devExt = QueueGetExtension(Queue)->DeviceExtension;
    NTSTATUS               Status = STATUS_INVALID_PARAMETER;
    WDF_REQUEST_PARAMETERS Parameters;
    LARGE_INTEGER          ByteOffset;
    WDFMEMORY              hMemory;
 //时间2010年4月21日12:52:03
 PVOID buf_XOR_13=0;
 unsigned char *p_Byte=0;
 unsigned int count=0;

    __analysis_assume(Length > 0);

    WDF_REQUEST_PARAMETERS_INIT(&Parameters);
    WdfRequestGetParameters(Request, &Parameters);

    ByteOffset.QuadPart = Parameters.Parameters.Write.DeviceOffset;

    if (RamDiskCheckParameters(devExt, ByteOffset, Length)) {

        Status = WdfRequestRetrieveInputMemory(Request, &hMemory);
        if(NT_SUCCESS(Status)){
   //时间 2010年4月21日12:44:25
   //写入时加密,异或0x13H

            //Status = WdfMemoryCopyToBuffer(hMemory, // Source
            //                        0,              // offset in Source memory where the copy has to start
            //                        devExt->DiskImage + ByteOffset.LowPart, // destination
            //                        Length);
            buf_XOR_13=ExAllocatePoolWithTag(NonPagedPool,
                     Length,
                     RAMDISK_TAG);
   Status = WdfMemoryCopyToBuffer(hMemory, // Source
                                    0,              // offset in Source memory where the copy has to start
                                    buf_XOR_13, // destination
                                    Length);
   p_Byte=(unsigned char*)buf_XOR_13;
   //怀疑真正写的长度很小,故Length改为3
   for(count=0;count<3;count++)
   { *p_Byte = (*p_Byte) ^ 0x13;
    p_Byte++;
   }
   Status = WdfMemoryCopyToBuffer((WDFMEMORY)buf_XOR_13, // Source
                                    0,              // offset in Source memory where the copy has to start
                                    devExt->DiskImage + ByteOffset.LowPart, // destination
                                    Length);
   //释放内存
   ExFreePool(buf_XOR_13);
   
        }

    }

    WdfRequestCompleteWithInformation(Request, Status, (ULONG_PTR)Length);
}

Re: 请问张老师,内存虚拟磁盘加密失败,能否指点? 谢谢!《寒江独钓》ramdisk例子(WDK7600,storage里的源码),


王宇 2010-04-22, 13:12 下午
楼主的 ID 让我想起了 Rhett 感慨一下...

请问蓝在哪里?

再感慨一下...

Re: 请问张老师,内存虚拟磁盘加密失败,能否指点? 谢谢!《寒江独钓》ramdisk例子(WDK7600,storage里的源码),


SuperMouse 2010-04-22, 14:05 下午
Status = WdfMemoryCopyToBuffer((WDFMEMORY)buf_XOR_13, // Source
0, // offset in Source memory where the copy has to start
devExt->DiskImage + ByteOffset.LowPart, // destination
Length);

这里对吗?没玩过WdfMemoryXXX,但是感觉WDFMEMORY类型的对象应该不是一个纯指针吧……你把一个BYTE*强制转换成WDMEMORY,好像不对诶。况且这里直接RtlCopyMemory不就行了么……

Re: 请问张老师,内存虚拟磁盘加密失败,能否指点? 谢谢!《寒江独钓》ramdisk例子(WDK7600,storage里的源码),


nightxie 2010-04-22, 19:41 下午
Oh my GoD~
WDFMEMORY a handle to the new framework memory object not just a point to buffer.

Re: 请问张老师,内存虚拟磁盘加密失败,能否指点? 谢谢!《寒江独钓》ramdisk例子(WDK7600,storage里的源码),


静水流深 2010-04-23, 15:07 下午

1. WDK7600里的ramdisk示例,能够在Vista下运行,但在Windows 7 下只成功过一次,后来重装了两三次Win7的虚拟机,总是不成功,显示【本地磁盘R:】0字节,不能读写

请问有谁在Windows 7 下试验成功了,相互切磋?

Re: 请问张老师,内存虚拟磁盘加密失败,能否指点? 谢谢!《寒江独钓》ramdisk例子(WDK7600,storage里的源码),


後生SHIN 2013-01-15, 17:55 下午

请问一下第1个问题现在解决了么。。。我也碰到这个问题了啊

Powered by Community Server Powered by CnForums.Net