P2: Modernize C++, clean up dead code, add error handling to junk mode - #20
Merged
Conversation
Issue #9 — C++ modernization (partial): - Replace clock()/CLOCKS_PER_SEC with std::chrono::steady_clock - Remove #define NOMINMAX (now in vcxproj preprocessor defs) - Remove srand() from main() (kept in TrampolineInjector constructor) - Cast to unsigned char for std::isdigit (avoid UB with signed char) - Add #include <cstdint> and <climits> for INT32_MAX/INT32_MIN Issue #11 — main.cpp cleanup: - Rename DetectPEArchitecture → detect_pe_architecture (snake_case) - Rename camelCase locals to snake_case (filePath→file_path, etc.) - Add try/catch to junk code mode (was unprotected) - Check std::getline return values (handle EOF/error) - Initialize is_64_bit to false in junk code mode - Remove redundant peFile.close() calls (RAII handles it) - Remove misleading comment ("32-bit right rotation function" on strcmp) - Rename print_execution_time → print_elapsed_time Clean up dead code: - Remove unused CFF namespace and obfuscatecff_extensions from cfflattening.h (duplicated BasicBlock struct, never-used declarations) Closes #9, Closes #11
sondt99
added a commit
that referenced
this pull request
Aug 10, 2026
P2: Modernize C++, clean up dead code, add error handling to junk mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
clock()withstd::chrono::steady_clockfor accurate wall-clock timingsrand()from main() — single seeding point remains inTrampolineInjectortry/catchto junk code mode — was missing, exceptions crashed the processstd::getlinereturn values — handle EOF/pipe correctlyDetectPEArchitecturetodetect_pe_architecture(consistent snake_case)cfflattening.h(unusedCFFnamespace, duplicatedBasicBlockstruct, unusedobfuscatecff_extensionsnamespace)<cstdint>/<climits>includes forINT32_MAX/INT32_MINused in P0 fixChanges Made
main.cppobfuscatecff.cpp<cstdint>/<climits>, remove misleading commentcfflattening.hChecklist
clock()→std::chrono::steady_clockin both modessrand()removed frommain()(single seed in TrampolineInjector)mode_trampoline_junkcode()std::getlinereturn values checked (3 locations)std::isdigitcalled withunsigned charcastDetectPEArchitecture→detect_pe_architecture#define NOMINMAXremoved (now in vcxproj preprocessor defs)is_64_bitinitialized tofalsein junk modeCFFandobfuscatecff_extensionsnamespaces removed from cfflattening.hTest plan
match_check.pyon full test suiteCloses #9, Closes #11