mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-14 13:59:34 +02:00
* FpDebug: Fix for handling processes that do not provide a real file-handle.
This commit is contained in:
parent
a9457c2f2b
commit
a05f75154d
@ -447,9 +447,11 @@ end;
|
||||
procedure tDbgWinLibrary.InitializeLoaders;
|
||||
var
|
||||
FileInformation: TByHandleFileInformation;
|
||||
Loader: TDbgImageLoader;
|
||||
begin
|
||||
Loader := nil;
|
||||
if GetFileInformationByHandle(FInfo.hFile, FileInformation) then
|
||||
TDbgImageLoaderLibrary.Create(FInfo.hFile, nil, TDBGPtr(FInfo.lpBaseOfDll)).AddToLoaderList(LoaderList)
|
||||
Loader := TDbgImageLoaderLibrary.Create(FInfo.hFile, nil, TDBGPtr(FInfo.lpBaseOfDll))
|
||||
else if Name <> '' then
|
||||
begin
|
||||
// There are situations in which the provided handle is not a file-handle. In
|
||||
@ -457,10 +459,14 @@ begin
|
||||
// (Happened in a Windows-docker (Azure, AKS) on the kernel32.dll. No idea
|
||||
// why, though)
|
||||
if FileExists(Name) then
|
||||
TDbgImageLoaderLibrary.Create(Name, nil, TDBGPtr(FInfo.lpBaseOfDll)).AddToLoaderList(LoaderList)
|
||||
Loader := TDbgImageLoaderLibrary.Create(Name, nil, TDBGPtr(FInfo.lpBaseOfDll))
|
||||
else
|
||||
DebugLn(DBG_WARNINGS, 'File [%s] related to library does not exist', [Name]);
|
||||
end;
|
||||
if Assigned(Loader) and Loader.IsValid then
|
||||
Loader.AddToLoaderList(LoaderList)
|
||||
else
|
||||
Loader.Free;
|
||||
end;
|
||||
|
||||
constructor tDbgWinLibrary.Create(const AProcess: TDbgProcess;
|
||||
@ -493,10 +499,24 @@ end;
|
||||
|
||||
procedure TDbgWinProcess.InitializeLoaders;
|
||||
var
|
||||
FileInformation: TByHandleFileInformation;
|
||||
Loader: TDbgImageLoader;
|
||||
begin
|
||||
Loader := TDbgImageLoader.Create(FInfo.hFile, nil, TDbgPtr(FInfo.lpBaseOfImage));
|
||||
if Loader.IsValid then
|
||||
Loader := nil;
|
||||
if GetFileInformationByHandle(FInfo.hFile, FileInformation) then
|
||||
Loader := TDbgImageLoader.Create(FInfo.hFile, nil, TDbgPtr(FInfo.lpBaseOfImage))
|
||||
else if Name <> '' then
|
||||
begin
|
||||
// There are situations in which the provided handle is not a file-handle. In
|
||||
// those cases, use the filename as fallback.
|
||||
// (Happened in a Windows-docker (Azure, AKS) on the kernel32.dll. No idea
|
||||
// why, though)
|
||||
if FileExists(Name) then
|
||||
Loader := TDbgImageLoader.Create(Name, nil, TDBGPtr(FInfo.lpBaseOfImage))
|
||||
else
|
||||
DebugLn(DBG_WARNINGS, 'File [%s] related to the process does not exist', [Name]);
|
||||
end;
|
||||
if Assigned(Loader) and Loader.IsValid then
|
||||
Loader.AddToLoaderList(LoaderList)
|
||||
else
|
||||
Loader.Free;
|
||||
|
Loading…
Reference in New Issue
Block a user