diff --git a/src/bindings/squirrelfunctions.rs b/src/bindings/squirrelfunctions.rs index 5b22c42..31f8847 100644 --- a/src/bindings/squirrelfunctions.rs +++ b/src/bindings/squirrelfunctions.rs @@ -61,7 +61,7 @@ offset_functions! { sq_defconst = sq_defconstType where offset(0x12120); sq_compilebuffer = sq_compilebufferType where offset(0x3110); - sq_pushroottable = sq_pushroottableType where offset(0x5840); + sq_pushroottable = sq_pushroottableType where offset(0x5860); sq_call = sq_callType where offset(0x8650); sq_compilefile = sq_compilefileType where offset(0xF950); diff --git a/src/high/northstar.rs b/src/high/northstar.rs index efbf834..02b44c4 100644 --- a/src/high/northstar.rs +++ b/src/high/northstar.rs @@ -17,7 +17,25 @@ impl PluginInfo { dependency_name: &'static str, context: PluginContext, ) -> Self { - assert!(log_name.len() == 9, "log name is used for logging and ideally should be 9 chars long and all upercase to look like every other log str"); + assert!( + name.as_bytes()[name.len().saturating_sub(1)] == 0, + "name has to end with a null char to be a null terminated string" + ); + assert!( + log_name.as_bytes()[log_name.len().saturating_sub(1)] == 0, + "log_name has to end with a null char to be a null terminated string" + ); + assert!( + dependency_name.as_bytes()[dependency_name.len().saturating_sub(1)] == 0, + "dependency_name has to end with a null char to be a null terminated string" + ); + assert!(name.len() > 1, "consider actually having a name"); + assert!(log_name.len() > 1, "consider actually having a log_name"); + assert!( + dependency_name.len() > 1, + "consider actually having a dependency_name" + ); + assert!(log_name.len().saturating_sub(1) == 9, "log name is used for logging and ideally should be 9 chars long and all upercase to look like every other log str"); Self { name, log_name, diff --git a/src/interfaces/external.rs b/src/interfaces/external.rs index 61c5cac..df0b252 100644 --- a/src/interfaces/external.rs +++ b/src/interfaces/external.rs @@ -26,6 +26,7 @@ macro_rules! create_external_interface { } impl $crate::interfaces::external::SourceInterface for $interface_name { + #[inline] fn get_vtable(&self) -> core::ptr::NonNull { self.vtable } @@ -44,7 +45,10 @@ macro_rules! create_external_interface { $( $func_vis unsafe fn $name( &self, $($arg_name: $arg,)* ) -> $output { use $crate::interfaces::external::SourceInterface; - unsafe { (std::mem::transmute::<_,unsafe extern "C" fn($($arg),*) -> $output>(self.get_func($mod_name::Counter::$name as usize)))( $($arg_name),* ) } + use std::ffi::c_void; + unsafe { (std::mem::transmute::<_,unsafe extern "C" fn(*const c_void, $($arg),*) -> $output>(self.get_func($mod_name::Counter::$name as usize)))( + self as *const Self as *const c_void, $($arg_name),* + ) } } )* } @@ -54,6 +58,7 @@ macro_rules! create_external_interface { pub trait SourceInterface { fn get_vtable(&self) -> NonNull; + #[inline] fn get_func(&self, index: usize) -> fn() { unsafe { *self.get_vtable().as_ptr().add(index) } } diff --git a/src/macros/entry.rs b/src/macros/entry.rs index dde33b2..86dcc6c 100644 --- a/src/macros/entry.rs +++ b/src/macros/entry.rs @@ -13,7 +13,7 @@ /// /// impl Plugin for BasicPlugin { /// const PLUGIN_INFO: PluginInfo = -/// PluginInfo::new("test", "Testttttt", "test", PluginContext::all()); +/// PluginInfo::new("test\0", "Testttttt\0", "test\0", PluginContext::all()); /// /// fn new(reloaded: bool) -> Self { /// Self {} @@ -300,7 +300,7 @@ mod test_entry { impl Plugin for Test { const PLUGIN_INFO: PluginInfo = - PluginInfo::new("test", "Testttttt", "test", PluginContext::all()); + PluginInfo::new("test\0", "Testttttt\0", "test\0", PluginContext::all()); fn new(_reloaded: bool) -> Self { Self {}