You're right, i initially had it above the if statement, though then i thought about only declaring it when it's actually necessary ( if Module32First returns true ); i didn't think about it being out of scope for the return statement.
Code:
DWORD CMemory::Module( char* szModuleName )
{
HANDLE hModule = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwPID);
MODULEENTRY32 mEntry;
mEntry.dwSize = sizeof( MODULEENTRY32 );
bool bModuleFound = false;
if ( Module32First( hModule, &mEntry ) )
{
do
{
if (!strcmp( mEntry.szModule, szModuleName ) && bModuleFound = true )
break;
} while ( Module32Next( hModule, &mEntry ) );
}
CloseHandle( hModule );
return bModuleFound ? reinterpret_cast< DWORD >( mEntry.modBaseAddr ) : 0;
}

