Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cOSModDyn.h
Go to the documentation of this file.
1 //
4 //
5 #ifndef _INC_cOSModDyn_H
6 #define _INC_cOSModDyn_H
7 #ifndef NO_PRAGMA_ONCE
8 #pragma once
9 #endif
10 
11 #include "../GrayLibBase.h"
14 
15 namespace GrayLib
16 {
18  {
21 
22  typedef cOSModImpl SUPER_t;
23 
24  public:
25  cOSModDyn(const char* pszModuleName) noexcept
26  : cOSModImpl(pszModuleName)
27  {
28  }
29 
30  virtual HRESULT RegisterModule(DWORD dwGrayLibVer, cOSModDyn** ppMod, IUnknown* pContainer)
31  {
36 
38  if (dwGrayLibVer != _INC_GrayLibBase_H)
39  return HRESULT_WIN32_C(ERROR_PRODUCT_VERSION);
40 
41  // My *Core DLL is the correct version and packing is correct?
43  if (FAILED(hRes))
44  return hRes;
45 
46  ASSERT(IsLoaded());
47  if (ppMod != nullptr)
48  {
49  *ppMod = this;
50  }
51  return S_OK; // We are good with dwGrayLibVer!
52  }
53 
54  virtual void UnRegisterModule()
55  {
56  // Unload all my connected data (if possible)
57  }
58  };
59 
60  typedef HRESULT(GRAYCALL COSMod_RegisterModuleC)(UINT32 dwGrayLibVer, cOSModDyn** ppMod, IUnknown* pContainer);
61 
62 #ifdef USE_64BIT
63 #define COSMod_RegisterModuleS GRAY_NAMES "_RegisterModule" // Gray_RegisterModule name as a string. 64 bit
64 #else
65 #define COSMod_RegisterModuleS "_" GRAY_NAMES "_RegisterModule@12" // Gray_RegisterModule name as a string. 32 bit name has decoration.
66 #endif
67 
68 #ifdef GRAY_DLL // _WINDLL
69  // Declare/expose *_RegisterModule() for dynamically pluggable DLL.
70 #define COSMODULE_RegisterModule_IMPL(N) COSMODULE_IMPL(N); \
71 extern "C" __DECL_EXPORT HRESULT GRAYCALL CATOM_CAT(Gray,_RegisterModule)(DWORD dwGrayLibVer, ::GrayLib::cOSModDyn** ppMod, IUnknown* pContainer) { return N::g_Module.RegisterModule(dwGrayLibVer, ppMod, pContainer); }
72 #else
73 #define COSMODULE_RegisterModule_IMPL(N)
74 #endif // GRAY_DLL
75 
76 }
77 
78 #endif
#define _INC_GrayCore_H
0.0.3 Version stamp the API. Especially important to the Variant and Archive types.
Definition: GrayCore.h:7
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define _INC_GrayLibBase_H
Definition: GrayLibBase.h:7
#define HRESULT_WIN32_C(x)
a constant LSTATUS/error_status_t with no check, unlike HRESULT_FROM_WIN32()
Definition: HResult.h:79
#define FAILED(x)
Definition: HResult.h:30
#define UNREFERENCED_PARAMETER(P)
< _WIN32 type thing. get rid of stupid warning.
Definition: SysTypes.h:299
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define ASSERT(exp)
Definition: cDebugAssert.h:87
Definition: cOSModDyn.h:18
cOSModDyn(const char *pszModuleName) noexcept
Definition: cOSModDyn.h:25
virtual HRESULT RegisterModule(DWORD dwGrayLibVer, cOSModDyn **ppMod, IUnknown *pContainer)
Definition: cOSModDyn.h:30
virtual void UnRegisterModule()
Definition: cOSModDyn.h:54
Definition: cAppState.h:82
static HRESULT CheckValidSignature(UINT32 nGrayCoreVer, size_t nSizeofThis)
Definition: cAppState.h:120
Definition: cOSModImpl.h:25
Definition: IUnknown.h:68
Definition: cMesh.h:22
cOSModDyn ** ppMod
Definition: cOSModDyn.h:60
typedef HRESULT(GRAYCALL COSMod_RegisterModuleC)(UINT32 dwGrayLibVer
cOSModDyn IUnknown * pContainer
Definition: cOSModDyn.h:60