/// <summary> /// Loads the specified module as a data file. /// </summary> /// <param name="fileName"> /// A string that specifies the file name of the module to load. /// </param> /// <returns> /// A <see cref="SafeModuleHandle"/> to the loaded module. The handle /// can only be used to extract messages or resources. You cannot call /// functions like <c>GetProcAddress</c> with it. /// </returns> /// <remarks> /// Maps the file into the calling process's virtual address space as /// if it were a data file. Nothing is done to execute or prepare to /// execute the mapped file. The loader does not load the static imports /// or perform the other usual initialization steps. Use this flag /// when you want to load a DLL only to extract messages or resources /// from it. /// </remarks> public static SafeModuleHandle LoadImageResource(string fileName) { const LoadLibraryExFlags ImageResourceFlags = LoadLibraryExFlags.AsImageResource | LoadLibraryExFlags.AsDatafile; return(Load(fileName, ImageResourceFlags)); }
public static SafeModuleHandle LoadImageResource(string fileName) { const LoadLibraryExFlags ImageResourceFlags = LoadLibraryExFlags.LOAD_LIBRARY_AS_IMAGE_RESOURCE | LoadLibraryExFlags.LOAD_LIBRARY_AS_DATAFILE; return(Load(fileName, ImageResourceFlags)); }
/// <summary> /// Loads the specified module. /// </summary> /// <param name="fileName"> /// A string that specifies the file name of the module to load. /// </param> /// <param name="flags"> /// The action to be taken when loading the module. /// </param> /// <returns> /// A <see cref="SafeModuleHandle"/> to the loaded module. /// </returns> public static SafeModuleHandle Load(string fileName, LoadLibraryExFlags flags = 0) { SafeModuleHandle handle = ResourceUnsafeNativeMethods.LoadLibraryEx( fileName, IntPtr.Zero, flags); if (handle.IsInvalid) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } return(handle); }
internal static IntPtr LoadLibraryEx_Hooked( String lpFileName, IntPtr hFile, LoadLibraryExFlags dwFlags ) { return(new HookContext <IntPtr>( func => ((LoadLibraryEx_Delegate)func)(lpFileName, hFile, dwFlags), helper => { DoAccessLogging(helper.HookHolderAndCallback, lpFileName); return LoadLibraryEx(lpFileName, hFile, dwFlags); }, errorCode => { SetLastError(unchecked ((uint)errorCode)); return IntPtr.Zero; }, HookLogging.NoLogging, "").Call()); }
/// <summary> /// The LoadLibraryEx function maps the specified executable module into the /// address space of the calling process. The executable module can be a .dll /// or an .exe file. The specified module may cause other modules to be mapped /// into the address space /// </summary> /// <param name="lpfFileName">Pointer to a null-terminated string that names /// the executable module (either a .dll or an .exe file). The name specified /// is the file name of the executable module. This name is not related to the /// name stored in a library module itself, as specified by the LIBRARY keyword /// in the module-definition (.def) file. If the string specifies a path, but /// the file does not exist in the specified directory, the function fails. When /// specifying a path, be sure to use backslashes (\), not forward slashes (/). /// If the string does not specify a path, and the file name extension is omitted, /// the function appends the default library extension .dll to the file name. /// However, the file name string can include a trailing point character (.) to /// indicate that the module name has no extension. If the string does not specify /// a path, the function uses a standard search strategy to find the file. If /// mapping the specified module into the address space causes the system to map /// in other, associated executable modules, the function can use either the /// standard search strategy or an alternate search strategy to find those modules.</param> /// <param name="flags">Action to take when loading the module. If no flags are /// specified, the behavior of this function is identical to that of the LoadLibrary /// function. This parameter can be one of the LoadLibraryExFlags values</param> /// <returns>If the function succeeds, the return value is a handle to the mapped /// executable module. If the function fails, the return value is NULL.</returns> public static IntPtr LoadLibraryEx(string lpfFileName, LoadLibraryExFlags flags) { return NativeMethods.InternalLoadLibraryEx(lpfFileName, IntPtr.Zero, (int)flags); }
/// <summary> /// The LoadLibraryEx function maps the specified executable module into the /// address space of the calling process. The executable module can be a .dll /// or an .exe file. The specified module may cause other modules to be mapped /// into the address space /// </summary> /// <param name="lpfFileName">Pointer to a null-terminated string that names /// the executable module (either a .dll or an .exe file). The name specified /// is the file name of the executable module. This name is not related to the /// name stored in a library module itself, as specified by the LIBRARY keyword /// in the module-definition (.def) file. If the string specifies a path, but /// the file does not exist in the specified directory, the function fails. When /// specifying a path, be sure to use backslashes (\), not forward slashes (/). /// If the string does not specify a path, and the file name extension is omitted, /// the function appends the default library extension .dll to the file name. /// However, the file name string can include a trailing point character (.) to /// indicate that the module name has no extension. If the string does not specify /// a path, the function uses a standard search strategy to find the file. If /// mapping the specified module into the address space causes the system to map /// in other, associated executable modules, the function can use either the /// standard search strategy or an alternate search strategy to find those modules.</param> /// <param name="flags">Action to take when loading the module. If no flags are /// specified, the behavior of this function is identical to that of the LoadLibrary /// function. This parameter can be one of the LoadLibraryExFlags values</param> /// <returns>If the function succeeds, the return value is a handle to the mapped /// executable module. If the function fails, the return value is NULL.</returns> public static IntPtr LoadLibraryEx(string lpfFileName, LoadLibraryExFlags flags) { return(NativeMethods.InternalLoadLibraryEx(lpfFileName, IntPtr.Zero, (int)flags)); }
private extern static IntPtr LoadLibraryEx( string lpLibFileName, IntPtr hFile, [MarshalAs(UnmanagedType.U4)] LoadLibraryExFlags dwFlags);
public static extern IntPtr LoadLibraryEx( [MarshalAs(UnmanagedType.LPWStr)] string lpFileName, IntPtr hFile, LoadLibraryExFlags dwFlags);
internal static extern IntPtr LoadLibraryEx(string filename, IntPtr reserved, LoadLibraryExFlags flags);
private static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hFile, LoadLibraryExFlags dwFlags);
public static extern Ookii.Dialogs.SafeModuleHandle LoadLibraryEx( string lpFileName, IntPtr hFile, LoadLibraryExFlags dwFlags );
public static extern IntPtr LoadLibraryEx(String lpFilename, IntPtr hFile, LoadLibraryExFlags dwFlags);
public static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hReservedNull, LoadLibraryExFlags dwFlags);
internal static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hFile_Reserved, LoadLibraryExFlags flags);
public static extern SafeModuleHandle LoadLibraryEx( string lpFileName, IntPtr hFile, [MarshalAs(UnmanagedType.U4)] LoadLibraryExFlags dwFlags);
public static extern TylorsTech.HandyClasses.WPF.Dialogs.SafeModuleHandle LoadLibraryEx( string lpFileName, IntPtr hFile, LoadLibraryExFlags dwFlags );
internal static extern IntPtr LoadLibraryEx(string fileName, IntPtr hFile, LoadLibraryExFlags dwFlags);
internal static extern SafeLibraryHandle LoadLibraryEx(string fileName, IntPtr reserved, LoadLibraryExFlags flags);
public static extern CrystalLib.Toolset.Dialogs.SafeModuleHandle LoadLibraryEx( string lpFileName, IntPtr hFile, LoadLibraryExFlags dwFlags );
public static extern Ookii.Dialogs.Wpf.SafeModuleHandle LoadLibraryEx( string lpFileName, IntPtr hFile, LoadLibraryExFlags dwFlags );
public static SafeModuleHandle Load(string fileName, LoadLibraryExFlags flags = 0) { return(UnsafeNativeMethods.LoadLibraryEx(fileName, IntPtr.Zero, flags)); }
public static extern SafeModuleHandle LoadLibraryEx( string lpFileName, IntPtr hFile, LoadLibraryExFlags dwFlags );