--------------------------------------------------------------------------------------------------
                      [BUG/PRB.] VFP 9.0 FIX - CHECK THE UPPERCASE FILE NAMES IN THE COMPILED EXECUTABLE FILES
                                 January 2024
                 --------------------------------------------------------------------------------------------------
                                     CCB



1. BUG:

     In vfp9 (and vfp7, vfp8), sometimes it will check the uppercase file names in the compiled executable files failed.

     The bug occurs in vfp7, vfp8 and vfp9, it does not occur in vfp6.

     The bug only occurs on some Windows systems (for example, Spanish Windows system, and Spanish uppercase file names).

     The bug occurs in the following commands:
     DO FORM command
     IMPORT FROM command
     LABEL FORM command
     REPORT FORM command
     SET RESOURCE command
     TYPE command


2. CAUSE:

     In vfp9 (and vfp7, vfp8), for example, for the DO FORM command:
     DO FORM "FORMS\SESI"+CHR(0xD3)+"N.SCX" && "SESIÓN.SCX"
     it will try to check the uppercase file names in the compiled executable files,
     it will check failed (because file names are saved to lowercase in the compiled executable files),
     and then it will try to check the file on disk,
     it will check failed (becasue there is no the file on disk),
     so it will cause the error "File 'name' does not exist (Error 1)".

     In VFP Advanced, for example, for the DO FORM command:
     DO FORM "FORMS\SESI"+CHR(0xD3)+"N.SCX" && "SESIÓN.SCX"
     it will try to check the uppercase file names in the compiled executable files,
     it will check failed (because file names are saved to lowercase in the compiled executable files),
     and then it will try to check the lowercase file names in the compiled executable files,
     it will check success,
     and then it will run fine.

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun42cd23 :: ; proc near
             sub esp , 0218h                                                 ;0x0042cd23 :        81ec18020000
             mov eax ,  dword ptr [ Data937090 ]                             ;0x0042cd29 :        a190709300
             push ebx                                                        ;0x0042cd2e :        53
             push ebp                                                        ;0x0042cd2f :        55
             mov  ebp , dword ptr [ esp + 0224h ]                            ;0x0042cd30 :        8bac2424020000
             mov  dword ptr [ esp + 021Ch ] , eax                            ;0x0042cd37 :        8984241c020000
             mov eax ,  dword ptr [ Data937574 ]                             ;0x0042cd3e :        a174759300
             push esi                                                        ;0x0042cd43 :        56
             xor ebx , ebx                                                   ;0x0042cd44 :        33db
             test eax , eax                                                  ;0x0042cd46 :        85c0
             push edi                                                        ;0x0042cd48 :        57
             mov  dword ptr [ esp + 16 ] , 00h                               ;0x0042cd49 :        c744241000000000
             jne Label5afc23                                                 ;0x0042cd51 :        0f85cc2e1800

     Label42cd57 ::
             mov  eax , dword ptr [ esp + 0240h ]                            ;0x0042cd57 :        8b842440020000
             test eax , eax                                                  ;0x0042cd5e :        85c0
             jne Label42cd6c                                                 ;0x0042cd60 :        750a
             cmp  word ptr [ Data937100 ] , 00h                              ;0x0042cd62 :        66833d0071930000
             jne Label42cdb7                                                 ;0x0042cd6a :        754b

     Label42cd6c ::
             call Fun42cdd2                                                  ;0x0042cd6c :        e861000000
             mov edi , eax                                                   ;0x0042cd71 :        8bf8
             test edi , edi                                                  ;0x0042cd73 :        85ff
             je Label42cda8                                                  ;0x0042cd75 :        7431
             test ebx , ebx                                                  ;0x0042cd77 :        85db
             jne Label42cd93                                                 ;0x0042cd79 :        7518
             mov  ecx , dword ptr [ esp + 0230h ]                            ;0x0042cd7b :        8b8c2430020000
             push ecx                                                        ;0x0042cd82 :        51
             lea ecx ,  dword ptr [ esp + 24 ]                               ;0x0042cd83 :        8d4c2418
             mov edx , ebp                                                   ;0x0042cd87 :        8bd5
             call Fun52ca44                                                  ;0x0042cd89 :        e8b6fc0f00
             mov ebx , 01h                                                   ;0x0042cd8e :        bb01000000

     Label42cd93 ::
             lea edx ,  dword ptr [ esp + 20 ]                               ;0x0042cd93 :        8d542414
             push edx                                                        ;0x0042cd97 :        52
             push edi                                                        ;0x0042cd98 :        57
             call Fun52caa8                                                  ;0x0042cd99 :        e80afd0f00


     ;
     ;                 ---------------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - CHECK THE UPPERCASE FILE NAMES IN THE COMPILED EXECUTABLE FILES
     ;                                December 2023
     ;                 ---------------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; Check the uppercase file names in the compiled executable files.
     ;
     ; 2023/12/13, by ccb
     ;

             cmp dword ptr vfpa_sys9142_data,00h
             je Label42cd9e
             mov esi , eax
             test esi , esi
             jnl Label42cd9e
             lea esi ,  dword ptr [ esp + 20 ]
             mov ecx , esi
             call Fun42c241
             lea edx ,  dword ptr [ esp + 20 ]
             push edx
             push edi
             call Fun52caa8


     Label42cd9e ::
             mov esi , eax                                                   ;0x0042cd9e :        8bf0
             test esi , esi                                                  ;0x0042cda0 :        85f6
             jnl Label4f45ff                                                 ;0x0042cda2 :        0f8d57780c00

     Label42cda8 ::
             mov  eax , dword ptr [ esp + 0240h ]                            ;0x0042cda8 :        8b842440020000
             test eax , eax                                                  ;0x0042cdaf :        85c0
             jne Label43e499                                                 ;0x0042cdb1 :        0f85e2160100

     Label42cdb7 ::
             xor eax , eax                                                   ;0x0042cdb7 :        33c0

     Label42cdb9 ::
             mov  ecx , dword ptr [ esp + 0224h ]                            ;0x0042cdb9 :        8b8c2424020000
             pop edi                                                         ;0x0042cdc0 :        5f
             pop esi                                                         ;0x0042cdc1 :        5e
             pop ebp                                                         ;0x0042cdc2 :        5d
             pop ebx                                                         ;0x0042cdc3 :        5b
             call Fun42bf1d                                                  ;0x0042cdc4 :        e854f1ffff
             add esp , 0218h                                                 ;0x0042cdc9 :        81c418020000
             ret 018h                                                        ;0x0042cdcf :        c21800


4. APPLIES TO:

     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.

     IMPORTANT NOTE:
     In vfp9 (and vfp7, vfp8), we can use the setlocale Windows API to fix the bug, for example,
     DECLARE INTEGER "setlocale" IN "msvcr100.dll" INTEGER category, STRING locale
     =setlocale(0,"spanish")
     For more information about the setlocale Windows API, please refer to:
     https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=msvc-170
     https://learn.microsoft.com/en-us/cpp/c-runtime-library/language-strings?view=msvc-170


5. REFERENCE WEBSITES:

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


6. OTHER:

     For reference only, there is no guarantees.

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