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



1. BUG:

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


2. CAUSE:

     There are some compatible problems when the FCREATE() function calls the CreateFileA Windows API
     for the Windows Defender program or the antivirus programs.
     Now if the FCREATE() function 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.

     Label449c4e ::
             push ebp                                                        ;0x00449c4e :        55
             lea ebp ,  dword ptr [ esp + 0FFFFFDBCh ]                       ;0x00449c4f :        8dac24bcfdffff
             sub esp , 02C4h                                                 ;0x00449c56 :        81ecc4020000
             mov eax ,  dword ptr [ Data937090 ]                             ;0x00449c5c :        a190709300
             push ebx                                                        ;0x00449c61 :        53
             push esi                                                        ;0x00449c62 :        56
             xor ebx , ebx                                                   ;0x00449c63 :        33db
             push edi                                                        ;0x00449c65 :        57
             mov  dword ptr [ ebp + 0240h ] , eax                            ;0x00449c66 :        898540020000
             mov  word ptr [ Data93bc88 ] , bx                               ;0x00449c6c :        66891d88bc9300
             call Fun420d8c                                                  ;0x00449c73 :        e81471fdff
             cmp  dword ptr [ Data936f1c ] , 01h                             ;0x00449c78 :        833d1c6f930001
             mov  dword ptr [ ebp + 48 ] , eax                               ;0x00449c7f :        894530
             mov edi , 0100h                                                 ;0x00449c82 :        bf00010000
             jg Label60c554                                                  ;0x00449c87 :        0f8fc7281c00
             mov  byte ptr [ ebp + 55 ] , bl                                 ;0x00449c8d :        885d37

     Label449c90 ::
             mov  eax , dword ptr [ ebp + 48 ]                               ;0x00449c90 :        8b4530
             call Fun42371d                                                  ;0x00449c93 :        e8859afdff
             mov  edx , dword ptr [ ebp + 48 ]                               ;0x00449c98 :        8b5530
             lea ebx ,  dword ptr [ ebp + 0140h ]                            ;0x00449c9b :        8d9d40010000
             call Fun52b398                                                  ;0x00449ca1 :        e8f2160e00
             xor ebx , ebx                                                   ;0x00449ca6 :        33db
             push ebx                                                        ;0x00449ca8 :        53
             push ebx                                                        ;0x00449ca9 :        53
             pushd offset Data91aed0                                                  ;0x00449caa :        68d0ae9100
             push edi                                                        ;0x00449caf :        57
             lea eax ,  dword ptr [ ebp + 0140h ]                            ;0x00449cb0 :        8d8540010000
             push eax                                                        ;0x00449cb6 :        50
             call Fun437e2a                                                  ;0x00449cb7 :        e86ee1feff
             push eax                                                        ;0x00449cbc :        50
             lea edx ,  dword ptr [ ebp + 0140h ]                            ;0x00449cbd :        8d9540010000
             lea ecx ,  dword ptr [ ebp + 56 ]                               ;0x00449cc3 :        8d4d38
             call Fun42cc34                                                  ;0x00449cc6 :        e8692ffeff
             push ebx                                                        ;0x00449ccb :        53
             lea eax ,  dword ptr [ ebp + 56 ]                               ;0x00449ccc :        8d4538
             call Fun42d5e0                                                  ;0x00449ccf :        e80c39feff
             test eax , eax                                                  ;0x00449cd4 :        85c0
             jne Label60c66e                                                 ;0x00449cd6 :        0f8592291c00
             push ebx                                                        ;0x00449cdc :        53
             lea eax ,  dword ptr [ ebp + 56 ]                               ;0x00449cdd :        8d4538
             push eax                                                        ;0x00449ce0 :        50
             call Fun42c9be                                                  ;0x00449ce1 :        e8d82cfeff
             test eax , eax                                                  ;0x00449ce6 :        85c0
             jne Label60c60d                                                 ;0x00449ce8 :        0f851f291c00

     Label449cee ::
             lea edx ,  dword ptr [ ebp + 36 ]                               ;0x00449cee :        8d5524
             lea eax ,  dword ptr [ ebp - 128 ]                              ;0x00449cf1 :        8d4580
             call Fun42c27f                                                  ;0x00449cf4 :        e88625feff
             push ebx                                                        ;0x00449cf9 :        53
             push eax                                                        ;0x00449cfa :        50
             call Fun42c2be                                                  ;0x00449cfb :        e8be25feff
             cmp eax , ebx                                                   ;0x00449d00 :        3bc3
             pop ecx                                                         ;0x00449d02 :        59
             pop ecx                                                         ;0x00449d03 :        59
             mov  dword ptr [ ebp + 40 ] , eax                               ;0x00449d04 :        894528
             jne Label449d1f                                                 ;0x00449d07 :        7516
             xor edx , edx                                                   ;0x00449d09 :        33d2
             cmp  byte ptr [ ebp + 55 ] , bl                                 ;0x00449d0b :        385d37


     ;
     ;                 ---------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - THE NUMBER OF TIMES TO TRY AGAIN AFTER CREATE FILE FAILED
     ;                                September 2024
     ;                 ---------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; The number of times to try again after create file (FCREATE() function) failed.
     ;
     ; 2024/9/19, by ccb
     ;

     ;         mov dword ptr vfpa_createfile_iscreatefile,01h


             lea ecx ,  dword ptr [ ebp + 56 ]                               ;0x00449d0e :        8d4d38
             setne dl                                                        ;0x00449d11 :        0f95c2
             or edx , 02Ch                                                   ;0x00449d14 :        83ca2c
             call Fun42ce21                                                  ;0x00449d17 :        e80531feff


     ;
     ;                 ---------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - THE NUMBER OF TIMES TO TRY AGAIN AFTER CREATE FILE FAILED
     ;                                September 2024
     ;                 ---------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; The number of times to try again after create file (FCREATE() function) failed.
     ;
     ; 2024/9/19, by ccb
     ;

     Label449d1b ::
     ;         mov dword ptr vfpa_createfile_iscreatefile,00h


     Label449d1c ::
             mov  dword ptr [ ebp + 44 ] , eax                               ;0x00449d1c :        89452c

     Label449d1f ::
             lea eax ,  dword ptr [ ebp + 36 ]                               ;0x00449d1f :        8d4524
             push eax                                                        ;0x00449d22 :        50
             lea eax ,  dword ptr [ ebp - 128 ]                              ;0x00449d23 :        8d4580
             call Fun42d200                                                  ;0x00449d26 :        e8d534feff
             cmp  dword ptr [ ebp + 40 ] , ebx                               ;0x00449d2b :        395d28
             jne Label60c61e                                                 ;0x00449d2e :        0f85ea281c00
             cmp  byte ptr [ ebp + 55 ] , bl                                 ;0x00449d34 :        385d37
             jne Label60c65a                                                 ;0x00449d37 :        0f851d291c00

     Label449d3d ::
             mov  eax , dword ptr [ ebp + 48 ]                               ;0x00449d3d :        8b4530
             mov  ecx , dword ptr [ ebp + 44 ]                               ;0x00449d40 :        8b4d2c
             mov  dword ptr [ eax + 12 ] , ecx                               ;0x00449d43 :        89480c
             mov  byte ptr [eax] , 049h                                      ;0x00449d46 :        c60049
             mov  dword ptr [ eax + 4 ] , 0Ah                                ;0x00449d49 :        c740040a000000

     Label449d50 ::
             mov  ecx , dword ptr [ ebp + 0240h ]                            ;0x00449d50 :        8b8d40020000
             call Fun42bf1d                                                  ;0x00449d56 :        e8c221feff
             pop edi                                                         ;0x00449d5b :        5f
             pop esi                                                         ;0x00449d5c :        5e
             pop ebx                                                         ;0x00449d5d :        5b
             add ebp , 0244h                                                 ;0x00449d5e :        81c544020000
             leave                                                           ;0x00449d64 :        c9
             ret                                                             ;0x00449d65 :        c3


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_vfp9fix348.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_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_vfp9fix350.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix351.asp

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


6. OTHER:

     For reference only, there is no guarantees.

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