阅读:1752回复:2
为什么我的filedisk写入文件的数据没法改变?
switch (io_stack->MajorFunction)
{ case IRP_MJ_READ: system_buffer = MmGetSystemAddressForMdl(irp->MdlAddress); if (system_buffer == NULL) { irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES; irp->IoStatus.Information = 0; break; } for (i = 0 ;i <io_stack->Parameters.Read.Length; i++) { buffer -=1; } ZwReadFile( device_extension->file_handle, NULL, NULL, NULL, &irp->IoStatus, system_buffer, io_stack->Parameters.Read.Length, &io_stack->Parameters.Read.ByteOffset, NULL ); break; case IRP_MJ_WRITE: if ((io_stack->Parameters.Write.ByteOffset.QuadPart + io_stack->Parameters.Write.Length) > device_extension->file_size.QuadPart) { irp->IoStatus.Status = STATUS_INVALID_PARAMETER; irp->IoStatus.Information = 0; break; } buffer = (PUCHAR)ExAllocatePool(PagedPool, io_stack->Parameters.Write.Length); RtlCopyMemory(buffer,MmGetSystemAddressForMdlSafe(irp->MdlAddress, NormalPagePriority),io_stack->Parameters.Write.Length); for (i = 0 ;i < io_stack->Parameters.Write.Length ; i++) { buffer +=1; } ZwWriteFile( device_extension->file_handle, NULL, NULL, NULL, &irp->IoStatus, buffer, io_stack->Parameters.Write.Length, &io_stack->Parameters.Write.ByteOffset, NULL ); ExFreePool(buffer); break; 我其他地方都没动,就是想改一下写如何读取时的文件。而且写入的时候我也没有改变原来内从中的内容啊。 加入我的代码后windows会提示无法格式化磁盘~! |
|
沙发#
发布于:2009-10-29 15:46
问题解决了吗?
|
|
板凳#
发布于:2011-04-22 20:42
你是不是在创建img文件的时候是只读的形式?
|
|