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



1. BUG:

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


2. CAUSE:

     There are some compatible problems when the MKDIR (or MD) command calls the _mkdir Windows API
     for the Windows Defender program or the antivirus programs.
     Now if the MKDIR (or MD) command calls the _mkdir Windows API failed,
     it will call the _mkdir Windows API many times again.

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label4ba8e9 ::
             push ebp                                                        ;0x004ba8e9 :        55
             mov ebp , esp                                                   ;0x004ba8ea :        8bec
             and esp , 0FFFFFFF8h                                            ;0x004ba8ec :        83e4f8
             sub esp , 0220h                                                 ;0x004ba8ef :        81ec20020000
             mov eax ,  dword ptr [ Data937090 ]                             ;0x004ba8f5 :        a190709300
             push esi                                                        ;0x004ba8fa :        56
             push edi                                                        ;0x004ba8fb :        57
             mov  dword ptr [ esp + 0224h ] , eax                            ;0x004ba8fc :        89842424020000
             pushd 00h                                                       ;0x004ba903 :        6a00
             lea eax ,  dword ptr [ esp + 20 ]                               ;0x004ba905 :        8d442414
             push eax                                                        ;0x004ba909 :        50
             mov eax , 0105h                                                 ;0x004ba90a :        b805010000
             call Fun5463b6                                                  ;0x004ba90f :        e8a2ba0800
             mov  al , byte ptr [ esp + 16 ]                                 ;0x004ba914 :        8a442410
             test al , al                                                    ;0x004ba918 :        84c0
             je Label59890f                                                  ;0x004ba91a :        0f84efdf0d00


     ;
     ;                 --------------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - THE NUMBER OF TIMES TO TRY AGAIN AFTER CREATE DIRECTORY FAILED
     ;                                  March 2019
     ;                 --------------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; The number of times to try again after create directory failed.
     ;
     ; 2019/3/6, by ccb
     ;

     ;         lea ecx ,  dword ptr [ esp + 16 ]                               ;0x004ba920 :        8d4c2410
     ;         push ecx                                                        ;0x004ba924 :        51
     ;         call  _mkdir                                      ;0x004ba925 :        ff1520799100
     ;         add esp , 04h                                                   ;0x004ba92b :        83c404
     ;         call Label42d319                                                ;0x004ba92e :        e8e629f7ff

             mov dword ptr vfpa_mkdir_mkdir_cnt,00h

     Label4ba920 ::
             lea ecx ,  dword ptr [ esp + 16 ]
             push ecx
             call  _mkdir
             add esp , 04h
             call Label42d319
             test eax , eax
             je Label4ba933
             cmp eax , 079h
             je Label4ba933
             mov ecx,dword ptr vfpa_sys9016_data
             inc dword ptr vfpa_mkdir_mkdir_cnt
             cmp dword ptr vfpa_mkdir_mkdir_cnt,ecx
             ja Label4ba933
             push dword ptr vfpa_sys9074_data
             call  Sleep
             jmp Label4ba920


     Label4ba933 ::
             test eax , eax                                                  ;0x004ba933 :        85c0
             je Label5989c2                                                  ;0x004ba935 :        0f8487e00d00
             xor esi , esi                                                   ;0x004ba93b :        33f6
             lea ebx ,  dword ptr [ebx]                                      ;0x004ba93d :        8d1b

     Label4ba93f ::
             mov  al , byte ptr [ esp + esi + 16 ]                           ;0x004ba93f :        8a443410
             test al , al                                                    ;0x004ba943 :        84c0
             je Label4ba96d                                                  ;0x004ba945 :        7426
             mov  al , byte ptr [ esp + esi + 17 ]                           ;0x004ba947 :        8a443411
             test al , al                                                    ;0x004ba94b :        84c0
             je Label4ba96c                                                  ;0x004ba94d :        741d
             mov  al , byte ptr [ esp + esi + 18 ]                           ;0x004ba94f :        8a443412
             test al , al                                                    ;0x004ba953 :        84c0
             je Label598919                                                  ;0x004ba955 :        0f84bedf0d00
             add esi , 03h                                                   ;0x004ba95b :        83c603
             cmp esi , 0105h                                                 ;0x004ba95e :        81fe05010000
             jnl Label598921                                                 ;0x004ba964 :        0f8db7df0d00
             jmp Label4ba93f                                                 ;0x004ba96a :        ebd3


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_vfp9fix71.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_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_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


6. OTHER:

     For reference only, there is no guarantees.

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