---------------------------------------------------
                      VFP 9.0 FIX - SET RESOURCE OFF AT STARTUP
                                February 2017
                 ---------------------------------------------------
                                    CCB



1. BUG:

     Usually, VFP will open the resource file at startup.
     If there is no the resource file, it will create the resource file.
 
     But in some cases, for example,
     VFP Runtime, VFP Multi-threaded Runtime,
     usually we need not create the resource file,
     so we can set resource off at startup in these cases.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label406299 ::
             call Fun409702                                                  ;0x00406299 :        e864340000
             call Fun40976e                                                  ;0x0040629e :        e8cb340000
             call Fun409926                                                  ;0x004062a3 :        e87e360000
             call Fun409acf                                                  ;0x004062a8 :        e822380000
             call Fun409b32                                                  ;0x004062ad :        e880380000
             call Fun409bef                                                  ;0x004062b2 :        e838390000
             call Fun409d23                                                  ;0x004062b7 :        e8673a0000
             call Fun40a000                                                  ;0x004062bc :        e83f3d0000
             mov eax , ebx                                                   ;0x004062c1 :        8bc3
             call Fun40a116                                                  ;0x004062c3 :        e84e3e0000


     ;
     ;                 ---------------------------------------------------
     ;                      VFP 9.0 FIX - SET RESOURCE OFF AT STARTUP
     ;                                February 2017
     ;                 ---------------------------------------------------
     ;                                     CCB
     ;
     ; VFP IDE: SET RESOURCE ON at startup.
     ; VFP Runtime: SET RESOURCE OFF at startup.
     ; VFP Multi-threaded Runtime: SET RESOURCE OFF at startup.
     ;
     ; 2017/2/22, by ccb
     ;

     ;         push 00h
     ;         push 01h
     ;         push ebx
     ;         push offset vfpa_setresource_data
     ;         call Fun40a45d


     Label4062c8 ::
             push ebx                                                        ;0x004062c8 :        53
             call Fun40a140                                                  ;0x004062c9 :        e8723e0000
             mov  edx , dword ptr [ Data93a780 ]                             ;0x004062ce :        8b1580a79300
             xor eax , eax                                                   ;0x004062d4 :        33c0
             inc eax                                                         ;0x004062d6 :        40
             mov ecx , 090h                                                  ;0x004062d7 :        b990000000
             call Fun40a7ee                                                  ;0x004062dc :        e80d450000
             call Fun40a8a2                                                  ;0x004062e1 :        e8bc450000
             call Fun40a9e4                                                  ;0x004062e6 :        e8f9460000
             push ebx                                                        ;0x004062eb :        53
             call Fun40aae9                                                  ;0x004062ec :        e8f8470000
             call Fun40b071                                                  ;0x004062f1 :        e87b4d0000
             call Fun40b0aa                                                  ;0x004062f6 :        e8af4d0000
             call Fun40bee8                                                  ;0x004062fb :        e8e85b0000
             mov eax ,  dword ptr [ Data937794 ]                             ;0x00406300 :        a194779300
             call Fun41757a                                                  ;0x00406305 :        e870120100
             mov  dword ptr [ Data936de4 ] , 01388h                          ;0x0040630a :        c705e46d930088130000
             call Fun40c222                                                  ;0x00406314 :        e8095f0000
             call Fun40c29c                                                  ;0x00406319 :        e87e5f0000
             xor esi , esi                                                   ;0x0040631e :        33f6

     Label406320 ::
             lea eax ,  dword ptr [ ebp - 12 ]                               ;0x00406320 :        8d45f4
             push eax                                                        ;0x00406323 :        50
             lea eax ,  dword ptr [ ebp + 0FFFFFF74h ]                       ;0x00406324 :        8d8574ffffff
             call Fun42d200                                                  ;0x0040632a :        e8d16e0200
             cmp  dword ptr [ ebp - 8 ] , esi                                ;0x0040632f :        3975f8
             jne Label5783de                                                 ;0x00406332 :        0f85a6201700
             pop edi                                                         ;0x00406338 :        5f
             pop esi                                                         ;0x00406339 :        5e
             pop ebx                                                         ;0x0040633a :        5b
             leave                                                           ;0x0040633b :        c9
             ret 04h                                                         ;0x0040633c :        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

     2, microsoft.com:
     https://social.msdn.microsoft.com/Forums/en-US/aa67e00c-ce8e-42f9-af05-6143739448ef/foxuserdbf-on-desktop
     https://social.msdn.microsoft.com/Forums/en-US/ecfa0280-4953-42e4-bb10-9e1b437bd3e4/error-reading-foxuserdbf

     3, tek-tips.com:
     http://www.tek-tips.com/viewthread.cfm?qid=1711792
     http://www.tek-tips.com/viewthread.cfm?qid=604896

     4, narkive.com:
     http://microsoft.public.fox.vfp.dbc.narkive.com/IZETNP3d/foxuser-dbf-file-cause-application-crash
     http://profox.leafe.narkive.com/NZrOndgI/vfp9-resource-file-not-valid


6. OTHER:

     For reference only, there is no guarantees.

     Any questions or suggestions, please e-mail to ccb2000@163.com.