├── LICENSE
├── README.md
├── dotnet_standard_interfaces.txt
├── samples
├── MD5.exe
├── RC4.exe
└── SHA1.exe
└── src
├── Cfg
├── Cfg.cs
├── Cfg.csproj
├── CfgManipulation.cs
└── Properties
│ └── AssemblyInfo.cs
├── CfgElements
├── CfgElements.cs
├── CfgElements.csproj
└── Properties
│ └── AssemblyInfo.cs
├── Documentation
├── A Common Compiler Infrastructure for the Common Language Infrastructure.pptx
├── CCI Metadata components API documentation.chm
├── CCI at ICSE 2010.pptx
├── CCI2 Architecture.pptx
├── CCI_Metadata.chm
├── Metadata.shfb
└── Metadata.shfbproj
├── External
└── Xunit
│ ├── HTML.xslt
│ ├── NUnitXml.xslt
│ ├── readme.txt
│ ├── xunit.console.exe
│ ├── xunit.console.exe.config
│ ├── xunit.dll
│ ├── xunit.extensions.dll
│ ├── xunit.extensions.xml
│ ├── xunit.gui.exe
│ ├── xunit.installer.exe
│ ├── xunit.runner.msbuild.dll
│ ├── xunit.runner.tdnet.dll
│ ├── xunit.runner.utility.dll
│ ├── xunit.runner.utility.xml
│ └── xunit.xml
├── Graph
├── Graph.cs
├── Graph.csproj
└── Properties
│ └── AssemblyInfo.cs
├── GraphElements
├── GraphElements.cs
├── GraphElements.csproj
└── Properties
│ └── AssemblyInfo.cs
├── Log
├── Log.cs
├── Log.csproj
└── Properties
│ └── AssemblyInfo.cs
├── MergeClasses
├── App.config
├── MergeClasses.csproj
├── Program.cs
└── Properties
│ └── AssemblyInfo.cs
├── Metadata.sln
├── Metadata.v12.suo
├── Metadata.vssscc
├── Probfuscator
├── App.config
├── Probfuscator.csproj
├── Probfuscator.csproj.user
├── Program.cs
└── Properties
│ └── AssemblyInfo.cs
├── Samples
├── AnalysisToText
│ ├── AnalysisToText.csproj
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── SourceEmitter.cs
├── CDFGToText
│ ├── CdfgToText.csproj
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── SourceEmitter.cs
├── EdgeProfiler
│ ├── AddInstrumentation.cs
│ ├── EdgeProfiler.csproj
│ ├── Logger.cs
│ ├── Program.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
├── FindGeneric
│ ├── FindGeneric.csproj
│ ├── Program.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
├── FindThrowArgumentNull
│ ├── FindThrowArgumentNull.csproj
│ ├── Program.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
├── HelloIL
│ ├── HelloIL.csproj
│ ├── Program.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
├── ILGarbageCollect
│ ├── AnalysisReasons.cs
│ ├── GarbageCollectHelper.cs
│ ├── ILGarbageCollect.csproj
│ ├── ILGarbageCollect.csproj.user
│ ├── ILGarbageCollect.csproj.vspscc
│ ├── Instrumentation
│ │ ├── ILMethodBodyRewriter.cs
│ │ ├── TraceInstrumentor.cs
│ │ └── ZombieFieldInstrumentor.cs
│ ├── LocalFlow.cs
│ ├── Mark.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── RapidTypeAnalysis.cs
│ ├── Summaries
│ │ ├── LocalFlowMethodSummarizer.cs
│ │ ├── SimpleBytecodeMethodSummarizer.cs
│ │ ├── Summaries.cs
│ │ └── TextFileMethodSummarizer.cs
│ └── Sweep.cs
├── ILMutator
│ ├── ILMutator.cs
│ ├── ILMutator.csproj
│ └── Properties
│ │ └── AssemblyInfo.cs
├── PeToPe
│ ├── PeToPe.csproj
│ ├── Program.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
├── PeToText
│ ├── PeToText.csproj
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── SourceEmitter.cs
└── Z3Wrapper
│ ├── Microsoft.Z3.xml
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Readme.txt
│ ├── Wrapper.cs
│ ├── Z3Wrapper.csproj
│ ├── msvcp100.dll
│ └── vcomp100.dll
├── Sources
├── AnalyisUtilities
│ ├── AbstractDomains
│ │ └── Intervals.cs
│ ├── AbstractInterpretation.cs
│ ├── AnalysisUtilities.csproj
│ ├── Evaluator.cs
│ ├── ExpressionCanonicalizer.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Purger.cs
│ ├── SatSolver.cs
│ ├── Simplifier.cs
│ ├── SingleAssignment.cs
│ └── ValueMappings.cs
├── Common
│ ├── Include
│ │ └── Version.cs
│ └── InterimKey.snk
├── ControlAndDataFlowGraph
│ ├── ControlAndDataFlowGraph.csproj
│ ├── ControlFlowInferencer.cs
│ ├── ControlFlowQueries.cs
│ ├── DataFlowInferencer.cs
│ ├── Graph.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── TypeInferencer.cs
├── ILGenerator
│ ├── ILGenerator.cs
│ ├── ILGenerator.csproj
│ ├── ILRewriter.cs
│ ├── MethodBody.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
├── MetadataHelper
│ ├── AttributeHelper.cs
│ ├── CommandLineOptions.cs
│ ├── Core.cs
│ ├── ErrorMessages.resx
│ ├── ExpressionHelper.cs
│ ├── GlobalAssemblyCache.cs
│ ├── MemberHelper.cs
│ ├── Members.cs
│ ├── MetadataHelper.csproj
│ ├── MetadataHelperCF.csproj
│ ├── MonoAssemblyCache.cs
│ ├── PlatformTypes.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── TypeHelper.cs
│ ├── Types.cs
│ ├── UnitHelper.cs
│ ├── UnmanagedFileIO.cs
│ ├── UtilityDataStructures.cs
│ ├── Validator.cs
│ └── Visitors.cs
├── MetadataModel
│ ├── Core.cd
│ ├── Core.cs
│ ├── DummyObjects.cs
│ ├── Expressions.cs
│ ├── Members.cd
│ ├── Members.cs
│ ├── MetadataModel.csproj
│ ├── MetadataModelCF.csproj
│ ├── Miscellaneous.cs
│ ├── Namespaces.cd
│ ├── Namespaces.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Templates.cd
│ ├── Types.cd
│ ├── Types.cs
│ ├── Units.cd
│ └── Units.cs
├── Microsoft.Contracts
│ ├── Contracts.cs
│ ├── ContractsEx.cs
│ ├── InterimKey.snk
│ ├── Microsoft.Contracts.csproj
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── RuntimeContracts.cs
├── MutableMetadataModel
│ ├── Copier.cs
│ ├── Expressions.cs
│ ├── Members.cs
│ ├── Miscellaneous.cs
│ ├── MutableMetadataModel.csproj
│ ├── MutableMetadataModelCF.csproj
│ ├── Mutator.cs
│ ├── Namespaces.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Types.cs
│ └── Units.cs
├── OptimizationUtilities
│ ├── ILGeneration.cs
│ ├── Inlining.cs
│ ├── LocalMinimizer.cs
│ ├── Merger.cs
│ ├── MultipleAssignment.cs
│ ├── OptimizationUtilities.csproj
│ ├── PartialEvaluation.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── StackEliminator.cs
├── PdbReader
│ ├── BitAccess.cs
│ ├── BitSet.cs
│ ├── CvInfo.cs
│ ├── DataStream.cs
│ ├── DbiDbgHdr.cs
│ ├── DbiHeader.cs
│ ├── DbiModuleInfo.cs
│ ├── DbiSecCon.cs
│ ├── IntHashTable.cs
│ ├── MsfDirectory.cs
│ ├── PdbConstant.cs
│ ├── PdbDebugException.cs
│ ├── PdbException.cs
│ ├── PdbFile.cs
│ ├── PdbFileHeader.cs
│ ├── PdbFunction.cs
│ ├── PdbLine.cs
│ ├── PdbLines.cs
│ ├── PdbReader.cs
│ ├── PdbReader.csproj
│ ├── PdbScope.cs
│ ├── PdbSlot.cs
│ ├── PdbSource.cs
│ ├── PdbTokenLine.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── SourceLocationProvider.cs
├── PdbWriter
│ ├── GlobalSuppressions.cs
│ ├── ISymbolWriter.cs
│ ├── PdbWriter.csproj
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── Writer.cs
├── PeReader
│ ├── Attributes.cs
│ ├── BinaryObjectModel.cs
│ ├── CoreTypes.cs
│ ├── Errors.cs
│ ├── ILReader.cs
│ ├── ModuleReadWriteFactory.cs
│ ├── PEFileReader.cs
│ ├── PEFileStructures.cs
│ ├── PEFileToObjectModel.cs
│ ├── PeReader.csproj
│ ├── PeReaderCF.csproj
│ ├── PeReaderErrorMessages.resx
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Types.cs
│ ├── UnmanagedReadWrite.cs
│ ├── UtilityDataStructures.cs
│ └── WindowsRuntimeHost.cs
├── PeWriter
│ ├── BinaryWriter.cs
│ ├── GlobalSuppressions.cs
│ ├── IMetadata.cs
│ ├── MemoryStream.cs
│ ├── PdbWriterInterface.cs
│ ├── PeWriter.cs
│ ├── PeWriter.csproj
│ ├── PeWriterCF.csproj
│ └── Properties
│ │ └── AssemblyInfo.cs
├── ReflectionEmitter
│ ├── Emitter.cs
│ ├── Mapper.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── ReflectionEmitter.csproj
├── ReflectionImporter
│ ├── Mapper.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── ReflectionImporter.csproj
│ └── Wrapper.cs
└── SourceModel
│ ├── DummyObjects.cs
│ ├── Implementations.cs
│ ├── Interfaces.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── SourceModel.csproj
│ ├── SourceModelCF.csproj
│ └── SourceModelHelper.cs
├── Tests
├── PEReaderTests
│ ├── AssemblyModuleTests.cs
│ ├── MethodBodyTests.cs
│ ├── ModuleReaderTests.cs
│ ├── PEReaderTests.csproj
│ ├── PrettyPrinter.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── TestModules
│ │ ├── MRW_Assembly.cs
│ │ ├── MRW_Assembly.dll
│ │ ├── MRW_CppAssembly.cpp
│ │ ├── MRW_CppAssembly.dll
│ │ ├── MRW_ILAsmAssembly.dll
│ │ ├── MRW_ILAsmAssembly.il
│ │ ├── MRW_Module1.cs
│ │ ├── MRW_Module1.netmodule
│ │ ├── MRW_Module2.cs
│ │ ├── MRW_Module2.netmodule
│ │ ├── MRW_TestAssembly.cs
│ │ ├── MRW_TestAssembly.dll
│ │ ├── arch-msil.dll
│ │ ├── build.cmd
│ │ └── vjslib.dll
│ ├── TypeMemberTests.cs
│ └── TypeTests.cs
├── RoundtripTests
│ ├── PeVerify.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── RoundTripTests.cs
│ ├── RoundtripTests.csproj
│ └── TestData
│ │ ├── source
│ │ ├── Repro1.cs
│ │ ├── Repro2.cs
│ │ ├── Repro3.cs
│ │ ├── Repro4.cs
│ │ ├── Repro5.cs
│ │ └── Repro6.cs
│ │ ├── v2
│ │ ├── System.dll
│ │ ├── System.pdb
│ │ ├── mscorlib.dll
│ │ └── mscorlib.pdb
│ │ └── v4
│ │ ├── System.Core.dll
│ │ ├── System.Core.pdb
│ │ ├── mscorlib.dll
│ │ └── mscorlib.pdb
└── TestILGarbageCollector
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── RapidTypeAnalysisTests.cs
│ ├── SourceInputs
│ ├── DeadField.cs
│ └── DeadMethod.cs
│ ├── TestILGarbageCollector.csproj
│ └── TestILGarbageCollector.csproj.vspscc
├── Transformations
├── GraphTransformer.cs
├── Helper.cs
├── InterfaceTransformer.cs
├── NopTransformer.cs
├── Properties
│ └── AssemblyInfo.cs
└── Transformations.csproj
└── TransformationsMetadata
├── Properties
└── AssemblyInfo.cs
├── TransformationsMetadata.cs
└── TransformationsMetadata.csproj
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Andre Pawlowski (sqall)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # What?
2 |
3 | This is the obfuscation prototype targeting .NET programs of the paper [Probfuscation: An Obfuscation Approach using Probabilistic Control Flows](https://www.syssec.rub.de/research/publications/probfuscation/), published at the Conference on Detection of Intrusions and Malware & Vulnerability Assessment (DIMVA), Donostia-San Sebastian, Spain, July 2016.
4 |
5 |
6 | # How to use?
7 |
8 | The prototype uses [CCI Metadata](https://ccimetadata.codeplex.com/) as a framework. If you want to use it, please use the Visual Studio Solution to compile the "Probfuscator" project. This creates a console application which can obfuscate arbitrary methods.
9 |
10 | In order to obfuscate a function you can, for example, execute the following command:
11 |
12 | ```bash
13 |
14 | Probfuscator.exe e:\MD5.exe e:\MD5_obfu.exe MD5 MD5 CalculateMD5Value 4 4 3 10 10 10 10 10 2
15 |
16 | ```
17 |
18 | The arguments are the following:
19 |
20 | * inputBinary - Path to the binary that should be obfuscated.
21 | * outputBinary - Path and name of the binary that is created by the obfuscator.
22 | * namespace - The namespace that target class resides in (case sensitive).
23 | * class - The class that target method resides in (case sensitive).
24 | * method - The method that should be obfuscated (case sensitive).
25 | * depth - The depth of the obfuscation graph.
26 | * dimension - The dimension of the obfuscation graph.
27 | * numberValidPaths - Number of vpaths through the obfuscation graph.
28 | * duplicateBasicBlockWeight - A weighting value that is used in the random decision if a basic block is duplicated or not.
29 | * duplicateBasicBlockCorrectionValue - This correction value is added to the weighting value after each obfuscation iteration in order to ensure the termination of the process.
30 | * stateChangeWeight - A weighting value that is used in the random decision if code to change the vpath is added or not.
31 | * stateChangeCorrectionValue - This correction value is added to the weighting value after each obfuscation iteration in order to ensure the termination of the process.
32 | * insertOpaquePredicateWeight - A weighting value that is used in the random decision if an opaque predicate is added or not.
33 | * seed - Seed of the PRNG that is used by the prototype.
--------------------------------------------------------------------------------
/samples/MD5.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/samples/MD5.exe
--------------------------------------------------------------------------------
/samples/RC4.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/samples/RC4.exe
--------------------------------------------------------------------------------
/samples/SHA1.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/samples/SHA1.exe
--------------------------------------------------------------------------------
/src/Cfg/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Cfg")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Cfg")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("6942d7ee-ffa7-430f-93a5-9fdfa2f4f6e1")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/CfgElements/CfgElements.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {88149B24-2131-4240-9DED-DE8BCDEAC34B}
8 | Library
9 | Properties
10 | CfgElements
11 | CfgElements
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | {08156c78-403a-4112-ad81-8646ac51cd2f}
48 | ILGenerator
49 |
50 |
51 | {33cab640-0d03-43df-81bd-22cdc6c0a597}
52 | MetadataModel
53 |
54 |
55 | {319e151c-8f33-49e7-81c9-30f02f9ba90a}
56 | MutableMetadataModel
57 |
58 |
59 | {b67baaf5-6527-4fdb-bb72-468b0a3a8a06}
60 | TransformationsMetadata
61 |
62 |
63 |
64 |
71 |
--------------------------------------------------------------------------------
/src/CfgElements/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("CfgElements")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("CfgElements")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("2d3b02a1-a7f1-4d0e-8d72-bbf326383e0d")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Documentation/A Common Compiler Infrastructure for the Common Language Infrastructure.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/Documentation/A Common Compiler Infrastructure for the Common Language Infrastructure.pptx
--------------------------------------------------------------------------------
/src/Documentation/CCI Metadata components API documentation.chm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/Documentation/CCI Metadata components API documentation.chm
--------------------------------------------------------------------------------
/src/Documentation/CCI at ICSE 2010.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/Documentation/CCI at ICSE 2010.pptx
--------------------------------------------------------------------------------
/src/Documentation/CCI2 Architecture.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/Documentation/CCI2 Architecture.pptx
--------------------------------------------------------------------------------
/src/Documentation/CCI_Metadata.chm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/Documentation/CCI_Metadata.chm
--------------------------------------------------------------------------------
/src/External/Xunit/NUnitXml.xslt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | False
35 | True
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | False
54 | True
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | False
80 | True
81 |
82 |
83 |
84 | False
85 | True
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
--------------------------------------------------------------------------------
/src/External/Xunit/readme.txt:
--------------------------------------------------------------------------------
1 | xunit 1.5-ctp1
--------------------------------------------------------------------------------
/src/External/Xunit/xunit.console.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/External/Xunit/xunit.console.exe
--------------------------------------------------------------------------------
/src/External/Xunit/xunit.console.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
14 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/External/Xunit/xunit.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/External/Xunit/xunit.dll
--------------------------------------------------------------------------------
/src/External/Xunit/xunit.extensions.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/External/Xunit/xunit.extensions.dll
--------------------------------------------------------------------------------
/src/External/Xunit/xunit.gui.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/External/Xunit/xunit.gui.exe
--------------------------------------------------------------------------------
/src/External/Xunit/xunit.installer.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/External/Xunit/xunit.installer.exe
--------------------------------------------------------------------------------
/src/External/Xunit/xunit.runner.msbuild.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/External/Xunit/xunit.runner.msbuild.dll
--------------------------------------------------------------------------------
/src/External/Xunit/xunit.runner.tdnet.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/External/Xunit/xunit.runner.tdnet.dll
--------------------------------------------------------------------------------
/src/External/Xunit/xunit.runner.utility.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/External/Xunit/xunit.runner.utility.dll
--------------------------------------------------------------------------------
/src/Graph/Graph.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {C5764054-5E31-4751-BD4C-6075011808EC}
8 | Library
9 | Properties
10 | Graph
11 | Graph
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | {95b70772-379d-4e73-af16-50b9f670f5b7}
48 | GraphElements
49 |
50 |
51 | {cb22ed55-2cb2-4f7f-a2d5-a4ed5c26edad}
52 | Log
53 |
54 |
55 | {4a34a3c5-6176-49d7-a4c5-b2b671247f8f}
56 | MetadataHelper
57 |
58 |
59 | {33cab640-0d03-43df-81bd-22cdc6c0a597}
60 | MetadataModel
61 |
62 |
63 | {319e151c-8f33-49e7-81c9-30f02f9ba90a}
64 | MutableMetadataModel
65 |
66 |
67 | {4b0054fd-124a-4037-9965-bdb55e6bf389}
68 | SourceModel
69 |
70 |
71 |
72 |
79 |
--------------------------------------------------------------------------------
/src/Graph/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Graph")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Graph")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("07553c76-17e2-48b4-9024-57a44ee44aa4")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/GraphElements/GraphElements.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {95B70772-379D-4E73-AF16-50B9F670F5B7}
8 | Library
9 | Properties
10 | GraphElements
11 | GraphElements
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | {4a34a3c5-6176-49d7-a4c5-b2b671247f8f}
48 | MetadataHelper
49 |
50 |
51 | {33cab640-0d03-43df-81bd-22cdc6c0a597}
52 | MetadataModel
53 |
54 |
55 | {319e151c-8f33-49e7-81c9-30f02f9ba90a}
56 | MutableMetadataModel
57 |
58 |
59 | {4b0054fd-124a-4037-9965-bdb55e6bf389}
60 | SourceModel
61 |
62 |
63 |
64 |
71 |
--------------------------------------------------------------------------------
/src/GraphElements/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("GraphElements")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("GraphElements")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("2b5d71ab-440d-4fb9-b8f7-dbbb83e10e83")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Log/Log.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {CB22ED55-2CB2-4F7F-A2D5-A4ED5C26EDAD}
8 | Library
9 | Properties
10 | Log
11 | Log
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | {88149b24-2131-4240-9ded-de8bcdeac34b}
48 | CfgElements
49 |
50 |
51 | {95b70772-379d-4e73-af16-50b9f670f5b7}
52 | GraphElements
53 |
54 |
55 | {4a34a3c5-6176-49d7-a4c5-b2b671247f8f}
56 | MetadataHelper
57 |
58 |
59 | {33cab640-0d03-43df-81bd-22cdc6c0a597}
60 | MetadataModel
61 |
62 |
63 | {319e151c-8f33-49e7-81c9-30f02f9ba90a}
64 | MutableMetadataModel
65 |
66 |
67 | {b67baaf5-6527-4fdb-bb72-468b0a3a8a06}
68 | TransformationsMetadata
69 |
70 |
71 |
72 |
79 |
--------------------------------------------------------------------------------
/src/Log/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Log")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Log")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("d3856e7a-e6b6-4b31-9701-8256796cfd91")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/MergeClasses/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/MergeClasses/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("MergeClasses")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("MergeClasses")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("3dd72287-b9ca-40e2-ba12-a070971c4efc")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Metadata.v12.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/Metadata.v12.suo
--------------------------------------------------------------------------------
/src/Metadata.vssscc:
--------------------------------------------------------------------------------
1 | ""
2 | {
3 | "FILE_VERSION" = "9237"
4 | "ENLISTMENT_CHOICE" = "NEVER"
5 | "PROJECT_FILE_RELATIVE_PATH" = ""
6 | "NUMBER_OF_EXCLUDED_FILES" = "0"
7 | "ORIGINAL_PROJECT_FILE_PATH" = ""
8 | "NUMBER_OF_NESTED_PROJECTS" = "0"
9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT"
10 | }
11 |
--------------------------------------------------------------------------------
/src/Probfuscator/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/Probfuscator/Probfuscator.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | e:\MD5.exe e:\MD5_obfu.exe MD5 MD5 CalculateMD5Value 4 4 4 10 10 10 10 10 2
5 |
6 |
--------------------------------------------------------------------------------
/src/Probfuscator/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Probfuscator")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Probfuscator")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("e56be4c8-a124-4b9e-820c-c42cb11b14f5")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Samples/AnalysisToText/AnalysisToText.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {75BF77FD-8A3F-4367-8049-26B019506F78}
9 | Exe
10 | Properties
11 | CDFGToText
12 | CDFGToText
13 | v4.0
14 |
15 |
16 | 512
17 |
18 |
19 | x64
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 |
28 |
29 | AnyCPU
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | {4A34A3C5-6176-49D7-A4C5-B2B671247F8F}
48 | MetadataHelper
49 |
50 |
51 | {33CAB640-0D03-43DF-81BD-22CDC6C0A597}
52 | MetadataModel
53 |
54 |
55 | {4B0054FD-124A-4037-9965-BDB55E6BF389}
56 | SourceModel
57 |
58 |
59 | {A6A31B03-7C3D-4DE6-AA73-BE88116BC40A}
60 | PdbReader
61 |
62 |
63 | {34B9A0CE-DF18-4CBC-8F7A-90C2B74338D5}
64 | PeReader
65 |
66 |
67 | {2596EFB0-87AE-42CE-89EB-84F35D6350D2}
68 | ControlAndDataFlowGraph
69 |
70 |
71 | {E8B89C56-383A-4A1D-9EEE-E5FE9FC9DE03}
72 | AnalysisUtilities
73 |
74 |
75 | {3F8C2DDB-E3DB-478A-8482-743E8BFB8F7B}
76 | Z3Wrapper
77 |
78 |
79 |
80 |
87 |
--------------------------------------------------------------------------------
/src/Samples/AnalysisToText/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using Microsoft.Cci;
4 | using Microsoft.Cci.MetadataReader;
5 |
6 | namespace CdfgToText {
7 | class Program {
8 | static void Main(string[] args) {
9 | if (args == null || args.Length == 0) {
10 | Console.WriteLine("usage: CdfgToText [path]fileName.ext");
11 | return;
12 | }
13 | using (var host = new PeReader.DefaultHost()) {
14 | IModule/*?*/ module = host.LoadUnitFrom(args[0]) as IModule;
15 | if (module == null || module is Dummy) {
16 | Console.WriteLine(args[0]+" is not a PE file containing a CLR module or assembly.");
17 | return;
18 | }
19 |
20 | PdbReader/*?*/ pdbReader = null;
21 | string pdbFile = Path.ChangeExtension(module.Location, "pdb");
22 | if (File.Exists(pdbFile)) {
23 | using (var pdbStream = File.OpenRead(pdbFile)) {
24 | pdbReader = new PdbReader(pdbStream, host);
25 | }
26 | }
27 |
28 | FileStream profileReader = null;
29 | string proFile = Path.ChangeExtension(module.Location, "profile");
30 | if (File.Exists(proFile))
31 | profileReader = File.OpenRead(proFile);
32 |
33 | using (pdbReader) {
34 | string txtFile = Path.ChangeExtension(pdbFile, "txt");
35 | var writer = new StreamWriter(txtFile);
36 | SourceEmitter csSourceEmitter = new SourceEmitter(writer, host, pdbReader, profileReader);
37 |
38 | csSourceEmitter.Traverse(module.UnitNamespaceRoot);
39 | writer.Close();
40 | }
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/Samples/AnalysisToText/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("CDFGToText")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("CCI")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("6e80c218-ac88-4290-bdee-f7cc3b5e505a")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Samples/CDFGToText/CdfgToText.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {B0AB7104-3683-4A5E-9505-B5813FD41D72}
9 | Exe
10 | Properties
11 | CDFGToText
12 | CDFGToText
13 | v4.0
14 |
15 |
16 | 512
17 |
18 |
19 | x86
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 |
28 |
29 | x86
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | {2596EFB0-87AE-42CE-89EB-84F35D6350D2}
48 | ControlAndDataFlowGraph
49 |
50 |
51 | {34B9A0CE-DF18-4CBC-8F7A-90C2B74338D5}
52 | PeReader
53 |
54 |
55 | {4A34A3C5-6176-49D7-A4C5-B2B671247F8F}
56 | MetadataHelper
57 |
58 |
59 | {33CAB640-0D03-43DF-81BD-22CDC6C0A597}
60 | MetadataModel
61 |
62 |
63 | {A6A31B03-7C3D-4DE6-AA73-BE88116BC40A}
64 | PdbReader
65 |
66 |
67 | {4B0054FD-124A-4037-9965-BDB55E6BF389}
68 | SourceModel
69 |
70 |
71 |
72 |
79 |
--------------------------------------------------------------------------------
/src/Samples/CDFGToText/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using Microsoft.Cci;
4 | using Microsoft.Cci.MetadataReader;
5 |
6 | namespace CdfgToText {
7 | class Program {
8 | static void Main(string[] args) {
9 | if (args == null || args.Length == 0) {
10 | Console.WriteLine("usage: CdfgToText [path]fileName.ext");
11 | return;
12 | }
13 | using (var host = new PeReader.DefaultHost()) {
14 | IModule/*?*/ module = host.LoadUnitFrom(args[0]) as IModule;
15 | if (module == null || module is Dummy) {
16 | Console.WriteLine(args[0]+" is not a PE file containing a CLR module or assembly.");
17 | return;
18 | }
19 |
20 | PdbReader/*?*/ pdbReader = null;
21 | string pdbFile = Path.ChangeExtension(module.Location, "pdb");
22 | if (File.Exists(pdbFile)) {
23 | using (var pdbStream = File.OpenRead(pdbFile)) {
24 | pdbReader = new PdbReader(pdbStream, host);
25 | }
26 | }
27 |
28 | FileStream profileReader = null;
29 | string proFile = Path.ChangeExtension(module.Location, "profile");
30 | if (File.Exists(proFile))
31 | profileReader = File.OpenRead(proFile);
32 |
33 | using (pdbReader) {
34 | string txtFile = Path.ChangeExtension(pdbFile, "txt");
35 | var writer = new StreamWriter(txtFile);
36 | SourceEmitter csSourceEmitter = new SourceEmitter(writer, host, pdbReader, profileReader);
37 |
38 | csSourceEmitter.Traverse(module.UnitNamespaceRoot);
39 | writer.Close();
40 | }
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/Samples/CDFGToText/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("CDFGToText")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("CDFGToText")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("6e80c218-ac88-4290-bdee-f7cc3b5e505a")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Samples/EdgeProfiler/Logger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Reflection;
4 |
5 | public class Logger {
6 |
7 | static FileStream traceFile;
8 | static byte[] buffer;
9 |
10 | static Logger(){
11 | var myAssembly = Assembly.GetExecutingAssembly();
12 | var traceFileName = myAssembly.Location;
13 | traceFile = File.Create(traceFileName.Replace(".instrumented.exe", ".profile"));
14 | buffer = new byte[4];
15 | }
16 |
17 | public static void LogEdgeCount(uint count) {
18 | buffer[0] = (byte)(count & 0xFF);
19 | count >>= 8;
20 | buffer[1] = (byte)(count & 0xFF);
21 | count >>= 8;
22 | buffer[2] = (byte)(count & 0xFF);
23 | count >>= 8;
24 | buffer[3] = (byte)(count & 0xFF);
25 |
26 | traceFile.Write(buffer, 0, 4);
27 | }
28 |
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/src/Samples/EdgeProfiler/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using Microsoft.Cci;
4 | using Microsoft.Cci.MetadataReader;
5 |
6 | namespace EdgeProfiler {
7 | class Program {
8 | static void Main(string[] args) {
9 | if (args == null || args.Length == 0) {
10 | Console.WriteLine("usage: EdgeProfiler [path]fileName.ext");
11 | return;
12 | }
13 | using (var host = new PeReader.DefaultHost()) {
14 | IModule/*?*/ module = host.LoadUnitFrom(args[0]) as IModule;
15 | if (module == null || module is Dummy) {
16 | Console.WriteLine(args[0]+" is not a PE file containing a CLR module or assembly.");
17 | return;
18 | }
19 |
20 | var coreIdentity = host.CoreAssemblySymbolicIdentity; //force host to let args[0] determine the target platform
21 | var profiler = (IAssembly)host.LoadUnitFrom(typeof(Program).Assembly.Location);
22 | var logger = (INamespaceTypeDefinition)UnitHelper.FindType(host.NameTable, profiler, "Logger");
23 |
24 | PdbReader/*?*/ pdbReader = null;
25 | string pdbFile = Path.ChangeExtension(module.Location, "pdb");
26 | if (File.Exists(pdbFile)) {
27 | using (var pdbStream = File.OpenRead(pdbFile)) {
28 | pdbReader = new PdbReader(pdbStream, host);
29 | }
30 | }
31 |
32 | using (pdbReader) {
33 | var instrumentedModule = Instrumenter.GetInstrumented(host, module, pdbReader, logger);
34 | var newRoot = Path.GetFileNameWithoutExtension(module.Location)+".instrumented";
35 | var newName = newRoot+Path.GetExtension(module.Location);
36 | using (var peStream = File.Create(newName)) {
37 | if (pdbReader == null) {
38 | PeWriter.WritePeToStream(instrumentedModule, host, peStream);
39 | } else {
40 | var localScopeProvider = new ILGenerator.LocalScopeProvider(pdbReader);
41 | using (var pdbWriter = new PdbWriter(newRoot + ".pdb", pdbReader)) {
42 | PeWriter.WritePeToStream(instrumentedModule, host, peStream, pdbReader, localScopeProvider, pdbWriter);
43 | }
44 | }
45 | }
46 | }
47 | }
48 | }
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/Samples/EdgeProfiler/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("FindHotBlocks")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("FindHotBlocks")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("1e06825a-c53b-400b-89d0-5270358840c3")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Samples/FindGeneric/FindGeneric.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.30729
7 | 2.0
8 | {2E554101-B95E-4A88-B96E-D72447D66647}
9 | Exe
10 | Properties
11 | FindGeneric
12 | FindGeneric
13 | v4.0
14 | 512
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | {4A34A3C5-6176-49D7-A4C5-B2B671247F8F}
41 | MetadataHelper
42 |
43 |
44 | {33CAB640-0D03-43DF-81BD-22CDC6C0A597}
45 | MetadataModel
46 |
47 |
48 | {34B9A0CE-DF18-4CBC-8F7A-90C2B74338D5}
49 | PeReader
50 |
51 |
52 |
53 |
60 |
--------------------------------------------------------------------------------
/src/Samples/FindGeneric/Program.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All Rights Reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 | using Microsoft.Cci;
13 |
14 | namespace FindGeneric {
15 | class Program {
16 | static void Main(string[] args) {
17 | if (args.Length < 1) {
18 | Console.WriteLine("Must specify at least one input file.");
19 | return;
20 | }
21 | using (var host = new PeReader.DefaultHost()) {
22 | foreach (string assemblyName in args) {
23 | var assembly = host.LoadUnitFrom(assemblyName) as IAssembly;
24 | if (assembly == null || assembly == Dummy.Assembly) {
25 | Console.WriteLine("The file '" + assemblyName + "' is not a PE file" +
26 | " containing a CLR assembly, or an error occurred when loading it.");
27 | continue;
28 | }
29 |
30 | Console.WriteLine("Generic Methods in generic types from '"+assembly.Name.Value+"':");
31 | foreach (INamedTypeDefinition type in assembly.GetAllTypes()) {
32 | if (!type.IsGeneric) continue;
33 | foreach (IMethodDefinition methodDefinition in type.Methods) {
34 | if (methodDefinition.IsGeneric) {
35 | Console.WriteLine(MemberHelper.GetMemberSignature(methodDefinition,
36 | NameFormattingOptions.Signature | NameFormattingOptions.TypeParameters | NameFormattingOptions.TypeConstraints | NameFormattingOptions.ParameterName));
37 | }
38 | }
39 | }
40 | }
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/Samples/FindGeneric/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("FindGeneric")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("FindGeneric")]
13 | [assembly: AssemblyCopyright("Copyright © 2009")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("abef6852-f5ba-4586-ab23-74502e03189d")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Samples/FindThrowArgumentNull/FindThrowArgumentNull.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.30729
7 | 2.0
8 | {271E4173-B938-430F-988E-910EBF22B7B5}
9 | Exe
10 | Properties
11 | FindThrowArgumentNull
12 | FindThrowArgumentNull
13 | v4.0
14 | 512
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | {4A34A3C5-6176-49D7-A4C5-B2B671247F8F}
41 | MetadataHelper
42 |
43 |
44 | {33CAB640-0D03-43DF-81BD-22CDC6C0A597}
45 | MetadataModel
46 |
47 |
48 | {34B9A0CE-DF18-4CBC-8F7A-90C2B74338D5}
49 | PeReader
50 |
51 |
52 |
53 |
60 |
--------------------------------------------------------------------------------
/src/Samples/FindThrowArgumentNull/Program.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All Rights Reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 | using Microsoft.Cci;
13 | using Microsoft.Cci.Immutable;
14 |
15 | namespace FindThrowPlatformType {
16 | class Program {
17 | static void Main(string[] args) {
18 | if (args == null || args.Length == 0) {
19 | Console.WriteLine("usage: FindThrowArgumentNull [path]fileName.ext");
20 | return;
21 | }
22 |
23 | using (var host = new PeReader.DefaultHost()) {
24 | var module = host.LoadUnitFrom(args[0]) as IModule;
25 |
26 | if (module == null) {
27 | Console.WriteLine(args[0] + " is not a PE file containing a CLR module or assembly.");
28 | return;
29 | }
30 |
31 | var platformType = new MyPlatformType(host);
32 | INamespaceTypeReference systemArgumentNullException = platformType.SystemArgumentNullException;
33 | IName ctor = host.NameTable.Ctor;
34 |
35 | //write out the signature of every method that contains the IL equivalent of "throw new System.ArgumentNullException();"
36 | foreach (var type in module.GetAllTypes()) {
37 | foreach (var methodDefinition in type.Methods) {
38 | var lastInstructionWasNewObjSystemArgumentNull = false;
39 | foreach (var operation in methodDefinition.Body.Operations) {
40 | if (operation.OperationCode == OperationCode.Newobj) {
41 | var consRef = operation.Value as IMethodReference;
42 | if (consRef != null && consRef.Name == ctor &&
43 | TypeHelper.TypesAreEquivalent(consRef.ContainingType, systemArgumentNullException)) {
44 | lastInstructionWasNewObjSystemArgumentNull = true;
45 | }
46 | } else if (lastInstructionWasNewObjSystemArgumentNull && operation.OperationCode == OperationCode.Throw) {
47 | Console.WriteLine(MemberHelper.GetMethodSignature(methodDefinition,
48 | NameFormattingOptions.ReturnType|NameFormattingOptions.TypeParameters|NameFormattingOptions.Signature));
49 | break;
50 | } else {
51 | lastInstructionWasNewObjSystemArgumentNull = false;
52 | }
53 | }
54 | }
55 | }
56 | }
57 | }
58 | }
59 |
60 | ///
61 | /// A collection of references to types from the core platform, such as System.Object and System.SystemArgumentNullException.
62 | ///
63 | internal class MyPlatformType : PlatformType {
64 |
65 | ///
66 | /// Allocates an object that is a collection of references to types from the core platform, such as System.Object and System.SystemArgumentNullException.
67 | ///
68 | ///
69 | /// An object that provides a standard abstraction over the applications that host components that provide or consume objects from the metadata model.
70 | ///
71 | internal MyPlatformType(IMetadataHost host)
72 | : base(host) {
73 | }
74 |
75 | ///
76 | /// A reference to the System.ArgumentNullException from the core system assembly.
77 | ///
78 | internal INamespaceTypeReference SystemArgumentNullException {
79 | get {
80 | if (this.systemArgumentNullException == null) {
81 | this.systemArgumentNullException = this.CreateReference(
82 | this.CoreAssemblyRef, "System", "ArgumentNullException");
83 | }
84 | return this.systemArgumentNullException;
85 | }
86 | }
87 | INamespaceTypeReference systemArgumentNullException;
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/Samples/FindThrowArgumentNull/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("FindThrowPlatformType")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("FindThrowPlatformType")]
13 | [assembly: AssemblyCopyright("Copyright © 2009")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("5abf9c7a-cb67-4d9a-b372-c6ab8d2ec045")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Samples/HelloIL/HelloIL.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.30729
7 | 2.0
8 | {DA095D70-B99F-4703-BCDF-B1E133DF685D}
9 | Exe
10 | Properties
11 | HelloIL
12 | HelloIL
13 | v4.0
14 | 512
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | {08156C78-403A-4112-AD81-8646AC51CD2F}
41 | ILGenerator
42 |
43 |
44 | {34B9A0CE-DF18-4CBC-8F7A-90C2B74338D5}
45 | PeReader
46 |
47 |
48 | {304A8B0B-851B-4AA6-A17D-5F87F39C5E5C}
49 | PeWriter
50 |
51 |
52 | {319E151C-8F33-49E7-81C9-30F02F9BA90A}
53 | MutableMetadataModel
54 |
55 |
56 | {4A34A3C5-6176-49D7-A4C5-B2B671247F8F}
57 | MetadataHelper
58 |
59 |
60 | {33CAB640-0D03-43DF-81BD-22CDC6C0A597}
61 | MetadataModel
62 |
63 |
64 | {4B0054FD-124A-4037-9965-BDB55E6BF389}
65 | SourceModel
66 |
67 |
68 |
69 |
76 |
--------------------------------------------------------------------------------
/src/Samples/HelloIL/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using Microsoft.Cci;
4 | using Microsoft.Cci.MutableCodeModel;
5 | using System.Collections.Generic;
6 |
7 | namespace HelloCodeModel {
8 | class Program {
9 | static void Main(string[] args) {
10 | var nameTable = new NameTable();
11 | using (var host = new PeReader.DefaultHost(nameTable)) {
12 | var coreAssembly = host.LoadAssembly(host.CoreAssemblySymbolicIdentity);
13 |
14 | var assembly = new Assembly() {
15 | Name = nameTable.GetNameFor("hello"),
16 | ModuleName = nameTable.GetNameFor("hello.exe"),
17 | PlatformType = host.PlatformType,
18 | Kind = ModuleKind.ConsoleApplication,
19 | RequiresStartupStub = host.PointerSize == 4,
20 | TargetRuntimeVersion = coreAssembly.TargetRuntimeVersion,
21 | };
22 | assembly.AssemblyReferences.Add(coreAssembly);
23 |
24 | var rootUnitNamespace = new RootUnitNamespace();
25 | assembly.UnitNamespaceRoot = rootUnitNamespace;
26 | rootUnitNamespace.Unit = assembly;
27 |
28 | var moduleClass = new NamespaceTypeDefinition() {
29 | ContainingUnitNamespace = rootUnitNamespace,
30 | InternFactory = host.InternFactory,
31 | IsClass = true,
32 | Name = nameTable.GetNameFor(""),
33 | };
34 | assembly.AllTypes.Add(moduleClass);
35 |
36 | var testClass = new NamespaceTypeDefinition() {
37 | ContainingUnitNamespace = rootUnitNamespace,
38 | InternFactory = host.InternFactory,
39 | IsClass = true,
40 | IsPublic = true,
41 | Methods = new List(1),
42 | Name = nameTable.GetNameFor("Test"),
43 | };
44 | rootUnitNamespace.Members.Add(testClass);
45 | assembly.AllTypes.Add(testClass);
46 | testClass.BaseClasses = new List() { host.PlatformType.SystemObject };
47 |
48 | var mainMethod = new MethodDefinition() {
49 | ContainingTypeDefinition = testClass,
50 | InternFactory = host.InternFactory,
51 | IsCil = true,
52 | IsStatic = true,
53 | Name = nameTable.GetNameFor("Main"),
54 | Type = host.PlatformType.SystemVoid,
55 | Visibility = TypeMemberVisibility.Public,
56 | };
57 | assembly.EntryPoint = mainMethod;
58 | testClass.Methods.Add(mainMethod);
59 |
60 | var ilGenerator = new ILGenerator(host, mainMethod);
61 |
62 | var systemConsole = UnitHelper.FindType(nameTable, coreAssembly, "System.Console");
63 | var writeLine = TypeHelper.GetMethod(systemConsole, nameTable.GetNameFor("WriteLine"), host.PlatformType.SystemString);
64 |
65 | ilGenerator.Emit(OperationCode.Ldstr, "hello");
66 | ilGenerator.Emit(OperationCode.Call, writeLine);
67 | ilGenerator.Emit(OperationCode.Ret);
68 |
69 | var body = new ILGeneratorMethodBody(ilGenerator, true, 1, mainMethod, Enumerable.Empty, Enumerable.Empty);
70 | mainMethod.Body = body;
71 |
72 | using (var peStream = File.Create("hello.exe")) {
73 | PeWriter.WritePeToStream(assembly, host, peStream);
74 | }
75 | }
76 | }
77 |
78 |
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/Samples/HelloIL/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("HelloCodeModel")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("HelloCodeModel")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2009")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("95f340e0-91f3-4213-8590-4df77060d6af")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Samples/ILGarbageCollect/ILGarbageCollect.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | publish\
5 |
6 |
7 |
8 |
9 |
10 | en-US
11 | false
12 |
13 |
--------------------------------------------------------------------------------
/src/Samples/ILGarbageCollect/ILGarbageCollect.csproj.vspscc:
--------------------------------------------------------------------------------
1 | ""
2 | {
3 | "FILE_VERSION" = "9237"
4 | "ENLISTMENT_CHOICE" = "NEVER"
5 | "PROJECT_FILE_RELATIVE_PATH" = ""
6 | "NUMBER_OF_EXCLUDED_FILES" = "0"
7 | "ORIGINAL_PROJECT_FILE_PATH" = ""
8 | "NUMBER_OF_NESTED_PROJECTS" = "0"
9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
10 | }
11 |
--------------------------------------------------------------------------------
/src/Samples/ILGarbageCollect/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ILGarbageCollect")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("ILGarbageCollect")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("93425260-3863-4ab8-85c6-6b83de9b9947")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Samples/ILMutator/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ILMutator")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("MSIT")]
12 | [assembly: AssemblyProduct("ILMutator")]
13 | [assembly: AssemblyCopyright("Copyright © MSIT 2009")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("e598f352-699c-42e6-957a-b44f8a0d495d")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Samples/PeToPe/PeToPe.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.30729
7 | 2.0
8 | {47D44A88-A9EE-46E9-8780-5B42A503A493}
9 | Exe
10 | Properties
11 | PeToPe
12 | PeToPe
13 | v4.0
14 | 512
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | true
27 | full
28 | false
29 | bin\Debug\
30 | DEBUG;TRACE
31 | prompt
32 | 4
33 | false
34 |
35 |
36 | pdbonly
37 | true
38 | bin\Release\
39 | TRACE
40 | prompt
41 | 4
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | {34B9A0CE-DF18-4CBC-8F7A-90C2B74338D5}
50 | PeReader
51 |
52 |
53 | {304A8B0B-851B-4AA6-A17D-5F87F39C5E5C}
54 | PeWriter
55 |
56 |
57 | {319E151C-8F33-49E7-81C9-30F02F9BA90A}
58 | MutableMetadataModel
59 |
60 |
61 | {4A34A3C5-6176-49D7-A4C5-B2B671247F8F}
62 | MetadataHelper
63 |
64 |
65 | {33CAB640-0D03-43DF-81BD-22CDC6C0A597}
66 | MetadataModel
67 |
68 |
69 | {A6A31B03-7C3D-4DE6-AA73-BE88116BC40A}
70 | PdbReader
71 |
72 |
73 | {6D83F687-ABB5-40B3-915E-CA53DA0EB7F3}
74 | PdbWriter
75 |
76 |
77 | {4B0054FD-124A-4037-9965-BDB55E6BF389}
78 | SourceModel
79 |
80 |
81 |
82 |
89 |
--------------------------------------------------------------------------------
/src/Samples/PeToPe/Program.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All Rights Reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 | using System.IO;
13 | using Microsoft.Cci;
14 | using Microsoft.Cci.MutableCodeModel;
15 |
16 | namespace PeToPe {
17 | class Program {
18 | static void Main(string[] args) {
19 | if (args == null || args.Length == 0) {
20 | Console.WriteLine("usage: PeToPe [path]fileName.ext");
21 | return;
22 | }
23 |
24 | using (var host = new PeReader.DefaultHost()) {
25 | var module = host.LoadUnitFrom(args[0]) as IModule;
26 | if (module == null || module is Dummy) {
27 | Console.WriteLine(args[0]+" is not a PE file containing a CLR module or assembly.");
28 | return;
29 | }
30 |
31 | PdbReader/*?*/ pdbReader = null;
32 | string pdbFile = module.DebugInformationLocation;
33 | if (string.IsNullOrEmpty(pdbFile))
34 | pdbFile = Path.ChangeExtension(module.Location, "pdb");
35 | if (File.Exists(pdbFile)) {
36 | Stream pdbStream = File.OpenRead(pdbFile);
37 | pdbReader = new PdbReader(pdbStream, host);
38 | }
39 |
40 | using (pdbReader) {
41 | //Make a mutable copy of the module.
42 | var copier = new MetadataDeepCopier(host);
43 | var mutableModule = copier.Copy(module);
44 |
45 | //Traverse the module. In a real application the MetadataVisitor and/or the MetadataTravers will be subclasses
46 | //and the traversal will gather information to use during rewriting.
47 | var traverser = new MetadataTraverser() { PreorderVisitor = new MetadataVisitor(), TraverseIntoMethodBodies = true };
48 | traverser.Traverse(mutableModule);
49 |
50 | //Rewrite the mutable copy. In a real application the rewriter would be a subclass of MetadataRewriter that actually does something.
51 | var rewriter = new MetadataRewriter(host);
52 | var rewrittenModule = rewriter.Rewrite(mutableModule);
53 |
54 | //Write out rewritten module.
55 | using (var peStream = File.Create(rewrittenModule.Location + ".pe")) {
56 | if (pdbReader == null) {
57 | PeWriter.WritePeToStream(rewrittenModule, host, peStream);
58 | } else {
59 | //Note that the default copier and rewriter preserves the locations collections, so the original pdbReader is still a valid ISourceLocationProvider.
60 | //However, if IL instructions were rewritten, the pdbReader will no longer be an accurate ILocalScopeProvider
61 | using (var pdbWriter = new PdbWriter(pdbFile + ".pdb", pdbReader)) {
62 | PeWriter.WritePeToStream(rewrittenModule, host, peStream, pdbReader, pdbReader, pdbWriter);
63 | }
64 | }
65 | }
66 | }
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/Samples/PeToPe/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("PeToPe")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("MSIT")]
12 | [assembly: AssemblyProduct("PeToPe")]
13 | [assembly: AssemblyCopyright("Copyright © MSIT 2008")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("fd69a30a-319d-48fe-b7c2-2b3d10a263cd")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Samples/PeToText/PeToText.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.21022
7 | 2.0
8 | {84EF1733-24F1-4BC2-AD02-8D097740EE0A}
9 | Exe
10 | Properties
11 | PeToText
12 | PeToText
13 | v4.0
14 | 512
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | true
27 | full
28 | false
29 | bin\Debug\
30 | DEBUG;TRACE
31 | prompt
32 | 4
33 | false
34 |
35 |
36 | pdbonly
37 | true
38 | bin\Release\
39 | TRACE
40 | prompt
41 | 4
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | {4A34A3C5-6176-49D7-A4C5-B2B671247F8F}
51 | MetadataHelper
52 |
53 |
54 | {33CAB640-0D03-43DF-81BD-22CDC6C0A597}
55 | MetadataModel
56 |
57 |
58 | {A6A31B03-7C3D-4DE6-AA73-BE88116BC40A}
59 | PdbReader
60 |
61 |
62 | {34B9A0CE-DF18-4CBC-8F7A-90C2B74338D5}
63 | PeReader
64 |
65 |
66 | {4B0054FD-124A-4037-9965-BDB55E6BF389}
67 | SourceModel
68 |
69 |
70 |
71 |
78 |
--------------------------------------------------------------------------------
/src/Samples/PeToText/Program.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All Rights Reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 | using System.IO;
13 | using Microsoft.Cci;
14 |
15 | namespace PeToText {
16 | class Program {
17 | static void Main(string[] args) {
18 | if (args == null || args.Length == 0) {
19 | Console.WriteLine("usage: peToText [path]fileName.ext");
20 | return;
21 | }
22 | using (var host = new PeReader.DefaultHost()) {
23 | IModule/*?*/ module = host.LoadUnitFrom(args[0]) as IModule;
24 | if (module == null || module == Dummy.Module || module == Dummy.Assembly) {
25 | Console.WriteLine(args[0] + " is not a PE file containing a CLR module or assembly.");
26 | return;
27 | }
28 |
29 | PdbReader/*?*/ pdbReader = null;
30 | string pdbFile = Path.ChangeExtension(module.Location, "pdb");
31 | if (File.Exists(pdbFile)) {
32 | Stream pdbStream = File.OpenRead(pdbFile);
33 | pdbReader = new PdbReader(pdbStream, host);
34 | }
35 | using (pdbReader) {
36 | string txtFile = Path.ChangeExtension(pdbFile, "txt");
37 | using (var writer = new StreamWriter(txtFile)) {
38 | SourceEmitter csSourceEmitter = new SourceEmitter(writer, host, pdbReader);
39 | csSourceEmitter.Traverse((INamespaceDefinition)module.UnitNamespaceRoot);
40 | writer.Close();
41 | }
42 | }
43 | }
44 | }
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/Samples/PeToText/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("PeToText")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("MSIT")]
12 | [assembly: AssemblyProduct("PeToText")]
13 | [assembly: AssemblyCopyright("Copyright © MSIT 2008")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("5831014d-e34d-49e6-9e09-61c455483807")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Samples/Z3Wrapper/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Z3Wrapper")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft IT")]
12 | [assembly: AssemblyProduct("Z3Wrapper")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft IT 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("831e17f9-9f95-4598-9bac-7076c6a76c1c")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Samples/Z3Wrapper/Readme.txt:
--------------------------------------------------------------------------------
1 | In order to build and use this sample you have obtain your own copy of the Z3 binaries. Specifically, you need the following:
2 |
3 | Microsoft.Z3.dll
4 | libz3.dll
5 |
6 | You can get these from http://z3.codeplex.com/releases.
7 |
8 | This sample expects the 64-bit binaries, but can be easily modified to work with 32-bit binaries instead.
9 |
--------------------------------------------------------------------------------
/src/Samples/Z3Wrapper/Z3Wrapper.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {3F8C2DDB-E3DB-478A-8482-743E8BFB8F7B}
9 | Library
10 | Properties
11 | Microsoft.Cci.Z3Wrapper
12 | Microsoft.Cci.Z3Wrapper
13 | v4.0
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 | x64
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 | x64
34 |
35 |
36 | true
37 |
38 |
39 | ..\..\Common\InterimKey.snk
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | Microsoft.Z3.dll
48 |
49 |
50 | Microsoft.Z3V3.dll
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | Always
59 |
60 |
61 |
62 | Always
63 |
64 |
65 |
66 |
67 | {4A34A3C5-6176-49D7-A4C5-B2B671247F8F}
68 | MetadataHelper
69 |
70 |
71 | {33CAB640-0D03-43DF-81BD-22CDC6C0A597}
72 | MetadataModel
73 |
74 |
75 | {2596EFB0-87AE-42CE-89EB-84F35D6350D2}
76 | ControlAndDataFlowGraph
77 |
78 |
79 | {E8B89C56-383A-4A1D-9EEE-E5FE9FC9DE03}
80 | AnalysisUtilities
81 |
82 |
83 |
84 |
91 |
--------------------------------------------------------------------------------
/src/Samples/Z3Wrapper/msvcp100.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/Samples/Z3Wrapper/msvcp100.dll
--------------------------------------------------------------------------------
/src/Samples/Z3Wrapper/vcomp100.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/Samples/Z3Wrapper/vcomp100.dll
--------------------------------------------------------------------------------
/src/Sources/AnalyisUtilities/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Microsoft.Cci.Analysis.AnalysisUtilities")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyCulture("")]
11 |
12 | // Setting ComVisible to false makes the types in this assembly not visible
13 | // to COM components. If you need to access a type in this assembly from
14 | // COM, set the ComVisible attribute to true on that type.
15 | [assembly: ComVisible(false)]
16 |
17 | // The following GUID is for the ID of the typelib if this project is exposed to COM
18 | [assembly: Guid("c7078b32-c394-49a1-9946-c0306c238aa8")]
19 |
--------------------------------------------------------------------------------
/src/Sources/Common/Include/Version.cs:
--------------------------------------------------------------------------------
1 | // ==++==
2 | //
3 | // Copyright (c) Microsoft Corporation. All Rights Reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | // ==--==
11 | // Warning: Automatically generated file. DO NOT EDIT
12 | // Generated at
13 |
14 | using System.Reflection;
15 | [assembly: AssemblyVersion("1.0.13.0")]
16 | [assembly: AssemblyFileVersion("1.0.13.0")]
17 | [assembly: AssemblyCompany("Microsoft Corporation")]
18 | [assembly: AssemblyTrademark("Microsoft")]
19 | [assembly: AssemblyCopyright("Copyright (c) Microsoft Corporation. All rights reserved.")]
20 | [assembly: AssemblyProduct("CCI")]
21 | #if DEBUG
22 | [assembly: AssemblyConfiguration("Debug")]
23 | #else
24 | [assembly: AssemblyConfiguration("Release")]
25 | #endif
26 |
--------------------------------------------------------------------------------
/src/Sources/Common/InterimKey.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/Sources/Common/InterimKey.snk
--------------------------------------------------------------------------------
/src/Sources/ControlAndDataFlowGraph/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Microsof.Cci.ControlAndDataFlowGraph")]
9 | [assembly: AssemblyDescription("")]
10 |
11 | // Setting ComVisible to false makes the types in this assembly not visible
12 | // to COM components. If you need to access a type in this assembly from
13 | // COM, set the ComVisible attribute to true on that type.
14 | [assembly: ComVisible(false)]
15 |
16 | // The following GUID is for the ID of the typelib if this project is exposed to COM
17 | [assembly: Guid("29c3269c-6c6e-49fc-b471-181bb71ec938")]
18 |
19 |
--------------------------------------------------------------------------------
/src/Sources/ILGenerator/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Microsof.Cci.ILGenerator")]
9 | [assembly: AssemblyDescription("")]
10 |
11 | // Setting ComVisible to false makes the types in this assembly not visible
12 | // to COM components. If you need to access a type in this assembly from
13 | // COM, set the ComVisible attribute to true on that type.
14 | [assembly: ComVisible(false)]
15 |
16 | // The following GUID is for the ID of the typelib if this project is exposed to COM
17 | [assembly: Guid("64b687bd-39ec-4270-9ecf-6bfa09db035d")]
18 |
19 |
--------------------------------------------------------------------------------
/src/Sources/MetadataHelper/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System.Diagnostics.Contracts;
12 | using System.Reflection;
13 | using System.Runtime.CompilerServices;
14 | using System.Runtime.InteropServices;
15 |
16 | // General Information about an assembly is controlled through the following
17 | // set of attributes. Change these attribute values to modify the information
18 | // associated with an assembly.
19 | [assembly: AssemblyTitle("Microsof.Cci.MetadataHelper")]
20 | [assembly: AssemblyDescription("A collection of convenience methods that are implemented solely in terms of the metadata object model.")]
21 |
22 | // Setting ComVisible to false makes the types in this assembly not visible
23 | // to COM components. If you need to access a type in this assembly from
24 | // COM, set the ComVisible attribute to true on that type.
25 | [assembly: ComVisible(false)]
26 |
27 | // The following GUID is for the ID of the typelib if this project is exposed to COM
28 | [assembly: Guid("e18a577e-4477-4fbd-ae4f-5f1116791fcf")]
29 |
30 | [assembly: ContractVerification(false)]
31 |
--------------------------------------------------------------------------------
/src/Sources/MetadataModel/MetadataModelCF.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Debug
4 | AnyCPU
5 | 9.0.30729
6 | 2.0
7 | {F0453DA7-61CF-4BF4-B90C-C3AF2EA82A46}
8 | Library
9 | Properties
10 | MetadataModelCF
11 | MetadataModelCF
12 | {4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
13 | PocketPC
14 | b2c48bd2-963d-4549-9169-1fa021dce484
15 | 5.2
16 | MetadataModelCF
17 | v3.5
18 | Windows Mobile 6 Professional SDK
19 |
20 |
21 |
22 |
23 | true
24 | full
25 | false
26 | bin\Debug\
27 | TRACE;DEBUG;COMPACTFX
28 | true
29 | true
30 | prompt
31 | 512
32 | 4
33 | Off
34 | true
35 |
36 |
37 | pdbonly
38 | true
39 | bin\Release\
40 | TRACE;COMPACTFX
41 | true
42 | true
43 | prompt
44 | 512
45 | 4
46 | Off
47 |
48 |
49 |
50 |
51 | {B114E5FF-F2A2-4BE7-8AF1-936FC87030F0}
52 | Microsoft.Contracts
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
81 |
--------------------------------------------------------------------------------
/src/Sources/MetadataModel/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All Rights Reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 | using System.Reflection;
13 | using System.Runtime.CompilerServices;
14 | using System.Runtime.InteropServices;
15 |
16 | // General Information about an assembly is controlled through the following
17 | // set of attributes. Change these attribute values to modify the information
18 | // associated with an assembly.
19 | [assembly: AssemblyTitle("Microsoft.Cci.MetadataModel")]
20 | [assembly: AssemblyDescription("An object model for CLR metadata and IL")]
21 |
22 | // Setting ComVisible to false makes the types in this assembly not visible
23 | // to COM components. If you need to access a type in this assembly from
24 | // COM, set the ComVisible attribute to true on that type.
25 | [assembly: ComVisible(false)]
26 |
27 | // The following GUID is for the ID of the typelib if this project is exposed to COM
28 | [assembly: Guid("62878a7b-9cd8-48f0-af78-02b7583ab03d")]
29 |
--------------------------------------------------------------------------------
/src/Sources/Microsoft.Contracts/Contracts.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/Sources/Microsoft.Contracts/Contracts.cs
--------------------------------------------------------------------------------
/src/Sources/Microsoft.Contracts/ContractsEx.cs:
--------------------------------------------------------------------------------
1 | #define CONTRACTS_FULL // this file should always have everything defined
2 |
3 | namespace System.Diagnostics.Contracts
4 | {
5 | ///
6 | /// Additional contracts not yet part of the mainstream contract library.
7 | ///
8 | public static class ContractEx
9 | {
10 | #region Unreachable
11 |
12 | ///
13 | /// Fails.
14 | ///
15 | [Pure]
16 | [System.Diagnostics.DebuggerNonUserCode]
17 | public static Exception UnreachableAlways(Exception exception, string message)
18 | {
19 | Internal.ContractHelper.TriggerFailure(ContractFailureKind.Assert, message, null, null, null);
20 | if (exception == null)
21 | exception = new InvalidOperationException(message);
22 | throw exception;
23 | }
24 |
25 | ///
26 | /// Fails.
27 | ///
28 | [Pure]
29 | [System.Diagnostics.DebuggerNonUserCode]
30 | public static Exception UnreachableAlways(Exception exception)
31 | {
32 | throw UnreachableAlways(exception, null);
33 | }
34 |
35 | ///
36 | /// Fails.
37 | ///
38 | [Pure]
39 | [System.Diagnostics.DebuggerNonUserCode]
40 | public static Exception UnreachableAlways(Exception ex, String format, params object[] args)
41 | {
42 | throw UnreachableAlways(ex, string.Format(format, args));
43 | }
44 |
45 | ///
46 | /// Fails.
47 | ///
48 | [Pure]
49 | [System.Diagnostics.DebuggerNonUserCode]
50 | public static Exception UnreachableAlways(string message)
51 | {
52 | throw UnreachableAlways(null, message);
53 | }
54 |
55 | ///
56 | /// Fails.
57 | ///
58 | [Pure]
59 | [System.Diagnostics.DebuggerNonUserCode]
60 | public static Exception UnreachableAlways()
61 | {
62 | throw UnreachableAlways((Exception)null);
63 | }
64 |
65 | ///
66 | /// Fails.
67 | ///
68 | [Pure]
69 | [System.Diagnostics.DebuggerNonUserCode]
70 | public static Exception UnreachableAlways(String format, params object[] args)
71 | {
72 | throw UnreachableAlways(null, format, args);
73 | }
74 |
75 | #endregion Unreachable
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/Sources/Microsoft.Contracts/InterimKey.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/Sources/Microsoft.Contracts/InterimKey.snk
--------------------------------------------------------------------------------
/src/Sources/Microsoft.Contracts/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Microsoft.Contracts")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("MSIT")]
12 | [assembly: AssemblyProduct("Microsoft.Contracts")]
13 | [assembly: AssemblyCopyright("Copyright © MSIT 2009")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("108a8fc6-51fa-4fa3-a833-3b0358848aa9")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Sources/MutableMetadataModel/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All Rights Reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System.Reflection;
12 | using System.Runtime.CompilerServices;
13 | using System.Runtime.InteropServices;
14 |
15 | // General Information about an assembly is controlled through the following
16 | // set of attributes. Change these attribute values to modify the information
17 | // associated with an assembly.
18 | [assembly: AssemblyTitle("Microsoft.Cci.MutableMetadataModel")]
19 | [assembly: AssemblyDescription("")]
20 |
21 | // Setting ComVisible to false makes the types in this assembly not visible
22 | // to COM components. If you need to access a type in this assembly from
23 | // COM, set the ComVisible attribute to true on that type.
24 | [assembly: ComVisible(false)]
25 |
26 | // The following GUID is for the ID of the typelib if this project is exposed to COM
27 | [assembly: Guid("b7dccfcd-96b3-499e-ba5f-1f1ba7b09978")]
28 |
--------------------------------------------------------------------------------
/src/Sources/OptimizationUtilities/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Optimization")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyCulture("")]
11 |
12 | // Setting ComVisible to false makes the types in this assembly not visible
13 | // to COM components. If you need to access a type in this assembly from
14 | // COM, set the ComVisible attribute to true on that type.
15 | [assembly: ComVisible(false)]
16 |
17 | // The following GUID is for the ID of the typelib if this project is exposed to COM
18 | [assembly: Guid("9a1c684f-4070-4fa3-af2d-c33b1c7f6fd7")]
19 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/BitSet.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 |
13 | namespace Microsoft.Cci.Pdb {
14 | internal struct BitSet {
15 | internal BitSet(BitAccess bits) {
16 | bits.ReadInt32(out size); // 0..3 : Number of words
17 | words = new uint[size];
18 | bits.ReadUInt32(words);
19 | }
20 |
21 | //internal BitSet(int size) {
22 | // this.size = size;
23 | // words = new uint[size];
24 | //}
25 |
26 | internal bool IsSet(int index) {
27 | int word = index / 32;
28 | if (word >= this.size) return false;
29 | return ((words[word] & GetBit(index)) != 0);
30 | }
31 |
32 | //internal void Set(int index) {
33 | // int word = index / 32;
34 | // if (word >= this.size) return;
35 | // words[word] |= GetBit(index);
36 | //}
37 |
38 | //internal void Clear(int index) {
39 | // int word = index / 32;
40 | // if (word >= this.size) return;
41 | // words[word] &= ~GetBit(index);
42 | //}
43 |
44 | private static uint GetBit(int index) {
45 | return ((uint)1 << (index % 32));
46 | }
47 |
48 | //private static uint ReverseBits(uint value) {
49 | // uint o = 0;
50 | // for (int i = 0; i < 32; i++) {
51 | // o = (o << 1) | (value & 1);
52 | // value >>= 1;
53 | // }
54 | // return o;
55 | //}
56 |
57 | internal bool IsEmpty {
58 | get { return size == 0; }
59 | }
60 |
61 | //internal bool GetWord(int index, out uint word) {
62 | // if (index < size) {
63 | // word = ReverseBits(words[index]);
64 | // return true;
65 | // }
66 | // word = 0;
67 | // return false;
68 | //}
69 |
70 | private int size;
71 | private uint[] words;
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/DataStream.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 | using System.IO;
13 |
14 | namespace Microsoft.Cci.Pdb {
15 | internal class DataStream {
16 | internal DataStream() {
17 | }
18 |
19 | internal DataStream(int contentSize, BitAccess bits, int count) {
20 | this.contentSize = contentSize;
21 | if (count > 0) {
22 | this.pages = new int[count];
23 | bits.ReadInt32(this.pages);
24 | }
25 | }
26 |
27 | internal void Read(PdbReader reader, BitAccess bits) {
28 | bits.MinCapacity(contentSize);
29 | Read(reader, 0, bits.Buffer, 0, contentSize);
30 | }
31 |
32 | internal void Read(PdbReader reader, int position,
33 | byte[] bytes, int offset, int data) {
34 | if (position + data > contentSize) {
35 | throw new PdbException("DataStream can't read off end of stream. " +
36 | "(pos={0},siz={1})",
37 | position, data);
38 | }
39 | if (position == contentSize) {
40 | return;
41 | }
42 |
43 | int left = data;
44 | int page = position / reader.pageSize;
45 | int rema = position % reader.pageSize;
46 |
47 | // First get remained of first page.
48 | if (rema != 0) {
49 | int todo = reader.pageSize - rema;
50 | if (todo > left) {
51 | todo = left;
52 | }
53 |
54 | reader.Seek(pages[page], rema);
55 | reader.Read(bytes, offset, todo);
56 |
57 | offset += todo;
58 | left -= todo;
59 | page++;
60 | }
61 |
62 | // Now get the remaining pages.
63 | while (left > 0) {
64 | int todo = reader.pageSize;
65 | if (todo > left) {
66 | todo = left;
67 | }
68 |
69 | reader.Seek(pages[page], 0);
70 | reader.Read(bytes, offset, todo);
71 |
72 | offset += todo;
73 | left -= todo;
74 | page++;
75 | }
76 | }
77 |
78 | //private void AddPages(int page0, int count) {
79 | // if (pages == null) {
80 | // pages = new int[count];
81 | // for (int i = 0; i < count; i++) {
82 | // pages[i] = page0 + i;
83 | // }
84 | // } else {
85 | // int[] old = pages;
86 | // int used = old.Length;
87 |
88 | // pages = new int[used + count];
89 | // Array.Copy(old, pages, used);
90 | // for (int i = 0; i < count; i++) {
91 | // pages[used + i] = page0 + i;
92 | // }
93 | // }
94 | //}
95 |
96 | //internal int Pages {
97 | // get { return pages == null ? 0 : pages.Length; }
98 | //}
99 |
100 | internal int Length {
101 | get { return contentSize; }
102 | }
103 |
104 | //internal int GetPage(int index) {
105 | // return pages[index];
106 | //}
107 |
108 | internal int contentSize;
109 | internal int[] pages;
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/DbiDbgHdr.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 |
13 | namespace Microsoft.Cci.Pdb {
14 | internal struct DbiDbgHdr {
15 | internal DbiDbgHdr(BitAccess bits) {
16 | bits.ReadUInt16(out snFPO);
17 | bits.ReadUInt16(out snException);
18 | bits.ReadUInt16(out snFixup);
19 | bits.ReadUInt16(out snOmapToSrc);
20 | bits.ReadUInt16(out snOmapFromSrc);
21 | bits.ReadUInt16(out snSectionHdr);
22 | bits.ReadUInt16(out snTokenRidMap);
23 | bits.ReadUInt16(out snXdata);
24 | bits.ReadUInt16(out snPdata);
25 | bits.ReadUInt16(out snNewFPO);
26 | bits.ReadUInt16(out snSectionHdrOrig);
27 | }
28 |
29 | internal ushort snFPO; // 0..1
30 | internal ushort snException; // 2..3 (deprecated)
31 | internal ushort snFixup; // 4..5
32 | internal ushort snOmapToSrc; // 6..7
33 | internal ushort snOmapFromSrc; // 8..9
34 | internal ushort snSectionHdr; // 10..11
35 | internal ushort snTokenRidMap; // 12..13
36 | internal ushort snXdata; // 14..15
37 | internal ushort snPdata; // 16..17
38 | internal ushort snNewFPO; // 18..19
39 | internal ushort snSectionHdrOrig; // 20..21
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/DbiHeader.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 |
13 | namespace Microsoft.Cci.Pdb {
14 | internal struct DbiHeader {
15 | internal DbiHeader(BitAccess bits) {
16 | bits.ReadInt32(out sig);
17 | bits.ReadInt32(out ver);
18 | bits.ReadInt32(out age);
19 | bits.ReadInt16(out gssymStream);
20 | bits.ReadUInt16(out vers);
21 | bits.ReadInt16(out pssymStream);
22 | bits.ReadUInt16(out pdbver);
23 | bits.ReadInt16(out symrecStream);
24 | bits.ReadUInt16(out pdbver2);
25 | bits.ReadInt32(out gpmodiSize);
26 | bits.ReadInt32(out secconSize);
27 | bits.ReadInt32(out secmapSize);
28 | bits.ReadInt32(out filinfSize);
29 | bits.ReadInt32(out tsmapSize);
30 | bits.ReadInt32(out mfcIndex);
31 | bits.ReadInt32(out dbghdrSize);
32 | bits.ReadInt32(out ecinfoSize);
33 | bits.ReadUInt16(out flags);
34 | bits.ReadUInt16(out machine);
35 | bits.ReadInt32(out reserved);
36 | }
37 |
38 | internal int sig; // 0..3
39 | internal int ver; // 4..7
40 | internal int age; // 8..11
41 | internal short gssymStream; // 12..13
42 | internal ushort vers; // 14..15
43 | internal short pssymStream; // 16..17
44 | internal ushort pdbver; // 18..19
45 | internal short symrecStream; // 20..21
46 | internal ushort pdbver2; // 22..23
47 | internal int gpmodiSize; // 24..27
48 | internal int secconSize; // 28..31
49 | internal int secmapSize; // 32..35
50 | internal int filinfSize; // 36..39
51 | internal int tsmapSize; // 40..43
52 | internal int mfcIndex; // 44..47
53 | internal int dbghdrSize; // 48..51
54 | internal int ecinfoSize; // 52..55
55 | internal ushort flags; // 56..57
56 | internal ushort machine; // 58..59
57 | internal int reserved; // 60..63
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/DbiModuleInfo.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 |
13 | namespace Microsoft.Cci.Pdb {
14 | internal class DbiModuleInfo {
15 | internal DbiModuleInfo(BitAccess bits, bool readStrings) {
16 | bits.ReadInt32(out opened);
17 | new DbiSecCon(bits);
18 | bits.ReadUInt16(out flags);
19 | bits.ReadInt16(out stream);
20 | bits.ReadInt32(out cbSyms);
21 | bits.ReadInt32(out cbOldLines);
22 | bits.ReadInt32(out cbLines);
23 | bits.ReadInt16(out files);
24 | bits.ReadInt16(out pad1);
25 | bits.ReadUInt32(out offsets);
26 | bits.ReadInt32(out niSource);
27 | bits.ReadInt32(out niCompiler);
28 | if (readStrings) {
29 | bits.ReadCString(out moduleName);
30 | bits.ReadCString(out objectName);
31 | } else {
32 | bits.SkipCString(out moduleName);
33 | bits.SkipCString(out objectName);
34 | }
35 | bits.Align(4);
36 | //if (opened != 0 || pad1 != 0) {
37 | // throw new PdbException("Invalid DBI module. "+
38 | // "(opened={0}, pad={1})", opened, pad1);
39 | //}
40 | }
41 |
42 | internal int opened; // 0..3
43 | //internal DbiSecCon section; // 4..31
44 | internal ushort flags; // 32..33
45 | internal short stream; // 34..35
46 | internal int cbSyms; // 36..39
47 | internal int cbOldLines; // 40..43
48 | internal int cbLines; // 44..57
49 | internal short files; // 48..49
50 | internal short pad1; // 50..51
51 | internal uint offsets;
52 | internal int niSource;
53 | internal int niCompiler;
54 | internal string moduleName;
55 | internal string objectName;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/DbiSecCon.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 |
13 | namespace Microsoft.Cci.Pdb {
14 | internal struct DbiSecCon {
15 | internal DbiSecCon(BitAccess bits) {
16 | bits.ReadInt16(out section);
17 | bits.ReadInt16(out pad1);
18 | bits.ReadInt32(out offset);
19 | bits.ReadInt32(out size);
20 | bits.ReadUInt32(out flags);
21 | bits.ReadInt16(out module);
22 | bits.ReadInt16(out pad2);
23 | bits.ReadUInt32(out dataCrc);
24 | bits.ReadUInt32(out relocCrc);
25 | //if (pad1 != 0 || pad2 != 0) {
26 | // throw new PdbException("Invalid DBI section. "+
27 | // "(pad1={0}, pad2={1})",
28 | // pad1, pad2);
29 | //}
30 | }
31 |
32 | internal short section; // 0..1
33 | internal short pad1; // 2..3
34 | internal int offset; // 4..7
35 | internal int size; // 8..11
36 | internal uint flags; // 12..15
37 | internal short module; // 16..17
38 | internal short pad2; // 18..19
39 | internal uint dataCrc; // 20..23
40 | internal uint relocCrc; // 24..27
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/IntHashTable.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RUB-SysSec/Probfuscator/a21ec50ab38d7c7a3e614d6fc695d75c104214fd/src/Sources/PdbReader/IntHashTable.cs
--------------------------------------------------------------------------------
/src/Sources/PdbReader/MsfDirectory.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 |
13 | namespace Microsoft.Cci.Pdb {
14 | internal class MsfDirectory {
15 | internal MsfDirectory(PdbReader reader, PdbFileHeader head, BitAccess bits) {
16 | int pages = reader.PagesFromSize(head.directorySize);
17 |
18 | // 0..n in page of directory pages.
19 | bits.MinCapacity(head.directorySize);
20 | int directoryRootPages = head.directoryRoot.Length;
21 | int pagesPerPage = head.pageSize / 4;
22 | int pagesToGo = pages;
23 | for (int i = 0; i < directoryRootPages; i++) {
24 | int pagesInThisPage = pagesToGo <= pagesPerPage ? pagesToGo : pagesPerPage;
25 | reader.Seek(head.directoryRoot[i], 0);
26 | bits.Append(reader.reader, pagesInThisPage * 4);
27 | pagesToGo -= pagesInThisPage;
28 | }
29 | bits.Position = 0;
30 |
31 | DataStream stream = new DataStream(head.directorySize, bits, pages);
32 | bits.MinCapacity(head.directorySize);
33 | stream.Read(reader, bits);
34 |
35 | // 0..3 in directory pages
36 | int count;
37 | bits.ReadInt32(out count);
38 |
39 | // 4..n
40 | int[] sizes = new int[count];
41 | bits.ReadInt32(sizes);
42 |
43 | // n..m
44 | streams = new DataStream[count];
45 | for (int i = 0; i < count; i++) {
46 | if (sizes[i] <= 0) {
47 | streams[i] = new DataStream();
48 | } else {
49 | streams[i] = new DataStream(sizes[i], bits,
50 | reader.PagesFromSize(sizes[i]));
51 | }
52 | }
53 | }
54 |
55 | internal DataStream[] streams;
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/PdbConstant.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 | using System.Runtime.InteropServices;
13 |
14 | namespace Microsoft.Cci.Pdb {
15 | internal class PdbConstant {
16 | internal string name;
17 | internal uint token;
18 | internal object value;
19 |
20 | internal PdbConstant(BitAccess bits) {
21 | bits.ReadUInt32(out this.token);
22 | byte tag1;
23 | bits.ReadUInt8(out tag1);
24 | byte tag2;
25 | bits.ReadUInt8(out tag2);
26 | if (tag2 == 0) {
27 | this.value = tag1;
28 | } else if (tag2 == 0x80) {
29 | switch (tag1) {
30 | case 0x00: //sbyte
31 | sbyte sb;
32 | bits.ReadInt8(out sb);
33 | this.value = sb;
34 | break;
35 | case 0x01: //short
36 | short s;
37 | bits.ReadInt16(out s);
38 | this.value = s;
39 | break;
40 | case 0x02: //ushort
41 | ushort us;
42 | bits.ReadUInt16(out us);
43 | this.value = us;
44 | break;
45 | case 0x03: //int
46 | int i;
47 | bits.ReadInt32(out i);
48 | this.value = i;
49 | break;
50 | case 0x04: //uint
51 | uint ui;
52 | bits.ReadUInt32(out ui);
53 | this.value = ui;
54 | break;
55 | case 0x05: //float
56 | this.value = bits.ReadFloat();
57 | break;
58 | case 0x06: //double
59 | this.value = bits.ReadDouble();
60 | break;
61 | case 0x09: //long
62 | long sl;
63 | bits.ReadInt64(out sl);
64 | this.value = sl;
65 | break;
66 | case 0x0a: //ulong
67 | ulong ul;
68 | bits.ReadUInt64(out ul);
69 | this.value = ul;
70 | break;
71 | case 0x10: //string
72 | string str;
73 | bits.ReadBString(out str);
74 | this.value = str;
75 | break;
76 | case 0x19: //decimal
77 | this.value = bits.ReadDecimal();
78 | break;
79 | default:
80 | //TODO: error
81 | break;
82 | }
83 | } else {
84 | //TODO: error
85 | }
86 | bits.ReadCString(out name);
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/PdbDebugException.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 | using System.IO;
13 |
14 | namespace Microsoft.Cci.Pdb {
15 | internal class PdbDebugException : IOException {
16 | internal PdbDebugException(String format, params object[] args)
17 | : base(String.Format(format, args)) {
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/PdbException.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 | using System.IO;
13 |
14 | namespace Microsoft.Cci.Pdb {
15 | internal class PdbException : IOException {
16 | internal PdbException(String format, params object[] args)
17 | : base(String.Format(format, args)) {
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/PdbFileHeader.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 | using System.IO;
13 | using System.Text;
14 |
15 | namespace Microsoft.Cci.Pdb {
16 | internal class PdbFileHeader {
17 | //internal PdbFileHeader(int pageSize) {
18 | // this.magic = new byte[32] {
19 | // 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, // "Microsof"
20 | // 0x74, 0x20, 0x43, 0x2F, 0x43, 0x2B, 0x2B, 0x20, // "t C/C++ "
21 | // 0x4D, 0x53, 0x46, 0x20, 0x37, 0x2E, 0x30, 0x30, // "MSF 7.00"
22 | // 0x0D, 0x0A, 0x1A, 0x44, 0x53, 0x00, 0x00, 0x00 // "^^^DS^^^"
23 | // };
24 | // this.pageSize = pageSize;
25 | //}
26 |
27 | internal PdbFileHeader(Stream reader, BitAccess bits) {
28 | bits.MinCapacity(56);
29 | reader.Seek(0, SeekOrigin.Begin);
30 | bits.FillBuffer(reader, 52);
31 |
32 | this.magic = new byte[32];
33 | bits.ReadBytes(this.magic); // 0..31
34 | bits.ReadInt32(out this.pageSize); // 32..35
35 | bits.ReadInt32(out this.freePageMap); // 36..39
36 | bits.ReadInt32(out this.pagesUsed); // 40..43
37 | bits.ReadInt32(out this.directorySize); // 44..47
38 | bits.ReadInt32(out this.zero); // 48..51
39 |
40 | int directoryPages = ((((directorySize + pageSize - 1) / pageSize) * 4) + pageSize - 1) / pageSize;
41 | this.directoryRoot = new int[directoryPages];
42 | bits.FillBuffer(reader, directoryPages * 4);
43 | bits.ReadInt32(this.directoryRoot);
44 | }
45 |
46 | //internal string Magic {
47 | // get { return StringFromBytesUTF8(magic); }
48 | //}
49 |
50 | //internal void Write(Stream writer, BitAccess bits) {
51 | // bits.MinCapacity(pageSize);
52 | // bits.WriteBytes(magic); // 0..31
53 | // bits.WriteInt32(pageSize); // 32..35
54 | // bits.WriteInt32(freePageMap); // 36..39
55 | // bits.WriteInt32(pagesUsed); // 40..43
56 | // bits.WriteInt32(directorySize); // 44..47
57 | // bits.WriteInt32(zero); // 48..51
58 | // bits.WriteInt32(directoryRoot); // 52..55
59 |
60 | // writer.Seek(0, SeekOrigin.Begin);
61 | // bits.WriteBuffer(writer, pageSize);
62 | //}
63 |
64 | //////////////////////////////////////////////////// Helper Functions.
65 | //
66 | //internal static string StringFromBytesUTF8(byte[] bytes) {
67 | // return StringFromBytesUTF8(bytes, 0, bytes.Length);
68 | //}
69 |
70 | //internal static string StringFromBytesUTF8(byte[] bytes, int offset, int length) {
71 | // for (int i = 0; i < length; i++) {
72 | // if (bytes[offset + i] < ' ') {
73 | // length = i;
74 | // }
75 | // }
76 | // return Encoding.UTF8.GetString(bytes, offset, length);
77 | //}
78 |
79 | ////////////////////////////////////////////////////////////// Fields.
80 | //
81 | internal readonly byte[] magic;
82 | internal readonly int pageSize;
83 | internal int freePageMap;
84 | internal int pagesUsed;
85 | internal int directorySize;
86 | internal readonly int zero;
87 | internal int[] directoryRoot;
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/PdbLine.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 |
13 | namespace Microsoft.Cci.Pdb {
14 | internal struct PdbLine {
15 | internal uint offset;
16 | internal uint lineBegin;
17 | internal uint lineEnd;
18 | internal ushort colBegin;
19 | internal ushort colEnd;
20 |
21 | internal PdbLine(uint offset, uint lineBegin, ushort colBegin, uint lineEnd, ushort colEnd) {
22 | this.offset = offset;
23 | this.lineBegin = lineBegin;
24 | this.colBegin = colBegin;
25 | this.lineEnd = lineEnd;
26 | this.colEnd = colEnd;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/PdbLines.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 |
13 | namespace Microsoft.Cci.Pdb {
14 | internal class PdbLines {
15 | internal PdbSource file;
16 | internal PdbLine[] lines;
17 |
18 | internal PdbLines(PdbSource file, uint count) {
19 | this.file = file;
20 | this.lines = new PdbLine[count];
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/PdbReader.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 | using System.IO;
13 |
14 | namespace Microsoft.Cci.Pdb {
15 | internal class PdbReader {
16 | internal PdbReader(Stream reader, int pageSize) {
17 | this.pageSize = pageSize;
18 | this.reader = reader;
19 | }
20 |
21 | internal void Seek(int page, int offset) {
22 | reader.Seek(page * pageSize + offset, SeekOrigin.Begin);
23 | }
24 |
25 | internal void Read(byte[] bytes, int offset, int count) {
26 | reader.Read(bytes, offset, count);
27 | }
28 |
29 | internal int PagesFromSize(int size) {
30 | return (size + pageSize - 1) / (pageSize);
31 | }
32 |
33 | //internal int PageSize {
34 | // get { return pageSize; }
35 | //}
36 |
37 | internal readonly int pageSize;
38 | internal readonly Stream reader;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/PdbSlot.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 |
13 | namespace Microsoft.Cci.Pdb {
14 | internal class PdbSlot {
15 | internal uint slot;
16 | internal uint typeToken;
17 | internal string name;
18 | internal ushort flags;
19 | //internal uint segment;
20 | //internal uint address;
21 |
22 | internal PdbSlot(BitAccess bits) {
23 | AttrSlotSym slot;
24 |
25 | bits.ReadUInt32(out slot.index);
26 | bits.ReadUInt32(out slot.typind);
27 | bits.ReadUInt32(out slot.offCod);
28 | bits.ReadUInt16(out slot.segCod);
29 | bits.ReadUInt16(out slot.flags);
30 | bits.ReadCString(out slot.name);
31 |
32 | this.slot = slot.index;
33 | this.typeToken = slot.typind;
34 | this.name = slot.name;
35 | this.flags = slot.flags;
36 | //this.segment = slot.segCod;
37 | //this.address = slot.offCod;
38 |
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/PdbSource.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 |
13 | namespace Microsoft.Cci.Pdb {
14 | internal class PdbSource {
15 | //internal uint index;
16 | internal string name;
17 | internal Guid doctype;
18 | internal Guid language;
19 | internal Guid vendor;
20 |
21 | internal PdbSource(/*uint index, */string name, Guid doctype, Guid language, Guid vendor) {
22 | //this.index = index;
23 | this.name = name;
24 | this.doctype = doctype;
25 | this.language = language;
26 | this.vendor = vendor;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/PdbTokenLine.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 |
13 | namespace Microsoft.Cci.Pdb {
14 | internal class PdbTokenLine {
15 | internal uint token;
16 | internal uint file_id;
17 | internal uint line;
18 | internal uint column;
19 | internal uint endLine;
20 | internal uint endColumn;
21 | internal PdbSource sourceFile;
22 | internal PdbTokenLine/*?*/ nextLine;
23 |
24 | internal PdbTokenLine(uint token, uint file_id, uint line, uint column, uint endLine, uint endColumn) {
25 | this.token = token;
26 | this.file_id = file_id;
27 | this.line = line;
28 | this.column = column;
29 | this.endLine = endLine;
30 | this.endColumn = endColumn;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Sources/PdbReader/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Microsof.Cci.PdbReaderAndWriter")]
9 | [assembly: AssemblyDescription("")]
10 |
11 | // Setting ComVisible to false makes the types in this assembly not visible
12 | // to COM components. If you need to access a type in this assembly from
13 | // COM, set the ComVisible attribute to true on that type.
14 | [assembly: ComVisible(false)]
15 |
16 | // The following GUID is for the ID of the typelib if this project is exposed to COM
17 | [assembly: Guid("b798fe0d-39bf-4bf3-b8b1-cb09cf4f07a0")]
18 |
19 |
--------------------------------------------------------------------------------
/src/Sources/PdbWriter/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 | // This file is used by Code Analysis to maintain SuppressMessage
2 | // attributes that are applied to this project.
3 | // Project-level suppressions either have no target or are given
4 | // a specific target and scoped to a namespace, type, member, etc.
5 | //
6 | // To add a suppression to this file, right-click the message in the
7 | // Error List, point to "Suppress Message(s)", and click
8 | // "In Project Suppression File".
9 | // You do not need to add suppressions to this file manually.
10 |
11 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope="member", Target="Microsoft.Cci.ImageDebugDirectory.#.ctor(System.Object)")]
12 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="dummy", Scope="member", Target="Microsoft.Cci.ImageDebugDirectory.#.ctor(System.Object)")]
13 |
--------------------------------------------------------------------------------
/src/Sources/PdbWriter/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Microsof.Cci.PdbWriter")]
9 | [assembly: AssemblyDescription("")]
10 |
11 | // Setting ComVisible to false makes the types in this assembly not visible
12 | // to COM components. If you need to access a type in this assembly from
13 | // COM, set the ComVisible attribute to true on that type.
14 | [assembly: ComVisible(false)]
15 |
16 | // The following GUID is for the ID of the typelib if this project is exposed to COM
17 | [assembly: Guid("15dcf2b3-89c3-4465-8d53-633b40f7ed62")]
18 |
19 |
--------------------------------------------------------------------------------
/src/Sources/PeReader/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All Rights Reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System.Reflection;
12 | using System.Runtime.CompilerServices;
13 | using System.Runtime.InteropServices;
14 |
15 | // General Information about an assembly is controlled through the following
16 | // set of attributes. Change these attribute values to modify the information
17 | // associated with an assembly.
18 | [assembly: AssemblyTitle("Microsoft.Cci.PEReader")]
19 | [assembly: AssemblyDescription("")]
20 |
21 | // Setting ComVisible to false makes the types in this assembly not visible
22 | // to COM components. If you need to access a type in this assembly from
23 | // COM, set the ComVisible attribute to true on that type.
24 | [assembly: ComVisible(false)]
25 |
26 | // The following GUID is for the ID of the typelib if this project is exposed to COM
27 | [assembly: Guid("dc891919-b1b9-441c-b5b7-ce68dfba0b55")]
28 |
--------------------------------------------------------------------------------
/src/Sources/PeWriter/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 | // This file is used by Code Analysis to maintain SuppressMessage
2 | // attributes that are applied to this project.
3 | // Project-level suppressions either have no target or are given
4 | // a specific target and scoped to a namespace, type, member, etc.
5 | //
6 | // To add a suppression to this file, right-click the message in the
7 | // Error List, point to "Suppress Message(s)", and click
8 | // "In Project Suppression File".
9 | // You do not need to add suppressions to this file manually.
10 |
11 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope="member", Target="Microsoft.Cci.COR_FIELD_OFFSET.#.ctor(System.Object)")]
12 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="dummy", Scope="member", Target="Microsoft.Cci.COR_FIELD_OFFSET.#.ctor(System.Object)")]
13 |
--------------------------------------------------------------------------------
/src/Sources/PeWriter/MemoryStream.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 |
12 | namespace Microsoft.Cci.WriterUtilities {
13 | public sealed class MemoryStream {
14 |
15 | public MemoryStream() {
16 | this.Buffer = new byte[64];
17 | }
18 |
19 | public MemoryStream(uint initialSize)
20 | //^ requires initialSize > 0;
21 | {
22 | this.Buffer = new byte[initialSize];
23 | }
24 |
25 | public byte[] Buffer;
26 | //^ invariant Buffer.LongLength > 0;
27 |
28 | private void Grow(byte[] myBuffer, uint n, uint m)
29 | //^ requires n > 0;
30 | {
31 | ulong n2 = n*2;
32 | if (n2 == 0) n2 = 16;
33 | while (m >= n2) n2 = n2*2;
34 | byte[] newBuffer = this.Buffer = new byte[n2];
35 | for (int i = 0; i < n; i++)
36 | newBuffer[i] = myBuffer[i];
37 | }
38 |
39 | public uint Length;
40 |
41 | public uint Position {
42 | get {
43 | return this.position;
44 | }
45 | set {
46 | byte[] myBuffer = this.Buffer;
47 | #if COMPACTFX
48 | uint n = (uint)myBuffer.Length;
49 | #else
50 | uint n = (uint)myBuffer.LongLength;
51 | #endif
52 | if (value >= n) this.Grow(myBuffer, n, value);
53 | if (value > this.Length) this.Length = value;
54 | this.position = value;
55 | }
56 | }
57 | private uint position;
58 |
59 | public byte[] ToArray() {
60 | uint n = this.Length;
61 | byte[] source = this.Buffer;
62 | if (source.Length == n) return this.Buffer;
63 | byte[] result = new byte[n];
64 | for (int i = 0; i < n; i++)
65 | result[i] = source[i];
66 | return result;
67 | }
68 |
69 | public void Write(byte[] buffer, uint index, uint count) {
70 | uint p = this.position;
71 | this.Position = p + count;
72 | byte[] myBuffer = this.Buffer;
73 | for (uint i = 0, j = p, k = index; i < count; i++)
74 | myBuffer[j++] = buffer[k++];
75 | }
76 |
77 | public void WriteTo(MemoryStream stream) {
78 | stream.Write(this.Buffer, 0, this.Length);
79 | }
80 |
81 | public void WriteTo(System.IO.Stream stream) {
82 | stream.Write(this.Buffer, 0, (int)this.Length);
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/Sources/PeWriter/PdbWriterInterface.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 |
13 | //^ using Microsoft.Contracts;
14 |
15 | namespace Microsoft.Cci {
16 |
17 | public interface IPdbWriter {
18 | void CloseMethod(uint offset);
19 | void CloseScope(uint offset);
20 | void CloseTokenSourceLocationsScope();
21 | void DefineCustomMetadata(string name, byte[] metadata);
22 | void DefineLocalConstant(string name, object value, uint contantSignatureToken);
23 | void DefineLocalVariable(uint index, string name, bool isCompilerGenerated, uint localVariablesSignatureToken);
24 | void DefineSequencePoint(ILocation location, uint offset);
25 | void DefineTokenSourceLocation(uint token, ILocation location);
26 | PeDebugDirectory GetDebugDirectory();
27 | void OpenMethod(uint methodToken);
28 | void OpenScope(uint offset);
29 | void OpenTokenSourceLocationsScope();
30 | void SetEntryPoint(uint entryMethodToken);
31 | void UsingNamespace(string fullName);
32 | }
33 |
34 | public interface IUnmanagedPdbWriter : IPdbWriter, IDisposable {
35 | void SetMetadataEmitter(object metadataEmitter);
36 | }
37 |
38 | public class PeDebugDirectory {
39 | public uint Characteristics;
40 | public uint TimeDateStamp;
41 | public ushort MajorVersion;
42 | public ushort MinorVersion;
43 | public uint Type;
44 | public uint SizeOfData;
45 | public uint AddressOfRawData;
46 | public uint PointerToRawData;
47 | public byte[] Data;
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/src/Sources/PeWriter/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Microsof.Cci.PeWriter")]
9 | [assembly: AssemblyDescription("")]
10 |
11 | // Setting ComVisible to false makes the types in this assembly not visible
12 | // to COM components. If you need to access a type in this assembly from
13 | // COM, set the ComVisible attribute to true on that type.
14 | [assembly: ComVisible(false)]
15 |
16 | // The following GUID is for the ID of the typelib if this project is exposed to COM
17 | [assembly: Guid("ca48caa0-6b9b-42d0-a4e0-17f9120575b5")]
18 |
19 |
--------------------------------------------------------------------------------
/src/Sources/ReflectionEmitter/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Microsof.Cci.ReflectionEmitter")]
9 | [assembly: AssemblyDescription("")]
10 |
11 | // Setting ComVisible to false makes the types in this assembly not visible
12 | // to COM components. If you need to access a typeBuilder in this assembly from
13 | // COM, set the ComVisible attribute to true on that typeBuilder.
14 | [assembly: ComVisible(false)]
15 |
16 | // The following GUID is for the ID of the typelib if this project is exposed to COM
17 | [assembly: Guid("dd06ef47-5c16-488c-be84-25c516cf10ee")]
18 |
19 |
--------------------------------------------------------------------------------
/src/Sources/ReflectionEmitter/ReflectionEmitter.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {4343021F-2848-4770-A0F5-8C9768F9DA98}
9 | Library
10 | Properties
11 | Microsoft.Cci
12 | Microsoft.Cci.ReflectionEmitter
13 | v4.0
14 | 512
15 | true
16 | ..\Common\InterimKey.snk
17 |
18 |
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 | bin\Release\Microsoft.Cci.ReflectionEmitter.XML
35 |
36 |
37 |
38 | Build\Version.cs
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | {4A34A3C5-6176-49D7-A4C5-B2B671247F8F}
47 | MetadataHelper
48 |
49 |
50 | {33CAB640-0D03-43DF-81BD-22CDC6C0A597}
51 | MetadataModel
52 |
53 |
54 | {4B0054FD-124A-4037-9965-BDB55E6BF389}
55 | SourceModel
56 |
57 |
58 |
59 |
60 |
61 |
62 |
69 |
--------------------------------------------------------------------------------
/src/Sources/ReflectionImporter/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ReflectionImporter")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("MSIT")]
12 | [assembly: AssemblyProduct("ReflectionImporter")]
13 | [assembly: AssemblyCopyright("Copyright © MSIT 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("6ea77057-52a6-4fce-a691-a7ec3e625580")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Sources/ReflectionImporter/ReflectionImporter.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {1C6DEEAD-AF77-44A3-AB8F-E77A6C6C50A7}
9 | Library
10 | Properties
11 | ReflectionImporter
12 | ReflectionImporter
13 | v4.0
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | {4A34A3C5-6176-49D7-A4C5-B2B671247F8F}
50 | MetadataHelper
51 |
52 |
53 | {33CAB640-0D03-43DF-81BD-22CDC6C0A597}
54 | MetadataModel
55 |
56 |
57 |
58 |
65 |
--------------------------------------------------------------------------------
/src/Sources/SourceModel/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All Rights Reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System.Reflection;
12 | using System.Runtime.CompilerServices;
13 | using System.Runtime.InteropServices;
14 |
15 | // General Information about an assembly is controlled through the following
16 | // set of attributes. Change these attribute values to modify the information
17 | // associated with an assembly.
18 | [assembly: AssemblyTitle("Microsoft.Cci.SourceModel")]
19 | [assembly: AssemblyDescription("")]
20 |
21 | // Setting ComVisible to false makes the types in this assembly not visible
22 | // to COM components. If you need to access a type in this assembly from
23 | // COM, set the ComVisible attribute to true on that type.
24 | [assembly: ComVisible(false)]
25 |
26 | // The following GUID is for the ID of the typelib if this project is exposed to COM
27 | [assembly: Guid("f0b0c0f2-4aa5-4a2e-a2bb-12dfadea90d0")]
28 |
--------------------------------------------------------------------------------
/src/Tests/PEReaderTests/Program.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All Rights Reserved.
4 | // This code is licensed under the Microsoft Public License.
5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 | //
10 | //-----------------------------------------------------------------------------
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Text;
14 |
15 | namespace ModuleReaderTests
16 | {
17 | class Program
18 | {
19 | static int Main(string[] args)
20 | {
21 | var newArgs = new List();
22 | newArgs.Add(typeof(Program).Assembly.Location);
23 | if (args != null)
24 | newArgs.AddRange(args);
25 | return Xunit.ConsoleClient.Program.Main(newArgs.ToArray());
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Tests/PEReaderTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ModuleReaderTests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("ModuleReaderTests")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2007")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM componenets. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("0cebda09-1eb4-4ed6-b692-5af55ab8989a")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/src/Tests/PEReaderTests/TestModules/MRW_Assembly.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | public class Assem {
4 | public Module1.Foo Foo;
5 | public Module1.Foo.Nested FooNested;
6 | public Module2.Bar Bar;
7 | public Generic1 Generic1;
8 | public Generic2 Generic2;
9 | public Generic3 Generic3;
10 | public Generic4 Generic4;
11 | public Generic1.Nested Generic1Nested;
12 | public Generic2