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



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), somtimes the pack memo function runs failed on Windows Vista or later,
     but vfp does not cause an error immediately.
     When we use the table and memo files next time,
     vfp will cause the error "Memo file is missing or is invalid (Error 41)".


2. CAUSE:

     There are some compatible problems when vfp calls the pack memo function
     for the Windows Defender program or the antivirus programs.
     Now if vfp calls the pack memo function failed,
     it will call the pack memo function many times again.
     In the end, if vfp calls the pack memo function many times, but it always failed,
     vfp will restore the old table and memo files, we will not lose any data.

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun8afcbb :: ; proc near
             push ebp                                                        ;0x008afcbb :        55
             mov ebp , esp                                                   ;0x008afcbc :        8bec


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

     ;         sub esp , 0C8h                                                  ;0x008afcbe :        81ecc8000000

             sub esp , 02D8h                                                  ;0x008afcbe :        81ecc8000000
             xor eax , eax
             mov dword ptr [ ebp - 0C8h ][-060h][00h] , eax ;; _JUMP_BUFFER_vfp[50h], otherdata[10h].
             mov dword ptr [ ebp - 0C8h ][-060h][50h] , eax
             mov dword ptr [ ebp - 0C8h ][-060h][54h] , eax
             mov dword ptr [ ebp - 0C8h ][-060h][58h] , eax
             mov dword ptr [ ebp - 0C8h ][-060h][5Ch] , eax
             mov dword ptr [ ebp - 0C8h ][-0C0h][00h] , eax ;; _JUMP_BUFFER_vfp[50h], otherdata[10h].
             mov dword ptr [ ebp - 0C8h ][-0C0h][50h] , eax
             mov dword ptr [ ebp - 0C8h ][-0C0h][54h] , eax
             mov dword ptr [ ebp - 0C8h ][-0C0h][58h] , eax
             mov dword ptr [ ebp - 0C8h ][-0C0h][5Ch] , eax
             mov dword ptr [ ebp - 0C8h ][-0D0h][00h] , eax ;; error code.
             mov dword ptr [ ebp - 0C8h ][-0D0h][04h] , eax
             mov dword ptr [ ebp - 0C8h ][-0D0h][08h] , eax ;; vfpa_packmemo_packmemo_cnt
             mov dword ptr [ ebp - 0C8h ][-0D0h][0Ch] , eax
             mov dword ptr [ ebp - 0C8h ][-0E0h][00h] , 0FFFFFFFFh ;; hfoxfiledbf_tmp
             mov dword ptr [ ebp - 0C8h ][-0E0h][04h] , eax
             mov dword ptr [ ebp - 0C8h ][-0E0h][08h] , eax ;; filesizedbf_tmp
             mov dword ptr [ ebp - 0C8h ][-0E0h][0Ch] , eax
             mov dword ptr [ ebp - 0C8h ][-0F0h][00h] , 0FFFFFFFFh ;; hfoxfilefpt_tmp
             mov dword ptr [ ebp - 0C8h ][-0F0h][04h] , eax
             mov dword ptr [ ebp - 0C8h ][-0F0h][08h] , eax ;; filesizefpt_tmp
             mov dword ptr [ ebp - 0C8h ][-0F0h][0Ch] , eax
             mov dword ptr [ ebp - 0C8h ][-100h][00h] , eax ;; diroffset.
             mov dword ptr [ ebp - 0C8h ][-100h][04h] , eax
             mov dword ptr [ ebp - 0C8h ][-100h][08h] , eax
             mov dword ptr [ ebp - 0C8h ][-100h][0Ch] , eax
             mov dword ptr [ ebp - 0C8h ][-210h][00h] , eax ;; filenamedbf.
             mov dword ptr [ ebp - 0C8h ][-210h][04h] , eax
             mov dword ptr [ ebp - 0C8h ][-210h][08h] , eax
             mov dword ptr [ ebp - 0C8h ][-210h][0Ch] , eax


             push ebx                                                        ;0x008afcc4 :        53
             push esi                                                        ;0x008afcc5 :        56
             mov  esi , dword ptr [ ebp + 16 ]                               ;0x008afcc6 :        8b7510
             push edi                                                        ;0x008afcc9 :        57
             mov ecx , esi                                                   ;0x008afcca :        8bce
             call Fun53eaa2                                                  ;0x008afccc :        e8d1edc8ff
             test eax , eax                                                  ;0x008afcd1 :        85c0
             je Label8afe36                                                  ;0x008afcd3 :        0f845d010000
             mov eax ,  dword ptr [ Data9388dc ]                             ;0x008afcd9 :        a1dc889300
             lea esi ,  dword ptr [ esi + 4 * esi ]                          ;0x008afcde :        8d34b6
             shl esi , 05h                                                   ;0x008afce1 :        c1e605
             mov  edi , dword ptr [ esi + eax + 116 ]                        ;0x008afce4 :        8b7c0674
             test edi , edi                                                  ;0x008afce8 :        85ff
             mov  dword ptr [ ebp - 20 ] , edi                               ;0x008afcea :        897dec
             je Label8afd09                                                  ;0x008afced :        741a
             pushd 09h                                                       ;0x008afcef :        6a09
             lea edx ,  dword ptr [ ebp - 28 ]                               ;0x008afcf1 :        8d55e4
             call Fun4d6eae                                                  ;0x008afcf4 :        e8b571c2ff
             test eax , eax                                                  ;0x008afcf9 :        85c0
             je Label8afd09                                                  ;0x008afcfb :        740c
             mov  ecx , dword ptr [ ebp - 28 ]                               ;0x008afcfd :        8b4de4
             test ecx , ecx                                                  ;0x008afd00 :        85c9
             jl Label8afd09                                                  ;0x008afd02 :        7c05
             call Fun42ddf2                                                  ;0x008afd04 :        e8e9e0b7ff

     Label8afd09 ::
             mov eax ,  dword ptr [ Data9388dc ]                             ;0x008afd09 :        a1dc889300
             lea eax ,  dword ptr [ esi + eax + 120 ]                        ;0x008afd0e :        8d440678
             mov  esi , dword ptr [eax]                                      ;0x008afd12 :        8b30
             test esi , esi                                                  ;0x008afd14 :        85f6
             mov  dword ptr [ ebp - 24 ] , esi                               ;0x008afd16 :        8975e8
             je Label8afe36                                                  ;0x008afd19 :        0f8417010000
             and  dword ptr [eax] , 00h                                      ;0x008afd1f :        832000
             mov  eax , dword ptr [esi]                                      ;0x008afd22 :        8b06
             mov  edi , dword ptr [ eax + 021Ch ]                            ;0x008afd24 :        8bb81c020000
             mov  edx , dword ptr [ eax + 0214h ]                            ;0x008afd2a :        8b9014020000
             mov ecx , edi                                                   ;0x008afd30 :        8bcf
             call Fun434624                                                  ;0x008afd32 :        e8ed48b8ff
             mov  eax , dword ptr [esi]                                      ;0x008afd37 :        8b06
             push  dword ptr [ eax + 0214h ]                                 ;0x008afd39 :        ffb014020000
             pushd 03h                                                       ;0x008afd3f :        6a03
             pop ebx                                                         ;0x008afd41 :        5b
             call Fun41ac96                                                  ;0x008afd42 :        e84fafb6ff
             mov ecx , edi                                                   ;0x008afd47 :        8bcf
             call Fun43f9b2                                                  ;0x008afd49 :        e864fcb8ff
             mov  esi , dword ptr [esi]                                      ;0x008afd4e :        8b36
             xor ebx , ebx                                                   ;0x008afd50 :        33db
             cmp  dword ptr [ esi + 0110h ] , ebx                            ;0x008afd52 :        399e10010000
             je Label8afd99                                                  ;0x008afd58 :        743f
             push  dword ptr [ ebp + 12 ]                                    ;0x008afd5a :        ff750c
             push  dword ptr [ ebp + 8 ]                                     ;0x008afd5d :        ff7508
             call Fun8b0e8b                                                  ;0x008afd60 :        e826110000
             mov  edi , dword ptr [ ebp - 20 ]                               ;0x008afd65 :        8b7dec
             cmp edi , ebx                                                   ;0x008afd68 :        3bfb
             je Label8afd99                                                  ;0x008afd6a :        742d
             mov edx , edi                                                   ;0x008afd6c :        8bd7
             call Fun43b5d5                                                  ;0x008afd6e :        e862b8b8ff
             cmp eax , 05h                                                   ;0x008afd73 :        83f805
             jne Label8afd99                                                 ;0x008afd76 :        7521
             pushd 011h                                                      ;0x008afd78 :        6a11
             lea edx ,  dword ptr [ ebp - 32 ]                               ;0x008afd7a :        8d55e0
             call Fun4d6eae                                                  ;0x008afd7d :        e82c71c2ff
             mov  eax , dword ptr [ ebp - 32 ]                               ;0x008afd82 :        8b45e0
             cmp eax , ebx                                                   ;0x008afd85 :        3bc3
             je Label8afd99                                                  ;0x008afd87 :        7410
             mov  eax , dword ptr [eax]                                      ;0x008afd89 :        8b00
             test  byte ptr [ eax + 37 ] , 04h                               ;0x008afd8b :        f6402504
             je Label8afd99                                                  ;0x008afd8f :        7408
             mov  ecx , dword ptr [ ebp + 8 ]                                ;0x008afd91 :        8b4d08
             call Fun8b1bb3                                                  ;0x008afd94 :        e81a1e0000

     Label8afd99 ::
             call Fun41eb74                                                  ;0x008afd99 :        e8d6edb6ff
             mov  dword ptr [ ebp - 8 ] , eax                                ;0x008afd9e :        8945f8
             lea edx ,  dword ptr [ ebp - 12 ]                               ;0x008afda1 :        8d55f4
             lea eax ,  dword ptr [ ebp - 116 ]                              ;0x008afda4 :        8d458c
             call Fun42c27f                                                  ;0x008afda7 :        e8d3c4b7ff
             push ebx                                                        ;0x008afdac :        53
             push eax                                                        ;0x008afdad :        50
             call Fun42c2be                                                  ;0x008afdae :        e80bc5b7ff
             mov esi , eax                                                   ;0x008afdb3 :        8bf0
             cmp esi , ebx                                                   ;0x008afdb5 :        3bf3
             pop ecx                                                         ;0x008afdb7 :        59
             pop ecx                                                         ;0x008afdb8 :        59
             jne Label8afdca                                                 ;0x008afdb9 :        750f
             mov  edx , dword ptr [ ebp + 8 ]                                ;0x008afdbb :        8b5508
             mov  ecx , dword ptr [ ebp - 8 ]                                ;0x008afdbe :        8b4df8
             pushd 04h                                                       ;0x008afdc1 :        6a04
             pushd 0FFFFFFFFh                                                ;0x008afdc3 :        6aff
             call Fun41e901                                                  ;0x008afdc5 :        e837ebb6ff

     Label8afdca ::
             lea eax ,  dword ptr [ ebp - 12 ]                               ;0x008afdca :        8d45f4
             push eax                                                        ;0x008afdcd :        50
             lea eax ,  dword ptr [ ebp - 116 ]                              ;0x008afdce :        8d458c
             call Fun42d200                                                  ;0x008afdd1 :        e82ad4b7ff
             cmp esi , ebx                                                   ;0x008afdd6 :        3bf3
             jne Label8afe2e                                                 ;0x008afdd8 :        7554
             lea edx ,  dword ptr [ ebp - 16 ]                               ;0x008afdda :        8d55f0
             lea eax ,  dword ptr [ ebp + 0FFFFFF3Ch ]                       ;0x008afddd :        8d853cffffff
             call Fun42c27f                                                  ;0x008afde3 :        e897c4b7ff
             push ebx                                                        ;0x008afde8 :        53
             push eax                                                        ;0x008afde9 :        50
             call Fun42c2be                                                  ;0x008afdea :        e8cfc4b7ff
             cmp eax , ebx                                                   ;0x008afdef :        3bc3
             mov  esi , dword ptr [ ebp - 8 ]                                ;0x008afdf1 :        8b75f8
             pop ecx                                                         ;0x008afdf4 :        59
             pop ecx                                                         ;0x008afdf5 :        59
             jne Label8afe0a                                                 ;0x008afdf6 :        7512
             test  byte ptr [ esi + 16 ] , 040h                              ;0x008afdf8 :        f6461040
             jne Label8afe0a                                                 ;0x008afdfc :        750c
             push esi                                                        ;0x008afdfe :        56
             call Fun4ec1b8                                                  ;0x008afdff :        e8b4c3c3ff


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

     ;         push esi                                                        ;0x008afe04 :        56
     ;         call Fun41af30                                                  ;0x008afe05 :        e826b1b6ff

             mov eax , dword ptr [ esi ]
             mov eax , dword ptr [ eax + 4 ]
             cmp eax , 00h
             jl Label8afe0a

             ;; hfoxfiledbf_tmp.
             ;; hfoxfilefpt_tmp.
             mov dword ptr [ ebp - 0C8h ][-0E0h][00h] , 0FFFFFFFFh
             mov dword ptr [ ebp - 0C8h ][-0F0h][00h] , 0FFFFFFFFh

             ;; vfpa_fflush(hfoxfiledbf).
             ;; vfpa_fflush(hfoxfilefpt).
             mov eax , dword ptr [ esi ]
             mov eax , dword ptr [ eax ]
             push eax
             call Fun431d6c
             mov eax , dword ptr [ esi ]
             mov eax , dword ptr [ eax + 4 ]
             push eax
             call Fun431d6c

             ;; filesizedbf_tmp.
             push edi
             mov eax , dword ptr [ esi ]
             mov edi , dword ptr [ eax ]
             call Fun433ef7
             mov dword ptr [ ebp - 0C8h ][-0E0h][08h] , eax
             IF VFPA_VERSION GE 101
             mov dword ptr [ ebp - 0C8h ][-0E0h][0Ch] , edx
             ENDIF
             pop edi

             ;; filesizefpt_tmp.
             push edi
             mov eax , dword ptr [ esi ]
             mov edi , dword ptr [ eax + 4 ]
             call Fun433ef7
             mov dword ptr [ ebp - 0C8h ][-0F0h][08h] , eax
             IF VFPA_VERSION GE 101
             mov dword ptr [ ebp - 0C8h ][-0F0h][0Ch] , edx
             ENDIF
             pop edi

             ;; filenamedbf.
             mov eax , dword ptr [ esi ]
             mov ecx , dword ptr [ eax ]
             lea eax ,  dword ptr [ ebp - 0C8h ][-210h][00h]
             call Fun41975b

             ;; diroffset.
             lea eax ,  dword ptr [ ebp - 0C8h ][-210h][00h]
             push eax
             lea eax ,  dword ptr [ ebp - 0C8h ][-100h][00h]
             push eax
             call Fun434bcf

             ;; hfoxfiledbf_tmp.
             lea  ecx , dword ptr [ ebp - 0C8h ][-100h][00h]
             push ecx
             call Fun431de4
             mov dword ptr [ ebp - 0C8h ][-0E0h][00h] , eax

             ;; hfoxfilefpt_tmp.
             lea  ecx , dword ptr [ ebp - 0C8h ][-100h][00h]
             push ecx
             call Fun431de4
             mov dword ptr [ ebp - 0C8h ][-0F0h][00h] , eax

             ;; copy file hfoxfiledbf to hfoxfiledbf_tmp.
             IF VFPA_VERSION GE 101
             pushd 00h
             pushd 00h
             push dword ptr [ ebp - 0C8h ][-0E0h][0Ch]
             push dword ptr [ ebp - 0C8h ][-0E0h][08h]
             pushd 00h
             pushd 00h
             ENDIF
             pushd 01h
             pushd 00h
             push dword ptr [ ebp - 0C8h ][-0E0h][00h]
             push dword ptr [ ebp - 0C8h ][-0E0h][08h]
             pushd 00h
             mov eax , dword ptr [ esi ]
             mov eax , dword ptr [ eax ]
             push eax
             call Fun41b5cc

             ;; copy file hfoxfilefpt to hfoxfilefpt_tmp.
             IF VFPA_VERSION GE 101
             pushd 00h
             pushd 00h
             push dword ptr [ ebp - 0C8h ][-0F0h][0Ch]
             push dword ptr [ ebp - 0C8h ][-0F0h][08h]
             pushd 00h
             pushd 00h
             ENDIF
             pushd 01h
             pushd 00h
             push dword ptr [ ebp - 0C8h ][-0F0h][00h]
             push dword ptr [ ebp - 0C8h ][-0F0h][08h]
             pushd 00h
             mov eax , dword ptr [ esi ]
             mov eax , dword ptr [ eax + 4 ]
             push eax
             call Fun41b5cc

             ;; vfpa_fflush(hfoxfiledbf_tmp).
             ;; vfpa_fflush(hfoxfilefpt_tmp).
             push dword ptr [ ebp - 0C8h ][-0E0h][00h]
             call Fun431d6c
             push dword ptr [ ebp - 0C8h ][-0F0h][00h]
             call Fun431d6c

             mov dword ptr [ ebp - 0C8h ][-0D0h][08h] , 00h

     Label8afe04 ::
             mov dword ptr [ ebp - 0C8h ][-060h][00h] , 00h
             mov dword ptr [ ebp - 0C8h ][-060h][50h] , 00h
             mov dword ptr [ ebp - 0C8h ][-060h][54h] , 00h

             lea eax ,  dword ptr [ ebp - 0C8h ][-060h][00h]
             lea edx ,  dword ptr [ ebp - 0C8h ][-060h][50h]
             call Fun42c27f
             push 00h
             push eax
             call Fun42c2be
             pop ecx
             pop ecx
             mov dword ptr [ ebp - 0C8h ][-060h][54h] , eax
             mov dword ptr [ ebp - 0C8h ][-0D0h][00h] , eax
             test eax , eax
             jne Label8afe05

             ;; vfpa_packmemo().
             ;; vfpa_fflush(hfoxfiledbf).
             ;; vfpa_fflush(hfoxfilefpt).
             push esi
             call Fun41af30
             mov eax , dword ptr [ esi ]
             mov eax , dword ptr [ eax ]
             push eax
             call Fun431d6c
             mov eax , dword ptr [ esi ]
             mov eax , dword ptr [ eax + 4 ]
             push eax
             call Fun431d6c

     Label8afe05 ::
             lea eax ,  dword ptr [ ebp - 0C8h ][-060h][00h]
             lea edx ,  dword ptr [ ebp - 0C8h ][-060h][50h]
             push edx
             call Fun42d200

             cmp dword ptr [ ebp - 0C8h ][-060h][54h] , 00h
             jne Label8afe07

             mov dword ptr [ ebp - 0C8h ][-0C0h][00h] , 00h
             mov dword ptr [ ebp - 0C8h ][-0C0h][50h] , 00h
             mov dword ptr [ ebp - 0C8h ][-0C0h][54h] , 00h

             lea eax ,  dword ptr [ ebp - 0C8h ][-0C0h][00h]
             lea edx ,  dword ptr [ ebp - 0C8h ][-0C0h][50h]
             call Fun42c27f
             push 00h
             push eax
             call Fun42c2be
             pop ecx
             pop ecx
             mov dword ptr [ ebp - 0C8h ][-0C0h][54h] , eax
             mov dword ptr [ ebp - 0C8h ][-0D0h][00h] , eax
             test eax , eax
             jne Label8afe06

             ;; vfpa_packmemo().
             ;; vfpa_fflush(hfoxfiledbf).
             ;; vfpa_fflush(hfoxfilefpt).
             push esi
             call Fun41af30
             mov eax , dword ptr [ esi ]
             mov eax , dword ptr [ eax ]
             push eax
             call Fun431d6c
             mov eax , dword ptr [ esi ]
             mov eax , dword ptr [ eax + 4 ]
             push eax
             call Fun431d6c

     Label8afe06 ::
             lea eax ,  dword ptr [ ebp - 0C8h ][-0C0h][00h]
             lea edx ,  dword ptr [ ebp - 0C8h ][-0C0h][50h]
             push edx
             call Fun42d200

             cmp dword ptr [ ebp - 0C8h ][-0C0h][54h] , 00h
             jne Label8afe07

             jmp Label8afe08

     Label8afe07 ::
             ;; vfpa_fflush(hfoxfiledbf).
             ;; vfpa_fflush(hfoxfilefpt).
             mov eax , dword ptr [ esi ]
             mov eax , dword ptr [ eax ]
             push eax
             call Fun431d6c
             mov eax , dword ptr [ esi ]
             mov eax , dword ptr [ eax + 4 ]
             push eax
             call Fun431d6c

             ;; copy file hfoxfiledbf_tmp to hfoxfiledbf.
             IF VFPA_VERSION GE 101
             pushd 00h
             pushd 00h
             push dword ptr [ ebp - 0C8h ][-0E0h][0Ch]
             push dword ptr [ ebp - 0C8h ][-0E0h][08h]
             pushd 00h
             pushd 00h
             ENDIF
             pushd 01h
             pushd 00h
             mov eax , dword ptr [ esi ]
             mov eax , dword ptr [ eax ]
             push eax
             push dword ptr [ ebp - 0C8h ][-0E0h][08h]
             pushd 00h
             push dword ptr [ ebp - 0C8h ][-0E0h][00h]
             call Fun41b5cc

             ;; copy file hfoxfilefpt_tmp to hfoxfilefpt.
             IF VFPA_VERSION GE 101
             pushd 00h
             pushd 00h
             push dword ptr [ ebp - 0C8h ][-0F0h][0Ch]
             push dword ptr [ ebp - 0C8h ][-0F0h][08h]
             pushd 00h
             pushd 00h
             ENDIF
             pushd 01h
             pushd 00h
             mov eax , dword ptr [ esi ]
             mov eax , dword ptr [ eax + 4 ]
             push eax
             push dword ptr [ ebp - 0C8h ][-0F0h][08h]
             pushd 00h
             push dword ptr [ ebp - 0C8h ][-0F0h][00h]
             call Fun41b5cc

             ;; vfpa_fflush(hfoxfiledbf).
             ;; vfpa_fflush(hfoxfilefpt).
             mov eax , dword ptr [ esi ]
             mov eax , dword ptr [ eax ]
             push eax
             call Fun431d6c
             mov eax , dword ptr [ esi ]
             mov eax , dword ptr [ eax + 4 ]
             push eax
             call Fun431d6c

             mov dword ptr [ ebp - 0C8h ][-0D0h][00h] , 00h

             mov ecx,dword ptr vfpa_sys9049_data
             inc dword ptr [ ebp - 0C8h ][-0D0h][08h]
             cmp dword ptr [ ebp - 0C8h ][-0D0h][08h],ecx
             ja Label8afe08
             push dword ptr vfpa_sys9074_data
             call  Sleep
             jmp Label8afe04

     Label8afe08 ::
             cmp dword ptr [ ebp - 0C8h ][-0E0h][00h] , 00h
             jl Label8afe09
             ;; vfpa_fclose(hfoxfiledbf_tmp).
             mov ecx , dword ptr [ ebp - 0C8h ][-0E0h][00h]
             call Fun42ddf2
             mov dword ptr [ ebp - 0C8h ][-0E0h][00h] , 0FFFFFFFFh

     Label8afe09 ::
             cmp dword ptr [ ebp - 0C8h ][-0F0h][00h] , 00h
             jl Label8afe0a
             ;; vfpa_fclose(hfoxfilefpt_tmp).
             mov ecx , dword ptr [ ebp - 0C8h ][-0F0h][00h]
             call Fun42ddf2
             mov dword ptr [ ebp - 0C8h ][-0F0h][00h] , 0FFFFFFFFh


     Label8afe0a ::
             lea eax ,  dword ptr [ ebp - 16 ]                               ;0x008afe0a :        8d45f0
             push eax                                                        ;0x008afe0d :        50
             lea eax ,  dword ptr [ ebp + 0FFFFFF3Ch ]                       ;0x008afe0e :        8d853cffffff
             call Fun42d200                                                  ;0x008afe14 :        e8e7d3b7ff


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

             cmp dword ptr [ ebp - 0C8h ][-0E0h][00h] , 00h
             jl Label8afe18
             ;; vfpa_fclose(hfoxfiledbf_tmp).
             mov ecx , dword ptr [ ebp - 0C8h ][-0E0h][00h]
             call Fun42ddf2
             mov dword ptr [ ebp - 0C8h ][-0E0h][00h] , 0FFFFFFFFh

     Label8afe18 ::
             cmp dword ptr [ ebp - 0C8h ][-0F0h][00h] , 00h
             jl Label8afe19
             ;; vfpa_fclose(hfoxfiledbf_tmp).
             mov ecx , dword ptr [ ebp - 0C8h ][-0F0h][00h]
             call Fun42ddf2
             mov dword ptr [ ebp - 0C8h ][-0F0h][00h] , 0FFFFFFFFh


     Label8afe19 ::
             mov ecx , esi                                                   ;0x008afe19 :        8bce
             call Fun43f9b2                                                  ;0x008afe1b :        e892fbb8ff
             mov  ecx , dword ptr [ Data937794 ]                             ;0x008afe20 :        8b0d94779300
             xor edx , edx                                                   ;0x008afe26 :        33d2
             inc edx                                                         ;0x008afe28 :        42
             call Fun4e9e08                                                  ;0x008afe29 :        e8da9fc3ff

     Label8afe2e ::
             mov  ecx , dword ptr [ ebp - 24 ]                               ;0x008afe2e :        8b4de8
             call Fun42c1e2                                                  ;0x008afe31 :        e8acc3b7ff

     Label8afe36 ::
             pop edi                                                         ;0x008afe36 :        5f
             pop esi                                                         ;0x008afe37 :        5e
             pop ebx                                                         ;0x008afe38 :        5b
             leave                                                           ;0x008afe39 :        c9
             ret 0Ch                                                         ;0x008afe3a :        c20c00


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 memo 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 memo function, please refer to the following pseudo code:
     ;
     ; * temp.dbf is a temporary file name, for example, 000001aa000a.tmp.
     ; * temp.fpt is a temporary file name, for example, 000001aa000b.tmp.
     ;
     ; use test.dbf
     ; flush file test.dbf
     ; flush file test.fpt
     ;
     ; * copy to the backup files temp.dbf and temp.fpt:
     ; copy file test.dbf to temp.dbf
     ; copy file test.fpt to temp.fpt
     ; flush file temp.dbf
     ; flush file temp.fpt
     ;
     ; packmemocnt = 0
     ;
     ; start:
     ;
     ;    * the first pack memo
     ;    pack memo
     ;    flush file test.dbf
     ;    flush file test.fpt
     ;
     ;    if there are some errors in the first pack memo, goto error.
     ;
     ;    * the second pack memo
     ;    pack memo && if there is no any error in the first pack memo, it's very fast in the second pack memo.
     ;    flush file test.dbf
     ;    flush file test.fpt
     ;
     ;    if there are some errors in the second pack memo, goto error.
     ;
     ;    * if there is no any error in the first pack memo and the second pack memo, it's normal.
     ;    goto end
     ;
     ; error:
     ;
     ;    * restore the files test.dbf and test.fpt from the backup files:
     ;    copy file temp.dbf to test.dbf
     ;    copy file temp.fpt to test.fpt
     ;    flush file test.dbf
     ;    flush file test.fpt
     ;
     ;    packmemocnt = packmemocnt + 1 
     ;
     ;    if packmemocnt < SYS(9049) goto start && if pack memo failed, it will try many (SYS(9049)) times again.
     ;
     ;    * if it has tried many (SYS(9049)) times, but it always pack memo failed,
     ;    * there is no any changes for the files test.dbf and test.fpt,
     ;    * we will not lose any data.
     ;    goto end
     ;
     ; end:
     ;
     ; * delete backup files:
     ; delete file temp.dbf
     ; delete file temp.fpt
     ;
     ; * if the computer turns off or the program crashes when packing memo,
     ; * we can restore the files test.dbf and test.fpt from the backup files manually,
     ; * we will not lose any data.


