From de22950caf591fd66c5537d07b205d7b1d376696 Mon Sep 17 00:00:00 2001 From: Dreamy Cecil <21009796+DreamyCecil@users.noreply.github.com> Date: Thu, 13 Jun 2024 00:51:11 +0300 Subject: [PATCH] Add OS structure for dynamic modules that utilize the engine. --- Sources/Engine/OS/OS.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Sources/Engine/OS/OS.h b/Sources/Engine/OS/OS.h index 350416667..80bd00e80 100644 --- a/Sources/Engine/OS/OS.h +++ b/Sources/Engine/OS/OS.h @@ -64,6 +64,31 @@ class ENGINE_API OS { void Destroy(void); }; + // Depending on build configuration this structure can either be: + // - A handle to a dynamic module + // - A dummy for a static module + struct EngineModule { + HMODULE hHandle; + + EngineModule(HMODULE hOther = NULL) : hHandle(hOther) {}; + + inline BOOL IsLoaded(void) { return hHandle != NULL; }; + inline void Load(const char *strLibrary) { hHandle = LoadLib(strLibrary); }; + inline void LoadOrThrow_t(const char *strLibrary) { hHandle = LoadLibOrThrow_t(strLibrary); }; + + inline BOOL Free(void) { + if (!IsLoaded()) return FALSE; + BOOL bReturn = FreeLib(hHandle); + hHandle = NULL; + return bReturn; + }; + + inline EngineModule &operator=(const EngineModule &hOther) { + hHandle = hOther.hHandle; + return *this; + }; + }; + // Dynamic library methods public: