コード例 #1
0
ファイル: main.cpp プロジェクト: Chuvi-w/ReGameDLL_CS
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
	if (fdwReason == DLL_PROCESS_ATTACH)
	{
#ifdef HOOK_GAMEDLL
		g_ReGameDLLRuntimeConfig.parseFromCommandLine(GetCommandLineA());

		g_pOriginalGameDLLModule = Sys_LoadModule(shrPathGameDLL());
		g_pOriginalFileSystemModule = Sys_LoadModule(ORIGINAL_FILESYSTEM_DLL_NAME);

		size_t gameAddr = (size_t)Sys_GetProcAddress((void *)g_pOriginalGameDLLModule, GIVEFNPTRS_TO_DLL_PROCNAME);
		size_t engAddr = (size_t)Sys_GetProcAddress(ORIGINAL_ENGINE_DLL_NAME, CREATEINTERFACE_PROCNAME);

		HookGameDLL(gameAddr, engAddr);
#endif
	}
	else if (fdwReason == DLL_PROCESS_DETACH)
	{
		if (g_pOriginalFileSystemModule)
		{
			Sys_UnloadModule(g_pOriginalFileSystemModule);
			g_pOriginalFileSystemModule = NULL;
			g_OriginalFileSystemFactory = NULL;
			g_pOriginalFileSystem = NULL;
		}
		if (g_pOriginalGameDLLModule)
		{
			Sys_UnloadModule(g_pOriginalGameDLLModule);
			g_pOriginalGameDLLModule = NULL;
		}
	}

	return TRUE;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: Chuvi-w/ReGameDLL_CS