5. REFERENCE WEBSITES:

     1, baiyujia.com:
     http://www.baiyujia.com
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix149.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix68.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix65.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix66.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_vfp9fix147.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix148.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

     2, microsoft.com:
     https://social.msdn.microsoft.com/Forums/en-US/38eadf8b-d801-421e-9f71-c01a76e79864/memo-file-is-missing-or-invalid
     https://social.msdn.microsoft.com/Forums/en-US/b8be4748-6089-4451-bd79-a76b9b6d02c6/random-memo-file-sct-is-missing-or-invalid
     https://social.msdn.microsoft.com/forums/en-US/bc41018b-1446-4641-999e-d9d62ee0b242/memo-file-csct-missing-or-invalid
     https://social.msdn.microsoft.com/Forums/en-US/9c802b90-8420-4a94-9184-45c048b83c38/vfp-90-on-window-7-memo-file-missing-or-invalid
     https://social.msdn.microsoft.com/forums/en-US/62df884d-9012-42ed-a51d-0c3f0e8fd3e7/error-41-in-intstyle-0-memo-file

     3, foxite.com:
     https://www.foxite.com/archives/memo-file-myporjectpjt-is-missing-or-invalid-0000092755.htm
     https://www.foxite.com/archives/memo-file-is-missing-or-invalid-0000034237.htm
     https://www.foxite.com/archives/invalid-memo-file-under-w7-0000255749.htm
     https://www.foxite.com/archives/can-not-modify-form-0000293924.htm
     https://www.foxite.com/archives/compilation-problem-0000385161.htm
     https://www.foxite.com/archives/corrupted-scx-file-0000105795.htm
     https://www.foxite.com/archives/form-corruption-0000129626.htm

     4, computer-programming-forum.com:
     http://computer-programming-forum.com/2-vfp/d6fcb9125c0c971b.htm
     http://computer-programming-forum.com/2-vfp/805f3de4e248b6a8.htm
     http://computer-programming-forum.com/2-vfp/2909fea7b6c93556.htm

     5, tek-tips.com:
     https://www.tek-tips.com/viewthread.cfm?qid=413823
     https://www.tek-tips.com/viewthread.cfm?qid=1777994
     https://www.tek-tips.com/viewthread.cfm?qid=1513567

     6, experts-exchange.com:
     https://www.experts-exchange.com/questions/27433514/Visual-Foxpro-sct-is-missing-or-invalid.html
     https://www.experts-exchange.com/questions/26815464/Memo-File-missing-or-Invalid-in-VFP-6-0.html

     7, narkive.com:
     https://microsoft.public.fox.programmer.exchange.narkive.com/X2csYw5C/memo-file-is-missing-invalid-error-behavior-in-vfp9
     https://microsoft.public.fox.programmer.exchange.narkive.com/77JsOqgj/memory-file-is-invalid
     https://microsoft.public.fox.vfp.oop.narkive.com/wxEG22NS/how-to-repair-a-corrupted-class-library
     https://microsoft.public.fox.helpwanted.narkive.com/PdHvUB2C/cannot-open-form-due-to-error-of-memo-file


6. OTHER:

     For reference only, there is no guarantees.

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