Steve Dell
Steve Dell

Reputation: 605

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?

Upvotes: 4

Views: 2948

Answers (1)

HeavenHM
HeavenHM

Reputation: 992

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

Upvotes: 2

Related Questions