static WrapperProvider() { frc = new FieldReferenceComparer(); TypeDefinitionComparer tdc = new TypeDefinitionComparer(); InstructionComparer idc = new InstructionComparer(); VariableComparer vc = new VariableComparer(); MethRefToWrapperMap = new Dictionary <IMethodReference, MethodRefWrapper>(MethodReferenceDefinitionComparer.Default); TypeRefToWrapperMap = new Dictionary <ITypeReference, TypeRefWrapper>(tdc); FieldRefToWrapperMap = new Dictionary <IFieldReference, FieldRefWrapper>(frc); InstToWrapperMap = new Dictionary <Instruction, InstructionWrapper>(new InstructionComparer()); VarToWrapperMap = new Dictionary <IVariable, VariableWrapper>(vc); MethRefToAddrWrapperMap = new Dictionary <IMethodReference, AddressWrapper>(MethodReferenceDefinitionComparer.Default); InstFldRefToAddrWrapperMap = new Dictionary <Instruction, IDictionary <IFieldReference, AddressWrapper> >(idc); FieldRefToAddrWrapperMap = new Dictionary <IFieldReference, AddressWrapper>(frc); VarToAddrWrapperMap = new Dictionary <IVariable, AddressWrapper>(vc); ArrayToAddrWrapperMap = new Dictionary <Instruction, AddressWrapper>(idc); InstToHeapElemWrapperMap = new Dictionary <Instruction, HeapElemWrapper>(idc); InstToHeapArrayElemWrapperMap = new Dictionary <Instruction, HeapElemWrapper>(idc); VarToHeapElemWrapperMap = new Dictionary <IVariable, HeapElemWrapper>(vc); FieldRefToHeapElemWrapperMap = new Dictionary <IFieldReference, HeapElemWrapper>(frc); InstFldRefToHeapElemWrapperMap = new Dictionary <Instruction, IDictionary <IFieldReference, HeapElemWrapper> >(idc); InstToExHandlerWrapperMap = new Dictionary <Instruction, ExHandlerWrapper>(idc); }
public RTAAnalyzer(bool rootIsExe, StreamWriter sw, IMetadataHost h) { TypeDefinitionComparer tdc = new TypeDefinitionComparer(); MethodReferenceDefinitionComparer mdc = MethodReferenceDefinitionComparer.Default; FieldReferenceComparer frc = new FieldReferenceComparer(); VariableComparer vc = new VariableComparer(); classWorkList = new List <ITypeDefinition>(); entryPtClasses = new HashSet <ITypeDefinition>(tdc); visitedClasses = new HashSet <ITypeDefinition>(tdc); clinitProcessedClasses = new HashSet <ITypeDefinition>(tdc); ignoredClasses = new HashSet <ITypeDefinition>(tdc); visitedMethods = new HashSet <IMethodDefinition>(mdc); ignoredMethods = new HashSet <IMethodDefinition>(mdc); entryPtMethods = new HashSet <IMethodDefinition>(mdc); allocClasses = new HashSet <ITypeDefinition>(tdc); classes = new HashSet <ITypeDefinition>(tdc); methods = new HashSet <IMethodDefinition>(mdc); types = new HashSet <ITypeDefinition>(tdc); this.rootIsExe = rootIsExe; this.rtaLogSW = sw; this.host = h; addrTakenInstFlds = new HashSet <IFieldDefinition>(frc); addrTakenStatFlds = new HashSet <IFieldDefinition>(frc); addrTakenLocals = new HashSet <IVariable>(vc); addrTakenMethods = new HashSet <IMethodDefinition>(mdc); }
static ClassAndMethodVisitor() { MethodReferenceDefinitionComparer mdc = MethodReferenceDefinitionComparer.Default; TypeDefinitionComparer tdc = new TypeDefinitionComparer(); genericMethodMap = new Dictionary <IMethodDefinition, IDictionary <string, IMethodDefinition> >(mdc); moduleToPdbMap = new Dictionary <IModule, ISourceLocationProvider>(); methodToCfgAndTacMap = new Dictionary <IMethodDefinition, MethodCfgAndTac>(); }
static Utils() { tdc = new TypeDefinitionComparer(); }
public void SaveScope(IMetadataHost host) { string modulesFN = "modules.txt"; StreamWriter modulesSW = new StreamWriter(Path.Combine(ConfigParams.SaveScopePath, modulesFN)); List <IModule> moduleList = host.LoadedUnits.OfType <IModule>().ToList(); TypeDefinitionComparer tdc = new TypeDefinitionComparer(); ISet <ITypeDefinition> processedTypes = new HashSet <ITypeDefinition>(tdc); foreach (IModule module in moduleList) { if (module == null || module == Dummy.Module || module == Dummy.Assembly) { System.Console.WriteLine("WARNING: SaveScope - modules: Dummy or null module - skipping."); continue; } modulesSW.WriteLine("MODULE:" + module.Name.Value + " LOCATION:" + module.Location); } modulesSW.Close(); string classesFN = "classes.txt"; StreamWriter classesSW = new StreamWriter(Path.Combine(ConfigParams.SaveScopePath, classesFN)); foreach (ITypeDefinition cl in classes) { if (processedTypes.Contains(cl)) { continue; } IModule mod = TypeHelper.GetDefiningUnit(cl) as IModule; if (cl is IGenericTypeInstance) { ProcessGenericType(cl, classesSW, mod, processedTypes); } else { classesSW.WriteLine("CLASS:" + cl.FullName() + " ARGS: MODULE:" + mod.Name.Value); processedTypes.Add(cl); } } classesSW.Close(); string entClassesFN = "entrypt_classes.txt"; StreamWriter entClassesSW = new StreamWriter(Path.Combine(ConfigParams.SaveScopePath, entClassesFN)); foreach (ITypeDefinition cl in entryPtClasses) { IModule mod = TypeHelper.GetDefiningUnit(cl) as IModule; entClassesSW.WriteLine("CLASS:" + cl.FullName() + " ARGS: MODULE:" + mod.Name.Value); } entClassesSW.Close(); string methodsFN = "methods.txt"; StreamWriter methodsSW = new StreamWriter(Path.Combine(ConfigParams.SaveScopePath, methodsFN)); foreach (IMethodDefinition meth in methods) { string argStr = ""; IMethodDefinition methToRecord = meth; if (meth is IGenericMethodInstance) { IGenericMethodInstance genericM = meth as IGenericMethodInstance; IEnumerable <ITypeReference> genericArgs = genericM.GenericArguments; foreach (ITypeReference ty in genericArgs) { ITypeDefinition tyDefn = ty.ResolvedType; argStr += tyDefn.FullName() + ";"; } if (!argStr.Equals("")) { argStr = argStr.TrimEnd(';'); } methToRecord = genericM.GenericMethod.ResolvedMethod; } methodsSW.WriteLine("METHOD:" + methToRecord.FullName() + " ARGS:" + argStr + " CLASS:" + methToRecord.ContainingTypeDefinition.FullName()); } methodsSW.Close(); }