|
21 | 21 | import atexit |
22 | 22 | import sys |
23 | 23 | import ctypes |
| 24 | +import json |
24 | 25 | from time import gmtime, struct_time |
25 | 26 | import os |
26 | | -from typing import Mapping, Optional |
| 27 | +from typing import Any, List, Mapping, Optional |
27 | 28 | import functools |
28 | 29 |
|
29 | 30 | # Binary Ninja components |
@@ -373,6 +374,36 @@ def core_license_count() -> int: |
373 | 374 | return core.BNGetLicenseCount() |
374 | 375 |
|
375 | 376 |
|
| 377 | +def core_license_addons() -> List[str]: |
| 378 | + '''License addons from the license file''' |
| 379 | + _init_plugins() |
| 380 | + count = ctypes.c_ulonglong() |
| 381 | + addons = core.BNGetLicenseAddons(ctypes.byref(count)) |
| 382 | + if not addons: |
| 383 | + return [] |
| 384 | + result = [core.pyNativeStr(addons[i]) for i in range(count.value)] |
| 385 | + core.BNFreeStringList(addons, count.value) |
| 386 | + return result |
| 387 | + |
| 388 | + |
| 389 | +def core_license_addons_json() -> str: |
| 390 | + '''Structured license addons JSON from the license file''' |
| 391 | + _init_plugins() |
| 392 | + return core.BNGetLicenseAddonsJson() |
| 393 | + |
| 394 | + |
| 395 | +def core_license_addon_data() -> List[Mapping[str, Any]]: |
| 396 | + '''Structured license addons from the license file''' |
| 397 | + return json.loads(core_license_addons_json()) |
| 398 | + |
| 399 | + |
| 400 | +def core_license_user_id() -> Optional[int]: |
| 401 | + '''License user id from the license file''' |
| 402 | + _init_plugins() |
| 403 | + uid = core.BNGetLicenseUserId() |
| 404 | + return int(uid) if uid else None |
| 405 | + |
| 406 | + |
376 | 407 | def core_ui_enabled() -> bool: |
377 | 408 | '''Indicates that a UI exists and the UI has invoked BNInitUI''' |
378 | 409 | return core.BNIsUIEnabled() |
|
0 commit comments