GetProcessModules – The list of DLLs and OCXes a process uses

GetProcessModules – The list of DLLs and OCXes a process uses

Const MAX_MODULE_NAmeInfo = 255Const MAX_PATH = 260Const TH32CS_SNAPMODULE = &H8Private Type MODULEENTRY32    dwSize As Long    th32ModuleID As Long    th32ProcessID As Long    GlblcntUsage As Long    ProccntUsage As Long    modBaseAddr As Long    modBaseSize As Long    hModule As Long    szModule As String * 256    szExePath As String * MAX_PATHEnd TypePrivate Declare Function CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal _    dest As Any, ByVal source As Any, ByVal bytes As Long) As LongPrivate Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias _    "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) _    As LongPrivate Declare Function Module32First Lib "kernel32" (ByVal hSnapshot As Long, _    lpmeInfo As MODULEENTRY32) As LongPrivate Declare Function Module32Next Lib "kernel32" (ByVal hSnapshot As Long, _    lpmeInfo As MODULEENTRY32) As LongPrivate Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long' Return the list of DLLs and OCXes that a process uses' if argument if omitted, the current process is used'' names are stored starting at element 1 in the result array' thus UBound(result) gives the number of modules' in general, the first element is the name of the EXE file.' NOTES: works only on Win 9x and 2000 (not on NT)Function GetProcessModules(Optional ByVal processID As Long = -1) As String()    Dim meInfo As MODULEENTRY32    Dim success As Long    Dim hSnapshot As Long    ReDim res(0) As String    Dim count As Long        ' provide a default argument, if missing    If processID = -1 Then processID = GetCurrentProcessId        ' get information about the given process    hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPMODULE, processID)    ' exit now if process ID is invalid    If hSnapshot = 0 Then GoTo ExitProc        ' prepare the structure for receiving info    meInfo.dwSize = Len(meInfo)        ' get info on the first module    success = Module32First(hSnapshot, meInfo)    Do While success        ' consider only modules belonging to the specified process        If meInfo.th32ProcessID = processID Then            count = count + 1            ' make room in the array, if needed            If count > UBound(res) Then                ReDim Preserve res(count + 100) As String            End If            ' store the result            res(count) = Left$(meInfo.szExePath, InStr(meInfo.szExePath & _                vbNullChar, vbNullChar) - 1)        End If        ' continue the search        success = Module32Next(hSnapshot, meInfo)    Loop        ' close the snapshot    CloseHandle hSnapshot    ExitProc:    ' trim out elements in excess    ReDim Preserve res(0 To count) As String        GetProcessModules = resEnd Function

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes