Counter Strike : Global Offensive Source Code
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.

104 lines
2.5 KiB

  1. //====== Copyright c 1996-2007, Valve Corporation, All rights reserved. =======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef SUBPROCESS_H
  9. #define SUBPROCESS_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. class SubProcessKernelObjects
  14. {
  15. friend class SubProcessKernelObjects_Memory;
  16. public:
  17. SubProcessKernelObjects( void );
  18. ~SubProcessKernelObjects( void );
  19. private:
  20. SubProcessKernelObjects( SubProcessKernelObjects const & );
  21. SubProcessKernelObjects & operator =( SubProcessKernelObjects const & );
  22. protected:
  23. BOOL Create( char const *szBaseName );
  24. BOOL Open( char const *szBaseName );
  25. public:
  26. BOOL IsValid( void ) const;
  27. void Close( void );
  28. protected:
  29. HANDLE m_hMemorySection;
  30. HANDLE m_hMutex;
  31. HANDLE m_hEvent[2];
  32. DWORD m_dwCookie;
  33. };
  34. class SubProcessKernelObjects_Create : public SubProcessKernelObjects
  35. {
  36. public:
  37. SubProcessKernelObjects_Create( char const *szBaseName ) { Create( szBaseName ), m_dwCookie = 1; }
  38. };
  39. class SubProcessKernelObjects_Open : public SubProcessKernelObjects
  40. {
  41. public:
  42. SubProcessKernelObjects_Open( char const *szBaseName ) { Open( szBaseName ), m_dwCookie = 0; }
  43. };
  44. class SubProcessKernelObjects_Memory
  45. {
  46. public:
  47. SubProcessKernelObjects_Memory( SubProcessKernelObjects *p ) : m_pObjs( p ), m_pLockData( NULL ), m_pMemory( NULL ) { }
  48. ~SubProcessKernelObjects_Memory() { Unlock(); }
  49. public:
  50. void * Lock( void );
  51. BOOL Unlock( void );
  52. public:
  53. BOOL IsValid( void ) const { return m_pLockData != NULL; }
  54. void * GetMemory( void ) const { return m_pMemory; }
  55. protected:
  56. void *m_pMemory;
  57. private:
  58. SubProcessKernelObjects *m_pObjs;
  59. void *m_pLockData;
  60. };
  61. //
  62. // Response implementation
  63. //
  64. class CSubProcessResponse : public CmdSink::IResponse
  65. {
  66. public:
  67. explicit CSubProcessResponse( void const *pvMemory );
  68. ~CSubProcessResponse( void ) { }
  69. public:
  70. virtual bool Succeeded( void ) { return ( 1 == m_dwResult ); }
  71. virtual size_t GetResultBufferLen( void ) { return ( Succeeded() ? m_dwResultBufferLength : 0 ); }
  72. virtual const void * GetResultBuffer( void ) { return ( Succeeded() ? m_pvResultBuffer : NULL ); }
  73. virtual const char * GetListing( void ) { return (const char *) ( ( m_szListing && * m_szListing ) ? m_szListing : NULL ); }
  74. protected:
  75. void const *m_pvMemory;
  76. DWORD m_dwResult;
  77. DWORD m_dwResultBufferLength;
  78. void const *m_pvResultBuffer;
  79. char const *m_szListing;
  80. };
  81. int ShaderCompile_Subprocess_Main( char const *szSubProcessData );
  82. #endif // #ifndef SUBPROCESS_H