Active Member Kori 219 Posted February 20 Active Member Share Posted February 20 (edited) DefineExtractor β Extract Preprocessor Defines from C/C++ Code Lightweight & Fast Tool for Extracting Preprocessor Macros Β π Features:Β Β Extracts `#define` macros from C and C++ source code. Β Supports complex macros, including those with parameters. Β Fast & efficient β parses large codebases with minimal overhead. Β Standalone tool β no dependencies required, runs directly. Β Ideal for static analysis, reverse engineering, and code auditing. Β Β How It Works: - Scans `.c`, `.cpp`, `.h`, and `.hpp` files for `#define` statements. Β - Extracts macro names, values, and parameters. Β - Outputs structured results for easy processing. Β Β Download & Usage: GitHub Repository:Β This is the hidden content, please Sign In or Sign Up How to use: Clone the repository: Β git clone https://github.com/M2tecDev/DefineExtractor.git Compile the tool (if needed) or run the precompiled binary. Β Extract macros from source files. View extracted defines in the output. Β FAQ: What is this tool useful for? - Reverse engineering legacy codebases. Β - Static analysis of C/C++ projects. Β - Automating the extraction of preprocessor macros. Β Is it open-source? Yes! The project is fully open-source under the MIT license. Β Can it handle large projects? Absolutely! It is optimized for performance and can process large amounts of code efficiently. Β Β Feedback & Contributions Welcome! - Found a bug or have a feature request? Open an issue on GitHub! Β - Contributions are welcome β feel free to submit a pull request. Β GitHub Repo:Β This is the hidden content, please Sign In or Sign Up Β orΒ This is the hidden content, please Sign In or Sign Up V0.4 Video: Changelogs Β Spoiler Changelog 0.3 Multi-Threaded Parsing Improvements Introduced a dynamic, multi-threaded approach for scanning .cpp, .h, and .py files. Uses atomic counters (std::atomic<size_t>) to coordinate file indexing and track processed lines. Prevents potential race conditions when aggregating results from each thread by using mutex locks. Enhanced Regex Detection Refined the regular expressions for identifying C/C++ #if, #ifdef, and #elif directives. Created a unified function (createConditionalRegex) to handle various forms of conditional compilation checks more reliably. Improved the function signature detection (functionHeadRegex) for multi-line function definitions, reducing missed or incorrectly captured blocks. Python File Analysis Added a specialized parser (parsePythonFileSinglePass) to detect if app.<param> blocks in .py files. Collects both the if blocks and their enclosing function blocks to give a clearer context of where app.<param> is used. Respects indentation and handles multi-line blocks, ensuring more accurate extraction of relevant code sections. Line Counting and Progress Updates Implemented a global line-count cache to avoid recounting lines for the same file, improving performance. Enhanced the progress bar to update at controlled intervals (about every ~100ms), preventing excessive console output and flicker. File System and Path Detection Improved cross-platform directory scanning with additional checks for symlinks, permission-denied folders, and non-regular files. Added dedicated functions to locate project-specific header files (e.g., locale_inc.h and service.h/commondefines.h) within nested folder structures. Introduced support for detecting Python root folders to facilitate scanning .py files in specific directories. User Interface & Menu System Updated console color handling to be more uniform between Windows and Unix-like systems. Revised the menu prompts to clarify the steps for configuring client path, server path, and Python root directories. Provided user feedback about found headers or missing files in a more concise manner. Bug Fixes and Stability Fixed an issue where nested #if/#endif blocks were not always correctly matched when scanning files with multiple conditional levels. Resolved concurrency problems that could lead to incomplete parsing results if too many threads were launched. Addressed minor formatting inconsistencies in generated output files (e.g., extra blank lines at the end of extracted code blocks). Why These Changes? Some users reported problems with partial or incorrect extraction of code blocks, especially in larger projects with nested conditionals, multi-line function declarations, and Python scripts. These updates introduce more robust, multi-threaded parsing logic and refined regex matching to ensure DefineExtractor handles a broader range of code structures accurately. The improvements in file system scanning, path detection, and user-interface feedback also help avoid common setup issues, leading to a more stable and user-friendly experience overall. Β Β Spoiler v0.4 Separate Output per Source File A new function, writeOutputPerFile(), writes the matched blocks into separate text files for each source file. Instead of combining everything into one large file, the program now creates subdirectories (e.g. Output/CLIENT_<DEFINE>_files) and places a separate .txt for each .cpp/.h that contained relevant blocks. Header File Snippets For .h files, the program only records a small snippet (Β±2 lines) around #if <DEFINE> lines, rather than dumping the entire #if ... #endif block. This helps keep the results for headers concise. Public/Private Region Detection When scanning .h files, the parser now notices public: and private: sections; in each snippet, it logs which region was currently in effect ([Currently in PRIVATE region] or [Currently in PUBLIC region]). Overall Parsing Flow Restructured The parseFileSinglePass() function has been significantly reworked to handle .h and .cpp differently within a single pass. .cpp files still behave as before: full #if β¦ #endif blocks are captured. .h files follow the snippet-based approach. Unchanged Python Parsing The logic for scanning .py files (parsePythonFileSinglePass() and related code) remains essentially the same as before. More Organized Output For each define (client or server), there is now a subdirectory that gathers the found blocks by file, making it easier to locate which .cpp/.h had the matched code. Β Β Edited February 26 by Kori update 25 2 13 Link to comment https://metin2.dev/topic/33491-c-define-parser/ Share on other sites More sharing options...
Premium Muzan 1 Posted March 31 Premium Share Posted March 31 Β I'am just joking, Works well. Nice work. 1 Link to comment https://metin2.dev/topic/33491-c-define-parser/#findComment-170095 Share on other sites More sharing options...
Recommended Posts
Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now