├── .editorconfig
├── .gitattributes
├── .github
├── CODEOWNERS
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── config.yml
│ └── feature_request.md
├── dependabot.yml
└── workflows
│ ├── codeql-analysis.yml
│ ├── issue-lock.yml
│ └── issue-stale.yml
├── .gitignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── Confuser.CLI
├── Confuser.CLI.csproj
└── Program.cs
├── Confuser.Core
├── API
│ ├── APIStore.cs
│ ├── IDataStore.cs
│ └── IOpaquePredicate.cs
├── Annotations.cs
├── Confuser.Core.csproj
├── Confuser.Core.packages.config
├── ConfuserAssemblyResolver.cs
├── ConfuserComponent.cs
├── ConfuserContext.cs
├── ConfuserEngine.cs
├── ConfuserException.cs
├── ConfuserParameters.cs
├── CoreComponent.cs
├── DependencyResolver.cs
├── DnlibUtils.cs
├── Helpers
│ ├── ControlFlowGraph.cs
│ ├── InjectHelper.cs
│ ├── KeySequence.cs
│ └── MutationHelper.cs
├── ILogger.cs
├── LZMA
│ ├── Common
│ │ ├── CRC.cs
│ │ ├── InBuffer.cs
│ │ └── OutBuffer.cs
│ ├── Compress
│ │ ├── LZ
│ │ │ ├── IMatchFinder.cs
│ │ │ ├── LzBinTree.cs
│ │ │ ├── LzInWindow.cs
│ │ │ └── LzOutWindow.cs
│ │ ├── LZMA
│ │ │ ├── LzmaBase.cs
│ │ │ ├── LzmaDecoder.cs
│ │ │ └── LzmaEncoder.cs
│ │ └── RangeCoder
│ │ │ ├── RangeCoder.cs
│ │ │ ├── RangeCoderBit.cs
│ │ │ └── RangeCoderBitTree.cs
│ └── ICoder.cs
├── Marker.cs
├── MarkerResult.cs
├── ModuleSorter.cs
├── NativeEraser.cs
├── NullLogger.cs
├── ObfAttrMarker.cs
├── ObfAttrParser.cs
├── Packer.cs
├── PluginDiscovery.cs
├── Project
│ ├── ConfuserPrj.xsd
│ ├── ConfuserProject.cs
│ ├── InvalidPatternException.cs
│ ├── PatternParser.cs
│ ├── PatternToken.cs
│ ├── PatternTokenizer.cs
│ └── Patterns
│ │ ├── AndOperator.cs
│ │ ├── DeclTypeFunction.cs
│ │ ├── FullNameFunction.cs
│ │ ├── HasAttrFunction.cs
│ │ ├── InheritsFunction.cs
│ │ ├── IsPublicFunction.cs
│ │ ├── IsTypeFunction.cs
│ │ ├── LiteralExpression.cs
│ │ ├── MatchFunction.cs
│ │ ├── MemberTypeFunction.cs
│ │ ├── ModuleFunction.cs
│ │ ├── NameFunction.cs
│ │ ├── NamespaceFunction.cs
│ │ ├── NotOperator.cs
│ │ ├── OrOperator.cs
│ │ ├── PatternExpression.cs
│ │ ├── PatternFunction.cs
│ │ └── PatternOperator.cs
├── Protection.cs
├── ProtectionDependencyAttributes.cs
├── ProtectionParameters.cs
├── ProtectionPhase.cs
├── ProtectionPipeline.cs
├── ProtectionPreset.cs
├── ProtectionSettings.cs
├── ProtectionTargets.cs
├── ServiceRegistry.cs
├── Services
│ ├── CompressionService.cs
│ ├── MarkerService.cs
│ ├── RandomService.cs
│ ├── RuntimeService.cs
│ └── TraceService.cs
├── UnreachableException.cs
├── Utils.cs
└── WatermarkingProtection.cs
├── Confuser.DynCipher
├── AST
│ ├── ArrayIndexExpression.cs
│ ├── AssignmentStatement.cs
│ ├── BinOpExpression.cs
│ ├── Expression.cs
│ ├── LiteralExpression.cs
│ ├── LoopStatement.cs
│ ├── Statement.cs
│ ├── StatementBlock.cs
│ ├── UnaryOpExpression.cs
│ ├── Variable.cs
│ └── VariableExpression.cs
├── Confuser.DynCipher.csproj
├── DynCipherComponent.cs
├── DynCipherService.cs
├── Elements
│ ├── AddKey.cs
│ ├── BinOp.cs
│ ├── CryptoElement.cs
│ ├── Matrix.cs
│ ├── NumOp.cs
│ ├── RotateBit.cs
│ └── Swap.cs
├── Generation
│ ├── CILCodeGen.cs
│ ├── CipherGenContext.cs
│ ├── CipherGenerator.cs
│ ├── DMCodeGen.cs
│ ├── ExpressionGenerator.cs
│ └── x86CodeGen.cs
├── Transforms
│ ├── ConvertVariables.cs
│ ├── ExpansionTransform.cs
│ ├── MulToShiftTransform.cs
│ ├── NormalizeBinOpTransform.cs
│ └── ShuffleTransform.cs
└── Utils.cs
├── Confuser.MSBuild.Tasks
├── ConfuseTask.cs
├── Confuser.MSBuild.Tasks.csproj
├── CreateProjectTask.cs
├── MSBuildLogger.cs
└── build
│ ├── Confuser.MSBuild.Tasks.targets
│ └── Confuser.MSBuild.targets
├── Confuser.Protections
├── AntiDebugProtection.cs
├── AntiDumpProtection.cs
├── AntiILDasmProtection.cs
├── AntiTamper
│ ├── AntiMode.cs
│ ├── AntiTamperExtensions.cs
│ ├── AntiTamperProtection.cs
│ ├── DynamicDeriver.cs
│ ├── IKeyDeriver.cs
│ ├── IModeHandler.cs
│ ├── JITBody.cs
│ ├── JITMode.cs
│ ├── NormalDeriver.cs
│ └── NormalMode.cs
├── Compress
│ ├── Compressor.cs
│ ├── CompressorContext.cs
│ ├── DynamicDeriver.cs
│ ├── ExtractPhase.cs
│ ├── IKeyDeriver.cs
│ ├── NormalDeriver.cs
│ └── StubProtection.cs
├── Confuser.Protections.csproj
├── Constants
│ ├── CEContext.cs
│ ├── ConstantProtection.cs
│ ├── DynamicMode.cs
│ ├── EncodeElements.cs
│ ├── EncodePhase.cs
│ ├── IEncodeMode.cs
│ ├── InjectPhase.cs
│ ├── Mode.cs
│ ├── NormalMode.cs
│ ├── ReferenceReplacer.cs
│ └── x86Mode.cs
├── ControlFlow
│ ├── BlockParser.cs
│ ├── Blocks.cs
│ ├── CFContext.cs
│ ├── ControlFlowPhase.cs
│ ├── ControlFlowProtection.cs
│ ├── ExpressionPredicate.cs
│ ├── IPredicate.cs
│ ├── JumpMangler.cs
│ ├── ManglerBase.cs
│ ├── NormalPredicate.cs
│ ├── SwitchMangler.cs
│ └── x86Predicate.cs
├── HardeningPhase.cs
├── HardeningProtection.cs
├── InvalidMetadataProtection.cs
├── ReferenceProxy
│ ├── ExpressionEncoding.cs
│ ├── IRPEncoding.cs
│ ├── MildMode.cs
│ ├── NormalEncoding.cs
│ ├── RPContext.cs
│ ├── RPMode.cs
│ ├── ReferenceProxyPhase.cs
│ ├── ReferenceProxyProtection.cs
│ ├── StrongMode.cs
│ └── x86Encoding.cs
├── Resources
│ ├── DynamicMode.cs
│ ├── IEncodeMode.cs
│ ├── InjectPhase.cs
│ ├── MDPhase.cs
│ ├── Mode.cs
│ ├── NormalMode.cs
│ ├── REContext.cs
│ └── ResourceProtection.cs
└── TypeScrambler
│ ├── AnalyzePhase.cs
│ ├── ScramblePhase.cs
│ ├── Scrambler
│ ├── Analyzers
│ │ ├── ContextAnalyzer.cs
│ │ ├── ContextAnalyzerFactory.cs
│ │ ├── ContextAnalyzer`1.cs
│ │ ├── MemberRefAnalyzer.cs
│ │ ├── MethodDefAnalyzer.cs
│ │ ├── MethodSpecAnalyzer.cs
│ │ └── TypeRefAnalyzer.cs
│ ├── Rewriter
│ │ └── Instructions
│ │ │ ├── FieldDefInstructionRewriter.cs
│ │ │ ├── InstructionRewriter.cs
│ │ │ ├── InstructionRewriterFactory.cs
│ │ │ ├── InstructionRewriter`1.cs
│ │ │ ├── MemberRefInstructionRewriter.cs
│ │ │ ├── MethodDefInstructionRewriter.cs
│ │ │ ├── MethodSpecInstructionRewriter.cs
│ │ │ ├── TypeDefInstructionRewriter.cs
│ │ │ └── TypeRefInstructionRewriter.cs
│ ├── ScannedItem.cs
│ ├── ScannedMethod.cs
│ ├── ScannedType.cs
│ ├── SignatureUtils.cs
│ └── TypeRewriter.cs
│ ├── TypeScrambleProtection.cs
│ └── TypeService.cs
├── Confuser.Renamer
├── AnalyzePhase.cs
├── Analyzers
│ ├── CaliburnAnalyzer.cs
│ ├── CallSiteAnalyzer.cs
│ ├── InterReferenceAnalyzer.cs
│ ├── JsonAnalyzer.cs
│ ├── LdtokenEnumAnalyzer.cs
│ ├── ManifestResourceAnalyzer.cs
│ ├── ReflectionAnalyzer.cs
│ ├── ResourceAnalyzer.cs
│ ├── TypeBlobAnalyzer.cs
│ ├── VTableAnalyzer.cs
│ ├── VisualBasicRuntimeAnalyzer.cs
│ ├── VsCompositionAnalyzer.cs
│ ├── WPFAnalyzer.cs
│ └── WinFormsAnalyzer.cs
├── BAML
│ ├── BAMLAnalyzer.cs
│ ├── BAMLPropertyReference.cs
│ ├── BAMLStringReference.cs
│ ├── BamlDocument.cs
│ ├── BamlElement.cs
│ ├── BamlRW.cs
│ ├── BamlRecords.cs
│ ├── IBAMLReference.cs
│ ├── IKnownThings.cs
│ ├── KnownThingsv3.cs
│ ├── KnownThingsv4.cs
│ ├── PropertyPath
│ │ ├── DrillIn.cs
│ │ ├── IndexerParamInfo.cs
│ │ ├── PropertyPathParser.cs
│ │ ├── README.md
│ │ ├── SourceValueInfo.cs
│ │ └── SourceValueType.cs
│ ├── PropertyPathIndexUpdater.cs
│ ├── PropertyPathPartUpdater.cs
│ └── PropertyPathUpdater.cs
├── Confuser.Renamer.csproj
├── DisplayNormalizedName.cs
├── GenericArgumentResolver.cs
├── GenericArguments.cs
├── INameReference.cs
├── IRenamer.cs
├── MessageDeobfuscator.cs
├── NameProtection.cs
├── NameService.cs
├── PostRenamePhase.cs
├── Properties
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── RecursionCounter.cs
├── ReferenceUtilities.cs
├── References
│ ├── BAMLAttributeReference.cs
│ ├── BAMLConverterMemberReference.cs
│ ├── BAMLConverterTypeReference.cs
│ ├── BAMLEnumReference.cs
│ ├── BAMLPathTypeReference.cs
│ ├── BAMLTypeReference.cs
│ ├── CAMemberReference.cs
│ ├── MemberOldestSiblingReference.cs
│ ├── MemberOverrideReference.cs
│ ├── MemberRefReference.cs
│ ├── MemberSiblingReference.cs
│ ├── OverrideDirectiveReference.cs
│ ├── RequiredPrefixReference.cs
│ ├── ResourceReference.cs
│ ├── StringMemberNameReference.cs
│ ├── StringTypeReference.cs
│ └── TypeRefReference.cs
├── RenameMode.cs
├── RenamePhase.cs
├── ReversibleRenamer.cs
├── RickRoller.cs
└── VTable.cs
├── Confuser.Runtime
├── AntiDebug.Antinet.cs
├── AntiDebug.Safe.cs
├── AntiDebug.Win32.cs
├── AntiDump.cs
├── AntiTamper.Anti.cs
├── AntiTamper.JIT.cs
├── AntiTamper.Normal.cs
├── Compressor.Compat.cs
├── Compressor.cs
├── Confuser.Runtime.csproj
├── Constant.cs
├── ExcludeFromCodeCoverageAttribute.cs
├── Lzma.cs
├── Mutation.cs
├── RefProxy.Strong.cs
├── Resource.cs
└── antinet
│ ├── ABOUT
│ ├── AntiManagedDebugger.cs
│ ├── AntiManagedProfiler.cs
│ ├── HandleProcessCorruptedStateExceptionsAttribute.cs
│ └── PEInfo.cs
├── Confuser2.sln
├── ConfuserEx.Common.props
├── ConfuserEx.Common.targets
├── ConfuserEx.snk
├── ConfuserEx
├── App.xaml
├── App.xaml.cs
├── BoolToVisibilityConverter.cs
├── BrushToColorConverter.cs
├── CompComboBox.xaml
├── CompComboBox.xaml.cs
├── ComponentConverter.cs
├── ComponentDiscovery.cs
├── ConfuserEx.csproj
├── ConfuserEx.ico
├── EmptyToBoolConverter.cs
├── EnumValuesExtension.cs
├── FileDragDrop.cs
├── InvertBoolConverter.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Resources
│ ├── CREDITS
│ ├── Decode.png
│ ├── Error.png
│ ├── FontAwesome.otf
│ ├── New.png
│ ├── Open.png
│ ├── Save.png
│ └── Tools.png
├── Skin.cs
├── Skin.xaml
├── StackTraceDecoder.xaml
├── StackTraceDecoder.xaml.cs
├── ViewModel
│ ├── IViewModel.cs
│ ├── Project
│ │ ├── ProjectModuleVM.cs
│ │ ├── ProjectRuleVM.cs
│ │ ├── ProjectSettingVM.cs
│ │ └── ProjectVM.cs
│ ├── StringItem.cs
│ ├── UI
│ │ ├── AboutTabVM.cs
│ │ ├── AppVM.cs
│ │ ├── ProjectTabVM.cs
│ │ ├── ProtectTabVM.cs
│ │ ├── SettingsTabVM.cs
│ │ └── TabViewModel.cs
│ ├── Utils.cs
│ └── ViewModelBase.cs
├── Views.xaml
├── Views
│ ├── AboutTabView.xaml
│ ├── ProjectModuleView.xaml
│ ├── ProjectModuleView.xaml.cs
│ ├── ProjectRuleView.xaml
│ ├── ProjectRuleView.xaml.cs
│ ├── ProjectTabAdvancedView.xaml
│ ├── ProjectTabAdvancedView.xaml.cs
│ ├── ProjectTabView.xaml
│ ├── ProtectTabView.xaml
│ └── SettingsTabView.xaml
└── app.config
├── GlobalAssemblyInfo.cs
├── LICENSE.md
├── README.md
├── Tests
├── 118_EnhancedStrongName.Test
│ ├── 118_EnhancedStrongName.Test.csproj
│ └── EnhancedStrongNameTest.cs
├── 118_EnhancedStrongName
│ ├── 118_EnhancedStrongName.csproj
│ ├── Attributes.cs
│ ├── IClrStrongName.cs
│ ├── IdentityKey.snk
│ ├── IdentityPubKey.snk
│ ├── Program.cs
│ ├── SignatureKey.snk
│ └── SignaturePubKey.snk
├── 123_InheritCustomAttr.Test
│ ├── 123_InheritCustomAttr.Test.csproj
│ └── InheritCustomAttributeTest.cs
├── 123_InheritCustomAttr
│ ├── 123_InheritCustomAttr.csproj
│ ├── C.cs
│ ├── D.cs
│ ├── E.cs
│ ├── ExtReference
│ │ ├── C.cs
│ │ ├── IExt.cs
│ │ ├── IExt`2.cs
│ │ └── IRoot.cs
│ ├── I.cs
│ ├── IDayOfWeek.cs
│ ├── MyAttribute.cs
│ └── Program.cs
├── 161_DynamicTypeRename.Test
│ ├── 161_DynamicTypeRename.Test.csproj
│ └── RenameDynamicMethodTest.cs
├── 161_DynamicTypeRename
│ ├── 161_DynamicTypeRename.csproj
│ └── Program.cs
├── 193_ConstantsInlining.Lib
│ ├── 193_ConstantsInlining.Lib.csproj
│ └── ExternalClass.cs
├── 193_ConstantsInlining.Test
│ ├── 193_ConstantsInlining.Test.csproj
│ └── ConstantInliningTest.cs
├── 193_ConstantsInlining
│ ├── 193_ConstantsInlining.csproj
│ └── Program.cs
├── 244_ClrProtection.Test
│ ├── 244_ClrProtection.Test.csproj
│ └── ProtectClrAssemblyTest.cs
├── 244_ClrProtection
│ ├── 244_ClrProtection.vcxproj
│ ├── 244_ClrProtection.vcxproj.filters
│ └── Program.cpp
├── 252_ComplexInterfaceRenaming.Test
│ ├── 252_ComplexInterfaceRenaming.Test.csproj
│ └── RenameComplexInterfaceTest.cs
├── 252_ComplexInterfaceRenaming
│ ├── 252_ComplexInterfaceRenaming.csproj
│ ├── IC.cs
│ ├── IName.cs
│ ├── IOperator.cs
│ ├── IWorker.cs
│ ├── Manager.cs
│ ├── Operator.cs
│ ├── Program.cs
│ └── Worker.cs
├── 270_EnumArrayConstantProtection.Test
│ ├── 270_EnumArrayConstantProtection.Test.csproj
│ └── ConstantProtectionTest.cs
├── 270_EnumArrayConstantProtection
│ ├── 270_EnumArrayConstantProtection.csproj
│ ├── Level.cs
│ └── Program.cs
├── 306_ComplexClassStructureRename.Lib
│ ├── 306_ComplexClassStructureRename.Lib.csproj
│ ├── ITestEvents.cs
│ ├── InternalBaseClass.cs
│ ├── InternalClass1.cs
│ ├── InternalClass2.cs
│ ├── MyTest.cs
│ ├── PublicClass1.cs
│ └── PublicClass2.cs
├── 306_ComplexClassStructureRename.Test
│ ├── 306_ComplexClassStructureRename.Test.csproj
│ └── ComplexRenameTest.cs
├── 306_ComplexClassStructureRename
│ ├── 306_ComplexClassStructureRename.csproj
│ └── Program.cs
├── 342_InterfaceRenamingLoop.Test
│ ├── 342_InterfaceRenamingLoop.Test.csproj
│ └── InterfaceRenamingLoopTest.cs
├── 342_InterfaceRenamingLoop
│ ├── 342_InterfaceRenamingLoop.csproj
│ ├── CBase.cs
│ ├── ClassA.cs
│ ├── ClassB.cs
│ ├── IAEvents.cs
│ └── Program.cs
├── 345_RenameDynamicParameter.Test
│ ├── 345_RenameDynamicParameter.Test.csproj
│ └── RenameDynamicParameterTest.cs
├── 345_RenameDynamicParameter
│ ├── 345_RenameDynamicParameter.csproj
│ ├── ConstructorTestClass.cs
│ ├── FieldTestClass.cs
│ ├── OverloadTestClass.cs
│ ├── OverrideBaseTestClass.cs
│ ├── OverrideTestClass.cs
│ ├── Program.cs
│ └── SimpleTestClass.cs
├── 389_MixedCultureCasing.Test
│ ├── 389_MixedCultureCasing.Test.csproj
│ └── MixedCultureCasingTest.cs
├── 389_MixedCultureCasing
│ ├── 389_MixedCultureCasing.csproj
│ ├── Program.cs
│ ├── Resource1.Designer.cs
│ ├── Resource1.de-DE.resx
│ ├── Resource1.resx
│ ├── Resource2.Designer.cs
│ ├── Resource2.de-de.resx
│ └── Resource2.resx
├── 421_NewtonsoftJsonSerialization.Test
│ ├── 421_NewtonsoftJsonSerialization.Test.csproj
│ └── NewtonsoftJsonTest.cs
├── 421_NewtonsoftJsonSerialization
│ ├── 421_NewtonsoftJsonSerialization.csproj
│ ├── ObfExcluded.cs
│ ├── ObfMarkedWithAttribute.cs
│ └── Program.cs
├── 470_ImplementationInBaseClass.Test
│ ├── 470_ImplementationInBaseClass.Test.csproj
│ └── RenameTest.cs
├── 470_ImplementationInBaseClass
│ ├── 470_ImplementationInBaseClass.csproj
│ ├── IMyInterfaceA.cs
│ ├── IMyInterfaceB.cs
│ ├── IMyInterfaceC.cs
│ ├── MyBaseClass.cs
│ ├── MyClassA.cs
│ ├── MyClassB.cs
│ ├── MyClassB2.cs
│ ├── MyClassC.cs
│ └── Program.cs
├── 78_SignatureMismatch.Test
│ ├── 78_SignatureMismatch.Test.csproj
│ └── SignatureMismatchTest.cs
├── 78_SignatureMismatch
│ ├── 78_SignatureMismatch.csproj
│ ├── EasyDict.cs
│ ├── EasyFile.cs
│ └── Program.cs
├── AntiTamper.Test
│ ├── AntiTamper.Test.csproj
│ └── AntiTamperTest.cs
├── AntiTamper
│ ├── AntiTamper.csproj
│ ├── Program.cs
│ └── Properties
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
├── BlockingReferences.Test
│ ├── BlockingReferences.Test.csproj
│ └── Program.cs
├── BlockingReferences
│ ├── BlockingReferences.csproj
│ └── Program.cs
├── BlockingReferencesHelper
│ ├── BaseImplementation.cs
│ └── BlockingReferencesHelper.csproj
├── CompressorWithResx.Test
│ ├── CompressTest.cs
│ └── CompressorWithResx.Test.csproj
├── CompressorWithResx
│ ├── CompressorWithResx.csproj
│ ├── Program.cs
│ └── Properties
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.de.resx
│ │ └── Resources.resx
├── Confuser.Core.Test
│ ├── Confuser.Core.Test.csproj
│ ├── Helpers.cs
│ ├── Services
│ │ └── TraceServiceTest.cs
│ └── UtilsTest.cs
├── Confuser.Renamer.Test
│ ├── AbstractAttribute.cs
│ ├── Analyzers
│ │ ├── ManifestResourceAnalyzerTest.cs
│ │ ├── ReflectionAnalyzerTest.cs
│ │ └── TypeBlobAnalyzerTest.cs
│ ├── Confuser.Renamer.Test.csproj
│ ├── Helpers.cs
│ ├── ImplementationAttribute.cs
│ └── VTableTest.cs
├── Confuser.UnitTest
│ ├── Confuser.UnitTest.csproj
│ ├── FileUtilities.cs
│ ├── TestBase.cs
│ └── XUnitLogger.cs
├── IncorrectRedirectToGac.Test
│ ├── IncorrectRedirectToGac.Test.csproj
│ └── IncorrectRedirectToGacTest.cs
├── IncorrectRedirectToGac
│ ├── IncorrectRedirectToGac.csproj
│ └── Program.cs
├── MessageDeobfuscation.Test
│ ├── MessageDeobfuscation.Test.csproj
│ └── MessageDeobfuscationTest.cs
├── MessageDeobfuscation
│ ├── MessageDeobfuscation.csproj
│ └── Program.cs
├── MethodOverloading.Test
│ ├── MethodOverloading.Test.csproj
│ └── MethodOverloadingTest.cs
├── MethodOverloading
│ ├── MethodOverloading.csproj
│ └── Program.cs
├── ReferenceProxy.Test
│ ├── ReferenceProxy.Test.csproj
│ └── ReferenceProxyTest.cs
├── ReferenceProxy
│ ├── Program.cs
│ └── ReferenceProxy.csproj
├── SignatureMismatch2.Test
│ ├── SignatureMismatch2.Test.csproj
│ └── SignatureMismatch2Test.cs
├── SignatureMismatch2
│ ├── Program.cs
│ └── SignatureMismatch2.csproj
├── SignatureMismatch2Helper
│ ├── External.cs
│ └── SignatureMismatch2Helper.csproj
├── TypeScrambler.Test
│ ├── TypeScrambler.Test.csproj
│ └── TypeScramblerTest.cs
├── TypeScrambler
│ ├── ExplicitInterface.cs
│ ├── FactoryPattern.cs
│ ├── GenericClass.cs
│ ├── ITestInterface.cs
│ ├── ImplicitInterface.cs
│ ├── Program.cs
│ ├── Properties
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── TestClass.cs
│ └── TypeScrambler.csproj
├── VisualBasicRenamingResx.Test
│ ├── RenamingTest.cs
│ └── VisualBasicRenamingResx.Test.csproj
├── VisualBasicRenamingResx
│ ├── My Project
│ │ ├── Resources.Designer.vb
│ │ └── Resources.resx
│ ├── Program.vb
│ └── VisualBasicRenamingResx.vbproj
├── WinFormsRenaming.Test
│ ├── RenameDataPropertyNameTest.cs
│ └── WinFormsRenaming.Test.csproj
├── WinFormsRenaming
│ ├── DataBoundElement.cs
│ ├── DataGridViewForm.cs
│ └── WinFormsRenaming.csproj
├── WpfRenaming.Test
│ ├── ProcessWpfTest.cs
│ └── WpfRenaming.Test.csproj
└── WpfRenaming
│ ├── TestData.xml
│ ├── UserControl1.xaml
│ ├── UserControl1.xaml.cs
│ ├── UserControl1Context.cs
│ └── WpfRenaming.csproj
├── additional
├── Icon.pdn
├── Icon16.pdn
├── Icon256.pdn
├── Icon32.pdn
├── Icon48.pdn
├── Icon64.pdn
├── ilspy.crproj
└── pdn.crproj
├── appveyor.yml
├── chocolatey-packages
├── .gitignore
├── New-ChocolateyPackage.ps1
├── confuserex.portable
│ ├── confuserex.portable.nuspec.template
│ ├── legal
│ │ ├── LICENSE.md
│ │ └── VERIFICATION.txt.template
│ └── tools
│ │ └── chocolateyInstall.ps1
└── confuserex
│ ├── confuserex.nuspec.template
│ ├── legal
│ ├── LICENSE.md
│ └── VERIFICATION.txt.template
│ └── tools
│ └── chocolateyInstall.ps1
├── docs
├── DeclarativeObfuscation.txt
├── ProjectFormat.md
└── docs.shfbproj
└── version.json
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.cs diff=csharp
2 |
--------------------------------------------------------------------------------
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | @mkaring
2 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: mkaring
2 | open_collective: confuserex
3 | custom: ['http://buymeacoff.ee/fFUnXMCdW']
4 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help ConfuserEx improve
4 | title: ""
5 | labels: potential-bug, triage
6 | assignees: ""
7 | ---
8 |
9 |
13 |
14 | - ConfuserEx Version:
15 | - Target Framework:
16 | - Operating System:
17 |
18 | Steps to Reproduce:
19 |
20 | 1.
21 |
22 |
25 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: Question
4 | url: https://github.com/mkaring/ConfuserEx/discussions/categories/q-a
5 | about: Ask and answer questions about ConfuserEx
6 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for ConfuserEx
4 | title: ""
5 | labels: enhancement, triage
6 | assignees: ""
7 | ---
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # To get started with Dependabot version updates, you'll need to specify which
2 | # package ecosystems to update and where the package manifests are located.
3 | # Please see the documentation for all configuration options:
4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5 |
6 | version: 2
7 | updates:
8 | - package-ecosystem: "nuget"
9 | directory: "/"
10 | schedule:
11 | interval: "daily"
12 | target-branch: "master"
13 | ignore:
14 | - dependency-name: "Microsoft.Build.Tasks.Core"
15 | versions: ["16.*"]
16 | labels:
17 | - "dependencies"
18 | reviewers:
19 | - "mkaring"
20 |
--------------------------------------------------------------------------------
/.github/workflows/codeql-analysis.yml:
--------------------------------------------------------------------------------
1 | name: "CodeQL"
2 |
3 | on:
4 | push:
5 | branches: [master, release/*]
6 | pull_request:
7 | branches: [master]
8 | schedule:
9 | - cron: "26 4 * * 0"
10 |
11 | permissions:
12 | contents: read
13 | security-events: write
14 | pull-requests: read
15 |
16 | jobs:
17 | analyze:
18 | name: Analyze
19 | runs-on: windows-2019
20 |
21 | strategy:
22 | fail-fast: false
23 |
24 | steps:
25 | - name: Checkout repository
26 | uses: actions/checkout@v2
27 | with:
28 | fetch-depth: 0
29 | submodules: recursive
30 |
31 | - name: Initialize CodeQL
32 | uses: github/codeql-action/init@v1
33 | with:
34 | languages: csharp
35 |
36 | - name: Autobuild
37 | uses: github/codeql-action/autobuild@v1
38 |
39 | - name: Perform CodeQL Analysis
40 | uses: github/codeql-action/analyze@v1
41 |
--------------------------------------------------------------------------------
/.github/workflows/issue-lock.yml:
--------------------------------------------------------------------------------
1 | name: "Lock closed issues"
2 |
3 | on:
4 | schedule:
5 | - cron: "15 4 * * *"
6 | workflow_dispatch:
7 |
8 | permissions:
9 | contents: read
10 | issues: write
11 |
12 | jobs:
13 | stale:
14 | runs-on: ubuntu-latest
15 | steps:
16 | - uses: dessant/lock-threads@v2
17 | with:
18 | github-token: ${{ secrets.GITHUB_TOKEN }}
19 | issue-lock-comment: "This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs."
20 | issue-lock-inactive-days: 30
21 | process-only: "issues"
22 |
--------------------------------------------------------------------------------
/.github/workflows/issue-stale.yml:
--------------------------------------------------------------------------------
1 | name: "Close stale issues"
2 |
3 | on:
4 | schedule:
5 | - cron: "00 4 * * *"
6 | workflow_dispatch:
7 |
8 | permissions:
9 | contents: read
10 | issues: write
11 |
12 | jobs:
13 | stale:
14 | runs-on: ubuntu-latest
15 | steps:
16 | - uses: actions/stale@v3
17 | with:
18 | repo-token: ${{ secrets.GITHUB_TOKEN }}
19 | days-before-close: 7
20 | days-before-stale: 14
21 | only-labels: "feedback-required"
22 | close-issue-message: "Closing this issue because it needs more information and has not had recent activity. Please re-open this issue if more details can be provided. Thanks!"
23 | stale-issue-label: "inactive"
24 | stale-issue-message: "This issue needs more information and has not had recent activity. Please provide the missing information or it will be closed in 7 days. Thanks!"
25 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Visual Studio Cache files (starting with VS 2015)
2 | .vs/
3 |
4 | # Launch Settings
5 | launchSettings.json
6 |
7 | #ignore thumbnails created by windows
8 | Thumbs.db
9 | #Ignore files build by Visual Studio
10 | *.obj
11 | *.exe
12 | *.pdb
13 | *.user
14 | *.aps
15 | *.pch
16 | *.vspscc
17 | *_i.c
18 | *_p.c
19 | *.ncb
20 | *.suo
21 | *.tlb
22 | *.tlh
23 | *.bak
24 | *.cache
25 | *.ilk
26 | *.log
27 | [Bb]in
28 | [Dd]ebug*/
29 | *.sbr
30 | obj/
31 | [Rr]elease*/
32 | _ReSharper*/
33 | [Tt]est[Rr]esult*
34 |
35 | !packages/*/build/
36 | packages/
37 | /Confuser.Test
38 | *.sln.*
39 | gh-pages/
40 |
41 | .idea/
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Contributions of any kind are in general always welcome.
4 |
5 | When contributing to this repository, please first discuss the changes you wish
6 | to make via issue, email, discussions, or any other method with the owners of
7 | this repository before making a change.
8 |
9 | For contributions that contain only bugfixes or added unit tests, this
10 | discussion is not required before hand.
11 |
12 | Please note we have a code of conduct, please follow it in all your
13 | interactions with the project.
14 |
15 | ## Pull Request Process
16 |
17 | 1. Ensure that only the files that are part of your change are actually part of
18 | the pull request. Changes in unrelated files, unrelated additional files or
19 | binaries have to be removed.
20 | 2. In case the pull request is created in response to a specific issue, please
21 | reference the issue in the description of the pull request.
22 | 3. Pull-Requests are merged once they are signed-off by one other developer
23 | with the permission to merge changes into the repository.
24 |
--------------------------------------------------------------------------------
/Confuser.CLI/Confuser.CLI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Exe
7 | net461
8 | true
9 | ..\ConfuserEx.snk
10 |
11 |
12 |
13 | ConfuserEx Command-line
14 | Command-line interface of ConfuserEx
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Confuser.Core/Confuser.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | net461;netstandard2.0
8 | true
9 | ..\ConfuserEx.snk
10 |
11 |
12 |
13 | ConfuserEx Core
14 | Core framework of ConfuserEx
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | Designer
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Confuser.Core/Confuser.Core.packages.config:
--------------------------------------------------------------------------------
1 |
5 |
6 |
--------------------------------------------------------------------------------
/Confuser.Core/ConfuserException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.Core {
4 | ///
5 | /// The exception that is thrown when a handled error occurred during the protection process.
6 | ///
7 | public class ConfuserException : Exception {
8 | public ConfuserException() : this(null) { }
9 |
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | /// The inner exception, or null if no exception is associated with the error.
14 | public ConfuserException(Exception innerException)
15 | : base("Exception occurred during the protection process.", innerException) { }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Confuser.Core/LZMA/Common/OutBuffer.cs:
--------------------------------------------------------------------------------
1 | // OutBuffer.cs
2 |
3 | using System;
4 | using System.IO;
5 |
6 | namespace SevenZip.Buffer {
7 | internal class OutBuffer {
8 |
9 | private readonly byte[] m_Buffer;
10 | private readonly uint m_BufferSize;
11 | private uint m_Pos;
12 | private ulong m_ProcessedSize;
13 | private Stream m_Stream;
14 |
15 | public OutBuffer(uint bufferSize) {
16 | m_Buffer = new byte[bufferSize];
17 | m_BufferSize = bufferSize;
18 | }
19 |
20 | public void SetStream(Stream stream) {
21 | m_Stream = stream;
22 | }
23 |
24 | public void FlushStream() {
25 | m_Stream.Flush();
26 | }
27 |
28 | public void CloseStream() {
29 | m_Stream.Close();
30 | }
31 |
32 | public void ReleaseStream() {
33 | m_Stream = null;
34 | }
35 |
36 | public void Init() {
37 | m_ProcessedSize = 0;
38 | m_Pos = 0;
39 | }
40 |
41 | public void WriteByte(byte b) {
42 | m_Buffer[m_Pos++] = b;
43 | if (m_Pos >= m_BufferSize)
44 | FlushData();
45 | }
46 |
47 | public void FlushData() {
48 | if (m_Pos == 0)
49 | return;
50 | m_Stream.Write(m_Buffer, 0, (int)m_Pos);
51 | m_Pos = 0;
52 | }
53 |
54 | public ulong GetProcessedSize() {
55 | return m_ProcessedSize + m_Pos;
56 | }
57 |
58 | }
59 | }
--------------------------------------------------------------------------------
/Confuser.Core/LZMA/Compress/LZ/IMatchFinder.cs:
--------------------------------------------------------------------------------
1 | // IMatchFinder.cs
2 |
3 | using System;
4 | using System.IO;
5 |
6 | namespace SevenZip.Compression.LZ {
7 | internal interface IInWindowStream {
8 |
9 | void SetStream(Stream inStream);
10 | void Init();
11 | void ReleaseStream();
12 | Byte GetIndexByte(Int32 index);
13 | UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit);
14 | UInt32 GetNumAvailableBytes();
15 |
16 | }
17 |
18 | internal interface IMatchFinder : IInWindowStream {
19 |
20 | void Create(UInt32 historySize, UInt32 keepAddBufferBefore,
21 | UInt32 matchMaxLen, UInt32 keepAddBufferAfter);
22 |
23 | UInt32 GetMatches(UInt32[] distances);
24 | void Skip(UInt32 num);
25 |
26 | }
27 | }
--------------------------------------------------------------------------------
/Confuser.Core/MarkerResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using dnlib.DotNet;
4 |
5 | namespace Confuser.Core {
6 | ///
7 | /// Result of the marker.
8 | ///
9 | public class MarkerResult {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | /// The modules.
14 | /// The packer.
15 | /// The external modules.
16 | public MarkerResult(IList modules, Packer packer, IList extModules) {
17 | Modules = modules;
18 | Packer = packer;
19 | ExternalModules = extModules;
20 | }
21 |
22 | ///
23 | /// Gets a list of modules that is marked.
24 | ///
25 | /// The list of modules.
26 | public IList Modules { get; private set; }
27 |
28 | ///
29 | /// Gets a list of external modules.
30 | ///
31 | /// The list of external modules.
32 | public IList ExternalModules { get; private set; }
33 |
34 | ///
35 | /// Gets the packer if exists.
36 | ///
37 | /// The packer, or null if no packer exists.
38 | public Packer Packer { get; private set; }
39 | }
40 | }
--------------------------------------------------------------------------------
/Confuser.Core/Project/InvalidPatternException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.Core.Project {
4 | ///
5 | /// The exception that is thrown when attempted to parse an invalid pattern.
6 | ///
7 | public class InvalidPatternException : Exception {
8 | ///
9 | /// Initializes a new instance of the class.
10 | ///
11 | /// The message that describes the error.
12 | public InvalidPatternException(string message)
13 | : base(message) { }
14 |
15 | ///
16 | /// Initializes a new instance of the class.
17 | ///
18 | /// The error message that explains the reason for the exception.
19 | ///
20 | /// The exception that is the cause of the current exception, or a null reference (Nothing in
21 | /// Visual Basic) if no inner exception is specified.
22 | ///
23 | public InvalidPatternException(string message, Exception innerException)
24 | : base(message, innerException) { }
25 | }
26 | }
--------------------------------------------------------------------------------
/Confuser.Core/Project/Patterns/AndOperator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using dnlib.DotNet;
3 |
4 | namespace Confuser.Core.Project.Patterns {
5 | ///
6 | /// The AND operator.
7 | ///
8 | public class AndOperator : PatternOperator {
9 | internal const string OpName = "and";
10 |
11 | ///
12 | public override string Name {
13 | get { return OpName; }
14 | }
15 |
16 | ///
17 | public override bool IsUnary {
18 | get { return false; }
19 | }
20 |
21 | ///
22 | public override object Evaluate(IDnlibDef definition) {
23 | var a = (bool)OperandA.Evaluate(definition);
24 | if (!a) return false;
25 | return (bool)OperandB.Evaluate(definition);
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/Confuser.Core/Project/Patterns/DeclTypeFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using dnlib.DotNet;
3 |
4 | namespace Confuser.Core.Project.Patterns {
5 | ///
6 | /// A function that compare the full name of declaring type.
7 | ///
8 | public class DeclTypeFunction : PatternFunction {
9 | internal const string FnName = "decl-type";
10 |
11 | ///
12 | public override string Name {
13 | get { return FnName; }
14 | }
15 |
16 | ///
17 | public override int ArgumentCount {
18 | get { return 1; }
19 | }
20 |
21 | ///
22 | public override object Evaluate(IDnlibDef definition) {
23 | if (!(definition is IMemberDef) || ((IMemberDef)definition).DeclaringType == null)
24 | return false;
25 | object fullName = Arguments[0].Evaluate(definition);
26 | return ((IMemberDef)definition).DeclaringType.FullName == fullName.ToString();
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/Confuser.Core/Project/Patterns/FullNameFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using dnlib.DotNet;
3 |
4 | namespace Confuser.Core.Project.Patterns {
5 | ///
6 | /// A function that compare the full name of definition.
7 | ///
8 | public class FullNameFunction : PatternFunction {
9 | internal const string FnName = "full-name";
10 |
11 | ///
12 | public override string Name {
13 | get { return FnName; }
14 | }
15 |
16 | ///
17 | public override int ArgumentCount {
18 | get { return 1; }
19 | }
20 |
21 | ///
22 | public override object Evaluate(IDnlibDef definition) {
23 | object name = Arguments[0].Evaluate(definition);
24 | return definition.FullName == name.ToString();
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/Confuser.Core/Project/Patterns/HasAttrFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using dnlib.DotNet;
3 |
4 | namespace Confuser.Core.Project.Patterns {
5 | ///
6 | /// A function that indicate whether the item has the given custom attribute.
7 | ///
8 | public class HasAttrFunction : PatternFunction {
9 | internal const string FnName = "has-attr";
10 |
11 | ///
12 | public override string Name {
13 | get { return FnName; }
14 | }
15 |
16 | ///
17 | public override int ArgumentCount {
18 | get { return 1; }
19 | }
20 |
21 | ///
22 | public override object Evaluate(IDnlibDef definition) {
23 | string attrName = Arguments[0].Evaluate(definition).ToString();
24 | return definition.CustomAttributes.IsDefined(attrName);
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/Confuser.Core/Project/Patterns/InheritsFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using dnlib.DotNet;
3 |
4 | namespace Confuser.Core.Project.Patterns {
5 | ///
6 | /// A function that indicate whether the type inherits from the specified type.
7 | ///
8 | public class InheritsFunction : PatternFunction {
9 | internal const string FnName = "inherits";
10 |
11 | ///
12 | public override string Name {
13 | get { return FnName; }
14 | }
15 |
16 | ///
17 | public override int ArgumentCount {
18 | get { return 1; }
19 | }
20 |
21 | ///
22 | public override object Evaluate(IDnlibDef definition) {
23 | string name = Arguments[0].Evaluate(definition).ToString();
24 |
25 | var type = definition as TypeDef;
26 | if (type == null && definition is IMemberDef)
27 | type = ((IMemberDef)definition).DeclaringType;
28 | if (type == null)
29 | return false;
30 |
31 | if (type.InheritsFrom(name) || type.Implements(name))
32 | return true;
33 |
34 | return false;
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/Confuser.Core/Project/Patterns/LiteralExpression.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using dnlib.DotNet;
4 |
5 | namespace Confuser.Core.Project.Patterns {
6 | ///
7 | /// A literal expression.
8 | ///
9 | public class LiteralExpression : PatternExpression {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | /// The literal.
14 | public LiteralExpression(object literal) {
15 | Literal = literal;
16 | }
17 |
18 | ///
19 | /// Gets the value of literal.
20 | ///
21 | /// The value of literal.
22 | public object Literal { get; private set; }
23 |
24 | ///
25 | public override object Evaluate(IDnlibDef definition) {
26 | return Literal;
27 | }
28 |
29 | ///
30 | public override void Serialize(IList tokens) {
31 | if (Literal is bool) {
32 | var value = (bool)Literal;
33 | tokens.Add(new PatternToken(TokenType.Identifier, value.ToString().ToLowerInvariant()));
34 | }
35 | else
36 | tokens.Add(new PatternToken(TokenType.Literal, Literal.ToString()));
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/Confuser.Core/Project/Patterns/ModuleFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using dnlib.DotNet;
3 |
4 | namespace Confuser.Core.Project.Patterns {
5 | ///
6 | /// A function that compare the module of definition.
7 | ///
8 | public class ModuleFunction : PatternFunction {
9 | internal const string FnName = "module";
10 |
11 | ///
12 | public override string Name {
13 | get { return FnName; }
14 | }
15 |
16 | ///
17 | public override int ArgumentCount {
18 | get { return 1; }
19 | }
20 |
21 | ///
22 | public override object Evaluate(IDnlibDef definition) {
23 | if (!(definition is IOwnerModule) && !(definition is IModule))
24 | return false;
25 | object name = Arguments[0].Evaluate(definition);
26 | if (definition is IModule)
27 | return ((IModule)definition).Name == name.ToString();
28 | return ((IOwnerModule)definition).Module.Name == name.ToString();
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/Confuser.Core/Project/Patterns/NameFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using dnlib.DotNet;
3 |
4 | namespace Confuser.Core.Project.Patterns {
5 | ///
6 | /// A function that compare the name of definition.
7 | ///
8 | public class NameFunction : PatternFunction {
9 | internal const string FnName = "name";
10 |
11 | ///
12 | public override string Name {
13 | get { return FnName; }
14 | }
15 |
16 | ///
17 | public override int ArgumentCount {
18 | get { return 1; }
19 | }
20 |
21 | ///
22 | public override object Evaluate(IDnlibDef definition) {
23 | object name = Arguments[0].Evaluate(definition);
24 | return definition.Name == name.ToString();
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/Confuser.Core/Project/Patterns/NamespaceFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text.RegularExpressions;
3 | using dnlib.DotNet;
4 |
5 | namespace Confuser.Core.Project.Patterns {
6 | ///
7 | /// A function that compare the namespace of definition.
8 | ///
9 | public class NamespaceFunction : PatternFunction {
10 | internal const string FnName = "namespace";
11 |
12 | ///
13 | public override string Name {
14 | get { return FnName; }
15 | }
16 |
17 | ///
18 | public override int ArgumentCount {
19 | get { return 1; }
20 | }
21 |
22 | ///
23 | public override object Evaluate(IDnlibDef definition) {
24 | if (!(definition is TypeDef) && !(definition is IMemberDef))
25 | return false;
26 | var ns = "^" + Arguments[0].Evaluate(definition).ToString() + "$";
27 |
28 | var type = definition as TypeDef;
29 | if (type == null)
30 | type = ((IMemberDef)definition).DeclaringType;
31 |
32 | if (type == null)
33 | return false;
34 |
35 | while (type.IsNested)
36 | type = type.DeclaringType;
37 |
38 | return type != null && Regex.IsMatch(type.Namespace ?? "", ns);
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/Confuser.Core/Project/Patterns/NotOperator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using dnlib.DotNet;
3 |
4 | namespace Confuser.Core.Project.Patterns {
5 | ///
6 | /// The NOT operator.
7 | ///
8 | public class NotOperator : PatternOperator {
9 | internal const string OpName = "not";
10 |
11 | ///
12 | public override string Name {
13 | get { return OpName; }
14 | }
15 |
16 | ///
17 | public override bool IsUnary {
18 | get { return true; }
19 | }
20 |
21 | ///
22 | public override object Evaluate(IDnlibDef definition) {
23 | return !(bool)OperandA.Evaluate(definition);
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/Confuser.Core/Project/Patterns/OrOperator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using dnlib.DotNet;
3 |
4 | namespace Confuser.Core.Project.Patterns {
5 | ///
6 | /// The OR operator.
7 | ///
8 | public class OrOperator : PatternOperator {
9 | internal const string OpName = "or";
10 |
11 | ///
12 | public override string Name {
13 | get { return OpName; }
14 | }
15 |
16 | ///
17 | public override bool IsUnary {
18 | get { return false; }
19 | }
20 |
21 | ///
22 | public override object Evaluate(IDnlibDef definition) {
23 | var a = (bool)OperandA.Evaluate(definition);
24 | if (a) return true;
25 | return (bool)OperandB.Evaluate(definition);
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/Confuser.Core/Project/Patterns/PatternExpression.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using dnlib.DotNet;
4 |
5 | namespace Confuser.Core.Project.Patterns {
6 | ///
7 | /// A pattern expression.
8 | ///
9 | public abstract class PatternExpression {
10 | ///
11 | /// Evaluates the expression on the specified definition.
12 | ///
13 | /// The definition.
14 | /// The result value.
15 | public abstract object Evaluate(IDnlibDef definition);
16 |
17 | ///
18 | /// Serializes the expression into tokens.
19 | ///
20 | /// The output list of tokens.
21 | public abstract void Serialize(IList tokens);
22 | }
23 | }
--------------------------------------------------------------------------------
/Confuser.Core/Project/Patterns/PatternFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Confuser.Core.Project.Patterns {
5 | ///
6 | /// A pattern function.
7 | ///
8 | public abstract class PatternFunction : PatternExpression {
9 | ///
10 | /// Gets the name of function.
11 | ///
12 | /// The name.
13 | public abstract string Name { get; }
14 |
15 | ///
16 | /// Gets the number of arguments of the function.
17 | ///
18 | /// The number of arguments.
19 | public abstract int ArgumentCount { get; }
20 |
21 | ///
22 | /// Gets or sets the arguments of function.
23 | ///
24 | /// The arguments.
25 | public IList Arguments { get; set; }
26 |
27 | ///
28 | public override void Serialize(IList tokens) {
29 | tokens.Add(new PatternToken(TokenType.Identifier, Name));
30 | tokens.Add(new PatternToken(TokenType.LParens));
31 | for (int i = 0; i < Arguments.Count; i++) {
32 | if (i != 0)
33 | tokens.Add(new PatternToken(TokenType.Comma));
34 | Arguments[i].Serialize(tokens);
35 | }
36 | tokens.Add(new PatternToken(TokenType.RParens));
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/Confuser.Core/Protection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.Core {
4 | ///
5 | /// Base class of Confuser protections.
6 | ///
7 | ///
8 | /// A parameterless constructor must exists in derived classes to enable plugin discovery.
9 | ///
10 | public abstract class Protection : ConfuserComponent {
11 | ///
12 | /// Gets the preset this protection is in.
13 | ///
14 | /// The protection's preset.
15 | public abstract ProtectionPreset Preset { get; }
16 | }
17 | }
--------------------------------------------------------------------------------
/Confuser.Core/ProtectionPreset.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.Core {
4 | ///
5 | /// Various presets of protections.
6 | ///
7 | public enum ProtectionPreset {
8 | /// The protection does not belong to any preset.
9 | None = 0,
10 |
11 | /// The protection provides basic security.
12 | Minimum = 1,
13 |
14 | /// The protection provides normal security for public release.
15 | Normal = 2,
16 |
17 | /// The protection provides better security with observable performance impact.
18 | Aggressive = 3,
19 |
20 | /// The protection provides strongest security with possible incompatibility.
21 | Maximum = 4
22 | }
23 | }
--------------------------------------------------------------------------------
/Confuser.Core/ProtectionSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Confuser.Core {
5 | ///
6 | /// Protection settings for a certain component
7 | ///
8 | public class ProtectionSettings : Dictionary> {
9 | ///
10 | /// Initializes a new instance of the class.
11 | ///
12 | public ProtectionSettings() { }
13 |
14 | ///
15 | /// Initializes a new instance of the class
16 | /// from an existing .
17 | ///
18 | /// The settings to copy from.
19 | public ProtectionSettings(ProtectionSettings settings) {
20 | if (settings == null)
21 | return;
22 |
23 | foreach (var i in settings)
24 | Add(i.Key, new Dictionary(i.Value));
25 | }
26 |
27 | ///
28 | /// Determines whether the settings is empty.
29 | ///
30 | /// true if the settings is empty; otherwise, false.
31 | public bool IsEmpty() {
32 | return Count == 0;
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/Confuser.Core/ProtectionTargets.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.Core {
4 | ///
5 | /// Targets of protection.
6 | ///
7 | [Flags]
8 | public enum ProtectionTargets {
9 | /// Type definitions.
10 | Types = 1,
11 |
12 | /// Method definitions.
13 | Methods = 2,
14 |
15 | /// Field definitions.
16 | Fields = 4,
17 |
18 | /// Event definitions.
19 | Events = 8,
20 |
21 | /// Property definitions.
22 | Properties = 16,
23 |
24 | /// All member definitions (i.e. type, methods, fields, events and properties).
25 | AllMembers = Types | Methods | Fields | Events | Properties,
26 |
27 | /// Module definitions.
28 | Modules = 32,
29 |
30 | /// All definitions (i.e. All member definitions and modules).
31 | AllDefinitions = AllMembers | Modules
32 | }
33 | }
--------------------------------------------------------------------------------
/Confuser.Core/UnreachableException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.Core {
4 | ///
5 | /// The exception that is thrown when supposedly unreachable code is executed.
6 | ///
7 | public class UnreachableException : SystemException {
8 | ///
9 | /// Initializes a new instance of the class.
10 | ///
11 | public UnreachableException() :
12 | base("Unreachable code reached.") { }
13 | }
14 | }
--------------------------------------------------------------------------------
/Confuser.DynCipher/AST/ArrayIndexExpression.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.DynCipher.AST {
4 | public class ArrayIndexExpression : Expression {
5 | public Expression Array { get; set; }
6 | public int Index { get; set; }
7 |
8 | public override string ToString() {
9 | return string.Format("{0}[{1}]", Array, Index);
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/Confuser.DynCipher/AST/AssignmentStatement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.DynCipher.AST {
4 | public class AssignmentStatement : Statement {
5 | public Expression Target { get; set; }
6 | public Expression Value { get; set; }
7 |
8 | public override string ToString() {
9 | return string.Format("{0} = {1};", Target, Value);
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/Confuser.DynCipher/AST/BinOpExpression.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.DynCipher.AST {
4 | public enum BinOps {
5 | Add,
6 | Sub,
7 | Div,
8 | Mul,
9 | Or,
10 | And,
11 | Xor,
12 | Lsh,
13 | Rsh
14 | }
15 |
16 | public class BinOpExpression : Expression {
17 | public Expression Left { get; set; }
18 | public Expression Right { get; set; }
19 | public BinOps Operation { get; set; }
20 |
21 | public override string ToString() {
22 | string op;
23 | switch (Operation) {
24 | case BinOps.Add:
25 | op = "+";
26 | break;
27 | case BinOps.Sub:
28 | op = "-";
29 | break;
30 | case BinOps.Div:
31 | op = "/";
32 | break;
33 | case BinOps.Mul:
34 | op = "*";
35 | break;
36 | case BinOps.Or:
37 | op = "|";
38 | break;
39 | case BinOps.And:
40 | op = "&";
41 | break;
42 | case BinOps.Xor:
43 | op = "^";
44 | break;
45 | case BinOps.Lsh:
46 | op = "<<";
47 | break;
48 | case BinOps.Rsh:
49 | op = ">>";
50 | break;
51 | default:
52 | throw new Exception();
53 | }
54 | return string.Format("({0} {1} {2})", Left, op, Right);
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/Confuser.DynCipher/AST/LiteralExpression.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.DynCipher.AST {
4 | public class LiteralExpression : Expression {
5 | public uint Value { get; set; }
6 |
7 | public static implicit operator LiteralExpression(uint val) {
8 | return new LiteralExpression { Value = val };
9 | }
10 |
11 | public override string ToString() {
12 | return Value.ToString("x8") + "h";
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/Confuser.DynCipher/AST/LoopStatement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 |
4 | namespace Confuser.DynCipher.AST {
5 | // i.e. for loop
6 | public class LoopStatement : StatementBlock {
7 | public int Begin { get; set; }
8 | public int Limit { get; set; }
9 |
10 | public override string ToString() {
11 | var ret = new StringBuilder();
12 | ret.AppendFormat("for (int i = {0}; i < {1}; i++)", Begin, Limit);
13 | ret.AppendLine();
14 | ret.Append(base.ToString());
15 | return ret.ToString();
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/Confuser.DynCipher/AST/Statement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.DynCipher.AST {
4 | public abstract class Statement {
5 | public object Tag { get; set; }
6 | public abstract override string ToString();
7 | }
8 | }
--------------------------------------------------------------------------------
/Confuser.DynCipher/AST/StatementBlock.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Confuser.DynCipher.AST {
6 | public class StatementBlock : Statement {
7 | public StatementBlock() {
8 | Statements = new List();
9 | }
10 |
11 | public IList Statements { get; private set; }
12 |
13 | public override string ToString() {
14 | var sb = new StringBuilder();
15 | sb.AppendLine("{");
16 | foreach (Statement i in Statements)
17 | sb.AppendLine(i.ToString());
18 | sb.AppendLine("}");
19 | return sb.ToString();
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/Confuser.DynCipher/AST/UnaryOpExpression.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.DynCipher.AST {
4 | public enum UnaryOps {
5 | Not,
6 | Negate
7 | }
8 |
9 | public class UnaryOpExpression : Expression {
10 | public Expression Value { get; set; }
11 | public UnaryOps Operation { get; set; }
12 |
13 | public override string ToString() {
14 | string op;
15 | switch (Operation) {
16 | case UnaryOps.Not:
17 | op = "~";
18 | break;
19 | case UnaryOps.Negate:
20 | op = "-";
21 | break;
22 | default:
23 | throw new Exception();
24 | }
25 | return op + Value;
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/Confuser.DynCipher/AST/Variable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.DynCipher.AST {
4 | public class Variable {
5 | public Variable(string name) {
6 | Name = name;
7 | }
8 |
9 | public string Name { get; set; }
10 | public object Tag { get; set; }
11 |
12 | public override string ToString() {
13 | return Name;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Confuser.DynCipher/AST/VariableExpression.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.DynCipher.AST {
4 | public class VariableExpression : Expression {
5 | public Variable Variable { get; set; }
6 |
7 | public override string ToString() {
8 | return Variable.Name;
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/Confuser.DynCipher/Confuser.DynCipher.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | net461;netstandard2.0
8 | true
9 | ..\ConfuserEx.snk
10 |
11 |
12 |
13 | ConfuserEx Dynamic Cipher Library
14 | Cipher generator of ConfuserEx
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Confuser.DynCipher/DynCipherComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Confuser.Core;
3 |
4 | namespace Confuser.DynCipher {
5 | internal class DynCipherComponent : ConfuserComponent {
6 | public const string _ServiceId = "Confuser.DynCipher";
7 |
8 | public override string Name {
9 | get { return "Dynamic Cipher"; }
10 | }
11 |
12 | public override string Description {
13 | get { return "Provides dynamic cipher generation services."; }
14 | }
15 |
16 | public override string Id {
17 | get { return _ServiceId; }
18 | }
19 |
20 | public override string FullId {
21 | get { return _ServiceId; }
22 | }
23 |
24 | protected override void Initialize(ConfuserContext context) {
25 | context.Registry.RegisterService(_ServiceId, typeof(IDynCipherService), new DynCipherService());
26 | }
27 |
28 | protected override void PopulatePipeline(ProtectionPipeline pipeline) {
29 | //
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/Confuser.DynCipher/DynCipherService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Confuser.Core.Services;
3 | using Confuser.DynCipher.AST;
4 | using Confuser.DynCipher.Generation;
5 |
6 | namespace Confuser.DynCipher {
7 | public interface IDynCipherService {
8 | void GenerateCipherPair(RandomGenerator random, out StatementBlock encrypt, out StatementBlock decrypt);
9 | void GenerateExpressionPair(RandomGenerator random, Expression var, Expression result, int depth, out Expression expression, out Expression inverse);
10 | }
11 |
12 | internal class DynCipherService : IDynCipherService {
13 | public void GenerateCipherPair(RandomGenerator random, out StatementBlock encrypt, out StatementBlock decrypt) {
14 | CipherGenerator.GeneratePair(random, out encrypt, out decrypt);
15 | }
16 |
17 | public void GenerateExpressionPair(RandomGenerator random, Expression var, Expression result, int depth, out Expression expression, out Expression inverse) {
18 | ExpressionGenerator.GeneratePair(random, var, result, depth, out expression, out inverse);
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/Confuser.DynCipher/Elements/AddKey.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Confuser.Core.Services;
3 | using Confuser.DynCipher.AST;
4 | using Confuser.DynCipher.Generation;
5 |
6 | namespace Confuser.DynCipher.Elements {
7 | internal class AddKey : CryptoElement {
8 | public AddKey(int index)
9 | : base(0) {
10 | Index = index;
11 | }
12 |
13 | public int Index { get; private set; }
14 |
15 | public override void Initialize(RandomGenerator random) { }
16 |
17 | void EmitCore(CipherGenContext context) {
18 | Expression val = context.GetDataExpression(Index);
19 |
20 | context.Emit(new AssignmentStatement {
21 | Value = val ^ context.GetKeyExpression(Index),
22 | Target = val
23 | });
24 | }
25 |
26 | public override void Emit(CipherGenContext context) {
27 | EmitCore(context);
28 | }
29 |
30 | public override void EmitInverse(CipherGenContext context) {
31 | EmitCore(context);
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/Confuser.DynCipher/Elements/CryptoElement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Confuser.Core.Services;
3 | using Confuser.DynCipher.Generation;
4 |
5 | namespace Confuser.DynCipher.Elements {
6 | internal abstract class CryptoElement {
7 | public CryptoElement(int count) {
8 | DataCount = count;
9 | DataIndexes = new int[count];
10 | }
11 |
12 | public int DataCount { get; private set; }
13 | public int[] DataIndexes { get; private set; }
14 |
15 | public abstract void Initialize(RandomGenerator random);
16 | public abstract void Emit(CipherGenContext context);
17 | public abstract void EmitInverse(CipherGenContext context);
18 | }
19 | }
--------------------------------------------------------------------------------
/Confuser.MSBuild.Tasks/ConfuseTask.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Linq;
3 | using System.Xml;
4 | using Confuser.Core;
5 | using Confuser.Core.Project;
6 | using Microsoft.Build.Framework;
7 | using Microsoft.Build.Utilities;
8 |
9 | namespace Confuser.MSBuild.Tasks {
10 | public sealed class ConfuseTask : Task {
11 | [Required]
12 | public ITaskItem Project { get; set; }
13 |
14 | [Required]
15 | public ITaskItem OutputAssembly { get; set; }
16 |
17 | [Output]
18 | public ITaskItem[] ConfusedFiles { get; set; }
19 |
20 | public override bool Execute() {
21 | var project = new ConfuserProject();
22 | var xmlDoc = new XmlDocument();
23 | xmlDoc.Load(Project.ItemSpec);
24 | project.Load(xmlDoc);
25 | project.OutputDirectory = Path.GetDirectoryName(Path.GetFullPath(OutputAssembly.ItemSpec));
26 |
27 | var logger = new MSBuildLogger(Log);
28 | var parameters = new ConfuserParameters {
29 | Project = project,
30 | Logger = logger
31 | };
32 |
33 | ConfuserEngine.Run(parameters).Wait();
34 |
35 | ConfusedFiles = project.Select(m => new TaskItem(Path.Combine(project.OutputDirectory, m.Path))).Cast().ToArray();
36 |
37 | return !logger.HasError;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Confuser.MSBuild.Tasks/build/Confuser.MSBuild.Tasks.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 |
6 |
7 |
8 | $(MSBuildThisFileDirectory)\..\netframework\
9 | $(MSBuildThisFileDirectory)\..\netstandard\
10 |
11 |
12 |
14 |
16 |
17 |
--------------------------------------------------------------------------------
/Confuser.Protections/AntiTamper/AntiTamperExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using dnlib.DotNet.Writer;
4 |
5 | namespace Confuser.Protections.AntiTamper {
6 | internal static class AntiTamperExtensions {
7 | internal static void AddBeforeReloc(this List sections, PESection newSection) {
8 | if (sections == null) throw new ArgumentNullException(nameof(sections));
9 | InsertBeforeReloc(sections, sections.Count, newSection);
10 | }
11 |
12 | internal static void InsertBeforeReloc(this List sections, int preferredIndex, PESection newSection) {
13 | if (sections == null) throw new ArgumentNullException(nameof(sections));
14 | if (preferredIndex < 0 || preferredIndex > sections.Count) throw new ArgumentOutOfRangeException(nameof(preferredIndex), preferredIndex, "Preferred index is out of range.");
15 | if (newSection == null) throw new ArgumentNullException(nameof(newSection));
16 |
17 | var relocIndex = sections.FindIndex(0, Math.Min(preferredIndex + 1, sections.Count), IsRelocSection);
18 | if (relocIndex == -1)
19 | sections.Insert(preferredIndex, newSection);
20 | else
21 | sections.Insert(relocIndex, newSection);
22 | }
23 |
24 | private static bool IsRelocSection(PESection section) =>
25 | section.Name.Equals(".reloc", StringComparison.Ordinal);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Confuser.Protections/AntiTamper/IKeyDeriver.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Confuser.Core;
4 | using Confuser.Core.Services;
5 | using dnlib.DotNet;
6 | using dnlib.DotNet.Emit;
7 |
8 | namespace Confuser.Protections.AntiTamper {
9 | internal enum Mode {
10 | Normal,
11 | Dynamic
12 | }
13 |
14 | internal interface IKeyDeriver {
15 | void Init(ConfuserContext ctx, RandomGenerator random);
16 | uint[] DeriveKey(uint[] a, uint[] b);
17 | IEnumerable EmitDerivation(MethodDef method, ConfuserContext ctx, Local dst, Local src);
18 | }
19 | }
--------------------------------------------------------------------------------
/Confuser.Protections/AntiTamper/IModeHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Confuser.Core;
3 |
4 | namespace Confuser.Protections.AntiTamper {
5 | internal interface IModeHandler {
6 | void HandleInject(AntiTamperProtection parent, ConfuserContext context, ProtectionParameters parameters);
7 | void HandleMD(AntiTamperProtection parent, ConfuserContext context, ProtectionParameters parameters);
8 | }
9 | }
--------------------------------------------------------------------------------
/Confuser.Protections/Compress/IKeyDeriver.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Confuser.Core;
4 | using Confuser.Core.Services;
5 | using dnlib.DotNet;
6 | using dnlib.DotNet.Emit;
7 |
8 | namespace Confuser.Protections.Compress {
9 | internal enum Mode {
10 | Normal,
11 | Dynamic
12 | }
13 |
14 | internal interface IKeyDeriver {
15 | void Init(ConfuserContext ctx, RandomGenerator random);
16 | uint[] DeriveKey(uint[] a, uint[] b);
17 | IEnumerable EmitDerivation(MethodDef method, ConfuserContext ctx, Local dst, Local src);
18 | }
19 | }
--------------------------------------------------------------------------------
/Confuser.Protections/Confuser.Protections.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | net461;netstandard2.0
8 | true
9 | ..\ConfuserEx.snk
10 |
11 |
12 |
13 | ConfuserEx Protections
14 | Protections and packers of ConfuserEx
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Confuser.Protections/Constants/EncodeElements.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.Protections.Constants {
4 | [Flags]
5 | internal enum EncodeElements {
6 | Strings = 1,
7 | Numbers = 2,
8 | Primitive = 4,
9 | Initializers = 8
10 | }
11 | }
--------------------------------------------------------------------------------
/Confuser.Protections/Constants/IEncodeMode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using dnlib.DotNet;
4 | using dnlib.DotNet.Emit;
5 |
6 | namespace Confuser.Protections.Constants {
7 | internal interface IEncodeMode {
8 | IEnumerable EmitDecrypt(MethodDef init, CEContext ctx, Local block, Local key);
9 | uint[] Encrypt(uint[] data, int offset, uint[] key);
10 |
11 | object CreateDecoder(MethodDef decoder, CEContext ctx);
12 | uint Encode(object data, CEContext ctx, uint id);
13 | }
14 | }
--------------------------------------------------------------------------------
/Confuser.Protections/Constants/Mode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.Protections.Constants {
4 | internal enum Mode {
5 | Normal,
6 | Dynamic,
7 | x86
8 | }
9 | }
--------------------------------------------------------------------------------
/Confuser.Protections/ControlFlow/IPredicate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using dnlib.DotNet.Emit;
4 |
5 | namespace Confuser.Protections.ControlFlow {
6 | internal interface IPredicate {
7 | void Init(CilBody body);
8 | void EmitSwitchLoad(IList instrs);
9 | int GetSwitchKey(int key);
10 | }
11 | }
--------------------------------------------------------------------------------
/Confuser.Protections/ControlFlow/ManglerBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using dnlib.DotNet.Emit;
4 |
5 | namespace Confuser.Protections.ControlFlow {
6 | internal abstract class ManglerBase {
7 | protected static IEnumerable GetAllBlocks(ScopeBlock scope) {
8 | foreach (BlockBase child in scope.Children) {
9 | if (child is InstrBlock)
10 | yield return (InstrBlock)child;
11 | else {
12 | foreach (InstrBlock block in GetAllBlocks((ScopeBlock)child))
13 | yield return block;
14 | }
15 | }
16 | }
17 |
18 | public abstract void Mangle(CilBody body, ScopeBlock root, CFContext ctx);
19 | }
20 | }
--------------------------------------------------------------------------------
/Confuser.Protections/ControlFlow/NormalPredicate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using dnlib.DotNet.Emit;
4 |
5 | namespace Confuser.Protections.ControlFlow {
6 | internal class NormalPredicate : IPredicate {
7 | readonly CFContext ctx;
8 | bool inited;
9 | int xorKey;
10 |
11 | public NormalPredicate(CFContext ctx) {
12 | this.ctx = ctx;
13 | }
14 |
15 | public void Init(CilBody body) {
16 | if (inited)
17 | return;
18 |
19 | xorKey = ctx.Random.NextInt32();
20 | inited = true;
21 | }
22 |
23 | public void EmitSwitchLoad(IList instrs) {
24 | instrs.Add(Instruction.Create(OpCodes.Ldc_I4, xorKey));
25 | instrs.Add(Instruction.Create(OpCodes.Xor));
26 | }
27 |
28 | public int GetSwitchKey(int key) {
29 | return key ^ xorKey;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/Confuser.Protections/HardeningProtection.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics.CodeAnalysis;
2 | using Confuser.Core;
3 |
4 | namespace Confuser.Protections {
5 | [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global", Justification = "Instantiated by reflection.")]
6 | internal sealed class HardeningProtection : Protection {
7 | ///
8 | public override string Name => "Protection Hardening";
9 |
10 | ///
11 | public override string Description => "This component improves the protection code, making it harder to circumvent it.";
12 |
13 | ///
14 | public override string Id => "harden";
15 |
16 | ///
17 | public override string FullId => "Cx.Harden";
18 |
19 | ///
20 | protected override void Initialize(ConfuserContext context) { }
21 |
22 | ///
23 | protected override void PopulatePipeline(ProtectionPipeline pipeline) =>
24 | pipeline.InsertPreStage(PipelineStage.OptimizeMethods, new HardeningPhase(this));
25 |
26 | ///
27 | public override ProtectionPreset Preset => ProtectionPreset.Minimum;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Confuser.Protections/ReferenceProxy/IRPEncoding.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using dnlib.DotNet;
3 | using dnlib.DotNet.Emit;
4 |
5 | namespace Confuser.Protections.ReferenceProxy {
6 | internal interface IRPEncoding {
7 | Instruction[] EmitDecode(MethodDef init, RPContext ctx, Instruction[] arg);
8 | int Encode(MethodDef init, RPContext ctx, int value);
9 | }
10 | }
--------------------------------------------------------------------------------
/Confuser.Protections/ReferenceProxy/RPContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Confuser.Core;
4 | using Confuser.Core.Services;
5 | using Confuser.DynCipher;
6 | using Confuser.Renamer;
7 | using dnlib.DotNet;
8 | using dnlib.DotNet.Emit;
9 |
10 | namespace Confuser.Protections.ReferenceProxy {
11 | internal enum Mode {
12 | Mild,
13 | Strong,
14 | Ftn
15 | }
16 |
17 | internal enum EncodingType {
18 | Normal,
19 | Expression,
20 | x86
21 | }
22 |
23 | internal class RPContext {
24 | public ReferenceProxyProtection Protection;
25 | public CilBody Body;
26 | public HashSet BranchTargets;
27 | public ConfuserContext Context;
28 | public Dictionary Delegates;
29 | public int Depth;
30 | public IDynCipherService DynCipher;
31 | public EncodingType Encoding;
32 | public IRPEncoding EncodingHandler;
33 | public int InitCount;
34 | public bool InternalAlso;
35 | public IMarkerService Marker;
36 | public MethodDef Method;
37 | public Mode Mode;
38 |
39 | public RPMode ModeHandler;
40 | public ModuleDef Module;
41 | public INameService Name;
42 | public RandomGenerator Random;
43 | public bool TypeErasure;
44 | }
45 | }
--------------------------------------------------------------------------------
/Confuser.Protections/Resources/IEncodeMode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using dnlib.DotNet;
4 | using dnlib.DotNet.Emit;
5 |
6 | namespace Confuser.Protections.Resources {
7 | internal interface IEncodeMode {
8 | IEnumerable EmitDecrypt(MethodDef init, REContext ctx, Local block, Local key);
9 | uint[] Encrypt(uint[] data, int offset, uint[] key);
10 | }
11 | }
--------------------------------------------------------------------------------
/Confuser.Protections/Resources/Mode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.Protections.Resources {
4 | internal enum Mode {
5 | Normal,
6 | Dynamic
7 | }
8 | }
--------------------------------------------------------------------------------
/Confuser.Protections/Resources/NormalMode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using dnlib.DotNet;
4 | using dnlib.DotNet.Emit;
5 |
6 | namespace Confuser.Protections.Resources {
7 | internal class NormalMode : IEncodeMode {
8 | public IEnumerable EmitDecrypt(MethodDef init, REContext ctx, Local block, Local key) {
9 | for (int i = 0; i < 0x10; i++) {
10 | yield return Instruction.Create(OpCodes.Ldloc, block);
11 | yield return Instruction.Create(OpCodes.Ldc_I4, i);
12 | yield return Instruction.Create(OpCodes.Ldloc, block);
13 | yield return Instruction.Create(OpCodes.Ldc_I4, i);
14 | yield return Instruction.Create(OpCodes.Ldelem_U4);
15 | yield return Instruction.Create(OpCodes.Ldloc, key);
16 | yield return Instruction.Create(OpCodes.Ldc_I4, i);
17 | yield return Instruction.Create(OpCodes.Ldelem_U4);
18 | yield return Instruction.Create(OpCodes.Xor);
19 | yield return Instruction.Create(OpCodes.Stelem_I4);
20 | }
21 | }
22 |
23 | public uint[] Encrypt(uint[] data, int offset, uint[] key) {
24 | var ret = new uint[key.Length];
25 | for (int i = 0; i < key.Length; i++)
26 | ret[i] = data[i + offset] ^ key[i];
27 | return ret;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/Confuser.Protections/Resources/REContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Confuser.Core;
3 | using Confuser.Core.Services;
4 | using Confuser.DynCipher;
5 | using Confuser.Renamer;
6 | using dnlib.DotNet;
7 |
8 | namespace Confuser.Protections.Resources {
9 | internal class REContext {
10 | public ConfuserContext Context;
11 |
12 | public FieldDef DataField;
13 | public TypeDef DataType;
14 | public IDynCipherService DynCipher;
15 | public MethodDef InitMethod;
16 | public IMarkerService Marker;
17 |
18 | public Mode Mode;
19 |
20 | public IEncodeMode ModeHandler;
21 | public ModuleDef Module;
22 | public INameService Name;
23 | public RandomGenerator Random;
24 | }
25 | }
--------------------------------------------------------------------------------
/Confuser.Protections/Resources/ResourceProtection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Confuser.Core;
3 | using Confuser.Protections.Resources;
4 |
5 | namespace Confuser.Protections {
6 | [BeforeProtection("Ki.ControlFlow"), AfterProtection("Ki.Constants")]
7 | internal class ResourceProtection : Protection {
8 | public const string _Id = "resources";
9 | public const string _FullId = "Ki.Resources";
10 | public const string _ServiceId = "Ki.Resources";
11 |
12 | public override string Name {
13 | get { return "Resources Protection"; }
14 | }
15 |
16 | public override string Description {
17 | get { return "This protection encodes and compresses the embedded resources."; }
18 | }
19 |
20 | public override string Id {
21 | get { return _Id; }
22 | }
23 |
24 | public override string FullId {
25 | get { return _FullId; }
26 | }
27 |
28 | public override ProtectionPreset Preset {
29 | get { return ProtectionPreset.Normal; }
30 | }
31 |
32 | protected override void Initialize(ConfuserContext context) { }
33 |
34 | protected override void PopulatePipeline(ProtectionPipeline pipeline) {
35 | pipeline.InsertPreStage(PipelineStage.ProcessModule, new InjectPhase(this));
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/Confuser.Protections/TypeScrambler/Scrambler/Analyzers/ContextAnalyzer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using dnlib.DotNet.Emit;
3 |
4 | namespace Confuser.Protections.TypeScrambler.Scrambler.Analyzers {
5 | internal abstract class ContextAnalyzer {
6 | internal abstract Type TargetType();
7 |
8 | internal abstract void ProcessOperand(ScannedMethod method, Instruction instruction, object operand);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Confuser.Protections/TypeScrambler/Scrambler/Analyzers/ContextAnalyzer`1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using dnlib.DotNet.Emit;
3 |
4 | namespace Confuser.Protections.TypeScrambler.Scrambler.Analyzers {
5 | internal abstract class ContextAnalyzer : ContextAnalyzer {
6 | internal override Type TargetType() => typeof(T);
7 | internal abstract void Process(ScannedMethod method, Instruction instruction, T operand);
8 | internal override void ProcessOperand(ScannedMethod method, Instruction instruction, object operand) =>
9 | Process(method, instruction, (T)operand);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Confuser.Protections/TypeScrambler/Scrambler/Analyzers/MemberRefAnalyzer.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using dnlib.DotNet;
3 | using dnlib.DotNet.Emit;
4 |
5 | namespace Confuser.Protections.TypeScrambler.Scrambler.Analyzers {
6 | internal sealed class MemberRefAnalyzer : ContextAnalyzer {
7 | internal override void Process(ScannedMethod method, Instruction instruction, MemberRef operand) {
8 | Debug.Assert(method != null, $"{nameof(method)} != null");
9 | Debug.Assert(instruction != null, $"{nameof(instruction)} != null");
10 | Debug.Assert(operand != null, $"{nameof(operand)} != null");
11 |
12 | // Scrambling member references only works for constructors without parameters currently.
13 | if (instruction.OpCode != OpCodes.Newobj) return;
14 | if (operand.MethodSig.Params.Count > 0) return;
15 |
16 | TypeSig sig = null;
17 | if (operand.Class is TypeRef typeRef)
18 | sig = typeRef.ToTypeSig();
19 |
20 | if (operand.Class is TypeSpec typeSpec)
21 | sig = typeSpec.ToTypeSig();
22 |
23 | if (sig != null)
24 | method.RegisterGeneric(sig);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Confuser.Protections/TypeScrambler/Scrambler/Analyzers/MethodDefAnalyzer.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using dnlib.DotNet;
3 | using dnlib.DotNet.Emit;
4 |
5 | namespace Confuser.Protections.TypeScrambler.Scrambler.Analyzers {
6 | internal sealed class MethodDefAnalyzer : ContextAnalyzer {
7 | private TypeService Service { get; }
8 |
9 | internal MethodDefAnalyzer(TypeService service) {
10 | Debug.Assert(service != null, $"{nameof(service)} != null");
11 |
12 | Service = service;
13 | }
14 | internal override void Process(ScannedMethod method, Instruction instruction, MethodDef operand) {
15 | Debug.Assert(method != null, $"{nameof(method)} != null");
16 | Debug.Assert(instruction != null, $"{nameof(instruction)} != null");
17 | Debug.Assert(operand != null, $"{nameof(operand)} != null");
18 |
19 | var sc = Service.GetItem(operand);
20 | if (sc?.IsScambled == true)
21 | foreach (var regTypes in sc.TrueTypes)
22 | method.RegisterGeneric(regTypes);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Confuser.Protections/TypeScrambler/Scrambler/Analyzers/MethodSpecAnalyzer.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using dnlib.DotNet;
3 | using dnlib.DotNet.Emit;
4 |
5 | namespace Confuser.Protections.TypeScrambler.Scrambler.Analyzers {
6 | internal sealed class MethodSpecAnalyzer : ContextAnalyzer {
7 | internal override void Process(ScannedMethod method, Instruction instruction, MethodSpec operand) {
8 | Debug.Assert(method != null, $"{nameof(method)} != null");
9 | Debug.Assert(instruction != null, $"{nameof(instruction)} != null");
10 | Debug.Assert(operand != null, $"{nameof(operand)} != null");
11 |
12 | foreach (var t in operand.GenericInstMethodSig.GenericArguments)
13 | method.RegisterGeneric(t);
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Confuser.Protections/TypeScrambler/Scrambler/Analyzers/TypeRefAnalyzer.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using dnlib.DotNet;
3 | using dnlib.DotNet.Emit;
4 |
5 | namespace Confuser.Protections.TypeScrambler.Scrambler.Analyzers {
6 | internal sealed class TypeRefAnalyzer : ContextAnalyzer {
7 | internal override void Process(ScannedMethod method, Instruction instruction, TypeRef operand) {
8 | Debug.Assert(method != null, $"{nameof(method)} != null");
9 | Debug.Assert(instruction != null, $"{nameof(instruction)} != null");
10 | Debug.Assert(operand != null, $"{nameof(operand)} != null");
11 |
12 | method.RegisterGeneric(operand.ToTypeSig());
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Confuser.Protections/TypeScrambler/Scrambler/Rewriter/Instructions/InstructionRewriter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using dnlib.DotNet;
4 | using dnlib.DotNet.Emit;
5 |
6 | namespace Confuser.Protections.TypeScrambler.Scrambler.Rewriter.Instructions {
7 | internal abstract class InstructionRewriter {
8 | internal abstract void ProcessInstruction(TypeService service, MethodDef method, IList body, ref int index, Instruction i);
9 | internal abstract Type TargetType();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Confuser.Protections/TypeScrambler/Scrambler/Rewriter/Instructions/InstructionRewriter`1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using dnlib.DotNet;
4 | using dnlib.DotNet.Emit;
5 |
6 | namespace Confuser.Protections.TypeScrambler.Scrambler.Rewriter.Instructions {
7 | internal abstract class InstructionRewriter : InstructionRewriter {
8 | internal override void ProcessInstruction(TypeService service, MethodDef method, IList body, ref int index, Instruction i) {
9 | ProcessOperand(service, method, body, ref index, (T)i.Operand);
10 | }
11 | internal override Type TargetType() => typeof(T);
12 |
13 | internal abstract void ProcessOperand(TypeService service, MethodDef method, IList body, ref int index, T operand);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Confuser.Protections/TypeScrambler/Scrambler/Rewriter/Instructions/TypeDefInstructionRewriter.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Diagnostics;
3 | using dnlib.DotNet;
4 | using dnlib.DotNet.Emit;
5 |
6 | namespace Confuser.Protections.TypeScrambler.Scrambler.Rewriter.Instructions {
7 | internal sealed class TypeDefInstructionRewriter : InstructionRewriter {
8 | internal override void ProcessOperand(TypeService service, MethodDef method, IList body, ref int index, TypeDef operand) {
9 | Debug.Assert(service != null, $"{nameof(service)} != null");
10 | Debug.Assert(method != null, $"{nameof(method)} != null");
11 | Debug.Assert(body != null, $"{nameof(body)} != null");
12 | Debug.Assert(operand != null, $"{nameof(operand)} != null");
13 | Debug.Assert(index >= 0, $"{nameof(index)} >= 0");
14 | Debug.Assert(index < body.Count, $"{nameof(index)} < {nameof(body)}.Count");
15 |
16 | var current = service.GetItem(operand);
17 | if (current?.IsScambled == true)
18 | body[index].Operand = new TypeSpecUser(current.CreateGenericTypeSig(service.GetItem(method.DeclaringType)));
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Confuser.Protections/TypeScrambler/Scrambler/Rewriter/Instructions/TypeRefInstructionRewriter.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Diagnostics;
3 | using dnlib.DotNet;
4 | using dnlib.DotNet.Emit;
5 |
6 | namespace Confuser.Protections.TypeScrambler.Scrambler.Rewriter.Instructions {
7 | internal sealed class TypeRefInstructionRewriter : InstructionRewriter {
8 | internal override void ProcessOperand(TypeService service, MethodDef method, IList body, ref int index, TypeRef operand) {
9 | Debug.Assert(service != null, $"{nameof(service)} != null");
10 | Debug.Assert(method != null, $"{nameof(method)} != null");
11 | Debug.Assert(body != null, $"{nameof(body)} != null");
12 | Debug.Assert(operand != null, $"{nameof(operand)} != null");
13 | Debug.Assert(index >= 0, $"{nameof(index)} >= 0");
14 | Debug.Assert(index < body.Count, $"{nameof(index)} < {nameof(body)}.Count");
15 |
16 | var current = service.GetItem(method);
17 | if (current?.IsScambled == true)
18 | body[index].Operand = new TypeSpecUser(current.ConvertToGenericIfAvalible(operand.ToTypeSig()));
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Confuser.Protections/TypeScrambler/TypeScrambleProtection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Confuser.Core;
3 |
4 | namespace Confuser.Protections.TypeScrambler {
5 | class TypeScrambleProtection : Protection {
6 | public override ProtectionPreset Preset => ProtectionPreset.None;
7 |
8 | public override string Name => "Type Scrambler";
9 |
10 | public override string Description => "Replaces types with generics";
11 |
12 | public override string Id => "typescramble";
13 |
14 | public override string FullId => "BahNahNah.typescramble";
15 |
16 | protected override void Initialize(ConfuserContext context) {
17 | if (context == null) throw new ArgumentNullException(nameof(context));
18 |
19 | context.Registry.RegisterService(FullId, typeof(TypeService), new TypeService());
20 | }
21 |
22 | protected override void PopulatePipeline(ProtectionPipeline pipeline) {
23 | if (pipeline == null) throw new ArgumentNullException(nameof(pipeline));
24 |
25 | pipeline.InsertPreStage(PipelineStage.Inspection, new AnalyzePhase(this));
26 | pipeline.InsertPostStage(PipelineStage.ProcessModule, new ScramblePhase(this));
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Confuser.Renamer/BAML/BAMLPropertyReference.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using Confuser.Core;
4 | using dnlib.DotNet;
5 |
6 | namespace Confuser.Renamer.BAML {
7 | sealed class BAMLPropertyReference : IBAMLReference {
8 | readonly ModuleDef _refModule;
9 | readonly PropertyRecord _rec;
10 |
11 | public BAMLPropertyReference(ModuleDef refModule, PropertyRecord rec) {
12 | _refModule = refModule;
13 | _rec = rec;
14 | }
15 |
16 | public bool CanRename(ModuleDef moduleDef, string oldName, string newName) => true;
17 |
18 | public void Rename(ModuleDef moduleDef, string oldName, string newName) {
19 | if (moduleDef != _refModule) return;
20 |
21 | var value = _rec.Value;
22 | while (true) {
23 | if (value.EndsWith(oldName, StringComparison.OrdinalIgnoreCase)) {
24 | value = value.Substring(0, value.Length - oldName.Length) + newName;
25 | _rec.Value = value;
26 | }
27 | else if (oldName.EndsWith(".baml", StringComparison.OrdinalIgnoreCase)) {
28 | oldName = ToXaml(oldName);
29 | newName = ToXaml(newName);
30 | continue;
31 | }
32 |
33 | break;
34 | }
35 | }
36 |
37 | private static string ToXaml(string refName) {
38 | Debug.Assert(refName.EndsWith(".baml"));
39 | return refName.Substring(0, refName.Length - 5) + ".xaml";
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Confuser.Renamer/BAML/BamlDocument.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Confuser.Renamer.BAML {
5 | internal class BamlDocument : List {
6 | public string DocumentName { get; set; }
7 |
8 | public string Signature { get; set; }
9 | public BamlVersion ReaderVersion { get; set; }
10 | public BamlVersion UpdaterVersion { get; set; }
11 | public BamlVersion WriterVersion { get; set; }
12 |
13 | public struct BamlVersion {
14 | public ushort Major;
15 | public ushort Minor;
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/Confuser.Renamer/BAML/IBAMLReference.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using dnlib.DotNet;
3 |
4 | namespace Confuser.Renamer.BAML {
5 | internal interface IBAMLReference {
6 | bool CanRename(ModuleDef moduleDef, string oldName, string newName);
7 | void Rename(ModuleDef moduleDef, string oldName, string newName);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Confuser.Renamer/BAML/PropertyPath/DrillIn.cs:
--------------------------------------------------------------------------------
1 | namespace Confuser.Renamer.BAML {
2 | internal enum DrillIn {
3 | Never,
4 | IfNeeded,
5 | Always
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Confuser.Renamer/BAML/PropertyPath/IndexerParamInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Confuser.Renamer.BAML {
8 | internal struct IndexerParamInfo {
9 | // parse each indexer param "(abc)xyz" into two pieces - either can be empty
10 | public string parenString;
11 | public string valueString;
12 |
13 | public IndexerParamInfo(string paren, string value) {
14 | parenString = paren;
15 | valueString = value;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Confuser.Renamer/BAML/PropertyPath/README.md:
--------------------------------------------------------------------------------
1 | # WPF Property Path Parser
2 |
3 | The code in this directory was extracted from the sources of the Presentation Framework part of the .NET Fraemework.
4 |
5 | The original code can be viewed here:
6 | https://referencesource.microsoft.com/#PresentationFramework/src/Framework/MS/Internal/Data/PathParser.cs
7 |
--------------------------------------------------------------------------------
/Confuser.Renamer/BAML/PropertyPath/SourceValueInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Confuser.Renamer.BAML {
8 | internal struct SourceValueInfo {
9 | public SourceValueType type;
10 | public DrillIn drillIn;
11 | public string name; // the name the user supplied - could be "(0)"
12 | public IReadOnlyList paramList; // params for indexer
13 |
14 | public SourceValueInfo(SourceValueType t, DrillIn d, string n) {
15 | type = t;
16 | drillIn = d;
17 | name = n;
18 | paramList = null;
19 | }
20 |
21 | public SourceValueInfo(SourceValueType t, DrillIn d, IReadOnlyList list) {
22 | type = t;
23 | drillIn = d;
24 | name = null;
25 | paramList = list;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Confuser.Renamer/BAML/PropertyPath/SourceValueType.cs:
--------------------------------------------------------------------------------
1 | namespace Confuser.Renamer.BAML {
2 | internal enum SourceValueType {
3 | Property,
4 | Indexer,
5 | Direct
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Confuser.Renamer/BAML/PropertyPathIndexUpdater.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.Renamer.BAML {
4 | internal struct PropertyPathIndexUpdater {
5 | PropertyPathUpdater Parent { get; }
6 | int PathIndex { get; }
7 | int IndexerIndex { get; }
8 | IndexerParamInfo IndexInfo => Parent.PropertyPath[PathIndex].paramList[IndexerIndex];
9 |
10 | internal string ParenString {
11 | get => IndexInfo.parenString;
12 | set => Parent.UpdateParenString(PathIndex, IndexerIndex, value);
13 | }
14 |
15 | internal PropertyPathIndexUpdater(PropertyPathUpdater parent, int pathIndex, int indexerIndex) {
16 | Parent = parent ?? throw new ArgumentNullException(nameof(parent));
17 | PathIndex = pathIndex;
18 | IndexerIndex = indexerIndex;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Confuser.Renamer/DisplayNormalizedName.cs:
--------------------------------------------------------------------------------
1 | namespace Confuser.Renamer {
2 | public struct DisplayNormalizedName {
3 | public string DisplayName { get; }
4 |
5 | public string NormalizedName { get; }
6 |
7 | public DisplayNormalizedName(string displayName, string normalizedName) {
8 | DisplayName = displayName;
9 | NormalizedName = normalizedName;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Confuser.Renamer/IRenamer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Confuser.Core;
3 | using dnlib.DotNet;
4 |
5 | namespace Confuser.Renamer {
6 | public interface IRenamer {
7 | void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def);
8 | void PreRename(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def);
9 | void PostRename(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def);
10 | }
11 | }
--------------------------------------------------------------------------------
/Confuser.Renamer/PostRenamePhase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Confuser.Core;
3 | using dnlib.DotNet;
4 |
5 | namespace Confuser.Renamer {
6 | internal class PostRenamePhase : ProtectionPhase {
7 | public PostRenamePhase(NameProtection parent)
8 | : base(parent) { }
9 |
10 | public override bool ProcessAll {
11 | get { return true; }
12 | }
13 |
14 | public override ProtectionTargets Targets {
15 | get { return ProtectionTargets.AllDefinitions; }
16 | }
17 |
18 | public override string Name {
19 | get { return "Post-renaming"; }
20 | }
21 |
22 | protected override void Execute(ConfuserContext context, ProtectionParameters parameters) {
23 | var service = (NameService)context.Registry.GetService();
24 |
25 | foreach (IRenamer renamer in service.Renamers) {
26 | foreach (IDnlibDef def in parameters.Targets)
27 | renamer.PostRename(context, service, parameters, def);
28 | context.CheckCancellation();
29 | }
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/Confuser.Renamer/References/OverrideDirectiveReference.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 | using Confuser.Core;
3 | using dnlib.DotNet;
4 |
5 | namespace Confuser.Renamer.References {
6 | internal sealed class OverrideDirectiveReference : INameReference {
7 | readonly VTableSlot baseSlot;
8 | readonly VTableSlot thisSlot;
9 |
10 | public bool ShouldCancelRename => baseSlot.MethodDefDeclType is GenericInstSig && thisSlot.MethodDef.Module.IsClr20;
11 |
12 | public OverrideDirectiveReference(VTableSlot thisSlot, VTableSlot baseSlot) {
13 | this.thisSlot = thisSlot;
14 | this.baseSlot = baseSlot;
15 | }
16 |
17 | ///
18 | public bool DelayRenaming(INameService service, IDnlibDef currentDef) => false;
19 |
20 | public bool UpdateNameReference(ConfuserContext context, INameService service) => false;
21 |
22 | public override string ToString() => ToString(null);
23 |
24 | public string ToString(INameService nameService) {
25 | var builder = new StringBuilder();
26 | builder.Append("Override directive").Append("(");
27 | builder.AppendReferencedMethod(thisSlot.MethodDef, nameService);
28 | builder.Append(")");
29 | return builder.ToString();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Confuser.Renamer/RenameMode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.Renamer {
4 | public enum RenameMode {
5 | Empty = 0x0,
6 | Unicode = 0x1,
7 | // ReSharper disable once InconsistentNaming
8 | ASCII = 0x2,
9 | ///
10 | /// This the the rename mode with the largest set of possible characters,
11 | /// that is still save for reflection.
12 | ///
13 | Reflection = 0x3,
14 | Letters = 0x4,
15 |
16 | Decodable = 0x10,
17 | Sequential = 0x11,
18 | Reversible = 0x12,
19 |
20 | /// Add a underscore to the name to mark that it would be renamed.
21 | Debug = 0x20,
22 |
23 | /// Keep the names as they are.
24 | Retain = Int32.MaxValue
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Confuser.Runtime/AntiDebug.Antinet.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Confuser.Runtime {
4 | static partial class AntiDebugAntinet {
5 | static void Initialize() {
6 | if (!InitializeAntiDebugger())
7 | Environment.FailFast(null);
8 | InitializeAntiProfiler();
9 | if (IsProfilerAttached) {
10 | Environment.FailFast(null);
11 | PreventActiveProfilerFromReceivingProfilingMessages();
12 | }
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/Confuser.Runtime/AntiDebug.Safe.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Threading;
4 |
5 | namespace Confuser.Runtime {
6 | internal static class AntiDebugSafe {
7 | static void Initialize() {
8 | const string x = "COR";
9 | var env = typeof(Environment);
10 | var method = env.GetMethod("GetEnvironmentVariable", new[] { typeof(string) });
11 |
12 | // Comparison is done using is-operator to avoid the op_inequality overload of .NET 4.0
13 | // This is required to ensure that the result is .NET 2.0 compatible.
14 | if (!(method is null) &&
15 | "1".Equals(method.Invoke(null, new object[] { x + "_ENABLE_PROFILING" })))
16 | Environment.FailFast(null);
17 |
18 | var thread = new Thread(Worker);
19 | thread.IsBackground = true;
20 | thread.Start(null);
21 | }
22 |
23 | static void Worker(object thread) {
24 | if (!(thread is Thread th)) {
25 | th = new Thread(Worker);
26 | th.IsBackground = true;
27 | th.Start(Thread.CurrentThread);
28 | Thread.Sleep(500);
29 | }
30 | while (true) {
31 | if (Debugger.IsAttached || Debugger.IsLogging())
32 | Environment.FailFast(null);
33 |
34 | if (!th.IsAlive)
35 | Environment.FailFast(null);
36 |
37 | Thread.Sleep(1000);
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Confuser.Runtime/Confuser.Runtime.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | net20
8 | true
9 | true
10 | ..\ConfuserEx.snk
11 |
12 |
13 |
14 | ConfuserEx Runtime
15 | Runtime library of ConfuserEx
16 |
17 |
18 |
19 |
20 | all
21 | runtime; build; native; contentfiles; analyzers; buildtransitive
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Confuser.Runtime/ExcludeFromCodeCoverageAttribute.cs:
--------------------------------------------------------------------------------
1 | #if NETFRAMEWORK && (NET20 || NET35)
2 | // ReSharper disable once CheckNamespace
3 | namespace System.Diagnostics.CodeAnalysis {
4 | internal sealed class ExcludeFromCodeCoverageAttribute : Attribute {
5 | }
6 | }
7 | #endif
8 |
--------------------------------------------------------------------------------
/Confuser.Runtime/Mutation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | internal class Mutation {
4 | public static readonly int KeyI0 = 0;
5 | public static readonly int KeyI1 = 1;
6 | public static readonly int KeyI2 = 2;
7 | public static readonly int KeyI3 = 3;
8 | public static readonly int KeyI4 = 4;
9 | public static readonly int KeyI5 = 5;
10 | public static readonly int KeyI6 = 6;
11 | public static readonly int KeyI7 = 7;
12 | public static readonly int KeyI8 = 8;
13 | public static readonly int KeyI9 = 9;
14 | public static readonly int KeyI10 = 10;
15 | public static readonly int KeyI11 = 11;
16 | public static readonly int KeyI12 = 12;
17 | public static readonly int KeyI13 = 13;
18 | public static readonly int KeyI14 = 14;
19 | public static readonly int KeyI15 = 15;
20 |
21 | public static T Placeholder(T val) {
22 | return val;
23 | }
24 |
25 | public static T Value() {
26 | return default(T);
27 | }
28 |
29 | public static T Value(Arg0 arg0) {
30 | return default(T);
31 | }
32 |
33 | public static void Crypt(uint[] data, uint[] key) { }
34 | }
--------------------------------------------------------------------------------
/Confuser.Runtime/antinet/ABOUT:
--------------------------------------------------------------------------------
1 | antinet --- Code to prevent a managed .NET debugger/profiler from working
2 | Official site: https://bitbucket.org/0xd4d/antinet
3 |
4 | Written by de4dot@gmail.com
5 | Modified by Ki for use in ConfuserEx
6 |
7 | The source code in this folder is in the public domain.
--------------------------------------------------------------------------------
/Confuser.Runtime/antinet/HandleProcessCorruptedStateExceptionsAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace System.Runtime.ExceptionServices {
4 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
5 | internal class HandleProcessCorruptedStateExceptionsAttribute : Attribute {
6 |
7 | }
8 | }
--------------------------------------------------------------------------------
/ConfuserEx.Common.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 | 7.3
6 |
7 |
8 |
9 | <_CurrentYear>$([System.DateTime]::Now.ToString(yyyy))
10 | Ki;Martin Karing
11 | Copyright © 2014 Ki, 2018 - $(_CurrentYear) Martin Karing
12 | https://github.com/mkaring/ConfuserEx.git
13 | git
14 |
15 |
16 |
17 | en
18 |
19 |
20 |
21 | GitHub
22 | $(RepositoryUrl)
23 |
24 |
25 |
26 | false
27 |
28 |
29 |
--------------------------------------------------------------------------------
/ConfuserEx.Common.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ConfuserEx.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mkaring/ConfuserEx/657fb58dcf7c7a408c60ab496bfdf6442d751787/ConfuserEx.snk
--------------------------------------------------------------------------------
/ConfuserEx/App.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | Resources/#FontAwesome
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/ConfuserEx/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 |
4 | namespace ConfuserEx {
5 | public partial class App : Application { }
6 | }
--------------------------------------------------------------------------------
/ConfuserEx/BoolToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Globalization;
4 | using System.Windows;
5 | using System.Windows.Data;
6 |
7 | namespace ConfuserEx {
8 | internal class BoolToVisibilityConverter : IValueConverter {
9 | public static readonly BoolToVisibilityConverter Instance = new BoolToVisibilityConverter();
10 | BoolToVisibilityConverter() { }
11 |
12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
13 | Debug.Assert(value is bool);
14 | Debug.Assert(targetType == typeof(Visibility));
15 | return (bool)value ? Visibility.Visible : Visibility.Collapsed;
16 | }
17 |
18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
19 | throw new NotSupportedException();
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/ConfuserEx/BrushToColorConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 | using System.Windows.Media;
5 |
6 | namespace ConfuserEx {
7 | public class BrushToColorConverter : IValueConverter {
8 | public static readonly BrushToColorConverter Instance = new BrushToColorConverter();
9 | BrushToColorConverter() { }
10 |
11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
12 | var brush = value as SolidColorBrush;
13 | if (brush != null)
14 | return brush.Color;
15 | return null;
16 | }
17 |
18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
19 | throw new NotImplementedException();
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/ConfuserEx/ConfuserEx.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mkaring/ConfuserEx/657fb58dcf7c7a408c60ab496bfdf6442d751787/ConfuserEx/ConfuserEx.ico
--------------------------------------------------------------------------------
/ConfuserEx/EmptyToBoolConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace ConfuserEx {
6 | [ValueConversion(typeof(string), typeof(bool), ParameterType = typeof(bool))]
7 | [ValueConversion(typeof(string), typeof(bool), ParameterType = typeof(string))]
8 | public class EmptyToBoolConverter : IValueConverter {
9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
10 | bool stateIfEmpty = true;
11 | switch (parameter) {
12 | case bool boolParameter:
13 | stateIfEmpty = boolParameter;
14 | break;
15 | case string strParameter when bool.TryParse(strParameter, out var parsedStrParameter):
16 | stateIfEmpty = parsedStrParameter;
17 | break;
18 | }
19 |
20 | if (value == null) return stateIfEmpty;
21 | if (!(value is string strValue)) return stateIfEmpty;
22 |
23 | return string.IsNullOrEmpty(strValue) ? stateIfEmpty : !stateIfEmpty;
24 | }
25 |
26 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
27 | throw new NotSupportedException();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ConfuserEx/EnumValuesExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Markup;
3 |
4 | namespace ConfuserEx {
5 | public class EnumValuesExtension : MarkupExtension {
6 | readonly Type enumType;
7 |
8 | public EnumValuesExtension(Type enumType) {
9 | this.enumType = enumType;
10 | }
11 |
12 | public override object ProvideValue(IServiceProvider serviceProvider) {
13 | return Enum.GetValues(enumType);
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/ConfuserEx/InvertBoolConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Globalization;
4 | using System.Windows.Data;
5 |
6 | namespace ConfuserEx {
7 | internal class InvertBoolConverter : IValueConverter {
8 | public static readonly InvertBoolConverter Instance = new InvertBoolConverter();
9 | InvertBoolConverter() { }
10 |
11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
12 | Debug.Assert(value is bool);
13 | Debug.Assert(targetType == typeof(bool));
14 | return !(bool)value;
15 | }
16 |
17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
18 | throw new NotSupportedException();
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/ConfuserEx/Resources/CREDITS:
--------------------------------------------------------------------------------
1 | Icons adapted from http://flaticons.net
--------------------------------------------------------------------------------
/ConfuserEx/Resources/Decode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mkaring/ConfuserEx/657fb58dcf7c7a408c60ab496bfdf6442d751787/ConfuserEx/Resources/Decode.png
--------------------------------------------------------------------------------
/ConfuserEx/Resources/Error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mkaring/ConfuserEx/657fb58dcf7c7a408c60ab496bfdf6442d751787/ConfuserEx/Resources/Error.png
--------------------------------------------------------------------------------
/ConfuserEx/Resources/FontAwesome.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mkaring/ConfuserEx/657fb58dcf7c7a408c60ab496bfdf6442d751787/ConfuserEx/Resources/FontAwesome.otf
--------------------------------------------------------------------------------
/ConfuserEx/Resources/New.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mkaring/ConfuserEx/657fb58dcf7c7a408c60ab496bfdf6442d751787/ConfuserEx/Resources/New.png
--------------------------------------------------------------------------------
/ConfuserEx/Resources/Open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mkaring/ConfuserEx/657fb58dcf7c7a408c60ab496bfdf6442d751787/ConfuserEx/Resources/Open.png
--------------------------------------------------------------------------------
/ConfuserEx/Resources/Save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mkaring/ConfuserEx/657fb58dcf7c7a408c60ab496bfdf6442d751787/ConfuserEx/Resources/Save.png
--------------------------------------------------------------------------------
/ConfuserEx/Resources/Tools.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mkaring/ConfuserEx/657fb58dcf7c7a408c60ab496bfdf6442d751787/ConfuserEx/Resources/Tools.png
--------------------------------------------------------------------------------
/ConfuserEx/ViewModel/IViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ConfuserEx.ViewModel {
4 | public interface IViewModel {
5 | TModel Model { get; }
6 | }
7 | }
--------------------------------------------------------------------------------
/ConfuserEx/ViewModel/Project/ProjectSettingVM.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Confuser.Core.Project;
3 |
4 | namespace ConfuserEx.ViewModel {
5 | public class ProjectSettingVM : ViewModelBase, IViewModel> {
6 | readonly ProjectVM parent;
7 | readonly SettingItem setting;
8 |
9 | public ProjectSettingVM(ProjectVM parent, SettingItem setting) {
10 | this.parent = parent;
11 | this.setting = setting;
12 | }
13 |
14 | public string Id {
15 | get { return setting.Id; }
16 | set {
17 | if (SetProperty(setting.Id != value, val => setting.Id = val, value, "Id"))
18 | parent.IsModified = true;
19 | }
20 | }
21 |
22 | public SettingItemAction Action {
23 | get { return setting.Action; }
24 | set {
25 | if (SetProperty(setting.Action != value, val => setting.Action = val, value, "Action"))
26 | parent.IsModified = true;
27 | }
28 | }
29 |
30 | SettingItem IViewModel>.Model {
31 | get { return setting; }
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/ConfuserEx/ViewModel/StringItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ConfuserEx.ViewModel {
4 | public class StringItem : IViewModel {
5 | public StringItem(string item) {
6 | Item = item;
7 | }
8 |
9 | public string Item { get; private set; }
10 |
11 | string IViewModel.Model {
12 | get { return Item; }
13 | }
14 |
15 | public override string ToString() {
16 | return Item;
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/ConfuserEx/ViewModel/UI/AboutTabVM.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Linq;
4 | using System.Windows.Input;
5 | using System.Windows.Media.Imaging;
6 | using GalaSoft.MvvmLight.CommandWpf;
7 |
8 | namespace ConfuserEx.ViewModel {
9 | internal class AboutTabVM : TabViewModel {
10 | public AboutTabVM(AppVM app)
11 | : base(app, "About") {
12 | var decoder = new IconBitmapDecoder(new Uri("pack://application:,,,/ConfuserEx.ico"), BitmapCreateOptions.DelayCreation, BitmapCacheOption.OnDemand);
13 |
14 | Icon = decoder.Frames.First(frame => frame.Width == 64);
15 | }
16 |
17 | public ICommand LaunchBrowser {
18 | get { return new RelayCommand(site => Process.Start(site)); }
19 | }
20 |
21 | public BitmapSource Icon { get; private set; }
22 | }
23 | }
--------------------------------------------------------------------------------
/ConfuserEx/ViewModel/UI/TabViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ConfuserEx.ViewModel {
4 | public abstract class TabViewModel : ViewModelBase {
5 | protected TabViewModel(AppVM app, string header) {
6 | App = app;
7 | Header = header;
8 | }
9 |
10 | public AppVM App { get; private set; }
11 | public string Header { get; private set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/ConfuserEx/ViewModel/ViewModelBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 |
5 | namespace ConfuserEx.ViewModel {
6 | public class ViewModelBase : INotifyPropertyChanged {
7 | // http://stackoverflow.com/a/1316417/462805
8 |
9 | public event PropertyChangedEventHandler PropertyChanged;
10 |
11 | protected virtual void OnPropertyChanged(string property) {
12 | if (PropertyChanged != null)
13 | PropertyChanged(this, new PropertyChangedEventArgs(property));
14 | }
15 |
16 | protected bool SetProperty(ref T field, T value, string property) {
17 | if (!EqualityComparer.Default.Equals(field, value)) {
18 | field = value;
19 | OnPropertyChanged(property);
20 | return true;
21 | }
22 | return false;
23 | }
24 |
25 | protected bool SetProperty(bool changed, Action setter, T value, string property) {
26 | if (changed) {
27 | setter(value);
28 | OnPropertyChanged(property);
29 | return true;
30 | }
31 | return false;
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/ConfuserEx/Views.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ConfuserEx/Views/ProjectModuleView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using ConfuserEx.ViewModel;
5 | using Ookii.Dialogs.Wpf;
6 |
7 | namespace ConfuserEx.Views {
8 | public partial class ProjectModuleView : Window {
9 | readonly ProjectModuleVM module;
10 |
11 | public ProjectModuleView(ProjectModuleVM module) {
12 | InitializeComponent();
13 | this.module = module;
14 | DataContext = module;
15 | }
16 |
17 | void Done(object sender, RoutedEventArgs e) {
18 | DialogResult = true;
19 | }
20 |
21 | void ChooseSNKey(object sender, RoutedEventArgs e) =>
22 | module.SNKeyPath = ChooseKey();
23 |
24 | void ChooseSNSigKey(object sender, RoutedEventArgs e) =>
25 | module.SNSigKeyPath = ChooseKey();
26 |
27 | void ChooseSNPublicKey(object sender, RoutedEventArgs e) =>
28 | module.SNPubKeyPath = ChooseKey();
29 |
30 | void ChooseSNPublicSigKey(object sender, RoutedEventArgs e) =>
31 | module.SNPubSigKeyPath = ChooseKey();
32 |
33 | string ChooseKey() {
34 | var ofd = new VistaOpenFileDialog {
35 | Filter = "Supported Key Files (*.snk, *.pfx)|*.snk;*.pfx|All Files (*.*)|*.*"
36 | };
37 |
38 | return ofd.ShowDialog() ?? false ? ofd.FileName : null;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ConfuserEx/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/GlobalAssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyProduct("ConfuserEx")]
4 | [assembly: AssemblyCompany("Ki")]
5 | [assembly: AssemblyCopyright("Copyright (C) Ki 2014")]
6 |
7 | #if DEBUG
8 |
9 | [assembly: AssemblyConfiguration("Debug")]
10 | #else
11 |
12 | [assembly: AssemblyConfiguration("Release")]
13 | #endif
14 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014 yck1509
2 | Copyright (c) 2018 Martin Karing
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining
5 | a copy of this software and associated documentation files (the
6 | "Software"), to deal in the Software without restriction, including
7 | without limitation the rights to use, copy, modify, merge, publish,
8 | distribute, sublicense, and/or sell copies of the Software, and to
9 | permit persons to whom the Software is furnished to do so, subject to
10 | the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Tests/118_EnhancedStrongName.Test/118_EnhancedStrongName.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net461
5 | EnhancedStrongName.Test
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | PreserveNewest
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Tests/118_EnhancedStrongName.Test/EnhancedStrongNameTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Threading.Tasks;
4 | using Confuser.UnitTest;
5 | using Xunit;
6 | using Xunit.Abstractions;
7 |
8 | namespace EnhancedStrongName.Test {
9 | public class EnhancedStrongNameTest : TestBase {
10 | public EnhancedStrongNameTest(ITestOutputHelper outputHelper) : base(outputHelper) { }
11 |
12 | [Fact]
13 | [Trait("Category", "core")]
14 | [Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/118")]
15 | public async Task EnhancedStrongName() =>
16 | await Run("118_EnhancedStrongName.exe",
17 | new[] {"My strong key token: 79A18AF4CEA8A9BD", "My signature is valid!"},
18 | NoProtections,
19 | projectModuleAction: projectModule => {
20 | projectModule.SNSigKeyPath = Path.Combine(Environment.CurrentDirectory, "SignatureKey.snk");
21 | projectModule.SNPubSigKeyPath = Path.Combine(Environment.CurrentDirectory, "SignaturePubKey.snk");
22 | projectModule.SNKeyPath = Path.Combine(Environment.CurrentDirectory, "IdentityKey.snk");
23 | projectModule.SNPubKeyPath = Path.Combine(Environment.CurrentDirectory, "IdentityPubKey.snk");
24 | });
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Tests/118_EnhancedStrongName/118_EnhancedStrongName.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net461
6 | EnhancedStrongName
7 | true
8 | true
9 | IdentityPubKey.snk
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Tests/118_EnhancedStrongName/Attributes.cs:
--------------------------------------------------------------------------------
1 | [assembly: System.Reflection.AssemblySignatureKey(
2 | "002400000c8000009400000006020000002400005253413100040000010001003dbf2a4a3ec2fdc1d1fbb41ada405236cfd7d60d9bc35107ac747bb0ab741136ec4e9f2ec380a5ce55c360db4e64df3b8f02eb81ecf47122ccda5c7e5a14b3bac847eac14223827586270a8a39383d4d09b73c19858fd28d9a21375019f9fe3563315e60ee7dfa3c9b8b11226ec678a244153e9c32d723c7f43e91ff389fff9f",
3 | "0f3904690b927bc2a63f3466de2f7899840782f9ed7905f3445d2709e83076d8365be7b2d3d59ef47936633dfda3106654c63172747e2fb037989b98161830c89e128fa5788c83341fae908de677e2c0dc2f73bda4d54f7dac4ef1b53c8bdac84a547223e9060f4e7b5cfae14dad6c56aabdbb09c784fe1c81bbdc1eee491704")
4 | ]
5 |
--------------------------------------------------------------------------------
/Tests/118_EnhancedStrongName/IdentityKey.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mkaring/ConfuserEx/657fb58dcf7c7a408c60ab496bfdf6442d751787/Tests/118_EnhancedStrongName/IdentityKey.snk
--------------------------------------------------------------------------------
/Tests/118_EnhancedStrongName/IdentityPubKey.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mkaring/ConfuserEx/657fb58dcf7c7a408c60ab496bfdf6442d751787/Tests/118_EnhancedStrongName/IdentityPubKey.snk
--------------------------------------------------------------------------------
/Tests/118_EnhancedStrongName/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime.InteropServices;
4 | using System.Text;
5 |
6 | namespace EnhancedStrongName {
7 | public class Program {
8 | internal static int Main(string[] args) {
9 | Console.WriteLine("START");
10 | var assembly = typeof(Program).Assembly;
11 | var assemblyName = new AssemblyName(assembly.FullName);
12 |
13 | Console.WriteLine("My strong key token: " + BytesToString(assemblyName.GetPublicKeyToken()));
14 |
15 | var clrStrongName = (IClrStrongName)RuntimeEnvironment.GetRuntimeInterfaceAsObject(
16 | new Guid("B79B0ACD-F5CD-409b-B5A5-A16244610B92"),
17 | new Guid("9FD93CCF-3280-4391-B3A9-96E1CDE77C8D"));
18 |
19 | int result = clrStrongName.StrongNameSignatureVerificationEx(assembly.Location, true, out var verified);
20 | if (result == 0 && verified)
21 | Console.WriteLine("My signature is valid!");
22 |
23 | Console.WriteLine("END");
24 | return 42;
25 | }
26 |
27 | private static string BytesToString(byte[] data) {
28 | var builder = new StringBuilder();
29 | foreach (var val in data) {
30 | builder.AppendFormat("{0:X2}", val);
31 | }
32 | return builder.ToString();
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Tests/118_EnhancedStrongName/SignatureKey.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mkaring/ConfuserEx/657fb58dcf7c7a408c60ab496bfdf6442d751787/Tests/118_EnhancedStrongName/SignatureKey.snk
--------------------------------------------------------------------------------
/Tests/118_EnhancedStrongName/SignaturePubKey.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mkaring/ConfuserEx/657fb58dcf7c7a408c60ab496bfdf6442d751787/Tests/118_EnhancedStrongName/SignaturePubKey.snk
--------------------------------------------------------------------------------
/Tests/123_InheritCustomAttr.Test/123_InheritCustomAttr.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net461
5 | InheritCustomAttr.Test
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tests/123_InheritCustomAttr/123_InheritCustomAttr.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net461
6 | InheritCustomAttr
7 | InheritCustomAttr.Program
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Tests/123_InheritCustomAttr/C.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace InheritCustomAttr {
4 | abstract class C : I, IDayOfWeek {
5 | [My(Value = 1)]
6 | public abstract DayOfWeek T { get; }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Tests/123_InheritCustomAttr/D.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace InheritCustomAttr {
4 | class D : C {
5 | #pragma warning disable CS0067
6 | // Just here to make sure it works.
7 | public event EventHandler TestEvent;
8 | #pragma warning restore CS0067
9 |
10 | // this property should inherit the MyAttribute from its base class
11 | public override DayOfWeek T { get => DayOfWeek.Monday; }
12 |
13 | public virtual int U => 42;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Tests/123_InheritCustomAttr/E.cs:
--------------------------------------------------------------------------------
1 | namespace InheritCustomAttr {
2 | // this should inherit T with the MyAttribute from its base class D, C
3 | sealed class E : D {
4 | public override int U => 43;
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/Tests/123_InheritCustomAttr/ExtReference/IExt.cs:
--------------------------------------------------------------------------------
1 | namespace InheritCustomAttr.ExtReference {
2 | interface IExt : IRoot {
3 | string Ext { get; }
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/Tests/123_InheritCustomAttr/ExtReference/IExt`2.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace InheritCustomAttr.ExtReference {
4 | interface IExt : IExt, IDictionary {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/Tests/123_InheritCustomAttr/ExtReference/IRoot.cs:
--------------------------------------------------------------------------------
1 | namespace InheritCustomAttr.ExtReference {
2 | interface IRoot {
3 | int Count { get; }
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/Tests/123_InheritCustomAttr/I.cs:
--------------------------------------------------------------------------------
1 | namespace InheritCustomAttr {
2 | interface I {
3 | TM T { get; }
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/Tests/123_InheritCustomAttr/IDayOfWeek.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace InheritCustomAttr {
4 | interface IDayOfWeek {
5 | DayOfWeek T { get; }
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Tests/123_InheritCustomAttr/MyAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace InheritCustomAttr {
4 |
5 | [System.AttributeUsage(AttributeTargets.All, Inherited = true, AllowMultiple = true)]
6 | sealed class MyAttribute : Attribute {
7 | public int Value { get; set; }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Tests/123_InheritCustomAttr/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace InheritCustomAttr {
4 | class Program {
5 | static int Main(string[] args) {
6 | Console.WriteLine("START");
7 | var e = new E();
8 | Console.WriteLine(e.T);
9 | Console.WriteLine(e.U);
10 | // the following statement will crash the program after protection
11 | Console.WriteLine((Attribute.GetCustomAttributes(typeof(E).GetProperty("T"), typeof(MyAttribute))[0] as MyAttribute).Value);
12 | Console.WriteLine("END");
13 | return 42;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Tests/161_DynamicTypeRename.Test/161_DynamicTypeRename.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net461
5 | DynamicTypeRename.Test
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tests/161_DynamicTypeRename/161_DynamicTypeRename.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net461
6 | DynamicTypeRename
7 | DynamicTypeRename.Program
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Tests/193_ConstantsInlining.Lib/193_ConstantsInlining.Lib.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net461
5 | ConstantsInlining.Lib
6 |
7 |
8 |
12 |
13 | true
14 | full
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Tests/193_ConstantsInlining.Lib/ExternalClass.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 |
3 | namespace ConstantsInlining.Lib {
4 | public static class ExternalClass {
5 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
6 | public static string GetText() => "From External";
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Tests/193_ConstantsInlining.Test/193_ConstantsInlining.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net461
5 | ConstantsInlining.Test
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tests/193_ConstantsInlining.Test/ConstantInliningTest.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Confuser.Core;
3 | using Confuser.Core.Project;
4 | using Confuser.UnitTest;
5 | using Xunit;
6 | using Xunit.Abstractions;
7 |
8 | namespace ConstantsInlining.Test {
9 | public class ConstantInliningTest : TestBase {
10 | public ConstantInliningTest(ITestOutputHelper outputHelper) : base(outputHelper) { }
11 |
12 | [Fact]
13 | [Trait("Category", "Protection")]
14 | [Trait("Protection", "constants")]
15 | [Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/193")]
16 | public async Task ConstantInlining() =>
17 | await Run(new[] {"193_ConstantsInlining.exe", "193_ConstantsInlining.Lib.dll"},
18 | new[] {"From External"},
19 | new SettingItem("constants") {{"elements", "S"}});
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Tests/193_ConstantsInlining/193_ConstantsInlining.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net461
6 | ConstantsInlining
7 |
8 |
9 |
13 |
14 | true
15 | full
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Tests/193_ConstantsInlining/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ConstantsInlining {
4 | public class Program {
5 | static int Main(string[] args) {
6 | Console.WriteLine("START");
7 | Console.WriteLine(Lib.ExternalClass.GetText());
8 | Console.WriteLine("END");
9 | return 42;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Tests/244_ClrProtection.Test/244_ClrProtection.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net461
5 | ClrProtection.Test
6 | false
7 | x86
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Tests/244_ClrProtection/244_ClrProtection.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Quelldateien
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Tests/244_ClrProtection/Program.cpp:
--------------------------------------------------------------------------------
1 | using namespace System;
2 |
3 | int main()
4 | {
5 | Console::WriteLine("START");
6 | Console::WriteLine("END");
7 | return 42;
8 | }
9 |
--------------------------------------------------------------------------------
/Tests/252_ComplexInterfaceRenaming.Test/252_ComplexInterfaceRenaming.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net461
5 | ComplexInterfaceRenaming.Test
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tests/252_ComplexInterfaceRenaming/252_ComplexInterfaceRenaming.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net461
6 | ComplexInterfaceRenaming
7 | ComplexInterfaceRenaming.Program
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Tests/252_ComplexInterfaceRenaming/IC.cs:
--------------------------------------------------------------------------------
1 | namespace ComplexInterfaceRenaming {
2 | public interface IC {
3 | void C(string x);
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/Tests/252_ComplexInterfaceRenaming/IName.cs:
--------------------------------------------------------------------------------
1 | namespace ComplexInterfaceRenaming {
2 | public interface IName {
3 | string Name { get; }
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/Tests/252_ComplexInterfaceRenaming/IOperator.cs:
--------------------------------------------------------------------------------
1 | namespace ComplexInterfaceRenaming {
2 | public interface IOperator {
3 | string Name { get; }
4 | void Operate();
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/Tests/252_ComplexInterfaceRenaming/IWorker.cs:
--------------------------------------------------------------------------------
1 | namespace ComplexInterfaceRenaming
2 | {
3 | public interface IWorker : IName, IC {}
4 | }
5 |
--------------------------------------------------------------------------------
/Tests/252_ComplexInterfaceRenaming/Manager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ComplexInterfaceRenaming {
4 | internal sealed class Manager : Worker, IWorker, IOperator
5 | {
6 | public string Name => "I'm a manager!";
7 |
8 | public void Operate() => throw new NotImplementedException();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Tests/252_ComplexInterfaceRenaming/Operator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ComplexInterfaceRenaming {
4 | internal sealed class Operator : IC, IOperator, IName {
5 | public string Name { get; set; }
6 |
7 | public void C(string x) => throw new NotImplementedException();
8 |
9 | void IOperator.Operate() => throw new NotImplementedException();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Tests/252_ComplexInterfaceRenaming/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ComplexInterfaceRenaming {
4 | public class Program {
5 | static int Main(string[] args) {
6 | Console.WriteLine("START");
7 | var op = new Operator {
8 | Name = "I'm a operator."
9 | };
10 | Console.WriteLine("Operator: " + op.Name);
11 | Console.WriteLine("Operator(IOperator): " + (op as IOperator).Name);
12 | Console.WriteLine("Operator(IName): " + (op as IName).Name);
13 |
14 | var manager = new Manager();
15 | Console.WriteLine("Manager: " + manager.Name);
16 | Console.WriteLine("Manager(IWorker): " + (manager as IWorker).Name);
17 | Console.WriteLine("Manager(IOperator): " + (manager as IOperator).Name);
18 | Console.WriteLine("Manager(IName): " + (manager as IName).Name);
19 | manager.C("abc");
20 |
21 | Console.WriteLine("END");
22 |
23 | return 42;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Tests/252_ComplexInterfaceRenaming/Worker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ComplexInterfaceRenaming {
4 | internal class Worker {
5 | public void C(string x) => Console.WriteLine("Working: " + x);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Tests/270_EnumArrayConstantProtection.Test/270_EnumArrayConstantProtection.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net461
5 | EnumArrayConstantProtection.Test
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tests/270_EnumArrayConstantProtection.Test/ConstantProtectionTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Confuser.Core;
4 | using Confuser.Core.Project;
5 | using Confuser.UnitTest;
6 | using Xunit;
7 | using Xunit.Abstractions;
8 |
9 | namespace EnumArrayConstantProtection.Test {
10 | public class ConstantProtectionTest : TestBase {
11 | public ConstantProtectionTest(ITestOutputHelper outputHelper) : base(outputHelper) { }
12 |
13 | [Fact]
14 | [Trait("Category", "Protection")]
15 | [Trait("Protection", "constants")]
16 | [Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/270")]
17 | public async Task ConstantsProtection() =>
18 | await Run(
19 | "270_EnumArrayConstantProtection.exe",
20 | new[] {
21 | "Enum Array OK",
22 | "String Array OK"
23 | },
24 | new SettingItem("constants") { { "elements", "SI" } }
25 | );
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Tests/270_EnumArrayConstantProtection/270_EnumArrayConstantProtection.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net461
6 | ConstantProtection
7 | 7.3
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Tests/270_EnumArrayConstantProtection/Level.cs:
--------------------------------------------------------------------------------
1 | namespace EnumArrayConstantProtection {
2 | public enum Level : long {
3 | A = 1,
4 | B = 2,
5 | C = 4,
6 | D = 8,
7 | E = 1073741824
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Tests/270_EnumArrayConstantProtection/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics.CodeAnalysis;
3 |
4 | namespace EnumArrayConstantProtection {
5 | public class Program {
6 | [SuppressMessage("Style", "IDE0060:Remove unused parameters", Justification = "Required signature")]
7 | static int Main(string[] args) {
8 | Console.WriteLine("START");
9 | Console.WriteLine(Get(Level.A, Level.E, Level.D));
10 | Console.WriteLine(Get("abc", "def", "ghi"));
11 | Console.WriteLine("END");
12 | return 42;
13 | }
14 |
15 | [SuppressMessage("Style", "IDE0060:Remove unused parameters", Justification = "Just for testing.")]
16 | private static string Get(params Level[] levels) => "Enum Array OK";
17 |
18 | private static string Get(params string[] texts) => "String Array OK";
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Tests/306_ComplexClassStructureRename.Lib/306_ComplexClassStructureRename.Lib.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net461
5 | ComplexClassStructureRename.Lib
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Tests/306_ComplexClassStructureRename.Lib/ITestEvents.cs:
--------------------------------------------------------------------------------
1 | namespace ComplexClassStructureRename.Lib {
2 | public interface ITestEvents {
3 | void FireLog(string message);
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/Tests/306_ComplexClassStructureRename.Lib/InternalBaseClass.cs:
--------------------------------------------------------------------------------
1 | namespace ComplexClassStructureRename.Lib {
2 | internal class InternalBaseClass {
3 | public virtual void FireLog(string message) { }
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/Tests/306_ComplexClassStructureRename.Lib/InternalClass1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ComplexClassStructureRename.Lib {
4 | internal class InternalClass1 : InternalBaseClass {
5 | public new void FireLog(string message) =>
6 | Console.WriteLine("InternalClass1: " + message);
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Tests/306_ComplexClassStructureRename.Lib/InternalClass2.cs:
--------------------------------------------------------------------------------
1 | namespace ComplexClassStructureRename.Lib {
2 | internal class InternalClass2 : InternalBaseClass, ITestEvents { }
3 | }
4 |
--------------------------------------------------------------------------------
/Tests/306_ComplexClassStructureRename.Lib/MyTest.cs:
--------------------------------------------------------------------------------
1 | namespace ComplexClassStructureRename.Lib {
2 | internal class MyTest {
3 | readonly InternalClass1 _test1 = new InternalClass1();
4 | readonly InternalClass2 _test2 = new InternalClass2();
5 |
6 | public void Test() {
7 | _test1.FireLog("test1 Hello");
8 | _test2.FireLog("test2 Hello");
9 | }
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Tests/306_ComplexClassStructureRename.Lib/PublicClass1.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | namespace ComplexClassStructureRename.Lib {
4 | [Obfuscation(Exclude = false, Feature = "-rename")]
5 | public class PublicClass1 : ITestEvents {
6 | public void FireLog(string message) { }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Tests/306_ComplexClassStructureRename.Lib/PublicClass2.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | namespace ComplexClassStructureRename.Lib {
4 | [Obfuscation(Exclude = false, Feature = "-rename")]
5 | public class PublicClass2 {
6 | readonly MyTest _test = new MyTest();
7 |
8 | public void Test() => _test.Test();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Tests/306_ComplexClassStructureRename.Test/306_ComplexClassStructureRename.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net461
5 | ComplexClassStructureRename.Test
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Tests/306_ComplexClassStructureRename.Test/ComplexRenameTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Confuser.Core;
4 | using Confuser.Core.Project;
5 | using Confuser.UnitTest;
6 | using Xunit;
7 | using Xunit.Abstractions;
8 |
9 | namespace ComplexClassStructureRename.Test {
10 | public class ComplexRenameTest : TestBase {
11 | public ComplexRenameTest(ITestOutputHelper outputHelper) : base(outputHelper) { }
12 |
13 | [Fact]
14 | [Trait("Category", "Protection")]
15 | [Trait("Protection", "rename")]
16 | [Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/306")]
17 | public async Task ComplexClassStructureRename() =>
18 | await Run(
19 | new[] {
20 | "306_ComplexClassStructureRename.exe",
21 | "306_ComplexClassStructureRename.Lib.dll"
22 | },
23 | new[] {
24 | "InternalClass1: test1 Hello"
25 | },
26 | new SettingItem("rename") {
27 | { "mode", "sequential" },
28 | { "renPublic", "true" },
29 | { "flatten", "false" }
30 | }
31 | );
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Tests/306_ComplexClassStructureRename/306_ComplexClassStructureRename.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net461
6 | ComplexClassStructureRename
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Tests/306_ComplexClassStructureRename/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics.CodeAnalysis;
3 | using System.Reflection;
4 | using ComplexClassStructureRename.Lib;
5 |
6 | [assembly: Obfuscation(Exclude = false, Feature = "-rename")]
7 |
8 | namespace ComplexClassStructureRename {
9 | public class Program {
10 | [SuppressMessage("Style", "IDE0060:Remove unused parameters", Justification = "Required signature")]
11 | static int Main(string[] args) {
12 | Console.WriteLine("START");
13 |
14 | var t = new PublicClass2();
15 | t.Test();
16 |
17 | Console.WriteLine("END");
18 | return 42;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Tests/342_InterfaceRenamingLoop.Test/342_InterfaceRenamingLoop.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net461
5 | InterfaceRenamingLoop.Test
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Tests/342_InterfaceRenamingLoop.Test/InterfaceRenamingLoopTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Threading.Tasks;
4 | using Confuser.Core;
5 | using Confuser.Core.Project;
6 | using Confuser.Renamer;
7 | using Confuser.UnitTest;
8 | using Xunit;
9 | using Xunit.Abstractions;
10 |
11 | namespace InterfaceRenamingLoop.Test {
12 | public class InterfaceRenamingLoopTest : TestBase {
13 | public InterfaceRenamingLoopTest(ITestOutputHelper outputHelper) : base(outputHelper) { }
14 |
15 | [Theory]
16 | [MemberData(nameof(RenameInterfaceLoopTestData))]
17 | [Trait("Category", "Protection")]
18 | [Trait("Protection", "rename")]
19 | [Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/342")]
20 | public async Task RenameInterfaceLoop(string renameMode) =>
21 | await Run(
22 | "342_InterfaceRenamingLoop.exe",
23 | Array.Empty(),
24 | new SettingItem("rename") {
25 | { "mode", renameMode }
26 | },
27 | $"_{renameMode}"
28 | );
29 |
30 | public static IEnumerable