-------------------------------------------------
                        VFP 9.0 FIX - RETURN TO COMMAND
                                 January 2018
                 -------------------------------------------------
                                     CCB



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), if we use the RETURN TO command in the Destroy event code, sometimes it can not return to the specified procedure.

     The bug was reported by Tomas Tamm.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label58681a ::
             lea esi ,  dword ptr [ esp + 16 ]                               ;0x0058681a :        8d742410
             call Fun42107e                                                  ;0x0058681e :        e85ba8e9ff
             mov eax ,  dword ptr [ Data9370e8 ]                             ;0x00586823 :        a1e8709300
             mov  edx , dword ptr [ Data937104 ]                             ;0x00586828 :        8b1504719300
             add eax , 0FFFFFFC8h                                            ;0x0058682e :        83c0c8
             add edx , 038h                                                  ;0x00586831 :        83c238
             cmp eax , edx                                                   ;0x00586834 :        3bc2
             jbe Label586855                                                 ;0x00586836 :        761d
             mov  esi , dword ptr [ esp + 20 ]                               ;0x00586838 :        8b742414
             mov edi , edi                                                   ;0x0058683c :        8bff

     Label58683e ::
             mov  ecx , dword ptr [ eax + 4 ]                                ;0x0058683e :        8b4804
             mov  edi , dword ptr [eax]                                      ;0x00586841 :        8b38
             mov  edi , dword ptr [edi]                                      ;0x00586843 :        8b3f
             lea ecx ,  dword ptr [ ecx + 4 * ecx ]                          ;0x00586845 :        8d0c89
             cmp  dword ptr [ edi + 4 * ecx + 76 ] , esi                     ;0x00586848 :        39748f4c
             je Label586855                                                  ;0x0058684c :        7407
             sub eax , 038h                                                  ;0x0058684e :        83e838
             cmp eax , edx                                                   ;0x00586851 :        3bc2
             ja Label58683e                                                  ;0x00586853 :        77e9

     Label586855 ::


     ;
     ;                 -------------------------------------------------
     ;                        VFP 9.0 FIX - RETURN TO COMMAND
     ;                                December 2017
     ;                 -------------------------------------------------
     ;                                     CCB
     ;
     ; In vfp9, sometimes the RETURN TO command can not return to the specified procedure.
     ;
     ; 2017/12/8, by ccb
     ;

             mov dword ptr vfpa_returnto_isreturnto,01h


             add eax , 038h                                                  ;0x00586855 :        83c038
             mov dword ptr [ Data942688 ] ,  eax                             ;0x00586858 :        a388269400
             call Fun550bf2                                                  ;0x0058685d :        e890a3fcff
             pushd 00h                                                       ;0x00586862 :        6a00
             mov  dword ptr [ Data946e60 ] , 00h                             ;0x00586864 :        c705606e940000000000
             call Fun53e674                                                  ;0x0058686e :        e8017efbff
             pop edi                                                         ;0x00586873 :        5f
             pop esi                                                         ;0x00586874 :        5e
             pop ebx                                                         ;0x00586875 :        5b
             add esp , 030h                                                  ;0x00586876 :        83c430
             ret                                                             ;0x00586879 :        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


6. OTHER:

     For reference only, there is no guarantees.

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