in src/VSSetup.PowerShell/NativeMethods.cs [41:78]
public static extern int GetModuleFileName(
SafeModuleHandle hModule,
[Out] StringBuilder lpFilename,
[MarshalAs(UnmanagedType.U4)] int nSize);
/// <summary>
/// Gets a handle to the module given the module name.
/// </summary>
/// <param name="dwFlags">The <see cref="GetModuleHandleExFlags"/> for the call.</param>
/// <param name="lpModuleName">The name of the module or pointer to a function within the module.</param>
/// <param name="phModule">A handle to the module.</param>
/// <returns>True if the function succeeds; otherwise, false and <see cref="Marshal.GetLastWin32Error"/> will contain the reason.</returns>
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, EntryPoint = "GetModuleHandleExW", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetModuleHandleEx(
[MarshalAs(UnmanagedType.U4)] GetModuleHandleExFlags dwFlags,
IntPtr lpModuleName,
out SafeModuleHandle phModule);
/// <summary>
/// Frees the module given its handle.
/// </summary>
/// <param name="hModule">The handle to the module to free.</param>
/// <returns>True if the function succeeds; otherwise, false and <see cref="Marshal.GetLastWin32Error"/> will contain the reason.</returns>
[DllImport("kernel32.dll", ExactSpelling = true, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool FreeLibrary(
IntPtr hModule);
}
#pragma warning disable SA1201 // Elements must appear in the correct order
/// <summary>
/// Flags for <see cref="GetModuleHandleEx(GetModuleHandleExFlags, IntPtr, out SafeHandle)"/>.
/// </summary>
[Flags]
public enum GetModuleHandleExFlags
{