--------------------------------------------------------------- [ENHANCED] VFP 9.0 FIX - SYS(1105) FUNCTION May 2024 --------------------------------------------------------------- CCB 1. THE SYS(1105) FUNCTION: SYS(1105) - Returns the using file data buffer size Returns the using file data buffer size. SYS(1105 [, nType [, cFileName]]) Parameters nType 0 All memory. 1 Low address memory. 2 Large memory. cFileName Specifies the file name. If you do not specify the file name, SYS(1105) returns the using file data buffer size of all opened files. Return Value Character Remarks SYS(1105) returns the using file data buffer size of all opened files. SYS(1105,0) returns the using file data buffer size (all memory) of all opened files. SYS(1105,1) returns the using file data buffer size (low address memory) of all opened files. SYS(1105,2) returns the using file data buffer size (large memory) of all opened files. SYS(1105,0,cFileName) returns the using file data buffer size (all memory) of the specified file. SYS(1105,1,cFileName) returns the using file data buffer size (low address memory) of the specified file. SYS(1105,2,cFileName) returns the using file data buffer size (large memory) of the specified file. 2. CAUSE: There are some BUGs in the following code. 3. RESOLUTION: We can write some code to fix the BUG. Label4699b2 :: mov ecx , 0437h ;0x004699b2 : b937040000 cmp eax , ecx ;0x004699b7 : 3bc1 jle Label4699ef ;0x004699b9 : 7e34 sub eax , 044Dh ;0x004699bb : 2d4d040000 je Label6093bd ;0x004699c0 : 0f84f7f91900 dec eax ;0x004699c6 : 48 je Label4558c5 ;0x004699c7 : 0f84f8befeff dec eax ;0x004699cd : 48 je Label4558d2 ;0x004699ce : 0f84febefeff dec eax ;0x004699d4 : 48 je Label60930a ;0x004699d5 : 0f842ff91900 dec eax ;0x004699db : 48 jne Label6092f2 ;0x004699dc : 0f8510f91900 Label4699e1 :: ; ; ---------------------------------------------------- ; VFP 9.0 FIX - SYS(1105) FUNCTION ; May 2024 ; ---------------------------------------------------- ; CCB ; ; In vfp9, the SYS(1105) function returns the using file data buffer size of all opened files. ; In VFP Advanced, the SYS(1105) function returns the using file data buffer size of all opened files, ; the SYS(1105,nType,cFileName) function returns the using file data buffer size of the specified file. ; ; 2024/5/11, by ccb ; cmp dword ptr [ ebp + 12 ] , 02h jl Label4699e2 cmp dword ptr [ ebp + 12 ] , 03h jl Label4699e2_allfiles jmp Label4699e2_file Label4699e2 :: push esi push edi sub esp , 110h mov dword ptr [ esp + 00h ] , 00h mov dword ptr [ esp + 04h ] , 00h mov dword ptr [ esp + 08h ] , 00h mov byte ptr [ esp + 10h ] , 00h mov edi , dword ptr [ Data93757c ] cmp edi , dword ptr [ Data937774 ] ja Label4699e6 Label4699e3 :: xor ecx , ecx mov eax , dword ptr [ edi + 24h ] test eax , eax jle Label4699e5 Label4699e4 :: mov eax , dword ptr [ edi + 10h ] mov eax , dword ptr [eax] mov eax , dword ptr [ eax + 4 * ecx ] mov edx , dword ptr [ edi + 14h ] add eax , dword ptr [edx] mov eax , dword ptr [ eax + 08h ] add dword ptr [ esp + 00h ] , eax adc dword ptr [ esp + 04h ] , 00h inc ecx cmp ecx , dword ptr [ edi + 24h ] jl Label4699e4 Label4699e5 :: IF VFPA_VERSION GE 101 add edi , VFPA_CONST_X64_FOXFILE_LEN ELSE add edi , 038h ENDIF cmp edi , dword ptr [ Data937774 ] jbe Label4699e3 IF VFPA_VERSION GE 102 mov eax , dword ptr [ esp + 00h ] mov edx , dword ptr [ esp + 04h ] add esp , 110h pop edi pop esi sub esp , 08h mov byte ptr [esp][0],"%" mov byte ptr [esp][1],"." mov byte ptr [esp][2],"0" mov byte ptr [esp][3],"f" mov byte ptr [esp][4],0 push edx push eax fild qword ptr [ esp ] fstp qword ptr [ esp ] lea eax , dword ptr [ esp + 8 ] push eax lea eax , dword ptr [ ebp + 0FFFFFDE0h ] push eax call Fun43089c add esp , 018h jmp Label52a11a ELSE mov eax , dword ptr [ esp + 00h ] add esp , 110h pop edi pop esi pushd 00h pushd 00h mov edx,eax jmp Label52b74e ENDIF Label4699e6 :: mov eax , dword ptr [ esp + 00h ] add esp , 110h pop edi pop esi pushd 00h pushd 00h mov edx,eax jmp Label52b74e Label4699e2_allfiles :: push esi push edi sub esp , 110h mov dword ptr [ esp + 00h ] , 00h mov dword ptr [ esp + 04h ] , 00h mov dword ptr [ esp + 08h ] , 00h mov byte ptr [ esp + 10h ] , 00h pushd 0385h pushd 02h pushd 00h lea eax , dword ptr [ ebx + 44 ] call Fun529bc5 mov dword ptr [ esp + 08h ] , eax mov edi , dword ptr [ Data93757c ] cmp edi , dword ptr [ Data937774 ] ja Label4699e6_allfiles Label4699e3_allfiles :: xor ecx , ecx mov eax , dword ptr [ edi + 24h ] test eax , eax jle Label4699e5_allfiles Label4699e4_allfiles :: mov eax , dword ptr [ edi + 10h ] mov eax , dword ptr [eax] mov eax , dword ptr [ eax + 4 * ecx ] mov edx , dword ptr [ edi + 14h ] add eax , dword ptr [edx] cmp dword ptr [ esp + 08h ] , 01h je Label4699e4_allfiles_lowaddressmemory cmp dword ptr [ esp + 08h ] , 02h je Label4699e4_allfiles_largememory jmp Label4699e4_allfiles_addmemory Label4699e4_allfiles_lowaddressmemory :: cmp byte ptr [ eax + 14h ] , 10h jbe Label4699e4_allfiles_addmemory jmp Label4699e4_allfiles_nextfileblock Label4699e4_allfiles_largememory :: cmp byte ptr [ eax + 14h ] , 10h ja Label4699e4_allfiles_addmemory jmp Label4699e4_allfiles_nextfileblock Label4699e4_allfiles_addmemory :: mov eax , dword ptr [ eax + 08h ] add dword ptr [ esp + 00h ] , eax adc dword ptr [ esp + 04h ] , 00h Label4699e4_allfiles_nextfileblock :: inc ecx cmp ecx , dword ptr [ edi + 24h ] jl Label4699e4_allfiles Label4699e5_allfiles :: IF VFPA_VERSION GE 101 add edi , VFPA_CONST_X64_FOXFILE_LEN ELSE add edi , 038h ENDIF cmp edi , dword ptr [ Data937774 ] jbe Label4699e3_allfiles IF VFPA_VERSION GE 102 mov eax , dword ptr [ esp + 00h ] mov edx , dword ptr [ esp + 04h ] add esp , 110h pop edi pop esi sub esp , 08h mov byte ptr [esp][0],"%" mov byte ptr [esp][1],"." mov byte ptr [esp][2],"0" mov byte ptr [esp][3],"f" mov byte ptr [esp][4],0 push edx push eax fild qword ptr [ esp ] fstp qword ptr [ esp ] lea eax , dword ptr [ esp + 8 ] push eax lea eax , dword ptr [ ebp + 0FFFFFDE0h ] push eax call Fun43089c add esp , 018h jmp Label52a11a ELSE mov eax , dword ptr [ esp + 00h ] add esp , 110h pop edi pop esi pushd 00h pushd 00h mov edx,eax jmp Label52b74e ENDIF Label4699e6_allfiles :: mov eax , dword ptr [ esp + 00h ] add esp , 110h pop edi pop esi pushd 00h pushd 00h mov edx,eax jmp Label52b74e Label4699e2_file :: push esi push edi sub esp , 110h mov dword ptr [ esp + 00h ] , 00h mov dword ptr [ esp + 04h ] , 00h mov dword ptr [ esp + 08h ] , 00h mov byte ptr [ esp + 10h ] , 00h pushd 0385h pushd 02h pushd 00h lea eax , dword ptr [ ebx + 44 ] call Fun529bc5 mov dword ptr [ esp + 08h ] , eax cmp byte ptr [ ebx + 88 ] , 048h jne Label4699e6_file mov ecx , dword ptr [ ebx + 88 + 32 ] mov eax , dword ptr [ ebx + 88 + 8 ] mov edx , dword ptr [ecx] lea ecx , dword ptr [ esp + 10h ] pushd 00h pushd offset Data93a8c0 pushd offset Data91aed0 push eax call Fun42cc34 cmp byte ptr [ esp + 10h ] , 00h je Label4699e6_file mov edi , dword ptr [ Data93757c ] cmp edi , dword ptr [ Data937774 ] ja Label4699e6_file Label4699e3_file :: lea eax , dword ptr [ esp + 10h ] mov ecx , dword ptr [ edi + 12 ] test ecx , ecx jle Label4699e5_file mov ecx , dword ptr [ecx] push eax push ecx call lstrcmpiA test eax , eax jne Label4699e5_file xor ecx , ecx mov eax , dword ptr [ edi + 24h ] test eax , eax jle Label4699e6_file Label4699e4_file :: mov eax , dword ptr [ edi + 10h ] mov eax , dword ptr [eax] mov eax , dword ptr [ eax + 4 * ecx ] mov edx , dword ptr [ edi + 14h ] add eax , dword ptr [edx] cmp dword ptr [ esp + 08h ] , 01h je Label4699e4_file_lowaddressmemory cmp dword ptr [ esp + 08h ] , 02h je Label4699e4_file_largememory jmp Label4699e4_file_addmemory Label4699e4_file_lowaddressmemory :: cmp byte ptr [ eax + 14h ] , 10h jbe Label4699e4_file_addmemory jmp Label4699e4_file_nextfileblock Label4699e4_file_largememory :: cmp byte ptr [ eax + 14h ] , 10h ja Label4699e4_file_addmemory jmp Label4699e4_file_nextfileblock Label4699e4_file_addmemory :: mov eax , dword ptr [ eax + 08h ] add dword ptr [ esp + 00h ] , eax adc dword ptr [ esp + 04h ] , 00h Label4699e4_file_nextfileblock :: inc ecx cmp ecx , dword ptr [ edi + 24h ] jl Label4699e4_file IF VFPA_VERSION GE 102 mov eax , dword ptr [ esp + 00h ] mov edx , dword ptr [ esp + 04h ] add esp , 110h pop edi pop esi sub esp , 08h mov byte ptr [esp][0],"%" mov byte ptr [esp][1],"." mov byte ptr [esp][2],"0" mov byte ptr [esp][3],"f" mov byte ptr [esp][4],0 push edx push eax fild qword ptr [ esp ] fstp qword ptr [ esp ] lea eax , dword ptr [ esp + 8 ] push eax lea eax , dword ptr [ ebp + 0FFFFFDE0h ] push eax call Fun43089c add esp , 018h jmp Label52a11a ELSE mov eax , dword ptr [ esp + 00h ] add esp , 110h pop edi pop esi pushd 00h pushd 00h mov edx,eax jmp Label52b74e ENDIF Label4699e5_file :: IF VFPA_VERSION GE 101 add edi , VFPA_CONST_X64_FOXFILE_LEN ELSE add edi , 038h ENDIF cmp edi , dword ptr [ Data937774 ] jbe Label4699e3_file Label4699e6_file :: mov eax , dword ptr [ esp + 00h ] add esp , 110h pop edi pop esi pushd 00h pushd 00h mov edx,eax jmp Label52b74e Label4699e7 :: push edi ;0x004699e2 : 57 push edi ;0x004699e3 : 57 ; ; -------------------------------------------------------- ; VFP ADVANCED (X64) FIX - Support Large Memory ; February 2020 ; -------------------------------------------------------- ; CCB ; ; Support Large Memory. ; Only for VFP Advanced version 10.2 or later. ; SYS(1105) The using file data buffer size. ; ; 2020/7/14, by ccb ; IF VFPA_VERSION GE 102 call vfpa_lm_gettotalmemory_nocachedmemory mov ecx , dword ptr [ Data937784 ] add eax , ecx adc edx , 00h sub esp , 08h mov byte ptr [esp][0],"%" mov byte ptr [esp][1],"." mov byte ptr [esp][2],"0" mov byte ptr [esp][3],"f" mov byte ptr [esp][4],0 push edx push eax fild qword ptr [ esp ] fstp qword ptr [ esp ] lea eax , dword ptr [ esp + 8 ] push eax lea eax , dword ptr [ ebp + 0FFFFFDE0h ] push eax call Fun43089c add esp , 018h add esp , 08h jmp Label52a11a ENDIF Label4699e7 :: push edi ;0x004699e2 : 57 push edi ;0x004699e3 : 57 mov edx , dword ptr [ Data937784 ] ;0x004699e4 : 8b1584779300 jmp Label52b74e ;0x004699ea : e95f1d0c00 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_vfpsysfunctions.asp 6. OTHER: For reference only, there is no guarantees. Any questions or suggestions, please send me an email at ccb2000@163.com. |