summaryrefslogtreecommitdiff
path: root/utils/vvis_launcher/vvis_launcher.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/vvis_launcher/vvis_launcher.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'utils/vvis_launcher/vvis_launcher.cpp')
-rw-r--r--utils/vvis_launcher/vvis_launcher.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/utils/vvis_launcher/vvis_launcher.cpp b/utils/vvis_launcher/vvis_launcher.cpp
new file mode 100644
index 0000000..edf03d2
--- /dev/null
+++ b/utils/vvis_launcher/vvis_launcher.cpp
@@ -0,0 +1,79 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+// vvis_launcher.cpp : Defines the entry point for the console application.
+//
+
+#include "stdafx.h"
+#include <direct.h>
+#include "tier1/strtools.h"
+#include "tier0/icommandline.h"
+#include "ilaunchabledll.h"
+
+
+
+char* GetLastErrorString()
+{
+ static char err[2048];
+
+ LPVOID lpMsgBuf;
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL
+ );
+
+ strncpy( err, (char*)lpMsgBuf, sizeof( err ) );
+ LocalFree( lpMsgBuf );
+
+ err[ sizeof( err ) - 1 ] = 0;
+
+ return err;
+}
+
+
+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;
+}
+