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

Fix GetModuleHandle so its use doesn't prematurely unload a module #567

Merged
1 commit merged into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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