简体   繁体   中英

Using Module32First/Next to Enumerate 32bit Process Modules from 64bit Process

Here's the code:

 hModuleSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE32, dwPID ); 
  if( hModuleSnap == INVALID_HANDLE_VALUE ) 
  { 

    return( r_mi ); 
  } 


  me32.dwSize = sizeof( MODULEENTRY32 ); 

  if( !Module32First( hModuleSnap, &me32 ) ) 
  { 

    CloseHandle( hModuleSnap );
    return( r_mi ); 
  } 

  do 
  { 
      MessageBoxA(0,me32.szModule,0,0);

  } while( Module32Next( hModuleSnap, &me32 ) );

Problem is that when trying to enumerate the modules of a 32bit process from a 64bit process, only the x64 modules are being listed.

From MSDN for TH32CS_SNAPMODULE32: Includes all 32-bit modules of the process specified in th32ProcessID in the snapshot when called from a 64-bit process.

But still, it's only listing the x64 modules

Anyone know a work around for this?

You have to use TH32CS_SNAPMODULE32 | TH32CS_SNAPMODULE thanks for Hans Passant for figuring this out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM