-----------------------------------------------------------------------------------------
                      [BUG/PRB.] VFP 9.0 FIX - THE NUMBER OF TIMES TO TRY AGAIN AFTER PACK DBF FAILED
                                 January 2024
                 -----------------------------------------------------------------------------------------
                                     CCB



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), somtimes the pack dbf function runs failed on Windows Vista or later.


2. CAUSE:

     There are some compatible problems when vfp calls the pack dbf function
     for the Windows Defender program or the antivirus programs.
     Now if vfp calls the pack dbf function failed,
     it will call the pack dbf function many times again.

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label441dfa ::
             mov  eax , dword ptr [edi]                                      ;0x00441dfa :        8b07
             mov  eax , dword ptr [eax]                                      ;0x00441dfc :        8b00
             push esi                                                        ;0x00441dfe :        56
             call Fun413b37                                                  ;0x00441dff :        e8331dfdff
             mov  eax , dword ptr [edi]                                      ;0x00441e04 :        8b07
             mov  ecx , dword ptr [ ebp - 52 ]                               ;0x00441e06 :        8b4dcc
             push  dword ptr [ ebp - 60 ]                                    ;0x00441e09 :        ff75c4
             mov esi , edi                                                   ;0x00441e0c :        8bf7
             mov  dword ptr [ eax + 8 ] , ecx                                ;0x00441e0e :        894808
             call Fun52e00c                                                  ;0x00441e11 :        e8f6c10e00
             mov ecx , edi                                                   ;0x00441e16 :        8bcf
             call Fun43f9b2                                                  ;0x00441e18 :        e895dbffff
             push ebx                                                        ;0x00441e1d :        53
             call Fun441949                                                  ;0x00441e1e :        e826fbffff
             mov esi , eax                                                   ;0x00441e23 :        8bf0
             xor ecx , ecx                                                   ;0x00441e25 :        33c9
             cmp esi , ecx                                                   ;0x00441e27 :        3bf1
             jne Label5c42b0                                                 ;0x00441e29 :        0f8581241800

     Label441e2f ::
             mov  dword ptr [ ebx + 76 ] , ecx                               ;0x00441e2f :        894b4c
             mov  dword ptr [ ebx + 80 ] , ecx                               ;0x00441e32 :        894b50
             mov ecx , ebx                                                   ;0x00441e35 :        8bcb
             call Fun43f9b2                                                  ;0x00441e37 :        e876dbffff


     ;
     ;                 ------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - THE NUMBER OF TIMES TO TRY AGAIN AFTER PACK DBF FAILED
     ;                                December 2020
     ;                 ------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; The number of times to try again after pack dbf failed.
     ;
     ; 2020/12/26, by ccb
     ;

     ;         lea edi ,  dword ptr [ ebp + 0358h ]                            ;0x00441e3c :        8dbd58030000
     ;         call Fun546c56                                                  ;0x00441e42 :        e80f4e1000
     ;         lea eax ,  dword ptr [ ebp + 0250h ]                            ;0x00441e47 :        8d8550020000
     ;         call Fun488609                                                  ;0x00441e4d :        e8b7670400

             mov dword ptr vfpa_packdbf_packdbf_cnt,00h

     Label441e3d ::
             lea edi ,  dword ptr [ ebp + 0358h ]
             call Fun546c56
             test eax , eax
             je Label441e47
             mov ecx,dword ptr vfpa_sys9048_data
             inc dword ptr vfpa_packdbf_packdbf_cnt
             cmp dword ptr vfpa_packdbf_packdbf_cnt,ecx
             ja Label441e47
             push dword ptr vfpa_sys9074_data
             call  Sleep
             jmp Label441e3d

     Label441e47 ::
             mov dword ptr vfpa_packdbf_packdbf_cnt,00h

     Label441e48 ::
             lea eax ,  dword ptr [ ebp + 0250h ]
             call Fun488609
             test eax , eax
             je Label441e52
             mov ecx,dword ptr vfpa_sys9048_data
             inc dword ptr vfpa_packdbf_packdbf_cnt
             cmp dword ptr vfpa_packdbf_packdbf_cnt,ecx
             ja Label441e52
             push dword ptr vfpa_sys9074_data
             call  Sleep
             jmp Label441e48


     Label441e52 ::
             mov  ebx , dword ptr [ ebp - 48 ]                               ;0x00441e52 :        8b5dd0
             mov edi , eax                                                   ;0x00441e55 :        8bf8
             call Fun41de4e                                                  ;0x00441e57 :        e8f2bffdff
             mov ebx , eax                                                   ;0x00441e5c :        8bd8
             mov  eax , dword ptr [ ebp - 40 ]                               ;0x00441e5e :        8b45d8
             pushd 080004h                                                   ;0x00441e61 :        6804000800
             push  dword ptr [ ebp - 8 ]                                     ;0x00441e66 :        ff75f8
             lea edx ,  dword ptr [ ebp + 0128h ]                            ;0x00441e69 :        8d9528010000
             mov ecx , ebx                                                   ;0x00441e6f :        8bcb
             mov  dword ptr [ ebp + 0470h ] , ebx                            ;0x00441e71 :        899d70040000
             mov  dword ptr [ ebx + 68 ] , eax                               ;0x00441e77 :        894344
             call Fun53170a                                                  ;0x00441e7a :        e88bf80e00
             test edi , edi                                                  ;0x00441e7f :        85ff
             jne Label5c42c0                                                 ;0x00441e81 :        0f8539241800
             push  dword ptr [ ebp + 0 ]                                     ;0x00441e87 :        ff7500
             mov  edi , dword ptr [ebx]                                      ;0x00441e8a :        8b3b
             push esi                                                        ;0x00441e8c :        56
             call Fun441efb                                                  ;0x00441e8d :        e869000000
             mov  dword ptr [ edi + 104 ] , eax                              ;0x00441e92 :        894768
             mov  eax , dword ptr [ebx]                                      ;0x00441e95 :        8b03
             lea ecx ,  dword ptr [ ebp + 24 ]                               ;0x00441e97 :        8d4d18
             push ecx                                                        ;0x00441e9a :        51
             mov  ecx , dword ptr [ eax + 104 ]                              ;0x00441e9b :        8b4868
             call Fun441db6                                                  ;0x00441e9e :        e813ffffff
             test eax , eax                                                  ;0x00441ea3 :        85c0
             mov  dword ptr [ ebx + 52 ] , eax                               ;0x00441ea5 :        894334
             jne Label5c42c8                                                 ;0x00441ea8 :        0f851a241800

     Label441eae ::
             pushd 00h                                                       ;0x00441eae :        6a00
             push ebx                                                        ;0x00441eb0 :        53
             call Fun4d16fb                                                  ;0x00441eb1 :        e845f80800
             mov  eax , dword ptr [ ebp - 56 ]                               ;0x00441eb6 :        8b45c8
             mov  ecx , dword ptr [ ebp - 32 ]                               ;0x00441eb9 :        8b4de0
             push  dword ptr [ ebp - 36 ]                                    ;0x00441ebc :        ff75dc
             mov  dword ptr [ ebx + 76 ] , eax                               ;0x00441ebf :        89434c
             mov  eax , dword ptr [ ebp - 28 ]                               ;0x00441ec2 :        8b45e4
             mov  dword ptr [ ebx + 80 ] , eax                               ;0x00441ec5 :        894350
             mov  eax , dword ptr [ebx]                                      ;0x00441ec8 :        8b03
             shl ecx , 011h                                                  ;0x00441eca :        c1e111
             xor  ecx , dword ptr [ eax + 32 ]                               ;0x00441ecd :        334820
             mov esi , ebx                                                   ;0x00441ed0 :        8bf3
             and ecx , 020000h                                               ;0x00441ed2 :        81e100000200
             xor  dword ptr [ eax + 32 ] , ecx                               ;0x00441ed8 :        314820
             mov  eax , dword ptr [ ebp - 12 ]                               ;0x00441edb :        8b45f4
             call Fun41dd89                                                  ;0x00441ede :        e8a6befdff
             mov  eax , dword ptr [ebx]                                      ;0x00441ee3 :        8b03
             mov  ecx , dword ptr [ ebp - 16 ]                               ;0x00441ee5 :        8b4df0
             mov  dword ptr [ eax + 0C0h ] , ecx                             ;0x00441ee8 :        8988c0000000
             mov  eax , dword ptr [ebx]                                      ;0x00441eee :        8b03
             mov  ecx , dword ptr [ ebp - 24 ]                               ;0x00441ef0 :        8b4de8
             mov  dword ptr [ eax + 80 ] , ecx                               ;0x00441ef3 :        894850
             jmp Label4ec48b                                                 ;0x00441ef6 :        e990a50a00


