From dc46e8ce2e1164c5d73191bb60e654c35f41e30e Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 23 May 2024 16:18:01 +0200 Subject: [PATCH] FpDebug: Windows, implement alternative "normal" file reading (via stream). On 32bit mapping an entire file into memory can fail, if not enough continuous memory is available. --- components/fpdebug/fpimgreaderbase.pas | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/fpdebug/fpimgreaderbase.pas b/components/fpdebug/fpimgreaderbase.pas index e611e38a44..c099cdf77a 100644 --- a/components/fpdebug/fpimgreaderbase.pas +++ b/components/fpdebug/fpimgreaderbase.pas @@ -338,6 +338,14 @@ begin FModulePtr := MapViewOfFile(FMapHandle, FILE_MAP_READ, 0, 0, 0); if FModulePtr = nil then begin + if GetLastError = 8 then begin // not enough memory, use a stream instead + CloseHandle(FMapHandle); + FMapHandle := 0; + FList := TList.Create; + FStream := THandleStream.Create(AFileHandle); + inherited Create; + exit; + end; raise Exception.Create('Could not map view: ' + IntToStr(GetLastOSError)); Exit; end;