------------------------------------------------------------
                         [BUG/PRB.] VFP 9.0 FIX - GETPEM() Function
                                 January 2024
                 ------------------------------------------------------------
                                    CCB



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), the GETPEM() function can not return the user-defined method code in a program (.prg) file.

     The bug was reported by xinjie.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label5ba392 ::
             mov  ecx , dword ptr [ esp + 8 ]                                ;0x005ba392 :        8b4c2408
             pushd 0FFFFFFFFh                                                ;0x005ba396 :        6aff
             lea eax ,  dword ptr [ esp + 16 ]                               ;0x005ba398 :        8d442410
             push eax                                                        ;0x005ba39c :        50
             push esi                                                        ;0x005ba39d :        56
             pushd 00h                                                       ;0x005ba39e :        6a00
             pushd 0FFFFFFFFh                                                ;0x005ba3a0 :        6aff
             push ecx                                                        ;0x005ba3a2 :        51
             mov edi , 020h                                                  ;0x005ba3a3 :        bf20000000
             push edx                                                        ;0x005ba3a8 :        52
             mov  dword ptr [ esp + 40 ] , edi                               ;0x005ba3a9 :        897c2428
             call Fun433a39                                                  ;0x005ba3ad :        e88796e7ff
             mov  eax , dword ptr [ esp + 40 ]                               ;0x005ba3b2 :        8b442428
             add esp , 01Ch                                                  ;0x005ba3b6 :        83c41c
             cmp eax , edi                                                   ;0x005ba3b9 :        3bc7
             jne Label5ba3cc                                                 ;0x005ba3bb :        750f


     ;
     ;                 -------------------------------------------------
     ;                         VFP 9.0 FIX - GETPEM() Function
     ;                                November 2017
     ;                 -------------------------------------------------
     ;                                     CCB
     ;
     ; Returns the user-defined method code in a program (.prg) file.
     ;
     ; 2017/11/13, by ccb
     ;

             cmp dword ptr vfpa_sys9110_data,00h
             je Label5ba3bd
             cmp dword ptr [ esp + 4 ] , offset Label8e5024 ;; Fun8e4f83 .. ; proc near
             je Label5ba3bc
             cmp dword ptr [ esp + 4 ] , offset Label8e506f ;; Fun8e4f83 .. ; proc near
             je Label5ba3bc
             jmp Label5ba3bd
     Label5ba3bc ::
             cmp  dword ptr [ esi + 4 ] , 0FFFFFFFFh
             jne Label5ba3c3
             cmp  dword ptr [ esi + 16 ] , 00h
             jne Label5ba3c3
             jmp Label5ba3cc


     Label5ba3bd ::
             cmp  dword ptr [ esi + 4 ] , 0FFFFFFFFh                         ;0x005ba3bd :        837e04ff
             je Label5ba3cc                                                  ;0x005ba3c1 :        7409

     Label5ba3c3 ::
             mov eax , 01h                                                   ;0x005ba3c3 :        b801000000
             pop edi                                                         ;0x005ba3c8 :        5f
             ret 08h                                                         ;0x005ba3c9 :        c20800


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

     2, tek-tips.com:
     http://www.tek-tips.com/viewthread.cfm?qid=1283345

     3, foxite.com:
     https://www.foxite.com/archives/to-find-out-if-there-is-code-in-subclass-0000398070.htm


6. OTHER:

     For reference only, there is no guarantees.

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