#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Info.ico #AutoIt3Wrapper_Outfile=PEGetImportsX86.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_UPX_Parameters=--best --lzma #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_OutFile_X86=PEGetImportsX86.exe #AutoIt3Wrapper_Res_Comment=X86 Version #AutoIt3Wrapper_Res_Description=Get Dependencies of EXE and DLL #AutoIt3Wrapper_Res_Fileversion=1.0.0.1 #AutoIt3Wrapper_Res_ProductName=PEGetImports #AutoIt3Wrapper_Res_ProductVersion=1.0.0.1 #AutoIt3Wrapper_Res_Field=Compiled with | AutoIt Version 3.3.18.0 #AutoIt3Wrapper_Res_Field=Compile date|%longdate% #AutoIt3Wrapper_AU3Check_Stop_OnWarning=y #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Run_After=del "%scriptfile%_stripped.au3" #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe /rm #AutoIt3Wrapper_Versioning=v #AutoIt3Wrapper_Versioning_Parameters=/Comments %fileversionnew% #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Region ------ Includes ------------------------------ #Region ;************ Includes ************ #Include #include #EndRegion ;************ Includes ************ #EndRegion --- Includes ------------------------------ Opt('MustDeclareVars', 1) OnAutoItExitRegister ( '_OnAutoItExit' ) Global Const $IMAGE_DIRECTORY_ENTRY_IMPORT = 1 Global $sFile, $aDllList[0], $hWnd, $idEditImports #Region ------ Init ------------------------------ If $CMDLine[0] > 0 Then $sFile = FileGetLongName($CmdLine[1]) Else Exit EndIf #EndRegion --- Init ------------------------------ $aDllList = _WinAPI_ListDLLImports($sFile) ;~ If @error Then ConsoleWrite( '! @error _WinAPI_ListDLLImports : ' & @error & @Crlf ) If Not IsArray($aDllList) Then ;~ MsgBox(262144, 'Result for ' & StringRegExpReplace($sFile, ".+\\(.+)", "$1"), 'No dependencies found', 4) Else For $i = 1 To UBound( $aDllList ) -1 ConsoleWrite($aDllList[$i] & @CRLF) Next Sleep(1000) EndIf Exit Func _WinAPI_ListDLLImports($sFile ) ; by UEZ (modified) Local Const $hModule = _WinAPI_LoadLibraryEx($sFile, BitOR($DONT_RESOLVE_DLL_REFERENCES, $LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR)) ;~ Local Const $hModule = _WinAPI_LoadLibrary($sFile ) If Not $hModule Then Return SetError(1, 0, 0) Local Const $tSize = DllStructCreate("ulong bytes") ;https://learn.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-imagedirectoryentrytodata Local Const $aReturn = DllCall("Dbghelp.dll", "ptr", "ImageDirectoryEntryToData", "ptr", $hModule, "boolean", True, "ushort", $IMAGE_DIRECTORY_ENTRY_IMPORT, "struct*", $tSize) If Not IsArray($aReturn) Or @error Then _WinAPI_FreeLibrary($hModule) Return SetError(2, 0, 0) EndIf If Not $aReturn[0] Then _WinAPI_FreeLibrary($hModule) Return SetError(3, 0, 0) EndIf Local $tIMAGE_IMPORT_DESCRIPTOR, $sDLLName, $i While 1 $tIMAGE_IMPORT_DESCRIPTOR = DllStructCreate("dword dummy;dword TimeDateStamp;dword ForwarderChain;dword Name;dword FirstThunk;", $aReturn[0] + $i) If Not $tIMAGE_IMPORT_DESCRIPTOR.FirstThunk Then _WinAPI_FreeLibrary($hModule) $aDllList = _ArrayUnique($aDllList) _ArraySort($aDllList, 0, 0, 0, 0) $tIMAGE_IMPORT_DESCRIPTOR=0 Return $aDllList Else $sDLLName = _WinAPI_WideCharToMultiByte(DllStructCreate("char Text[64];", $hModule + $tIMAGE_IMPORT_DESCRIPTOR.name).Text, 65001); UTF-8 _ArrayAdd($aDllList, StringLower ($sDLLName)) Endif $i += DllStructGetSize($tIMAGE_IMPORT_DESCRIPTOR) Sleep(10) WEnd EndFunc ;==> _WinAPI_ListDLLImports Func __ReturnGBT2(Byref $hMapping, ByRef $hFile, $iError) ; by UEZ _WinAPI_CloseHandle($hMapping) _WinAPI_CloseHandle($hFile) If $iError Then Return SetError($iError, 0, 0) EndFunc ;==>__ReturnGBT2 Func _OnAutoItExit() ; self delete after 3 sec If $CMDLine[0] > 0 And @Compiled Then Run(@ComSpec & ' /c ping 127.0.0.1 -n 3 & del /q "' & @ScriptFullPath & '"', @SystemDir, @SW_HIDE, $RUN_CREATE_NEW_CONSOLE ) EndFunc ;==> _OnAutoItExit