How to check if an Executable loaded certain Dll at runtime?

Just starting out? Need help? Post your questions and find answers here.
Maya

How to check if an Executable loaded certain Dll at runtime?

Post by Maya »

Good Morning,
Suppose we are monitoring the execution of "Test.exe" which loads "TestDll.dll" at runtime.

How to check if this Executable is already loaded this Dll?
and, how to get the "Module Handle" of this Dll?

Any help will be much appreciated.
User avatar
jacdelad
Addict
Addict
Posts: 1993
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: How to check if an Executable loaded certain Dll at runtime?

Post by jacdelad »

Via command line:

Code: Select all

C:\>tasklist /m /fi "services eq Winmgmt"

Image Name                     PID Modules
========================= ======== ============================================
svchost.exe                    872 ntdll.dll, kernel32.dll, KERNELBASE.dll,
                                   msvcrt.dll, sechost.dll, RPCRT4.dll,
                                   ole32.dll, GDI32.dll, USER32.dll, LPK.dll,
                                   USP10.dll, IMM32.DLL, MSCTF.dll,...
Include this call into your program.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Maya

Re: How to check if an Executable loaded certain Dll at runtime?

Post by Maya »

jacdelad wrote: Sat Jan 06, 2024 12:51 am Via command line:

Code: Select all

C:\>tasklist /m /fi "services eq Winmgmt"

Image Name                     PID Modules
========================= ======== ============================================
svchost.exe                    872 ntdll.dll, kernel32.dll, KERNELBASE.dll,
                                   msvcrt.dll, sechost.dll, RPCRT4.dll,
                                   ole32.dll, GDI32.dll, USER32.dll, LPK.dll,
                                   USP10.dll, IMM32.DLL, MSCTF.dll,...
Include this call into your program.
I mean thru PureBasic!
AZJIO
Addict
Addict
Posts: 2143
Joined: Sun May 14, 2017 1:48 am

Re: How to check if an Executable loaded certain Dll at runtime?

Post by AZJIO »

Code: Select all

If OpenLibrary(#Library , Filename$)
	Debug "already loaded"
	Debug LibraryID(#Library)
EndIf
Maya

Re: How to check if an Executable loaded certain Dll at runtime?

Post by Maya »

AZJIO wrote: Sat Jan 06, 2024 11:07 am

Code: Select all

If OpenLibrary(#Library , Filename$)
	Debug "already loaded"
	Debug LibraryID(#Library)
EndIf
Dear AZJIO:
YOU ARE MY HERO! 🧡
Thank you very much..
User avatar
jacdelad
Addict
Addict
Posts: 1993
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: How to check if an Executable loaded certain Dll at runtime?

Post by jacdelad »

What?
Maya wrote: Sat Jan 06, 2024 12:06 am Suppose we are monitoring the execution of "Test.exe" which loads "TestDll.dll" at runtime.
This sounds absolutely like your program monitors a different program and wants to know whether this different program has loaded a certain dll...
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PoorMan
User
User
Posts: 15
Joined: Sat Oct 14, 2023 2:54 pm

Re: How to check if an Executable loaded certain Dll at runtime?

Post by PoorMan »

This sounds absolutely like your program monitors a different program and wants to know whether this different program has loaded a certain dll...
So what?
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: How to check if an Executable loaded certain Dll at runtime?

Post by DarkDragon »

PoorMan wrote: Wed Jan 17, 2024 6:56 am
This sounds absolutely like your program monitors a different program and wants to know whether this different program has loaded a certain dll...
So what?
OpenLibrary is inside the current process. Not in the monitored one as in the problem description. Also it is actively loading the DLL. It doesn't check whether the DLL has been loaded, it loads the DLL. If the process would never touch the DLL you wouldn't know because you loaded it.
bye,
Daniel
Post Reply