File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -272,6 +272,27 @@ string BinaryNinja::GetSerialNumber()
272272}
273273
274274
275+ string BinaryNinja::GetLicenseUserId ()
276+ {
277+ char * str = BNGetLicenseUserId ();
278+ string result = str;
279+ BNFreeString (str);
280+ return result;
281+ }
282+
283+
284+ vector<string> BinaryNinja::GetLicenseAddons ()
285+ {
286+ size_t count = 0 ;
287+ char ** addons = BNGetLicenseAddons (&count);
288+ vector<string> result;
289+ for (size_t i = 0 ; i < count; i++)
290+ result.emplace_back (addons[i]);
291+ BNFreeStringList (addons, count);
292+ return result;
293+ }
294+
295+
275296int BinaryNinja::GetLicenseCount ()
276297{
277298 return BNGetLicenseCount ();
Original file line number Diff line number Diff line change @@ -2027,6 +2027,8 @@ namespace BinaryNinja {
20272027 std::string GetProduct();
20282028 std::string GetProductType();
20292029 std::string GetSerialNumber();
2030+ std::string GetLicenseUserId();
2031+ std::vector<std::string> GetLicenseAddons();
20302032 int GetLicenseCount();
20312033 bool IsUIEnabled();
20322034 uint32_t GetBuildId();
Original file line number Diff line number Diff line change @@ -4072,6 +4072,8 @@ extern "C"
40724072 BINARYNINJACOREAPI char* BNGetLicensedUserEmail(void);
40734073 BINARYNINJACOREAPI char* BNGetProduct(void);
40744074 BINARYNINJACOREAPI char* BNGetProductType(void);
4075+ BINARYNINJACOREAPI char* BNGetLicenseUserId(void);
4076+ BINARYNINJACOREAPI char** BNGetLicenseAddons(size_t* count);
40754077 BINARYNINJACOREAPI int BNGetLicenseCount(void);
40764078 BINARYNINJACOREAPI bool BNIsUIEnabled(void);
40774079 BINARYNINJACOREAPI void BNSetLicense(const char* licenseData);
Original file line number Diff line number Diff line change 2323import ctypes
2424from time import gmtime , struct_time
2525import os
26- from typing import Mapping , Optional
26+ from typing import List , Mapping , Optional
2727import functools
2828
2929# Binary Ninja components
@@ -373,6 +373,19 @@ def core_license_count() -> int:
373373 return core .BNGetLicenseCount ()
374374
375375
376+ def core_license_addons () -> List [str ]:
377+ '''License addons from the license file'''
378+ _init_plugins ()
379+ return core .BNGetLicenseAddons ()
380+
381+
382+ def core_license_user_id () -> Optional [int ]:
383+ '''License user id from the license file'''
384+ _init_plugins ()
385+ uid = core .BNGetLicenseUserId ()
386+ return int (uid ) if uid else None
387+
388+
376389def core_ui_enabled () -> bool :
377390 '''Indicates that a UI exists and the UI has invoked BNInitUI'''
378391 return core .BNIsUIEnabled ()
Original file line number Diff line number Diff line change @@ -540,6 +540,30 @@ pub fn license_count() -> i32 {
540540 unsafe { BNGetLicenseCount ( ) }
541541}
542542
543+ pub fn license_addons ( ) -> Vec < String > {
544+ let mut count = 0 ;
545+ let addons = unsafe { BNGetLicenseAddons ( & mut count) } ;
546+ if addons. is_null ( ) {
547+ return Vec :: new ( ) ;
548+ }
549+
550+ let result = unsafe { std:: slice:: from_raw_parts ( addons, count) }
551+ . iter ( )
552+ . map ( |addon| unsafe { CStr :: from_ptr ( * addon) . to_string_lossy ( ) . into_owned ( ) } )
553+ . collect ( ) ;
554+ unsafe { BNFreeStringList ( addons, count) } ;
555+ result
556+ }
557+
558+ pub fn license_user_id ( ) -> Option < String > {
559+ let uid = unsafe { BnString :: into_string ( BNGetLicenseUserId ( ) ) } ;
560+ if uid. is_empty ( ) {
561+ None
562+ } else {
563+ Some ( uid)
564+ }
565+ }
566+
543567/// Set the license that will be used once the core initializes. You can reset the license by passing `None`.
544568///
545569/// If not set, the normal license retrieval will occur:
You can’t perform that action at this time.
0 commit comments