mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 16:19:27 +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;
|
procedure tDbgWinLibrary.InitializeLoaders;
|
||||||
var
|
var
|
||||||
FileInformation: TByHandleFileInformation;
|
FileInformation: TByHandleFileInformation;
|
||||||
|
Loader: TDbgImageLoader;
|
||||||
begin
|
begin
|
||||||
|
Loader := nil;
|
||||||
if GetFileInformationByHandle(FInfo.hFile, FileInformation) then
|
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
|
else if Name <> '' then
|
||||||
begin
|
begin
|
||||||
// There are situations in which the provided handle is not a file-handle. In
|
// 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
|
// (Happened in a Windows-docker (Azure, AKS) on the kernel32.dll. No idea
|
||||||
// why, though)
|
// why, though)
|
||||||
if FileExists(Name) then
|
if FileExists(Name) then
|
||||||
TDbgImageLoaderLibrary.Create(Name, nil, TDBGPtr(FInfo.lpBaseOfDll)).AddToLoaderList(LoaderList)
|
Loader := TDbgImageLoaderLibrary.Create(Name, nil, TDBGPtr(FInfo.lpBaseOfDll))
|
||||||
else
|
else
|
||||||
DebugLn(DBG_WARNINGS, 'File [%s] related to library does not exist', [Name]);
|
DebugLn(DBG_WARNINGS, 'File [%s] related to library does not exist', [Name]);
|
||||||
end;
|
end;
|
||||||
|
if Assigned(Loader) and Loader.IsValid then
|
||||||
|
Loader.AddToLoaderList(LoaderList)
|
||||||
|
else
|
||||||
|
Loader.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor tDbgWinLibrary.Create(const AProcess: TDbgProcess;
|
constructor tDbgWinLibrary.Create(const AProcess: TDbgProcess;
|
||||||
@ -493,10 +499,24 @@ end;
|
|||||||
|
|
||||||
procedure TDbgWinProcess.InitializeLoaders;
|
procedure TDbgWinProcess.InitializeLoaders;
|
||||||
var
|
var
|
||||||
|
FileInformation: TByHandleFileInformation;
|
||||||
Loader: TDbgImageLoader;
|
Loader: TDbgImageLoader;
|
||||||
begin
|
begin
|
||||||
Loader := TDbgImageLoader.Create(FInfo.hFile, nil, TDbgPtr(FInfo.lpBaseOfImage));
|
Loader := nil;
|
||||||
if Loader.IsValid then
|
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)
|
Loader.AddToLoaderList(LoaderList)
|
||||||
else
|
else
|
||||||
Loader.Free;
|
Loader.Free;
|
||||||
|
Loading…
Reference in New Issue
Block a user