Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9040195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:55:33+00:00 2026-06-16T09:55:33+00:00

I am trying to get a list of DLLs that a given process is

  • 0

I am trying to get a list of DLLs that a given process is using, I am trying to achieve that through VirtualQueryEx. My problem is that it return to me just a partial list of DLLs and not all of them (i can see the list using Process Explorer or using VirtualQuery on the given process).

Here’s the code:

    char szBuf[MAX_PATH * 100] = { 0 };
    PBYTE pb = NULL;
    MEMORY_BASIC_INFORMATION mbi;
    HANDLE h_process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, iPID);


    while (VirtualQueryEx(h_process, pb, &mbi, sizeof(mbi)) == sizeof(mbi)) {

        int nLen;
        char szModName[MAX_PATH];

        if (mbi.State == MEM_FREE)
        mbi.AllocationBase = mbi.BaseAddress;

        if ((mbi.AllocationBase == hInstDll) ||
            (mbi.AllocationBase != mbi.BaseAddress) ||
            (mbi.AllocationBase == NULL)) {
        // Do not add the module name to the list
        // if any of the following is true:
        // 1. If this region contains this DLL
        // 2. If this block is NOT the beginning of a region
        // 3. If the address is NULL
        nLen = 0;
        } else {
        nLen = GetModuleFileNameA((HINSTANCE) mbi.AllocationBase, 
            szModName, _countof(szModName));
        }

        if (nLen > 0) {
        wsprintfA(strchr(szBuf, 0), "\n%p-%s", 
            mbi.AllocationBase, szModName);
        }

        pb += mbi.RegionSize;
    }

I am getting the result on szBuf.

This function is part of a DLL file so that it is harder for me to debug.

Right now the DLL is compiled as x64 binary and i am using it against x64 processes.

P.S i know about EnumProcessModules and i am not using it with a reason (too long:).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:55:34+00:00Added an answer on June 16, 2026 at 9:55 am

    GetModuleFileName() only gives you the name for modules loaded in your process, not the other process. It will give you a few hits by accident, the Windows operating system DLLs will get loaded at the same address and will thus have the same module handle value.

    You will need to use GetModuleFileNameEx() so you can pass the process handle.

    Do note the fundamental flaw with your code as posted, you are not doing anything to ensure that you can safely use VirtualQueryEx() on another process. Which requires that you suspend all its threads so it cannot allocate memory while you are iterating it, the kind of thing a debugger does. Also required for EnumProcessModules. The failure mode is nasty, it is random and it can easily get your loop stuck, iterating the same addresses over and over again. Which is why the CreateToolHelp32Snapshot() function exists, emphasis on “snapshot”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get a list of subdirectories in a given directory using
I am trying to get a list of tmux sockets that are currently being
I'm trying to get a list in JavaScript (not using jQuery) of all the
I'm trying to get a list of comports that are currently in use to
I'm trying to get a list of user's friends using fb connect for the
I'm trying get a list of CNAME records using PHP. This method used to
Hi im working on iphone application using monotouch im trying to get list of
Trying to get a list of drives from a server side application using a
Im trying to get a list of line items to a webpage using JSON,
I was trying to get a list of files under a directory using: val

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.