------------------------------------------------------------------------------------------------------------------
                      [BUG/PRB.] VFP 9.0 FIX - SET THE MAXIMUM BUFFER MEMORY SIZE TO THE MAXIMUM FOREGROUND BUFFER MEMORY SIZE
                               January 2024
                 ------------------------------------------------------------------------------------------------------------------
                                     CCB



1. BUG:

     If we enable setting the maximum buffer memory size to the maximum foreground buffer memory size,
     when Visual FoxPro is running in the foreground or the background (or no response),
     it always sets the maximum buffer memory size (SYS(1101)) to the maximum foreground buffer memory size (SYS(3050,1)),
     so it can use more memory, it will run faster.
     It is the startup default for Visual FoxPro Advanced.

     If we disable setting the maximum buffer memory size to the maximum foreground buffer memory size,
     when Visual FoxPro is running in the background (or no response),
     it sets the maximum buffer memory size (SYS(1101)) to the maximum background buffer memory size (SYS(3050,2)),
     so it can only use less memory, it will run slower.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun43b25a :: ; proc near
             push ecx                                                        ;0x0043b25a :        51
             test eax , eax                                                  ;0x0043b25b :        85c0
             mov  ecx , dword ptr [ Data9392fc ]                             ;0x0043b25d :        8b0dfc929300
             mov dword ptr [ Data9397f8 ] ,  eax                             ;0x0043b263 :        a3f8979300
             je Label45fe8d                                                  ;0x0043b268 :        0f841f4c0200

     Label43b26e ::
             mov eax ,  dword ptr [ Data937584 ]                             ;0x0043b26e :        a184759300
             cmp eax , ecx                                                   ;0x0043b273 :        3bc1
             mov  dword ptr [ Data9370d4 ] , ecx                             ;0x0043b275 :        890dd4709300
             ja Label5b3771                                                  ;0x0043b27b :        0f87f0841700

     Label43b281 ::
             pop ecx                                                         ;0x0043b281 :        59
             ret                                                             ;0x0043b282 :        c3

     Label45fe8d ::


     ;
     ;                 -------------------------------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - SET THE MAXIMUM BUFFER MEMORY SIZE TO THE MAXIMUM FOREGROUND BUFFER MEMORY SIZE
     ;                                  June 2020
     ;                 -------------------------------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; Set the maximum buffer memory size to the maximum foreground buffer memory size.
     ;
     ; 2020/6/29, by ccb
     ;

             cmp dword ptr vfpa_sys9033_data,00h
             jne Label43b26e


             mov  ecx , dword ptr [ Data933764 ]                             ;0x0045fe8d :        8b0d64379300
             jmp Label43b26e                                                 ;0x0045fe93 :        e9d6b3fdff

     Label5b3771 ::
             push esi                                                        ;0x005b3771 :        56
             sub eax , ecx                                                   ;0x005b3772 :        2bc1
             lea esi ,  dword ptr [ esp + 4 ]                                ;0x005b3774 :        8d742404
             mov  dword ptr [ esp + 4 ] , eax                                ;0x005b3778 :        89442404
             call Fun7e0c91                                                  ;0x005b377c :        e810d52200
             test eax , eax                                                  ;0x005b3781 :        85c0
             pop esi                                                         ;0x005b3783 :        5e
             jne Label43b281                                                 ;0x005b3784 :        0f85f77ae8ff
             mov  eax , dword ptr [ esp ]                                    ;0x005b378a :        8b0424
             call Fun68507b                                                  ;0x005b378d :        e8e9180d00
             jmp Label43b281                                                 ;0x005b3792 :        e9ea7ae8ff


4. APPLIES TO:

     VFP 10 (VFP Advanced)


5. REFERENCE WEBSITES:

     1, baiyujia.com:
     http://www.baiyujia.com
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix120.asp


6. OTHER:

     For reference only, there is no guarantees.

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