From c01dc6af49c1123ed16b652676122d3b0c3f3585 Mon Sep 17 00:00:00 2001 From: Romain Thomas Date: Sun, 7 Jan 2024 10:11:57 +0100 Subject: [PATCH] Update PE's `ResourcesManager` --- api/python/lief/PE.pyi | 318 +------- api/python/src/PE/enums.cpp | 361 --------- api/python/src/PE/init.cpp | 2 + api/python/src/PE/objects/CMakeLists.txt | 1 + api/python/src/PE/objects/pyLang.cpp | 133 ++++ .../src/PE/objects/pyResourcesManager.cpp | 46 +- .../PE/objects/resources/pyLangCodeItem.cpp | 8 +- .../PE/objects/resources/pyResourceDialog.cpp | 8 +- .../PE/objects/resources/pyResourceIcon.cpp | 8 +- doc/sphinx/api/cpp/pe.rst | 9 - doc/sphinx/api/python/pe.rst | 28 +- doc/sphinx/changelog.rst | 3 + doc/sphinx/tutorials/07_pe_resource.rst | 15 +- include/LIEF/PE/EnumToString.hpp | 6 - include/LIEF/PE/ResourceNode.hpp | 3 +- include/LIEF/PE/ResourcesManager.hpp | 114 ++- include/LIEF/PE/enums.hpp | 726 ------------------ include/LIEF/PE/resources/LangCodeItem.hpp | 8 +- include/LIEF/PE/resources/ResourceDialog.hpp | 14 +- include/LIEF/PE/resources/ResourceIcon.hpp | 12 +- .../LIEF/PE/resources/ResourceVarFileInfo.hpp | 5 - include/LIEF/PE/resources/langs.hpp | 129 ++++ include/LIEF/PE/undef.h | 1 - src/PE/EnumToString.cpp | 375 --------- src/PE/ResourcesManager.cpp | 505 +++--------- src/PE/json.cpp | 4 +- src/PE/resources/LangCodeItem.cpp | 22 +- src/PE/resources/ResourceDialog.cpp | 22 +- src/PE/resources/ResourceIcon.cpp | 8 +- src/PE/resources/ResourceVarFileInfo.cpp | 9 +- tests/pe/test_resources.py | 18 +- 31 files changed, 605 insertions(+), 2316 deletions(-) create mode 100644 api/python/src/PE/objects/pyLang.cpp create mode 100644 include/LIEF/PE/resources/langs.hpp diff --git a/api/python/lief/PE.pyi b/api/python/lief/PE.pyi index cb6e32837a..e462de6158 100644 --- a/api/python/lief/PE.pyi +++ b/api/python/lief/PE.pyi @@ -1117,8 +1117,8 @@ class LangCodeItem(lief.Object): code_page: lief.PE.CODE_PAGES items: dict key: str - lang: lief.PE.RESOURCE_LANGS - sublang: lief.PE.RESOURCE_SUBLANGS + lang: int + sublang: int type: int def __init__(self, *args, **kwargs) -> None: ... @@ -1608,273 +1608,6 @@ class RESOURCE_LANGS: @property def value(self) -> int: ... -class RESOURCE_SUBLANGS: - AFRIKAANS_SOUTH_AFRICA: ClassVar[RESOURCE_SUBLANGS] = ... - ALBANIAN_ALBANIA: ClassVar[RESOURCE_SUBLANGS] = ... - ALSATIAN_FRANCE: ClassVar[RESOURCE_SUBLANGS] = ... - AMHARIC_ETHIOPIA: ClassVar[RESOURCE_SUBLANGS] = ... - ARABIC_ALGERIA: ClassVar[RESOURCE_SUBLANGS] = ... - ARABIC_BAHRAIN: ClassVar[RESOURCE_SUBLANGS] = ... - ARABIC_EGYPT: ClassVar[RESOURCE_SUBLANGS] = ... - ARABIC_IRAQ: ClassVar[RESOURCE_SUBLANGS] = ... - ARABIC_JORDAN: ClassVar[RESOURCE_SUBLANGS] = ... - ARABIC_KUWAIT: ClassVar[RESOURCE_SUBLANGS] = ... - ARABIC_LEBANON: ClassVar[RESOURCE_SUBLANGS] = ... - ARABIC_LIBYA: ClassVar[RESOURCE_SUBLANGS] = ... - ARABIC_MOROCCO: ClassVar[RESOURCE_SUBLANGS] = ... - ARABIC_OMAN: ClassVar[RESOURCE_SUBLANGS] = ... - ARABIC_QATAR: ClassVar[RESOURCE_SUBLANGS] = ... - ARABIC_SAUDI_ARABIA: ClassVar[RESOURCE_SUBLANGS] = ... - ARABIC_SYRIA: ClassVar[RESOURCE_SUBLANGS] = ... - ARABIC_TUNISIA: ClassVar[RESOURCE_SUBLANGS] = ... - ARABIC_UAE: ClassVar[RESOURCE_SUBLANGS] = ... - ARABIC_YEMEN: ClassVar[RESOURCE_SUBLANGS] = ... - ARMENIAN_ARMENIA: ClassVar[RESOURCE_SUBLANGS] = ... - ASSAMESE_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - AZERI_CYRILLIC: ClassVar[RESOURCE_SUBLANGS] = ... - AZERI_LATIN: ClassVar[RESOURCE_SUBLANGS] = ... - BANGLA_BANGLADESH: ClassVar[RESOURCE_SUBLANGS] = ... - BANGLA_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - BASHKIR_RUSSIA: ClassVar[RESOURCE_SUBLANGS] = ... - BASQUE_BASQUE: ClassVar[RESOURCE_SUBLANGS] = ... - BELARUSIAN_BELARUS: ClassVar[RESOURCE_SUBLANGS] = ... - BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC: ClassVar[RESOURCE_SUBLANGS] = ... - BOSNIAN_BOSNIA_HERZEGOVINA_LATIN: ClassVar[RESOURCE_SUBLANGS] = ... - BRETON_FRANCE: ClassVar[RESOURCE_SUBLANGS] = ... - BULGARIAN_BULGARIA: ClassVar[RESOURCE_SUBLANGS] = ... - CATALAN_CATALAN: ClassVar[RESOURCE_SUBLANGS] = ... - CHINESE_HONGKONG: ClassVar[RESOURCE_SUBLANGS] = ... - CHINESE_MACAU: ClassVar[RESOURCE_SUBLANGS] = ... - CHINESE_SIMPLIFIED: ClassVar[RESOURCE_SUBLANGS] = ... - CHINESE_SINGAPORE: ClassVar[RESOURCE_SUBLANGS] = ... - CHINESE_TRADITIONAL: ClassVar[RESOURCE_SUBLANGS] = ... - CORSICAN_FRANCE: ClassVar[RESOURCE_SUBLANGS] = ... - CROATIAN_BOSNIA_HERZEGOVINA_LATIN: ClassVar[RESOURCE_SUBLANGS] = ... - CROATIAN_CROATIA: ClassVar[RESOURCE_SUBLANGS] = ... - CUSTOM_DEFAULT: ClassVar[RESOURCE_SUBLANGS] = ... - CUSTOM_UNSPECIFIED: ClassVar[RESOURCE_SUBLANGS] = ... - CZECH_CZECH_REPUBLIC: ClassVar[RESOURCE_SUBLANGS] = ... - DANISH_DENMARK: ClassVar[RESOURCE_SUBLANGS] = ... - DARI_AFGHANISTAN: ClassVar[RESOURCE_SUBLANGS] = ... - DEFAULT: ClassVar[RESOURCE_SUBLANGS] = ... - DIVEHI_MALDIVES: ClassVar[RESOURCE_SUBLANGS] = ... - DUTCH: ClassVar[RESOURCE_SUBLANGS] = ... - DUTCH_BELGIAN: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_AUS: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_BELIZE: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_CAN: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_CARIBBEAN: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_EIRE: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_IRELAND: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_JAMAICA: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_MALAYSIA: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_NZ: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_PHILIPPINES: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_SINGAPORE: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_SOUTH_AFRICA: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_TRINIDAD: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_UK: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_US: ClassVar[RESOURCE_SUBLANGS] = ... - ENGLISH_ZIMBABWE: ClassVar[RESOURCE_SUBLANGS] = ... - ESTONIAN_ESTONIA: ClassVar[RESOURCE_SUBLANGS] = ... - FAEROESE_FAROE_ISLANDS: ClassVar[RESOURCE_SUBLANGS] = ... - FILIPINO_PHILIPPINES: ClassVar[RESOURCE_SUBLANGS] = ... - FINNISH_FINLAND: ClassVar[RESOURCE_SUBLANGS] = ... - FRENCH: ClassVar[RESOURCE_SUBLANGS] = ... - FRENCH_BELGIAN: ClassVar[RESOURCE_SUBLANGS] = ... - FRENCH_CANADIAN: ClassVar[RESOURCE_SUBLANGS] = ... - FRENCH_LUXEMBOURG: ClassVar[RESOURCE_SUBLANGS] = ... - FRENCH_MONACO: ClassVar[RESOURCE_SUBLANGS] = ... - FRENCH_SWISS: ClassVar[RESOURCE_SUBLANGS] = ... - FRISIAN_NETHERLANDS: ClassVar[RESOURCE_SUBLANGS] = ... - GALICIAN_GALICIAN: ClassVar[RESOURCE_SUBLANGS] = ... - GEORGIAN_GEORGIA: ClassVar[RESOURCE_SUBLANGS] = ... - GERMAN: ClassVar[RESOURCE_SUBLANGS] = ... - GERMAN_AUSTRIAN: ClassVar[RESOURCE_SUBLANGS] = ... - GERMAN_LIECHTENSTEIN: ClassVar[RESOURCE_SUBLANGS] = ... - GERMAN_LUXEMBOURG: ClassVar[RESOURCE_SUBLANGS] = ... - GERMAN_SWISS: ClassVar[RESOURCE_SUBLANGS] = ... - GREEK_GREECE: ClassVar[RESOURCE_SUBLANGS] = ... - GREENLANDIC_GREENLAND: ClassVar[RESOURCE_SUBLANGS] = ... - GUJARATI_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - HAUSA_NIGERIA_LATIN: ClassVar[RESOURCE_SUBLANGS] = ... - HEBREW_ISRAEL: ClassVar[RESOURCE_SUBLANGS] = ... - HINDI_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - HUNGARIAN_HUNGARY: ClassVar[RESOURCE_SUBLANGS] = ... - ICELANDIC_ICELAND: ClassVar[RESOURCE_SUBLANGS] = ... - IGBO_NIGERIA: ClassVar[RESOURCE_SUBLANGS] = ... - INDONESIAN_INDONESIA: ClassVar[RESOURCE_SUBLANGS] = ... - INUKTITUT_CANADA: ClassVar[RESOURCE_SUBLANGS] = ... - INUKTITUT_CANADA_LATIN: ClassVar[RESOURCE_SUBLANGS] = ... - IRISH_IRELAND: ClassVar[RESOURCE_SUBLANGS] = ... - ITALIAN: ClassVar[RESOURCE_SUBLANGS] = ... - ITALIAN_SWISS: ClassVar[RESOURCE_SUBLANGS] = ... - JAPANESE_JAPAN: ClassVar[RESOURCE_SUBLANGS] = ... - KANNADA_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - KASHMIRI_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - KASHMIRI_SASIA: ClassVar[RESOURCE_SUBLANGS] = ... - KAZAK_KAZAKHSTAN: ClassVar[RESOURCE_SUBLANGS] = ... - KHMER_CAMBODIA: ClassVar[RESOURCE_SUBLANGS] = ... - KICHE_GUATEMALA: ClassVar[RESOURCE_SUBLANGS] = ... - KINYARWANDA_RWANDA: ClassVar[RESOURCE_SUBLANGS] = ... - KONKANI_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - KOREAN: ClassVar[RESOURCE_SUBLANGS] = ... - KYRGYZ_KYRGYZSTAN: ClassVar[RESOURCE_SUBLANGS] = ... - LAO_LAO: ClassVar[RESOURCE_SUBLANGS] = ... - LATVIAN_LATVIA: ClassVar[RESOURCE_SUBLANGS] = ... - LITHUANIAN: ClassVar[RESOURCE_SUBLANGS] = ... - LITHUANIAN_CLASSIC: ClassVar[RESOURCE_SUBLANGS] = ... - LOWER_SORBIAN_GERMANY: ClassVar[RESOURCE_SUBLANGS] = ... - LUXEMBOURGISH_LUXEMBOURG: ClassVar[RESOURCE_SUBLANGS] = ... - MACEDONIAN_MACEDONIA: ClassVar[RESOURCE_SUBLANGS] = ... - MALAYALAM_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - MALAY_BRUNEI_DARUSSALAM: ClassVar[RESOURCE_SUBLANGS] = ... - MALAY_MALAYSIA: ClassVar[RESOURCE_SUBLANGS] = ... - MALTESE_MALTA: ClassVar[RESOURCE_SUBLANGS] = ... - MAORI_NEW_ZEALAND: ClassVar[RESOURCE_SUBLANGS] = ... - MAPUDUNGUN_CHILE: ClassVar[RESOURCE_SUBLANGS] = ... - MARATHI_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - MOHAWK_MOHAWK: ClassVar[RESOURCE_SUBLANGS] = ... - MONGOLIAN_CYRILLIC_MONGOLIA: ClassVar[RESOURCE_SUBLANGS] = ... - MONGOLIAN_PRC: ClassVar[RESOURCE_SUBLANGS] = ... - NEPALI_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - NEPALI_NEPAL: ClassVar[RESOURCE_SUBLANGS] = ... - NEUTRAL: ClassVar[RESOURCE_SUBLANGS] = ... - NORWEGIAN_BOKMAL: ClassVar[RESOURCE_SUBLANGS] = ... - NORWEGIAN_NYNORSK: ClassVar[RESOURCE_SUBLANGS] = ... - OCCITAN_FRANCE: ClassVar[RESOURCE_SUBLANGS] = ... - ORIYA_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - PASHTO_AFGHANISTAN: ClassVar[RESOURCE_SUBLANGS] = ... - PERSIAN_IRAN: ClassVar[RESOURCE_SUBLANGS] = ... - POLISH_POLAND: ClassVar[RESOURCE_SUBLANGS] = ... - PORTUGUESE: ClassVar[RESOURCE_SUBLANGS] = ... - PORTUGUESE_BRAZILIAN: ClassVar[RESOURCE_SUBLANGS] = ... - PULAR_SENEGAL: ClassVar[RESOURCE_SUBLANGS] = ... - PUNJABI_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - PUNJABI_PAKISTAN: ClassVar[RESOURCE_SUBLANGS] = ... - QUECHUA_BOLIVIA: ClassVar[RESOURCE_SUBLANGS] = ... - QUECHUA_ECUADOR: ClassVar[RESOURCE_SUBLANGS] = ... - QUECHUA_PERU: ClassVar[RESOURCE_SUBLANGS] = ... - ROMANIAN_ROMANIA: ClassVar[RESOURCE_SUBLANGS] = ... - ROMANSH_SWITZERLAND: ClassVar[RESOURCE_SUBLANGS] = ... - RUSSIAN_RUSSIA: ClassVar[RESOURCE_SUBLANGS] = ... - SAMI_INARI_FINLAND: ClassVar[RESOURCE_SUBLANGS] = ... - SAMI_LULE_NORWAY: ClassVar[RESOURCE_SUBLANGS] = ... - SAMI_LULE_SWEDEN: ClassVar[RESOURCE_SUBLANGS] = ... - SAMI_NORTHERN_FINLAND: ClassVar[RESOURCE_SUBLANGS] = ... - SAMI_NORTHERN_NORWAY: ClassVar[RESOURCE_SUBLANGS] = ... - SAMI_NORTHERN_SWEDEN: ClassVar[RESOURCE_SUBLANGS] = ... - SAMI_SKOLT_FINLAND: ClassVar[RESOURCE_SUBLANGS] = ... - SAMI_SOUTHERN_NORWAY: ClassVar[RESOURCE_SUBLANGS] = ... - SAMI_SOUTHERN_SWEDEN: ClassVar[RESOURCE_SUBLANGS] = ... - SANSKRIT_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC: ClassVar[RESOURCE_SUBLANGS] = ... - SERBIAN_BOSNIA_HERZEGOVINA_LATIN: ClassVar[RESOURCE_SUBLANGS] = ... - SERBIAN_CROATIA: ClassVar[RESOURCE_SUBLANGS] = ... - SERBIAN_CYRILLIC: ClassVar[RESOURCE_SUBLANGS] = ... - SERBIAN_LATIN: ClassVar[RESOURCE_SUBLANGS] = ... - SINDHI_AFGHANISTAN: ClassVar[RESOURCE_SUBLANGS] = ... - SINDHI_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - SINDHI_PAKISTAN: ClassVar[RESOURCE_SUBLANGS] = ... - SINHALESE_SRI_LANKA: ClassVar[RESOURCE_SUBLANGS] = ... - SLOVAK_SLOVAKIA: ClassVar[RESOURCE_SUBLANGS] = ... - SLOVENIAN_SLOVENIA: ClassVar[RESOURCE_SUBLANGS] = ... - SOTHO_NORTHERN_SOUTH_AFRICA: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_ARGENTINA: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_BOLIVIA: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_CHILE: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_COLOMBIA: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_COSTA_RICA: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_DOMINICAN_REPUBLIC: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_ECUADOR: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_EL_SALVADOR: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_GUATEMALA: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_HONDURAS: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_MEXICAN: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_MODERN: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_NICARAGUA: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_PANAMA: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_PARAGUAY: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_PERU: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_PUERTO_RICO: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_URUGUAY: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_US: ClassVar[RESOURCE_SUBLANGS] = ... - SPANISH_VENEZUELA: ClassVar[RESOURCE_SUBLANGS] = ... - SWAHILI_KENYA: ClassVar[RESOURCE_SUBLANGS] = ... - SWEDISH: ClassVar[RESOURCE_SUBLANGS] = ... - SWEDISH_FINLAND: ClassVar[RESOURCE_SUBLANGS] = ... - SYRIAC_SYRIA: ClassVar[RESOURCE_SUBLANGS] = ... - SYS_DEFAULT: ClassVar[RESOURCE_SUBLANGS] = ... - TAJIK_TAJIKISTAN: ClassVar[RESOURCE_SUBLANGS] = ... - TAMAZIGHT_ALGERIA_LATIN: ClassVar[RESOURCE_SUBLANGS] = ... - TAMIL_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - TAMIL_SRI_LANKA: ClassVar[RESOURCE_SUBLANGS] = ... - TATAR_RUSSIA: ClassVar[RESOURCE_SUBLANGS] = ... - TELUGU_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - THAI_THAILAND: ClassVar[RESOURCE_SUBLANGS] = ... - TIBETAN_PRC: ClassVar[RESOURCE_SUBLANGS] = ... - TIGRIGNA_ERITREA: ClassVar[RESOURCE_SUBLANGS] = ... - TIGRINYA_ERITREA: ClassVar[RESOURCE_SUBLANGS] = ... - TIGRINYA_ETHIOPIA: ClassVar[RESOURCE_SUBLANGS] = ... - TSWANA_BOTSWANA: ClassVar[RESOURCE_SUBLANGS] = ... - TSWANA_SOUTH_AFRICA: ClassVar[RESOURCE_SUBLANGS] = ... - TURKISH_TURKEY: ClassVar[RESOURCE_SUBLANGS] = ... - TURKMEN_TURKMENISTAN: ClassVar[RESOURCE_SUBLANGS] = ... - UIGHUR_PRC: ClassVar[RESOURCE_SUBLANGS] = ... - UI_CUSTOM_DEFAULT: ClassVar[RESOURCE_SUBLANGS] = ... - UKRAINIAN_UKRAINE: ClassVar[RESOURCE_SUBLANGS] = ... - UPPER_SORBIAN_GERMANY: ClassVar[RESOURCE_SUBLANGS] = ... - URDU_INDIA: ClassVar[RESOURCE_SUBLANGS] = ... - URDU_PAKISTAN: ClassVar[RESOURCE_SUBLANGS] = ... - UZBEK_CYRILLIC: ClassVar[RESOURCE_SUBLANGS] = ... - UZBEK_LATIN: ClassVar[RESOURCE_SUBLANGS] = ... - VALENCIAN_VALENCIA: ClassVar[RESOURCE_SUBLANGS] = ... - VIETNAMESE_VIETNAM: ClassVar[RESOURCE_SUBLANGS] = ... - WELSH_UNITED_KINGDOM: ClassVar[RESOURCE_SUBLANGS] = ... - WOLOF_SENEGAL: ClassVar[RESOURCE_SUBLANGS] = ... - XHOSA_SOUTH_AFRICA: ClassVar[RESOURCE_SUBLANGS] = ... - YAKUT_RUSSIA: ClassVar[RESOURCE_SUBLANGS] = ... - YI_PRC: ClassVar[RESOURCE_SUBLANGS] = ... - YORUBA_NIGERIA: ClassVar[RESOURCE_SUBLANGS] = ... - ZULU_SOUTH_AFRICA: ClassVar[RESOURCE_SUBLANGS] = ... - __name__: Any - def __init__(self, *args, **kwargs) -> None: ... - @staticmethod - def from_value(arg: int, /) -> lief.PE.RESOURCE_SUBLANGS: ... - @property - def value(self) -> int: ... - -class RESOURCE_TYPES: - ACCELERATOR: ClassVar[RESOURCE_TYPES] = ... - ANICURSOR: ClassVar[RESOURCE_TYPES] = ... - ANIICON: ClassVar[RESOURCE_TYPES] = ... - BITMAP: ClassVar[RESOURCE_TYPES] = ... - CURSOR: ClassVar[RESOURCE_TYPES] = ... - DIALOG: ClassVar[RESOURCE_TYPES] = ... - DLGINCLUDE: ClassVar[RESOURCE_TYPES] = ... - FONT: ClassVar[RESOURCE_TYPES] = ... - FONTDIR: ClassVar[RESOURCE_TYPES] = ... - GROUP_CURSOR: ClassVar[RESOURCE_TYPES] = ... - GROUP_ICON: ClassVar[RESOURCE_TYPES] = ... - HTML: ClassVar[RESOURCE_TYPES] = ... - ICON: ClassVar[RESOURCE_TYPES] = ... - MANIFEST: ClassVar[RESOURCE_TYPES] = ... - MENU: ClassVar[RESOURCE_TYPES] = ... - MESSAGETABLE: ClassVar[RESOURCE_TYPES] = ... - PLUGPLAY: ClassVar[RESOURCE_TYPES] = ... - RCDATA: ClassVar[RESOURCE_TYPES] = ... - STRING: ClassVar[RESOURCE_TYPES] = ... - VERSION: ClassVar[RESOURCE_TYPES] = ... - VXD: ClassVar[RESOURCE_TYPES] = ... - __name__: Any - def __init__(self, *args, **kwargs) -> None: ... - @staticmethod - def from_value(arg: int, /) -> lief.PE.RESOURCE_TYPES: ... - @property - def value(self) -> int: ... - class Relocation(lief.Object): class it_entries: def __init__(self, *args, **kwargs) -> None: ... @@ -1929,8 +1662,8 @@ class ResourceDialog(lief.Object): def __iter__(self) -> lief.PE.ResourceDialog.it_const_items: ... def __len__(self) -> int: ... def __next__(self) -> lief.PE.ResourceDialogItem: ... - lang: lief.PE.RESOURCE_LANGS - sub_lang: lief.PE.RESOURCE_SUBLANGS + lang: int + sub_lang: int def __init__(self, *args, **kwargs) -> None: ... def has_dialogbox_style(self, style: lief.PE.DIALOG_BOX_STYLES) -> bool: ... def has_extended_style(self, style: lief.PE.EXTENDED_WINDOW_STYLES) -> bool: ... @@ -2027,11 +1760,11 @@ class ResourceIcon(lief.Object): color_count: int height: int id: int - lang: lief.PE.RESOURCE_LANGS + lang: int pixels: memoryview planes: int reserved: int - sublang: lief.PE.RESOURCE_SUBLANGS + sublang: int width: int def __init__(self, *args, **kwargs) -> None: ... def save(self, filepath: str) -> None: ... @@ -2101,6 +1834,35 @@ class ResourceVersion(lief.Object): def has_var_file_info(self) -> bool: ... class ResourcesManager(lief.Object): + class TYPE: + ACCELERATOR: ClassVar[ResourcesManager.TYPE] = ... + ANICURSOR: ClassVar[ResourcesManager.TYPE] = ... + ANIICON: ClassVar[ResourcesManager.TYPE] = ... + BITMAP: ClassVar[ResourcesManager.TYPE] = ... + CURSOR: ClassVar[ResourcesManager.TYPE] = ... + DIALOG: ClassVar[ResourcesManager.TYPE] = ... + DLGINCLUDE: ClassVar[ResourcesManager.TYPE] = ... + FONT: ClassVar[ResourcesManager.TYPE] = ... + FONTDIR: ClassVar[ResourcesManager.TYPE] = ... + GROUP_CURSOR: ClassVar[ResourcesManager.TYPE] = ... + GROUP_ICON: ClassVar[ResourcesManager.TYPE] = ... + HTML: ClassVar[ResourcesManager.TYPE] = ... + ICON: ClassVar[ResourcesManager.TYPE] = ... + MANIFEST: ClassVar[ResourcesManager.TYPE] = ... + MENU: ClassVar[ResourcesManager.TYPE] = ... + MESSAGETABLE: ClassVar[ResourcesManager.TYPE] = ... + PLUGPLAY: ClassVar[ResourcesManager.TYPE] = ... + RCDATA: ClassVar[ResourcesManager.TYPE] = ... + STRING: ClassVar[ResourcesManager.TYPE] = ... + VERSION: ClassVar[ResourcesManager.TYPE] = ... + VXD: ClassVar[ResourcesManager.TYPE] = ... + __name__: Any + def __init__(self, *args, **kwargs) -> None: ... + @staticmethod + def from_value(arg: int, /) -> lief.PE.ResourcesManager.TYPE: ... + @property + def value(self) -> int: ... + class it_const_accelerators: def __init__(self, *args, **kwargs) -> None: ... def __getitem__(self, arg: int, /) -> lief.PE.ResourceAccelerator: ... @@ -2132,8 +1894,8 @@ class ResourcesManager(lief.Object): def __init__(self, arg: lief.PE.ResourceNode, /) -> None: ... def add_icon(self, icon: lief.PE.ResourceIcon) -> None: ... def change_icon(self, old_one: lief.PE.ResourceIcon, new_one: lief.PE.ResourceIcon) -> None: ... - def get_node_type(self, type: lief.PE.RESOURCE_TYPES) -> lief.PE.ResourceNode: ... - def has_type(self, type: lief.PE.RESOURCE_TYPES) -> bool: ... + def get_node_type(self, type: lief.PE.ResourcesManager.TYPE) -> lief.PE.ResourceNode: ... + def has_type(self, type: lief.PE.ResourcesManager.TYPE) -> bool: ... @property def accelerator(self) -> lief.PE.ResourcesManager.it_const_accelerators: ... @property @@ -2157,13 +1919,9 @@ class ResourcesManager(lief.Object): @property def icons(self) -> lief.PE.ResourcesManager.it_const_icons: ... @property - def langs_available(self) -> set[lief.PE.RESOURCE_LANGS]: ... - @property def string_table(self) -> lief.PE.ResourcesManager.it_const_strings_table: ... @property - def sublangs_available(self) -> set[lief.PE.RESOURCE_SUBLANGS]: ... - @property - def types_available(self) -> set[lief.PE.RESOURCE_TYPES]: ... + def types(self) -> list[lief.PE.ResourcesManager.TYPE]: ... @property def version(self) -> Union[lief.PE.ResourceVersion,lief.lief_errors]: ... diff --git a/api/python/src/PE/enums.cpp b/api/python/src/PE/enums.cpp index be6e21b1f2..ade0562bfe 100644 --- a/api/python/src/PE/enums.cpp +++ b/api/python/src/PE/enums.cpp @@ -122,367 +122,6 @@ void init_enums(nb::module_& m) { .value("DIR64", RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_DIR64) .value("HIGH3ADJ", RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_HIGH3ADJ); - enum_(m, "RESOURCE_TYPES") - .value(PY_ENUM(RESOURCE_TYPES::CURSOR)) - .value(PY_ENUM(RESOURCE_TYPES::BITMAP)) - .value(PY_ENUM(RESOURCE_TYPES::ICON)) - .value(PY_ENUM(RESOURCE_TYPES::MENU)) - .value(PY_ENUM(RESOURCE_TYPES::DIALOG)) - .value(PY_ENUM(RESOURCE_TYPES::STRING)) - .value(PY_ENUM(RESOURCE_TYPES::FONTDIR)) - .value(PY_ENUM(RESOURCE_TYPES::FONT)) - .value(PY_ENUM(RESOURCE_TYPES::ACCELERATOR)) - .value(PY_ENUM(RESOURCE_TYPES::RCDATA)) - .value(PY_ENUM(RESOURCE_TYPES::MESSAGETABLE)) - .value(PY_ENUM(RESOURCE_TYPES::GROUP_CURSOR)) - .value(PY_ENUM(RESOURCE_TYPES::GROUP_ICON)) - .value(PY_ENUM(RESOURCE_TYPES::VERSION)) - .value(PY_ENUM(RESOURCE_TYPES::DLGINCLUDE)) - .value(PY_ENUM(RESOURCE_TYPES::PLUGPLAY)) - .value(PY_ENUM(RESOURCE_TYPES::VXD)) - .value(PY_ENUM(RESOURCE_TYPES::ANICURSOR)) - .value(PY_ENUM(RESOURCE_TYPES::ANIICON)) - .value(PY_ENUM(RESOURCE_TYPES::HTML)) - .value(PY_ENUM(RESOURCE_TYPES::MANIFEST)); - - - enum_(m, "RESOURCE_LANGS") - .value(PY_ENUM(RESOURCE_LANGS::LANG_NEUTRAL)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_INVARIANT)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_AFRIKAANS)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_ALBANIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_ARABIC)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_ARMENIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_ASSAMESE)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_AZERI)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_BASQUE)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_BELARUSIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_BANGLA)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_BULGARIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_CATALAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_CHINESE)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_CROATIAN)) - .value("BOSNIAN", RESOURCE_LANGS::LANG_BOSNIAN) - .value(PY_ENUM(RESOURCE_LANGS::LANG_CZECH)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_DANISH)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_DIVEHI)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_DUTCH)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_ENGLISH)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_ESTONIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_FAEROESE)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_FARSI)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_FINNISH)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_FRENCH)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_GALICIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_GEORGIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_GERMAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_GREEK)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_GUJARATI)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_HEBREW)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_HINDI)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_HUNGARIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_ICELANDIC)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_INDONESIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_ITALIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_JAPANESE)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_KANNADA)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_KASHMIRI)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_KAZAK)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_KONKANI)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_KOREAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_KYRGYZ)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_LATVIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_LITHUANIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_MACEDONIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_MALAY)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_MALAYALAM)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_MANIPURI)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_MARATHI)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_MONGOLIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_NEPALI)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_NORWEGIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_ORIYA)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_POLISH)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_PORTUGUESE)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_PUNJABI)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_ROMANIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_RUSSIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_SANSKRIT)) - .value("SERBIAN", RESOURCE_LANGS::LANG_SERBIAN) - .value(PY_ENUM(RESOURCE_LANGS::LANG_SINDHI)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_SLOVAK)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_SLOVENIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_SPANISH)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_SWAHILI)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_SWEDISH)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_SYRIAC)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_TAMIL)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_TATAR)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_TELUGU)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_THAI)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_TURKISH)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_UKRAINIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_URDU)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_UZBEK)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_VIETNAMESE)) - .value("GAELIC", RESOURCE_LANGS::LANG_GAELIC) - .value(PY_ENUM(RESOURCE_LANGS::LANG_MALTESE)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_MAORI)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_RHAETO_ROMANCE)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_SAMI)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_SORBIAN)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_SUTU)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_TSONGA)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_TSWANA)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_VENDA)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_XHOSA)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_ZULU)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_ESPERANTO)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_WALON)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_CORNISH)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_WELSH)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_BRETON)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_INUKTITUT)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_IRISH)) - .value("LOWER_SORBIAN", RESOURCE_LANGS::LANG_LOWER_SORBIAN) - .value(PY_ENUM(RESOURCE_LANGS::LANG_PULAR)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_QUECHUA)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_TAMAZIGHT)) - .value(PY_ENUM(RESOURCE_LANGS::LANG_TIGRINYA)) - .value("VALENCIAN", RESOURCE_LANGS::LANG_VALENCIAN); - - enum_(m, "RESOURCE_SUBLANGS") - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_AFRIKAANS_SOUTH_AFRICA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ALBANIAN_ALBANIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ALSATIAN_FRANCE)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_AMHARIC_ETHIOPIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARABIC_ALGERIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARABIC_BAHRAIN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARABIC_EGYPT)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARABIC_IRAQ)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARABIC_JORDAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARABIC_KUWAIT)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARABIC_LEBANON)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARABIC_LIBYA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARABIC_MOROCCO)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARABIC_OMAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARABIC_QATAR)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARABIC_SAUDI_ARABIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARABIC_SYRIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARABIC_TUNISIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARABIC_UAE)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARABIC_YEMEN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ARMENIAN_ARMENIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ASSAMESE_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_AZERI_CYRILLIC)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_AZERI_LATIN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_BASHKIR_RUSSIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_BASQUE_BASQUE)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_BELARUSIAN_BELARUS)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_BANGLA_BANGLADESH)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_BANGLA_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_BRETON_FRANCE)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_BULGARIAN_BULGARIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_CATALAN_CATALAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_CHINESE_HONGKONG)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_CHINESE_MACAU)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_CHINESE_SIMPLIFIED)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_CHINESE_SINGAPORE)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_CHINESE_TRADITIONAL)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_CORSICAN_FRANCE)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_CROATIAN_CROATIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_CUSTOM_DEFAULT)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_CUSTOM_UNSPECIFIED)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_CZECH_CZECH_REPUBLIC)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_DANISH_DENMARK)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_DARI_AFGHANISTAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_DEFAULT)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_DIVEHI_MALDIVES)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_DUTCH_BELGIAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_DUTCH)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_AUS)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_BELIZE)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_CAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_CARIBBEAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_EIRE)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_JAMAICA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_MALAYSIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_NZ)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_PHILIPPINES)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_SINGAPORE)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_SOUTH_AFRICA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_TRINIDAD)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_UK)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_US)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_ZIMBABWE)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ENGLISH_IRELAND)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ESTONIAN_ESTONIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_FAEROESE_FAROE_ISLANDS)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_FILIPINO_PHILIPPINES)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_FINNISH_FINLAND)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_FRENCH_BELGIAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_FRENCH_CANADIAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_FRENCH_LUXEMBOURG)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_FRENCH_MONACO)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_FRENCH_SWISS)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_FRENCH)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_FRISIAN_NETHERLANDS)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_GALICIAN_GALICIAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_GEORGIAN_GEORGIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_GERMAN_AUSTRIAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_GERMAN_LIECHTENSTEIN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_GERMAN_LUXEMBOURG)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_GERMAN_SWISS)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_GERMAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_GREEK_GREECE)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_GREENLANDIC_GREENLAND)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_GUJARATI_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_HAUSA_NIGERIA_LATIN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_HEBREW_ISRAEL)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_HINDI_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_HUNGARIAN_HUNGARY)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ICELANDIC_ICELAND)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_IGBO_NIGERIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_INDONESIAN_INDONESIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_INUKTITUT_CANADA_LATIN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_INUKTITUT_CANADA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_IRISH_IRELAND)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ITALIAN_SWISS)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ITALIAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_JAPANESE_JAPAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_KANNADA_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_KASHMIRI_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_KASHMIRI_SASIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_KAZAK_KAZAKHSTAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_KHMER_CAMBODIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_KICHE_GUATEMALA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_KINYARWANDA_RWANDA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_KONKANI_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_KOREAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_KYRGYZ_KYRGYZSTAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_LAO_LAO)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_LATVIAN_LATVIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_LITHUANIAN_CLASSIC)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_LITHUANIAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_LOWER_SORBIAN_GERMANY)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_LUXEMBOURGISH_LUXEMBOURG)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_MACEDONIAN_MACEDONIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_MALAY_BRUNEI_DARUSSALAM)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_MALAY_MALAYSIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_MALAYALAM_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_MALTESE_MALTA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_MAORI_NEW_ZEALAND)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_MAPUDUNGUN_CHILE)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_MARATHI_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_MOHAWK_MOHAWK)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_MONGOLIAN_PRC)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_NEPALI_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_NEPALI_NEPAL)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_NEUTRAL)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_NORWEGIAN_BOKMAL)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_NORWEGIAN_NYNORSK)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_OCCITAN_FRANCE)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ORIYA_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_PASHTO_AFGHANISTAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_PERSIAN_IRAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_POLISH_POLAND)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_PORTUGUESE_BRAZILIAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_PORTUGUESE)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_PUNJABI_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_QUECHUA_BOLIVIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_QUECHUA_ECUADOR)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_QUECHUA_PERU)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ROMANIAN_ROMANIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ROMANSH_SWITZERLAND)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_RUSSIAN_RUSSIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SAMI_INARI_FINLAND)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SAMI_LULE_NORWAY)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SAMI_LULE_SWEDEN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SAMI_NORTHERN_FINLAND)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SAMI_NORTHERN_NORWAY)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SAMI_NORTHERN_SWEDEN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SAMI_SKOLT_FINLAND)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SAMI_SOUTHERN_NORWAY)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SAMI_SOUTHERN_SWEDEN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SANSKRIT_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SERBIAN_CROATIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SERBIAN_CYRILLIC)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SERBIAN_LATIN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SINDHI_AFGHANISTAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SINDHI_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SINDHI_PAKISTAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SINHALESE_SRI_LANKA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SLOVAK_SLOVAKIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SLOVENIAN_SLOVENIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_ARGENTINA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_BOLIVIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_CHILE)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_COLOMBIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_COSTA_RICA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_DOMINICAN_REPUBLIC)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_ECUADOR)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_EL_SALVADOR)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_GUATEMALA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_HONDURAS)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_MEXICAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_MODERN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_NICARAGUA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_PANAMA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_PARAGUAY)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_PERU)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_PUERTO_RICO)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_URUGUAY)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_US)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH_VENEZUELA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SPANISH)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SWAHILI_KENYA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SWEDISH_FINLAND)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SWEDISH)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SYRIAC_SYRIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_SYS_DEFAULT)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_TAJIK_TAJIKISTAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_TAMAZIGHT_ALGERIA_LATIN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_TAMIL_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_TATAR_RUSSIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_TELUGU_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_THAI_THAILAND)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_TIBETAN_PRC)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_TIGRIGNA_ERITREA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_TSWANA_SOUTH_AFRICA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_TURKISH_TURKEY)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_TURKMEN_TURKMENISTAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_UI_CUSTOM_DEFAULT)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_UIGHUR_PRC)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_UKRAINIAN_UKRAINE)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_UPPER_SORBIAN_GERMANY)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_URDU_INDIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_URDU_PAKISTAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_UZBEK_CYRILLIC)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_UZBEK_LATIN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_VIETNAMESE_VIETNAM)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_WELSH_UNITED_KINGDOM)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_WOLOF_SENEGAL)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_XHOSA_SOUTH_AFRICA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_YAKUT_RUSSIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_YI_PRC)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_YORUBA_NIGERIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_ZULU_SOUTH_AFRICA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_PULAR_SENEGAL)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_PUNJABI_PAKISTAN)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_TSWANA_BOTSWANA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_TAMIL_SRI_LANKA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_TIGRINYA_ETHIOPIA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_TIGRINYA_ERITREA)) - .value(PY_ENUM(RESOURCE_SUBLANGS::SUBLANG_VALENCIAN_VALENCIA)); - enum_(m, "EXTENDED_WINDOW_STYLES") .value(PY_ENUM(EXTENDED_WINDOW_STYLES::WS_EX_DLGMODALFRAME)) .value(PY_ENUM(EXTENDED_WINDOW_STYLES::WS_EX_NOPARENTNOTIFY)) diff --git a/api/python/src/PE/init.cpp b/api/python/src/PE/init.cpp index 279af7c04d..0cd7552d51 100644 --- a/api/python/src/PE/init.cpp +++ b/api/python/src/PE/init.cpp @@ -32,6 +32,7 @@ #include "LIEF/PE/debug/Pogo.hpp" #include "LIEF/PE/debug/PogoEntry.hpp" #include "LIEF/PE/resources/LangCodeItem.hpp" +#include "LIEF/PE/resources/langs.hpp" #include "LIEF/PE/signature/attributes.hpp" #include "LIEF/PE/signature/SpcIndirectData.hpp" #include "LIEF/PE/signature/GenericContent.hpp" @@ -55,6 +56,7 @@ void init_resources(nb::module_& m) { CREATE(ResourceDialogItem, m); CREATE(ResourceStringTable, m); CREATE(ResourceAccelerator, m); + CREATE(RESOURCE_LANGS, m); } void init_load_configs(nb::module_& m) { diff --git a/api/python/src/PE/objects/CMakeLists.txt b/api/python/src/PE/objects/CMakeLists.txt index 321ac29c17..e05b1e0dd8 100644 --- a/api/python/src/PE/objects/CMakeLists.txt +++ b/api/python/src/PE/objects/CMakeLists.txt @@ -22,6 +22,7 @@ target_sources(pyLIEF PRIVATE pyDelayImportEntry.cpp pySymbol.cpp pyTLS.cpp + pyLang.cpp ) add_subdirectory(resources) diff --git a/api/python/src/PE/objects/pyLang.cpp b/api/python/src/PE/objects/pyLang.cpp new file mode 100644 index 0000000000..b4c5869d66 --- /dev/null +++ b/api/python/src/PE/objects/pyLang.cpp @@ -0,0 +1,133 @@ +/* Copyright 2017 - 2023 R. Thomas + * Copyright 2017 - 2023 Quarkslab + * Copyright 2017 - 2021 K. Nakagawa + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "PE/pyPE.hpp" + +#include "LIEF/PE/resources/langs.hpp" +#include "enums_wrapper.hpp" + +namespace LIEF::PE::py { + +template<> +void create(nb::module_& m) { + enum_(m, "RESOURCE_LANGS") + .value("NEUTRAL", RESOURCE_LANGS::NEUTRAL) + .value("INVARIANT", RESOURCE_LANGS::INVARIANT) + .value("AFRIKAANS", RESOURCE_LANGS::AFRIKAANS) + .value("ALBANIAN", RESOURCE_LANGS::ALBANIAN) + .value("ARABIC", RESOURCE_LANGS::ARABIC) + .value("ARMENIAN", RESOURCE_LANGS::ARMENIAN) + .value("ASSAMESE", RESOURCE_LANGS::ASSAMESE) + .value("AZERI", RESOURCE_LANGS::AZERI) + .value("BASQUE", RESOURCE_LANGS::BASQUE) + .value("BELARUSIAN", RESOURCE_LANGS::BELARUSIAN) + .value("BANGLA", RESOURCE_LANGS::BANGLA) + .value("BULGARIAN", RESOURCE_LANGS::BULGARIAN) + .value("CATALAN", RESOURCE_LANGS::CATALAN) + .value("CHINESE", RESOURCE_LANGS::CHINESE) + .value("CROATIAN", RESOURCE_LANGS::CROATIAN) + .value("BOSNIAN", RESOURCE_LANGS::BOSNIAN) + .value("CZECH", RESOURCE_LANGS::CZECH) + .value("DANISH", RESOURCE_LANGS::DANISH) + .value("DIVEHI", RESOURCE_LANGS::DIVEHI) + .value("DUTCH", RESOURCE_LANGS::DUTCH) + .value("ENGLISH", RESOURCE_LANGS::ENGLISH) + .value("ESTONIAN", RESOURCE_LANGS::ESTONIAN) + .value("FAEROESE", RESOURCE_LANGS::FAEROESE) + .value("FARSI", RESOURCE_LANGS::FARSI) + .value("FINNISH", RESOURCE_LANGS::FINNISH) + .value("FRENCH", RESOURCE_LANGS::FRENCH) + .value("GALICIAN", RESOURCE_LANGS::GALICIAN) + .value("GEORGIAN", RESOURCE_LANGS::GEORGIAN) + .value("GERMAN", RESOURCE_LANGS::GERMAN) + .value("GREEK", RESOURCE_LANGS::GREEK) + .value("GUJARATI", RESOURCE_LANGS::GUJARATI) + .value("HEBREW", RESOURCE_LANGS::HEBREW) + .value("HINDI", RESOURCE_LANGS::HINDI) + .value("HUNGARIAN", RESOURCE_LANGS::HUNGARIAN) + .value("ICELANDIC", RESOURCE_LANGS::ICELANDIC) + .value("INDONESIAN", RESOURCE_LANGS::INDONESIAN) + .value("ITALIAN", RESOURCE_LANGS::ITALIAN) + .value("JAPANESE", RESOURCE_LANGS::JAPANESE) + .value("KANNADA", RESOURCE_LANGS::KANNADA) + .value("KASHMIRI", RESOURCE_LANGS::KASHMIRI) + .value("KAZAK", RESOURCE_LANGS::KAZAK) + .value("KONKANI", RESOURCE_LANGS::KONKANI) + .value("KOREAN", RESOURCE_LANGS::KOREAN) + .value("KYRGYZ", RESOURCE_LANGS::KYRGYZ) + .value("LATVIAN", RESOURCE_LANGS::LATVIAN) + .value("LITHUANIAN", RESOURCE_LANGS::LITHUANIAN) + .value("MACEDONIAN", RESOURCE_LANGS::MACEDONIAN) + .value("MALAY", RESOURCE_LANGS::MALAY) + .value("MALAYALAM", RESOURCE_LANGS::MALAYALAM) + .value("MANIPURI", RESOURCE_LANGS::MANIPURI) + .value("MARATHI", RESOURCE_LANGS::MARATHI) + .value("MONGOLIAN", RESOURCE_LANGS::MONGOLIAN) + .value("NEPALI", RESOURCE_LANGS::NEPALI) + .value("NORWEGIAN", RESOURCE_LANGS::NORWEGIAN) + .value("ORIYA", RESOURCE_LANGS::ORIYA) + .value("POLISH", RESOURCE_LANGS::POLISH) + .value("PORTUGUESE", RESOURCE_LANGS::PORTUGUESE) + .value("PUNJABI", RESOURCE_LANGS::PUNJABI) + .value("ROMANIAN", RESOURCE_LANGS::ROMANIAN) + .value("RUSSIAN", RESOURCE_LANGS::RUSSIAN) + .value("SANSKRIT", RESOURCE_LANGS::SANSKRIT) + .value("SERBIAN", RESOURCE_LANGS::SERBIAN) + .value("SINDHI", RESOURCE_LANGS::SINDHI) + .value("SLOVAK", RESOURCE_LANGS::SLOVAK) + .value("SLOVENIAN", RESOURCE_LANGS::SLOVENIAN) + .value("SPANISH", RESOURCE_LANGS::SPANISH) + .value("SWAHILI", RESOURCE_LANGS::SWAHILI) + .value("SWEDISH", RESOURCE_LANGS::SWEDISH) + .value("SYRIAC", RESOURCE_LANGS::SYRIAC) + .value("TAMIL", RESOURCE_LANGS::TAMIL) + .value("TATAR", RESOURCE_LANGS::TATAR) + .value("TELUGU", RESOURCE_LANGS::TELUGU) + .value("THAI", RESOURCE_LANGS::THAI) + .value("TURKISH", RESOURCE_LANGS::TURKISH) + .value("UKRAINIAN", RESOURCE_LANGS::UKRAINIAN) + .value("URDU", RESOURCE_LANGS::URDU) + .value("UZBEK", RESOURCE_LANGS::UZBEK) + .value("VIETNAMESE", RESOURCE_LANGS::VIETNAMESE) + .value("GAELIC", RESOURCE_LANGS::GAELIC) + .value("MALTESE", RESOURCE_LANGS::MALTESE) + .value("MAORI", RESOURCE_LANGS::MAORI) + .value("RHAETO_ROMANCE", RESOURCE_LANGS::RHAETO_ROMANCE) + .value("SAMI", RESOURCE_LANGS::SAMI) + .value("SORBIAN", RESOURCE_LANGS::SORBIAN) + .value("SUTU", RESOURCE_LANGS::SUTU) + .value("TSONGA", RESOURCE_LANGS::TSONGA) + .value("TSWANA", RESOURCE_LANGS::TSWANA) + .value("VENDA", RESOURCE_LANGS::VENDA) + .value("XHOSA", RESOURCE_LANGS::XHOSA) + .value("ZULU", RESOURCE_LANGS::ZULU) + .value("ESPERANTO", RESOURCE_LANGS::ESPERANTO) + .value("WALON", RESOURCE_LANGS::WALON) + .value("CORNISH", RESOURCE_LANGS::CORNISH) + .value("WELSH", RESOURCE_LANGS::WELSH) + .value("BRETON", RESOURCE_LANGS::BRETON) + .value("INUKTITUT", RESOURCE_LANGS::INUKTITUT) + .value("IRISH", RESOURCE_LANGS::IRISH) + .value("LOWER_SORBIAN", RESOURCE_LANGS::LOWER_SORBIAN) + .value("PULAR", RESOURCE_LANGS::PULAR) + .value("QUECHUA", RESOURCE_LANGS::QUECHUA) + .value("TAMAZIGHT", RESOURCE_LANGS::TAMAZIGHT) + .value("TIGRINYA", RESOURCE_LANGS::TIGRINYA) + .value("VALENCIAN", RESOURCE_LANGS::VALENCIAN); + +} + +} diff --git a/api/python/src/PE/objects/pyResourcesManager.cpp b/api/python/src/PE/objects/pyResourcesManager.cpp index 43a39cda2e..591f65bde3 100644 --- a/api/python/src/PE/objects/pyResourcesManager.cpp +++ b/api/python/src/PE/objects/pyResourcesManager.cpp @@ -21,6 +21,7 @@ #include "LIEF/PE/ResourcesManager.hpp" #include "LIEF/PE/ResourceNode.hpp" +#include "enums_wrapper.hpp" #include #include @@ -41,6 +42,31 @@ void create(nb::module_& m) { init_ref_iterator(manager, "it_const_icons"); init_ref_iterator(manager, "it_const_strings_table"); init_ref_iterator(manager, "it_const_accelerators"); + #define ENTRY(X) .value(to_string(ResourcesManager::TYPE::X), ResourcesManager::TYPE::X) + enum_(manager, "TYPE") + ENTRY(CURSOR) + ENTRY(BITMAP) + ENTRY(ICON) + ENTRY(MENU) + ENTRY(DIALOG) + ENTRY(STRING) + ENTRY(FONTDIR) + ENTRY(FONT) + ENTRY(ACCELERATOR) + ENTRY(RCDATA) + ENTRY(MESSAGETABLE) + ENTRY(GROUP_CURSOR) + ENTRY(GROUP_ICON) + ENTRY(VERSION) + ENTRY(DLGINCLUDE) + ENTRY(PLUGPLAY) + ENTRY(VXD) + ENTRY(ANICURSOR) + ENTRY(ANIICON) + ENTRY(HTML) + ENTRY(MANIFEST) + ; + #undef ENTRY manager .def(nb::init(), nb::keep_alive<0, 1>()) @@ -88,17 +114,9 @@ void create(nb::module_& m) { "Return the list of the " RST_CLASS_REF(lief.PE.ResourceDialog) " present in the resource"_doc, nb::keep_alive<0, 1>()) - .def_prop_ro("types_available", - &ResourcesManager::get_types_available, - "Return list of " RST_CLASS_REF(lief.PE.RESOURCE_TYPES) " present in the resources"_doc) - - .def_prop_ro("langs_available", - &ResourcesManager::get_langs_available, - "Return list of " RST_CLASS_REF(lief.PE.RESOURCE_LANGS) " present in the resources"_doc) - - .def_prop_ro("sublangs_available", - &ResourcesManager::get_sublangs_available, - "Return list of " RST_CLASS_REF(lief.PE.RESOURCE_SUBLANGS) " present in the resources"_doc) + .def_prop_ro("types", + &ResourcesManager::get_types, + "Return list of :class:`~.TYPE` present in the resources"_doc) .def("add_icon", &ResourcesManager::add_icon, @@ -107,7 +125,7 @@ void create(nb::module_& m) { .def("has_type", &ResourcesManager::has_type, - "``True`` if the resource has the given " RST_CLASS_REF(lief.PE.RESOURCE_TYPES) ""_doc, + "``True`` if the resource has the given :class:`~.TYPE`"_doc, "type"_a) .def_prop_ro("has_string_table", @@ -135,9 +153,9 @@ void create(nb::module_& m) { nb::keep_alive<1, 0>()) .def("get_node_type", - nb::overload_cast(&ResourcesManager::get_node_type), + nb::overload_cast(&ResourcesManager::get_node_type), R"delim( - Return :class:`~lief.PE.ResourceNode` with the given :class:`~lief.PE.RESOURCE_TYPES` + Return :class:`~lief.PE.ResourceNode` with the given :class:`~.TYPE` or None if not found. )delim"_doc, "type"_a, diff --git a/api/python/src/PE/objects/resources/pyLangCodeItem.cpp b/api/python/src/PE/objects/resources/pyLangCodeItem.cpp index 3b5a5e1163..d172faae84 100644 --- a/api/python/src/PE/objects/resources/pyLangCodeItem.cpp +++ b/api/python/src/PE/objects/resources/pyLangCodeItem.cpp @@ -63,14 +63,14 @@ void create(nb::module_& m) { .def_prop_rw("lang", nb::overload_cast<>(&LangCodeItem::lang, nb::const_), - nb::overload_cast(&LangCodeItem::lang), - "Lang (" RST_CLASS_REF(lief.PE.RESOURCE_LANGS) ") for which " + nb::overload_cast(&LangCodeItem::lang), + "Language for which " ":attr:`~lief.PE.LangCodeItem.items` are defined"_doc) .def_prop_rw("sublang", nb::overload_cast<>(&LangCodeItem::sublang, nb::const_), - nb::overload_cast(&LangCodeItem::sublang), - "Sub-lang (" RST_CLASS_REF(lief.PE.RESOURCE_SUBLANGS) ") for which " + nb::overload_cast(&LangCodeItem::sublang), + "Sublanguage for which " ":attr:`~lief.PE.LangCodeItem.items` are defined"_doc) .def_prop_rw("code_page", diff --git a/api/python/src/PE/objects/resources/pyResourceDialog.cpp b/api/python/src/PE/objects/resources/pyResourceDialog.cpp index b2ff58d980..ada25608d8 100644 --- a/api/python/src/PE/objects/resources/pyResourceDialog.cpp +++ b/api/python/src/PE/objects/resources/pyResourceDialog.cpp @@ -150,13 +150,13 @@ void create(nb::module_& m) { .def_prop_rw("lang", nb::overload_cast<>(&ResourceDialog::lang, nb::const_), - nb::overload_cast(&ResourceDialog::lang), - "Primary " RST_CLASS_REF(lief.PE.RESOURCE_LANGS) " associated with the dialog"_doc) + nb::overload_cast(&ResourceDialog::lang), + "Primary language associated with the dialog"_doc) .def_prop_rw("sub_lang", nb::overload_cast<>(&ResourceDialog::sub_lang, nb::const_), - nb::overload_cast(&ResourceDialog::sub_lang), - "Secondary " RST_CLASS_REF(lief.PE.RESOURCE_SUBLANGS) " associated with the dialog"_doc) + nb::overload_cast(&ResourceDialog::sub_lang), + "Secondary language associated with the dialog"_doc) LIEF_DEFAULT_STR(ResourceDialog); } diff --git a/api/python/src/PE/objects/resources/pyResourceIcon.cpp b/api/python/src/PE/objects/resources/pyResourceIcon.cpp index 112e99e5d9..150b0740c8 100644 --- a/api/python/src/PE/objects/resources/pyResourceIcon.cpp +++ b/api/python/src/PE/objects/resources/pyResourceIcon.cpp @@ -35,13 +35,13 @@ void create(nb::module_& m) { .def_prop_rw("lang", nb::overload_cast<>(&ResourceIcon::lang, nb::const_), - nb::overload_cast(&ResourceIcon::lang), - "Language (" RST_CLASS_REF(lief.PE.RESOURCE_LANGS) ") associated with the icon"_doc) + nb::overload_cast(&ResourceIcon::lang), + "Language associated with the icon"_doc) .def_prop_rw("sublang", nb::overload_cast<>(&ResourceIcon::sublang, nb::const_), - nb::overload_cast(&ResourceIcon::sublang), - "Sub language (" RST_CLASS_REF(lief.PE.RESOURCE_SUBLANGS) ") associated with the icon"_doc) + nb::overload_cast(&ResourceIcon::sublang), + "Sublanguage associated with the icon"_doc) .def_prop_rw("width", nb::overload_cast<>(&ResourceIcon::width, nb::const_), diff --git a/doc/sphinx/api/cpp/pe.rst b/doc/sphinx/api/cpp/pe.rst index b858ecea13..f4c7cdb076 100644 --- a/doc/sphinx/api/cpp/pe.rst +++ b/doc/sphinx/api/cpp/pe.rst @@ -651,15 +651,6 @@ Enums .. doxygenenum:: LIEF::PE::RELOCATIONS_ARM :project: lief -.. doxygenenum:: LIEF::PE::RESOURCE_TYPES - :project: lief - -.. doxygenenum:: LIEF::PE::RESOURCE_LANGS - :project: lief - -.. doxygenenum:: LIEF::PE::RESOURCE_SUBLANGS - :project: lief - .. doxygenenum:: LIEF::PE::CODE_PAGES :project: lief diff --git a/doc/sphinx/api/python/pe.rst b/doc/sphinx/api/python/pe.rst index 9ddf158556..b8fb22739c 100644 --- a/doc/sphinx/api/python/pe.rst +++ b/doc/sphinx/api/python/pe.rst @@ -551,27 +551,6 @@ RELOCATIONS_BASE_TYPES ---------- -RESOURCE_TYPES -~~~~~~~~~~~~~~ - -.. autoclass:: lief.PE.RESOURCE_TYPES - ----------- - -RESOURCE_LANGS -~~~~~~~~~~~~~~ - -.. autoclass:: lief.PE.RESOURCE_LANGS - ----------- - -RESOURCE_SUBLANGS -~~~~~~~~~~~~~~~~~ - -.. autoclass:: lief.PE.RESOURCE_SUBLANGS - ----------- - FIXED_VERSION_FILE_SUB_TYPES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -621,6 +600,13 @@ FIXED_VERSION_FILE_TYPES ---------- +RESOURCE_LANGS +~~~~~~~~~~~~~~ + +.. autoclass:: lief.PE.RESOURCE_LANGS + +----------- + FIXED_VERSION_FILE_SUB_TYPES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/sphinx/changelog.rst b/doc/sphinx/changelog.rst index 91d5d0e98d..9e91d89e81 100644 --- a/doc/sphinx/changelog.rst +++ b/doc/sphinx/changelog.rst @@ -53,6 +53,9 @@ Changelog (instead of `lief.MachO.Binary.name`) :PE: + * ``RESOURCE_SUBLANGS`` has been removed + * ``RESOURCE_LANGS`` is now defined in a dedicated header: ``LIEF/PE/resources/langs.hpp`` + * ``RESOURCE_TYPES`` is now scoped in ``ResourcesManager::TYPE`` * ``GUARD_CF_FLAGS`` is now scoped as :class:`~lief.PE.LoadConfigurationV1.IMAGE_GUARD` in :class:`lief.PE.LoadConfigurationV1` * ``SECTION_CHARACTERISTICS`` is now scoped within the diff --git a/doc/sphinx/tutorials/07_pe_resource.rst b/doc/sphinx/tutorials/07_pe_resource.rst index bacb80cc43..b9ee4afd1c 100644 --- a/doc/sphinx/tutorials/07_pe_resource.rst +++ b/doc/sphinx/tutorials/07_pe_resource.rst @@ -15,7 +15,8 @@ executable or a DLL. These resources are usually located in the ``.rsrc`` section but this is not an absolute rule. -To retrieve the section in which resources are located, one can use the :attr:`~lief.PE.DataDirectory.section` attribute of the associated :class:`~lief.PE.DataDirectory` +To retrieve the section in which resources are located, one can use the :attr:`~lief.PE.DataDirectory.section` +attribute of the associated :class:`~lief.PE.DataDirectory` .. code-block:: python @@ -44,9 +45,9 @@ In the resource tree we basically have two kinds of node: The first 3 levels of the tree have a special meaning: -* Level 1: The :attr:`~lief.PE.ResourceDirectory.id` represents the :class:`~lief.PE.RESOURCE_TYPES` +* Level 1: The :attr:`~lief.PE.ResourceDirectory.id` represents the :class:`~lief.PE.ResourcesManager.TYPE` * Level 2: The :attr:`~lief.PE.ResourceDirectory.id` represents an ID to access to the resource -* Level 3: The :attr:`~lief.PE.ResourceDirectory.id` represents the :class:`~lief.PE.RESOURCE_LANGS` / :class:`~lief.PE.RESOURCE_SUBLANGS` of the resource. +* Level 3: The :attr:`~lief.PE.ResourceDirectory.id` represents the :class:`~lief.PE.RESOURCE_LANGS` / SUBLANG of the resource. We can check that a given binary embed resources with the :attr:`~lief.PE.Binary.has_resources` property, then we can access to this structure @@ -54,7 +55,7 @@ through the :attr:`~lief.PE.Binary.resources` property which returns a :class:`~ Given a :class:`~lief.PE.ResourceDirectory`, the :attr:`~lief.PE.ResourceDirectory.childs` property returns an **iterator** (quiet similar to a ``list``) over the sub tree associated with the node. -The following snippet retrieves the :attr:`~lief.PE.RESOURCE_TYPES.MANIFEST` element and print it. +The following snippet retrieves the :attr:`~lief.PE.ResourcesManager.TYPE.MANIFEST` element and print it. .. code-block:: python @@ -67,7 +68,7 @@ The following snippet retrieves the :attr:`~lief.PE.RESOURCE_TYPES.MANIFEST` ele root = filezilla.resources # First level => Type ((ResourceDirectory node) - manifest_node = next(i for i in root.childs if i.id == lief.PE.RESOURCE_TYPES.MANIFEST) + manifest_node = next(i for i in root.childs if i.id == lief.PE.ResourcesManager.TYPE.MANIFEST) print(manifest_node) # Second level => ID (ResourceDirectory node) @@ -122,7 +123,7 @@ Resource Manager As mentioned previously, the :class:`~lief.PE.ResourcesManager` is a kind of wrapper over the resource tree to: * Parse resources that have a predefined structures like - :attr:`~lief.PE.RESOURCE_TYPES.MANIFEST`, :attr:`~lief.PE.RESOURCE_TYPES.ICON`, :attr:`~lief.PE.RESOURCE_TYPES.VERSION` ... + :attr:`~lief.PE.ResourcesManager.TYPE.MANIFEST`, :attr:`~lief.PE.ResourcesManager.TYPE.ICON`, :attr:`~lief.PE.ResourcesManager.TYPE.VERSION` ... * Access and modify these structures This can be summarize with the following diagram: @@ -143,7 +144,7 @@ The :class:`~lief.PE.ResourcesManager` can be accessed with the :attr:`~lief.PE. .. literalinclude:: ../_static/tutorial/07/resource_manager_output.txt -Similarly to the previous example, accessing to the :attr:`~lief.PE.RESOURCE_TYPES.MANIFEST` element is as simple as: +Similarly to the previous example, accessing to the :attr:`~lief.PE.ResourcesManager.TYPE.MANIFEST` element is as simple as: .. code-block:: python diff --git a/include/LIEF/PE/EnumToString.hpp b/include/LIEF/PE/EnumToString.hpp index 6dbbff2dd2..7646c26ce4 100644 --- a/include/LIEF/PE/EnumToString.hpp +++ b/include/LIEF/PE/EnumToString.hpp @@ -42,9 +42,6 @@ enum class RELOCATIONS_AMD64 : size_t; enum class RELOCATIONS_ARM : size_t; enum class RELOCATIONS_BASE_TYPES : size_t; enum class RELOCATIONS_I386 : size_t; -enum class RESOURCE_LANGS : size_t; -enum class RESOURCE_SUBLANGS : size_t; -enum class RESOURCE_TYPES : size_t; enum class SUBSYSTEM : size_t; enum class SYMBOL_BASE_TYPES : size_t; enum class SYMBOL_COMPLEX_TYPES : size_t; @@ -64,9 +61,6 @@ LIEF_API const char* to_string(RELOCATIONS_I386 e); LIEF_API const char* to_string(RELOCATIONS_AMD64 e); LIEF_API const char* to_string(RELOCATIONS_ARM e); -LIEF_API const char* to_string(RESOURCE_TYPES e); -LIEF_API const char* to_string(RESOURCE_LANGS e); -LIEF_API const char* to_string(RESOURCE_SUBLANGS e); LIEF_API const char* to_string(CODE_PAGES e); LIEF_API const char* to_string(EXTENDED_WINDOW_STYLES e); diff --git a/include/LIEF/PE/ResourceNode.hpp b/include/LIEF/PE/ResourceNode.hpp index 1571787b9b..55d3f50050 100644 --- a/include/LIEF/PE/ResourceNode.hpp +++ b/include/LIEF/PE/ResourceNode.hpp @@ -45,8 +45,7 @@ class LIEF_API ResourceNode : public Object { using it_childs = ref_iterator; using it_const_childs = const_ref_iterator; - //! Enum that identifies the type of a node in - //! the resource tree + /// Enum that identifies the type of a node in the resource tree enum class TYPE { UNKNOWN = 0, DATA, diff --git a/include/LIEF/PE/ResourcesManager.hpp b/include/LIEF/PE/ResourcesManager.hpp index ecbb22a888..284f72e583 100644 --- a/include/LIEF/PE/ResourcesManager.hpp +++ b/include/LIEF/PE/ResourcesManager.hpp @@ -17,8 +17,6 @@ #ifndef LIEF_PE_RESOURCES_MANAGER_H #define LIEF_PE_RESOURCES_MANAGER_H #include -#include -#include #include "LIEF/errors.hpp" #include "LIEF/visibility.h" @@ -39,10 +37,40 @@ class ResourceNode; //! The Resource Manager provides an enhanced API to manipulate the resource tree. class LIEF_API ResourcesManager : public Object { public: - static RESOURCE_SUBLANGS sub_lang(RESOURCE_LANGS lang, size_t index); - static RESOURCE_LANGS lang_from_id(size_t id); - static RESOURCE_SUBLANGS sublang_from_id(size_t id); + /// The different types of resources + /// Ref: From https://docs.microsoft.com/en-us/windows/win32/menurc/resource-types + enum class TYPE { + CURSOR = 1, + BITMAP = 2, + ICON = 3, + MENU = 4, + DIALOG = 5, + STRING = 6, + FONTDIR = 7, + FONT = 8, + ACCELERATOR = 9, + RCDATA = 10, + MESSAGETABLE = 11, + GROUP_CURSOR = 12, + GROUP_ICON = 14, + VERSION = 16, + DLGINCLUDE = 17, + PLUGPLAY = 19, + VXD = 20, + ANICURSOR = 21, + ANIICON = 22, + HTML = 23, + MANIFEST = 24 + }; + + static constexpr uint32_t lang_from_id(size_t id) { + return id & 0x3ff; + } + + static constexpr uint32_t sublang_from_id(size_t id) { + return id >> 10; + } public: using dialogs_t = std::vector; @@ -58,35 +86,35 @@ class LIEF_API ResourcesManager : public Object { using it_const_accelerators = const_ref_iterator; ResourcesManager() = delete; - ResourcesManager(ResourceNode& rsrc); + ResourcesManager(ResourceNode& rsrc) : + resources_{&rsrc} + {} - ResourcesManager(const ResourcesManager&); - ResourcesManager& operator=(const ResourcesManager&); + ResourcesManager(const ResourcesManager&) = default; + ResourcesManager& operator=(const ResourcesManager&) = default; - ResourcesManager(ResourcesManager&&); - ResourcesManager& operator=(ResourcesManager&&); + ResourcesManager(ResourcesManager&&) = default; + ResourcesManager& operator=(ResourcesManager&&) = default; - ~ResourcesManager() override; + ~ResourcesManager() override = default; - //! Return the ResourceNode associated with the given LIEF::PE::RESOURCE_TYPES + //! Return the ResourceNode associated with the given KIND //! or a nullptr if not found; - ResourceNode* get_node_type(RESOURCE_TYPES type); - const ResourceNode* get_node_type(RESOURCE_TYPES type) const; + ResourceNode* get_node_type(TYPE type); + const ResourceNode* get_node_type(TYPE type) const; - //! List of LIEF::PE::RESOURCE_TYPES present in the resources - std::set get_types_available() const; + //! List of TYPE present in the resources + std::vector get_types() const; - //! List of LIEF::PE::RESOURCE_LANGS present in the resources - std::set get_langs_available() const; - - //! List of LIEF::PE::RESOURCE_SUBLANGS present in the resources - std::set get_sublangs_available() const; - - //! ``true`` if the resource has the given LIEF::PE::RESOURCE_TYPES - bool has_type(RESOURCE_TYPES type) const; + //! ``true`` if the resource has the given LIEF::PE::KIND + bool has_type(TYPE type) const { + return get_node_type(type) != nullptr; + } //! ``true`` if resources contain the Manifest element - bool has_manifest() const; + bool has_manifest() const { + return get_node_type(TYPE::MANIFEST) != nullptr; + } //! Return the manifest as a std::string or an empty string if not found //! or corrupted @@ -96,13 +124,18 @@ class LIEF_API ResourcesManager : public Object { void manifest(const std::string& manifest); //! ``true`` if resources contain a LIEF::PE::ResourceVersion - bool has_version() const; + bool has_version() const { + return get_node_type(TYPE::VERSION) != nullptr; + } //! Return the ResourceVersion if any result version() const; //! ``true`` if resources contain a LIEF::PE::ResourceIcon - bool has_icons() const; + bool has_icons() const { + return get_node_type(TYPE::ICON) != nullptr && + get_node_type(TYPE::GROUP_ICON) != nullptr; + } //! Return the list of the icons present in the resources it_const_icons icons() const; @@ -110,36 +143,36 @@ class LIEF_API ResourcesManager : public Object { //! Add an icon to the resources void add_icon(const ResourceIcon& icon); - //void remove_icon(const ResourceIcon& icon) - void change_icon(const ResourceIcon& original, const ResourceIcon& newone); //! ``true`` if resources contain @link LIEF::PE::ResourceDialog dialogs @endlink - bool has_dialogs() const; + bool has_dialogs() const { + return get_node_type(TYPE::DIALOG) != nullptr; + } //! Return the list of the dialogs present in the resource it_const_dialogs dialogs() const; //! ``true`` if the resources contain a @link LIEF::PE::ResourceStringTable @endlink - bool has_string_table() const; + bool has_string_table() const { + return get_node_type(TYPE::STRING) != nullptr; + } //! Return the list of the string table in the resource it_const_strings_table string_table() const; - // HTML - // ==== - //! ``true`` if the resources contain html - bool has_html() const; + bool has_html() const { + return get_node_type(TYPE::HTML) != nullptr; + } //! Return the list of the html resources std::vector html() const; - // Accelerator - // ===== - //! ``true`` if the resources contain @link LIEF::PE::ResourceAccelerator @endlink - bool has_accelerator() const; + bool has_accelerator() const { + return get_node_type(TYPE::ACCELERATOR) != nullptr; + } //! Return the list of the accelerator in the resource it_const_accelerators accelerator() const; @@ -149,7 +182,6 @@ class LIEF_API ResourcesManager : public Object { void accept(Visitor& visitor) const override; - LIEF_API friend std::ostream& operator<<(std::ostream& os, const ResourcesManager& m); private: @@ -158,6 +190,8 @@ class LIEF_API ResourcesManager : public Object { ResourceNode* resources_ = nullptr; }; +LIEF_API const char* to_string(ResourcesManager::TYPE type); + } // namespace PE } // namespace LIEF diff --git a/include/LIEF/PE/enums.hpp b/include/LIEF/PE/enums.hpp index ab16b1c5ab..8778094b75 100644 --- a/include/LIEF/PE/enums.hpp +++ b/include/LIEF/PE/enums.hpp @@ -222,375 +222,6 @@ enum class CodeViewIdentifiers: size_t { }; -// -// Resources -// - -//! From https://docs.microsoft.com/en-us/windows/win32/menurc/resource-types -enum class RESOURCE_TYPES: size_t { - CURSOR = 1, - BITMAP = 2, - ICON = 3, - MENU = 4, - DIALOG = 5, - STRING = 6, - FONTDIR = 7, - FONT = 8, - ACCELERATOR = 9, - RCDATA = 10, - MESSAGETABLE = 11, - GROUP_CURSOR = 12, - GROUP_ICON = 14, - VERSION = 16, - DLGINCLUDE = 17, - PLUGPLAY = 19, - VXD = 20, - ANICURSOR = 21, - ANIICON = 22, - HTML = 23, - MANIFEST = 24 -}; - -enum class RESOURCE_LANGS: size_t { - LANG_NEUTRAL = 0x00, - LANG_INVARIANT = 0x7f, - LANG_AFRIKAANS = 0x36, - LANG_ALBANIAN = 0x1c, - LANG_ARABIC = 0x01, - LANG_ARMENIAN = 0x2b, - LANG_ASSAMESE = 0x4d, - LANG_AZERI = 0x2c, - LANG_BASQUE = 0x2d, - LANG_BELARUSIAN = 0x23, - LANG_BANGLA = 0x45, - LANG_BULGARIAN = 0x02, - LANG_CATALAN = 0x03, - LANG_CHINESE = 0x04, - LANG_CROATIAN = 0x1a, - LANG_BOSNIAN = 0x1a, - LANG_CZECH = 0x05, - LANG_DANISH = 0x06, - LANG_DIVEHI = 0x65, - LANG_DUTCH = 0x13, - LANG_ENGLISH = 0x09, - LANG_ESTONIAN = 0x25, - LANG_FAEROESE = 0x38, - LANG_FARSI = 0x29, - LANG_FINNISH = 0x0b, - LANG_FRENCH = 0x0c, - LANG_GALICIAN = 0x56, - LANG_GEORGIAN = 0x37, - LANG_GERMAN = 0x07, - LANG_GREEK = 0x08, - LANG_GUJARATI = 0x47, - LANG_HEBREW = 0x0d, - LANG_HINDI = 0x39, - LANG_HUNGARIAN = 0x0e, - LANG_ICELANDIC = 0x0f, - LANG_INDONESIAN = 0x21, - LANG_ITALIAN = 0x10, - LANG_JAPANESE = 0x11, - LANG_KANNADA = 0x4b, - LANG_KASHMIRI = 0x60, - LANG_KAZAK = 0x3f, - LANG_KONKANI = 0x57, - LANG_KOREAN = 0x12, - LANG_KYRGYZ = 0x40, - LANG_LATVIAN = 0x26, - LANG_LITHUANIAN = 0x27, - LANG_MACEDONIAN = 0x2f, - LANG_MALAY = 0x3e, - LANG_MALAYALAM = 0x4c, - LANG_MANIPURI = 0x58, - LANG_MARATHI = 0x4e, - LANG_MONGOLIAN = 0x50, - LANG_NEPALI = 0x61, - LANG_NORWEGIAN = 0x14, - LANG_ORIYA = 0x48, - LANG_POLISH = 0x15, - LANG_PORTUGUESE = 0x16, - LANG_PUNJABI = 0x46, - LANG_ROMANIAN = 0x18, - LANG_RUSSIAN = 0x19, - LANG_SANSKRIT = 0x4f, - LANG_SERBIAN = 0x1a, - LANG_SINDHI = 0x59, - LANG_SLOVAK = 0x1b, - LANG_SLOVENIAN = 0x24, - LANG_SPANISH = 0x0a, - LANG_SWAHILI = 0x41, - LANG_SWEDISH = 0x1d, - LANG_SYRIAC = 0x5a, - LANG_TAMIL = 0x49, - LANG_TATAR = 0x44, - LANG_TELUGU = 0x4a, - LANG_THAI = 0x1e, - LANG_TURKISH = 0x1f, - LANG_UKRAINIAN = 0x22, - LANG_URDU = 0x20, - LANG_UZBEK = 0x43, - LANG_VIETNAMESE = 0x2a, - LANG_GAELIC = 0x3c, - LANG_MALTESE = 0x3a, - LANG_MAORI = 0x28, - LANG_RHAETO_ROMANCE = 0x17, - LANG_SAMI = 0x3b, - LANG_SORBIAN = 0x2e, - LANG_SUTU = 0x30, - LANG_TSONGA = 0x31, - LANG_TSWANA = 0x32, - LANG_VENDA = 0x33, - LANG_XHOSA = 0x34, - LANG_ZULU = 0x35, - LANG_ESPERANTO = 0x8f, - LANG_WALON = 0x90, - LANG_CORNISH = 0x91, - LANG_WELSH = 0x92, - LANG_BRETON = 0x93, - LANG_INUKTITUT = 0x5d, - LANG_IRISH = 0x3C, - LANG_LOWER_SORBIAN = 0x2E, - LANG_PULAR = 0x67, - LANG_QUECHUA = 0x6B, - LANG_TAMAZIGHT = 0x5F, - LANG_TIGRINYA = 0x73, - LANG_VALENCIAN = 0x03, -}; - -enum class RESOURCE_SUBLANGS: size_t { - SUBLANG_AFRIKAANS_SOUTH_AFRICA = 0, - SUBLANG_ALBANIAN_ALBANIA, - SUBLANG_ALSATIAN_FRANCE, - SUBLANG_AMHARIC_ETHIOPIA, - SUBLANG_ARABIC_ALGERIA, - SUBLANG_ARABIC_BAHRAIN, - SUBLANG_ARABIC_EGYPT, - SUBLANG_ARABIC_IRAQ, - SUBLANG_ARABIC_JORDAN, - SUBLANG_ARABIC_KUWAIT, - SUBLANG_ARABIC_LEBANON, - SUBLANG_ARABIC_LIBYA, - SUBLANG_ARABIC_MOROCCO, - SUBLANG_ARABIC_OMAN, - SUBLANG_ARABIC_QATAR, - SUBLANG_ARABIC_SAUDI_ARABIA, - SUBLANG_ARABIC_SYRIA, - SUBLANG_ARABIC_TUNISIA, - SUBLANG_ARABIC_UAE, - SUBLANG_ARABIC_YEMEN, - SUBLANG_ARMENIAN_ARMENIA, - SUBLANG_ASSAMESE_INDIA, - SUBLANG_AZERI_CYRILLIC, - SUBLANG_AZERI_LATIN, - SUBLANG_BASHKIR_RUSSIA, - SUBLANG_BASQUE_BASQUE, - SUBLANG_BELARUSIAN_BELARUS, - SUBLANG_BANGLA_BANGLADESH, - SUBLANG_BANGLA_INDIA, - SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC, - SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN, - SUBLANG_BRETON_FRANCE, - SUBLANG_BULGARIAN_BULGARIA, - SUBLANG_CATALAN_CATALAN, - SUBLANG_CHINESE_HONGKONG, - SUBLANG_CHINESE_MACAU, - SUBLANG_CHINESE_SIMPLIFIED, - SUBLANG_CHINESE_SINGAPORE, - SUBLANG_CHINESE_TRADITIONAL, - SUBLANG_CORSICAN_FRANCE, - SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN, - SUBLANG_CROATIAN_CROATIA, - SUBLANG_CUSTOM_DEFAULT, - SUBLANG_CUSTOM_UNSPECIFIED, - SUBLANG_CZECH_CZECH_REPUBLIC, - SUBLANG_DANISH_DENMARK, - SUBLANG_DARI_AFGHANISTAN, - SUBLANG_DEFAULT, - SUBLANG_DIVEHI_MALDIVES, - SUBLANG_DUTCH_BELGIAN, - SUBLANG_DUTCH, - SUBLANG_ENGLISH_AUS, - SUBLANG_ENGLISH_BELIZE, - SUBLANG_ENGLISH_CAN, - SUBLANG_ENGLISH_CARIBBEAN, - SUBLANG_ENGLISH_EIRE, - SUBLANG_ENGLISH_INDIA, - SUBLANG_ENGLISH_JAMAICA, - SUBLANG_ENGLISH_MALAYSIA, - SUBLANG_ENGLISH_NZ, - SUBLANG_ENGLISH_PHILIPPINES, - SUBLANG_ENGLISH_SINGAPORE, - SUBLANG_ENGLISH_SOUTH_AFRICA, - SUBLANG_ENGLISH_TRINIDAD, - SUBLANG_ENGLISH_UK, - SUBLANG_ENGLISH_US, - SUBLANG_ENGLISH_ZIMBABWE, - SUBLANG_ENGLISH_IRELAND, - SUBLANG_ESTONIAN_ESTONIA, - SUBLANG_FAEROESE_FAROE_ISLANDS, - SUBLANG_FILIPINO_PHILIPPINES, - SUBLANG_FINNISH_FINLAND, - SUBLANG_FRENCH_BELGIAN, - SUBLANG_FRENCH_CANADIAN, - SUBLANG_FRENCH_LUXEMBOURG, - SUBLANG_FRENCH_MONACO, - SUBLANG_FRENCH_SWISS, - SUBLANG_FRENCH, - SUBLANG_FRISIAN_NETHERLANDS, - SUBLANG_GALICIAN_GALICIAN, - SUBLANG_GEORGIAN_GEORGIA, - SUBLANG_GERMAN_AUSTRIAN, - SUBLANG_GERMAN_LIECHTENSTEIN, - SUBLANG_GERMAN_LUXEMBOURG, - SUBLANG_GERMAN_SWISS, - SUBLANG_GERMAN, - SUBLANG_GREEK_GREECE, - SUBLANG_GREENLANDIC_GREENLAND, - SUBLANG_GUJARATI_INDIA, - SUBLANG_HAUSA_NIGERIA_LATIN, - SUBLANG_HEBREW_ISRAEL, - SUBLANG_HINDI_INDIA, - SUBLANG_HUNGARIAN_HUNGARY, - SUBLANG_ICELANDIC_ICELAND, - SUBLANG_IGBO_NIGERIA, - SUBLANG_INDONESIAN_INDONESIA, - SUBLANG_INUKTITUT_CANADA_LATIN, - SUBLANG_INUKTITUT_CANADA, - SUBLANG_IRISH_IRELAND, - SUBLANG_ITALIAN_SWISS, - SUBLANG_ITALIAN, - SUBLANG_JAPANESE_JAPAN, - SUBLANG_KANNADA_INDIA, - SUBLANG_KASHMIRI_INDIA, - SUBLANG_KASHMIRI_SASIA, - SUBLANG_KAZAK_KAZAKHSTAN, - SUBLANG_KHMER_CAMBODIA, - SUBLANG_KICHE_GUATEMALA, - SUBLANG_KINYARWANDA_RWANDA, - SUBLANG_KONKANI_INDIA, - SUBLANG_KOREAN, - SUBLANG_KYRGYZ_KYRGYZSTAN, - SUBLANG_LAO_LAO, - SUBLANG_LATVIAN_LATVIA, - SUBLANG_LITHUANIAN_CLASSIC, - SUBLANG_LITHUANIAN, - SUBLANG_LOWER_SORBIAN_GERMANY, - SUBLANG_LUXEMBOURGISH_LUXEMBOURG, - SUBLANG_MACEDONIAN_MACEDONIA, - SUBLANG_MALAY_BRUNEI_DARUSSALAM, - SUBLANG_MALAY_MALAYSIA, - SUBLANG_MALAYALAM_INDIA, - SUBLANG_MALTESE_MALTA, - SUBLANG_MAORI_NEW_ZEALAND, - SUBLANG_MAPUDUNGUN_CHILE, - SUBLANG_MARATHI_INDIA, - SUBLANG_MOHAWK_MOHAWK, - SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA, - SUBLANG_MONGOLIAN_PRC, - SUBLANG_NEPALI_INDIA, - SUBLANG_NEPALI_NEPAL, - SUBLANG_NEUTRAL, - SUBLANG_NORWEGIAN_BOKMAL, - SUBLANG_NORWEGIAN_NYNORSK, - SUBLANG_OCCITAN_FRANCE, - SUBLANG_ORIYA_INDIA, - SUBLANG_PASHTO_AFGHANISTAN, - SUBLANG_PERSIAN_IRAN, - SUBLANG_POLISH_POLAND, - SUBLANG_PORTUGUESE_BRAZILIAN, - SUBLANG_PORTUGUESE, - SUBLANG_PUNJABI_INDIA, - SUBLANG_QUECHUA_BOLIVIA, - SUBLANG_QUECHUA_ECUADOR, - SUBLANG_QUECHUA_PERU, - SUBLANG_ROMANIAN_ROMANIA, - SUBLANG_ROMANSH_SWITZERLAND, - SUBLANG_RUSSIAN_RUSSIA, - SUBLANG_SAMI_INARI_FINLAND, - SUBLANG_SAMI_LULE_NORWAY, - SUBLANG_SAMI_LULE_SWEDEN, - SUBLANG_SAMI_NORTHERN_FINLAND, - SUBLANG_SAMI_NORTHERN_NORWAY, - SUBLANG_SAMI_NORTHERN_SWEDEN, - SUBLANG_SAMI_SKOLT_FINLAND, - SUBLANG_SAMI_SOUTHERN_NORWAY, - SUBLANG_SAMI_SOUTHERN_SWEDEN, - SUBLANG_SANSKRIT_INDIA, - SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC, - SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN, - SUBLANG_SERBIAN_CROATIA, - SUBLANG_SERBIAN_CYRILLIC, - SUBLANG_SERBIAN_LATIN, - SUBLANG_SINDHI_AFGHANISTAN, - SUBLANG_SINDHI_INDIA, - SUBLANG_SINDHI_PAKISTAN, - SUBLANG_SINHALESE_SRI_LANKA, - SUBLANG_SLOVAK_SLOVAKIA, - SUBLANG_SLOVENIAN_SLOVENIA, - SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA, - SUBLANG_SPANISH_ARGENTINA, - SUBLANG_SPANISH_BOLIVIA, - SUBLANG_SPANISH_CHILE, - SUBLANG_SPANISH_COLOMBIA, - SUBLANG_SPANISH_COSTA_RICA, - SUBLANG_SPANISH_DOMINICAN_REPUBLIC, - SUBLANG_SPANISH_ECUADOR, - SUBLANG_SPANISH_EL_SALVADOR, - SUBLANG_SPANISH_GUATEMALA, - SUBLANG_SPANISH_HONDURAS, - SUBLANG_SPANISH_MEXICAN, - SUBLANG_SPANISH_MODERN, - SUBLANG_SPANISH_NICARAGUA, - SUBLANG_SPANISH_PANAMA, - SUBLANG_SPANISH_PARAGUAY, - SUBLANG_SPANISH_PERU, - SUBLANG_SPANISH_PUERTO_RICO, - SUBLANG_SPANISH_URUGUAY, - SUBLANG_SPANISH_US, - SUBLANG_SPANISH_VENEZUELA, - SUBLANG_SPANISH, - SUBLANG_SWAHILI_KENYA, - SUBLANG_SWEDISH_FINLAND, - SUBLANG_SWEDISH, - SUBLANG_SYRIAC_SYRIA, - SUBLANG_SYS_DEFAULT, - SUBLANG_TAJIK_TAJIKISTAN, - SUBLANG_TAMAZIGHT_ALGERIA_LATIN, - SUBLANG_TAMIL_INDIA, - SUBLANG_TATAR_RUSSIA, - SUBLANG_TELUGU_INDIA, - SUBLANG_THAI_THAILAND, - SUBLANG_TIBETAN_PRC, - SUBLANG_TIGRIGNA_ERITREA, - SUBLANG_TSWANA_SOUTH_AFRICA, - SUBLANG_TURKISH_TURKEY, - SUBLANG_TURKMEN_TURKMENISTAN, - SUBLANG_UI_CUSTOM_DEFAULT, - SUBLANG_UIGHUR_PRC, - SUBLANG_UKRAINIAN_UKRAINE, - SUBLANG_UPPER_SORBIAN_GERMANY, - SUBLANG_URDU_INDIA, - SUBLANG_URDU_PAKISTAN, - SUBLANG_UZBEK_CYRILLIC, - SUBLANG_UZBEK_LATIN, - SUBLANG_VIETNAMESE_VIETNAM, - SUBLANG_WELSH_UNITED_KINGDOM, - SUBLANG_WOLOF_SENEGAL, - SUBLANG_XHOSA_SOUTH_AFRICA, - SUBLANG_YAKUT_RUSSIA, - SUBLANG_YI_PRC, - SUBLANG_YORUBA_NIGERIA, - SUBLANG_ZULU_SOUTH_AFRICA, - SUBLANG_PULAR_SENEGAL, - SUBLANG_PUNJABI_PAKISTAN, - SUBLANG_TSWANA_BOTSWANA, - SUBLANG_TAMIL_SRI_LANKA, - SUBLANG_TIGRINYA_ETHIOPIA, - SUBLANG_TIGRINYA_ERITREA, - SUBLANG_VALENCIAN_VALENCIA, -}; - - //! From https://docs.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles enum class EXTENDED_WINDOW_STYLES: size_t { WS_EX_DLGMODALFRAME = 0x00000001L, @@ -1100,363 +731,6 @@ enum class ALGORITHMS : uint32_t { SHA_512_ECDSA, }; -static const RESOURCE_TYPES resource_types_array[] = { - RESOURCE_TYPES::CURSOR, - RESOURCE_TYPES::BITMAP, - RESOURCE_TYPES::ICON, - RESOURCE_TYPES::MENU, - RESOURCE_TYPES::DIALOG, - RESOURCE_TYPES::STRING, - RESOURCE_TYPES::FONTDIR, - RESOURCE_TYPES::FONT, - RESOURCE_TYPES::ACCELERATOR, - RESOURCE_TYPES::RCDATA, - RESOURCE_TYPES::MESSAGETABLE, - RESOURCE_TYPES::GROUP_CURSOR, - RESOURCE_TYPES::GROUP_ICON, - RESOURCE_TYPES::VERSION, - RESOURCE_TYPES::DLGINCLUDE, - RESOURCE_TYPES::PLUGPLAY, - RESOURCE_TYPES::VXD, - RESOURCE_TYPES::ANICURSOR, - RESOURCE_TYPES::ANIICON, - RESOURCE_TYPES::HTML, - RESOURCE_TYPES::MANIFEST, -}; - -static const RESOURCE_LANGS resource_langs_array[] = { - RESOURCE_LANGS::LANG_NEUTRAL, - RESOURCE_LANGS::LANG_INVARIANT, - RESOURCE_LANGS::LANG_AFRIKAANS, - RESOURCE_LANGS::LANG_ALBANIAN, - RESOURCE_LANGS::LANG_ARABIC, - RESOURCE_LANGS::LANG_ARMENIAN, - RESOURCE_LANGS::LANG_ASSAMESE, - RESOURCE_LANGS::LANG_AZERI, - RESOURCE_LANGS::LANG_BASQUE, - RESOURCE_LANGS::LANG_BELARUSIAN, - RESOURCE_LANGS::LANG_BANGLA, - RESOURCE_LANGS::LANG_BULGARIAN, - RESOURCE_LANGS::LANG_CATALAN, - RESOURCE_LANGS::LANG_CHINESE, - RESOURCE_LANGS::LANG_CROATIAN, - RESOURCE_LANGS::LANG_BOSNIAN, - RESOURCE_LANGS::LANG_CZECH, - RESOURCE_LANGS::LANG_DANISH, - RESOURCE_LANGS::LANG_DIVEHI, - RESOURCE_LANGS::LANG_DUTCH, - RESOURCE_LANGS::LANG_ENGLISH, - RESOURCE_LANGS::LANG_ESTONIAN, - RESOURCE_LANGS::LANG_FAEROESE, - RESOURCE_LANGS::LANG_FARSI, - RESOURCE_LANGS::LANG_FINNISH, - RESOURCE_LANGS::LANG_FRENCH, - RESOURCE_LANGS::LANG_GALICIAN, - RESOURCE_LANGS::LANG_GEORGIAN, - RESOURCE_LANGS::LANG_GERMAN, - RESOURCE_LANGS::LANG_GREEK, - RESOURCE_LANGS::LANG_GUJARATI, - RESOURCE_LANGS::LANG_HEBREW, - RESOURCE_LANGS::LANG_HINDI, - RESOURCE_LANGS::LANG_HUNGARIAN, - RESOURCE_LANGS::LANG_ICELANDIC, - RESOURCE_LANGS::LANG_INDONESIAN, - RESOURCE_LANGS::LANG_ITALIAN, - RESOURCE_LANGS::LANG_JAPANESE, - RESOURCE_LANGS::LANG_KANNADA, - RESOURCE_LANGS::LANG_KASHMIRI, - RESOURCE_LANGS::LANG_KAZAK, - RESOURCE_LANGS::LANG_KONKANI, - RESOURCE_LANGS::LANG_KOREAN, - RESOURCE_LANGS::LANG_KYRGYZ, - RESOURCE_LANGS::LANG_LATVIAN, - RESOURCE_LANGS::LANG_LITHUANIAN, - RESOURCE_LANGS::LANG_MACEDONIAN, - RESOURCE_LANGS::LANG_MALAY, - RESOURCE_LANGS::LANG_MALAYALAM, - RESOURCE_LANGS::LANG_MANIPURI, - RESOURCE_LANGS::LANG_MARATHI, - RESOURCE_LANGS::LANG_MONGOLIAN, - RESOURCE_LANGS::LANG_NEPALI, - RESOURCE_LANGS::LANG_NORWEGIAN, - RESOURCE_LANGS::LANG_ORIYA, - RESOURCE_LANGS::LANG_POLISH, - RESOURCE_LANGS::LANG_PORTUGUESE, - RESOURCE_LANGS::LANG_PUNJABI, - RESOURCE_LANGS::LANG_ROMANIAN, - RESOURCE_LANGS::LANG_RUSSIAN, - RESOURCE_LANGS::LANG_SANSKRIT, - RESOURCE_LANGS::LANG_SERBIAN, - RESOURCE_LANGS::LANG_SINDHI, - RESOURCE_LANGS::LANG_SLOVAK, - RESOURCE_LANGS::LANG_SLOVENIAN, - RESOURCE_LANGS::LANG_SPANISH, - RESOURCE_LANGS::LANG_SWAHILI, - RESOURCE_LANGS::LANG_SWEDISH, - RESOURCE_LANGS::LANG_SYRIAC, - RESOURCE_LANGS::LANG_TAMIL, - RESOURCE_LANGS::LANG_TATAR, - RESOURCE_LANGS::LANG_TELUGU, - RESOURCE_LANGS::LANG_THAI, - RESOURCE_LANGS::LANG_TURKISH, - RESOURCE_LANGS::LANG_UKRAINIAN, - RESOURCE_LANGS::LANG_URDU, - RESOURCE_LANGS::LANG_UZBEK, - RESOURCE_LANGS::LANG_VIETNAMESE, - RESOURCE_LANGS::LANG_GAELIC, - RESOURCE_LANGS::LANG_MALTESE, - RESOURCE_LANGS::LANG_MAORI, - RESOURCE_LANGS::LANG_RHAETO_ROMANCE, - RESOURCE_LANGS::LANG_SAMI, - RESOURCE_LANGS::LANG_SORBIAN, - RESOURCE_LANGS::LANG_SUTU, - RESOURCE_LANGS::LANG_TSONGA, - RESOURCE_LANGS::LANG_TSWANA, - RESOURCE_LANGS::LANG_VENDA, - RESOURCE_LANGS::LANG_XHOSA, - RESOURCE_LANGS::LANG_ZULU, - RESOURCE_LANGS::LANG_ESPERANTO, - RESOURCE_LANGS::LANG_WALON, - RESOURCE_LANGS::LANG_CORNISH, - RESOURCE_LANGS::LANG_WELSH, - RESOURCE_LANGS::LANG_BRETON, - RESOURCE_LANGS::LANG_INUKTITUT, - RESOURCE_LANGS::LANG_IRISH, - RESOURCE_LANGS::LANG_LOWER_SORBIAN, - RESOURCE_LANGS::LANG_PULAR, - RESOURCE_LANGS::LANG_QUECHUA, - RESOURCE_LANGS::LANG_TAMAZIGHT, - RESOURCE_LANGS::LANG_TIGRINYA, - RESOURCE_LANGS::LANG_VALENCIAN, -}; - - -static const RESOURCE_SUBLANGS resource_sublangs_array[] = { - RESOURCE_SUBLANGS::SUBLANG_AFRIKAANS_SOUTH_AFRICA, - RESOURCE_SUBLANGS::SUBLANG_ALBANIAN_ALBANIA, - RESOURCE_SUBLANGS::SUBLANG_ALSATIAN_FRANCE, - RESOURCE_SUBLANGS::SUBLANG_AMHARIC_ETHIOPIA, - RESOURCE_SUBLANGS::SUBLANG_ARABIC_ALGERIA, - RESOURCE_SUBLANGS::SUBLANG_ARABIC_BAHRAIN, - RESOURCE_SUBLANGS::SUBLANG_ARABIC_EGYPT, - RESOURCE_SUBLANGS::SUBLANG_ARABIC_IRAQ, - RESOURCE_SUBLANGS::SUBLANG_ARABIC_JORDAN, - RESOURCE_SUBLANGS::SUBLANG_ARABIC_KUWAIT, - RESOURCE_SUBLANGS::SUBLANG_ARABIC_LEBANON, - RESOURCE_SUBLANGS::SUBLANG_ARABIC_LIBYA, - RESOURCE_SUBLANGS::SUBLANG_ARABIC_MOROCCO, - RESOURCE_SUBLANGS::SUBLANG_ARABIC_OMAN, - RESOURCE_SUBLANGS::SUBLANG_ARABIC_QATAR, - RESOURCE_SUBLANGS::SUBLANG_ARABIC_SAUDI_ARABIA, - RESOURCE_SUBLANGS::SUBLANG_ARABIC_SYRIA, - RESOURCE_SUBLANGS::SUBLANG_ARABIC_TUNISIA, - RESOURCE_SUBLANGS::SUBLANG_ARABIC_UAE, - RESOURCE_SUBLANGS::SUBLANG_ARABIC_YEMEN, - RESOURCE_SUBLANGS::SUBLANG_ARMENIAN_ARMENIA, - RESOURCE_SUBLANGS::SUBLANG_ASSAMESE_INDIA, - RESOURCE_SUBLANGS::SUBLANG_AZERI_CYRILLIC, - RESOURCE_SUBLANGS::SUBLANG_AZERI_LATIN, - RESOURCE_SUBLANGS::SUBLANG_BASHKIR_RUSSIA, - RESOURCE_SUBLANGS::SUBLANG_BASQUE_BASQUE, - RESOURCE_SUBLANGS::SUBLANG_BELARUSIAN_BELARUS, - RESOURCE_SUBLANGS::SUBLANG_BANGLA_BANGLADESH, - RESOURCE_SUBLANGS::SUBLANG_BANGLA_INDIA, - RESOURCE_SUBLANGS::SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC, - RESOURCE_SUBLANGS::SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN, - RESOURCE_SUBLANGS::SUBLANG_BRETON_FRANCE, - RESOURCE_SUBLANGS::SUBLANG_BULGARIAN_BULGARIA, - RESOURCE_SUBLANGS::SUBLANG_CATALAN_CATALAN, - RESOURCE_SUBLANGS::SUBLANG_CHINESE_HONGKONG, - RESOURCE_SUBLANGS::SUBLANG_CHINESE_MACAU, - RESOURCE_SUBLANGS::SUBLANG_CHINESE_SIMPLIFIED, - RESOURCE_SUBLANGS::SUBLANG_CHINESE_SINGAPORE, - RESOURCE_SUBLANGS::SUBLANG_CHINESE_TRADITIONAL, - RESOURCE_SUBLANGS::SUBLANG_CORSICAN_FRANCE, - RESOURCE_SUBLANGS::SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN, - RESOURCE_SUBLANGS::SUBLANG_CROATIAN_CROATIA, - RESOURCE_SUBLANGS::SUBLANG_CUSTOM_DEFAULT, - RESOURCE_SUBLANGS::SUBLANG_CUSTOM_UNSPECIFIED, - RESOURCE_SUBLANGS::SUBLANG_CZECH_CZECH_REPUBLIC, - RESOURCE_SUBLANGS::SUBLANG_DANISH_DENMARK, - RESOURCE_SUBLANGS::SUBLANG_DARI_AFGHANISTAN, - RESOURCE_SUBLANGS::SUBLANG_DEFAULT, - RESOURCE_SUBLANGS::SUBLANG_DIVEHI_MALDIVES, - RESOURCE_SUBLANGS::SUBLANG_DUTCH_BELGIAN, - RESOURCE_SUBLANGS::SUBLANG_DUTCH, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_AUS, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_BELIZE, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_CAN, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_CARIBBEAN, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_EIRE, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_INDIA, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_JAMAICA, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_MALAYSIA, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_NZ, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_PHILIPPINES, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_SINGAPORE, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_SOUTH_AFRICA, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_TRINIDAD, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_UK, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_US, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_ZIMBABWE, - RESOURCE_SUBLANGS::SUBLANG_ENGLISH_IRELAND, - RESOURCE_SUBLANGS::SUBLANG_ESTONIAN_ESTONIA, - RESOURCE_SUBLANGS::SUBLANG_FAEROESE_FAROE_ISLANDS, - RESOURCE_SUBLANGS::SUBLANG_FILIPINO_PHILIPPINES, - RESOURCE_SUBLANGS::SUBLANG_FINNISH_FINLAND, - RESOURCE_SUBLANGS::SUBLANG_FRENCH_BELGIAN, - RESOURCE_SUBLANGS::SUBLANG_FRENCH_CANADIAN, - RESOURCE_SUBLANGS::SUBLANG_FRENCH_LUXEMBOURG, - RESOURCE_SUBLANGS::SUBLANG_FRENCH_MONACO, - RESOURCE_SUBLANGS::SUBLANG_FRENCH_SWISS, - RESOURCE_SUBLANGS::SUBLANG_FRENCH, - RESOURCE_SUBLANGS::SUBLANG_FRISIAN_NETHERLANDS, - RESOURCE_SUBLANGS::SUBLANG_GALICIAN_GALICIAN, - RESOURCE_SUBLANGS::SUBLANG_GEORGIAN_GEORGIA, - RESOURCE_SUBLANGS::SUBLANG_GERMAN_AUSTRIAN, - RESOURCE_SUBLANGS::SUBLANG_GERMAN_LIECHTENSTEIN, - RESOURCE_SUBLANGS::SUBLANG_GERMAN_LUXEMBOURG, - RESOURCE_SUBLANGS::SUBLANG_GERMAN_SWISS, - RESOURCE_SUBLANGS::SUBLANG_GERMAN, - RESOURCE_SUBLANGS::SUBLANG_GREEK_GREECE, - RESOURCE_SUBLANGS::SUBLANG_GREENLANDIC_GREENLAND, - RESOURCE_SUBLANGS::SUBLANG_GUJARATI_INDIA, - RESOURCE_SUBLANGS::SUBLANG_HAUSA_NIGERIA_LATIN, - RESOURCE_SUBLANGS::SUBLANG_HEBREW_ISRAEL, - RESOURCE_SUBLANGS::SUBLANG_HINDI_INDIA, - RESOURCE_SUBLANGS::SUBLANG_HUNGARIAN_HUNGARY, - RESOURCE_SUBLANGS::SUBLANG_ICELANDIC_ICELAND, - RESOURCE_SUBLANGS::SUBLANG_IGBO_NIGERIA, - RESOURCE_SUBLANGS::SUBLANG_INDONESIAN_INDONESIA, - RESOURCE_SUBLANGS::SUBLANG_INUKTITUT_CANADA_LATIN, - RESOURCE_SUBLANGS::SUBLANG_INUKTITUT_CANADA, - RESOURCE_SUBLANGS::SUBLANG_IRISH_IRELAND, - RESOURCE_SUBLANGS::SUBLANG_ITALIAN_SWISS, - RESOURCE_SUBLANGS::SUBLANG_ITALIAN, - RESOURCE_SUBLANGS::SUBLANG_JAPANESE_JAPAN, - RESOURCE_SUBLANGS::SUBLANG_KANNADA_INDIA, - RESOURCE_SUBLANGS::SUBLANG_KASHMIRI_INDIA, - RESOURCE_SUBLANGS::SUBLANG_KASHMIRI_SASIA, - RESOURCE_SUBLANGS::SUBLANG_KAZAK_KAZAKHSTAN, - RESOURCE_SUBLANGS::SUBLANG_KHMER_CAMBODIA, - RESOURCE_SUBLANGS::SUBLANG_KICHE_GUATEMALA, - RESOURCE_SUBLANGS::SUBLANG_KINYARWANDA_RWANDA, - RESOURCE_SUBLANGS::SUBLANG_KONKANI_INDIA, - RESOURCE_SUBLANGS::SUBLANG_KOREAN, - RESOURCE_SUBLANGS::SUBLANG_KYRGYZ_KYRGYZSTAN, - RESOURCE_SUBLANGS::SUBLANG_LAO_LAO, - RESOURCE_SUBLANGS::SUBLANG_LATVIAN_LATVIA, - RESOURCE_SUBLANGS::SUBLANG_LITHUANIAN_CLASSIC, - RESOURCE_SUBLANGS::SUBLANG_LITHUANIAN, - RESOURCE_SUBLANGS::SUBLANG_LOWER_SORBIAN_GERMANY, - RESOURCE_SUBLANGS::SUBLANG_LUXEMBOURGISH_LUXEMBOURG, - RESOURCE_SUBLANGS::SUBLANG_MACEDONIAN_MACEDONIA, - RESOURCE_SUBLANGS::SUBLANG_MALAY_BRUNEI_DARUSSALAM, - RESOURCE_SUBLANGS::SUBLANG_MALAY_MALAYSIA, - RESOURCE_SUBLANGS::SUBLANG_MALAYALAM_INDIA, - RESOURCE_SUBLANGS::SUBLANG_MALTESE_MALTA, - RESOURCE_SUBLANGS::SUBLANG_MAORI_NEW_ZEALAND, - RESOURCE_SUBLANGS::SUBLANG_MAPUDUNGUN_CHILE, - RESOURCE_SUBLANGS::SUBLANG_MARATHI_INDIA, - RESOURCE_SUBLANGS::SUBLANG_MOHAWK_MOHAWK, - RESOURCE_SUBLANGS::SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA, - RESOURCE_SUBLANGS::SUBLANG_MONGOLIAN_PRC, - RESOURCE_SUBLANGS::SUBLANG_NEPALI_INDIA, - RESOURCE_SUBLANGS::SUBLANG_NEPALI_NEPAL, - RESOURCE_SUBLANGS::SUBLANG_NEUTRAL, - RESOURCE_SUBLANGS::SUBLANG_NORWEGIAN_BOKMAL, - RESOURCE_SUBLANGS::SUBLANG_NORWEGIAN_NYNORSK, - RESOURCE_SUBLANGS::SUBLANG_OCCITAN_FRANCE, - RESOURCE_SUBLANGS::SUBLANG_ORIYA_INDIA, - RESOURCE_SUBLANGS::SUBLANG_PASHTO_AFGHANISTAN, - RESOURCE_SUBLANGS::SUBLANG_PERSIAN_IRAN, - RESOURCE_SUBLANGS::SUBLANG_POLISH_POLAND, - RESOURCE_SUBLANGS::SUBLANG_PORTUGUESE_BRAZILIAN, - RESOURCE_SUBLANGS::SUBLANG_PORTUGUESE, - RESOURCE_SUBLANGS::SUBLANG_PUNJABI_INDIA, - RESOURCE_SUBLANGS::SUBLANG_QUECHUA_BOLIVIA, - RESOURCE_SUBLANGS::SUBLANG_QUECHUA_ECUADOR, - RESOURCE_SUBLANGS::SUBLANG_QUECHUA_PERU, - RESOURCE_SUBLANGS::SUBLANG_ROMANIAN_ROMANIA, - RESOURCE_SUBLANGS::SUBLANG_ROMANSH_SWITZERLAND, - RESOURCE_SUBLANGS::SUBLANG_RUSSIAN_RUSSIA, - RESOURCE_SUBLANGS::SUBLANG_SAMI_INARI_FINLAND, - RESOURCE_SUBLANGS::SUBLANG_SAMI_LULE_NORWAY, - RESOURCE_SUBLANGS::SUBLANG_SAMI_LULE_SWEDEN, - RESOURCE_SUBLANGS::SUBLANG_SAMI_NORTHERN_FINLAND, - RESOURCE_SUBLANGS::SUBLANG_SAMI_NORTHERN_NORWAY, - RESOURCE_SUBLANGS::SUBLANG_SAMI_NORTHERN_SWEDEN, - RESOURCE_SUBLANGS::SUBLANG_SAMI_SKOLT_FINLAND, - RESOURCE_SUBLANGS::SUBLANG_SAMI_SOUTHERN_NORWAY, - RESOURCE_SUBLANGS::SUBLANG_SAMI_SOUTHERN_SWEDEN, - RESOURCE_SUBLANGS::SUBLANG_SANSKRIT_INDIA, - RESOURCE_SUBLANGS::SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC, - RESOURCE_SUBLANGS::SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN, - RESOURCE_SUBLANGS::SUBLANG_SERBIAN_CROATIA, - RESOURCE_SUBLANGS::SUBLANG_SERBIAN_CYRILLIC, - RESOURCE_SUBLANGS::SUBLANG_SERBIAN_LATIN, - RESOURCE_SUBLANGS::SUBLANG_SINDHI_AFGHANISTAN, - RESOURCE_SUBLANGS::SUBLANG_SINDHI_INDIA, - RESOURCE_SUBLANGS::SUBLANG_SINDHI_PAKISTAN, - RESOURCE_SUBLANGS::SUBLANG_SINHALESE_SRI_LANKA, - RESOURCE_SUBLANGS::SUBLANG_SLOVAK_SLOVAKIA, - RESOURCE_SUBLANGS::SUBLANG_SLOVENIAN_SLOVENIA, - RESOURCE_SUBLANGS::SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_ARGENTINA, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_BOLIVIA, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_CHILE, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_COLOMBIA, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_COSTA_RICA, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_DOMINICAN_REPUBLIC, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_ECUADOR, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_EL_SALVADOR, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_GUATEMALA, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_HONDURAS, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_MEXICAN, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_MODERN, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_NICARAGUA, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_PANAMA, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_PARAGUAY, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_PERU, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_PUERTO_RICO, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_URUGUAY, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_US, - RESOURCE_SUBLANGS::SUBLANG_SPANISH_VENEZUELA, - RESOURCE_SUBLANGS::SUBLANG_SPANISH, - RESOURCE_SUBLANGS::SUBLANG_SWAHILI_KENYA, - RESOURCE_SUBLANGS::SUBLANG_SWEDISH_FINLAND, - RESOURCE_SUBLANGS::SUBLANG_SWEDISH, - RESOURCE_SUBLANGS::SUBLANG_SYRIAC_SYRIA, - RESOURCE_SUBLANGS::SUBLANG_SYS_DEFAULT, - RESOURCE_SUBLANGS::SUBLANG_TAJIK_TAJIKISTAN, - RESOURCE_SUBLANGS::SUBLANG_TAMAZIGHT_ALGERIA_LATIN, - RESOURCE_SUBLANGS::SUBLANG_TAMIL_INDIA, - RESOURCE_SUBLANGS::SUBLANG_TATAR_RUSSIA, - RESOURCE_SUBLANGS::SUBLANG_TELUGU_INDIA, - RESOURCE_SUBLANGS::SUBLANG_THAI_THAILAND, - RESOURCE_SUBLANGS::SUBLANG_TIBETAN_PRC, - RESOURCE_SUBLANGS::SUBLANG_TIGRIGNA_ERITREA, - RESOURCE_SUBLANGS::SUBLANG_TSWANA_SOUTH_AFRICA, - RESOURCE_SUBLANGS::SUBLANG_TURKISH_TURKEY, - RESOURCE_SUBLANGS::SUBLANG_TURKMEN_TURKMENISTAN, - RESOURCE_SUBLANGS::SUBLANG_UI_CUSTOM_DEFAULT, - RESOURCE_SUBLANGS::SUBLANG_UIGHUR_PRC, - RESOURCE_SUBLANGS::SUBLANG_UKRAINIAN_UKRAINE, - RESOURCE_SUBLANGS::SUBLANG_UPPER_SORBIAN_GERMANY, - RESOURCE_SUBLANGS::SUBLANG_URDU_INDIA, - RESOURCE_SUBLANGS::SUBLANG_URDU_PAKISTAN, - RESOURCE_SUBLANGS::SUBLANG_UZBEK_CYRILLIC, - RESOURCE_SUBLANGS::SUBLANG_UZBEK_LATIN, - RESOURCE_SUBLANGS::SUBLANG_VIETNAMESE_VIETNAM, - RESOURCE_SUBLANGS::SUBLANG_WELSH_UNITED_KINGDOM, - RESOURCE_SUBLANGS::SUBLANG_WOLOF_SENEGAL, - RESOURCE_SUBLANGS::SUBLANG_XHOSA_SOUTH_AFRICA, - RESOURCE_SUBLANGS::SUBLANG_YAKUT_RUSSIA, - RESOURCE_SUBLANGS::SUBLANG_YI_PRC, - RESOURCE_SUBLANGS::SUBLANG_YORUBA_NIGERIA, - RESOURCE_SUBLANGS::SUBLANG_ZULU_SOUTH_AFRICA, -}; - } } diff --git a/include/LIEF/PE/resources/LangCodeItem.hpp b/include/LIEF/PE/resources/LangCodeItem.hpp index faf830e9dc..5c4750bed3 100644 --- a/include/LIEF/PE/resources/LangCodeItem.hpp +++ b/include/LIEF/PE/resources/LangCodeItem.hpp @@ -67,10 +67,10 @@ class LIEF_API LangCodeItem : public Object { CODE_PAGES code_page() const; //! Lang for which LangCodeItem::items are defined - RESOURCE_LANGS lang() const; + uint32_t lang() const; //! Sublang for which LangCodeItem::items are defined - RESOURCE_SUBLANGS sublang() const; + uint32_t sublang() const; const items_t& items() const; items_t& items(); @@ -80,8 +80,8 @@ class LIEF_API LangCodeItem : public Object { void key(const std::string& key); void code_page(CODE_PAGES code_page); - void lang(RESOURCE_LANGS lang); - void sublang(RESOURCE_SUBLANGS lang); + void lang(uint32_t lang); + void sublang(uint32_t lang); void items(const items_t& items); diff --git a/include/LIEF/PE/resources/ResourceDialog.hpp b/include/LIEF/PE/resources/ResourceDialog.hpp index b3b6c672b1..6f31a58428 100644 --- a/include/LIEF/PE/resources/ResourceDialog.hpp +++ b/include/LIEF/PE/resources/ResourceDialog.hpp @@ -105,13 +105,13 @@ class LIEF_API ResourceDialog : public Object { it_const_items items() const; //! RESOURCE_LANGS associated with the Dialog - RESOURCE_LANGS lang() const; + uint32_t lang() const; //! RESOURCE_SUBLANGS associated with the Dialog - RESOURCE_SUBLANGS sub_lang() const; + uint32_t sub_lang() const; - void lang(RESOURCE_LANGS lang); - void sub_lang(RESOURCE_SUBLANGS sub_lang); + void lang(uint32_t lang); + void sub_lang(uint32_t sub_lang); // Extended API @@ -178,10 +178,8 @@ class LIEF_API ResourceDialog : public Object { items_t items_; - RESOURCE_LANGS lang_; - RESOURCE_SUBLANGS sublang_; - - + uint32_t lang_; + uint32_t sublang_; }; diff --git a/include/LIEF/PE/resources/ResourceIcon.hpp b/include/LIEF/PE/resources/ResourceIcon.hpp index cee4766371..5010b1b275 100644 --- a/include/LIEF/PE/resources/ResourceIcon.hpp +++ b/include/LIEF/PE/resources/ResourceIcon.hpp @@ -54,10 +54,10 @@ class LIEF_API ResourceIcon : public Object { uint32_t id() const; //! Language associated with the icon - RESOURCE_LANGS lang() const; + uint32_t lang() const; //! Sub language associated with the icon - RESOURCE_SUBLANGS sublang() const; + uint32_t sublang() const; //! Width in pixels of the image uint8_t width() const; @@ -84,8 +84,8 @@ class LIEF_API ResourceIcon : public Object { span pixels() const; void id(uint32_t id); - void lang(RESOURCE_LANGS lang); - void sublang(RESOURCE_SUBLANGS sublang); + void lang(uint32_t lang); + void sublang(uint32_t sublang); void width(uint8_t width); void height(uint8_t height); void color_count(uint8_t color_count); @@ -112,8 +112,8 @@ class LIEF_API ResourceIcon : public Object { uint16_t planes_ = 0; uint16_t bit_count_ = 0; uint32_t id_ = UINT_MAX; - RESOURCE_LANGS lang_ = RESOURCE_LANGS::LANG_NEUTRAL; - RESOURCE_SUBLANGS sublang_ = RESOURCE_SUBLANGS::SUBLANG_DEFAULT; + uint32_t lang_ = /* LANG_NEUTRAL */0; + uint32_t sublang_ = 0 /* SUBLANG_NEUTRAL */; std::vector pixels_; }; diff --git a/include/LIEF/PE/resources/ResourceVarFileInfo.hpp b/include/LIEF/PE/resources/ResourceVarFileInfo.hpp index 9bc85f7202..32a20a810c 100644 --- a/include/LIEF/PE/resources/ResourceVarFileInfo.hpp +++ b/include/LIEF/PE/resources/ResourceVarFileInfo.hpp @@ -81,12 +81,7 @@ class LIEF_API ResourceVarFileInfo : public Object { std::vector translations_; }; - - - - } } - #endif diff --git a/include/LIEF/PE/resources/langs.hpp b/include/LIEF/PE/resources/langs.hpp new file mode 100644 index 0000000000..929c51166e --- /dev/null +++ b/include/LIEF/PE/resources/langs.hpp @@ -0,0 +1,129 @@ +/* Copyright 2017 - 2023 R. Thomas + * Copyright 2017 - 2023 Quarkslab + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef LIEF_PE_RESOURCE_LANG_H +#define LIEF_PE_RESOURCE_LANG_H +namespace LIEF { +namespace PE { + +enum class RESOURCE_LANGS { + NEUTRAL = 0x00, + INVARIANT = 0x7f, + AFRIKAANS = 0x36, + ALBANIAN = 0x1c, + ARABIC = 0x01, + ARMENIAN = 0x2b, + ASSAMESE = 0x4d, + AZERI = 0x2c, + BASQUE = 0x2d, + BELARUSIAN = 0x23, + BANGLA = 0x45, + BULGARIAN = 0x02, + CATALAN = 0x03, + CHINESE = 0x04, + CROATIAN = 0x1a, + BOSNIAN = 0x1a, + CZECH = 0x05, + DANISH = 0x06, + DIVEHI = 0x65, + DUTCH = 0x13, + ENGLISH = 0x09, + ESTONIAN = 0x25, + FAEROESE = 0x38, + FARSI = 0x29, + FINNISH = 0x0b, + FRENCH = 0x0c, + GALICIAN = 0x56, + GEORGIAN = 0x37, + GERMAN = 0x07, + GREEK = 0x08, + GUJARATI = 0x47, + HEBREW = 0x0d, + HINDI = 0x39, + HUNGARIAN = 0x0e, + ICELANDIC = 0x0f, + INDONESIAN = 0x21, + ITALIAN = 0x10, + JAPANESE = 0x11, + KANNADA = 0x4b, + KASHMIRI = 0x60, + KAZAK = 0x3f, + KONKANI = 0x57, + KOREAN = 0x12, + KYRGYZ = 0x40, + LATVIAN = 0x26, + LITHUANIAN = 0x27, + MACEDONIAN = 0x2f, + MALAY = 0x3e, + MALAYALAM = 0x4c, + MANIPURI = 0x58, + MARATHI = 0x4e, + MONGOLIAN = 0x50, + NEPALI = 0x61, + NORWEGIAN = 0x14, + ORIYA = 0x48, + POLISH = 0x15, + PORTUGUESE = 0x16, + PUNJABI = 0x46, + ROMANIAN = 0x18, + RUSSIAN = 0x19, + SANSKRIT = 0x4f, + SERBIAN = 0x1a, + SINDHI = 0x59, + SLOVAK = 0x1b, + SLOVENIAN = 0x24, + SPANISH = 0x0a, + SWAHILI = 0x41, + SWEDISH = 0x1d, + SYRIAC = 0x5a, + TAMIL = 0x49, + TATAR = 0x44, + TELUGU = 0x4a, + THAI = 0x1e, + TURKISH = 0x1f, + UKRAINIAN = 0x22, + URDU = 0x20, + UZBEK = 0x43, + VIETNAMESE = 0x2a, + GAELIC = 0x3c, + MALTESE = 0x3a, + MAORI = 0x28, + RHAETO_ROMANCE = 0x17, + SAMI = 0x3b, + SORBIAN = 0x2e, + SUTU = 0x30, + TSONGA = 0x31, + TSWANA = 0x32, + VENDA = 0x33, + XHOSA = 0x34, + ZULU = 0x35, + ESPERANTO = 0x8f, + WALON = 0x90, + CORNISH = 0x91, + WELSH = 0x92, + BRETON = 0x93, + INUKTITUT = 0x5d, + IRISH = 0x3C, + LOWER_SORBIAN = 0x2E, + PULAR = 0x67, + QUECHUA = 0x6B, + TAMAZIGHT = 0x5F, + TIGRINYA = 0x73, + VALENCIAN = 0x03, +}; + +} +} +#endif diff --git a/include/LIEF/PE/undef.h b/include/LIEF/PE/undef.h index 50d16bce27..991d5d4abf 100644 --- a/include/LIEF/PE/undef.h +++ b/include/LIEF/PE/undef.h @@ -295,7 +295,6 @@ #undef IMAGE_SCN_MEM_READ #undef IMAGE_SCN_MEM_WRITE -#undef RESOURCE_TYPES #undef RESOURCE_LANGS diff --git a/src/PE/EnumToString.cpp b/src/PE/EnumToString.cpp index d8f4ea3b44..f9814afd37 100644 --- a/src/PE/EnumToString.cpp +++ b/src/PE/EnumToString.cpp @@ -227,381 +227,6 @@ const char* to_string(RELOCATIONS_BASE_TYPES e) { return it == enumStrings.end() ? "Out of range" : it->second; } - - -const char* to_string(RESOURCE_TYPES e) { - CONST_MAP(RESOURCE_TYPES, const char*, 21) enumStrings { - { RESOURCE_TYPES::CURSOR, "CURSOR" }, - { RESOURCE_TYPES::BITMAP, "BITMAP" }, - { RESOURCE_TYPES::ICON, "ICON" }, - { RESOURCE_TYPES::MENU, "MENU" }, - { RESOURCE_TYPES::DIALOG, "DIALOG" }, - { RESOURCE_TYPES::STRING, "STRING" }, - { RESOURCE_TYPES::FONTDIR, "FONTDIR" }, - { RESOURCE_TYPES::FONT, "FONT" }, - { RESOURCE_TYPES::ACCELERATOR, "ACCELERATOR" }, - { RESOURCE_TYPES::RCDATA, "RCDATA" }, - { RESOURCE_TYPES::MESSAGETABLE, "MESSAGETABLE" }, - { RESOURCE_TYPES::GROUP_CURSOR, "GROUP_CURSOR" }, - { RESOURCE_TYPES::GROUP_ICON, "GROUP_ICON" }, - { RESOURCE_TYPES::VERSION, "VERSION" }, - { RESOURCE_TYPES::DLGINCLUDE, "DLGINCLUDE" }, - { RESOURCE_TYPES::PLUGPLAY, "PLUGPLAY" }, - { RESOURCE_TYPES::VXD, "VXD" }, - { RESOURCE_TYPES::ANICURSOR, "ANICURSOR" }, - { RESOURCE_TYPES::ANIICON, "ANIICON" }, - { RESOURCE_TYPES::HTML, "HTML" }, - { RESOURCE_TYPES::MANIFEST, "MANIFEST" }, - }; - - const auto it = enumStrings.find(e); - return it == enumStrings.end() ? "Out of range" : it->second; -} - -const char* to_string(RESOURCE_LANGS e) { - CONST_MAP(RESOURCE_LANGS, const char*, 98) enumStrings { - { RESOURCE_LANGS::LANG_NEUTRAL, "NEUTRAL" }, - { RESOURCE_LANGS::LANG_INVARIANT, "INVARIANT" }, - { RESOURCE_LANGS::LANG_AFRIKAANS, "AFRIKAANS" }, - { RESOURCE_LANGS::LANG_ALBANIAN, "ALBANIAN" }, - { RESOURCE_LANGS::LANG_ARABIC, "ARABIC" }, - { RESOURCE_LANGS::LANG_ARMENIAN, "ARMENIAN" }, - { RESOURCE_LANGS::LANG_ASSAMESE, "ASSAMESE" }, - { RESOURCE_LANGS::LANG_AZERI, "AZERI" }, - { RESOURCE_LANGS::LANG_BASQUE, "BASQUE" }, - { RESOURCE_LANGS::LANG_BELARUSIAN, "BELARUSIAN" }, - { RESOURCE_LANGS::LANG_BANGLA, "BANGLA" }, - { RESOURCE_LANGS::LANG_BULGARIAN, "BULGARIAN" }, - { RESOURCE_LANGS::LANG_CATALAN, "CATALAN" }, - { RESOURCE_LANGS::LANG_CHINESE, "CHINESE" }, - { RESOURCE_LANGS::LANG_CROATIAN, "CROATIAN" }, - { RESOURCE_LANGS::LANG_CZECH, "CZECH" }, - { RESOURCE_LANGS::LANG_DANISH, "DANISH" }, - { RESOURCE_LANGS::LANG_DIVEHI, "DIVEHI" }, - { RESOURCE_LANGS::LANG_DUTCH, "DUTCH" }, - { RESOURCE_LANGS::LANG_ENGLISH, "ENGLISH" }, - { RESOURCE_LANGS::LANG_ESTONIAN, "ESTONIAN" }, - { RESOURCE_LANGS::LANG_FAEROESE, "FAEROESE" }, - { RESOURCE_LANGS::LANG_FARSI, "FARSI" }, - { RESOURCE_LANGS::LANG_FINNISH, "FINNISH" }, - { RESOURCE_LANGS::LANG_FRENCH, "FRENCH" }, - { RESOURCE_LANGS::LANG_GALICIAN, "GALICIAN" }, - { RESOURCE_LANGS::LANG_GEORGIAN, "GEORGIAN" }, - { RESOURCE_LANGS::LANG_GERMAN, "GERMAN" }, - { RESOURCE_LANGS::LANG_GREEK, "GREEK" }, - { RESOURCE_LANGS::LANG_GUJARATI, "GUJARATI" }, - { RESOURCE_LANGS::LANG_HEBREW, "HEBREW" }, - { RESOURCE_LANGS::LANG_HINDI, "HINDI" }, - { RESOURCE_LANGS::LANG_HUNGARIAN, "HUNGARIAN" }, - { RESOURCE_LANGS::LANG_ICELANDIC, "ICELANDIC" }, - { RESOURCE_LANGS::LANG_INDONESIAN, "INDONESIAN" }, - { RESOURCE_LANGS::LANG_ITALIAN, "ITALIAN" }, - { RESOURCE_LANGS::LANG_JAPANESE, "JAPANESE" }, - { RESOURCE_LANGS::LANG_KANNADA, "KANNADA" }, - { RESOURCE_LANGS::LANG_KASHMIRI, "KASHMIRI" }, - { RESOURCE_LANGS::LANG_KAZAK, "KAZAK" }, - { RESOURCE_LANGS::LANG_KONKANI, "KONKANI" }, - { RESOURCE_LANGS::LANG_KOREAN, "KOREAN" }, - { RESOURCE_LANGS::LANG_KYRGYZ, "KYRGYZ" }, - { RESOURCE_LANGS::LANG_LATVIAN, "LATVIAN" }, - { RESOURCE_LANGS::LANG_LITHUANIAN, "LITHUANIAN" }, - { RESOURCE_LANGS::LANG_MACEDONIAN, "MACEDONIAN" }, - { RESOURCE_LANGS::LANG_MALAY, "MALAY" }, - { RESOURCE_LANGS::LANG_MALAYALAM, "MALAYALAM" }, - { RESOURCE_LANGS::LANG_MANIPURI, "MANIPURI" }, - { RESOURCE_LANGS::LANG_MARATHI, "MARATHI" }, - { RESOURCE_LANGS::LANG_MONGOLIAN, "MONGOLIAN" }, - { RESOURCE_LANGS::LANG_NEPALI, "NEPALI" }, - { RESOURCE_LANGS::LANG_NORWEGIAN, "NORWEGIAN" }, - { RESOURCE_LANGS::LANG_ORIYA, "ORIYA" }, - { RESOURCE_LANGS::LANG_POLISH, "POLISH" }, - { RESOURCE_LANGS::LANG_PORTUGUESE, "PORTUGUESE" }, - { RESOURCE_LANGS::LANG_PUNJABI, "PUNJABI" }, - { RESOURCE_LANGS::LANG_ROMANIAN, "ROMANIAN" }, - { RESOURCE_LANGS::LANG_RUSSIAN, "RUSSIAN" }, - { RESOURCE_LANGS::LANG_SANSKRIT, "SANSKRIT" }, - { RESOURCE_LANGS::LANG_SINDHI, "SINDHI" }, - { RESOURCE_LANGS::LANG_SLOVAK, "SLOVAK" }, - { RESOURCE_LANGS::LANG_SLOVENIAN, "SLOVENIAN" }, - { RESOURCE_LANGS::LANG_SPANISH, "SPANISH" }, - { RESOURCE_LANGS::LANG_SWAHILI, "SWAHILI" }, - { RESOURCE_LANGS::LANG_SWEDISH, "SWEDISH" }, - { RESOURCE_LANGS::LANG_SYRIAC, "SYRIAC" }, - { RESOURCE_LANGS::LANG_TAMIL, "TAMIL" }, - { RESOURCE_LANGS::LANG_TATAR, "TATAR" }, - { RESOURCE_LANGS::LANG_TELUGU, "TELUGU" }, - { RESOURCE_LANGS::LANG_THAI, "THAI" }, - { RESOURCE_LANGS::LANG_TURKISH, "TURKISH" }, - { RESOURCE_LANGS::LANG_UKRAINIAN, "UKRAINIAN" }, - { RESOURCE_LANGS::LANG_URDU, "URDU" }, - { RESOURCE_LANGS::LANG_UZBEK, "UZBEK" }, - { RESOURCE_LANGS::LANG_VIETNAMESE, "VIETNAMESE" }, - { RESOURCE_LANGS::LANG_MALTESE, "MALTESE" }, - { RESOURCE_LANGS::LANG_MAORI, "MAORI" }, - { RESOURCE_LANGS::LANG_RHAETO_ROMANCE, "RHAETO_ROMANCE" }, - { RESOURCE_LANGS::LANG_SAMI, "SAMI" }, - { RESOURCE_LANGS::LANG_SORBIAN, "SORBIAN" }, - { RESOURCE_LANGS::LANG_SUTU, "SUTU" }, - { RESOURCE_LANGS::LANG_TSONGA, "TSONGA" }, - { RESOURCE_LANGS::LANG_TSWANA, "TSWANA" }, - { RESOURCE_LANGS::LANG_VENDA, "VENDA" }, - { RESOURCE_LANGS::LANG_XHOSA, "XHOSA" }, - { RESOURCE_LANGS::LANG_ZULU, "ZULU" }, - { RESOURCE_LANGS::LANG_ESPERANTO, "ESPERANTO" }, - { RESOURCE_LANGS::LANG_WALON, "WALON" }, - { RESOURCE_LANGS::LANG_CORNISH, "CORNISH" }, - { RESOURCE_LANGS::LANG_WELSH, "WELSH" }, - { RESOURCE_LANGS::LANG_BRETON, "BRETON" }, - { RESOURCE_LANGS::LANG_INUKTITUT, "INUKTITUT" }, - { RESOURCE_LANGS::LANG_IRISH, "IRISH" }, - { RESOURCE_LANGS::LANG_PULAR, "PULAR" }, - { RESOURCE_LANGS::LANG_QUECHUA, "QUECHUA" }, - { RESOURCE_LANGS::LANG_TAMAZIGHT, "TAMAZIGHT" }, - { RESOURCE_LANGS::LANG_TIGRINYA, "TIGRINYA" }, - }; - - const auto it = enumStrings.find(e); - return it == enumStrings.end() ? "Out of range" : it->second; -} - -const char* to_string(RESOURCE_SUBLANGS e) { - CONST_MAP(RESOURCE_SUBLANGS, const char*, 230) enumStrings { - { RESOURCE_SUBLANGS::SUBLANG_AFRIKAANS_SOUTH_AFRICA, "AFRIKAANS_SOUTH_AFRICA" }, - { RESOURCE_SUBLANGS::SUBLANG_ALBANIAN_ALBANIA, "ALBANIAN_ALBANIA" }, - { RESOURCE_SUBLANGS::SUBLANG_ALSATIAN_FRANCE, "ALSATIAN_FRANCE" }, - { RESOURCE_SUBLANGS::SUBLANG_AMHARIC_ETHIOPIA, "AMHARIC_ETHIOPIA" }, - { RESOURCE_SUBLANGS::SUBLANG_ARABIC_ALGERIA, "ARABIC_ALGERIA" }, - { RESOURCE_SUBLANGS::SUBLANG_ARABIC_BAHRAIN, "ARABIC_BAHRAIN" }, - { RESOURCE_SUBLANGS::SUBLANG_ARABIC_EGYPT, "ARABIC_EGYPT" }, - { RESOURCE_SUBLANGS::SUBLANG_ARABIC_IRAQ, "ARABIC_IRAQ" }, - { RESOURCE_SUBLANGS::SUBLANG_ARABIC_JORDAN, "ARABIC_JORDAN" }, - { RESOURCE_SUBLANGS::SUBLANG_ARABIC_KUWAIT, "ARABIC_KUWAIT" }, - { RESOURCE_SUBLANGS::SUBLANG_ARABIC_LEBANON, "ARABIC_LEBANON" }, - { RESOURCE_SUBLANGS::SUBLANG_ARABIC_LIBYA, "ARABIC_LIBYA" }, - { RESOURCE_SUBLANGS::SUBLANG_ARABIC_MOROCCO, "ARABIC_MOROCCO" }, - { RESOURCE_SUBLANGS::SUBLANG_ARABIC_OMAN, "ARABIC_OMAN" }, - { RESOURCE_SUBLANGS::SUBLANG_ARABIC_QATAR, "ARABIC_QATAR" }, - { RESOURCE_SUBLANGS::SUBLANG_ARABIC_SAUDI_ARABIA, "ARABIC_SAUDI_ARABIA" }, - { RESOURCE_SUBLANGS::SUBLANG_ARABIC_SYRIA, "ARABIC_SYRIA" }, - { RESOURCE_SUBLANGS::SUBLANG_ARABIC_TUNISIA, "ARABIC_TUNISIA" }, - { RESOURCE_SUBLANGS::SUBLANG_ARABIC_UAE, "ARABIC_UAE" }, - { RESOURCE_SUBLANGS::SUBLANG_ARABIC_YEMEN, "ARABIC_YEMEN" }, - { RESOURCE_SUBLANGS::SUBLANG_ARMENIAN_ARMENIA, "ARMENIAN_ARMENIA" }, - { RESOURCE_SUBLANGS::SUBLANG_ASSAMESE_INDIA, "ASSAMESE_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_AZERI_CYRILLIC, "AZERI_CYRILLIC" }, - { RESOURCE_SUBLANGS::SUBLANG_AZERI_LATIN, "AZERI_LATIN" }, - { RESOURCE_SUBLANGS::SUBLANG_BASHKIR_RUSSIA, "BASHKIR_RUSSIA" }, - { RESOURCE_SUBLANGS::SUBLANG_BASQUE_BASQUE, "BASQUE_BASQUE" }, - { RESOURCE_SUBLANGS::SUBLANG_BELARUSIAN_BELARUS, "BELARUSIAN_BELARUS" }, - { RESOURCE_SUBLANGS::SUBLANG_BANGLA_BANGLADESH, "BANGLA_BANGLADESH" }, - { RESOURCE_SUBLANGS::SUBLANG_BANGLA_INDIA, "BANGLA_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC, "BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC" }, - { RESOURCE_SUBLANGS::SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN, "BOSNIAN_BOSNIA_HERZEGOVINA_LATIN" }, - { RESOURCE_SUBLANGS::SUBLANG_BRETON_FRANCE, "BRETON_FRANCE" }, - { RESOURCE_SUBLANGS::SUBLANG_BULGARIAN_BULGARIA, "BULGARIAN_BULGARIA" }, - { RESOURCE_SUBLANGS::SUBLANG_CATALAN_CATALAN, "CATALAN_CATALAN" }, - { RESOURCE_SUBLANGS::SUBLANG_CHINESE_HONGKONG, "CHINESE_HONGKONG" }, - { RESOURCE_SUBLANGS::SUBLANG_CHINESE_MACAU, "CHINESE_MACAU" }, - { RESOURCE_SUBLANGS::SUBLANG_CHINESE_SIMPLIFIED, "CHINESE_SIMPLIFIED" }, - { RESOURCE_SUBLANGS::SUBLANG_CHINESE_SINGAPORE, "CHINESE_SINGAPORE" }, - { RESOURCE_SUBLANGS::SUBLANG_CHINESE_TRADITIONAL, "CHINESE_TRADITIONAL" }, - { RESOURCE_SUBLANGS::SUBLANG_CORSICAN_FRANCE, "CORSICAN_FRANCE" }, - { RESOURCE_SUBLANGS::SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN, "CROATIAN_BOSNIA_HERZEGOVINA_LATIN" }, - { RESOURCE_SUBLANGS::SUBLANG_CROATIAN_CROATIA, "CROATIAN_CROATIA" }, - { RESOURCE_SUBLANGS::SUBLANG_CUSTOM_DEFAULT, "CUSTOM_DEFAULT" }, - { RESOURCE_SUBLANGS::SUBLANG_CUSTOM_UNSPECIFIED, "CUSTOM_UNSPECIFIED" }, - { RESOURCE_SUBLANGS::SUBLANG_CZECH_CZECH_REPUBLIC, "CZECH_CZECH_REPUBLIC" }, - { RESOURCE_SUBLANGS::SUBLANG_DANISH_DENMARK, "DANISH_DENMARK" }, - { RESOURCE_SUBLANGS::SUBLANG_DARI_AFGHANISTAN, "DARI_AFGHANISTAN" }, - { RESOURCE_SUBLANGS::SUBLANG_DEFAULT, "DEFAULT" }, - { RESOURCE_SUBLANGS::SUBLANG_DIVEHI_MALDIVES, "DIVEHI_MALDIVES" }, - { RESOURCE_SUBLANGS::SUBLANG_DUTCH_BELGIAN, "DUTCH_BELGIAN" }, - { RESOURCE_SUBLANGS::SUBLANG_DUTCH, "DUTCH" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_AUS, "ENGLISH_AUS" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_BELIZE, "ENGLISH_BELIZE" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_CAN, "ENGLISH_CAN" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_CARIBBEAN, "ENGLISH_CARIBBEAN" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_EIRE, "ENGLISH_EIRE" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_INDIA, "ENGLISH_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_JAMAICA, "ENGLISH_JAMAICA" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_MALAYSIA, "ENGLISH_MALAYSIA" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_NZ, "ENGLISH_NZ" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_PHILIPPINES, "ENGLISH_PHILIPPINES" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_SINGAPORE, "ENGLISH_SINGAPORE" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_SOUTH_AFRICA, "ENGLISH_SOUTH_AFRICA" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_TRINIDAD, "ENGLISH_TRINIDAD" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_UK, "ENGLISH_UK" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_US, "ENGLISH_US" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_ZIMBABWE, "ENGLISH_ZIMBABWE" }, - { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_IRELAND, "ENGLISH_IRELAND" }, - { RESOURCE_SUBLANGS::SUBLANG_ESTONIAN_ESTONIA, "ESTONIAN_ESTONIA" }, - { RESOURCE_SUBLANGS::SUBLANG_FAEROESE_FAROE_ISLANDS, "FAEROESE_FAROE_ISLANDS" }, - { RESOURCE_SUBLANGS::SUBLANG_FILIPINO_PHILIPPINES, "FILIPINO_PHILIPPINES" }, - { RESOURCE_SUBLANGS::SUBLANG_FINNISH_FINLAND, "FINNISH_FINLAND" }, - { RESOURCE_SUBLANGS::SUBLANG_FRENCH_BELGIAN, "FRENCH_BELGIAN" }, - { RESOURCE_SUBLANGS::SUBLANG_FRENCH_CANADIAN, "FRENCH_CANADIAN" }, - { RESOURCE_SUBLANGS::SUBLANG_FRENCH_LUXEMBOURG, "FRENCH_LUXEMBOURG" }, - { RESOURCE_SUBLANGS::SUBLANG_FRENCH_MONACO, "FRENCH_MONACO" }, - { RESOURCE_SUBLANGS::SUBLANG_FRENCH_SWISS, "FRENCH_SWISS" }, - { RESOURCE_SUBLANGS::SUBLANG_FRENCH, "FRENCH" }, - { RESOURCE_SUBLANGS::SUBLANG_FRISIAN_NETHERLANDS, "FRISIAN_NETHERLANDS" }, - { RESOURCE_SUBLANGS::SUBLANG_GALICIAN_GALICIAN, "GALICIAN_GALICIAN" }, - { RESOURCE_SUBLANGS::SUBLANG_GEORGIAN_GEORGIA, "GEORGIAN_GEORGIA" }, - { RESOURCE_SUBLANGS::SUBLANG_GERMAN_AUSTRIAN, "GERMAN_AUSTRIAN" }, - { RESOURCE_SUBLANGS::SUBLANG_GERMAN_LIECHTENSTEIN, "GERMAN_LIECHTENSTEIN" }, - { RESOURCE_SUBLANGS::SUBLANG_GERMAN_LUXEMBOURG, "GERMAN_LUXEMBOURG" }, - { RESOURCE_SUBLANGS::SUBLANG_GERMAN_SWISS, "GERMAN_SWISS" }, - { RESOURCE_SUBLANGS::SUBLANG_GERMAN, "GERMAN" }, - { RESOURCE_SUBLANGS::SUBLANG_GREEK_GREECE, "GREEK_GREECE" }, - { RESOURCE_SUBLANGS::SUBLANG_GREENLANDIC_GREENLAND, "GREENLANDIC_GREENLAND" }, - { RESOURCE_SUBLANGS::SUBLANG_GUJARATI_INDIA, "GUJARATI_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_HAUSA_NIGERIA_LATIN, "HAUSA_NIGERIA_LATIN" }, - { RESOURCE_SUBLANGS::SUBLANG_HEBREW_ISRAEL, "HEBREW_ISRAEL" }, - { RESOURCE_SUBLANGS::SUBLANG_HINDI_INDIA, "HINDI_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_HUNGARIAN_HUNGARY, "HUNGARIAN_HUNGARY" }, - { RESOURCE_SUBLANGS::SUBLANG_ICELANDIC_ICELAND, "ICELANDIC_ICELAND" }, - { RESOURCE_SUBLANGS::SUBLANG_IGBO_NIGERIA, "IGBO_NIGERIA" }, - { RESOURCE_SUBLANGS::SUBLANG_INDONESIAN_INDONESIA, "INDONESIAN_INDONESIA" }, - { RESOURCE_SUBLANGS::SUBLANG_INUKTITUT_CANADA_LATIN, "INUKTITUT_CANADA_LATIN" }, - { RESOURCE_SUBLANGS::SUBLANG_INUKTITUT_CANADA, "INUKTITUT_CANADA" }, - { RESOURCE_SUBLANGS::SUBLANG_IRISH_IRELAND, "IRISH_IRELAND" }, - { RESOURCE_SUBLANGS::SUBLANG_ITALIAN_SWISS, "ITALIAN_SWISS" }, - { RESOURCE_SUBLANGS::SUBLANG_ITALIAN, "ITALIAN" }, - { RESOURCE_SUBLANGS::SUBLANG_JAPANESE_JAPAN, "JAPANESE_JAPAN" }, - { RESOURCE_SUBLANGS::SUBLANG_KANNADA_INDIA, "KANNADA_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_KASHMIRI_INDIA, "KASHMIRI_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_KASHMIRI_SASIA, "KASHMIRI_SASIA" }, - { RESOURCE_SUBLANGS::SUBLANG_KAZAK_KAZAKHSTAN, "KAZAK_KAZAKHSTAN" }, - { RESOURCE_SUBLANGS::SUBLANG_KHMER_CAMBODIA, "KHMER_CAMBODIA" }, - { RESOURCE_SUBLANGS::SUBLANG_KICHE_GUATEMALA, "KICHE_GUATEMALA" }, - { RESOURCE_SUBLANGS::SUBLANG_KINYARWANDA_RWANDA, "KINYARWANDA_RWANDA" }, - { RESOURCE_SUBLANGS::SUBLANG_KONKANI_INDIA, "KONKANI_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_KOREAN, "KOREAN" }, - { RESOURCE_SUBLANGS::SUBLANG_KYRGYZ_KYRGYZSTAN, "KYRGYZ_KYRGYZSTAN" }, - { RESOURCE_SUBLANGS::SUBLANG_LAO_LAO, "LAO_LAO" }, - { RESOURCE_SUBLANGS::SUBLANG_LATVIAN_LATVIA, "LATVIAN_LATVIA" }, - { RESOURCE_SUBLANGS::SUBLANG_LITHUANIAN_CLASSIC, "LITHUANIAN_CLASSIC" }, - { RESOURCE_SUBLANGS::SUBLANG_LITHUANIAN, "LITHUANIAN" }, - { RESOURCE_SUBLANGS::SUBLANG_LOWER_SORBIAN_GERMANY, "LOWER_SORBIAN_GERMANY" }, - { RESOURCE_SUBLANGS::SUBLANG_LUXEMBOURGISH_LUXEMBOURG, "LUXEMBOURGISH_LUXEMBOURG" }, - { RESOURCE_SUBLANGS::SUBLANG_MACEDONIAN_MACEDONIA, "MACEDONIAN_MACEDONIA" }, - { RESOURCE_SUBLANGS::SUBLANG_MALAY_BRUNEI_DARUSSALAM, "MALAY_BRUNEI_DARUSSALAM" }, - { RESOURCE_SUBLANGS::SUBLANG_MALAY_MALAYSIA, "MALAY_MALAYSIA" }, - { RESOURCE_SUBLANGS::SUBLANG_MALAYALAM_INDIA, "MALAYALAM_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_MALTESE_MALTA, "MALTESE_MALTA" }, - { RESOURCE_SUBLANGS::SUBLANG_MAORI_NEW_ZEALAND, "MAORI_NEW_ZEALAND" }, - { RESOURCE_SUBLANGS::SUBLANG_MAPUDUNGUN_CHILE, "MAPUDUNGUN_CHILE" }, - { RESOURCE_SUBLANGS::SUBLANG_MARATHI_INDIA, "MARATHI_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_MOHAWK_MOHAWK, "MOHAWK_MOHAWK" }, - { RESOURCE_SUBLANGS::SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA, "MONGOLIAN_CYRILLIC_MONGOLIA" }, - { RESOURCE_SUBLANGS::SUBLANG_MONGOLIAN_PRC, "MONGOLIAN_PRC" }, - { RESOURCE_SUBLANGS::SUBLANG_NEPALI_INDIA, "NEPALI_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_NEPALI_NEPAL, "NEPALI_NEPAL" }, - { RESOURCE_SUBLANGS::SUBLANG_NEUTRAL, "NEUTRAL" }, - { RESOURCE_SUBLANGS::SUBLANG_NORWEGIAN_BOKMAL, "NORWEGIAN_BOKMAL" }, - { RESOURCE_SUBLANGS::SUBLANG_NORWEGIAN_NYNORSK, "NORWEGIAN_NYNORSK" }, - { RESOURCE_SUBLANGS::SUBLANG_OCCITAN_FRANCE, "OCCITAN_FRANCE" }, - { RESOURCE_SUBLANGS::SUBLANG_ORIYA_INDIA, "ORIYA_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_PASHTO_AFGHANISTAN, "PASHTO_AFGHANISTAN" }, - { RESOURCE_SUBLANGS::SUBLANG_PERSIAN_IRAN, "PERSIAN_IRAN" }, - { RESOURCE_SUBLANGS::SUBLANG_POLISH_POLAND, "POLISH_POLAND" }, - { RESOURCE_SUBLANGS::SUBLANG_PORTUGUESE_BRAZILIAN, "PORTUGUESE_BRAZILIAN" }, - { RESOURCE_SUBLANGS::SUBLANG_PORTUGUESE, "PORTUGUESE" }, - { RESOURCE_SUBLANGS::SUBLANG_PUNJABI_INDIA, "PUNJABI_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_QUECHUA_BOLIVIA, "QUECHUA_BOLIVIA" }, - { RESOURCE_SUBLANGS::SUBLANG_QUECHUA_ECUADOR, "QUECHUA_ECUADOR" }, - { RESOURCE_SUBLANGS::SUBLANG_QUECHUA_PERU, "QUECHUA_PERU" }, - { RESOURCE_SUBLANGS::SUBLANG_ROMANIAN_ROMANIA, "ROMANIAN_ROMANIA" }, - { RESOURCE_SUBLANGS::SUBLANG_ROMANSH_SWITZERLAND, "ROMANSH_SWITZERLAND" }, - { RESOURCE_SUBLANGS::SUBLANG_RUSSIAN_RUSSIA, "RUSSIAN_RUSSIA" }, - { RESOURCE_SUBLANGS::SUBLANG_SAMI_INARI_FINLAND, "SAMI_INARI_FINLAND" }, - { RESOURCE_SUBLANGS::SUBLANG_SAMI_LULE_NORWAY, "SAMI_LULE_NORWAY" }, - { RESOURCE_SUBLANGS::SUBLANG_SAMI_LULE_SWEDEN, "SAMI_LULE_SWEDEN" }, - { RESOURCE_SUBLANGS::SUBLANG_SAMI_NORTHERN_FINLAND, "SAMI_NORTHERN_FINLAND" }, - { RESOURCE_SUBLANGS::SUBLANG_SAMI_NORTHERN_NORWAY, "SAMI_NORTHERN_NORWAY" }, - { RESOURCE_SUBLANGS::SUBLANG_SAMI_NORTHERN_SWEDEN, "SAMI_NORTHERN_SWEDEN" }, - { RESOURCE_SUBLANGS::SUBLANG_SAMI_SKOLT_FINLAND, "SAMI_SKOLT_FINLAND" }, - { RESOURCE_SUBLANGS::SUBLANG_SAMI_SOUTHERN_NORWAY, "SAMI_SOUTHERN_NORWAY" }, - { RESOURCE_SUBLANGS::SUBLANG_SAMI_SOUTHERN_SWEDEN, "SAMI_SOUTHERN_SWEDEN" }, - { RESOURCE_SUBLANGS::SUBLANG_SANSKRIT_INDIA, "SANSKRIT_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC, "SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC" }, - { RESOURCE_SUBLANGS::SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN, "SERBIAN_BOSNIA_HERZEGOVINA_LATIN" }, - { RESOURCE_SUBLANGS::SUBLANG_SERBIAN_CROATIA, "SERBIAN_CROATIA" }, - { RESOURCE_SUBLANGS::SUBLANG_SERBIAN_CYRILLIC, "SERBIAN_CYRILLIC" }, - { RESOURCE_SUBLANGS::SUBLANG_SERBIAN_LATIN, "SERBIAN_LATIN" }, - { RESOURCE_SUBLANGS::SUBLANG_SINDHI_AFGHANISTAN, "SINDHI_AFGHANISTAN" }, - { RESOURCE_SUBLANGS::SUBLANG_SINDHI_INDIA, "SINDHI_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_SINDHI_PAKISTAN, "SINDHI_PAKISTAN" }, - { RESOURCE_SUBLANGS::SUBLANG_SINHALESE_SRI_LANKA, "SINHALESE_SRI_LANKA" }, - { RESOURCE_SUBLANGS::SUBLANG_SLOVAK_SLOVAKIA, "SLOVAK_SLOVAKIA" }, - { RESOURCE_SUBLANGS::SUBLANG_SLOVENIAN_SLOVENIA, "SLOVENIAN_SLOVENIA" }, - { RESOURCE_SUBLANGS::SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA, "SOTHO_NORTHERN_SOUTH_AFRICA" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_ARGENTINA, "SPANISH_ARGENTINA" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_BOLIVIA, "SPANISH_BOLIVIA" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_CHILE, "SPANISH_CHILE" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_COLOMBIA, "SPANISH_COLOMBIA" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_COSTA_RICA, "SPANISH_COSTA_RICA" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_DOMINICAN_REPUBLIC, "SPANISH_DOMINICAN_REPUBLIC" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_ECUADOR, "SPANISH_ECUADOR" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_EL_SALVADOR, "SPANISH_EL_SALVADOR" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_GUATEMALA, "SPANISH_GUATEMALA" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_HONDURAS, "SPANISH_HONDURAS" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_MEXICAN, "SPANISH_MEXICAN" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_MODERN, "SPANISH_MODERN" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_NICARAGUA, "SPANISH_NICARAGUA" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_PANAMA, "SPANISH_PANAMA" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_PARAGUAY, "SPANISH_PARAGUAY" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_PERU, "SPANISH_PERU" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_PUERTO_RICO, "SPANISH_PUERTO_RICO" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_URUGUAY, "SPANISH_URUGUAY" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_US, "SPANISH_US" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH_VENEZUELA, "SPANISH_VENEZUELA" }, - { RESOURCE_SUBLANGS::SUBLANG_SPANISH, "SPANISH" }, - { RESOURCE_SUBLANGS::SUBLANG_SWAHILI_KENYA, "SWAHILI_KENYA" }, - { RESOURCE_SUBLANGS::SUBLANG_SWEDISH_FINLAND, "SWEDISH_FINLAND" }, - { RESOURCE_SUBLANGS::SUBLANG_SWEDISH, "SWEDISH" }, - { RESOURCE_SUBLANGS::SUBLANG_SYRIAC_SYRIA, "SYRIAC_SYRIA" }, - { RESOURCE_SUBLANGS::SUBLANG_SYS_DEFAULT, "SYS_DEFAULT" }, - { RESOURCE_SUBLANGS::SUBLANG_TAJIK_TAJIKISTAN, "TAJIK_TAJIKISTAN" }, - { RESOURCE_SUBLANGS::SUBLANG_TAMAZIGHT_ALGERIA_LATIN, "TAMAZIGHT_ALGERIA_LATIN" }, - { RESOURCE_SUBLANGS::SUBLANG_TAMIL_INDIA, "TAMIL_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_TATAR_RUSSIA, "TATAR_RUSSIA" }, - { RESOURCE_SUBLANGS::SUBLANG_TELUGU_INDIA, "TELUGU_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_THAI_THAILAND, "THAI_THAILAND" }, - { RESOURCE_SUBLANGS::SUBLANG_TIBETAN_PRC, "TIBETAN_PRC" }, - { RESOURCE_SUBLANGS::SUBLANG_TIGRIGNA_ERITREA, "TIGRIGNA_ERITREA" }, - { RESOURCE_SUBLANGS::SUBLANG_TSWANA_SOUTH_AFRICA, "TSWANA_SOUTH_AFRICA" }, - { RESOURCE_SUBLANGS::SUBLANG_TURKISH_TURKEY, "TURKISH_TURKEY" }, - { RESOURCE_SUBLANGS::SUBLANG_TURKMEN_TURKMENISTAN, "TURKMEN_TURKMENISTAN" }, - { RESOURCE_SUBLANGS::SUBLANG_UI_CUSTOM_DEFAULT, "UI_CUSTOM_DEFAULT" }, - { RESOURCE_SUBLANGS::SUBLANG_UIGHUR_PRC, "UIGHUR_PRC" }, - { RESOURCE_SUBLANGS::SUBLANG_UKRAINIAN_UKRAINE, "UKRAINIAN_UKRAINE" }, - { RESOURCE_SUBLANGS::SUBLANG_UPPER_SORBIAN_GERMANY, "UPPER_SORBIAN_GERMANY" }, - { RESOURCE_SUBLANGS::SUBLANG_URDU_INDIA, "URDU_INDIA" }, - { RESOURCE_SUBLANGS::SUBLANG_URDU_PAKISTAN, "URDU_PAKISTAN" }, - { RESOURCE_SUBLANGS::SUBLANG_UZBEK_CYRILLIC, "UZBEK_CYRILLIC" }, - { RESOURCE_SUBLANGS::SUBLANG_UZBEK_LATIN, "UZBEK_LATIN" }, - { RESOURCE_SUBLANGS::SUBLANG_VIETNAMESE_VIETNAM, "VIETNAMESE_VIETNAM" }, - { RESOURCE_SUBLANGS::SUBLANG_WELSH_UNITED_KINGDOM, "WELSH_UNITED_KINGDOM" }, - { RESOURCE_SUBLANGS::SUBLANG_WOLOF_SENEGAL, "WOLOF_SENEGAL" }, - { RESOURCE_SUBLANGS::SUBLANG_XHOSA_SOUTH_AFRICA, "XHOSA_SOUTH_AFRICA" }, - { RESOURCE_SUBLANGS::SUBLANG_YAKUT_RUSSIA, "YAKUT_RUSSIA" }, - { RESOURCE_SUBLANGS::SUBLANG_YI_PRC, "YI_PRC" }, - { RESOURCE_SUBLANGS::SUBLANG_YORUBA_NIGERIA, "YORUBA_NIGERIA" }, - { RESOURCE_SUBLANGS::SUBLANG_ZULU_SOUTH_AFRICA, "ZULU_SOUTH_AFRICA" }, - { RESOURCE_SUBLANGS::SUBLANG_PUNJABI_PAKISTAN, "PUNJABI_PAKISTAN" }, - { RESOURCE_SUBLANGS::SUBLANG_TSWANA_BOTSWANA, "TSWANA_BOTSWANA" }, - { RESOURCE_SUBLANGS::SUBLANG_TAMIL_SRI_LANKA, "TAMIL_SRI_LANKA" }, - { RESOURCE_SUBLANGS::SUBLANG_TIGRINYA_ETHIOPIA, "TIGRINYA_ETHIOPIA" }, - { RESOURCE_SUBLANGS::SUBLANG_TIGRINYA_ERITREA, "TIGRINYA_ERITREA" }, - { RESOURCE_SUBLANGS::SUBLANG_VALENCIAN_VALENCIA, "VALENCIAN_VALENCIA" }, - { RESOURCE_SUBLANGS::SUBLANG_PULAR_SENEGAL, "PULAR_SENEGAL" }, - }; - - const auto it = enumStrings.find(e); - return it == enumStrings.end() ? "Out of range" : it->second; -} - const char* to_string(EXTENDED_WINDOW_STYLES e) { CONST_MAP(EXTENDED_WINDOW_STYLES, const char*, 17) enumStrings { { EXTENDED_WINDOW_STYLES::WS_EX_DLGMODALFRAME, "DLGMODALFRAME" }, diff --git a/src/PE/ResourcesManager.cpp b/src/PE/ResourcesManager.cpp index 37292f1ed4..dcdbc97e6a 100644 --- a/src/PE/ResourcesManager.cpp +++ b/src/PE/ResourcesManager.cpp @@ -14,238 +14,52 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include -#include -#include -#include - -#include "logging.hpp" -#include "internal_utils.hpp" - - -#include "LIEF/PE/hash.hpp" +#include "LIEF/Visitor.hpp" #include "LIEF/utils.hpp" -#include "LIEF/BinaryStream/SpanStream.hpp" - -#include "LIEF/PE/EnumToString.hpp" - #include "LIEF/PE/ResourcesManager.hpp" +#include "LIEF/PE/ResourceNode.hpp" #include "LIEF/PE/ResourceData.hpp" #include "LIEF/PE/ResourceDirectory.hpp" -#include "LIEF/PE/resources/ResourceStringTable.hpp" -#include "LIEF/PE/resources/ResourceAccelerator.hpp" -#include "PE/Structures.hpp" #include "PE/ResourcesParser.hpp" +#include "PE/Structures.hpp" -namespace LIEF { -namespace PE { - - -ResourcesManager::ResourcesManager(ResourcesManager&&) = default; -ResourcesManager& ResourcesManager::operator=(ResourcesManager&&) = default; - -ResourcesManager::ResourcesManager(const ResourcesManager&) = default; -ResourcesManager& ResourcesManager::operator=(const ResourcesManager&) = default; -ResourcesManager::~ResourcesManager() = default; - -ResourcesManager::ResourcesManager(ResourceNode& rsrc) : - resources_{&rsrc} -{} - -RESOURCE_LANGS ResourcesManager::lang_from_id(size_t id) { - return static_cast(id & 0x3ff); -} - -RESOURCE_SUBLANGS ResourcesManager::sublang_from_id(size_t id) { - const size_t index = id >> 10; - const RESOURCE_LANGS lang = ResourcesManager::lang_from_id(id); - return ResourcesManager::sub_lang(lang, index); -} - -RESOURCE_SUBLANGS ResourcesManager::sub_lang(RESOURCE_LANGS lang, size_t index) { - // From https://docs.microsoft.com/en-us/windows/win32/intl/language-identifier-constants-and-strings - static const std::map, RESOURCE_SUBLANGS> sublangs_map = { - - { {RESOURCE_LANGS::LANG_ARABIC, 0x5}, RESOURCE_SUBLANGS::SUBLANG_ARABIC_ALGERIA }, - { {RESOURCE_LANGS::LANG_ARABIC, 0xF}, RESOURCE_SUBLANGS::SUBLANG_ARABIC_BAHRAIN }, - { {RESOURCE_LANGS::LANG_ARABIC, 0x3}, RESOURCE_SUBLANGS::SUBLANG_ARABIC_EGYPT }, - { {RESOURCE_LANGS::LANG_ARABIC, 0x2}, RESOURCE_SUBLANGS::SUBLANG_ARABIC_IRAQ }, - { {RESOURCE_LANGS::LANG_ARABIC, 0xB}, RESOURCE_SUBLANGS::SUBLANG_ARABIC_JORDAN }, - { {RESOURCE_LANGS::LANG_ARABIC, 0xD}, RESOURCE_SUBLANGS::SUBLANG_ARABIC_KUWAIT }, - { {RESOURCE_LANGS::LANG_ARABIC, 0xC}, RESOURCE_SUBLANGS::SUBLANG_ARABIC_LEBANON }, - { {RESOURCE_LANGS::LANG_ARABIC, 0x4}, RESOURCE_SUBLANGS::SUBLANG_ARABIC_LIBYA }, - { {RESOURCE_LANGS::LANG_ARABIC, 0x6}, RESOURCE_SUBLANGS::SUBLANG_ARABIC_MOROCCO }, - { {RESOURCE_LANGS::LANG_ARABIC, 0x8}, RESOURCE_SUBLANGS::SUBLANG_ARABIC_OMAN }, - { {RESOURCE_LANGS::LANG_ARABIC, 0x10}, RESOURCE_SUBLANGS::SUBLANG_ARABIC_QATAR }, - { {RESOURCE_LANGS::LANG_ARABIC, 0x01}, RESOURCE_SUBLANGS::SUBLANG_ARABIC_SAUDI_ARABIA }, - { {RESOURCE_LANGS::LANG_ARABIC, 0xA}, RESOURCE_SUBLANGS::SUBLANG_ARABIC_SYRIA }, - { {RESOURCE_LANGS::LANG_ARABIC, 0x7}, RESOURCE_SUBLANGS::SUBLANG_ARABIC_TUNISIA }, - { {RESOURCE_LANGS::LANG_ARABIC, 0xE}, RESOURCE_SUBLANGS::SUBLANG_ARABIC_UAE }, - { {RESOURCE_LANGS::LANG_ARABIC, 0x9}, RESOURCE_SUBLANGS::SUBLANG_ARABIC_YEMEN }, - - { {RESOURCE_LANGS::LANG_AZERI, 2}, RESOURCE_SUBLANGS::SUBLANG_AZERI_CYRILLIC }, - { {RESOURCE_LANGS::LANG_AZERI, 1}, RESOURCE_SUBLANGS::SUBLANG_AZERI_LATIN }, - - { {RESOURCE_LANGS::LANG_BANGLA, 2}, RESOURCE_SUBLANGS::SUBLANG_BANGLA_BANGLADESH }, - { {RESOURCE_LANGS::LANG_BANGLA, 1}, RESOURCE_SUBLANGS::SUBLANG_BANGLA_INDIA }, - - { {RESOURCE_LANGS::LANG_BOSNIAN, 8}, RESOURCE_SUBLANGS::SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC }, - { {RESOURCE_LANGS::LANG_BOSNIAN, 5}, RESOURCE_SUBLANGS::SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN }, - - { {RESOURCE_LANGS::LANG_CHINESE, 3}, RESOURCE_SUBLANGS::SUBLANG_CHINESE_HONGKONG }, - { {RESOURCE_LANGS::LANG_CHINESE, 5}, RESOURCE_SUBLANGS::SUBLANG_CHINESE_MACAU }, - { {RESOURCE_LANGS::LANG_CHINESE, 4}, RESOURCE_SUBLANGS::SUBLANG_CHINESE_SINGAPORE }, - { {RESOURCE_LANGS::LANG_CHINESE, 2}, RESOURCE_SUBLANGS::SUBLANG_CHINESE_SIMPLIFIED }, - - { {RESOURCE_LANGS::LANG_CROATIAN, 4}, RESOURCE_SUBLANGS::SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN }, - { {RESOURCE_LANGS::LANG_CROATIAN, 1}, RESOURCE_SUBLANGS::SUBLANG_CROATIAN_CROATIA }, - - { {RESOURCE_LANGS::LANG_DUTCH, 2}, RESOURCE_SUBLANGS::SUBLANG_DUTCH_BELGIAN }, - { {RESOURCE_LANGS::LANG_DUTCH, 2}, RESOURCE_SUBLANGS::SUBLANG_DUTCH }, - - { {RESOURCE_LANGS::LANG_ENGLISH, 0x3}, RESOURCE_SUBLANGS::SUBLANG_ENGLISH_AUS }, - { {RESOURCE_LANGS::LANG_ENGLISH, 0xA}, RESOURCE_SUBLANGS::SUBLANG_ENGLISH_BELIZE }, - { {RESOURCE_LANGS::LANG_ENGLISH, 0x4}, RESOURCE_SUBLANGS::SUBLANG_ENGLISH_CAN }, - { {RESOURCE_LANGS::LANG_ENGLISH, 0x9}, RESOURCE_SUBLANGS::SUBLANG_ENGLISH_CARIBBEAN }, - { {RESOURCE_LANGS::LANG_ENGLISH, 0x10}, RESOURCE_SUBLANGS::SUBLANG_ENGLISH_IRELAND }, - { {RESOURCE_LANGS::LANG_ENGLISH, 0x6}, RESOURCE_SUBLANGS::SUBLANG_ENGLISH_JAMAICA }, - { {RESOURCE_LANGS::LANG_ENGLISH, 0x8}, RESOURCE_SUBLANGS::SUBLANG_ENGLISH_MALAYSIA }, - { {RESOURCE_LANGS::LANG_ENGLISH, 0x11}, RESOURCE_SUBLANGS::SUBLANG_ENGLISH_NZ }, - { {RESOURCE_LANGS::LANG_ENGLISH, 0x5}, RESOURCE_SUBLANGS::SUBLANG_ENGLISH_PHILIPPINES }, - { {RESOURCE_LANGS::LANG_ENGLISH, 0x12}, RESOURCE_SUBLANGS::SUBLANG_ENGLISH_SINGAPORE }, - { {RESOURCE_LANGS::LANG_ENGLISH, 0x7}, RESOURCE_SUBLANGS::SUBLANG_ENGLISH_SOUTH_AFRICA }, - { {RESOURCE_LANGS::LANG_ENGLISH, 0xB}, RESOURCE_SUBLANGS::SUBLANG_ENGLISH_TRINIDAD }, - { {RESOURCE_LANGS::LANG_ENGLISH, 0x2}, RESOURCE_SUBLANGS::SUBLANG_ENGLISH_UK }, - { {RESOURCE_LANGS::LANG_ENGLISH, 0x1}, RESOURCE_SUBLANGS::SUBLANG_ENGLISH_US }, - { {RESOURCE_LANGS::LANG_ENGLISH, 0xC}, RESOURCE_SUBLANGS::SUBLANG_ENGLISH_ZIMBABWE }, - - { {RESOURCE_LANGS::LANG_FRENCH, 1}, RESOURCE_SUBLANGS::SUBLANG_FRENCH }, - { {RESOURCE_LANGS::LANG_FRENCH, 2}, RESOURCE_SUBLANGS::SUBLANG_FRENCH_BELGIAN }, - { {RESOURCE_LANGS::LANG_FRENCH, 3}, RESOURCE_SUBLANGS::SUBLANG_FRENCH_CANADIAN }, - { {RESOURCE_LANGS::LANG_FRENCH, 5}, RESOURCE_SUBLANGS::SUBLANG_FRENCH_LUXEMBOURG }, - { {RESOURCE_LANGS::LANG_FRENCH, 6}, RESOURCE_SUBLANGS::SUBLANG_FRENCH_MONACO }, - { {RESOURCE_LANGS::LANG_FRENCH, 4}, RESOURCE_SUBLANGS::SUBLANG_FRENCH_SWISS }, - - { {RESOURCE_LANGS::LANG_GERMAN, 1}, RESOURCE_SUBLANGS::SUBLANG_GERMAN }, - { {RESOURCE_LANGS::LANG_GERMAN, 3}, RESOURCE_SUBLANGS::SUBLANG_GERMAN_AUSTRIAN }, - { {RESOURCE_LANGS::LANG_GERMAN, 5}, RESOURCE_SUBLANGS::SUBLANG_GERMAN_LIECHTENSTEIN }, - { {RESOURCE_LANGS::LANG_GERMAN, 4}, RESOURCE_SUBLANGS::SUBLANG_GERMAN_LUXEMBOURG }, - { {RESOURCE_LANGS::LANG_GERMAN, 2}, RESOURCE_SUBLANGS::SUBLANG_GERMAN_SWISS }, - - { {RESOURCE_LANGS::LANG_INUKTITUT, 1}, RESOURCE_SUBLANGS::SUBLANG_INUKTITUT_CANADA }, - { {RESOURCE_LANGS::LANG_INUKTITUT, 2}, RESOURCE_SUBLANGS::SUBLANG_INUKTITUT_CANADA_LATIN }, - - { {RESOURCE_LANGS::LANG_IRISH, 2}, RESOURCE_SUBLANGS::SUBLANG_IRISH_IRELAND }, - - { {RESOURCE_LANGS::LANG_ITALIAN, 1}, RESOURCE_SUBLANGS::SUBLANG_ITALIAN }, - { {RESOURCE_LANGS::LANG_ITALIAN, 2}, RESOURCE_SUBLANGS::SUBLANG_ITALIAN_SWISS }, - - { {RESOURCE_LANGS::LANG_LOWER_SORBIAN, 2}, RESOURCE_SUBLANGS::SUBLANG_LOWER_SORBIAN_GERMANY }, - - { {RESOURCE_LANGS::LANG_MALAY, 2}, RESOURCE_SUBLANGS::SUBLANG_MALAY_BRUNEI_DARUSSALAM }, - { {RESOURCE_LANGS::LANG_MALAY, 1}, RESOURCE_SUBLANGS::SUBLANG_MALAY_MALAYSIA }, - - { {RESOURCE_LANGS::LANG_MONGOLIAN, 2}, RESOURCE_SUBLANGS::SUBLANG_MONGOLIAN_PRC }, - { {RESOURCE_LANGS::LANG_MONGOLIAN, 1}, RESOURCE_SUBLANGS::SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA }, - - { {RESOURCE_LANGS::LANG_NEPALI, 2}, RESOURCE_SUBLANGS::SUBLANG_NEPALI_INDIA }, - { {RESOURCE_LANGS::LANG_NEPALI, 1}, RESOURCE_SUBLANGS::SUBLANG_NEPALI_NEPAL }, - - { {RESOURCE_LANGS::LANG_NORWEGIAN, 1}, RESOURCE_SUBLANGS::SUBLANG_NORWEGIAN_BOKMAL }, - { {RESOURCE_LANGS::LANG_NORWEGIAN, 2}, RESOURCE_SUBLANGS::SUBLANG_NORWEGIAN_NYNORSK }, - - { {RESOURCE_LANGS::LANG_PORTUGUESE, 2}, RESOURCE_SUBLANGS::SUBLANG_PORTUGUESE }, - { {RESOURCE_LANGS::LANG_PORTUGUESE, 1}, RESOURCE_SUBLANGS::SUBLANG_PORTUGUESE_BRAZILIAN }, - - { {RESOURCE_LANGS::LANG_PULAR, 2}, RESOURCE_SUBLANGS::SUBLANG_PULAR_SENEGAL }, - - { {RESOURCE_LANGS::LANG_PUNJABI, 1}, RESOURCE_SUBLANGS::SUBLANG_PUNJABI_INDIA }, - { {RESOURCE_LANGS::LANG_PUNJABI, 2}, RESOURCE_SUBLANGS::SUBLANG_PUNJABI_PAKISTAN }, - - { {RESOURCE_LANGS::LANG_QUECHUA, 1}, RESOURCE_SUBLANGS::SUBLANG_QUECHUA_BOLIVIA }, - { {RESOURCE_LANGS::LANG_QUECHUA, 2}, RESOURCE_SUBLANGS::SUBLANG_QUECHUA_ECUADOR }, - { {RESOURCE_LANGS::LANG_QUECHUA, 3}, RESOURCE_SUBLANGS::SUBLANG_QUECHUA_PERU }, - - { {RESOURCE_LANGS::LANG_SAMI, 9}, RESOURCE_SUBLANGS::SUBLANG_SAMI_INARI_FINLAND }, - { {RESOURCE_LANGS::LANG_SAMI, 4}, RESOURCE_SUBLANGS::SUBLANG_SAMI_LULE_NORWAY }, - { {RESOURCE_LANGS::LANG_SAMI, 5}, RESOURCE_SUBLANGS::SUBLANG_SAMI_LULE_SWEDEN }, - { {RESOURCE_LANGS::LANG_SAMI, 3}, RESOURCE_SUBLANGS::SUBLANG_SAMI_NORTHERN_FINLAND }, - { {RESOURCE_LANGS::LANG_SAMI, 2}, RESOURCE_SUBLANGS::SUBLANG_SAMI_NORTHERN_SWEDEN }, - { {RESOURCE_LANGS::LANG_SAMI, 8}, RESOURCE_SUBLANGS::SUBLANG_SAMI_SKOLT_FINLAND }, - { {RESOURCE_LANGS::LANG_SAMI, 6}, RESOURCE_SUBLANGS::SUBLANG_SAMI_SOUTHERN_NORWAY }, - { {RESOURCE_LANGS::LANG_SAMI, 7}, RESOURCE_SUBLANGS::SUBLANG_SAMI_SOUTHERN_SWEDEN }, - { {RESOURCE_LANGS::LANG_SAMI, 1}, RESOURCE_SUBLANGS::SUBLANG_SAMI_NORTHERN_NORWAY }, - - { {RESOURCE_LANGS::LANG_SERBIAN, 7}, RESOURCE_SUBLANGS::SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC }, - { {RESOURCE_LANGS::LANG_SERBIAN, 6}, RESOURCE_SUBLANGS::SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN }, - { {RESOURCE_LANGS::LANG_SERBIAN, 1}, RESOURCE_SUBLANGS::SUBLANG_SERBIAN_CROATIA }, - { {RESOURCE_LANGS::LANG_SERBIAN, 3}, RESOURCE_SUBLANGS::SUBLANG_SERBIAN_CYRILLIC }, - { {RESOURCE_LANGS::LANG_SERBIAN, 2}, RESOURCE_SUBLANGS::SUBLANG_SERBIAN_LATIN }, - - { {RESOURCE_LANGS::LANG_TSWANA, 2}, RESOURCE_SUBLANGS::SUBLANG_TSWANA_BOTSWANA }, - { {RESOURCE_LANGS::LANG_TSWANA, 1}, RESOURCE_SUBLANGS::SUBLANG_TSWANA_SOUTH_AFRICA }, - - { {RESOURCE_LANGS::LANG_SPANISH, 0xb}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_ARGENTINA }, - { {RESOURCE_LANGS::LANG_SPANISH, 0x10}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_BOLIVIA }, - { {RESOURCE_LANGS::LANG_SPANISH, 0xd}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_CHILE }, - { {RESOURCE_LANGS::LANG_SPANISH, 0x9}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_COLOMBIA }, - { {RESOURCE_LANGS::LANG_SPANISH, 0x5}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_COSTA_RICA }, - { {RESOURCE_LANGS::LANG_SPANISH, 0x7}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_DOMINICAN_REPUBLIC }, - { {RESOURCE_LANGS::LANG_SPANISH, 0xC}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_ECUADOR }, - { {RESOURCE_LANGS::LANG_SPANISH, 0x11}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_EL_SALVADOR }, - { {RESOURCE_LANGS::LANG_SPANISH, 0x4}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_GUATEMALA }, - { {RESOURCE_LANGS::LANG_SPANISH, 0x12}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_HONDURAS }, - { {RESOURCE_LANGS::LANG_SPANISH, 0x2}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_MEXICAN }, - { {RESOURCE_LANGS::LANG_SPANISH, 0x13}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_NICARAGUA }, - { {RESOURCE_LANGS::LANG_SPANISH, 0x6}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_PANAMA }, - { {RESOURCE_LANGS::LANG_SPANISH, 0xF}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_PARAGUAY }, - { {RESOURCE_LANGS::LANG_SPANISH, 0xA}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_PERU }, - { {RESOURCE_LANGS::LANG_SPANISH, 0x14}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_PUERTO_RICO }, - { {RESOURCE_LANGS::LANG_SPANISH, 0x3}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_MODERN }, - { {RESOURCE_LANGS::LANG_SPANISH, 0x1}, RESOURCE_SUBLANGS::SUBLANG_SPANISH }, - { {RESOURCE_LANGS::LANG_SPANISH, 0x15}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_US }, - { {RESOURCE_LANGS::LANG_SPANISH, 0xE}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_URUGUAY }, - { {RESOURCE_LANGS::LANG_SPANISH, 0x8}, RESOURCE_SUBLANGS::SUBLANG_SPANISH_VENEZUELA }, - - { {RESOURCE_LANGS::LANG_SWEDISH, 2}, RESOURCE_SUBLANGS::SUBLANG_SWEDISH_FINLAND }, - { {RESOURCE_LANGS::LANG_SWEDISH, 1}, RESOURCE_SUBLANGS::SUBLANG_SWEDISH }, - - { {RESOURCE_LANGS::LANG_TAMAZIGHT, 2}, RESOURCE_SUBLANGS::SUBLANG_TAMAZIGHT_ALGERIA_LATIN }, - - { {RESOURCE_LANGS::LANG_TAMIL, 1}, RESOURCE_SUBLANGS::SUBLANG_TAMIL_INDIA }, - { {RESOURCE_LANGS::LANG_TAMIL, 2}, RESOURCE_SUBLANGS::SUBLANG_TAMIL_SRI_LANKA }, - - { {RESOURCE_LANGS::LANG_TIGRINYA, 1}, RESOURCE_SUBLANGS::SUBLANG_TIGRINYA_ETHIOPIA }, - { {RESOURCE_LANGS::LANG_TIGRINYA, 2}, RESOURCE_SUBLANGS::SUBLANG_TIGRINYA_ERITREA }, - - { {RESOURCE_LANGS::LANG_TIGRINYA, 1}, RESOURCE_SUBLANGS::SUBLANG_UIGHUR_PRC }, - { {RESOURCE_LANGS::LANG_TIGRINYA, 2}, RESOURCE_SUBLANGS::SUBLANG_UZBEK_CYRILLIC }, - - { {RESOURCE_LANGS::LANG_VALENCIAN, 2}, RESOURCE_SUBLANGS::SUBLANG_VALENCIAN_VALENCIA }, - }; +#include "LIEF/BinaryStream/SpanStream.hpp" - const auto it = sublangs_map.find({lang, index}); - if (it == std::end(sublangs_map)) { - return RESOURCE_SUBLANGS::SUBLANG_DEFAULT; - } - return it->second; -} +#include "frozen.hpp" +#include "logging.hpp" +#include "internal_utils.hpp" +#include "fmt_formatter.hpp" +FMT_FORMATTER(LIEF::PE::ResourcesManager::TYPE, LIEF::PE::to_string); -// Enhancemed API to explore resource tree -// ======================================= +namespace LIEF { +namespace PE { -ResourceNode* ResourcesManager::get_node_type(RESOURCE_TYPES type) { +static constexpr auto RESOURCE_TYPES = { + ResourcesManager::TYPE::CURSOR, ResourcesManager::TYPE::BITMAP, + ResourcesManager::TYPE::ICON, ResourcesManager::TYPE::MENU, + ResourcesManager::TYPE::DIALOG, ResourcesManager::TYPE::STRING, + ResourcesManager::TYPE::FONTDIR, ResourcesManager::TYPE::FONT, + ResourcesManager::TYPE::ACCELERATOR, ResourcesManager::TYPE::RCDATA, + ResourcesManager::TYPE::MESSAGETABLE, ResourcesManager::TYPE::GROUP_CURSOR, + ResourcesManager::TYPE::GROUP_ICON, ResourcesManager::TYPE::VERSION, + ResourcesManager::TYPE::DLGINCLUDE, ResourcesManager::TYPE::PLUGPLAY, + ResourcesManager::TYPE::VXD, ResourcesManager::TYPE::ANICURSOR, + ResourcesManager::TYPE::ANIICON, ResourcesManager::TYPE::HTML, + ResourcesManager::TYPE::MANIFEST, +}; + +ResourceNode* ResourcesManager::get_node_type(ResourcesManager::TYPE type) { return const_cast(static_cast(this)->get_node_type(type)); } -const ResourceNode* ResourcesManager::get_node_type(RESOURCE_TYPES type) const { +const ResourceNode* ResourcesManager::get_node_type(ResourcesManager::TYPE type) const { ResourceNode::it_childs nodes = resources_->childs(); const auto it_node = std::find_if(std::begin(nodes), std::end(nodes), [type] (const ResourceNode& node) { - return static_cast(node.id()) == type; + return ResourcesManager::TYPE(node.id()) == type; }); if (it_node == std::end(nodes)) { @@ -255,71 +69,24 @@ const ResourceNode* ResourcesManager::get_node_type(RESOURCE_TYPES type) const { return &*it_node; } -std::set ResourcesManager::get_types_available() const { - std::set types; +std::vector ResourcesManager::get_types() const { + std::vector types; for (const ResourceNode& node : resources_->childs()) { - const auto *const it = std::find_if(std::begin(resource_types_array), std::end(resource_types_array), - [&node] (RESOURCE_TYPES t) { - return t == static_cast(node.id()); + const auto it = std::find_if(std::begin(RESOURCE_TYPES), std::end(RESOURCE_TYPES), + [&node] (ResourcesManager::TYPE t) { + return t == ResourcesManager::TYPE(node.id()); }); - if (it != std::end(resource_types_array)) { - types.insert(*it); - } - } - return types; - -} - -std::set ResourcesManager::get_langs_available() const { - std::set langs; - for (const ResourceNode& node_lvl_1 : resources_->childs()) { - for (const ResourceNode& node_lvl_2 : node_lvl_1.childs()) { - for (const ResourceNode& node_lvl_3 : node_lvl_2.childs()) { - auto lang = static_cast(node_lvl_3.id() & 0x3ff); - const auto *const it = std::find_if(std::begin(resource_langs_array), std::end(resource_langs_array), - [lang] (RESOURCE_LANGS t) { - return t == lang; - }); - - if (it != std::end(resource_langs_array)) { - langs.insert(*it); - } - } + if (it != std::end(RESOURCE_TYPES)) { + types.push_back(*it); } } - return langs; -} - -std::set ResourcesManager::get_sublangs_available() const { - std::set sublangs; - for (const ResourceNode& node_lvl_1 : resources_->childs()) { - for (const ResourceNode& node_lvl_2 : node_lvl_1.childs()) { - for (const ResourceNode& node_lvl_3 : node_lvl_2.childs()) { - RESOURCE_SUBLANGS sub_lang = ResourcesManager::sublang_from_id(node_lvl_3.id()); - sublangs.insert(sub_lang); - } - } - } - return sublangs; -} - -bool ResourcesManager::has_type(RESOURCE_TYPES type) const { - return get_node_type(type) != nullptr; -} - - -// Manifest -// ======== - -bool ResourcesManager::has_manifest() const { - return get_node_type(RESOURCE_TYPES::MANIFEST) != nullptr; + return types; } std::string ResourcesManager::manifest() const { - const ResourceNode* root_node = get_node_type(RESOURCE_TYPES::MANIFEST); + const ResourceNode* root_node = get_node_type(TYPE::MANIFEST); if (root_node == nullptr) { - LIEF_WARN("No manifest found in the resources"); return ""; } @@ -346,7 +113,7 @@ std::string ResourcesManager::manifest() const { } void ResourcesManager::manifest(const std::string& manifest) { - if (ResourceNode* manifest_node = get_node_type(RESOURCE_TYPES::MANIFEST)) { + if (ResourceNode* manifest_node = get_node_type(TYPE::MANIFEST)) { auto l1 = manifest_node->childs(); if (l1.empty()) { LIEF_INFO("Can't update manifest: l1 empty"); @@ -372,12 +139,8 @@ void ResourcesManager::manifest(const std::string& manifest) { // Resource Version // ================ -bool ResourcesManager::has_version() const { - return get_node_type(RESOURCE_TYPES::VERSION) != nullptr; -} - result ResourcesManager::version() const { - const ResourceNode* root_node = get_node_type(RESOURCE_TYPES::VERSION); + const ResourceNode* root_node = get_node_type(TYPE::VERSION); if (root_node == nullptr) { return make_error_code(lief_errors::not_found); } @@ -411,23 +174,17 @@ result ResourcesManager::version() const { // Icons // ===== -bool ResourcesManager::has_icons() const { - const ResourceNode* root_icon = get_node_type(RESOURCE_TYPES::ICON); - const ResourceNode* root_grp_icon = get_node_type(RESOURCE_TYPES::GROUP_ICON); - return root_icon != nullptr && root_grp_icon != nullptr; -} - ResourcesManager::it_const_icons ResourcesManager::icons() const { std::vector icons; - const ResourceNode* root_icon = get_node_type(RESOURCE_TYPES::ICON); - const ResourceNode* root_grp_icon = get_node_type(RESOURCE_TYPES::GROUP_ICON); + const ResourceNode* root_icon = get_node_type(TYPE::ICON); + const ResourceNode* root_grp_icon = get_node_type(TYPE::GROUP_ICON); if (root_icon == nullptr) { - LIEF_ERR("Missing '{}' entry", to_string(RESOURCE_TYPES::ICON)); + LIEF_ERR("Missing '{}' entry", to_string(TYPE::ICON)); return icons; } if (root_grp_icon == nullptr) { - LIEF_ERR("Missing '{}' entry", to_string(RESOURCE_TYPES::GROUP_ICON)); + LIEF_ERR("Missing '{}' entry", to_string(TYPE::GROUP_ICON)); return icons; } @@ -513,22 +270,22 @@ void ResourcesManager::add_icon(const ResourceIcon& icon) { ResourceNode::it_childs nodes = resources_->childs(); const auto it_icon = std::find_if(std::begin(nodes), std::end(nodes), [] (const ResourceNode& node) { - return static_cast(node.id()) == RESOURCE_TYPES::ICON; + return TYPE(node.id()) == TYPE::ICON; }); const auto it_grp_icon = std::find_if(std::begin(nodes), std::end(nodes), [] (const ResourceNode& node) { - return static_cast(node.id()) == RESOURCE_TYPES::GROUP_ICON; + return TYPE(node.id()) == TYPE::GROUP_ICON; }); if (it_icon == std::end(nodes)) { - LIEF_ERR("Missing '{}' entry", to_string(RESOURCE_TYPES::ICON)); + LIEF_ERR("Missing '{}' entry", to_string(TYPE::ICON)); return; } if (it_grp_icon == std::end(nodes)) { - LIEF_ERR("Missing '{}' entry", to_string(RESOURCE_TYPES::GROUP_ICON)); + LIEF_ERR("Missing '{}' entry", to_string(TYPE::GROUP_ICON)); return; } auto new_id = static_cast(icon.id()); @@ -600,18 +357,18 @@ void ResourcesManager::change_icon(const ResourceIcon& original, const ResourceI ResourceNode::it_childs nodes = resources_->childs(); const auto it_icon = std::find_if(std::begin(nodes), std::end(nodes), [] (const ResourceNode& node) { - return static_cast(node.id()) == RESOURCE_TYPES::ICON; + return TYPE(node.id()) == TYPE::ICON; }); const auto it_grp_icon = std::find_if(std::begin(nodes), std::end(nodes), [] (const ResourceNode& node) { - return static_cast(node.id()) == RESOURCE_TYPES::GROUP_ICON; + return TYPE(node.id()) == TYPE::GROUP_ICON; }); if (it_icon == std::end(nodes)) { - LIEF_ERR("Missing '{}' entry", to_string(RESOURCE_TYPES::ICON)); + LIEF_ERR("Missing '{}' entry", to_string(TYPE::ICON)); return; } @@ -684,7 +441,7 @@ void ResourcesManager::change_icon(const ResourceIcon& original, const ResourceI ResourcesManager::it_const_dialogs ResourcesManager::dialogs() const { std::vector dialogs; - const ResourceNode* dialog_node = get_node_type(RESOURCE_TYPES::DIALOG); + const ResourceNode* dialog_node = get_node_type(TYPE::DIALOG); if (dialog_node == nullptr) { return dialogs; } @@ -723,16 +480,12 @@ ResourcesManager::it_const_dialogs ResourcesManager::dialogs() const { } -bool ResourcesManager::has_dialogs() const { - return get_node_type(RESOURCE_TYPES::DIALOG) != nullptr; -} - // String table entry ResourcesManager::it_const_strings_table ResourcesManager::string_table() const { std::vector string_table; - const ResourceNode* root_node = get_node_type(RESOURCE_TYPES::STRING); + const ResourceNode* root_node = get_node_type(TYPE::STRING); if (root_node == nullptr) { - LIEF_ERR("Missing '{}' entry", to_string(RESOURCE_TYPES::STRING)); + LIEF_ERR("Missing '{}' entry", to_string(TYPE::STRING)); return string_table; } @@ -777,14 +530,10 @@ ResourcesManager::it_const_strings_table ResourcesManager::string_table() const return string_table; } -bool ResourcesManager::has_string_table() const { - return get_node_type(RESOURCE_TYPES::STRING) != nullptr; -} - std::vector ResourcesManager::html() const { - const ResourceNode* root_node = get_node_type(RESOURCE_TYPES::HTML); + const ResourceNode* root_node = get_node_type(TYPE::HTML); if (root_node == nullptr) { - LIEF_ERR("Missing '{}' entry", to_string(RESOURCE_TYPES::HTML)); + LIEF_ERR("Missing '{}' entry", to_string(TYPE::HTML)); return {}; } std::vector html; @@ -808,19 +557,11 @@ std::vector ResourcesManager::html() const { return html; } -bool ResourcesManager::has_html() const { - return get_node_type(RESOURCE_TYPES::HTML) != nullptr; -} - -bool ResourcesManager::has_accelerator() const { - return get_node_type(RESOURCE_TYPES::ACCELERATOR) != nullptr; -} - ResourcesManager::it_const_accelerators ResourcesManager::accelerator() const { std::vector accelerator; - const ResourceNode* root_node = get_node_type(RESOURCE_TYPES::ACCELERATOR); + const ResourceNode* root_node = get_node_type(TYPE::ACCELERATOR); if (root_node == nullptr) { - LIEF_ERR("Missing '{}' entry", to_string(RESOURCE_TYPES::ACCELERATOR)); + LIEF_ERR("Missing '{}' entry", to_string(TYPE::ACCELERATOR)); return accelerator; } @@ -859,9 +600,6 @@ ResourcesManager::it_const_accelerators ResourcesManager::accelerator() const { return accelerator; } -// Prints -// ====== - std::string ResourcesManager::print(uint32_t depth) const { std::ostringstream oss; uint32_t current_depth = 0; @@ -872,120 +610,62 @@ std::string ResourcesManager::print(uint32_t depth) const { void ResourcesManager::print_tree(const ResourceNode& node, std::ostringstream& output, uint32_t current_depth, uint32_t max_depth) const { - if (max_depth < current_depth) { return; } for (const ResourceNode& child_node : node.childs()) { - output << std::string(2 * (current_depth + 1), ' '); - output << "["; - if (child_node.is_directory()) { - output << "Directory"; - } else { - output << "Data"; - } - - output << "] "; - + std::string space(2 * (current_depth + 1), ' '); + std::string type = child_node.is_directory() ? "Directory" : "Data"; + output << fmt::format("{}[{}]", space, type); if (child_node.has_name()) { - output << u16tou8(child_node.name()); } else { - output << "ID: " << std::setw(2) << std::setfill('0') << std::dec << child_node.id(); + output << fmt::format("ID: {:02d}", child_node.id()); if (current_depth == 0) { - output << " - " << to_string(static_cast(child_node.id())); + output << fmt::format(" - {}", to_string(TYPE(child_node.id()))); } if (current_depth == 2) { - RESOURCE_LANGS lang = ResourcesManager::lang_from_id(child_node.id()); - RESOURCE_SUBLANGS sub_lang = ResourcesManager::sublang_from_id(child_node.id()); - output << " - " << to_string(lang) << "/" << to_string(sub_lang); + uint32_t lang = ResourcesManager::lang_from_id(child_node.id()); + uint32_t sub_lang = ResourcesManager::sublang_from_id(child_node.id()); + output << fmt::format(" - Lang: 0x{:02x} / Sublang: 0x{:02x}", lang, sub_lang); } - output << std::setfill(' '); } - output << std::endl; + output << '\n'; print_tree(child_node, output, current_depth + 1, max_depth); } - } void ResourcesManager::accept(Visitor& visitor) const { visitor.visit(*this); } - - - std::ostream& operator<<(std::ostream& os, const ResourcesManager& rsrc) { - os << rsrc.print(3); - os << std::endl; + os << rsrc.print(3) << '\n'; - std::set types = rsrc.get_types_available(); - std::set langs = rsrc.get_langs_available(); - std::set sublangs = rsrc.get_sublangs_available(); + std::vector types = rsrc.get_types(); if (!types.empty()) { - std::string types_str = std::accumulate( - std::begin(types), - std::end(types), std::string{}, - [] (const std::string& a, RESOURCE_TYPES t) { - return a.empty() ? to_string(t) : a + " - " + to_string(t); - }); - os << "Types: " << types_str << std::endl << std::endl; - } - - - if (!langs.empty()) { - std::string langs_str = std::accumulate( - std::begin(langs), - std::end(langs), std::string{}, - [] (const std::string& a, RESOURCE_LANGS l) { - return a.empty() ? to_string(l) : a + " - " + to_string(l); - }); - os << "Langs: " << langs_str << std::endl << std::endl; + os << fmt::format("Types: {}\n", types); } - - if (!sublangs.empty()) { - std::string sublangs_str = std::accumulate( - std::begin(sublangs), - std::end(sublangs), std::string{}, - [] (const std::string& a, RESOURCE_SUBLANGS sl) { - return a.empty() ? to_string(sl) : a + " - " + to_string(sl); - }); - os << "Sub-langs: " << sublangs_str << std::endl << std::endl; + if (const std::string& manifest = rsrc.manifest(); !manifest.empty()) { + os << fmt::format("Manifest:\n{}\n", manifest); } - - if (rsrc.has_manifest()) { - os << "Manifest" << std::endl; - os << "========" << std::endl << std::endl; - os << rsrc.manifest(); - os << std::endl << std::endl; - } - - - if (rsrc.has_version()) { - if (auto version = rsrc.version()) { - os << "Version" << std::endl; - os << "=======" << std::endl << std::endl; - os << *version; - os << std::endl; - } + if (auto version = rsrc.version()) { + os << fmt::format("Version:\n{}\n", *version); } const auto& icons = rsrc.icons(); for (size_t i = 0; i < icons.size(); ++i) { - os << "Icon #" << std::dec << i << " : " << std::endl; - os << icons[i] << std::endl; + os << fmt::format("Icon #{:02d}:\n{}\n", i, icons[i]); } - const auto& dialogs = rsrc.dialogs(); for (size_t i = 0; i < dialogs.size(); ++i) { - os << "Dialog #" << std::dec << i << " : " << std::endl; - os << dialogs[i] << std::endl; + os << fmt::format("Dialog #{:02d}:\n{}\n", i, dialogs[i]); } const auto& str_table = rsrc.string_table(); @@ -995,5 +675,40 @@ std::ostream& operator<<(std::ostream& os, const ResourcesManager& rsrc) { return os; } +const char* to_string(ResourcesManager::TYPE type) { + #define ENTRY(X) std::pair(ResourcesManager::TYPE::X, #X) + STRING_MAP enums2str { + ENTRY(CURSOR), + ENTRY(BITMAP), + ENTRY(ICON), + ENTRY(MENU), + ENTRY(DIALOG), + ENTRY(STRING), + ENTRY(FONTDIR), + ENTRY(FONT), + ENTRY(ACCELERATOR), + ENTRY(RCDATA), + ENTRY(MESSAGETABLE), + ENTRY(GROUP_CURSOR), + ENTRY(GROUP_ICON), + ENTRY(VERSION), + ENTRY(DLGINCLUDE), + ENTRY(PLUGPLAY), + ENTRY(VXD), + ENTRY(ANICURSOR), + ENTRY(ANIICON), + ENTRY(HTML), + ENTRY(MANIFEST), + }; + #undef ENTRY + + if (auto it = enums2str.find(type); it != enums2str.end()) { + return it->second; + } + + return "UNKNOWN"; +} + + } // namespace PE } // namespace LIEF diff --git a/src/PE/json.cpp b/src/PE/json.cpp index 001ba756db..827d98f50e 100644 --- a/src/PE/json.cpp +++ b/src/PE/json.cpp @@ -701,8 +701,8 @@ void JsonVisitor::visit(const ResourceVersion& resource_version) { void JsonVisitor::visit(const ResourceIcon& resource_icon) { node_["id"] = resource_icon.id(); - node_["lang"] = to_string(resource_icon.lang()); - node_["sublang"] = to_string(resource_icon.sublang()); + node_["lang"] = resource_icon.lang(); + node_["sublang"] = resource_icon.sublang(); node_["width"] = resource_icon.width(); node_["height"] = resource_icon.height(); node_["color_count"] = resource_icon.color_count(); diff --git a/src/PE/resources/LangCodeItem.cpp b/src/PE/resources/LangCodeItem.cpp index b7dcf44dff..44ae8a2ed2 100644 --- a/src/PE/resources/LangCodeItem.cpp +++ b/src/PE/resources/LangCodeItem.cpp @@ -60,27 +60,25 @@ CODE_PAGES LangCodeItem::code_page() const { return static_cast(std::stoul(u16tou8(key().substr(4, 8)), nullptr, 16)); } -RESOURCE_LANGS LangCodeItem::lang() const { +uint32_t LangCodeItem::lang() const { if (key().length() != 8) { LIEF_WARN("{} is expected to be 8 lengthy", u16tou8(key())); - return static_cast(0); + return 0; } uint64_t lang_id = std::stoul(u16tou8(key().substr(0, 4)), nullptr, 16); - auto lang = static_cast(lang_id & 0x3ff); - return lang; + return ResourcesManager::lang_from_id(lang_id); } -RESOURCE_SUBLANGS LangCodeItem::sublang() const { +uint32_t LangCodeItem::sublang() const { if (key().length() != 8) { LIEF_WARN("{} is expected to be 8 lengthy", u16tou8(key())); - return static_cast(0); + return 0; } uint64_t lang_id = std::stoul(u16tou8(key().substr(0, 4)), nullptr, 16); - RESOURCE_SUBLANGS sublang = ResourcesManager::sub_lang(lang(), (lang_id >> 10)); - return sublang; + return ResourcesManager::sublang_from_id(lang_id); } @@ -122,7 +120,7 @@ void LangCodeItem::code_page(CODE_PAGES code_page) { } } -void LangCodeItem::lang(RESOURCE_LANGS lang) { +void LangCodeItem::lang(uint32_t lang) { uint64_t lang_id = std::stoul(u16tou8(key().substr(0, 4)), nullptr, 16); lang_id &= ~static_cast(0x3ff); lang_id |= static_cast(lang); @@ -139,7 +137,7 @@ void LangCodeItem::lang(RESOURCE_LANGS lang) { } } -void LangCodeItem::sublang(RESOURCE_SUBLANGS lang) { +void LangCodeItem::sublang(uint32_t lang) { //TODO: Check uint64_t lang_id = std::stoul(u16tou8(key().substr(0, 4)), nullptr, 16); uint64_t mask = (static_cast(-1) >> 16) << 16; @@ -178,9 +176,9 @@ std::ostream& operator<<(std::ostream& os, const LangCodeItem& item) { os << std::setw(8) << std::setfill(' ') << "type:" << item.type() << std::endl; os << std::setw(8) << std::setfill(' ') << "key:" << u16tou8(item.key()) << ": (" - << to_string(item.lang()) + << item.lang() << " - " - << to_string(item.sublang()) + << item.sublang() << " - " << std::hex << to_string(item.code_page()) << ")" << std::endl; os << std::setw(8) << std::setfill(' ') << "Items: " << std::endl; diff --git a/src/PE/resources/ResourceDialog.cpp b/src/PE/resources/ResourceDialog.cpp index b47f9854da..d3c560b55e 100644 --- a/src/PE/resources/ResourceDialog.cpp +++ b/src/PE/resources/ResourceDialog.cpp @@ -48,8 +48,8 @@ ResourceDialog::ResourceDialog() : weight_{0}, italic_{false}, charset_{0}, - lang_{RESOURCE_LANGS::LANG_NEUTRAL}, - sublang_{RESOURCE_SUBLANGS::SUBLANG_DEFAULT} + lang_{0}, + sublang_{0} {} @@ -67,8 +67,8 @@ ResourceDialog::ResourceDialog(const details::pe_dialog_template_ext& header) : weight_{0}, italic_{false}, charset_{0}, - lang_{RESOURCE_LANGS::LANG_NEUTRAL}, - sublang_{RESOURCE_SUBLANGS::SUBLANG_DEFAULT} + lang_{0}, + sublang_{0} {} @@ -86,8 +86,8 @@ ResourceDialog::ResourceDialog(const details::pe_dialog_template& header) : weight_{0}, italic_{false}, charset_{0}, - lang_{RESOURCE_LANGS::LANG_NEUTRAL}, - sublang_{RESOURCE_SUBLANGS::SUBLANG_DEFAULT} + lang_{0}, + sublang_{0} {} @@ -172,19 +172,19 @@ ResourceDialog::it_const_items ResourceDialog::items() const { } -RESOURCE_LANGS ResourceDialog::lang() const { +uint32_t ResourceDialog::lang() const { return lang_; } -RESOURCE_SUBLANGS ResourceDialog::sub_lang() const { +uint32_t ResourceDialog::sub_lang() const { return sublang_; } -void ResourceDialog::lang(RESOURCE_LANGS lang) { +void ResourceDialog::lang(uint32_t lang) { lang_ = lang; } -void ResourceDialog::sub_lang(RESOURCE_SUBLANGS sub_lang) { +void ResourceDialog::sub_lang(uint32_t sub_lang) { sublang_ = sub_lang; } @@ -307,7 +307,7 @@ std::ostream& operator<<(std::ostream& os, const ResourceDialog& dialog) { os << "Styles: " << styles_str << std::endl; os << "Dialog box styles: " << dialogbox_styles_str << std::endl; os << "Extended styles: " << ext_styles_str << std::endl; - os << "Lang: " << to_string(dialog.lang()) << " / " << to_string(dialog.sub_lang()) << std::endl; + os << "Lang: " << dialog.lang() << " / " << dialog.sub_lang() << std::endl; if (dialog.is_extended()) { os << "Title: \"" << u16tou8(dialog.title()) << "\"" << std::endl; diff --git a/src/PE/resources/ResourceIcon.cpp b/src/PE/resources/ResourceIcon.cpp index af9aaefffb..9e5aa2129e 100644 --- a/src/PE/resources/ResourceIcon.cpp +++ b/src/PE/resources/ResourceIcon.cpp @@ -59,11 +59,11 @@ uint32_t ResourceIcon::id() const { return id_; } -RESOURCE_LANGS ResourceIcon::lang() const { +uint32_t ResourceIcon::lang() const { return lang_; } -RESOURCE_SUBLANGS ResourceIcon::sublang() const { +uint32_t ResourceIcon::sublang() const { return sublang_; } @@ -103,11 +103,11 @@ void ResourceIcon::id(uint32_t id) { id_ = id; } -void ResourceIcon::lang(RESOURCE_LANGS lang) { +void ResourceIcon::lang(uint32_t lang) { lang_ = lang; } -void ResourceIcon::sublang(RESOURCE_SUBLANGS sublang) { +void ResourceIcon::sublang(uint32_t sublang) { sublang_ = sublang; } diff --git a/src/PE/resources/ResourceVarFileInfo.cpp b/src/PE/resources/ResourceVarFileInfo.cpp index 129f73206c..abd297f472 100644 --- a/src/PE/resources/ResourceVarFileInfo.cpp +++ b/src/PE/resources/ResourceVarFileInfo.cpp @@ -84,10 +84,7 @@ void ResourceVarFileInfo::accept(Visitor& visitor) const { } - - std::ostream& operator<<(std::ostream& os, const ResourceVarFileInfo& entry) { - std::string translation_str = std::accumulate( std::begin(entry.translations()), std::end(entry.translations()), std::string{}, [] (const std::string& a, uint32_t t) { @@ -96,10 +93,10 @@ std::ostream& operator<<(std::ostream& os, const ResourceVarFileInfo& entry) { uint16_t msb = t >> 16; auto cp = static_cast(msb); - auto lang = static_cast(lsb & 0x3ff); - RESOURCE_SUBLANGS sublang = ResourcesManager::sub_lang(lang, (lsb >> 10)); + uint32_t lang = ResourcesManager::lang_from_id(lsb); + uint32_t sublang = ResourcesManager::sublang_from_id(lsb); - ss << to_string(cp) << "/" << to_string(lang) << "/" << to_string(sublang); + ss << to_string(cp) << "/" << lang << "/" << sublang; return a.empty() ? ss.str() : a + " - " + ss.str(); }); diff --git a/tests/pe/test_resources.py b/tests/pe/test_resources.py index 13c84f8c10..ce6b8c0ed5 100644 --- a/tests/pe/test_resources.py +++ b/tests/pe/test_resources.py @@ -127,7 +127,7 @@ def test_resource_version(): langcode_item = string_file_info.langcode_items[0] assert langcode_item.type == 1 assert langcode_item.lang == lief.PE.RESOURCE_LANGS.FRENCH - assert langcode_item.sublang == lief.PE.RESOURCE_SUBLANGS.FRENCH + assert langcode_item.sublang == 1 assert langcode_item.code_page == lief.PE.CODE_PAGES.UTF_16 items = langcode_item.items assert 'CompanyName' in items @@ -186,7 +186,7 @@ def test_resource_dialogs(): assert dialog.charset == 0x1 assert dialog.style == 0x0 assert dialog.lang == lief.PE.RESOURCE_LANGS.ENGLISH - assert dialog.sub_lang == lief.PE.RESOURCE_SUBLANGS.ENGLISH_US + assert dialog.sub_lang == 1 assert len(dialog.items) == 6 assert dialog.items[0].help_id == 0x0 @@ -349,15 +349,15 @@ def test_resource_directory_add_directory_node(tmp_path): nodes = [] node = lief.PE.ResourceDirectory() - node.id = lief.PE.RESOURCE_TYPES.HTML + node.id = lief.PE.ResourcesManager.TYPE.HTML nodes.append(node) node = lief.PE.ResourceDirectory() - node.id = lief.PE.RESOURCE_TYPES.RCDATA + node.id = lief.PE.ResourcesManager.TYPE.RCDATA nodes.append(node) node = lief.PE.ResourceDirectory() - node.id = lief.PE.RESOURCE_TYPES.FONT + node.id = lief.PE.ResourcesManager.TYPE.FONT nodes.append(node) # Deterministically shuffle the add order with the seed @@ -372,10 +372,10 @@ def test_resource_directory_add_directory_node(tmp_path): for seed in (7, 23, 91): app = lief.parse(sample.as_posix()) - assert lief.PE.RESOURCE_TYPES.RCDATA.value not in [child.id for child in app.resources.childs] + assert lief.PE.ResourcesManager.TYPE.RCDATA.value not in [child.id for child in app.resources.childs] node = lief.PE.ResourceDirectory() - node.id = lief.PE.RESOURCE_TYPES.RCDATA + node.id = lief.PE.ResourcesManager.TYPE.RCDATA rcdata_node = app.resources.add_directory_node(node) assert isinstance(rcdata_node, lief.PE.ResourceNode) @@ -430,10 +430,10 @@ def test_resource_directory_add_data_node(tmp_path): for seed in (7, 23, 91): app = lief.parse(sample.as_posix()) - assert lief.PE.RESOURCE_TYPES.RCDATA.value not in [child.id for child in app.resources.childs] + assert lief.PE.ResourcesManager.TYPE.RCDATA.value not in [child.id for child in app.resources.childs] node = lief.PE.ResourceDirectory() - node.id = lief.PE.RESOURCE_TYPES.RCDATA + node.id = lief.PE.ResourcesManager.TYPE.RCDATA rcdata_node = app.resources.add_directory_node(node) assert isinstance(rcdata_node, lief.PE.ResourceNode)