-------------------------------------------------
                        VFP 9.0 FIX - RETURN TO COMMAND
                                 January 2019
                 -------------------------------------------------
                                     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.

     Fun53e674 :: ; proc near
             push ecx                                                        ;0x0053e674 :        51
             mov eax ,  dword ptr [ Data939568 ]                             ;0x0053e675 :        a168959300
             push ebx                                                        ;0x0053e67a :        53
             push esi                                                        ;0x0053e67b :        56
             push edi                                                        ;0x0053e67c :        57
             xor edi , edi                                                   ;0x0053e67d :        33ff
             test eax , eax                                                  ;0x0053e67f :        85c0
             jne Label58688c                                                 ;0x0053e681 :        0f8505820400

     Label53e687 ::
             mov eax ,  dword ptr [ Data9370e8 ]                             ;0x0053e687 :        a1e8709300
             mov  cl , byte ptr [ eax + 28 ]                                 ;0x0053e68c :        8a481c
             mov bl , 04h                                                    ;0x0053e68f :        b304
             test bl , cl                                                    ;0x0053e691 :        84cb
             jne Label5868c9                                                 ;0x0053e693 :        0f8530820400
             call Fun54f6e2                                                  ;0x0053e699 :        e844100100


     ;
     ;                 -------------------------------------------------
     ;                        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
     ;

             cmp dword ptr vfpa_returnto_isreturnto,01h
             jne Label53e69e
             mov dword ptr vfpa_returnto_isreturnto,00h
             cmp eax,63h
             jne Label53e69e
             xor eax,eax


     Label53e69e ::
             mov  esi , dword ptr [ Data9370e8 ]                             ;0x0053e69e :        8b35e8709300
             mov edi , eax                                                   ;0x0053e6a4 :        8bf8

     Label53e6a6 ::
             mov  ebx , dword ptr [ esp + 20 ]                               ;0x0053e6a6 :        8b5c2414
             xor ecx , ecx                                                   ;0x0053e6aa :        33c9
             test ebx , ebx                                                  ;0x0053e6ac :        85db
             sete cl                                                         ;0x0053e6ae :        0f94c1
             push esi                                                        ;0x0053e6b1 :        56
             mov  byte ptr [ Data93da78 ] , bl                               ;0x0053e6b2 :        881d78da9300
             mov  dword ptr [ Data93da74 ] , ecx                             ;0x0053e6b8 :        890d74da9300
             call Fun549573                                                  ;0x0053e6be :        e8b0ae0000
             test edi , edi                                                  ;0x0053e6c3 :        85ff
             jne Label58690e                                                 ;0x0053e6c5 :        0f8543820400
             test ebx , ebx                                                  ;0x0053e6cb :        85db
             jne Label53e6e4                                                 ;0x0053e6cd :        7515
             cmp  word ptr [ Data937100 ] , bx                               ;0x0053e6cf :        66391d00719300
             jne Label53e6e4                                                 ;0x0053e6d6 :        750c
             mov  edx , dword ptr [ esi + 20 ]                               ;0x0053e6d8 :        8b5614
             cmp  edx , dword ptr [ esi + 76 ]                               ;0x0053e6db :        3b564c
             je Label53f564                                                  ;0x0053e6de :        0f84800e0000

     Label53e6e4 ::
             mov eax ,  dword ptr [ Data937220 ]                             ;0x0053e6e4 :        a120729300
             test eax , eax                                                  ;0x0053e6e9 :        85c0
             je Label53e6f9                                                  ;0x0053e6eb :        740c
             lea edi ,  dword ptr [ esi + 56 ]                               ;0x0053e6ed :        8d7e38

     Label53e6f0 ::
             cmp  dword ptr [ eax + 72 ] , edi                               ;0x0053e6f0 :        397848
             jnb Label586915                                                 ;0x0053e6f3 :        0f831c820400

     Label53e6f9 ::
             mov  ecx , dword ptr [ esi + 76 ]                               ;0x0053e6f9 :        8b4e4c
             pushd 01h                                                       ;0x0053e6fc :        6a01
             call Fun543c69                                                  ;0x0053e6fe :        e866550000

     Label53e703 ::
             test eax , eax                                                  ;0x0053e703 :        85c0
             jne Label53e6f0                                                 ;0x0053e705 :        75e9
             jmp Label53e6f9                                                 ;0x0053e707 :        ebf0

     Label53f564 ::
             mov eax ,  dword ptr [ Data9393ac ]                             ;0x0053f564 :        a1ac939300
             mov  al , byte ptr [eax]                                        ;0x0053f569 :        8a00
             cmp al , 0FBh                                                   ;0x0053f56b :        3cfb
             je Label53e6e4                                                  ;0x0053f56d :        0f8471f1ffff
             cmp al , 055h                                                   ;0x0053f573 :        3c55
             je Label53e6e4                                                  ;0x0053f575 :        0f8469f1ffff
             pop edi                                                         ;0x0053f57b :        5f
             pop esi                                                         ;0x0053f57c :        5e
             pop ebx                                                         ;0x0053f57d :        5b
             pop ecx                                                         ;0x0053f57e :        59
             ret 04h                                                         ;0x0053f57f :        c20400


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.