-------------------------------------------------------------
[BUG/PRB.] VFP 9.0 FIX - CHECK THE FILE DATA BUFFER
January 2025
-------------------------------------------------------------
CCB
1. BUG:
In vfp9 (and vfp7, vfp8), if the file data length is not equal to the file data buffer length (except the last file block),
it will not display any warning message.
The bug occurs in vfp7, vfp8 and vfp9, it does not occur in vfp6.
In VFP Advanced, if the file data length is not equal to the file data buffer length (except the last file block),
it will display a warning message "File data buffer internal consistency error! The file name is 'name'.
Press 'OK' to fix the error. Press 'Cancel' to ignore the error, the file will be invalid or corrupted!".
Please refer to the picture filedatabufferinternalconsistencyerror.png:
2. CAUSE:
There are some BUGs in the following code.
3. RESOLUTION:
Fun42d157 :: ; proc near
push ecx ;0x0042d157 : 51
mov eax , dword ptr [ Data93757c ] ;0x0042d158 : a17c759300
push ebx ;0x0042d15d : 53
push ebp ;0x0042d15e : 55
mov ebp , dword ptr [ esp + 24 ] ;0x0042d15f : 8b6c2418
push esi ;0x0042d163 : 56
push edi ;0x0042d164 : 57
;
; --------------------------------------------------
; VFP 9.0 FIX - CHECK THE FILE DATA BUFFER
; August 2024
; --------------------------------------------------
; CCB
;
; Check the file data buffer.
;
; 2024/8/23, by ccb
;
mov dword ptr vfpa_checkfiledatabuffer_errorcount,00h
mov edi , dword ptr [ esp + 24 ] ;0x0042d165 : 8b7c2418
mov ebx , edi ;0x0042d169 : 8bdf
imul ebx , ebx , 038h ;0x0042d16b : 6bdb38
mov dword ptr [ esp + 16 ] , ebx ;0x0042d16e : 895c2410
add ebx , eax ;0x0042d172 : 03d8
test byte ptr [ ebx + 8 ] , 021h ;0x0042d174 : f6430821
jne Label43e445 ;0x0042d178 : 0f85c7120100
Label42d17e ::
test byte ptr [ ebx + 44 ] , 02h ;0x0042d17e : f6432c02
je Label56e449 ;0x0042d182 : 0f84c1121400
xor eax , eax ;0x0042d188 : 33c0
test ebp , ebp ;0x0042d18a : 85ed
mov dword ptr [ esp + 32 ] , eax ;0x0042d18c : 89442420
jbe Label42d1f8 ;0x0042d190 : 7666
lea esp , dword ptr [ esp ] ;0x0042d192 : 8d2424
Label42d195 ::
mov ecx , dword ptr [ Data9370f8 ] ;0x0042d195 : 8b0df8709300
push ebp ;0x0042d19b : 55
mov edx , ebx ;0x0042d19c : 8bd3
call Fun42d01e ;0x0042d19e : e87bfeffff
mov esi , eax ;0x0042d1a3 : 8bf0
mov edx , dword ptr [ esi + 4 ] ;0x0042d1a5 : 8b5604
mov eax , dword ptr [ ebx + 4 ] ;0x0042d1a8 : 8b4304
sub eax , edx ;0x0042d1ab : 2bc2
mov edx , dword ptr [ esi + 12 ] ;0x0042d1ad : 8b560c
;
; --------------------------------------------------
; VFP 9.0 FIX - CHECK THE FILE DATA BUFFER
; August 2024
; --------------------------------------------------
; CCB
;
; Check the file data buffer.
;
; 2024/8/23, by ccb
;
; cmp eax , edx ;0x0042d1b0 : 3bc2
; jnb Label42d1f4 ;0x0042d1b2 : 7340
cmp eax , edx ;0x0042d1b0 : 3bc2
jb Label42d1b4 ;0x0042d1b2 : 7340
cmp dword ptr vfpa_sys9165_data,00h
je Label42d1f4
cmp edx , dword ptr [ esi + 8 ]
jae Label42d1f4
IF VFPA_VERSION GE 101
mov ecx , dword ptr [ esi + VFPA_CONST_X64_FILEBLOCK_CUROFFSET64 ][0]
mov edx , dword ptr [ esi + VFPA_CONST_X64_FILEBLOCK_CUROFFSET64 ][4]
add ecx , dword ptr [ esi + 12 ]
adc edx , 00h
cmp edx , dword ptr [ ebx + VFPA_CONST_X64_FOXFILE_FILESIZE64 ][4]
ja Label42d1f4
jb Label42d1b1
cmp ecx , dword ptr [ ebx + VFPA_CONST_X64_FOXFILE_FILESIZE64 ][0]
ja Label42d1f4
jb Label42d1b1
jmp Label42d1f4
ELSE
mov ecx , dword ptr [ esi + 4 ]
add ecx , dword ptr [ esi + 12 ]
cmp ecx , dword ptr [ebx]
jae Label42d1f4
ENDIF
Label42d1b1 ::
mov ecx , dword ptr [ ebx + 32 ]
test ecx , ecx
jl Label42d1f4
mov ecx , dword ptr [ ebx + 36 ]
dec ecx
test ecx , ecx
jle Label42d1f4
mov edx , dword ptr [ ebx + 16 ]
mov edx , dword ptr [edx]
lea ecx , dword ptr [ edx + 4 * ecx ]
mov edx , dword ptr [ ebx + 20 ]
mov ecx , dword ptr [ecx]
add ecx , dword ptr [edx]
mov edx , dword ptr [ esi + 12 ]
cmp ecx , esi
je Label42d1f4
mov ecx , dword ptr [ Data937794 ]
test ecx , ecx
je Label42d1f4
cmp dword ptr vfpa_sys9165_data,02h
je Label42d1b2
cmp dword ptr vfpa_checkfiledatabuffer_errorcount,00h
jne Label42d1b2
push eax
push edx
lea eax,byte ptr vfpa_checkfiledatabuffer_errormessage
push eax
lea eax,byte ptr vfpa_checkfiledatabuffer_errortext
push eax
call lstrcpyA
mov eax , dword ptr [ ebx + 12 ]
mov eax , dword ptr [eax]
push eax
lea eax,byte ptr vfpa_checkfiledatabuffer_errortext
push eax
call lstrcatA
lea eax,byte ptr vfpa_checkfiledatabuffer_errormessage2
push eax
lea eax,byte ptr vfpa_checkfiledatabuffer_errortext
push eax
call lstrcatA
pushd 00h
pushd 01h
lea eax,byte ptr vfpa_checkfiledatabuffer_errortext
push eax
call Fun6da3d3
mov ecx , eax
pop edx
pop eax
test ecx,ecx
je Label42d1f4
Label42d1b2 ::
inc dword ptr vfpa_checkfiledatabuffer_errorcount
mov edx , dword ptr [ esi + 8 ]
cmp eax , edx ;0x0042d1b0 : 3bc2
jb Label42d1b4 ;0x0042d1b2 : 7340
jmp Label42d1f4
Label42d1b4 ::
sub edx , eax ;0x0042d1b4 : 2bd0
cmp ebp , edx ;0x0042d1b6 : 3bea
ja Label434cfb ;0x0042d1b8 : 0f873d7b0000
mov edx , ebp ;0x0042d1be : 8bd5
Label42d1c0 ::
mov esi , dword ptr [esi] ;0x0042d1c0 : 8b36
mov edi , dword ptr [ esp + 32 ] ;0x0042d1c2 : 8b7c2420
add esi , eax ;0x0042d1c6 : 03f0
mov eax , dword ptr [ esp + 28 ] ;0x0042d1c8 : 8b44241c
add edi , eax ;0x0042d1cc : 03f8
mov ecx , edx ;0x0042d1ce : 8bca
mov eax , ecx ;0x0042d1d0 : 8bc1
shr ecx , 02h ;0x0042d1d2 : c1e902
rep movsd ;0x0042d1d5 : f3a5
mov ecx , eax ;0x0042d1d7 : 8bc8
and ecx , 03h ;0x0042d1d9 : 83e103
rep movsb ;0x0042d1dc : f3a4
mov esi , dword ptr [ esp + 32 ] ;0x0042d1de : 8b742420
mov ecx , dword ptr [ ebx + 4 ] ;0x0042d1e2 : 8b4b04
add esi , edx ;0x0042d1e5 : 03f2
add ecx , edx ;0x0042d1e7 : 03ca
sub ebp , edx ;0x0042d1e9 : 2bea
mov dword ptr [ esp + 32 ] , esi ;0x0042d1eb : 89742420
mov dword ptr [ ebx + 4 ] , ecx ;0x0042d1ef : 894b04
jne Label42d195 ;0x0042d1f2 : 75a1
Label42d1f4 ::
mov eax , dword ptr [ esp + 32 ] ;0x0042d1f4 : 8b442420
Label42d1f8 ::
pop edi ;0x0042d1f8 : 5f
pop esi ;0x0042d1f9 : 5e
pop ebp ;0x0042d1fa : 5d
pop ebx ;0x0042d1fb : 5b
pop ecx ;0x0042d1fc : 59
ret 0Ch ;0x0042d1fd : c20c00
4. APPLIES TO:
VFP 7.0.0.9262
VFP 7.0.0.9465 (SP1)
VFP 8.0.0.2521
VFP 8.0.0.3117 (SP1)
VFP 9.0.0.2412
VFP 9.0.0.3504 (SP1)
VFP 9.0.0.4611 (SP2)
VFP 9.0.0.5015 (SP2)
VFP 9.0.0.5411 (SP2)
VFP 9.0.0.5721 (SP2)
VFP 9.0.0.5815 (SP2)
VFP 9.0.0.6303 (SP2)
VFP 9.0.0.6602 (SP2)
VFP 9.0.0.7423 (SP2)
The bug has been fixed in VFP Advanced.
5. REFERENCE WEBSITES:
1, baiyujia.com:
http://www.baiyujia.com
http://www.baiyujia.com/vfpdocuments/f_vfp9fix338.asp
http://www.baiyujia.com/vfpdocuments/f_vfp9fix26.asp
http://www.baiyujia.com/vfpdocuments/f_vfp9fix337.asp
6. OTHER:
For reference only, there is no guarantees.
Any questions or suggestions, please send me an email at ccb2000@163.com.
|