Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. // vvis_launcher.cpp : Defines the entry point for the console application.
  9. //
  10. #include "stdafx.h"
  11. #include <direct.h>
  12. #include "tier1/strtools.h"
  13. #include "tier0/icommandline.h"
  14. #include "ilaunchabledll.h"
  15. char* GetLastErrorString()
  16. {
  17. static char err[2048];
  18. LPVOID lpMsgBuf;
  19. FormatMessage(
  20. FORMAT_MESSAGE_ALLOCATE_BUFFER |
  21. FORMAT_MESSAGE_FROM_SYSTEM |
  22. FORMAT_MESSAGE_IGNORE_INSERTS,
  23. NULL,
  24. GetLastError(),
  25. MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
  26. (LPTSTR) &lpMsgBuf,
  27. 0,
  28. NULL
  29. );
  30. strncpy( err, (char*)lpMsgBuf, sizeof( err ) );
  31. LocalFree( lpMsgBuf );
  32. err[ sizeof( err ) - 1 ] = 0;
  33. return err;
  34. }
  35. int main(int argc, char* argv[])
  36. {
  37. CommandLine()->CreateCmdLine( argc, argv );
  38. const char *pDLLName = "vvis_dll.dll";
  39. CSysModule *pModule = Sys_LoadModule( pDLLName );
  40. if ( !pModule )
  41. {
  42. printf( "vvis launcher error: can't load %s\n%s", pDLLName, GetLastErrorString() );
  43. return 1;
  44. }
  45. CreateInterfaceFn fn = Sys_GetFactory( pModule );
  46. if( !fn )
  47. {
  48. printf( "vvis launcher error: can't get factory from %s\n", pDLLName );
  49. Sys_UnloadModule( pModule );
  50. return 2;
  51. }
  52. int retCode = 0;
  53. ILaunchableDLL *pDLL = (ILaunchableDLL*)fn( LAUNCHABLE_DLL_INTERFACE_VERSION, &retCode );
  54. if( !pDLL )
  55. {
  56. printf( "vvis launcher error: can't get IVVisDLL interface from %s\n", pDLLName );
  57. Sys_UnloadModule( pModule );
  58. return 3;
  59. }
  60. pDLL->main( argc, argv );
  61. Sys_UnloadModule( pModule );
  62. return 0;
  63. }