Skip to content

Commit

Permalink
Fix safety comment for LibraryHandle::get_proc_address (#1010)
Browse files Browse the repository at this point in the history
  • Loading branch information
NobodyXu committed Mar 15, 2024
1 parent abf67d7 commit 77a54a9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/windows/find_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,13 @@ mod impl_ {
}

/// Get a function pointer to a function in the library.
/// SAFETY: The caller must ensure that the function signature matches the actual function.
/// # SAFETY
///
/// The caller must ensure that the function signature matches the actual function.
/// The easiest way to do this is to add an entry to windows_sys_no_link.list and use the
/// generated function for `func_signature`.
///
/// The function returned cannot be used after the handle is dropped.
unsafe fn get_proc_address<F>(&self, name: &[u8]) -> Option<F> {
let symbol = unsafe { GetProcAddress(self.0, name.as_ptr() as _) };
symbol.map(|symbol| unsafe { mem::transmute_copy(&symbol) })
Expand Down

0 comments on commit 77a54a9

Please sign in to comment.