{"id":13627240,"url":"https://github.com/leoetlino/classgen","last_synced_at":"2025-04-15T20:13:56.897Z","repository":{"id":72565864,"uuid":"441765601","full_name":"leoetlino/classgen","owner":"leoetlino","description":"Clang-based tool to dump type information (enums, records, vtables) from a C++ codebase and optionally import it into IDA","archived":false,"fork":false,"pushed_at":"2022-06-21T20:38:28.000Z","size":68,"stargazers_count":23,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T20:13:49.776Z","etag":null,"topics":["clang","cpp","ida-pro","reverse-engineering"],"latest_commit_sha":null,"homepage":"https://botw.link/classgen-viewer","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leoetlino.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-12-25T22:02:38.000Z","updated_at":"2025-01-17T04:31:42.000Z","dependencies_parsed_at":"2023-03-02T02:15:20.361Z","dependency_job_id":null,"html_url":"https://github.com/leoetlino/classgen","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoetlino%2Fclassgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoetlino%2Fclassgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoetlino%2Fclassgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoetlino%2Fclassgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leoetlino","download_url":"https://codeload.github.com/leoetlino/classgen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249145419,"owners_count":21219966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clang","cpp","ida-pro","reverse-engineering"],"created_at":"2024-08-01T22:00:31.819Z","updated_at":"2025-04-15T20:13:56.881Z","avatar_url":"https://github.com/leoetlino.png","language":"C++","readme":"classgen\n========\n\nSmall Clang-based tool to dump type information (enums, records, vtables) from a C++ codebase.\n\n## Prerequisites\n\n- A compiler that supports C++20\n- CMake 3.16+\n- LLVM + Clang 13+\n  - Version 13 and 14 are known to work. Versions \u003c= 12 are too old.\n  - If your version is too old, grab a newer release of LLVM from [releases.llvm.org](https://releases.llvm.org/)\n\n## Building from source\n\n1. `git clone --recursive https://github.com/leoetlino/classgen`\n2. `mkdir build` then `cd build`\n3. `cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo`\n    * This will automatically locate an existing install of LLVM.\n    * If you compiled Clang from source, add `-DCMAKE_PREFIX_PATH=/path/to/llvm-project/build/lib/cmake`\n    * If you are using a pre-built release from [releases.llvm.org](https://releases.llvm.org/), add `-DCMAKE_PREFIX_PATH=/path/to/extracted/archive/lib/cmake`\n4. `cmake --build .`\n\n## Usage\n\n### Generating type dumps\n\nUse `classgen-dump` to generate a JSON type dump that can be imported into other tools:\n\n```\nclassgen-dump [source files...] [options] \u003e output.json\n```\n\nIf you have a [compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html) for your project, you can pass `-p [path to database or build dir]` to tell classgen-dump to load compilation flags from the database.\n\nExample command line for [BotW](https://github.com/zeldaret/botw):\n\n```\nclassgen-dump -p build/ \u003e types.json -i src/KingSystem/Physics/RigidBody/physRigidBody.cpp src/KingSystem/Physics/System/physUserTag.cpp\n```\n\n(Note that there is no need to pass compile flags manually because they are loaded from the compilation database thanks to the `-p` option.)\n\nUseful options:\n\n* `-i`: Inline empty structs. If passed, record types that are empty (no fields, no bases, no vtables) will be folded into their containing records. This helps reduce the number of records in the output -- typically this will prevent things like `std::integral_constant\u003cint, 42\u003e` from appearing in the record list.\n\n* You can pass compilation options with `-- [options]`, the same way you'd specify options to Clang. For example:\n\n```\nclassgen-dump hello.cpp -- -target aarch64-none-elf -march=armv8-a+crc+crypto -std=c++20 [etc.]\n```\n\n### Visualising type dumps\n\nType dumps can be easily visualised using a simple web-based viewer app (viewer.html). You can find an online (but possibly outdated) version of the viewer at https://botw.link/classgen-viewer\n\n### Importing a type dump into IDA\n\nTo import a type dump into an IDA database, just run the `ida/classgen_load.py` script (requires IDAPython).\n\nPartial type imports are supported -- you can choose which types to import. Please note that importing a struct will recursively import all of its dependencies (member field types, pointer types, member function return types, etc.) *Warning: Any type that already exists will be overwritten*.\n\nKnown issues:\n\n* Importing types on older databases can sometimes cause existing types to break. This is because of IDA bugs or because your types are defined incorrectly. If you are importing a type that already exists in your database, make sure that it has the correct size and alignment.\n\n* IDA \u003c= 7.6 does not understand that class tail padding can be reused for derived class data members. To work around this shortcoming, the type importer creates two structs for every record you're importing: one with the correct alignment/sizeof, and another one with the \"packed\" attribute and with a `$$` name prefix. If necessary, the importer will use the packed version to represent class inheritance -- this causes ugly casts when upcasting but it is the only way to get the correct object layout under IDA's current type model.\n\n#### Speeding up imports\n\nTo avoid useless re-imports, the IDA script keeps track of type definitions that have already been imported into the IDB. The type record is stored in a JSON file next to the IDB with the `.imported` file extension suffix.\n\nIf you want to force a type to be imported (e.g. because you have manually edited a struct in IDA and classgen isn't detecting the change), just tick the \"Force re-import\" checkbox when importing.\n\nAs yet another import time optimisation, it is possible to specify a list of types that will *never* be imported; instead, classgen will assume that they already exist in the IDB and will never attempt to create or update them. (This is also useful for minimising potential type breakage due to IDA bugs.) Simply create a text file next to the IDB with the `.skip` file extension suffix, and write each type that should be skipped on its own line.\n","funding_links":[],"categories":["Clang Plugins"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleoetlino%2Fclassgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleoetlino%2Fclassgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleoetlino%2Fclassgen/lists"}