Skip to content

Commit 2e7ab44

Browse files
committed
Add LoadFromPath method by default flags
1 parent c6cadbb commit 2e7ab44

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

include/dynlibutils/module.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ class CAssemblyModule : public CMemory
407407
explicit CAssemblyModule(const std::string& sModuleName) : CAssemblyModule(std::string_view(sModuleName)) {}
408408

409409
bool LoadFromPath(const std::string_view svModelePath, int flags);
410+
bool LoadFromPath(const std::string_view svModelePath);
410411

411412
bool InitFromName(const std::string_view svModuleName, bool bExtension = false);
412413
bool InitFromMemory(const CMemory pModuleMemory, bool bForce = true);

src/apple/module.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bool CAssemblyModule<Mutex>::InitFromName(const std::string_view svModuleName, b
5858
if (!bExtension)
5959
sModuleName.append(".dylib");
6060

61-
SetPtr(dlopen(sModuleName.c_str(), RTLD_LAZY));
61+
SetPtr(dlopen(sModuleName.c_str()));
6262

6363
return IsValid();
6464
}
@@ -81,7 +81,7 @@ bool CAssemblyModule<Mutex>::InitFromMemory(const CMemory pModuleMemory, bool bF
8181
if (!dladdr(pModuleMemory, &info) || !info.dli_fbase || !info.dli_fname)
8282
return false;
8383

84-
if (!LoadFromPath(info.dli_fname, RTLD_LAZY))
84+
if (!LoadFromPath(info.dli_fname))
8585
return false;
8686

8787
return true;
@@ -148,6 +148,12 @@ bool CAssemblyModule<Mutex>::LoadFromPath(const std::string_view svModelePath, i
148148
return true;
149149
}
150150

151+
template<typename Mutex>
152+
bool CAssemblyModule<Mutex>::LoadFromPath(const std::string_view svModelePath)
153+
{
154+
return LoadFromPath(svModelePath, RTLD_LAZY);
155+
}
156+
151157
//-----------------------------------------------------------------------------
152158
// Purpose: Gets an address of a virtual method table by rtti type descriptor name
153159
// Input : svTableName

src/linux/module.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ bool CAssemblyModule<Mutex>::InitFromName(const std::string_view svModuleName, b
6262
if (!dldata.addr)
6363
return false;
6464

65-
if (!LoadFromPath(dldata.modulePath, RTLD_LAZY | RTLD_NOLOAD))
65+
if (!LoadFromPath(dldata.modulePath))
6666
return false;
6767

6868
return true;
@@ -86,7 +86,7 @@ bool CAssemblyModule<Mutex>::InitFromMemory(const CMemory pModuleMemory, bool bF
8686
if (!dladdr(pModuleMemory, &info) || !info.dli_fbase || !info.dli_fname)
8787
return false;
8888

89-
if (!LoadFromPath(info.dli_fname, RTLD_LAZY | RTLD_NOLOAD))
89+
if (!LoadFromPath(info.dli_fname))
9090
return false;
9191

9292
return true;
@@ -153,6 +153,12 @@ bool CAssemblyModule<Mutex>::LoadFromPath(const std::string_view svModelePath, i
153153
return true;
154154
}
155155

156+
template<typename Mutex>
157+
bool CAssemblyModule<Mutex>::LoadFromPath(const std::string_view svModelePath)
158+
{
159+
return LoadFromPath(svModelePath, RTLD_LAZY);
160+
}
161+
156162
//-----------------------------------------------------------------------------
157163
// Purpose: Gets an address of a virtual method table by rtti type descriptor name
158164
// Input : svTableName

src/windows/module.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ bool CAssemblyModule<Mutex>::InitFromName(const std::string_view svModuleName, b
7272
if(modulePath.empty())
7373
return false;
7474

75-
if (!LoadFromPath(modulePath, DONT_RESOLVE_DLL_REFERENCES))
75+
if (!LoadFromPath(modulePath))
7676
return false;
7777

7878
return true;
@@ -100,7 +100,7 @@ bool CAssemblyModule<Mutex>::InitFromMemory(const CMemory pModuleMemory, bool bF
100100
if (modulePath.empty())
101101
return false;
102102

103-
if (!LoadFromPath(modulePath, DONT_RESOLVE_DLL_REFERENCES))
103+
if (!LoadFromPath(modulePath))
104104
return false;
105105

106106
return true;
@@ -139,6 +139,12 @@ bool CAssemblyModule<Mutex>::LoadFromPath(const std::string_view svModelePath, i
139139
return true;
140140
}
141141

142+
template<typename Mutex>
143+
bool CAssemblyModule<Mutex>::LoadFromPath(const std::string_view svModelePath)
144+
{
145+
return LoadFromPath(svModelePath, DONT_RESOLVE_DLL_REFERENCES);
146+
}
147+
142148
//-----------------------------------------------------------------------------
143149
// Purpose: Gets an address of a virtual method table by rtti type descriptor name
144150
// Input : svTableName

0 commit comments

Comments
 (0)