Prechádzať zdrojové kódy

Add "NoLoad" option for DynamicModuleHandle (#17696)

* Add "NoLoad" option for DynamicModuleHandle to only load when the DLL is resident.
* Refactor Load function of DynamicModuleHandle to use flags instead of a group of bools.
* Add unit tests for DLL loading.

Signed-off-by: Akio Gaule <[email protected]>
Co-authored-by: lemonade-dm <[email protected]>
Akio Gaule 1 rok pred
rodič
commit
00bc87dfb8
31 zmenil súbory, kde vykonal 139 pridanie a 87 odobranie
  1. 1 1
      Code/Editor/GameEngine.cpp
  2. 1 1
      Code/Editor/Plugins/EditorAssetImporter/AssetImporterPlugin.cpp
  3. 1 1
      Code/Editor/main.cpp
  4. 17 2
      Code/Framework/AzCore/AzCore/Module/DynamicModuleHandle.cpp
  5. 29 1
      Code/Framework/AzCore/AzCore/Module/DynamicModuleHandle.h
  6. 1 1
      Code/Framework/AzCore/AzCore/Module/ModuleManager.cpp
  7. 0 7
      Code/Framework/AzCore/Platform/Android/AzCore/Module/DynamicModuleHandle_Android.cpp
  8. 0 12
      Code/Framework/AzCore/Platform/Common/Apple/AzCore/Module/DynamicModuleHandle_Apple.cpp
  9. 8 5
      Code/Framework/AzCore/Platform/Common/UnixLike/AzCore/Module/DynamicModuleHandle_UnixLike.cpp
  10. 8 7
      Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/Module/DynamicModuleHandle_WinAPI.cpp
  11. 1 1
      Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/Process/ProcessInfo_WinAPI.cpp
  12. 0 12
      Code/Framework/AzCore/Platform/Linux/AzCore/Module/DynamicModuleHandle_Linux.cpp
  13. 0 12
      Code/Framework/AzCore/Platform/iOS/AzCore/Module/DynamicModuleHandle_iOS.cpp
  14. 52 4
      Code/Framework/AzCore/Tests/DLL.cpp
  15. 2 2
      Code/Framework/AzCore/Tests/Module.cpp
  16. 1 1
      Code/Framework/AzFramework/Platform/Linux/AzFramework/Input/LibEVDevWrapper.cpp
  17. 1 1
      Code/Framework/AzFramework/Platform/Windows/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad_Windows.cpp
  18. 1 1
      Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp
  19. 1 1
      Code/Framework/AzToolsFramework/AzToolsFramework/API/PythonLoader.cpp
  20. 1 1
      Code/LauncherUnified/Launcher.cpp
  21. 2 2
      Code/Tools/SceneAPI/SceneBuilder/Tests/TestsMain.cpp
  22. 1 1
      Code/Tools/SceneAPI/SceneData/Tests/TestsMain.cpp
  23. 2 2
      Gems/Atom/RHI/Code/Source/RHI/Factory.cpp
  24. 1 1
      Gems/EMotionFX/Code/Tests/InitSceneAPIFixture.h
  25. 1 1
      Gems/ImGui/Code/Source/ImGuiManager.cpp
  26. 1 1
      Gems/PhysX/Core/PhysX4/Source/Module.cpp
  27. 1 1
      Gems/PhysX/Core/PhysX5/Source/Module.cpp
  28. 1 1
      Gems/SceneLoggingExample/Code/SceneLoggingExampleModule.cpp
  29. 1 1
      Gems/SceneProcessing/Code/Source/SceneProcessingModule.cpp
  30. 1 1
      Gems/SceneProcessing/Code/Tests/InitSceneAPIFixture.h
  31. 1 1
      Gems/SceneProcessing/Code/Tests/SceneBuilder/SceneBuilderPhasesTests.cpp

+ 1 - 1
Code/Editor/GameEngine.cpp

@@ -319,7 +319,7 @@ AZ::Outcome<void, AZStd::string> CGameEngine::Init(
     constexpr const char* crySystemLibraryName = AZ_TRAIT_OS_DYNAMIC_LIBRARY_PREFIX  "CrySystem" AZ_TRAIT_OS_DYNAMIC_LIBRARY_EXTENSION;
 
     m_hSystemHandle = AZ::DynamicModuleHandle::Create(crySystemLibraryName);
-    if (!m_hSystemHandle->Load(true))
+    if (!m_hSystemHandle->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired))
     {
         auto errorMessage = AZStd::string::format("%s Loading Failed", crySystemLibraryName);
         Error(errorMessage.c_str());

+ 1 - 1
Code/Editor/Plugins/EditorAssetImporter/AssetImporterPlugin.cpp

@@ -71,7 +71,7 @@ AZStd::unique_ptr<AZ::DynamicModuleHandle> AssetImporterPlugin::LoadSceneLibrary
     AZStd::unique_ptr<AZ::DynamicModuleHandle> module = AZ::DynamicModuleHandle::Create(name);
     if (module)
     {
-        module->Load(false);
+        module->Load();
 
         if (explicitInit)
         {

+ 1 - 1
Code/Editor/main.cpp

@@ -22,7 +22,7 @@ int main(int argc, char* argv[])
     constexpr const char CryEditMainName[] = "CryEditMain";
 
     auto handle = AZ::DynamicModuleHandle::Create("EditorLib");
-    [[maybe_unused]] const bool loaded = handle->Load(true);
+    [[maybe_unused]] const bool loaded = handle->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired);
     AZ_Assert(loaded, "EditorLib could not be loaded");
 
     int ret = 1;

+ 17 - 2
Code/Framework/AzCore/AzCore/Module/DynamicModuleHandle.cpp

@@ -18,7 +18,22 @@ namespace AZ
 
     bool DynamicModuleHandle::Load(bool isInitializeFunctionRequired, bool globalSymbols /*= false*/)
     {
-        LoadStatus status = LoadModule(globalSymbols);
+        LoadFlags flags = LoadFlags::None;
+        if (isInitializeFunctionRequired)
+        {
+            flags |= LoadFlags::InitFuncRequired;
+        }
+
+        if (globalSymbols)
+        {
+            flags |= LoadFlags::GlobalSymbols;
+        }
+        return Load(flags);
+    }
+
+    bool DynamicModuleHandle::Load(LoadFlags flags /*= LoadFlags::None*/)
+    {
+        LoadStatus status = LoadModule(flags);
         switch (status)
         {
             case LoadStatus::LoadFailure:
@@ -48,7 +63,7 @@ namespace AZ
                 initFunc();
             }
         }
-        else if (isInitializeFunctionRequired)
+        else if (CheckBitsAny(flags, LoadFlags::InitFuncRequired))
         {
             AZ_Error("Module", false, "Unable to locate required entry point '%s' within module '%s'.",
                 InitializeDynamicModuleFunctionName, m_fileName.c_str());

+ 29 - 1
Code/Framework/AzCore/AzCore/Module/DynamicModuleHandle.h

@@ -11,6 +11,7 @@
 #include <AzCore/std/string/fixed_string.h>
 #include <AzCore/IO/Path/Path_fwd.h>
 #include <AzCore/Module/Environment.h>
+#include <AzCore/PlatformDef.h>
 
 namespace AZ
 {
@@ -23,6 +24,17 @@ namespace AZ
     class DynamicModuleHandle
     {
     public:
+        /// Flags used for loading a dynamic module.
+        enum class LoadFlags : uint32_t
+        {
+            None                = 0,
+            InitFuncRequired    = 1 << 0, /// Whether a missing \ref InitializeDynamicModuleFunction causes the Load to fail.
+            GlobalSymbols       = 1 << 1, /// On platforms that support it, make the module's symbols global and available for
+                                          /// the relocation processing of other modules. Otherwise, the symbols need to be queried manually.
+            NoLoad              = 1 << 2  /// Don't load the library (only get a handle if it's already loaded).
+                                          /// This can be used to test if the library is already resident.
+        };
+
         /// Platform-specific implementation should call Unload().
         virtual ~DynamicModuleHandle() = default;
 
@@ -47,8 +59,16 @@ namespace AZ
         ///                                     need to be queried manually.
         ///
         /// \return True if the module loaded successfully.
+        AZ_DEPRECATED_MESSAGE("This method has been deprecated. Please use DynamicModuleHandle::Load(LoadFlags flags) function instead")
         bool Load(bool isInitializeFunctionRequired, bool globalSymbols = false);
 
+        /// Loads the module.
+        /// Invokes the \ref InitializeDynamicModuleFunction if it is found in the module and this is the first time loading the module.
+        /// \param flags Flags to control the loading of the module. \ref LoadFlags
+        ///
+        /// \return True if the module loaded successfully.
+        bool Load(LoadFlags flags = LoadFlags::None);
+
         /// Unload the module.
         /// Invokes the \ref UninitializeDynamicModuleFunction if it is found in the module and
         /// this was the first handle to load the module.
@@ -87,8 +107,14 @@ namespace AZ
             AlreadyLoaded
         };
 
+        template<typename T>
+        constexpr bool CheckBitsAny(T v, T bits)
+        {
+            return (v & bits) != T{};
+        }
+
         // Attempt to load a module.
-        virtual LoadStatus LoadModule(bool globalSymbols) = 0;
+        virtual LoadStatus LoadModule(LoadFlags flags) = 0;
         virtual bool       UnloadModule() = 0;
         virtual void*      GetFunctionAddress(const char* functionName) const = 0;
 
@@ -101,6 +127,8 @@ namespace AZ
         AZ::EnvironmentVariable<bool> m_initialized;
     };
 
+    AZ_DEFINE_ENUM_BITWISE_OPERATORS(DynamicModuleHandle::LoadFlags);
+
     /**
      * Functions that the \ref AZ::ComponentApplication expects
      * to find in a dynamic module.

+ 1 - 1
Code/Framework/AzCore/AzCore/Module/ModuleManager.cpp

@@ -402,7 +402,7 @@ namespace AZ
                     }
 
                     // Load DLL from disk
-                    if (!moduleDataPtr->m_dynamicHandle->Load(true))
+                    if (!moduleDataPtr->m_dynamicHandle->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired))
                     {
                         return AZ::Failure(AZStd::string::format("Failed to load dynamic library at path \"%s\".",
                             moduleDataPtr->m_dynamicHandle->GetFilename()));

+ 0 - 7
Code/Framework/AzCore/Platform/Android/AzCore/Module/DynamicModuleHandle_Android.cpp

@@ -17,13 +17,6 @@ namespace AZ::Platform
         return {};
     }
 
-    void* OpenModule(const AZ::IO::FixedMaxPathString& fileName, bool&, bool globalSymbols)
-    {
-        // Android 19 does not have RTLD_NOLOAD but it should be OK since only the Editor expects to reopen modules
-        int openFlags = globalSymbols ? RTLD_NOW | RTLD_GLOBAL : RTLD_NOW;
-        return dlopen(fileName.c_str(), openFlags);
-    }
-
     void ConstructModuleFullFileName(AZ::IO::FixedMaxPath&)
     {
     }

+ 0 - 12
Code/Framework/AzCore/Platform/Common/Apple/AzCore/Module/DynamicModuleHandle_Apple.cpp

@@ -17,18 +17,6 @@ namespace AZ::Platform
         return AZ::Utils::GetExecutableDirectory();
     }
 
-    void* OpenModule(const AZ::IO::FixedMaxPathString& fileName, bool& alreadyOpen, bool globalSymbols)
-    {
-        void* handle = dlopen(fileName.c_str(), RTLD_NOLOAD);
-        alreadyOpen = (handle != nullptr);
-        if (!alreadyOpen)
-        {
-            int openFlags = globalSymbols ? RTLD_NOW | RTLD_GLOBAL : RTLD_NOW;
-            handle = dlopen(fileName.c_str(), openFlags);
-        }
-        return handle;
-    }
-
     void ConstructModuleFullFileName(AZ::IO::FixedMaxPath&)
     {
     }

+ 8 - 5
Code/Framework/AzCore/Platform/Common/UnixLike/AzCore/Module/DynamicModuleHandle_UnixLike.cpp

@@ -19,7 +19,6 @@
 namespace AZ::Platform
 {
     AZ::IO::FixedMaxPath GetModulePath();
-    void* OpenModule(const AZ::IO::FixedMaxPathString& fileName, bool& alreadyOpen, bool globalSymbols);
     void ConstructModuleFullFileName(AZ::IO::FixedMaxPath& fullPath);
     AZ::IO::FixedMaxPath CreateFrameworkModulePath(const AZ::IO::PathView& moduleName);
 }
@@ -132,12 +131,16 @@ namespace AZ
             Unload();
         }
 
-        LoadStatus LoadModule(bool globalSymbols) override
+        LoadStatus LoadModule(LoadFlags flags) override
         {
             AZ::Debug::Trace::Instance().Printf("Module", "Attempting to load module:%s\n", m_fileName.c_str());
-            bool alreadyOpen = false;
-
-            m_handle = Platform::OpenModule(m_fileName, alreadyOpen, globalSymbols);
+            const int openFlags = RTLD_NOW | (CheckBitsAny(flags, LoadFlags::GlobalSymbols) ? RTLD_GLOBAL : 0);
+            m_handle = dlopen(m_fileName.c_str(), openFlags | RTLD_NOLOAD);
+            bool alreadyOpen = (m_handle != nullptr);
+            if (m_handle == nullptr && !CheckBitsAny(flags, LoadFlags::NoLoad))
+            {                
+                m_handle = dlopen(m_fileName.c_str(), openFlags);
+            }
 
             if (m_handle)
             {

+ 8 - 7
Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/Module/DynamicModuleHandle_WinAPI.cpp

@@ -90,7 +90,7 @@ namespace AZ
             Unload();
         }
 
-        LoadStatus LoadModule([[maybe_unused]] bool globalSymbols) override
+        LoadStatus LoadModule(LoadFlags flags) override
         {
             if (IsLoaded())
             {
@@ -104,11 +104,12 @@ namespace AZ
             errno_t wcharResult = mbstowcs_s(&numCharsConverted, fileNameW, m_fileName.c_str(), AZ_ARRAY_SIZE(fileNameW) - 1);
             if (wcharResult == 0)
             {
-                // If module already open, return false, it was not loaded.
-                alreadyLoaded = NULL != GetModuleHandleW(fileNameW);
-
-                // Note: Windows LoadLibrary has no concept of specifying that the module symbols are global or local
-                m_handle = LoadLibraryW(fileNameW);
+                alreadyLoaded = GetModuleHandleExW(0, fileNameW, &m_handle);
+                if (m_handle == nullptr && !CheckBitsAny(flags, LoadFlags::NoLoad))
+                {
+                    // Note: Windows LoadLibrary has no concept of specifying that the module symbols are global or local
+                    m_handle = LoadLibraryW(fileNameW);
+                }
             }
             else
             {
@@ -155,7 +156,7 @@ namespace AZ
             return reinterpret_cast<void*>(::GetProcAddress(m_handle, functionName));
         }
 
-        HMODULE m_handle;
+        HMODULE m_handle = nullptr;
     };
 
     // Implement the module creation function

+ 1 - 1
Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/Process/ProcessInfo_WinAPI.cpp

@@ -31,7 +31,7 @@ namespace AZ
                     // Load the PSAPI.dll if it is not loaded
                     if (!handlePsapi->IsLoaded())
                     {
-                        handlePsapi->Load(false);
+                        handlePsapi->Load();
                     }
 
                     // If the Psapi.dll is loaded lookup the GetProcessMemoryInfo function

+ 0 - 12
Code/Framework/AzCore/Platform/Linux/AzCore/Module/DynamicModuleHandle_Linux.cpp

@@ -17,18 +17,6 @@ namespace AZ::Platform
         return AZ::Utils::GetExecutableDirectory();
     }
 
-    void* OpenModule(const AZ::IO::FixedMaxPathString& fileName, bool& alreadyOpen, bool globalSymbols)
-    {
-        void* handle = dlopen(fileName.c_str(), RTLD_NOLOAD);
-        alreadyOpen = (handle != nullptr);
-        if (!alreadyOpen)
-        {
-            int openFlags = globalSymbols ? RTLD_NOW | RTLD_GLOBAL : RTLD_NOW;
-            handle = dlopen(fileName.c_str(), openFlags);
-        }
-        return handle;
-    }
-
     void ConstructModuleFullFileName(AZ::IO::FixedMaxPath&)
     {
     }

+ 0 - 12
Code/Framework/AzCore/Platform/iOS/AzCore/Module/DynamicModuleHandle_iOS.cpp

@@ -18,18 +18,6 @@ namespace AZ::Platform
         return AZ::IO::FixedMaxPath(AZ::Utils::GetExecutableDirectory()) / "Frameworks";
     }
 
-    void* OpenModule(const AZ::IO::FixedMaxPathString& fileName, bool& alreadyOpen, bool globalSymbols)
-    {
-        void* handle = dlopen(fileName.c_str(), RTLD_NOLOAD);
-        alreadyOpen = (handle != nullptr);
-        if (!alreadyOpen)
-        {
-            int openFlags = globalSymbols ? RTLD_NOW | RTLD_GLOBAL : RTLD_NOW;
-            handle = dlopen(fileName.c_str(), openFlags);
-        }
-        return handle;
-    }
-
     void ConstructModuleFullFileName(AZ::IO::FixedMaxPath& fullPath)
     {
         // Append .framework to the name of full path

+ 52 - 4
Code/Framework/AzCore/Tests/DLL.cpp

@@ -42,7 +42,7 @@ namespace UnitTest
         void LoadModule()
         {
             m_handle = DynamicModuleHandle::Create("AzCoreTestDLL");
-            bool isLoaded = m_handle->Load(true);
+            bool isLoaded = m_handle->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired);
             ASSERT_TRUE(isLoaded) << "Could not load required test module: " << m_handle->GetFilename(); // failed to load the DLL, please check the output paths
 
             auto createModule = m_handle->GetFunction<CreateModuleClassFunction>(CreateModuleClassFunctionName);
@@ -197,7 +197,7 @@ namespace UnitTest
     TEST_F(DLL, LoadFailure)
     {
         auto handle = DynamicModuleHandle::Create("Not_a_DLL");
-        bool isLoaded = handle->Load(true);
+        bool isLoaded = handle->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired);
         EXPECT_FALSE(isLoaded);
 
         bool isUnloaded = handle->Unload();
@@ -207,12 +207,12 @@ namespace UnitTest
     TEST_F(DLL, LoadModuleTwice)
     {
         auto handle = DynamicModuleHandle::Create("AzCoreTestDLL");
-        bool isLoaded = handle->Load(true);
+        bool isLoaded = handle->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired);
         EXPECT_TRUE(isLoaded);
         EXPECT_TRUE(handle->IsLoaded());
 
         auto secondHandle = DynamicModuleHandle::Create("AzCoreTestDLL");
-        isLoaded = secondHandle->Load(true);
+        isLoaded = secondHandle->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired);
         EXPECT_TRUE(isLoaded);
         EXPECT_TRUE(handle->IsLoaded());
         EXPECT_TRUE(secondHandle->IsLoaded());
@@ -227,5 +227,53 @@ namespace UnitTest
         EXPECT_FALSE(handle->IsLoaded());
         EXPECT_FALSE(secondHandle->IsLoaded());
     }
+
+    TEST_F(DLL, NoLoadModule)
+    {
+        auto handle = DynamicModuleHandle::Create("AzCoreTestDLL");
+        bool isLoaded = handle->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired | AZ::DynamicModuleHandle::LoadFlags::NoLoad);
+        EXPECT_FALSE(isLoaded);
+        EXPECT_FALSE(handle->IsLoaded());
+    }
+
+    TEST_F(DLL, NoLoadLoadedModule)
+    {
+        auto handle = DynamicModuleHandle::Create("AzCoreTestDLL");
+        bool isLoaded = handle->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired);
+        EXPECT_TRUE(isLoaded);
+        EXPECT_TRUE(handle->IsLoaded());
+
+        auto secondHandle = DynamicModuleHandle::Create("AzCoreTestDLL");
+        isLoaded = secondHandle->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired | AZ::DynamicModuleHandle::LoadFlags::NoLoad);
+        EXPECT_TRUE(isLoaded);
+        EXPECT_TRUE(handle->IsLoaded());
+        EXPECT_TRUE(secondHandle->IsLoaded());
+
+        bool isUnloaded = handle->Unload();
+        EXPECT_TRUE(isUnloaded);
+        EXPECT_FALSE(handle->IsLoaded());
+        EXPECT_TRUE(secondHandle->IsLoaded());
+
+        {
+            // Check that the Module wasn't unloaded by the OS when unloading one DynamicModuleHandle (the OS should have 1 ref count left).
+            isLoaded = handle->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired | AZ::DynamicModuleHandle::LoadFlags::NoLoad);
+            EXPECT_TRUE(isLoaded);
+            EXPECT_TRUE(handle->IsLoaded());
+            handle->Unload();
+        }
+
+        isUnloaded = secondHandle->Unload();
+        EXPECT_TRUE(isUnloaded);
+        EXPECT_FALSE(handle->IsLoaded());
+        EXPECT_FALSE(secondHandle->IsLoaded());
+
+        {
+            // Check that the Module was unloaded by the OS.
+            isLoaded = handle->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired | AZ::DynamicModuleHandle::LoadFlags::NoLoad);
+            EXPECT_FALSE(isLoaded);
+            EXPECT_FALSE(handle->IsLoaded());
+            handle->Unload();
+        }
+    }
 #endif // !AZ_UNIT_TEST_SKIP_DLL_TEST
 }

+ 2 - 2
Code/Framework/AzCore/Tests/Module.cpp

@@ -410,14 +410,14 @@ namespace UnitTest
                 PrintFCollector watchForCreation("InitializeDynamicModule called");
                 {
                     auto handle = DynamicModuleHandle::Create("AzCoreTestDLL");
-                    handle->Load(true);
+                    handle->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired);
                     EXPECT_TRUE(watchForCreation.m_foundWhatWeWereWatchingFor); // should not destroy until we leave scope.
                                                                                 // steal the file path (which will be resolved with per-platform extensions like DLL or SO.
                     EXPECT_FALSE(watchForDestruction.m_foundWhatWeWereWatchingFor); // should not destroy until we leave scope.
 
                     PrintFCollector watchForCreationSecondTime("InitializeDynamicModule called");
                     auto handle2 = DynamicModuleHandle::Create("AzCoreTestDLL");
-                    handle2->Load(true);
+                    handle2->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired);
                     // this should NOT have initialized it again:
                     EXPECT_FALSE(watchForCreationSecondTime.m_foundWhatWeWereWatchingFor); // should not destroy until we leave scope.
                 }

+ 1 - 1
Code/Framework/AzFramework/Platform/Linux/AzFramework/Input/LibEVDevWrapper.cpp

@@ -14,7 +14,7 @@ namespace AzFramework
     LibEVDevWrapper::LibEVDevWrapper()
     {
         m_libevdevHandle = AZ::DynamicModuleHandle::Create("libevdev.so");
-        if (!m_libevdevHandle->Load(false))
+        if (!m_libevdevHandle->Load())
         {
             AZ_Info("Input", "libevdev.so not found - gamepad support disabled.  Install libevdev2 to enable.\n");
             m_libevdevHandle.reset();

+ 1 - 1
Code/Framework/AzFramework/Platform/Windows/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad_Windows.cpp

@@ -116,7 +116,7 @@ namespace XInput
         }
 
         AZStd::shared_ptr<AZ::DynamicModuleHandle> handle = AZ::DynamicModuleHandle::Create(DynamicModuleName);
-        const bool loaded = handle->Load(false);
+        const bool loaded = handle->Load();
         if (!loaded)
         {
             // Could not load XInput9_1_0, this is most likely a Windows Server 2012 machine.

+ 1 - 1
Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp

@@ -28,7 +28,7 @@ namespace AzFramework
     NativeWindowImpl_Win32::NativeWindowImpl_Win32()
     {
         // Attempt to load GetDpiForWindow from user32 at runtime, available on Windows 10+ versions >= 1607
-        if (auto user32module = AZ::DynamicModuleHandle::Create("user32"); user32module->Load(false))
+        if (auto user32module = AZ::DynamicModuleHandle::Create("user32"); user32module->Load())
         {
             m_getDpiFunction = user32module->GetFunction<GetDpiForWindowType>("GetDpiForWindow");
         }

+ 1 - 1
Code/Framework/AzToolsFramework/AzToolsFramework/API/PythonLoader.cpp

@@ -48,7 +48,7 @@ namespace AzToolsFramework::EmbeddedPython
         if (!isSdkEngine)
         {
             m_embeddedLibPythonModuleHandle = AZ::DynamicModuleHandle::Create(IMPLICIT_LOAD_PYTHON_SHARED_LIBRARY, false);
-            bool loadResult = m_embeddedLibPythonModuleHandle->Load(false, true);
+            bool loadResult = m_embeddedLibPythonModuleHandle->Load(AZ::DynamicModuleHandle::LoadFlags::GlobalSymbols);
             AZ_Error("PythonLoader", loadResult, "Failed to load " IMPLICIT_LOAD_PYTHON_SHARED_LIBRARY "\n");
         }
         #endif // IMPLICIT_LOAD_PYTHON_SHARED_LIBRARY

+ 1 - 1
Code/LauncherUnified/Launcher.cpp

@@ -563,7 +563,7 @@ namespace O3DELauncher
     #if !defined(AZ_MONOLITHIC_BUILD)
         constexpr const char* crySystemLibraryName = AZ_TRAIT_OS_DYNAMIC_LIBRARY_PREFIX  "CrySystem" AZ_TRAIT_OS_DYNAMIC_LIBRARY_EXTENSION;
         AZStd::unique_ptr<AZ::DynamicModuleHandle> crySystemLibrary = AZ::DynamicModuleHandle::Create(crySystemLibraryName);
-        if (crySystemLibrary->Load(true))
+        if (crySystemLibrary->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired))
         {
             PFNCREATESYSTEMINTERFACE CreateSystemInterface =
                 crySystemLibrary->GetFunction<PFNCREATESYSTEMINTERFACE>("CreateSystemInterface");

+ 2 - 2
Code/Tools/SceneAPI/SceneBuilder/Tests/TestsMain.cpp

@@ -23,7 +23,7 @@ protected:
     {
         sceneCoreModule = AZ::DynamicModuleHandle::Create("SceneCore");
         AZ_Assert(sceneCoreModule, "SceneBuilder unit tests failed to create SceneCore module.");
-        [[maybe_unused]] bool loaded = sceneCoreModule->Load(false);
+        [[maybe_unused]] bool loaded = sceneCoreModule->Load();
         AZ_Assert(loaded, "SceneBuilder unit tests failed to load SceneCore module.");
         auto init = sceneCoreModule->GetFunction<AZ::InitializeDynamicModuleFunction>(AZ::InitializeDynamicModuleFunctionName);
         AZ_Assert(init, "SceneBuilder unit tests failed to find the initialization function the SceneCore module.");
@@ -31,7 +31,7 @@ protected:
 
         sceneDataModule = AZ::DynamicModuleHandle::Create("SceneData");
         AZ_Assert(sceneDataModule, "SceneData unit tests failed to create SceneData module.");
-        loaded = sceneDataModule->Load(false);
+        loaded = sceneDataModule->Load();
         AZ_Assert(loaded, "SceneBuilder unit tests failed to load SceneData module.");
         init = sceneDataModule->GetFunction<AZ::InitializeDynamicModuleFunction>(AZ::InitializeDynamicModuleFunctionName);
         AZ_Assert(init, "SceneBuilder unit tests failed to find the initialization function the SceneData module.");

+ 1 - 1
Code/Tools/SceneAPI/SceneData/Tests/TestsMain.cpp

@@ -22,7 +22,7 @@ protected:
     {
         sceneCoreModule = AZ::DynamicModuleHandle::Create("SceneCore");
         AZ_Assert(sceneCoreModule, "SceneData unit tests failed to create SceneCore module.");
-        [[maybe_unused]] bool loaded = sceneCoreModule->Load(false);
+        [[maybe_unused]] bool loaded = sceneCoreModule->Load();
         AZ_Assert(loaded, "SceneData unit tests failed to load SceneCore module.");
         auto init = sceneCoreModule->GetFunction<AZ::InitializeDynamicModuleFunction>(AZ::InitializeDynamicModuleFunctionName);
         AZ_Assert(init, "SceneData unit tests failed to find the initialization function the SceneCore module.");

+ 2 - 2
Gems/Atom/RHI/Code/Source/RHI/Factory.cpp

@@ -69,7 +69,7 @@ namespace AZ::RHI
             s_renderDocModule = DynamicModuleHandle::Create(AZ_TRAIT_RENDERDOC_MODULE);
             if (s_renderDocModule)
             {
-                if (s_renderDocModule->Load(false))
+                if (s_renderDocModule->Load())
                 {
                     s_isRenderDocDllLoaded = true;
                     pRENDERDOC_GetAPI renderDocGetAPI = s_renderDocModule->GetFunction<pRENDERDOC_GetAPI>("RENDERDOC_GetAPI");
@@ -111,7 +111,7 @@ namespace AZ::RHI
             s_pixModule = DynamicModuleHandle::Create(dllPath.c_str());
             if (s_pixModule)
             {
-                if (!s_pixModule->Load(false))
+                if (!s_pixModule->Load())
                 {
                     AZ_Printf("RHISystem", "Pix capture requested but module failed to load.\n");
                 }

+ 1 - 1
Gems/EMotionFX/Code/Tests/InitSceneAPIFixture.h

@@ -35,7 +35,7 @@ namespace EMotionFX
             {
                 AZStd::unique_ptr<AZ::DynamicModuleHandle> module = AZ::DynamicModuleHandle::Create(moduleName.c_str());
                 ASSERT_TRUE(module) << "EMotionFX Editor unit tests failed to create " << moduleName.c_str() << " module.";
-                const bool loaded = module->Load(false);
+                const bool loaded = module->Load();
                 ASSERT_TRUE(loaded) << "EMotionFX Editor unit tests failed to load " << moduleName.c_str() << " module.";
                 auto init = module->GetFunction<AZ::InitializeDynamicModuleFunction>(AZ::InitializeDynamicModuleFunctionName);
                 ASSERT_TRUE(init) << "EMotionFX Editor unit tests failed to find the initialization function the " << moduleName.c_str() << " module.";

+ 1 - 1
Gems/ImGui/Code/Source/ImGuiManager.cpp

@@ -109,7 +109,7 @@ void ImGuiManager::Initialize()
     // Let the application process the path
     AZ::ComponentApplicationBus::Broadcast(&AZ::ComponentApplicationBus::Events::ResolveModulePath, imgGuiLibPath);
     m_imgSharedLib = AZ::DynamicModuleHandle::Create(imgGuiLibPath.c_str());
-    if (!m_imgSharedLib->Load(false))
+    if (!m_imgSharedLib->Load())
     {
         AZ_Warning("ImGuiManager", false, "%s %s", __func__, "Unable to load " AZ_DYNAMIC_LIBRARY_PREFIX "imguilib" AZ_DYNAMIC_LIBRARY_EXTENSION "-- Skipping ImGui Initialization.");
         return;

+ 1 - 1
Gems/PhysX/Core/PhysX4/Source/Module.cpp

@@ -83,7 +83,7 @@ namespace PhysX
 #if defined(PHYSX_EDITOR)
             {
                 AZStd::unique_ptr<AZ::DynamicModuleHandle> sceneCoreModule = AZ::DynamicModuleHandle::Create("SceneCore");
-                [[maybe_unused]] bool ok = sceneCoreModule->Load(true/*isInitializeFunctionRequired*/);
+                [[maybe_unused]] bool ok = sceneCoreModule->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired);
                 AZ_Error("PhysX::Module", ok, "Error loading SceneCore module");
 
                 m_modules.push_back(AZStd::move(sceneCoreModule));

+ 1 - 1
Gems/PhysX/Core/PhysX5/Source/Module.cpp

@@ -83,7 +83,7 @@ namespace PhysX
 #if defined(PHYSX_EDITOR)
             {
                 AZStd::unique_ptr<AZ::DynamicModuleHandle> sceneCoreModule = AZ::DynamicModuleHandle::Create("SceneCore");
-                [[maybe_unused]] bool ok = sceneCoreModule->Load(true/*isInitializeFunctionRequired*/);
+                [[maybe_unused]] bool ok = sceneCoreModule->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired);
                 AZ_Error("PhysX::Module", ok, "Error loading SceneCore module");
 
                 m_modules.push_back(AZStd::move(sceneCoreModule));

+ 1 - 1
Gems/SceneLoggingExample/Code/SceneLoggingExampleModule.cpp

@@ -33,7 +33,7 @@ namespace SceneLoggingExample
             // sure to repeat the following two lines for any SceneAPI you want to use. Omitting these 
             // calls or making them too late can cause problems such as missing EBus events.
             m_sceneCoreModule = AZ::DynamicModuleHandle::Create("SceneCore");
-            m_sceneCoreModule->Load(true);
+            m_sceneCoreModule->Load(AZ::DynamicModuleHandle::LoadFlags::InitFuncRequired);
             m_descriptors.insert(m_descriptors.end(), 
             {
                 LoggingGroupBehavior::CreateDescriptor(),

+ 1 - 1
Gems/SceneProcessing/Code/Source/SceneProcessingModule.cpp

@@ -95,7 +95,7 @@ namespace AZ
                     module = DynamicModuleHandle::Create(name);
                     if (module)
                     {
-                        module->Load(false);
+                        module->Load();
                         auto init = module->GetFunction<InitializeDynamicModuleFunction>(InitializeDynamicModuleFunctionName);
                         if (init)
                         {

+ 1 - 1
Gems/SceneProcessing/Code/Tests/InitSceneAPIFixture.h

@@ -33,7 +33,7 @@ namespace SceneProcessing
             {
                 AZStd::unique_ptr<AZ::DynamicModuleHandle> module = AZ::DynamicModuleHandle::Create(moduleName.c_str());
                 ASSERT_TRUE(module) << "Scene Processing Gem unit tests failed to create " << moduleName.c_str() << " module.";
-                const bool loaded = module->Load(false);
+                const bool loaded = module->Load();
                 ASSERT_TRUE(loaded) << "Scene Processing Gem unit tests failed to load " << moduleName.c_str() << " module.";
                 auto init = module->GetFunction<AZ::InitializeDynamicModuleFunction>(AZ::InitializeDynamicModuleFunctionName);
                 ASSERT_TRUE(init) << "Scene Processing Gem unit tests failed to find the initialization function the " << moduleName.c_str() << " module.";

+ 1 - 1
Gems/SceneProcessing/Code/Tests/SceneBuilder/SceneBuilderPhasesTests.cpp

@@ -182,7 +182,7 @@ private:
             return {};
         }
 
-        module->Load(false);
+        module->Load();
         if (auto init = module->GetFunction<AZ::InitializeDynamicModuleFunction>(AZ::InitializeDynamicModuleFunctionName); init)
         {
             AZStd::invoke(init);