Jump to content

Recommended Posts

Posted (edited)

I recently read How do I find which Dlls contain specific W32 functions ?
and I found this:

// Source - https://stackoverflow.com/questions/21565739/how-do-i-find-which-dlls-contain-specific-w32-functions
// Posted by noseratio, modified by community. See post 'Timeline' for change history
// Retrieved 2025-11-30, License - CC BY-SA 3.0

for %f in (%windir%\system32\*.dll) do dumpbin.exe /exports %f >>%temp%\__exports

which however gave me a single file with 412000 lines, really, difficult to sort and explore

so I used Autoit
to extract information only for dlls that have at least one function, (2645 files in total)
and to extract, in a subfolder of the script,
for each dll a txt file with the name of the dll and the number of functions
e.g. for AddressParser.Dll it makes AddressParser(18).txt
with the help of dumpbin.exe  (external tool from the Visual Studio SDK).

for anyone with a curiosity for exploration

; https://www.autoitscript.com/forum/topic/213347-lists-the-system-libraries-dlls-which-have-functions/
;----------------------------------------------------------------------------------------
; Title...........: Print-all-dlls.au3
; Description.....: The script lists the system libraries (DLLs), which have functions,
;                   using the external tool dumpbin.exe (from the Visual Studio SDK).
; AutoIt Version..: 3.3.18.0   Author: ioa747           Script Version: 0.2
; Note............: Testet in Windows 11 Pro 24H2       Date:30/11/2025
; Info............: https://learn.microsoft.com/en-us/cpp/build/reference/dumpbin-reference?view=msvc-170
;----------------------------------------------------------------------------------------
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

#RequireAdmin
#include <File.au3>

_Print_all_dlls()

Func _Print_all_dlls($iNumFunctionsLimit = 0)
    ; The path to dumpbin.exe. <- Put your own path. 👈
    Local Const $sDumpBinPath = "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x86\dumpbin.exe"
    If Not FileExists($sDumpBinPath) Then Exit MsgBox(16, "Error", "Could not find dumpbin.exe path in " & @CRLF & $sDumpBinPath)

    Local $sSystemDir = @SystemDir
    Local $sSystemDirLen = StringLen($sSystemDir)
    ConsoleWrite("System Directory: " & $sSystemDir & ", Length: " & $sSystemDirLen & @CRLF)

    ; Remove older output directory if already exist (in ScriptDir)
    Local Const $sOutputDir = @ScriptDir & "\DllExportsAnalysis\"
    If FileExists($sOutputDir) Then DirRemove($sOutputDir, $DIR_REMOVE)
    DirCreate($sOutputDir)

    ; Find all DLL files in the system directory, recursively searching subfolders.
    Local $aDllFiles = _FileListToArrayRec($sSystemDir, "*.dll", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)

    If IsArray($aDllFiles) Then

        Local $iTotalFiles = $aDllFiles[0]
        ConsoleWrite("Found " & $iTotalFiles & " DLL files." & @CRLF)

        ; Loop through each found DLL
        For $i = 1 To $iTotalFiles ; <- Change $iTotalFiles to 10 for limited testing. 👈️
            Local $sFullDllPath = $aDllFiles[$i]
            Local $iNumFunctions = 0

            Local $sTempFile = @ScriptDir & "\temp_dump.tmp"

            ; Execute  dumpbin.exe and capture the output
            RunWait($sDumpBinPath & ' /exports /OUT:"' & $sTempFile & '" "' & $sFullDllPath & '"', "", @SW_HIDE)

            Local $sDumpOutput = FileRead($sTempFile)
            Local $aMatches = StringRegExp($sDumpOutput, '(\d+)\s+number of functions', 3)

            If IsArray($aMatches) Then
                ; The first captured group (index 0) is the number of functions
                $iNumFunctions = Number($aMatches[0])
            EndIf

            If $iNumFunctions > $iNumFunctionsLimit Then
                Local $sBaseName = StringTrimRight(StringTrimLeft($sFullDllPath, $sSystemDirLen + 1), 4)
                $sBaseName = StringReplace($sBaseName, "\", "_")
                Local $sFinalOutputPath = $sOutputDir & $sBaseName & "(" & $iNumFunctions & ").txt"
                FileWrite($sFinalOutputPath, $sDumpOutput)
                ConsoleWrite("- SUCCESS - " & $sFullDllPath & " -> Functions: " & $iNumFunctions & @CRLF)
            Else
                ConsoleWrite("+ SKIPPED - " & $sFullDllPath & " - Functions: 0" & @CRLF)
            EndIf

            FileDelete($sTempFile)
        Next

        MsgBox(0, "Script Complete", "Analysis finished. Check the results in: " & $sOutputDir)
    Else
        MsgBox(16, "Error", "Could not find DLL files in " & $sSystemDir & ". Check permissions or path.")
    EndIf
EndFunc   ;==>_Print_all_dlls

 

Please, every comment is appreciated!
leave your comments and experiences here!
Thank you very much  :)

 

Edited by ioa747

I know that I know nothing

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...