--------------------------------------------------------------------------------------------
                      [BUG/PRB.] VFP 9.0 FIX - CLEAN THE TEMPORARY PATH IN THE COMPILED EXECUTABLE FILES
                                 January 2024
                 --------------------------------------------------------------------------------------------
                                     CCB



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), there is the temporary path in the compiled executable files.


2. CAUSE:

     In vfp9 (and vfp6, vfp7, vfp8), for the following BUILD EXE command:
     CD c:\myapp
     BUILD PROJECT vctest.pjx FROM vctest.prg
     BUILD EXE vctest.exe FROM vctest.pjx

     vfp will compile c:\myapp\vctest.prg to C:\Users\UserName\AppData\Local\Temp\vctest.fxp (now the main folder is the temporary path),
     and then save the content of C:\Users\UserName\AppData\Local\Temp\vctest.fxp to the field Object in the project file vctest.pjx,
     and then read data from the field Object in the project file vctest.pjx,
     and then write data to the executable file vctest.exe,
     so there is the temporary path in the compiled executable file (and the field Object in the project file).

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun6908c2 :: ; proc near
             mov  ecx , dword ptr [ Data93757c ]                             ;0x006908c2 :        8b0d7c759300
             push ebx                                                        ;0x006908c8 :        53
             mov ebx , eax                                                   ;0x006908c9 :        8bd8
             mov  eax , dword ptr [ ebx + 0B68h ]                            ;0x006908cb :        8b83680b0000
             imul eax , eax , 038h                                           ;0x006908d1 :        6bc038
             mov  eax , dword ptr [ eax + ecx + 4 ]                          ;0x006908d4 :        8b440804
             push esi                                                        ;0x006908d8 :        56
             mov  dword ptr [ ebx + 0B7Dh ] , eax                            ;0x006908d9 :        89837d0b0000
             mov  eax , dword ptr [ ebx + 0BA4h ]                            ;0x006908df :        8b83a40b0000
             push edi                                                        ;0x006908e5 :        57
             mov  dword ptr [ ebx + 0B81h ] , eax                            ;0x006908e6 :        8983810b0000
             push eax                                                        ;0x006908ec :        50


     ;
     ;                 ---------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - CLEAN THE TEMPORARY PATH IN THE COMPILED EXECUTABLE FILES
     ;                                December 2023
     ;                 ---------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; Clean the temporary path in the compiled executable files.
     ;
     ; 2023/12/3, by ccb
     ;

             cmp dword ptr vfpa_sys9141_data,00h
             je Label6908ed
             mov  eax , dword ptr [ ebx + 0BA4h ]
             push eax
             mov  eax , dword ptr [ ebx + 0BA0h ]
             push  dword ptr [eax]
             call vfpa_cleantemppath


     Label6908ed ::
             mov  eax , dword ptr [ ebx + 0BA0h ]                            ;0x006908ed :        8b83a00b0000
             push  dword ptr [eax]                                           ;0x006908f3 :        ff30
             call Fun6877ed                                                  ;0x006908f5 :        e8f36effff
             mov  eax , dword ptr [ ebx + 0B68h ]                            ;0x006908fa :        8b83680b0000
             mov  ecx , dword ptr [ Data93757c ]                             ;0x00690900 :        8b0d7c759300
             imul eax , eax , 038h                                           ;0x00690906 :        6bc038
             mov  eax , dword ptr [ eax + ecx + 4 ]                          ;0x00690909 :        8b440804
             mov  dword ptr [ ebx + 0B79h ] , eax                            ;0x0069090d :        8983790b0000
             movzx eax ,word ptr [ ebx + 0B75h ]                             ;0x00690913 :        0fb783750b0000
             imul eax , eax , 019h                                           ;0x0069091a :        6bc019
             push eax                                                        ;0x0069091d :        50
             mov  eax , dword ptr [ ebx + 0B9Ch ]                            ;0x0069091e :        8b839c0b0000
             push  dword ptr [eax]                                           ;0x00690924 :        ff30
             call Fun6877ed                                                  ;0x00690926 :        e8c26effff
             lea esi ,  dword ptr [ ebx + 0B70h ]                            ;0x0069092b :        8db3700b0000
             pushd 02h                                                       ;0x00690931 :        6a02
             mov edx , offset Data92010c                                              ;0x00690933 :        ba0c019200
             mov ecx , esi                                                   ;0x00690938 :        8bce
             call Fun42c19b                                                  ;0x0069093a :        e85cb8d9ff
             mov  edi , dword ptr [ ebx + 0810h ]                            ;0x0069093f :        8bbb10080000
             test edi , edi                                                  ;0x00690945 :        85ff
             lea eax ,  dword ptr [ ebx + 0B72h ]                            ;0x00690947 :        8d83720b0000
             mov  word ptr [ ebx + 0B73h ] , 0220h                           ;0x0069094d :        66c783730b00002002
             mov  byte ptr [eax] , 0FFh                                      ;0x00690956 :        c600ff
             je Label69095e                                                  ;0x00690959 :        7403
             mov  byte ptr [eax] , 0EEh                                      ;0x0069095b :        c600ee

     Label69095e ::
             cmp  dword ptr [ ebx + 0814h ] , 00h                            ;0x0069095e :        83bb1408000000
             je Label69096a                                                  ;0x00690965 :        7403
             and  byte ptr [eax] , 0FDh                                      ;0x00690967 :        8020fd

     Label69096a ::
             mov eax , esi                                                   ;0x0069096a :        8bc6
             call Fun548481                                                  ;0x0069096c :        e8107bebff
             test edi , edi                                                  ;0x00690971 :        85ff
             mov  word ptr [ ebx + 0B97h ] , ax                              ;0x00690973 :        668983970b0000
             je Label690983                                                  ;0x0069097a :        7407
             mov eax , esi                                                   ;0x0069097c :        8bc6
             call Fun6da5ce                                                  ;0x0069097e :        e84b9c0400

     Label690983 ::
             mov  eax , dword ptr [ ebx + 0B68h ]                            ;0x00690983 :        8b83680b0000
             mov  ecx , dword ptr [ Data93757c ]                             ;0x00690989 :        8b0d7c759300
             imul eax , eax , 038h                                           ;0x0069098f :        6bc038
             and  dword ptr [ ecx + eax + 4 ] , 00h                          ;0x00690992 :        8364010400
             pushd 029h                                                      ;0x00690997 :        6a29
             push esi                                                        ;0x00690999 :        56
             push  dword ptr [ ebx + 0B68h ]                                 ;0x0069099a :        ffb3680b0000
             call Fun431e4d                                                  ;0x006909a0 :        e8a814daff
             pop edi                                                         ;0x006909a5 :        5f
             pop esi                                                         ;0x006909a6 :        5e
             pop ebx                                                         ;0x006909a7 :        5b
             ret                                                             ;0x006909a8 :        c3


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

     2, microsoft.com:
     https://social.msdn.microsoft.com/Forums/en-US/993c00e8-13ea-4074-8bd1-552a7dbea698/temporary-folder-in-vfp

     3, foxite.com:
     https://www.foxite.com/archives/problems-with-windows-8-0000398088.htm
     https://www.foxite.com/archives/error-reading-file-0000415016.htm


6. OTHER:

     For reference only, there is no guarantees.

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