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



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), somtimes the open table file command runs failed on Windows Vista or later.


2. CAUSE:

     There are some compatible problems when the open table file command calls the CreateFileA Windows API
     for the Windows Defender program or the antivirus programs.
     Now if the open table file command calls the CreateFileA Windows API failed,
     it will call the CreateFileA Windows API many times again.

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun41f9b6 :: ; proc near
             push ebp                                                        ;0x0041f9b6 :        55
             mov ebp , esp                                                   ;0x0041f9b7 :        8bec
             sub esp , 080h                                                  ;0x0041f9b9 :        81ec80000000
             push ebx                                                        ;0x0041f9bf :        53
             mov  ebx , dword ptr [ ebp + 16 ]                               ;0x0041f9c0 :        8b5d10
             push esi                                                        ;0x0041f9c3 :        56
             push edi                                                        ;0x0041f9c4 :        57
             mov  edi , dword ptr [ ebp + 8 ]                                ;0x0041f9c5 :        8b7d08
             and ebx , 0205h                                                 ;0x0041f9c8 :        81e305020000
             or ebx , 01000h                                                 ;0x0041f9ce :        81cb00100000


     ;
     ;                 -------------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - THE NUMBER OF TIMES TO TRY AGAIN AFTER OPEN TABLE FILE FAILED
     ;                                  March 2023
     ;                 -------------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; The number of times to try again after open table file failed.
     ;
     ; 2023/3/26, by ccb
     ;

     ;         mov dword ptr vfpa_opentablefile_isopentablefile,01h


             mov edx , ebx                                                   ;0x0041f9d4 :        8bd3
             mov ecx , edi                                                   ;0x0041f9d6 :        8bcf
             mov  dword ptr [ ebp - 12 ] , 00h                               ;0x0041f9d8 :        c745f400000000
             call Fun42ce21                                                  ;0x0041f9df :        e83dd40000


     ;
     ;                 -------------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - THE NUMBER OF TIMES TO TRY AGAIN AFTER OPEN TABLE FILE FAILED
     ;                                  March 2023
     ;                 -------------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; The number of times to try again after open table file failed.
     ;
     ; 2023/3/26, by ccb
     ;

     Label41f9e3 ::
     ;         mov dword ptr vfpa_opentablefile_isopentablefile,00h


     Label41f9e4 ::
             mov esi , eax                                                   ;0x0041f9e4 :        8bf0
             test esi , esi                                                  ;0x0041f9e6 :        85f6
             jl Label4bb9a9                                                  ;0x0041f9e8 :        0f8cbbbf0900

     Label41f9ee ::
             mov  eax , dword ptr [ ebp + 16 ]                               ;0x0041f9ee :        8b4510
             mov  ecx , dword ptr [ ebp + 12 ]                               ;0x0041f9f1 :        8b4d0c
             push eax                                                        ;0x0041f9f4 :        50
             push ecx                                                        ;0x0041f9f5 :        51
             push esi                                                        ;0x0041f9f6 :        56
             push edi                                                        ;0x0041f9f7 :        57
             call Fun41f590                                                  ;0x0041f9f8 :        e893fbffff
             mov  dword ptr [ ebp - 8 ] , eax                                ;0x0041f9fd :        8945f8
             lea edx ,  dword ptr [ ebp - 20 ]                               ;0x0041fa00 :        8d55ec
             lea eax ,  dword ptr [ ebp - 124 ]                              ;0x0041fa03 :        8d4584
             call Fun42c27f                                                  ;0x0041fa06 :        e874c80000
             pushd 00h                                                       ;0x0041fa0b :        6a00
             push eax                                                        ;0x0041fa0d :        50
             call Fun42c2be                                                  ;0x0041fa0e :        e8abc80000
             mov esi , eax                                                   ;0x0041fa13 :        8bf0
             add esp , 08h                                                   ;0x0041fa15 :        83c408
             test esi , esi                                                  ;0x0041fa18 :        85f6
             mov  dword ptr [ ebp - 16 ] , esi                               ;0x0041fa1a :        8975f0
             jne Label6198e9                                                 ;0x0041fa1d :        0f85c69e1f00
             mov  ebx , dword ptr [ ebp + 8 ]                                ;0x0041fa23 :        8b5d08
             mov  eax , dword ptr [ ebx + 0108h ]                            ;0x0041fa26 :        8b8308010000
             test eax , eax                                                  ;0x0041fa2c :        85c0
             jne Label4ab1f7                                                 ;0x0041fa2e :        0f85c3b70800

     Label41fa34 ::
             mov edi , ebx                                                   ;0x0041fa34 :        8bfb
             mov  ebx , dword ptr [ ebp - 8 ]                                ;0x0041fa36 :        8b5df8
             call Fun41f971                                                  ;0x0041fa39 :        e833ffffff
             mov edi , ebx                                                   ;0x0041fa3e :        8bfb
             mov ecx , edi                                                   ;0x0041fa40 :        8bcf
             call Fun41fa8d                                                  ;0x0041fa42 :        e846000000

     Label41fa47 ::
             mov  ecx , dword ptr [ Data937220 ]                             ;0x0041fa47 :        8b0d20729300
             lea eax ,  dword ptr [ ebp - 124 ]                              ;0x0041fa4d :        8d4584
             cmp eax , ecx                                                   ;0x0041fa50 :        3bc1
             jne Label6198f1                                                 ;0x0041fa52 :        0f85999e1f00
             mov  ecx , dword ptr [ Data937220 ]                             ;0x0041fa58 :        8b0d20729300
             mov  eax , dword ptr [ ecx + 76 ]                               ;0x0041fa5e :        8b414c
             cmp  dword ptr [ ebp - 20 ] , eax                               ;0x0041fa61 :        3945ec
             mov dword ptr [ Data937220 ] ,  eax                             ;0x0041fa64 :        a320729300
             jne Label6198fb                                                 ;0x0041fa69 :        0f858c9e1f00
             mov  eax , dword ptr [ ebp - 12 ]                               ;0x0041fa6f :        8b45f4
             test eax , eax                                                  ;0x0041fa72 :        85c0
             jne Label619905                                                 ;0x0041fa74 :        0f858b9e1f00

     Label41fa7a ::
             test esi , esi                                                  ;0x0041fa7a :        85f6
             jne Label61994e                                                 ;0x0041fa7c :        0f85cc9e1f00
             mov eax , edi                                                   ;0x0041fa82 :        8bc7
             pop edi                                                         ;0x0041fa84 :        5f
             pop esi                                                         ;0x0041fa85 :        5e
             pop ebx                                                         ;0x0041fa86 :        5b
             mov esp , ebp                                                   ;0x0041fa87 :        8be5
             pop ebp                                                         ;0x0041fa89 :        5d
             ret 0Ch                                                         ;0x0041fa8a :        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.


5. REFERENCE WEBSITES:

     1, baiyujia.com:
     http://www.baiyujia.com
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix261.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_vfp9fix147.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix148.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_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

     2, microsoft.com:
     https://devblogs.microsoft.com/oldnewthing/20120907-00/?p=6663

     3, foxite.com:
     https://www.foxite.com/archives/error-111-after-zap-0000493590.htm
     https://www.foxite.com/archives/intermittent-error-111-0000406044.htm


6. OTHER:

     For reference only, there is no guarantees.

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