├── .cproject ├── .gitattributes ├── .project ├── .settings ├── language.settings.xml ├── org.eclipse.cdt.codan.core.prefs ├── org.eclipse.cdt.core.prefs └── org.eclipse.cdt.managedbuilder.core.prefs ├── Debug └── src │ └── CppGuard.o ├── README.md └── src └── CppGuard.cpp /.cproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 73 | 74 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | CppGuard 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /.settings/org.eclipse.cdt.codan.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.cdt.codan.checkers.errnoreturn=Warning 3 | org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return\\")",implicit\=>false} 4 | org.eclipse.cdt.codan.checkers.errreturnvalue=Error 5 | org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused return value\\")"} 6 | org.eclipse.cdt.codan.checkers.nocommentinside=-Error 7 | org.eclipse.cdt.codan.checkers.nocommentinside.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Nesting comments\\")"} 8 | org.eclipse.cdt.codan.checkers.nolinecomment=-Error 9 | org.eclipse.cdt.codan.checkers.nolinecomment.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Line comments\\")"} 10 | org.eclipse.cdt.codan.checkers.noreturn=Error 11 | org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return value\\")",implicit\=>false} 12 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error 13 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Abstract class cannot be instantiated\\")"} 14 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error 15 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Ambiguous problem\\")"} 16 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning 17 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment in condition\\")"} 18 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error 19 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment to itself\\")"} 20 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning 21 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No break at end of case\\")",no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false,enable_fallthrough_quickfix_param\=>false} 22 | org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning 23 | org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Catching by reference is recommended\\")",unknown\=>false,exceptions\=>()} 24 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error 25 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Circular inheritance\\")"} 26 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning 27 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class members should be properly initialized\\")",skip\=>true} 28 | org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem=Error 29 | org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid 'decltype(auto)' specifier\\")"} 30 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error 31 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Field cannot be resolved\\")"} 32 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error 33 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Function cannot be resolved\\")"} 34 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error 35 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid arguments\\")"} 36 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error 37 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid template argument\\")"} 38 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error 39 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Label statement not found\\")"} 40 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error 41 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Member declaration not found\\")"} 42 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error 43 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Method cannot be resolved\\")"} 44 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info 45 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Name convention for function\\")",pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} 46 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning 47 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class has a virtual method and non-virtual destructor\\")"} 48 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error 49 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid overload\\")"} 50 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error 51 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redeclaration\\")"} 52 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error 53 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redefinition\\")"} 54 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning 55 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Return with parenthesis\\")"} 56 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning 57 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Format String Vulnerability\\")"} 58 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning 59 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Statement has no effect\\")",macro\=>true,exceptions\=>()} 60 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning 61 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suggested parenthesis around expression\\")",paramNot\=>false} 62 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning 63 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suspicious semicolon\\")",else\=>false,afterelse\=>false} 64 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error 65 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Type cannot be resolved\\")"} 66 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning 67 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused function declaration\\")",macro\=>true} 68 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning 69 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused static function\\")",macro\=>true} 70 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning 71 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused variable declaration in file scope\\")",macro\=>true,exceptions\=>("@(\#)","$Id")} 72 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error 73 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Symbol is not resolved\\")"} 74 | -------------------------------------------------------------------------------- /.settings/org.eclipse.cdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | environment/project/cdt.managedbuild.config.gnu.mingw.exe.debug.641917703/append=true 3 | environment/project/cdt.managedbuild.config.gnu.mingw.exe.debug.641917703/appendContributed=true 4 | -------------------------------------------------------------------------------- /.settings/org.eclipse.cdt.managedbuilder.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.641917703/CPATH/delimiter=; 3 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.641917703/CPATH/operation=remove 4 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.641917703/CPLUS_INCLUDE_PATH/delimiter=; 5 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.641917703/CPLUS_INCLUDE_PATH/operation=remove 6 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.641917703/C_INCLUDE_PATH/delimiter=; 7 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.641917703/C_INCLUDE_PATH/operation=remove 8 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.641917703/append=true 9 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.641917703/appendContributed=true 10 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.641917703/LIBRARY_PATH/delimiter=; 11 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.641917703/LIBRARY_PATH/operation=remove 12 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.641917703/append=true 13 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.641917703/appendContributed=true 14 | -------------------------------------------------------------------------------- /Debug/src/CppGuard.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techtocore/Cpp-Guard/435aa0a980bac35d400cf079254d4b2d2a6369b4/Debug/src/CppGuard.o -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cpp Guard 2 | 3 | This is a native C++ code obfuscator that scrambles C++ source code to make it very difficult to understand or reverse-engineer, while still keeping the execution and control flow intact. 4 | 5 | This shall provide significant protection for source code intellectual property, or help in testing behavioral based anti malware engines. 6 | 7 | ## Features 8 | 9 | 1. Strips single/multi line comments 10 | 2. Adding a pseudo-complex junk code snippet, while not affecting the asymptotic complexity of the overall program 11 | 3. Removing leading white-space 12 | 4. Removing line breaks 13 | 5. Handling all preprocessor directives, 'using' declarations and single-line 'else' clauses where the braces have been omitted. 14 | 6. Replacing string with its hex equivalent 15 | 16 | ## Todo 17 | 18 | 1. Optimize stripping of comments using regex 19 | 2. Implement renaming of variables 20 | 3. Change string encoding type - DONE 21 | -------------------------------------------------------------------------------- /src/CppGuard.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : CppGuard.cpp 3 | // Author : Akash Ravi 4 | // Version : 5 | // Copyright : akashravi.github.io 6 | // Description : Native C++ Code obfuscation tool 7 | //============================================================================ 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | const std::string TEMP_FILE = ".cppguard-temp-file.tmp"; 19 | 20 | bool containsOnlyWhite(const std::string &line) 21 | { 22 | std::string temp = line; 23 | temp.erase(remove_if(temp.begin(), temp.end(), isspace), temp.end()); 24 | return temp.size() <= 0; 25 | } 26 | 27 | void stripLeadingWhite(std::string &line) 28 | { 29 | if (line.size() > 0) 30 | { 31 | int nonWhiteIndex = 0; 32 | for (int i = 0; i < line.size(); ++i) 33 | { 34 | 35 | if (isspace(line.at(i))) 36 | { 37 | ++nonWhiteIndex; 38 | } 39 | else 40 | { 41 | break; 42 | } 43 | } 44 | 45 | line.erase(0, nonWhiteIndex); 46 | } 47 | } 48 | 49 | void stripSingleLineComment(std::string &line) 50 | { 51 | if (line.size() >= 2) 52 | { 53 | int loc = line.find("//"); 54 | if (loc != std::string::npos) 55 | { 56 | line.erase(loc); 57 | } 58 | } 59 | } 60 | 61 | void stripMultiLineComment(char *inFile) 62 | { 63 | std::ifstream inFileStream(inFile); 64 | std::ofstream outFileStream(TEMP_FILE.c_str()); 65 | std::string line; 66 | int startPos; 67 | int endPos; 68 | bool multiLine = false; 69 | while (std::getline(inFileStream, line)) 70 | { 71 | 72 | if (!multiLine) 73 | { 74 | startPos = line.find("/*"); 75 | if (startPos != std::string::npos) 76 | { 77 | endPos = line.find("*/"); 78 | if (endPos != std::string::npos) 79 | { 80 | int commentLength = (endPos + 2) - startPos; 81 | line.erase(startPos, commentLength); 82 | multiLine = false; 83 | } 84 | else 85 | { 86 | multiLine = true; 87 | line.erase(); 88 | } 89 | } 90 | } 91 | else 92 | { 93 | 94 | endPos = line.find("*/"); 95 | if (endPos != std::string::npos) 96 | { 97 | line.erase(0, endPos + 2); 98 | multiLine = false; 99 | } 100 | 101 | else 102 | { 103 | line.erase(); 104 | multiLine = true; 105 | } 106 | } 107 | if (line.size() > 0) 108 | { 109 | outFileStream << line << std::endl; 110 | } 111 | } 112 | inFileStream.close(); 113 | outFileStream.close(); 114 | } 115 | 116 | std::string asciiReplace(std::string s) 117 | { 118 | std::string p = ""; 119 | int q; 120 | for (int i = 0; i <= s.size(); i++) 121 | { 122 | p += ('\\'); 123 | p += ('x'); 124 | std::stringstream stream; 125 | stream << std::hex << (int)s[i]; 126 | std::string result(stream.str()); 127 | p += result; 128 | } 129 | return p; 130 | } 131 | 132 | void obfuscateString(std::string &line) 133 | { 134 | // std::ifstream inFileStream(inFile); 135 | // std::ofstream outFileStream(TEMP_FILE.c_str()); 136 | // std::string line; 137 | int startPos; 138 | int endPos; 139 | // while (std::getline(inFileStream, line)) 140 | { 141 | 142 | startPos = endPos = 0; 143 | bool flag = 1; 144 | std::string tmpStr; 145 | for (int i = 0; i <= line.size(); i++) 146 | { 147 | if (flag and line[i] == '\"') 148 | { 149 | startPos = i; 150 | flag = 0; 151 | continue; 152 | } 153 | if (flag == 0 and line[i] == '\"') 154 | { 155 | endPos = i; 156 | break; 157 | } 158 | } 159 | if (endPos == 0) 160 | { 161 | return; 162 | } 163 | for (int i = startPos + 1; i < endPos; i++) 164 | { 165 | tmpStr += line[i]; 166 | } 167 | tmpStr = asciiReplace(tmpStr); 168 | int commentLength = (endPos + 2) - startPos; 169 | line.erase(startPos + 1, endPos - startPos - 1); 170 | line.insert(startPos + 1, tmpStr); 171 | if (line.size() > 0) 172 | { 173 | //outFileStream << line << std::endl; 174 | } 175 | } 176 | //inFileStream.close(); 177 | //outFileStream.close(); 178 | } 179 | 180 | int main(int argc, char *argv[]) 181 | { 182 | if (argc != 3) 183 | { 184 | std::cerr << "\n\tWelcome to CppGuard - a cross platform C++ code obfuscation tool\n\n"; 185 | std::cerr << "\t\tCurrently, this application is a command line utility\n"; 186 | std::cerr << "\t\tUsage: ./cppguard infile outfile\n"; 187 | exit(1); 188 | } 189 | 190 | std::string junkText = "int ppp = 23;string dds = std::bitset<63>(ppp).to_string();string hhh; string ggg;ggg = dds;ffrr(i, dds.size() - 2, dds.size()) hhh += dds[i];int hyy = hhh.size();dds.clear();ffrr(i, 0, 31 - hyy){dds += '1';}vvvsort(dds);vvvuni(dds);ffrr(i, 0, hyy){dds += hhh[i];}hyy = std::bitset<63>(ggg).to_ulong();ggg.clear();if(ggg.size()!=0)cout<<\"yedhukku\";reverse(dds.begin(),dds.end());"; 191 | 192 | stripMultiLineComment(argv[1]); 193 | //obfuscateString(argv[1]); 194 | 195 | int jflag = 10; 196 | int fl = 0; 197 | 198 | std::ifstream inFileStream(TEMP_FILE.c_str()); 199 | std::ofstream outFileStream(argv[2]); 200 | std::string line; 201 | outFileStream << "#include" << std::endl; 202 | outFileStream << "#define ffrr(i,a,b) for(long long int i=a;i 0) 214 | { 215 | if ((line.find("main(") != std::string::npos) and fl == 0) 216 | { 217 | 218 | fl = 1; 219 | } 220 | if (fl == 1 and (line.find("{") != std::string::npos)) 221 | { 222 | jflag = 0; 223 | } 224 | if ((line.find("#include") != std::string::npos) or (line.find("# include") != std::string::npos)) 225 | { 226 | continue; 227 | } 228 | else if (line.find("#") != std::string::npos || 229 | line.find("using") != std::string::npos || 230 | line == "else") 231 | { 232 | 233 | outFileStream << std::endl 234 | << line << std::endl; 235 | } 236 | else if (jflag == 0) 237 | { 238 | outFileStream << std::endl 239 | << line << std::endl 240 | << junkText << std::endl; 241 | jflag = 1; 242 | } 243 | else 244 | { 245 | outFileStream << line; 246 | } 247 | } 248 | } 249 | } 250 | 251 | inFileStream.close(); 252 | outFileStream.close(); 253 | remove(TEMP_FILE.c_str()); 254 | return 0; 255 | } 256 | --------------------------------------------------------------------------------