diff options
Diffstat (limited to 'src/inc/clr/win32.h')
-rw-r--r-- | src/inc/clr/win32.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/inc/clr/win32.h b/src/inc/clr/win32.h new file mode 100644 index 0000000000..a0e00c6321 --- /dev/null +++ b/src/inc/clr/win32.h @@ -0,0 +1,38 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// +// clr/win32.h +// +// Provides Win32-specific utility functionality. +// + +// + +#ifndef clr_win32_h +#define clr_win32_h + +#include "winwrap.h" + +namespace clr +{ + namespace win32 + { + // Prevents an HMODULE from being unloaded until process termination. + inline + HRESULT PreventModuleUnload(HMODULE hMod) + { + if (!WszGetModuleHandleEx( + GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN, + reinterpret_cast<LPCTSTR>(hMod), + &hMod)) + { + return HRESULT_FROM_GetLastError(); + } + + return S_OK; + } + } // namespace win +} // namespace clr + +#endif // clr_win32_h |