Skip to content

Instantly share code, notes, and snippets.

@S3cur3Th1sSh1t
Created April 13, 2023 08:32
Show Gist options
  • Save S3cur3Th1sSh1t/d9aad93027aad893adae8805d59e2d73 to your computer and use it in GitHub Desktop.
Save S3cur3Th1sSh1t/d9aad93027aad893adae8805d59e2d73 to your computer and use it in GitHub Desktop.
# Get the DLL file path from user input
$dllPath = Read-Host "Enter the DLL file path"
# Get all running processes
$processes = Get-Process
# Loop through each process
foreach ($process in $processes) {
$processName = $process.ProcessName
# Check if the DLL is loaded in the process
try {
$loadedModules = Get-Process -Id $process.Id -Module -ErrorAction Stop
$isDllLoaded = $loadedModules.ModuleName -contains (Get-Item -Path $dllPath).Name
} catch {
# Handle access denied error gracefully
if ($_.Exception.Message -like "*Cannot enumerate the modules*") {
Write-Host "Access denied for process '$processName'"
continue
} else {
Write-Host "Failed to retrieve modules for process '$processName': $($_.Exception.Message)"
continue
}
}
if (!$isDllLoaded) {
Write-Host "DLL not loaded in process '$processName'"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment