------------------------------------------------------------------------------------------
                      [ENHANCED] VFP 9.0 FIX - THE DPI AWARENESS MODE OF THE COMPILED EXECUTABLE FILES
                                  January 2024
                 ------------------------------------------------------------------------------------------
                                     CCB



1. BUG:

     We can set the DPI awareness mode of the compiled executable files,
     it is useful for fixing the fuzzy problem on high DPI monitor.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun431e4d :: ; proc near
             push ecx                                                        ;0x00431e4d :        51
             mov eax ,  dword ptr [ Data9370f8 ]                             ;0x00431e4e :        a1f8709300
             push ebx                                                        ;0x00431e53 :        53
             mov  ebx , dword ptr [ esp + 12 ]                               ;0x00431e54 :        8b5c240c
             mov ecx , ebx                                                   ;0x00431e58 :        8bcb
             imul ecx , ecx , 038h                                           ;0x00431e5a :        6bc938
             push ebp                                                        ;0x00431e5d :        55
             push esi                                                        ;0x00431e5e :        56
             mov  esi , dword ptr [ Data93757c ]                             ;0x00431e5f :        8b357c759300
             lea ebp ,  dword ptr [ ecx + esi ]                              ;0x00431e65 :        8d2c31
             mov  cl , byte ptr [ ebp + 44 ]                                 ;0x00431e68 :        8a4d2c
             xor edx , edx                                                   ;0x00431e6b :        33d2
             test  byte ptr cl , 02h                                         ;0x00431e6d :        f6c102
             push edi                                                        ;0x00431e70 :        57
             mov  dword ptr [ esp + 16 ] , edx                               ;0x00431e71 :        89542410
             je Label56e4d2                                                  ;0x00431e75 :        0f8457c61300
             test  dword ptr [ ebp + 8 ] , 0A04h                             ;0x00431e7b :        f74508040a0000
             je Label52a7ff                                                  ;0x00431e82 :        0f8477890f00

     Label431e88 ::
             cmp eax , edx                                                   ;0x00431e88 :        3bc2
             je Label431e9a                                                  ;0x00431e8a :        740e
             mov  ecx , dword ptr [eax]                                      ;0x00431e8c :        8b08
             cmp  dword ptr [ ecx + 0164h ] , edx                            ;0x00431e8e :        399164010000
             jne Label56e517                                                 ;0x00431e94 :        0f857dc61300

     Label431e9a ::
             cmp  dword ptr [ esp + 32 ] , edx                               ;0x00431e9a :        39542420
             mov  dword ptr [ esp + 16 ] , edx                               ;0x00431e9e :        89542410
             jbe Label431f1b                                                 ;0x00431ea2 :        7677

     Label431ea4 ::
             mov  eax , dword ptr [ esp + 32 ]                               ;0x00431ea4 :        8b442420
             push eax                                                        ;0x00431ea8 :        50
             mov edx , ebp                                                   ;0x00431ea9 :        8bd5
             xor ecx , ecx                                                   ;0x00431eab :        33c9
             call Fun42d01e                                                  ;0x00431ead :        e86cb1ffff
             mov edi , eax                                                   ;0x00431eb2 :        8bf8
             mov  eax , dword ptr [ ebp + 4 ]                                ;0x00431eb4 :        8b4504
             mov  esi , dword ptr [ edi + 8 ]                                ;0x00431eb7 :        8b7708
             mov  ecx , dword ptr [ edi + 4 ]                                ;0x00431eba :        8b4f04
             sub esi , eax                                                   ;0x00431ebd :        2bf0
             mov ebx , eax                                                   ;0x00431ebf :        8bd8
             mov  eax , dword ptr [ esp + 32 ]                               ;0x00431ec1 :        8b442420
             add esi , ecx                                                   ;0x00431ec5 :        03f1
             sub ebx , ecx                                                   ;0x00431ec7 :        2bd9
             cmp eax , esi                                                   ;0x00431ec9 :        3bc6
             jnb Label431ecf                                                 ;0x00431ecb :        7302
             mov esi , eax                                                   ;0x00431ecd :        8bf0

     Label431ecf ::
             mov  ecx , dword ptr [ esp + 16 ]                               ;0x00431ecf :        8b4c2410
             mov  edx , dword ptr [ esp + 28 ]                               ;0x00431ed3 :        8b54241c
             add edx , ecx                                                   ;0x00431ed7 :        03d1
             mov  ecx , dword ptr [edi]                                      ;0x00431ed9 :        8b0f
             push esi                                                        ;0x00431edb :        56
             add ecx , ebx                                                   ;0x00431edc :        03cb
             call Fun42c19b                                                  ;0x00431ede :        e8b8a2ffff


     ;
     ;                 -------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - THE DPI AWARENESS MODE OF THE COMPILED EXECUTABLE FILES
     ;                                September 2020
     ;                 -------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; The DPI awareness mode of the compiled executable files.
     ;
     ; 2020/9/30, by ccb
     ;

     vfpa_updatedpiawareness0_start:
             cmp dword ptr [ esp + 20 ] , offset Label6912b4 ;; Fun69124b .. ; proc near
             jne vfpa_updatedpiawareness0_end
             push ecx
             push eax
             mov  ecx , dword ptr [edi]
             add ecx , ebx
             push dword ptr vfpa_sys9037_data
             push esi
             push ecx
             call vfpa_updatedpiawareness
             pop eax
             pop ecx
     vfpa_updatedpiawareness0_end:


             mov  dl , byte ptr [ edi + 21 ]                                 ;0x00431ee3 :        8a5715
             mov  ecx , dword ptr [ edi + 12 ]                               ;0x00431ee6 :        8b4f0c
             or dl , 01h                                                     ;0x00431ee9 :        80ca01
             lea eax ,  dword ptr [ ebx + esi ]                              ;0x00431eec :        8d0433
             cmp eax , ecx                                                   ;0x00431eef :        3bc1
             mov  byte ptr [ edi + 21 ] , dl                                 ;0x00431ef1 :        885715
             jbe Label431ef9                                                 ;0x00431ef4 :        7603
             mov  dword ptr [ edi + 12 ] , eax                               ;0x00431ef6 :        89470c

     Label431ef9 ::
             mov  edx , dword ptr [ esp + 16 ]                               ;0x00431ef9 :        8b542410
             mov  ecx , dword ptr [ ebp + 4 ]                                ;0x00431efd :        8b4d04
             mov  eax , dword ptr [ esp + 32 ]                               ;0x00431f00 :        8b442420
             add edx , esi                                                   ;0x00431f04 :        03d6
             add ecx , esi                                                   ;0x00431f06 :        03ce
             sub eax , esi                                                   ;0x00431f08 :        2bc6
             mov  dword ptr [ esp + 16 ] , edx                               ;0x00431f0a :        89542410
             mov  dword ptr [ ebp + 4 ] , ecx                                ;0x00431f0e :        894d04
             mov  dword ptr [ esp + 32 ] , eax                               ;0x00431f11 :        89442420
             jne Label431ea4                                                 ;0x00431f15 :        758d
             mov  ebx , dword ptr [ esp + 24 ]                               ;0x00431f17 :        8b5c2418

     Label431f1b ::
             mov  eax , dword ptr [ ebp + 4 ]                                ;0x00431f1b :        8b4504
             cmp  eax , dword ptr [ ebp + 0 ]                                ;0x00431f1e :        3b4500
             jle Label433f55                                                 ;0x00431f21 :        0f8e2e200000
             and  dword ptr [ ebp + 44 ] , 0FFFFFF7Fh                        ;0x00431f27 :        81652c7fffffff
             mov  dword ptr [ ebp + 0 ] , eax                                ;0x00431f2e :        894500

     Label431f31 ::
             test  byte ptr [ ebp + 44 ] , 060h                              ;0x00431f31 :        f6452c60
             jne Label56e53d                                                 ;0x00431f35 :        0f8502c61300

     Label431f3b ::
             mov  eax , dword ptr [ esp + 16 ]                               ;0x00431f3b :        8b442410
             pop edi                                                         ;0x00431f3f :        5f
             pop esi                                                         ;0x00431f40 :        5e
             pop ebp                                                         ;0x00431f41 :        5d
             pop ebx                                                         ;0x00431f42 :        5b
             pop ecx                                                         ;0x00431f43 :        59
             ret 0Ch                                                         ;0x00431f44 :        c20c00


4. APPLIES TO:

     VFP 10 (VFP Advanced)


5. REFERENCE WEBSITES:

     1, baiyujia.com:
     http://www.baiyujia.com
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix127.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix129.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix130.asp

     2, microsoft.com:
     https://docs.microsoft.com/en-us/windows/win32/hidpi/setting-the-default-dpi-awareness-for-a-process
     https://support.microsoft.com/en-us/help/3025083/windows-scaling-issues-for-high-dpi-devices

     3, xpexplorer.com:
     http://windows10-dpi-fix.xpexplorer.com/

     4, kevinragsdale.net:
     https://kevinragsdale.net/is-your-app-dpi-aware/

     5, rw-designer.com:
     http://www.rw-designer.com/DPI-aware


6. OTHER:

     For reference only, there is no guarantees.

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