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

Commit

Permalink
Merge pull request #567 from dotnet/fix563
Browse files Browse the repository at this point in the history
Fix `GetModuleHandle` so its use doesn't prematurely unload a module
  • Loading branch information
pr-autocomplete[bot] authored Jan 22, 2021
2 parents d91801e + 768eb8f commit 76d2d9f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Kernel32/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ static extern PInvoke.Kernel32.GetDllDirectory(int nBufferLength, char* lpBuffer
static extern PInvoke.Kernel32.GetExitCodeProcess(System.IntPtr hProcess, out int lpExitCode) -> bool
static extern PInvoke.Kernel32.GetExitCodeThread(System.IntPtr hThread, out int lpExitCode) -> bool
static extern PInvoke.Kernel32.GetLargestConsoleWindowSize(System.IntPtr hConsoleOutput) -> PInvoke.COORD
static extern PInvoke.Kernel32.GetModuleHandle(string lpModuleName) -> PInvoke.Kernel32.SafeLibraryHandle
static extern PInvoke.Kernel32.GetModuleHandle(string lpModuleName) -> System.IntPtr
static extern PInvoke.Kernel32.GetModuleHandleEx(PInvoke.Kernel32.GetModuleHandleExFlags dwFlags, string lpModuleName, out PInvoke.Kernel32.SafeLibraryHandle phModule) -> bool
static extern PInvoke.Kernel32.GetNamedPipeClientComputerName(PInvoke.Kernel32.SafeObjectHandle Pipe, System.Text.StringBuilder ClientComputerName, int ClientComputerNameLength) -> bool
static extern PInvoke.Kernel32.GetNamedPipeClientComputerName(PInvoke.Kernel32.SafeObjectHandle Pipe, char* ClientComputerName, int ClientComputerNameLength) -> bool
Expand Down
2 changes: 1 addition & 1 deletion src/Kernel32/storebanned/Kernel32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@ public static unsafe extern bool GetDllDirectory(
/// 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.
/// </remarks>
[DllImport(nameof(Kernel32), SetLastError = true, CharSet = CharSet.Unicode)]
public static extern SafeLibraryHandle GetModuleHandle(string lpModuleName);
public static extern IntPtr GetModuleHandle(string lpModuleName);

/// <summary>
/// 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.
Expand Down

0 comments on commit 76d2d9f

Please sign in to comment.