------------------------------------------------------------
                        [BUG/PRB.] VFP 9.0 FIX - SYS(2901) FUNCTION
                               January 2024
                 ------------------------------------------------------------
                                     CCB



1. BUG:

     In vfp9 (and vfp8, vfp7), sometimes vfp will crash when calling the SYS(2901) function.

     There is a test program:

     *PROC testsys2901function

     FOR n1=0 TO 0xffff
        ?TRANSFORM(n1,"@0")+" "+SYS(2901,n1)
        =INKEY(0.01)
     ENDFOR

     RETURN

     * END OF PROC TESTSYS2901FUNCTION.

     Sometimes vfp will crash.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label60a3cb ::
             call Fun7989a9                                                  ;0x0060a3cb :        e8d9e51800
             test eax , eax                                                  ;0x0060a3d0 :        85c0
             je Label52a11a                                                  ;0x0060a3d2 :        0f8442fdf1ff
             cmp  dword ptr [ ebp + 12 ] , 02h                               ;0x0060a3d8 :        837d0c02
             jne Label52a11a                                                 ;0x0060a3dc :        0f8538fdf1ff
             lea edi ,  dword ptr [ ebx + 44 ]                               ;0x0060a3e2 :        8d7b2c
             call Fun529a6e                                                  ;0x0060a3e5 :        e884f6f1ff
             wait                                                            ;0x0060a3ea :        9b
             mov  dword ptr [ ebp - 4 ] , 01h                                ;0x0060a3eb :        c745fc01000000
             mov  ecx , dword ptr [ ebx + 56 ]                               ;0x0060a3f2 :        8b4b38
             call Fun42c583                                                  ;0x0060a3f5 :        e88921e2ff
             lea ecx ,  dword ptr [ ebp + 0FFFFFDE0h ]                       ;0x0060a3fa :        8d8de0fdffff


     ;
     ;                 -------------------------------------------------
     ;                        VFP 9.0 FIX - SYS(2901) FUNCTION
     ;                                   May 2021
     ;                 -------------------------------------------------
     ;                                     CCB
     ;
     ; Sometimes vfp will crash when calling the SYS(2901) function.
     ;
     ; 2021/5/28, by ccb
     ;

     ;         push ecx                                                        ;0x0060a400 :        51
     ;         call Fun425524                                                  ;0x0060a401 :        e81eb1e1ff
     ;         pop ecx                                                         ;0x0060a406 :        59
             push 0FFh
             push eax
             push ecx
             call  dword ptr [ Data9392b8 ]
             add esp , 0Ch
             mov  byte ptr [ ebp + 0FFFFFEDFh ] , 00h


             wait                                                            ;0x0060a407 :        9b
             or  dword ptr [ ebp - 4 ] , 0FFFFFFFFh                          ;0x0060a408 :        834dfcff
             jmp Label52a11a                                                 ;0x0060a40c :        e909fdf1ff


4. APPLIES TO:

     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_vfpsysfunctions.asp

     2, sweetpotatosoftware.com:
     https://www.sweetpotatosoftware.com/blog/index.php/2005/08/15/undocument-sys-functions/


6. OTHER:

     For reference only, there is no guarantees.

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