sehang / dokan

Automatically exported from code.google.com/p/dokan
0 stars 0 forks source link

Invalid Offset in function for write IRP #138

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. I capture the file i/o(write), using FileMon in local hard drive.
HNexcel.exe:4056    WRITE   D:\새 한글과컴퓨터 넥셀 문서.nxl SUCCESS
    Offset: 7679 Length: 1                                             
HNexcel.exe:4056    WRITE   D:\새 한글과컴퓨터 넥셀 문서.nxl SUCCESS
    Offset: 0 Length: 7680  
HNexcel.exe:4056    WRITE   D:\새 한글과컴퓨터 넥셀 문서.nxl SUCCESS
    Offset: 0 Length: 512      

2. and Compare to Mirror debugMsg for Same File I/O.
write = d:\temp\새 한글과컴퓨터 넥셀 문서.nxl, write length = 1, 
wirte 
offset : 7679, pid : 0     
write = d:\temp\새 한글과컴퓨터 넥셀 문서.nxl, write length = 7680, 
wirte 
offset : 7680, pid : 0 
write = d:\temp\새 한글과컴퓨터 넥셀 문서.nxl, write length = 512, 
wirte 
offset : 512, pid : 0    

3. the Second and third File I/O is not eual to local drive.
   the offset is not correct.

What is the expected output? What do you see instead?
check the offset in Dispatch function for write IRP.

What version of the product are you using? On what operating system?
lastest version of dokan.sys/dll/mirror

Please provide any additional information below.
R61 is correct. need to check the code for paging io, may be.

Original issue reported on code.google.com by digerat...@gmail.com on 8 Mar 2010 at 5:10

GoogleCodeExporter commented 8 years ago
I have to modify dispatchwrite function.

if ((fileObject->Flags & FO_SYNCHRONOUS_IO) &&
    /*(irpSp->Parameters.Write.ByteOffset.QuadPart == 0 ||*/
((irpSp->Parameters.Write.ByteOffset.LowPart == FILE_USE_FILE_POINTER_POSITION) 
&&
    (irpSp->Parameters.Write.ByteOffset.HighPart == -1))) {

please comment this conditions.

Original comment by digerat...@gmail.com on 16 Mar 2010 at 1:45

GoogleCodeExporter commented 8 years ago
From:
http://msdn.microsoft.com/en-us/library/ms795960.aspx
===
IrpSp->Parameters.Write.ByteOffset
A pointer to a LARGE_INTEGER variable that specifies the starting byte offset 
within the file of the 
data to be written.
Under certain circumstances, this parameter might validly contain a NULL or 
negative value. For 
example:

If the following condition is true, this indicates that the current end of file 
should be used instead 
of an explicit file offset value:
IrpSp->Parameters.Write.ByteOffset.LowPart == FILE_WRITE_TO_END_OF_FILE and 
IrpSp-
>Parameters.Write.ByteOffset.HighPart == -1

If the file object was opened for synchronous I/O, and one of the following 
conditions is true, this 
indicates that the current file position should be used instead of an explicit 
file offset value:
IrpSp->Parameters.Write.ByteOffset.QuadPart == 0

IrpSp->Parameters.Write.ByteOffset.LowPart == FILE_USE_FILE_POINTER_POSITION 
and IrpSp-
>Parameters.Write.ByteOffset.HighPart == -1
===

Is the document wrong?

Original comment by asa...@gmail.com on 16 Mar 2010 at 8:21

GoogleCodeExporter commented 8 years ago
Probably, setting CurrentByteOffset in DokanCompleteWrite is wrong, I fixed it 
in both 
dll and driver.

Original comment by asa...@gmail.com on 16 Mar 2010 at 9:28

GoogleCodeExporter commented 8 years ago
It seems the document is wrong. I removed 
IrpSp->Parameters.Write.ByteOffset.QuadPart 
== 0 check.

Original comment by asa...@gmail.com on 17 Mar 2010 at 7:23