#[macro_export]
macro_rules! nsis_plugin {
() => {
$crate::__nsis_dllmain!(DllMainCRTStartup);
#[cfg(target_os = "windows")]
#[panic_handler]
fn __nsis_panic(_info: &::core::panic::PanicInfo) -> ! {
$crate::rt::abort()
}
#[cfg(target_os = "windows")]
#[global_allocator]
static __NSIS_ALLOCATOR: $crate::rt::NsisAllocator = $crate::rt::NsisAllocator;
$crate::__nsis_unwind_stubs!();
};
(std) => {
$crate::__nsis_dllmain!(DllMain);
#[cfg(all(target_os = "windows", target_env = "gnu", target_arch = "x86"))]
#[unsafe(no_mangle)]
extern "C" fn _Unwind_Resume() -> ! {
$crate::rt::unwind_unreachable()
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __nsis_unwind_stubs {
() => {
#[cfg(target_os = "windows")]
#[unsafe(no_mangle)]
extern "C" fn rust_eh_personality() {}
#[cfg(all(target_os = "windows", target_env = "msvc"))]
#[unsafe(no_mangle)]
extern "C" fn __CxxFrameHandler3() -> ! {
$crate::rt::unwind_unreachable()
}
#[cfg(all(target_os = "windows", target_env = "gnu"))]
#[unsafe(no_mangle)]
extern "C" fn _Unwind_Resume() -> ! {
$crate::rt::unwind_unreachable()
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __nsis_dllmain {
($entry:ident) => {
#[cfg(target_os = "windows")]
#[unsafe(no_mangle)]
pub extern "system" fn $entry(
hinst: *mut ::core::ffi::c_void,
reason: u32,
_reserved: *mut ::core::ffi::c_void,
) -> i32 {
const DLL_PROCESS_ATTACH: u32 = 1;
if reason == DLL_PROCESS_ATTACH {
$crate::rt::set_hinstance(hinst);
}
1
}
};
}
#[macro_export]
macro_rules! nsis_fn {
($(
$(#[$attr:meta])*
fn $name:ident($nsis:ident: &mut Nsis) -> Result<()> $body:block
)*) => {$(
$(#[$attr])*
#[unsafe(no_mangle)]
pub unsafe extern "C" fn $name(
hwnd: $crate::Hwnd,
string_size: ::core::ffi::c_int,
variables: *mut $crate::Tchar,
stacktop: *mut *mut $crate::StackNode,
extra: *mut $crate::ExtraParameters,
) {
fn __nsis_body($nsis: &mut Nsis) -> Result<()> $body
let mut nsis = unsafe {
$crate::Nsis::from_raw(hwnd, string_size, variables, stacktop, extra)
};
let outcome = __nsis_body(&mut nsis);
if outcome.is_err() {
nsis.set_error(true);
}
}
)*};
}
#[macro_export]
macro_rules! nsis_unload {
($(
$(#[$attr:meta])*
fn $name:ident() $body:block
)*) => {$(
$(#[$attr])*
///
/// Registered with `RegisterPluginCallback`; not a DLL export.
pub unsafe extern "C" fn $name(message: ::core::ffi::c_int) -> usize {
if message == $crate::NSPIM_UNLOAD {
fn __nsis_unload_body() $body
__nsis_unload_body();
}
0
}
)*};
}