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.

This commit is contained in:
Martin 2024-05-23 16:18:01 +02:00
parent 5b84fae03d
commit dc46e8ce2e

View File

@ -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;