Example #1
0
HRESULT Init(HWND hWnd)
{
	mod_file_system.Init("Core.FileSystem.dll");
	mod_dx9.Init("Engine.Graphics.DX9.dll");

	mod_file_system.CreateInstance(CLSID_CFileSystem, UUID_PPV(IFileSystem, &pFS));
	gEnv = &sgEnv;
	gEnv->Core = 0;
	gEnv->Logger = 0;
	gEnv->PluginManager = 0;
	gEnv->FileSystem = pFS;

	IPlugin *plug;
	mod_dx9.CreateInstance(UUID_PPV(IPlugin, &plug));
	plug->Initialize(gEnv, 0);
	plug->Release();

	mod_dx9.CreateInstance(UUID_PPV(IRenderer, &pRenderer));

	SRendererParams params;
	params.FullScreen = fullScreen;
	params.MainWindow = (WND_HANDLE)hWnd;
	params.ScreenHeight = iHeight;
	params.ScreenWidth = iWidth;
	params.BackBufferFormat = FMT_X8R8G8B8;
	pRenderer->Init(params);

	return InitGeometry();
}
Example #2
0
void ModuleRegistry::Register(ModuleInfo* info)
{
  static long regCount = 0;
  if (info->id > 0)
  {
    // The module was already registered
    Module* module = 0;
    {
      MutexLocker lock(*modulesLock());
      module = modules()->operator[](info->id);
      assert(module != 0);
    }
    module->Start();
  }
  else
  {
    Module* module = 0;
    // check if the module is reloaded
    {
      MutexLocker lock(*modulesLock());
      ModuleMap* map = modules();
      for (ModuleMap::const_iterator i = map->begin();
           i != map->end(); ++i)
      {
        if (i->second->GetLocation() == info->location)
        {
          module = i->second;
          info->id = module->GetModuleId();
        }
      }
    }

    if (!module)
    {
      module = new Module();
      countLock()->Lock();
      info->id = ++regCount;
      countLock()->Unlock();

      module->Init(coreModuleContext(), info);

      MutexLocker lock(*modulesLock());
      ModuleMap* map = modules();
      map->insert(std::make_pair(info->id, module));
    }
    else
    {
      module->Init(coreModuleContext(), info);
    }

    module->Start();
  }
}
Example #3
0
    BOOL WINAPI RawDllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID)
    {
        if (ul_reason_for_call == DLL_PROCESS_ATTACH)
        {
            try
            {
                _Module.Init(hModule);
            }
            catch (Exception* e)
            {
                MessageBoxW(NULL, e->get_Reason().c_strw(), L"EcmaScript", MB_OK | MB_ICONERROR);
                return FALSE;
            }
        }

        return TRUE;
    }
Example #4
0
BOOL WINAPI RawDllMain(HMODULE hModule, DWORD ul_reason_for_call, void*)
{
	if (ul_reason_for_call == DLL_PROCESS_ATTACH)
	{
		try
		{
			_Module.Init(hModule);
		}
		catch (Exception* e)
		{
			MessageBox(NULL, CStringw(e->get_Reason()), L"MPEG4VideoDec", MB_OK);
			return FALSE;
		}
	}

	return TRUE;
}
Example #5
0
/**
 * loads a module, and adds it to the Module list
 * 
 * @param modulepath the path to the module
 * @param configpath the path to the config file
 * 
 * @return returns true if there was no error, else false
 */
bool ModuleManager::registerModule(string *modulepath, string *configpath)
{
	bool retval=true;

    void *handle;

    typedef int32_t (*module_init_proc)(int32_t, Module**, Nepenthes *);
    module_init_proc module_init;

	handle = dlopen (modulepath->c_str(), RTLD_NOW|RTLD_LOCAL);

    if ( handle == NULL )
    {
        logCrit("Failed to load library \"%s\": %s\n", modulepath->c_str(), dlerror());
        return false;
    }

    module_init = (module_init_proc)dlsym(handle, "module_init");
    if ( module_init == NULL )
    {
        logCrit("Cannot obtain symbol \"module_init\" from \"%s\": %s\n", modulepath->c_str(), dlerror());
        dlclose (handle);
        return false;
    }


    Module *newmodule;
    if ( module_init (MODULE_IFACE_VERSION, &newmodule, m_Nepenthes) != 1 )
    {

        logCrit("Module \"%s\" library failed to initialize\n", modulepath->c_str());
        dlclose (handle);
        return false;
    }
    newmodule->setDlHandle(handle);

// fixme load config
	if(configpath->size() > 0)
	{

		Config *config = new Config;

		try
		{
			config->load(configpath->c_str());
		} catch( LoadError e )
		{
			printf("Unable to load configuration file %s: %s\n", configpath->c_str(), e.getMessage());
			retval = false;
		} catch( ParseError e )
		{
			printf("Parse error in %s on line %d: %s\n", configpath->c_str(), e.getLine(), e.getMessage());
			retval = false;
		}

		newmodule->setConfig(config);
	}else
		newmodule->setConfig(NULL);


	if ( newmodule->Init() == false )
	{
		logCrit("Module instance of \"%s\" using configuration \"%s\" failed to initialize\n", modulepath->c_str(), configpath->c_str());
		delete newmodule;
		dlclose (handle);
		return false;
	}

    m_Modules.push_back(newmodule);
//	logInfo("Added Module %s %s \n",pszModulePath, pNewModule->m_sModuleDir.c_str());
    return retval;
}
Example #6
0
BOOL Module::InitModules()
{
	// Initialise the list of Modules.
	Modules = new ModuleList;
	if (!Modules)
		return FALSE;
		
	if (!OILModule::Init())						// get OIL's list of modules. This works
		return FALSE;							// by calling back to DescribeModule.
												// NB. OILModule::Init does it own error
	BOOL Finished;								// reporting
	
	do
	{
		// All the modules have been 'new'ed now. We can now ask them to initialise themselves.
		// If they don't want to, they get 'delete'ed.

		ModuleListItem *Item = (ModuleListItem *) Modules->GetHead();
		
		Finished = TRUE;
		
		while (Item != NULL)
		{
			Module *Module = Item->m_pModule;
			
			// If this module exists and has not been initialised yet, then try to
			// initialise it.  If it initialises ok, set the item's flag, and force
			// another scan of the remaining modules in case one of them depends on
			// this module being present.
			if ((Module != NULL) && (!Item->m_Initialised) && (Module->Init()))
			{
				Item->m_Initialised = TRUE;	// Tool initialised ok.
				Finished = FALSE;			// At least one more loop to try
			}

			// Try the next module
			Item = (ModuleListItem *) Modules->GetNext(Item);
		}
		
	} while (!Finished);

	// Delete any un-initialised modules
	ModuleListItem *Item = (ModuleListItem *) Modules->GetHead();

	while (Item != NULL)
	{
		if ((Item->m_pModule != NULL) && (!Item->m_Initialised))
		{
			delete Item->m_pModule;
			Item->m_pModule = NULL;
		}

		// Try the next module
		Item = (ModuleListItem *) Modules->GetNext(Item);
	}

	// Scan all the modules and create (but do not initialise) any tools they provide.
	if (!Tool::InitToolList() || !CreateTools())
		return FALSE;

	return TRUE;
}