--------------------------------------------------------------------------
[ENHANCED] VFP 9.0 FIX - CATCH THE BUFFER OVERRUN DETECTED ERROR
July 2026
--------------------------------------------------------------------------
CCB
1. BUG:
If we enable catching the buffer overrun detected error in Visual FoxPro Advanced,
when Visual FoxPro causes the buffer overrun detected error (exception code 0xC0000409),
it will display a dialog box "Are you sure you want to exit Visual FoxPro?",
if we select "Yes", it will display the Visual C++ runtime error dialog, and then exit Visual FoxPro,
if we select "No", it will cause the error "There is not enough memory to complete this operation (Error 43)",
and then it will return to Visual FoxPro, now we can do some important works, and then exit Visual FoxPro.
It is the startup default for Visual FoxPro Advanced Interactive Development Environment (IDE).
Please refer to the picture testbufferoverrun.png:
If we disable catching the buffer overrun detected error in Visual FoxPro Advanced,
when Visual FoxPro causes the buffer overrun detected error (exception code 0xC0000409),
it will display the Visual C++ runtime error dialog, and then exit Visual FoxPro.
It is the startup default for Visual FoxPro Advanced Runtime and Visual FoxPro Advanced Multi-threaded Runtime.
Please refer to the picture testbufferoverrun2.png:
2. CAUSE:
There are some BUGs in the following code.
3. RESOLUTION:
We can write some code to fix the BUG.
Fun42bf1d :: ; proc near
cmp ecx , dword ptr [ Data937090 ] ;0x0042bf1d : 3b0d90709300
jne Label91639f ;0x0042bf23 : 0f8576a44e00
ret ;0x0042bf29 : c3
Label91639f ::
pushd 08h ;0x0091639f : 6a08
pushd offset Data9259a8 ;0x009163a1 : 68a8599200
call Fun42c14f ;0x009163a6 : e8a45db1ff
and dword ptr [ ebp - 4 ] , 00h ;0x009163ab : 8365fc00
;
; ---------------------------------------------------------------
; VFP 9.0 FIX - CATCH THE BUFFER OVERRUN DETECTED ERROR
; July 2026
; ---------------------------------------------------------------
; CCB
;
; Catch the buffer overrun detected error (exception code 0xC0000409).
;
; 2026/7/29, by ccb
;
cmp dword ptr vfpa_sys9211_data,00h
je Label9163ae
cmp dword ptr vfpa_sys9211_data,02h
je Label9163ae
pushd 00h
pushd 02h
pushd 00h
pushd 00h
lea eax , byte ptr vfpa_sys9211_text
push eax
call Fun6da248
cmp eax , 02h
jne Label9163ae
mov ecx , 0B6h
jmp Fun544742
Label9163ae ::
IF VFPA_VERSION GE 102
call vfpa_lmm_release
ENDIF
cmp dword ptr vfpa_sys9211_data,02h
jne Label9163af
push 03h
call _exit
Label9163af ::
pushd 00h ;0x009163af : 6a00
pushd 01h ;0x009163b1 : 6a01
call __security_error_handler ;0x009163b3 : e817000000
pop ecx ;0x009163b8 : 59
pop ecx ;0x009163b9 : 59
jmp Label9163c3 ;0x009163ba : eb07
Label9163bc ::
xor eax , eax ;0x009163bc : 33c0
inc eax ;0x009163be : 40
ret ;0x009163bf : c3
Label9163c0 ::
mov esp , dword ptr [ ebp - 24 ] ;0x009163c0 : 8b65e8
Label9163c3 ::
or dword ptr [ ebp - 4 ] , 0FFFFFFFFh ;0x009163c3 : 834dfcff
pushd 03h ;0x009163c7 : 6a03
call ExitProcess ;0x009163c9 : ff1504709100
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_vfp9fix422.asp
http://www.baiyujia.com/vfpdocuments/f_vfp9fix212.asp
http://www.baiyujia.com/vfpdocuments/f_vfp9fix213.asp
http://www.baiyujia.com/vfpdocuments/f_vfp9fix214.asp
http://www.baiyujia.com/vfpdocuments/f_vfp9fix215.asp
http://www.baiyujia.com/vfpdocuments/f_vfp9fix422.asp
http://www.baiyujia.com/vfpdocuments/f_vfp9fix423.asp
2, microsoft.com:
https://learn.microsoft.com/en-us/cpp/build/reference/gs-buffer-security-check?view=msvc-170
https://devblogs.microsoft.com/oldnewthing/20190108-00/?p=100655
6. OTHER:
For reference only, there is no guarantees.
Any questions or suggestions, please send me an email at ccb2000@163.com.
|