void __attribute__((constructor)) DllMainLoad()
{
	g_pOriginalGameDLLModule = Sys_LoadModule(shrPathGameDLL());
	g_pOriginalFileSystemModule = Sys_LoadModule(ORIGINAL_FILESYSTEM_DLL_NAME);

	size_t gameAddr = (size_t)Sys_GetProcAddress((void *)g_pOriginalGameDLLModule, GIVEFNPTRS_TO_DLL_PROCNAME);
	size_t engAddr = (size_t)Sys_GetProcAddress(ORIGINAL_ENGINE_DLL_NAME, CREATEINTERFACE_PROCNAME);

	HookGameDLL(gameAddr, engAddr);
}
コード例 #3
0
int main(int argc, char* argv[])
{
	CommandLine()->CreateCmdLine( argc, argv );
	const char *pDLLName = "vvis_dll.dll";
	
	CSysModule *pModule = Sys_LoadModule( pDLLName );
	if ( !pModule )
	{
		printf( "vvis launcher error: can't load %s\n%s", pDLLName, GetLastErrorString() );
		return 1;
	}

	CreateInterfaceFn fn = Sys_GetFactory( pModule );
	if( !fn )
	{
		printf( "vvis launcher error: can't get factory from %s\n", pDLLName );
		Sys_UnloadModule( pModule );
		return 2;
	}

	int retCode = 0;
	ILaunchableDLL *pDLL = (ILaunchableDLL*)fn( LAUNCHABLE_DLL_INTERFACE_VERSION, &retCode );
	if( !pDLL )
	{
		printf( "vvis launcher error: can't get IVVisDLL interface from %s\n", pDLLName );
		Sys_UnloadModule( pModule );
		return 3;
	}

	pDLL->main( argc, argv );
	Sys_UnloadModule( pModule );

	return 0;
}
コード例 #4
0
bool RehldsApi_Init() {
	char failReason[2048];

#ifdef WIN32
	CSysModule* engineModule = Sys_LoadModule("swds.dll");
#else
	CSysModule* engineModule = Sys_LoadModule("engine_i486.so");
#endif

	if (!RehldsApi_TryInit(engineModule, failReason)) {
		Con_DPrintf("[RePatcher]: ReHLDS API init error: '%s'", failReason);
		return false;
	}

	return true;
}
コード例 #5
0
int main( int argc, char **argv )
{
	const char *pModuleName = "vtex_dll.dll";
	
	CSysModule *pModule = Sys_LoadModule( pModuleName );
	if ( !pModule )
	{
		printf( "Can't load %s.", pModuleName );
		return false;
	}

	CreateInterfaceFn fn = Sys_GetFactory( pModule );
	if ( !fn )
	{
		printf( "Can't get factory from %s.", pModuleName );
		Sys_UnloadModule( pModule );
		return false;
	}

	ILaunchableDLL *pInterface = (ILaunchableDLL*)fn( LAUNCHABLE_DLL_INTERFACE_VERSION, NULL );
	if ( !pInterface )
	{
		printf( "Can't get '%s' interface from %s.", LAUNCHABLE_DLL_INTERFACE_VERSION, pModuleName );
		Sys_UnloadModule( pModule );
		return false;
	}

	int iRet = pInterface->main( argc, argv );
	Sys_UnloadModule( pModule );
	return iRet;
}
コード例 #6
0
ファイル: cdll_int.cpp プロジェクト: Arkshine/NS
int CL_DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
{
	gEngfuncs = *pEnginefuncs;

	RecClInitialize(pEnginefuncs, iVersion);

	if (iVersion != CLDLL_INTERFACE_VERSION)
		return 0;

	memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t));

	EV_HookEvents();
	// get tracker interface, if any
	char szDir[512];
	if (!gEngfuncs.COM_ExpandFilename("Bin/TrackerUI.dll", szDir, sizeof(szDir)))
	{
		g_pTrackerUser = NULL;
		g_hTrackerModule = NULL;
		return 1;
	}

	g_hTrackerModule = Sys_LoadModule(szDir);
	CreateInterfaceFn trackerFactory = Sys_GetFactory(g_hTrackerModule);
	if (!trackerFactory)
	{
		g_pTrackerUser = NULL;
		g_hTrackerModule = NULL;
		return 1;
	}

	g_pTrackerUser = (ITrackerUser *)trackerFactory(TRACKERUSER_INTERFACE_VERSION, NULL);
	return 1;
}
コード例 #7
0
void InitStudioRender( void )
{
	if ( g_pStudioRenderModule )
		return;
	Assert( g_MatSysFactory );

	g_pStudioRenderModule = Sys_LoadModule( "StudioRender.dll" );
	if( !g_pStudioRenderModule )
	{
		Error( "Can't load StudioRender.dll\n" );
	}
	CreateInterfaceFn studioRenderFactory = Sys_GetFactory( g_pStudioRenderModule );
	if (!studioRenderFactory )
	{
		Error( "Can't get factory for StudioRender.dll\n" );
	}
	g_pStudioRender = ( IStudioRender * )studioRenderFactory( STUDIO_RENDER_INTERFACE_VERSION, NULL );
	if (!g_pStudioRender)
	{
		Error( "Unable to init studio render system version %s\n", STUDIO_RENDER_INTERFACE_VERSION );
	}

	g_pStudioRender->Init( g_MatSysFactory, g_ShaderAPIFactory );
	UpdateStudioRenderConfig();
}
コード例 #8
0
void RunInDLL( const char *pFilename, CUtlVector<char*> &newArgv )
{
	if ( g_pConnMgr )						   
		g_pConnMgr->SetAppState( VMPI_SERVICE_STATE_BUSY );

	bool bSuccess = false;
	CSysModule *pModule = Sys_LoadModule( pFilename );
	if ( pModule )
	{
		CreateInterfaceFn fn = Sys_GetFactory( pModule );
		if ( fn )
		{
			ILaunchableDLL *pDLL = (ILaunchableDLL*)fn( LAUNCHABLE_DLL_INTERFACE_VERSION, NULL );
			if( pDLL )
			{
				// Do this here because the executables we would have launched usually would do it.
				CommandLine()->CreateCmdLine( newArgv.Count(), newArgv.Base() );
				pDLL->main( newArgv.Count(), newArgv.Base() );
				bSuccess = true;
				SpewOutputFunc( MySpewOutputFunc );
			}
		}

		Sys_UnloadModule( pModule );
	}
	
	if ( !bSuccess )
	{
		Msg( "Error running VRAD (or VVIS) out of DLL '%s'\n", pFilename );
	}

	if ( g_pConnMgr )
		g_pConnMgr->SetAppState( VMPI_SERVICE_STATE_IDLE );
}
コード例 #9
0
//-----------------------------------------------------------------------------
// Purpose: Application entry point
//			Loads and runs the TrackerSRV
//-----------------------------------------------------------------------------
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
	// winsock aware
	WSAData wsaData;
	int nReturnCode = ::WSAStartup(MAKEWORD(2,0), &wsaData);

	// load the Tracker Server DLL
	CSysModule *serverDll = Sys_LoadModule("TrackerSRV.dll");
	CreateInterfaceFn serverFactory = Sys_GetFactory(serverDll);
	if (!serverFactory)
	{
		::MessageBox(NULL, "Could not load 'TrackerSRV.dll'", "Fatal Error - TrackerServer", MB_OK | MB_ICONERROR);
		return 1;
	}

	ITrackerSRV *trackerInterface = (ITrackerSRV *)serverFactory(TRACKERSERVER_INTERFACE_VERSION, NULL);

	// Activate server
	trackerInterface->RunTrackerServer(lpCmdLine);

	Sys_UnloadModule(serverDll);

	::WSACleanup();

	return 0;
}
コード例 #10
0
ファイル: cdll_int.cpp プロジェクト: Chuvi-w/CSSDK
void CL_LoadParticleMan( void )
{
	char szPDir[512];

	if ( gEngfuncs.COM_ExpandFilename( PARTICLEMAN_DLLNAME, szPDir, sizeof( szPDir ) ) == FALSE )
	{
		g_pParticleMan = NULL;
		g_hParticleManModule = NULL;
		return;
	}

	g_hParticleManModule = Sys_LoadModule( szPDir );
	CreateInterfaceFn particleManFactory = Sys_GetFactory( g_hParticleManModule );

	if ( particleManFactory == NULL )
	{
		g_pParticleMan = NULL;
		g_hParticleManModule = NULL;
		return;
	}

	g_pParticleMan = (IParticleMan *)particleManFactory( PARTICLEMAN_INTERFACE, NULL);

	if ( g_pParticleMan )
	{
		 g_pParticleMan->SetUp( &gEngfuncs );

		 // Add custom particle classes here BEFORE calling anything else or you will die.
		 g_pParticleMan->AddCustomParticleClassSize ( sizeof ( CBaseParticle ) );
	}
}
コード例 #11
0
//-----------------------------------------------------------------------------
// Purpose: get the interface for the specified module and version
// Input  : 
// Output : 
//-----------------------------------------------------------------------------
bool Sys_LoadInterface(
	const char *pModuleName,
	const char *pInterfaceVersionName,
	CSysModule **pOutModule,
	void **pOutInterface )
{
	CSysModule *pMod = Sys_LoadModule( pModuleName );
	if ( !pMod )
		return false;

	CreateInterfaceFn fn = Sys_GetFactory( pMod );
	if ( !fn )
	{
		Sys_UnloadModule( pMod );
		return false;
	}

	*pOutInterface = fn( pInterfaceVersionName, NULL );
	if ( !( *pOutInterface ) )
	{
		Sys_UnloadModule( pMod );
		return false;
	}

	if ( pOutModule )
		*pOutModule = pMod;

	return true;
}
コード例 #12
0
ファイル: cdll_int.cpp プロジェクト: ChunHungLiu/halflife
int EXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
{
    gEngfuncs = *pEnginefuncs;

    //!!! mwh UNDONE We need to think about our versioning strategy. Do we want to try to be compatible
    // with previous versions, especially when we're only 'bonus' functionality? Should it be the engine
    // that decides if the DLL is compliant?

    if (iVersion != CLDLL_INTERFACE_VERSION)
        return 0;

    memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t));

    EV_HookEvents();

    // Determine which filesystem to use.
