-------------------------------------------------------------------------------------------- [ENHANCED] VFP 9.0 FIX - THE MAXIMUM NUMBER OF CHARACTERS FOR THE FGETS() FUNCTION January 2024 -------------------------------------------------------------------------------------------- CCB 1. BUG: In vfp9 (and vfp6, vfp7, vfp8), the maximum number of characters for the FGETS() function is 0x2000 (8192), now the maximum number of characters for the FGETS() function can be set to 0x2000 (8192) to 0x0FFFFFE0 (268435424). 2. CAUSE: There are some BUGs in the following code. 3. RESOLUTION: We can write some code to fix the BUG. Fun74beb6 :: ; proc near push ebp ;0x0074beb6 : 55 mov ebp , esp ;0x0074beb7 : 8bec sub esp , 074h ;0x0074beb9 : 83ec74 push ebx ;0x0074bebc : 53 push esi ;0x0074bebd : 56 push edi ;0x0074bebe : 57 xor esi , esi ;0x0074bebf : 33f6 mov edi , 01h ;0x0074bec1 : bf01000000 mov dword ptr [ ebp - 20 ] , esi ;0x0074bec6 : 8975ec mov byte ptr [ ebp - 4 ] , 0Dh ;0x0074bec9 : c645fc0d mov byte ptr [ ebp - 3 ] , 0Ah ;0x0074becd : c645fd0a mov dword ptr [ ebp - 8 ] , 0FEh ;0x0074bed1 : c745f8fe000000 mov dword ptr [ ebp - 16 ] , edi ;0x0074bed8 : 897df0 mov dword ptr [ ebp - 12 ] , esi ;0x0074bedb : 8975f4 call Fun420d8c ;0x0074bede : e8a94ecdff mov ebx , eax ;0x0074bee3 : 8bd8 cmp dword ptr [ Data936f1c ] , edi ;0x0074bee5 : 393d1c6f9300 mov dword ptr [ ebp - 28 ] , ebx ;0x0074beeb : 895de4 jle Label74bf82 ;0x0074beee : 0f8e8e000000 lea edi , dword ptr [ ebx + 44 ] ;0x0074bef4 : 8d7b2c call Fun529a6e ;0x0074bef7 : e872dbddff cmp byte ptr [edi] , 049h ;0x0074befc : 803f49 mov eax , dword ptr [ ebp + 8 ] ;0x0074beff : 8b4508 jne Label74bf3d ;0x0074bf02 : 7539 cmp eax , esi ;0x0074bf04 : 3bc6 ; ; --------------------------------------------------------------------------------- ; VFP 9.0 FIX - THE MAXIMUM NUMBER OF CHARACTERS FOR THE FGETS() FUNCTION ; July 2021 ; --------------------------------------------------------------------------------- ; CCB ; ; The maximum number of characters for the FGETS() function. ; ; 2021/7/18, by ccb ; ; mov eax , 02000h ;0x0074bf06 : b800200000 mov eax , dword ptr vfpa_sys9063_data ;0x0074bf06 : b800200000 jne Label74bf12 ;0x0074bf0b : 7505 mov eax , dword ptr [ Data936f20 ] ;0x0074bf0d : a1206f9300 Label74bf12 :: pushd 0385h ;0x0074bf12 : 6885030000 push eax ;0x0074bf17 : 50 push esi ;0x0074bf18 : 56 mov eax , edi ;0x0074bf19 : 8bc7 call Fun529bc5 ;0x0074bf1b : e8a5dcddff mov edx , dword ptr [ Data936f1c ] ;0x0074bf20 : 8b151c6f9300 mov dword ptr [ ebp - 8 ] , eax ;0x0074bf26 : 8945f8 xor eax , eax ;0x0074bf29 : 33c0 cmp edx , 02h ;0x0074bf2b : 83fa02 setg al ;0x0074bf2e : 0f9fc0 cmp eax , esi ;0x0074bf31 : 3bc6 mov dword ptr [ ebp - 12 ] , eax ;0x0074bf33 : 8945f4 je Label74bf82 ;0x0074bf36 : 744a add edi , 02Ch ;0x0074bf38 : 83c72c jmp Label74bf4d ;0x0074bf3b : eb10 Label74bf3d :: cmp eax , esi ;0x0074bf3d : 3bc6 je Label74bfea ;0x0074bf3f : 0f84a5000000 mov eax , 01h ;0x0074bf45 : b801000000 mov dword ptr [ ebp - 12 ] , eax ;0x0074bf4a : 8945f4 Label74bf4d :: cmp eax , esi ;0x0074bf4d : 3bc6 je Label74bf82 ;0x0074bf4f : 7431 mov eax , edi ;0x0074bf51 : 8bc7 call Fun42371d ;0x0074bf53 : e8c577cdff mov eax , dword ptr [ edi + 8 ] ;0x0074bf58 : 8b4708 cmp eax , 02h ;0x0074bf5b : 83f802 jbe Label74bf65 ;0x0074bf5e : 7605 mov eax , 02h ;0x0074bf60 : b802000000 Label74bf65 :: mov ecx , eax ;0x0074bf65 : 8bc8 mov edx , ecx ;0x0074bf67 : 8bd1 shr ecx , 02h ;0x0074bf69 : c1e902 mov dword ptr [ ebp - 16 ] , eax ;0x0074bf6c : 8945f0 mov eax , dword ptr [ edi + 32 ] ;0x0074bf6f : 8b4720 mov esi , dword ptr [eax] ;0x0074bf72 : 8b30 lea edi , dword ptr [ ebp - 4 ] ;0x0074bf74 : 8d7dfc rep movsd ;0x0074bf77 : f3a5 mov ecx , edx ;0x0074bf79 : 8bca and ecx , 03h ;0x0074bf7b : 83e103 rep movsb ;0x0074bf7e : f3a4 xor esi , esi ;0x0074bf80 : 33f6 Label74bf82 :: mov edi , ebx ;0x0074bf82 : 8bfb mov word ptr [ Data93bc88 ] , si ;0x0074bf84 : 66893588bc9300 call Fun529a6e ;0x0074bf8b : e8dedaddff cmp byte ptr [ebx] , 049h ;0x0074bf90 : 803b49 mov esi , dword ptr [ ebx + 12 ] ;0x0074bf93 : 8b730c jne Label74bfa2 ;0x0074bf96 : 750a push esi ;0x0074bf98 : 56 call Fun45340a ;0x0074bf99 : e86c74d0ff test eax , eax ;0x0074bf9e : 85c0 jne Label74bfae ;0x0074bfa0 : 750c Label74bfa2 :: or esi , 0FFFFFFFFh ;0x0074bfa2 : 83ceff mov word ptr [ Data93bc88 ] , 06h ;0x0074bfa5 : 66c70588bc93000600 Label74bfae :: cmp esi , 0FFFFFFFFh ;0x0074bfae : 83feff mov dword ptr [ ebp - 32 ] , esi ;0x0074bfb1 : 8975e0 je Label74c026 ;0x0074bfb4 : 7470 mov eax , esi ;0x0074bfb6 : 8bc6 call Fun68518e ;0x0074bfb8 : e8d191f3ff test eax , eax ;0x0074bfbd : 85c0 jne Label74c026 ;0x0074bfbf : 7565 mov edi , dword ptr [ ebp - 8 ] ;0x0074bfc1 : 8b7df8 cmp edi , 0FFFFh ;0x0074bfc4 : 81ffffff0000 jbe Label74c029 ;0x0074bfca : 765d test byte ptr [ Data936f10 ] , 01h ;0x0074bfcc : f605106f930001 je Label74c01c ;0x0074bfd3 : 7447 mov eax , dword ptr [ Data936f14 ] ;0x0074bfd5 : a1146f9300 test eax , eax ;0x0074bfda : 85c0 jne Label74c029 ;0x0074bfdc : 754b mov dword ptr [ Data936f14 ] , 0385h ;0x0074bfde : c705146f930085030000 jmp Label74c029 ;0x0074bfe8 : eb3f Label74bfea :: test byte ptr [ Data936f10 ] , 01h ;0x0074bfea : f605106f930001 je Label74c012 ;0x0074bff1 : 741f cmp dword ptr [ Data936f14 ] , esi ;0x0074bff3 : 3935146f9300 jne Label74c199 ;0x0074bff9 : 0f859a010000 mov dword ptr [ Data936f14 ] , 0385h ;0x0074bfff : c705146f930085030000 pop edi ;0x0074c009 : 5f pop esi ;0x0074c00a : 5e pop ebx ;0x0074c00b : 5b mov esp , ebp ;0x0074c00c : 8be5 pop ebp ;0x0074c00e : 5d ret 04h ;0x0074c00f : 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 http://www.baiyujia.com/vfpdocuments/f_vfp9fix182.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix170.asp 6. OTHER: For reference only, there is no guarantees. Any questions or suggestions, please send me an email at ccb2000@163.com. |