/// <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));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 4
0
 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());
 }
Exemplo n.º 5
0
 /// <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);
 }
Exemplo n.º 6
0
 /// <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));
 }
Exemplo n.º 7
0
 private extern static IntPtr LoadLibraryEx(
     string lpLibFileName,
     IntPtr hFile,
     [MarshalAs(UnmanagedType.U4)] LoadLibraryExFlags dwFlags);
Exemplo n.º 8
0
 public static extern IntPtr LoadLibraryEx(
     [MarshalAs(UnmanagedType.LPWStr)]
     string lpFileName,
     IntPtr hFile,
     LoadLibraryExFlags dwFlags);
Exemplo n.º 9
0
 internal static extern IntPtr LoadLibraryEx(string filename, IntPtr reserved, LoadLibraryExFlags flags);
Exemplo n.º 10
0
 private static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hFile, LoadLibraryExFlags dwFlags);
Exemplo n.º 11
0
 public static extern Ookii.Dialogs.SafeModuleHandle LoadLibraryEx(
     string lpFileName,
     IntPtr hFile,
     LoadLibraryExFlags dwFlags
     );
Exemplo n.º 12
0
 public static extern IntPtr LoadLibraryEx(String lpFilename, IntPtr hFile, LoadLibraryExFlags dwFlags);
Exemplo n.º 13
0
 public static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hReservedNull, LoadLibraryExFlags dwFlags);
Exemplo n.º 14
0
 private static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hFile, LoadLibraryExFlags dwFlags);
Exemplo n.º 15
0
 internal static extern IntPtr LoadLibraryEx(string lpFileName,
                                             IntPtr hFile_Reserved,
                                             LoadLibraryExFlags flags);
Exemplo n.º 16
0
 public static extern SafeModuleHandle LoadLibraryEx(
     string lpFileName, IntPtr hFile, [MarshalAs(UnmanagedType.U4)] LoadLibraryExFlags dwFlags);
Exemplo n.º 17
0
 public static extern TylorsTech.HandyClasses.WPF.Dialogs.SafeModuleHandle LoadLibraryEx(
     string lpFileName,
     IntPtr hFile,
     LoadLibraryExFlags dwFlags
     );
Exemplo n.º 18
0
 public static extern IntPtr LoadLibraryEx(
     [MarshalAs(UnmanagedType.LPWStr)]
     string lpFileName,
     IntPtr hFile,
     LoadLibraryExFlags dwFlags);
Exemplo n.º 19
0
 internal static extern IntPtr LoadLibraryEx(string fileName, IntPtr hFile, LoadLibraryExFlags dwFlags);
Exemplo n.º 20
0
 internal static extern SafeLibraryHandle LoadLibraryEx(string fileName, IntPtr reserved, LoadLibraryExFlags flags);
Exemplo n.º 21
0
 public static extern CrystalLib.Toolset.Dialogs.SafeModuleHandle LoadLibraryEx(
     string lpFileName,
     IntPtr hFile,
     LoadLibraryExFlags dwFlags
     );
Exemplo n.º 22
0
 public static extern Ookii.Dialogs.Wpf.SafeModuleHandle LoadLibraryEx(
     string lpFileName,
     IntPtr hFile,
     LoadLibraryExFlags dwFlags
     );
Exemplo n.º 23
0
 public static SafeModuleHandle Load(string fileName, LoadLibraryExFlags flags = 0)
 {
     return(UnsafeNativeMethods.LoadLibraryEx(fileName, IntPtr.Zero, flags));
 }
Exemplo n.º 24
0
 public static extern SafeModuleHandle LoadLibraryEx(
     string lpFileName,
     IntPtr hFile,
     LoadLibraryExFlags dwFlags
     );
Exemplo n.º 25
0
 internal static extern SafeLibraryHandle LoadLibraryEx(string fileName, IntPtr reserved, LoadLibraryExFlags flags);