Skip to content
This repository was archived by the owner on Jul 26, 2023. It is now read-only.

Commit 76d2d9f

Browse files
author
pr-autocomplete[bot]
authored
Merge pull request #567 from dotnet/fix563
Fix `GetModuleHandle` so its use doesn't prematurely unload a module
2 parents d91801e + 768eb8f commit 76d2d9f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Kernel32/PublicAPI.Shipped.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ static extern PInvoke.Kernel32.GetDllDirectory(int nBufferLength, char* lpBuffer
13201320
static extern PInvoke.Kernel32.GetExitCodeProcess(System.IntPtr hProcess, out int lpExitCode) -> bool
13211321
static extern PInvoke.Kernel32.GetExitCodeThread(System.IntPtr hThread, out int lpExitCode) -> bool
13221322
static extern PInvoke.Kernel32.GetLargestConsoleWindowSize(System.IntPtr hConsoleOutput) -> PInvoke.COORD
1323-
static extern PInvoke.Kernel32.GetModuleHandle(string lpModuleName) -> PInvoke.Kernel32.SafeLibraryHandle
1323+
static extern PInvoke.Kernel32.GetModuleHandle(string lpModuleName) -> System.IntPtr
13241324
static extern PInvoke.Kernel32.GetModuleHandleEx(PInvoke.Kernel32.GetModuleHandleExFlags dwFlags, string lpModuleName, out PInvoke.Kernel32.SafeLibraryHandle phModule) -> bool
13251325
static extern PInvoke.Kernel32.GetNamedPipeClientComputerName(PInvoke.Kernel32.SafeObjectHandle Pipe, System.Text.StringBuilder ClientComputerName, int ClientComputerNameLength) -> bool
13261326
static extern PInvoke.Kernel32.GetNamedPipeClientComputerName(PInvoke.Kernel32.SafeObjectHandle Pipe, char* ClientComputerName, int ClientComputerNameLength) -> bool

src/Kernel32/storebanned/Kernel32.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ public static unsafe extern bool GetDllDirectory(
13521352
/// Therefore, do not pass a handle returned by this function to the <see cref="FreeLibrary"/> function. Doing so can cause a DLL module to be unmapped prematurely.
13531353
/// </remarks>
13541354
[DllImport(nameof(Kernel32), SetLastError = true, CharSet = CharSet.Unicode)]
1355-
public static extern SafeLibraryHandle GetModuleHandle(string lpModuleName);
1355+
public static extern IntPtr GetModuleHandle(string lpModuleName);
13561356

13571357
/// <summary>
13581358
/// Retrieves a module handle for the specified module and increments the module's reference count unless <see cref="GetModuleHandleExFlags.GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT"/> is specified.

0 commit comments

Comments
 (0)