Skip to content

Commit eca97a3

Browse files
committed
xrCore: Added functions for dynamic library loading and function lookup.
1 parent 7048f0a commit eca97a3

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

src/xrCore/ModuleLookup.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "ModuleLookup.hpp"
2+
3+
#define WIN32_LEAN_AND_MEAN
4+
#include <windows.h>
5+
6+
namespace XRay {
7+
HMODULE LoadLibrary(const char *libraryFileName, bool log)
8+
{
9+
if (log)
10+
Log("Loading DLL:", libraryFileName);
11+
return ::LoadLibrary(libraryFileName);
12+
}
13+
14+
void UnloadLibrary(HMODULE libraryHandle)
15+
{
16+
FreeLibrary(libraryHandle);
17+
}
18+
19+
void *GetProcAddress(HMODULE libraryHandle, const char *procName)
20+
{
21+
return ::GetProcAddress(libraryHandle, procName);
22+
}
23+
24+
}

src/xrCore/ModuleLookup.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
#include "xrCore.h"
4+
5+
namespace XRay {
6+
XRCORE_API HMODULE LoadLibrary(const char *libraryFileName, bool log = true);
7+
XRCORE_API void UnloadLibrary(HMODULE libraryHandle);
8+
XRCORE_API void *GetProcAddress(HMODULE libraryHandle, const char *procName);
9+
}

src/xrCore/xrCore.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@
376376
<ClCompile Include="Threading\ttapi.cpp" />
377377
<ClCompile Include="Threading\Lock.cpp" />
378378
<ClCompile Include="xrCore.cpp" />
379+
<ClCompile Include="ModuleLookup.cpp" />
379380
<ClCompile Include="xrDebugNew.cpp" />
380381
<ClCompile Include="xrMemory.cpp" />
381382
<ClCompile Include="xrMemory_align.cpp" />
@@ -508,6 +509,7 @@
508509
<ClInclude Include="Threading\Lock.hpp" />
509510
<ClInclude Include="vector.h" />
510511
<ClInclude Include="xrCore.h" />
512+
<ClInclude Include="ModuleLookup.hpp" />
511513
<ClInclude Include="Platform.h" />
512514
<ClInclude Include="xrDebug.h" />
513515
<ClInclude Include="xrDebug_macros.h" />

src/xrCore/xrCore.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@
132132
<ClCompile Include="xrCore.cpp">
133133
<Filter>Kernel</Filter>
134134
</ClCompile>
135+
<ClCompile Include="ModuleLookup.cpp">
136+
<Filter>Kernel</Filter>
137+
</ClCompile>
135138
<ClCompile Include="_compressed_normal.cpp">
136139
<Filter>Math</Filter>
137140
</ClCompile>
@@ -401,6 +404,9 @@
401404
<ClInclude Include="xrCore.h">
402405
<Filter>Kernel</Filter>
403406
</ClInclude>
407+
<ClInclude Include="ModuleLookup.hpp">
408+
<Filter>Kernel</Filter>
409+
</ClInclude>
404410
<ClInclude Include="Platform.h">
405411
<Filter>Kernel</Filter>
406412
</ClInclude>

0 commit comments

Comments
 (0)