1- use crate :: cache:: container:: cached_containers;
1+ use crate :: cache:: container:: { add_cached_container, cached_container_by_name, cached_containers} ;
2+ use crate :: container:: disk:: DiskContainer ;
23use crate :: container:: {
34 ContainerSearchItem , ContainerSearchItemKind , ContainerSearchQuery , SourcePath , SourceTag ,
45} ;
@@ -12,6 +13,7 @@ use binaryninja::rc::Ref;
1213use binaryninja:: string:: BnString ;
1314use binaryninja:: types:: Type ;
1415use binaryninjacore_sys:: { BNArchitecture , BNBinaryView , BNType } ;
16+ use std:: collections:: HashMap ;
1517use std:: ffi:: { c_char, CStr } ;
1618use std:: mem:: ManuallyDrop ;
1719use std:: ops:: Deref ;
@@ -172,6 +174,21 @@ pub unsafe extern "C" fn BNWARPContainerSearchItemGetFunction(
172174 }
173175}
174176
177+ #[ no_mangle]
178+ pub unsafe extern "C" fn BNWARPAddContainer ( name : * const c_char ) -> * mut BNWARPContainer {
179+ let name_cstr = unsafe { CStr :: from_ptr ( name) } ;
180+ let name_str = name_cstr. to_str ( ) . unwrap ( ) ;
181+ // TODO: Using this generic API name for disk container, I think anything like the network container
182+ // TODO: should probably be a second class name so something like BNWARPAddNetworkContainer.
183+ let disk_container = DiskContainer :: new ( name_str. to_string ( ) , HashMap :: new ( ) ) ;
184+ let container_name = disk_container. to_string ( ) ;
185+ add_cached_container ( disk_container) ;
186+ match cached_container_by_name ( & container_name) {
187+ Some ( container) => Arc :: into_raw ( container) as * mut BNWARPContainer ,
188+ None => std:: ptr:: null_mut ( ) ,
189+ }
190+ }
191+
175192#[ no_mangle]
176193pub unsafe extern "C" fn BNWARPGetContainers ( count : * mut usize ) -> * mut * mut BNWARPContainer {
177194 // NOTE: Leak the arc pointers to be freed by BNWARPFreeContainerList
0 commit comments