コード例 #1
0
ErrorCode ComponentManager::LoadLibrary( const char *name )
{
	TRACE_BEGIN( LOG_LVL_INFO );
	IModule *mod = NULL;
	ErrorCode result = kNoError;
	
	LOG_NOTICE( "Opening Library: %s", name );
	
	ErrorCode (*LoadLibrary)( IComponentManager *mgr );
	IModule *(*GetModule)();
	void *handle = dlopen( name, RTLD_LAZY );
	
	if ( handle == NULL )
	{
		result = kLoadFailed;
		LOG_WARN( "Failed to open shared lib \"%s\": %s", name, dlerror() );
	}
	else
	{
		LoadLibrary = (ErrorCode (*)(IComponentManager *mgr))dlsym( handle, "JHCOM_LibraryEntry" );
		GetModule = (IModule *(*)())dlsym( handle, "JHCOM_GetModule" );

		if ( GetModule == NULL || LoadLibrary == NULL )
		{
			result = kLoadFailed;
			LOG_WARN( "Failed to get symbol" );
		}
		else
		{
			LOG( "LoadLibrary is %p", LoadLibrary );
			LOG( "RegisterServices is %p", GetModule );
			result = LoadLibrary( this );
			
			if ( result == kNoError )
			{
				mod = GetModule();
				mod->AddRef();
				mod->loadComponents();
				ModuleInfo *info = jh_new ModuleInfo( name, mod, handle );
				mModules.push_back( info );
			}
		}
	}
	
	return result;
}
コード例 #2
0
ファイル: utest1.cpp プロジェクト: aBothe/MagoWrapper
    virtual void OnModuleLoad( IProcess* process, IModule* module )
    {
        char*   macName = "";

        switch ( module->GetMachine() )
        {
        case IMAGE_FILE_MACHINE_I386: macName = "x86"; break;
        case IMAGE_FILE_MACHINE_IA64: macName = "ia64"; break;
        case IMAGE_FILE_MACHINE_AMD64: macName = "x64"; break;
        }

        if ( sizeof( Address ) == sizeof( uintptr_t ) )
            printf( "  %p %d %s '%ls'\n", module->GetImageBase(), module->GetSize(), macName, module->GetPath() );
        else
            printf( "  %08I64x %d %s '%ls'\n", module->GetImageBase(), module->GetSize(), macName, module->GetPath() );

        if ( mMod == NULL )
        {
            mMod = module;
            mMod->AddRef();
        }
    }