Host

The interface exposes an API to query information about the host on which LIEF is running. It provides a cross-platform API for common values like the hostname and standard user directories (home, cache, …). Platform-specific information is provided within their own namespace/module.

Cross-platform

The following snippet illustrates how to retrieve the generic host information that is available on every supported platform:

print(f"    Hostname:    {lief.runtime.Host.name}")
print(f"    Home:        {lief.runtime.Host.home_dir}")
print(f"    cache:       {lief.runtime.Host.cache_dir}")
print(f"    temp:        {lief.runtime.Host.tmp_dir}")
print(f"    config:      {lief.runtime.Host.config_dir}")

Linux

print(f"    sys_name:    {lief.runtime.linux.Host.sys_name}")
print(f"    sys_release: {lief.runtime.linux.Host.sys_release}")
print(f"    sys_version: {lief.runtime.linux.Host.sys_version}")
print(f"    hardware:    {lief.runtime.linux.Host.hardware}")

Windows

print(f"    Version:  {lief.runtime.windows.Host.version}")

OSX

print(f"    Version:  {lief.runtime.osx.Host.os_version_name}")
sip = "enabled" if lief.runtime.osx.Host.is_sip_enabled else "disabled"
print(f"    SIP:      {sip}")

Android

if (sdk := lief.runtime.android.Host.sdk_version) is not None:
    print(f"    SDK:         {sdk}")