如题
目前我能用Module32First  Module32Next
列出应用程序的进程模块 比如 qq的
但是一些系统的进程模块不能显示 比如smss.exe 等等

解决方案 »

  1.   

    下面是《windows核心编程》列举  本进程文件映像(包括可执行文件和D L L),可以参考一下
    char szBuf[MAX_PATH * 100] = { 0 };PBYTE pb = NULL;
    MEMORY_BASIC_INFORMATION mbi;
    while(VirtualQuery(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. This region contains this DLL.
          // 2. This block is NOT the beginning of a region.
          // 3. The address is NULL.
          nLen = 0;
       } 
       else 
       {
          nLen = GetModuleFileNameA((HINSTANCE) mbi.AllocationBase,
             szModName, chDIMOF(szModName));
       }   if(nLen > 0) 
       {
          wsprintfA(strchr(szBuf, 0), "\n%08X-%s",
             mbi.AllocationBase, szModName);
       }   pb += mbi.RegionSize;
    }
    chMB(&szBuf[1]);
      

  2.   

    权限提升没?这些系统进程要提升到Debug权限才可以的.而且提升到Debug权限,你必须运行在管理员权限下.(值得一说的是smss不是win32程序).
    列举模块前先调用一下:EnableDebugPrivilege(TRUE)
    代码如下..
    BOOL EnableDebugPrivilege(BOOL bEnable) 
    {
    // 附给本进程特权,以便访问系统进程
    BOOL bOk = FALSE; 
    HANDLE hToken;

    // 打开一个进程的访问令牌
    if(::OpenProcessToken(::GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken)) 
    {
    // 取得特权名称为“SetDebugPrivilege”的LUID
    LUID uID;
    ::LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &uID); // 调整特权级别
    TOKEN_PRIVILEGES tp;
    tp.PrivilegeCount = 1;
    tp.Privileges[0].Luid = uID;
    tp.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
    ::AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(tp), NULL, NULL);
    bOk = (::GetLastError() == ERROR_SUCCESS); // 关闭访问令牌句柄
    ::CloseHandle(hToken);
    }
    return bOk;
    }