badzox Posted June 24, 2008 Share Posted June 24, 2008 (edited) Hi, i want to list all Processes with Name and Pid, which use one Dll. The Code only searches inside the processes of the user .. not in all processes like System, network , local etc.. It should search everywhere not only in process of the user. Does anybody know what is wrong here? After that i want to unload the dll from all process (but this is the next step - perhaps someone could also help to code this ?? ) I´m a newbie, so please excuse my errors... : CODE#include<Array.au3> _ListDlls ("kernel32") Func _ListDlls ($DllName) Local $Proclist = ProcessList() Local $ProcMod, $Result,$test Local $i,$t For $i = 1 to UBound($Proclist)-1 If $Proclist[$i][1] > 0 Then $ProcMod = _ProcessListModules($Proclist[$i][0]) For $t = 1 to UBound($ProcMod)-1 If StringInStr(StringLower($ProcMod[$t][1]),StringLower($DllName)) <> 0 Then $Result = $Result & "Process: " & $Proclist[$i][0] & " " & "PID: " & $Proclist[$i][1] & @CRLF & "Dll: " & $ProcMod[$t][1] & @CRLF & @CRLF EndIf Next EndIf Next msgbox (0,"Testfinish",$Result) EndFunc Func _ProcessListModules($dwPID) If IsInt($dwPID) = 0 Then $dwPID = ProcessExists($dwPID) Local Const $TH32CS_SNAPALL = BitOR(0x01, 0x08, 0x02, 0x04) Local $aDLLCall, $tagMODULEENTRY32, $hModuleSnap $aDLLCall = DllCall("Kernel32.dll", "ptr", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPALL, "dword", $dwPID) If @error Or $aDLLCall[0] = 0xFFFFFFFF Then Return SetError(1, 0, 0) $hModuleSnap = $aDLLCall[0] $tagMODULEENTRY32 = DllStructCreate("dword;dword;dword;dword;dword;byte;dword;uint;char[257];char[256]") DllStructSetData($tagMODULEENTRY32, 1, DllStructGetSize($tagMODULEENTRY32)) $aDLLCall = DllCall("Kernel32.dll", "int", "Module32First", "ptr", $hModuleSnap, "long", DllStructGetPtr($tagMODULEENTRY32)) If @error Or Not $aDLLCall[0] Then Return SetError(2, DllCall("Kernel32.dll", "int", "CloseHandle", "ptr", $hModuleSnap), 0) Local $avArray[2][2], $iAdd = 1 While 1 $avArray[$iAdd][0] = DllStructGetData($tagMODULEENTRY32, 9) ; File Name $avArray[$iAdd][1] = DllStructGetData($tagMODULEENTRY32, 10) ; File Path $aDLLCall = DllCall("kernel32", "int", "Module32Next", "ptr", $hModuleSnap, "long", DllStructGetPtr($tagMODULEENTRY32)) If @error Then Return SetError(3, DllCall("Kernel32.dll", "int", "CloseHandle", "ptr", $hModuleSnap), 0) If Not $aDLLCall[0] Then ExitLoop $iAdd += 1 ReDim $avArray[$iAdd + 1][2] WEnd DllCall("Kernel32.dll", "int", "CloseHandle", "ptr", $hModuleSnap) $avArray[0][0] = $iAdd Return $avArray EndFunc Edited June 24, 2008 by badzox Link to comment Share on other sites More sharing options...
ptrex Posted June 25, 2008 Share Posted June 25, 2008 @badzox Don't overcomplicate things. Open CMD -> tasklist /M Regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
badzox Posted July 31, 2008 Author Share Posted July 31, 2008 (edited) Tasklist doesn´t list all Dlls ! From Services per Expamle. Ic checked It with Sysinternals ListDlls. I would like to do it without tasklist only per Script. Hopefully only with Kernel Dlls.... Can someone look over the code above ? Edited July 31, 2008 by badzox Link to comment Share on other sites More sharing options...
badzox Posted November 5, 2008 Author Share Posted November 5, 2008 Anyone out there who wanna help out ? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now