------------------------------------------------------------
                         [BUG/PRB.] VFP 9.0 FIX - VARBINARY OR BLOB DATA
                                 January 2024
                 ------------------------------------------------------------
                                    CCB



1. BUG:

     In vfp9, we can use some new data type such as Varbinary Data, Blob Data,
     but when SET("STATUS BAR")="OFF" and SET("TALK")="ON", VFP will enter an infinite loop.

     There is a program for test:

     *PROC testvarbinary

     SET STEP OFF
     SET ECHO OFF
     SET DEBUG OFF
     SET ESCAPE OFF
     SET TALK OFF
     SET SAFETY OFF

     _SCREEN.VISIBLE=.T.
     _SCREEN.WINDOWSTATE=2

     SET STATUS BAR OFF
     SET TALK ON
     x1=0h11223344
     WAIT

     RETURN

     * END OF PROC TESTVARBINARY.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label8765a8 ::
             pushd 0Ah                                                       ;0x008765a8 :        6a0a
             call Fun6d99d2                                                  ;0x008765aa :        e82334e6ff

     Label8765af ::


     ;
     ;                 -------------------------------------------------
     ;                         VFP 9.0 FIX - VARBINARY OR BLOB DATA
     ;                                  June 2014
     ;                 -------------------------------------------------
     ;                                     CCB
     ;
     ; Store Varbinary or Blob data to a variable when SET("STATUS BAR")="OFF" and SET("TALK")="ON", VFP will enter an infinite loop.
     ;
     ; 2014/6/29, by ccb
     ;

             cmp dword ptr [esi],48h ; H
             je VFP9FixVarbinary_Varbinary
             cmp dword ptr [esi],51h ; Q
             je VFP9FixVarbinary_Varbinary
             jmp VFP9FixVarbinary_Other

     VFP9FixVarbinary_Varbinary:
             cmp dword ptr [esi+4],1
             jne VFP9FixVarbinary_Other

             cmp dword ptr [esi+8],07Eh
             jbe VFP9FixVarbinary_Label87658b
             mov dword ptr [esi+8],07Eh

     VFP9FixVarbinary_Label87658b :
             mov  ecx , dword ptr [ esi + 8 ]                             ;0x0087658b :        8b88f4000000
             mov eax , 07Eh                                                 ;0x00876591 :        b800010000
             cmp ecx , eax                                                   ;0x00876596 :        3bc8
             mov  dword ptr [ ebp + 0FFFFFF78h ] , ecx                       ;0x00876598 :        898d78ffffff
             jl VFP9FixVarbinary_Label8765af                                                  ;0x0087659e :        7c0f
             mov  dword ptr [ ebp + 0FFFFFF78h ] , eax                       ;0x008765a0 :        898578ffffff
             jmp VFP9FixVarbinary_Label8765af                                                 ;0x008765a6 :        eb07

     VFP9FixVarbinary_Label8765af :
             push  dword ptr [ ebp + 0FFFFFF78h ]                            ;0x008765af :        ffb578ffffff
             lea eax ,  dword ptr [ ebp + 0FFFFFF7Ch ]                       ;0x008765b5 :        8d857cffffff
             push eax                                                        ;0x008765bb :        50
             push esi                                                        ;0x008765bc :        56
             call Fun876638                                                  ;0x008765bd :        e876000000

     VFP9FixVarbinary_Label5cba13 ::
             mov  eax , dword ptr [ ebp + 0FFFFFF78h ]                                ;0x005cba13 :        8b4308
             cmp eax , 07Eh                                                  ;0x005cba16 :        83f87e
             mov  byte ptr [ ebp + 0FFFFFF7Ch ] , 030h                       ;0x005cba19 :        c6857cffffff30
             mov  byte ptr [ ebp + 0FFFFFF7Dh ] , 068h                       ;0x005cba20 :        c6857dffffff68
             jbe VFP9FixVarbinary_Label5cba2c                                                 ;0x005cba27 :        7603
             pushd 07Eh                                                      ;0x005cba29 :        6a7e
             pop eax                                                         ;0x005cba2b :        58

     VFP9FixVarbinary_Label5cba2c ::
             lea ecx ,  dword ptr [ ebp + 0FFFFFF7Eh ]                       ;0x005cba2c :        8d8d7effffff
             push ecx                                                        ;0x005cba32 :        51
             mov  ecx , dword ptr [ esi + 32 ]                               ;0x005cba33 :        8b4b20
             mov  ecx , dword ptr [ecx]                                      ;0x005cba36 :        8b09
             call Fun78244e                                                  ;0x005cba38 :        e8116a1b00

             add eax,2
             mov dword ptr [esi+8],0

             jmp VFP9FixVarbinary_end

     VFP9FixVarbinary_Other:
             push  dword ptr [ ebp + 0FFFFFF78h ]                            ;0x008765af :        ffb578ffffff
             lea eax ,  dword ptr [ ebp + 0FFFFFF7Ch ]                       ;0x008765b5 :        8d857cffffff
             push eax                                                        ;0x008765bb :        50
             push esi                                                        ;0x008765bc :        56
             call Fun876638                                                  ;0x008765bd :        e876000000

     VFP9FixVarbinary_end:

             pushd 00h                                                       ;0x008765c2 :        6a00
             lea ebx ,  dword ptr [ ebp + 0FFFFFF7Ch ]                       ;0x008765c4 :        8d9d7cffffff
             mov edi , eax                                                   ;0x008765ca :        8bf8
             pushd 00h                                                       ;0x008765cc :        6a00
             call Fun49df89                                                  ;0x008765ce :        e8b679c2ff
             mov ecx , esi                                                   ;0x008765d3 :        8bce
             call Fun540791                                                  ;0x008765d5 :        e8b7a1ccff


     ;
     ;                 -------------------------------------------------
     ;                         VFP 9.0 FIX - VARBINARY OR BLOB DATA
     ;                                  June 2014
     ;                 -------------------------------------------------
     ;                                     CCB
     ;
     ; Store Varbinary or Blob data to a variable when SET("STATUS BAR")="OFF" and SET("TALK")="ON", VFP will enter an infinite loop.
     ;
     ; 2014/6/29, by ccb
     ;

             cmp dword ptr [esi],48h ; H
             je VFP9FixVarbinary2_Varbinary
             cmp dword ptr [esi],51h ; Q
             je VFP9FixVarbinary2_Varbinary
             jmp VFP9FixVarbinary2_end

     VFP9FixVarbinary2_Varbinary:
             cmp dword ptr [esi+4],1
             jne VFP9FixVarbinary2_end
             cmp dword ptr [esi+8],0
             jne VFP9FixVarbinary2_end

             xor eax,eax

     VFP9FixVarbinary2_end:

             test eax , eax                                                  ;0x008765da :        85c0
             jne Label8765a8                                                 ;0x008765dc :        75ca
             jmp Label8765e8                                                 ;0x008765de :        eb08


4. APPLIES TO:

     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

     2, microsoft.com:
     http://connect.microsoft.com/VisualStudio/feedback/details/458727/visual-foxpro-9-0-locks-up-when-assigning-varbinary-variables

     3, foxite.com:
     http://www.foxite.com/archives/foxcharts-hang-up-0000228718.htm

     4, codeplex.com:
     http://vfpx.codeplex.com/discussions/56847

     5, foxclub.ru:
     http://forum.foxclub.ru/read.php?29,389161


6. OTHER:

     For reference only, there is no guarantees.

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