#if defined ( _WIN32 )
    char *szFsModule = "filesystem_stdio.dll";
#elif defined(OSX)
    char *szFsModule = "filesystem_stdio.dylib";
#elif defined(LINUX)
    char *szFsModule = "filesystem_stdio.so";
#else
#error
#endif


    char szFSDir[MAX_PATH];
    szFSDir[0] = 0;
    if ( gEngfuncs.COM_ExpandFilename( szFsModule, szFSDir, sizeof( szFSDir ) ) == FALSE )
    {
        return false;
    }

    // Get filesystem interface.
    g_pFileSystemModule = Sys_LoadModule( szFSDir );
    assert( g_pFileSystemModule );
    if( !g_pFileSystemModule )
    {
        return false;
    }

    CreateInterfaceFn fileSystemFactory = Sys_GetFactory( g_pFileSystemModule );
    if( !fileSystemFactory )
    {
        return false;
    }

    g_pFileSystem = ( IFileSystem * )fileSystemFactory( FILESYSTEM_INTERFACE_VERSION, NULL );
    assert( g_pFileSystem );
    if( !g_pFileSystem )
    {
        return false;
    }

    return 1;
}
コード例 #13
0
//-----------------------------------------------------------------------------
// Purpose: Adds tool from specified library
// Input  : *dllname - 
//-----------------------------------------------------------------------------
void CToolFrameworkInternal::LoadToolsFromLibrary( const char *dllname )
{
	CSysModule *module = Sys_LoadModule( dllname );
	if ( !module )
	{
		Warning( "CToolFrameworkInternal::LoadToolsFromLibrary:  Unable to load '%s'\n", dllname );
		return;
	}

	CreateInterfaceFn factory = Sys_GetFactory( module );
	if ( !factory )
	{
		Sys_UnloadModule( module );
		Warning( "CToolFrameworkInternal::LoadToolsFromLibrary:  Dll '%s' has no factory\n", dllname );
		return;
	}

	IToolDictionary *dictionary = ( IToolDictionary * )factory( VTOOLDICTIONARY_INTERFACE_VERSION, NULL );
	if ( !dictionary )
	{
		Sys_UnloadModule( module );
		Warning( "CToolFrameworkInternal::LoadToolsFromLibrary:  Dll '%s' doesn't support '%s'\n", dllname, VTOOLDICTIONARY_INTERFACE_VERSION );
		return;
	}

	if ( !dictionary->Connect( g_AppSystemFactory ) )
	{
		Sys_UnloadModule( module );
		Warning( "CToolFrameworkInternal::LoadToolsFromLibrary:  Dll '%s' connection phase failed.\n", dllname );
		return;
	}

	if ( dictionary->Init( ) != INIT_OK )
	{
		Sys_UnloadModule( module );
		Warning( "CToolFrameworkInternal::LoadToolsFromLibrary:  Dll '%s' initialization phase failed.\n", dllname );
		return;
	}

	dictionary->CreateTools();

	int toolCount = dictionary->GetToolCount();
	for ( int i = 0; i < toolCount; ++i )
	{
		IToolSystem *tool = dictionary->GetTool( i );
		if ( tool )
		{
			Msg( "Loaded tool '%s'\n", tool->GetToolName() );
			m_ToolSystems.AddToTail( tool );
		}
	}

	m_Dictionaries.AddToTail( dictionary );
	m_Modules.AddToTail( module );
}
コード例 #14
0
HINTERFACEMODULE LoadFilesystemModule(void)
{
	HINTERFACEMODULE hModule = Sys_LoadModule("filesystem_stdio.dll");

	if (!hModule)
	{
		MessageBox(NULL, "Could not load filesystem dll.\nFileSystem crashed during construction.", "Fatal Error", MB_ICONERROR);
		return NULL;
	}

	return hModule;
}
コード例 #15
0
bool Revoice_RehldsApi_Init() {
	char failReason[2048];

#ifdef WIN32
	CSysModule* engineModule = Sys_LoadModule("swds.dll");
	if (!Revoice_RehldsApi_TryInit(engineModule, failReason)) {
		engineModule = Sys_LoadModule("filesystem_stdio.dll");
		if (!Revoice_RehldsApi_TryInit(engineModule, failReason)) {
			LCPrintf(true, "%s", failReason);
			return false;
		}
	}
#else
	CSysModule* engineModule = Sys_LoadModule("engine_i486.so");
	if (!Revoice_RehldsApi_TryInit(engineModule, failReason)) {
		LCPrintf(true, "%s", failReason);
		return false;
	}
#endif

	return true;
}
コード例 #16
0
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
bool CUnitTestApp::Create()
{
	// Install a special Spew handler that ignores all assertions and lets us
	// run for as long as possible
	SpewOutputFunc( UnitTestSpew );

	// FIXME: This list of dlls should come from the unittests themselves
	AppSystemInfo_t appSystems[] = 
	{
		{ "vstdlib.dll",			PROCESS_UTILS_INTERFACE_VERSION },
		{ "", "" }	// Required to terminate the list
	};

	if ( !AddSystems( appSystems ) ) 
		return false;

	// Very simple... just iterate over all .DLLs in the current directory 
	// see if they export UNITTEST_INTERFACE_VERSION. If not, then unload them
	// just as quick.

	// We may want to make this more sophisticated, giving it a search path,
	// or giving test DLLs special extensions, or statically linking the test DLLs
	// to this program.

	WIN32_FIND_DATA findFileData;
	HANDLE hFind= FindFirstFile("*.dll", &findFileData);

	while (hFind != INVALID_HANDLE_VALUE)
	{
		CSysModule* hLib = Sys_LoadModule(findFileData.cFileName);
		if ( hLib )
		{
			CreateInterfaceFn factory = Sys_GetFactory( hLib );
			if ( factory && factory( UNITTEST_INTERFACE_VERSION, NULL ) )
			{
				AppModule_t module = LoadModule( factory );
				AddSystem( module, UNITTEST_INTERFACE_VERSION );
			}
			else
			{
				Sys_UnloadModule( hLib );
			}
		}

		if (!FindNextFile( hFind, &findFileData ))
			break;
	}

	return true;
}
コード例 #17
0
CreateInterfaceFn CDllDemandLoader::GetFactory()
{
	if ( !m_hModule && !m_bLoadAttempted )
	{
		m_bLoadAttempted = true;
		m_hModule = Sys_LoadModule( m_pchModuleName );
	}

	if ( !m_hModule )
	{
		return NULL;
	}

	return Sys_GetFactory( m_hModule );
}
コード例 #18
0
// ------------------------------------------------------------------------ //
// Global functions.
// ------------------------------------------------------------------------ //
IFileSystem* ScratchPad3D_SetupFileSystem()
{
	// Get a filesystem interface.
	CSysModule *pModule = Sys_LoadModule( "filesystem_stdio" );
	if( !pModule )
		return NULL;

	CreateInterfaceFn fn = Sys_GetFactory( pModule );
	IFileSystem *pFileSystem;
	if( !fn || (pFileSystem = (IFileSystem *)fn( FILESYSTEM_INTERFACE_VERSION, NULL )) == NULL )
	{
		Sys_UnloadModule( pModule );
		return NULL;
	}

	return pFileSystem;
}
コード例 #19
0
ファイル: modgame.cpp プロジェクト: tschumann/basis
void LoadFileSystem( void )
{
	hFileSystemModule = Sys_LoadModule( FILESYSTEM_DLLNAME );
	CreateInterfaceFn fileSystemFactory = Sys_GetFactory( hFileSystemModule );

	if( fileSystemFactory == NULL )
	{
		g_pFileSystem = NULL;
	}

	g_pFileSystem = (IFileSystem *)fileSystemFactory( FILESYSTEM_INTERFACE_VERSION, NULL );

	if( g_pFileSystem )
	{
		ALERT( at_aiconsole, "%s interface instantiated.\n", FILESYSTEM_INTERFACE_VERSION );
	}
}
コード例 #20
0
ファイル: SystemWrapper.cpp プロジェクト: Chuvi-w/rehlds
SystemWrapper::library_t *SystemWrapper::GetLibrary(char *name)
{
	char fixedname[MAX_PATH];
	Q_strlcpy(fixedname, name);
	COM_FixSlashes(fixedname);

	library_t *lib = (library_t *)m_Libraries.GetFirst();
	while (lib)
	{
		if (Q_stricmp(lib->name, name) == 0) {
			return lib;
		}

		lib = (library_t *)m_Libraries.GetNext();
	}

	lib = (library_t *)Mem_Malloc(sizeof(library_t));
	if (!lib) {
		DPrintf("ERROR! System::GetLibrary: out of memory (%s).\n", name);
		return nullptr;
	}

	Q_snprintf(lib->name, sizeof(lib->name), "%s." LIBRARY_PREFIX, fixedname);
	FS_GetLocalCopy(lib->name);

	lib->handle = (CSysModule *)Sys_LoadModule(lib->name);
	if (!lib->handle) {
		DPrintf("ERROR! System::GetLibrary: coulnd't load library (%s).\n", lib->name);
		Mem_Free(lib);
		return nullptr;
	}

	lib->createInterfaceFn = (CreateInterfaceFn)Sys_GetFactory(lib->handle);
	if (!lib->createInterfaceFn) {
		DPrintf("ERROR! System::GetLibrary: coulnd't get object factory(%s).\n", lib->name);
		Mem_Free(lib);
		return nullptr;
	}

	m_Libraries.Add(lib);
	DPrintf("Loaded library %s.\n", lib->name);

	return lib;
}
コード例 #21
0
bool ConnectDeferredExt()
{
	char modulePath[MAX_PATH*4];
	Q_snprintf( modulePath, sizeof( modulePath ), "%s/bin/game_shader_generic_deferred.dll\0", engine->GetGameDirectory() );
	__g_pDeferredShaderModule = Sys_LoadModule( modulePath );

	if ( __g_pDeferredShaderModule )
	{
		CreateInterfaceFn shaderDeferredDLLFactory = Sys_GetFactory( __g_pDeferredShaderModule );
		__g_defExt = shaderDeferredDLLFactory ? ((IDeferredExtension *) shaderDeferredDLLFactory( DEFERRED_EXTENSION_VERSION, NULL )) : NULL;

		if ( !__g_defExt )
			Warning( "Unable to pull IDeferredExtension interface.\n" );
	}
	else
		Warning( "Cannot load game_shader_generic_deferred.dll from %s!\n", modulePath );

	return __g_defExt != NULL;
}
コード例 #22
0
bool ConnectShaderPostprocessInterface()
{
	char modulePath[MAX_PATH*4];
	Q_snprintf( modulePath, sizeof( modulePath ), "%s/bin/game_shader_dx9.dll", engine->GetGameDirectory() );
	__g_pShaderAPIShaderModule = Sys_LoadModule( modulePath );

	if ( __g_pShaderAPIShaderModule )
	{
		CreateInterfaceFn shaderShaderAPIDLLFactory = Sys_GetFactory( __g_pShaderAPIShaderModule );
		__g_shaderExt = shaderShaderAPIDLLFactory ? ((IShaderEnginePostprocessInterface *)shaderShaderAPIDLLFactory(POSTPROCESS_INTERFACE_VERSION, NULL)) : NULL;

		if ( !__g_shaderExt )
			Warning( "Unable to pull IShaderEnginePostprocessInterface interface.\n" );
	}
	else
		Warning( "Cannot load game_shader_dx9.dll from %s!\n", modulePath );

	return __g_shaderExt != NULL;
}
コード例 #23
0
void ConnectHaptics(CreateInterfaceFn appFactory)
{
	bool success = false;
	// NVNT load haptics module
	pFalconModule = Sys_LoadModule( HAPTICS_TEST_PREFIX HAPTICS_DLL_NAME );
	if(pFalconModule)
	{
		CreateInterfaceFn factory = Sys_GetFactory( pFalconModule );
		if(factory)
		{
			haptics = reinterpret_cast< IHaptics* >( factory( HAPTICS_INTERFACE_VERSION, NULL ) );
			if(haptics && 
				haptics->Initialize(engine,
					view,
					g_InputInternal,
					gpGlobals,
					appFactory,
					g_pVGuiInput->GetIMEWindow(),
					filesystem,
					enginevgui,
					ActivityList_IndexForName,
					ActivityList_NameForIndex))
			{
				success = true;
				hap_HasDevice.SetValue(1);
			}
		}
	}
	if(!success)
	{
		Sys_UnloadModule(pFalconModule);
		pFalconModule = 0;
		haptics = new CHapticsStubbed;
	}

	if(haptics->HasDevice())
	{
		Assert( (void*)haptics == inputsystem->GetHapticsInterfaceAddress() );
	}
	HookHapticMessages();
}
コード例 #24
0
ファイル: mdlviewer.cpp プロジェクト: newroob/bg2-2007
void LoadFileSystemDialogModule()
{
	Assert( !g_pFSDialogModule );

	// Load the module with the file system open dialog.
	const char *pDLLName = "FileSystemOpenDialog.dll";
	g_pFSDialogModule = Sys_LoadModule( pDLLName );
	if ( g_pFSDialogModule )
	{
		g_FSDialogFactory = Sys_GetFactory( g_pFSDialogModule );
	}

	if ( !g_pFSDialogModule || !g_FSDialogFactory )
	{
		if ( g_pFSDialogModule )
		{
			Sys_UnloadModule( g_pFSDialogModule );
			g_pFSDialogModule = NULL;
		}
	}
}
コード例 #25
0
ファイル: filesystem.cpp プロジェクト: WPMGPRoSToTeMa/rehlds
bool FileSystem_LoadDLL(CreateInterfaceFn filesystemFactory)
{
	if (!filesystemFactory)
	{
		g_pFileSystemModule = Sys_LoadModule(STDIO_FILESYSTEM_LIB);

		if (g_pFileSystemModule)
		{
			filesystemFactory = Sys_GetFactory(g_pFileSystemModule);
		}
	}

	if (filesystemFactory)
	{
		g_FileSystemFactory = filesystemFactory;

		g_pFileSystem = (IFileSystem *)filesystemFactory(FILESYSTEM_INTERFACE_VERSION, 0);
		return g_pFileSystem != NULL;
	}

	return false;
}
コード例 #26
0
ファイル: vrad_launcher.cpp プロジェクト: Bubbasacs/FinalProj
int main(int argc, char* argv[])
{
	char dllName[512];
	bool bUseDefault = true;

	CommandLine()->CreateCmdLine( argc, argv );

	// check whether they used the -both switch. If this is specified, vrad will be run
	// twice, once with -hdr and once without
	int both_arg=0;
	for(int arg=1;arg<argc;arg++)
		if (Q_stricmp(argv[arg],"-both")==0)
		{
			both_arg=arg;
		}

	char fullPath[512], redirectFilename[512];
	MakeFullPath( argv[0], fullPath, sizeof( fullPath ) );
	Q_StripFilename( fullPath );
	Q_snprintf( redirectFilename, sizeof( redirectFilename ), "%s\\%s", fullPath, "vrad.redirect" );

	// First, look for vrad.redirect and load the dll specified in there if possible.
	CSysModule *pModule = NULL;
	FILE *fp = fopen( redirectFilename, "rt" );
	if ( fp )
	{
		if ( fgets( dllName, sizeof( dllName ), fp ) )
		{
			char *pEnd = strstr( dllName, "\n" );
			if ( pEnd )
				*pEnd = 0;

			pModule = Sys_LoadModule( dllName );
			if ( pModule )
				printf( "Loaded alternate VRAD DLL (%s) specified in vrad.redirect.\n", dllName );
			else
				printf( "Can't find '%s' specified in vrad.redirect.\n", dllName );
		}
		
		fclose( fp );
	}

	int returnValue;
	
	for(int mode=0;mode<2;mode++)
	{
		if (mode && (! both_arg))
			continue;
		

		// If it didn't load the module above, then use the 
		if ( !pModule )
		{
			strcpy( dllName, "vrad.dll" );
			pModule = Sys_LoadModule( dllName );
		}
		
		if( !pModule )
		{
			printf( "vrad_launcher error: can't load %s\n%s", dllName, GetLastErrorString() );
			return 1;
		}
		
		CreateInterfaceFn fn = Sys_GetFactory( pModule );
		if( !fn )
		{
			printf( "vrad_launcher error: can't get factory from vrad.dll\n" );
			Sys_UnloadModule( pModule );
			return 2;
		}
		
		int retCode = 0;
		IVRadDLL *pDLL = (IVRadDLL*)fn( VRAD_INTERFACE_VERSION, &retCode );
		if( !pDLL )
		{
			printf( "vrad_launcher error: can't get IVRadDLL interface from vrad.dll\n" );
			Sys_UnloadModule( pModule );
			return 3;
		}
		
		if (both_arg)
			strcpy(argv[both_arg],(mode)?"-hdr":"-ldr");
		returnValue = pDLL->main( argc, argv );
		Sys_UnloadModule( pModule );
		pModule=0;
	}
	return returnValue;
}
コード例 #27
0
int main(int argc, char* argv[])
{
	char dllName[512];

	Pause();	
	CommandLine()->CreateCmdLine( argc, argv );

	char fullPath[512], redirectFilename[512];
	MakeFullPath( argv[0], fullPath, sizeof( fullPath ) );
	Q_StripFilename( fullPath );
	Q_snprintf( redirectFilename, sizeof( redirectFilename ), "%s\\%s", fullPath, "vrad.redirect" );

	Pause();	
	// First, look for vrad.redirect and load the dll specified in there if possible.
	CSysModule *pModule = NULL;
	FILE *fp = fopen( redirectFilename, "rt" );
	if ( fp )
	{
		if ( fgets( dllName, sizeof( dllName ), fp ) )
		{
			char *pEnd = strstr( dllName, "\n" );
			if ( pEnd )
				*pEnd = 0;

			pModule = Sys_LoadModule( dllName );
			if ( pModule )
				printf( "Loaded alternate VRAD DLL (%s) specified in vrad.redirect.\n", dllName );
			else
				printf( "Can't find '%s' specified in vrad.redirect.\n", dllName );
		}
		
		fclose( fp );
	}
	Pause();	

	// If it didn't load the module above, then use the 
	if ( !pModule )
	{
		strcpy( dllName, "shadercompile_dll.dll" );
		pModule = Sys_LoadModule( dllName );
	}

	Pause();	
	if( !pModule )
	{
		printf( "vrad_launcher error: can't load %s\n%s", dllName, GetLastErrorString() );
		Pause();	
		return 1;
	}

	Pause();	
	CreateInterfaceFn fn = Sys_GetFactory( pModule );
	if( !fn )
	{
		printf( "vrad_launcher error: can't get factory from vrad_dll.dll\n" );
		Sys_UnloadModule( pModule );
		return 2;
	}

	int retCode = 0;
	IShaderCompileDLL *pDLL = (IShaderCompileDLL*)fn( SHADER_COMPILE_INTERFACE_VERSION, &retCode );
	if( !pDLL )
	{
		printf( "vrad_launcher error: can't get IVRadDLL interface from vrad_dll.dll\n" );
		Sys_UnloadModule( pModule );
		return 3;
	}

	int returnValue = pDLL->main( argc, argv );
	Sys_UnloadModule( pModule );
	
	return returnValue;
}
コード例 #28
0
bool ShaderEditorHandler::Init()
{
	factorylist_t factories;
	FactoryList_Retrieve( factories );

#ifdef SOURCE_2006
	ConVar *pCVarDev = cvar->FindVar( "developer" );
	bool bShowPrimDebug = pCVarDev != NULL && pCVarDev->GetInt() != 0;
#else
	ConVarRef devEnabled( "developer", true );
	bool bShowPrimDebug = devEnabled.GetInt() != 0;
#endif

	bool bCreateEditor = ( CommandLine() != NULL ) && ( CommandLine()->FindParm( "-shaderedit" ) != 0 );
	SEDIT_SKYMASK_MODE iEnableSkymask = SKYMASK_OFF;

#ifdef SHADEREDITOR_FORCE_ENABLED
	bCreateEditor = true;
	iEnableSkymask = SKYMASK_QUARTER;
#endif

	char modulePath[MAX_PATH*4];
#ifdef SWARM_DLL
	Q_snprintf( modulePath, sizeof( modulePath ), "%s/bin/shadereditor_swarm.dll\0", engine->GetGameDirectory() );
#elif SOURCE_2006
	Q_snprintf( modulePath, sizeof( modulePath ), "%s/bin/shadereditor_2006.dll\0", engine->GetGameDirectory() );
#elif SOURCE_2013
	Q_snprintf( modulePath, sizeof( modulePath ), "%s/bin/shadereditor_2013.dll\0", engine->GetGameDirectory() );
#else
	Q_snprintf( modulePath, sizeof( modulePath ), "%s/bin/shadereditor_2007.dll\0", engine->GetGameDirectory() );
#endif
	shaderEditorModule = Sys_LoadModule( modulePath );
	if ( shaderEditorModule )
	{
		CreateInterfaceFn shaderEditorDLLFactory = Sys_GetFactory( shaderEditorModule );
		shaderEdit = shaderEditorDLLFactory ? ((IVShaderEditor *) shaderEditorDLLFactory( SHADEREDIT_INTERFACE_VERSION, NULL )) : NULL;

		if ( !shaderEdit )
		{
			Warning( "Unable to pull IVShaderEditor interface.\n" );
		}
		else if ( !shaderEdit->Init( factories.appSystemFactory, gpGlobals, sEditMRender,
				bCreateEditor, bShowPrimDebug, iEnableSkymask ) )
		{
			Warning( "Cannot initialize IVShaderEditor.\n" );
			shaderEdit = NULL;
		}
	}
	else
	{
		Warning( "Cannot load shadereditor.dll from %s!\n", modulePath );
	}

	m_bReady = shaderEdit != NULL;

	RegisterCallbacks();
	RegisterViewRenderCallbacks();

	if ( IsReady() )
	{
		shaderEdit->PrecacheData();
	}

	return true;
}
コード例 #29
0
ファイル: hlds.cpp プロジェクト: RaisingTheDerp/raisingthebar
//-----------------------------------------------------------------------------
// Purpose: the main loop for the dedicated server
// Output : value to return to shell
//-----------------------------------------------------------------------------
DWORD WINAPI ServerThreadFunc( LPVOID threadobject )
{
	int		iret = DLL_NORMAL;
	IDedicatedServerAPI *engineAPI;

	char cur[1024];
	_getcwd(cur,1024);

	CSysModule *engineModule = NULL;
	CreateInterfaceFn engineFactory = NULL;
	
	while(iret!=DLL_CLOSE )
	{
	
		//_chdir(UTIL_GetBaseDir());
		vgui::filesystem()->Unmount();
		
		engineModule = Sys_LoadModule( g_pszengine );
	
	
		if ( !engineModule )
		{
			goto cleanup;
		}

		engineFactory = Sys_GetFactory( engineModule );
		if ( engineFactory )
		{
			engineAPI = ( IDedicatedServerAPI * )engineFactory( VENGINE_HLDS_API_VERSION, NULL );
		}

		if ( !engineAPI )
		{
			goto cleanup;
		}
		server.SetEngineAPI(engineAPI);
	
		engineAPI->Init( UTIL_GetBaseDir(),server.GetCmdline(), Sys_GetFactoryThis() );

		vgui::filesystem()->Mount();

		if(strlen(server.GetCvars())>0)
		{
			engineAPI->AddConsoleText(server.GetCvars());
			server.ResetCvars();
		}


		while ( 1 )
		{
			// Try to allow other apps to get some CPU
			Sys_Sleep( 1 );
			
			// Check for shutdown event
			if ( !engineAPI->RunFrame() )
				break;
			server.UpdateStatus( 0 );
 
		}

		server.SetEngineAPI(NULL);
		server.SetInstance(NULL);
		iret = engineAPI->Shutdown();

		Sys_UnloadModule( engineModule );

	} // while(iret != DLL_CLOSE && gbAppHasBeenTerminated==FALSE )

cleanup:
	// this line is IMPORTANT!
	SetEvent(server.GetShutDownHandle()); // tell the main window we have shut down now 

	//return 0;
	ExitThread(0);

}
コード例 #30
0
ファイル: Main.cpp プロジェクト: RaisingTheDerp/raisingthebar
//-----------------------------------------------------------------------------
// Purpose: Entry point
//-----------------------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	// load vgui
	CSysModule *vguiModule = Sys_LoadModule("vgui2.dll");
	CSysModule *fileSystemModule = Sys_LoadModule("filesystem_stdio.dll");
	CSysModule *netModule = Sys_LoadModule("../friends/trackerNET.dll");
	CreateInterfaceFn vguiFactory = Sys_GetFactory(vguiModule);
	CreateInterfaceFn netFactory = Sys_GetFactory(netModule);
	CreateInterfaceFn fileSystemFactory = Sys_GetFactory(fileSystemModule);
	if (!vguiFactory)
	{
		printf("Fatal error: Could not load vgui2.dll\n");
		return 2;
	}
	if (!netFactory)
	{
		printf("Fatal error: Could not load trackerNET.dll\n");
		return 3;
	}

	// initialize interfaces
	CreateInterfaceFn factories[2] = { fileSystemFactory, vguiFactory };
	assert(vgui::VGui_InitInterfacesList(factories, 2));
	g_pTrackerNET = (ITrackerNET *)netFactory(TRACKERNET_INTERFACE_VERSION, NULL);
	g_pTrackerNET->Initialize(1300, 1400);

	vgui::filesystem()->AddSearchPath("../", "");

	// Init the surface
	vgui::Panel *panel = new vgui::Panel(NULL, "TopPanel");
	vgui::surface()->Init(panel->GetVPanel());

	// load the scheme
	if (!vgui::scheme()->LoadSchemeFromFile("resource/TrackerScheme.res"))
	{
		return false;
	}

	// Start vgui
	vgui::ivgui()->Start();

	// add our main window
	vgui::Panel *main = new CMainDialog(panel);

	// server list
	g_pServerList = new CServerList(main);

	// Run app frame loop
	while (vgui::ivgui()->IsRunning())
	{
		vgui::ivgui()->RunFrame();

		// networking
		g_pServerList->RunFrame();
	}

	delete g_pServerList;

	// Shutdown
	vgui::surface()->Shutdown();
	Sys_UnloadModule(vguiModule);
	Sys_UnloadModule(netModule);
	return 1;
}