4. APPLIES TO:

     VFP 6.0.8167.0
     VFP 6.0.8961.0 (SP5)

     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.

     IMPORTANT NOTE:
     The following commands and functions have been fixed for the pack dbf function:
     PACK command
     COMPILE command
     MODIFY CLASS command
     MODIFY PROJECT command: check project
     BUILD command: check project
     SOURCE CONTROL: check project
     RESOURCE FILE: check resource file

     ; for the pack dbf function, please refer to the following pseudo code:
     ;
     ; * temp.dbf is a temporary file name, for example, 000001aa000a.tmp.
     ;
     ; use test.dbf
     ; copy to temp.dbf for !dele()
     ; use
     ;
     ; delete file test.dbf && if delete file failed, it will try many (SYS(9048)) times again.
     ;
     ; rename temp.dbf to test.dbf && if rename file failed, it will try many (SYS(9048)) times again.
     ;
     ; * there is no any changes for the memo file test.fpt.


5. REFERENCE WEBSITES:

     1, baiyujia.com:
     http://www.baiyujia.com
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix147.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix65.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix66.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix67.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix68.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix69.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix70.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix71.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix72.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix73.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix74.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix84.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix85.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix107.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix108.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix109.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix110.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix143.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix144.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix145.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix146.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix149.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix150.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix203.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix261.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix262.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix269.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix270.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix278.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix279.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix348.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix349.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix350.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix351.asp


6. OTHER:

     For reference only, there is no guarantees.

     Any questions or suggestions, please send me an email at ccb2000@163.com.