Skip to content

Commit

Permalink
xrCore: Added functions for dynamic library loading and function lookup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaffeine committed Nov 24, 2015
1 parent 7048f0a commit eca97a3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/xrCore/ModuleLookup.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "ModuleLookup.hpp"

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

namespace XRay {
HMODULE LoadLibrary(const char *libraryFileName, bool log)
{
if (log)
Log("Loading DLL:", libraryFileName);
return ::LoadLibrary(libraryFileName);
}

void UnloadLibrary(HMODULE libraryHandle)
{
FreeLibrary(libraryHandle);
}

void *GetProcAddress(HMODULE libraryHandle, const char *procName)
{
return ::GetProcAddress(libraryHandle, procName);
}

}
9 changes: 9 additions & 0 deletions src/xrCore/ModuleLookup.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include "xrCore.h"

namespace XRay {
XRCORE_API HMODULE LoadLibrary(const char *libraryFileName, bool log = true);
XRCORE_API void UnloadLibrary(HMODULE libraryHandle);
XRCORE_API void *GetProcAddress(HMODULE libraryHandle, const char *procName);
}
2 changes: 2 additions & 0 deletions src/xrCore/xrCore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@
<ClCompile Include="Threading\ttapi.cpp" />
<ClCompile Include="Threading\Lock.cpp" />
<ClCompile Include="xrCore.cpp" />
<ClCompile Include="ModuleLookup.cpp" />
<ClCompile Include="xrDebugNew.cpp" />
<ClCompile Include="xrMemory.cpp" />
<ClCompile Include="xrMemory_align.cpp" />
Expand Down Expand Up @@ -508,6 +509,7 @@
<ClInclude Include="Threading\Lock.hpp" />
<ClInclude Include="vector.h" />
<ClInclude Include="xrCore.h" />
<ClInclude Include="ModuleLookup.hpp" />
<ClInclude Include="Platform.h" />
<ClInclude Include="xrDebug.h" />
<ClInclude Include="xrDebug_macros.h" />
Expand Down
6 changes: 6 additions & 0 deletions src/xrCore/xrCore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@
<ClCompile Include="xrCore.cpp">
<Filter>Kernel</Filter>
</ClCompile>
<ClCompile Include="ModuleLookup.cpp">
<Filter>Kernel</Filter>
</ClCompile>
<ClCompile Include="_compressed_normal.cpp">
<Filter>Math</Filter>
</ClCompile>
Expand Down Expand Up @@ -401,6 +404,9 @@
<ClInclude Include="xrCore.h">
<Filter>Kernel</Filter>
</ClInclude>
<ClInclude Include="ModuleLookup.hpp">
<Filter>Kernel</Filter>
</ClInclude>
<ClInclude Include="Platform.h">
<Filter>Kernel</Filter>
</ClInclude>
Expand Down

0 comments on commit eca97a3

Please sign in to comment.