Struct libloading::os::windows::Library[−][src]

pub struct Library(_);
This is supported on Windows only.

A platform-specific counterpart of the cross-platform Library.

Implementations

impl Library[src]

pub unsafe fn new<P: AsRef<OsStr>>(filename: P) -> Result<Library, Error>[src]

Find and load a module.

If the filename specifies a full path, the function only searches that path for the module. Otherwise, if the filename specifies a relative path or a module name without a path, the function uses a windows-specific search strategy to find the module; for more information, see the Remarks on MSDN.

If the filename specifies a library filename without path and with extension omitted, .dll extension is implicitly added. This behaviour may be suppressed by appending a trailing . to the filename.

This is equivalent to Library::load_with_flags(filename, 0).

Safety

When a library is loaded initialization routines contained within the library are executed. For the purposes of safety, execution of these routines is conceptually the same calling an unknown foreign function and may impose arbitrary requirements on the caller for the call to be sound.

Additionally, the callers of this function must also ensure that execution of the termination routines contained within the library is safe as well. These routines may be executed when the library is unloaded.

pub fn this() -> Result<Library, Error>[src]

Get the Library representing the original program executable.

Note that behaviour of Library loaded with this method is different from Libraries loaded with os::unix::Library::this. For more information refer to MSDN.

Corresponds to GetModuleHandleExW(0, NULL, _).

pub fn open_already_loaded<P: AsRef<OsStr>>(
    filename: P
) -> Result<Library, Error>
[src]

Get a module that is already loaded by the program.

This function returns a Library corresponding to a module with the given name that is already mapped into the address space of the process. If the module isn't found an error is returned.

If the filename does not include a full path and there are multiple different loaded modules corresponding to the filename, it is impossible to predict which module handle will be returned. For more information refer to MSDN.

If the filename specifies a library filename without path and with extension omitted, .dll extension is implicitly added. This behaviour may be suppressed by appending a trailing . to the filename.

This is equivalent to GetModuleHandleExW(0, filename, _).

pub unsafe fn load_with_flags<P: AsRef<OsStr>>(
    filename: P,
    flags: DWORD
) -> Result<Library, Error>
[src]

Find and load a module, additionally adjusting behaviour with flags.

See Library::new for documentation on handling of the filename argument. See the flag table on MSDN for information on applicable values for the flags argument.

Corresponds to LoadLibraryExW(filename, reserved: NULL, flags).

Safety

When a library is loaded initialization routines contained within the library are executed. For the purposes of safety, execution of these routines is conceptually the same calling an unknown foreign function and may impose arbitrary requirements on the caller for the call to be sound.

Additionally, the callers of this function must also ensure that execution of the termination routines contained within the library is safe as well. These routines may be executed when the library is unloaded.

pub unsafe fn get<T>(&self, symbol: &[u8]) -> Result<Symbol<T>, Error>[src]

Get a pointer to function or static variable by symbol name.

The symbol may not contain any null bytes, with an exception of last byte. A null terminated symbol may avoid a string allocation in some cases.

Symbol is interpreted as-is; no mangling is done. This means that symbols like x::y are most likely invalid.

Safety

Users of this API must specify the correct type of the function or variable loaded. Using a Symbol with a wrong type is undefined.

pub unsafe fn get_ordinal<T>(&self, ordinal: WORD) -> Result<Symbol<T>, Error>[src]

Get a pointer to function or static variable by ordinal number.

Safety

Users of this API must specify the correct type of the function or variable loaded. Using a Symbol with a wrong type is undefined.

pub fn into_raw(self) -> HMODULE[src]

Convert the Library to a raw handle.

pub unsafe fn from_raw(handle: HMODULE) -> Library[src]

Convert a raw handle to a Library.

Safety

The handle shall be a result of a successful call of LoadLibraryA, LoadLibraryW, LoadLibraryExW, LoadLibraryExA or a handle previously returned by the Library::into_raw call.

pub fn close(self) -> Result<(), Error>[src]

Unload the library.

You only need to call this if you are interested in handling any errors that may arise when library is unloaded. Otherwise this will be done when Library is dropped.

The underlying data structures may still get leaked if an error does occur.

Trait Implementations

impl Debug for Library[src]

impl Drop for Library[src]

impl From<Library> for Library[src]

impl From<Library> for Library[src]

impl Send for Library[src]

impl Sync for Library[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.