Skip to content

Commit

Permalink
Use plain "LoadLibrary".
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jul 1, 2021
1 parent 387a2b3 commit d13a57d
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions win_directx_helper/win_directx_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ HRESULT (__stdcall *CreateDXGIFactory1)(
REFIID riid,
_COM_Outptr_ void **ppFactory);

Handle SafeLoadLibrary(const wchar_t *name) {
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32);
return LoadLibrary(name);
}

template <typename Function>
inline bool LoadSymbol(Handle handle, const char *name, Function &func) {
func = handle
Expand All @@ -63,7 +58,7 @@ inline bool LoadSymbol(Handle handle, const char *name, Function &func) {

bool ResolveD3D9() {
static const auto loaded = [] {
const auto d3d9 = SafeLoadLibrary(L"d3d9.dll");
const auto d3d9 = LoadLibrary(L"d3d9.dll");
LOAD_SYMBOL(d3d9, D3DPERF_BeginEvent);
LOAD_SYMBOL(d3d9, D3DPERF_EndEvent);
LOAD_SYMBOL(d3d9, D3DPERF_SetMarker);
Expand All @@ -76,7 +71,7 @@ bool ResolveD3D9() {

bool ResolveD3D11() {
static const auto loaded = [] {
const auto d3d11 = SafeLoadLibrary(L"d3d11.dll");
const auto d3d11 = LoadLibrary(L"d3d11.dll");
return true
&& LOAD_SYMBOL(d3d11, D3D11CreateDevice);
}();
Expand All @@ -85,7 +80,7 @@ bool ResolveD3D11() {

bool ResolveDXGI() {
static const auto loaded = [&] {
const auto dxgi = SafeLoadLibrary(L"dxgi.dll");
const auto dxgi = LoadLibrary(L"dxgi.dll");
LOAD_SYMBOL(dxgi, CreateDXGIFactory1);
return true
&& LOAD_SYMBOL(dxgi, CreateDXGIFactory);
Expand Down

0 comments on commit d13a57d

Please sign in to comment.