VS
2003.net
When using the setFilePointered setup file location, you need to use the longlong type, then after reading a DWREAD long data, you need to reset the file location:
Large_integer lnfilepos.quadpart = 0x00 - dwread;
SetFilePointerex (...);
The problem will appear, this code is problematic. Because 0x00 - dwread is not a negative number for lnfilepos.quadpart.
Let's take a look at the assembly code:
The key is on the MOV DWORD PTR [lnFilePosition], EAX, which is directly written to memory, and the high ECX is simple to be 0, and no extension is performed. In the memory, lnfilepost accounts for 8 bytes, which is like this:
So when you retrieve lnfilepost again, lnFiLePOStion = 00000000 fffffc00, not the desired ffffffffFFFFC00.
Here is the assembly code after adding type conversion (although under Debug, the assembly code generated by VC2003.net is a bit bad).
Where SBB 0, 0 generates 0xFffffFFFF.
However, this situation only exists when the expression contains variables, if two immediate numbers, such as:
Large_integer lnfilepos.quadpart = 0x00 - 0x400;
The VC can be handled correctly.