Example #1
0
        void WriteDisassembly(TextWriter writer)
        {
            CilWriter             cw = new CilWriter(writer);
            StructureDisassembler sd = new StructureDisassembler();

            sd.DisassembleAssembly(AssemblyFactory.GetAssembly(m_assembly), cw);
        }
        public void DisassembleAssembly(AssemblyDefinition asm, CilWriter writer)
        {
            writer.WriteLine("// Mono CIL Disassembler");
            writer.WriteLine("// Prototype using Mono.Cecil");
            writer.WriteLine();

            DisassembleManifest(asm, writer);

            m_rd.DisassembleModule(asm.MainModule, writer);
        }
        public void DisassembleManifest(AssemblyDefinition asm, CilWriter writer)
        {
            m_writer    = writer;
            m_rd.Writer = writer;

            VisitModuleReferenceCollection(asm.MainModule.ModuleReferences);
            VisitAssemblyNameReferenceCollection(asm.MainModule.AssemblyReferences);
            VisitAssemblyDefinition(asm);
            VisitModuleDefinition(asm.MainModule);
        }
		public void DisassembleAssembly (AssemblyDefinition asm, CilWriter writer)
		{
			writer.WriteLine ("// Mono CIL Disassembler");
			writer.WriteLine ("// Prototype using Mono.Cecil");
			writer.WriteLine ();

			DisassembleManifest (asm, writer);

			m_rd.DisassembleModule (asm.MainModule, writer);
		}
		public void DisassembleManifest (AssemblyDefinition asm, CilWriter writer)
		{
			m_writer = writer;
			m_rd.Writer = writer;

			VisitModuleReferenceCollection (asm.MainModule.ModuleReferences);
			VisitAssemblyNameReferenceCollection (asm.MainModule.AssemblyReferences);
			VisitAssemblyDefinition (asm);
			VisitModuleDefinition (asm.MainModule);
		}
Example #6
0
        //FIXME: Move to ReflectionDisassembler ?
        public void DisassembleMethod(MethodDefinition method, CilWriter writer)
        {
            m_writer = writer;
            //    .method public hidebysig  specialname
            //               instance default class [mscorlib]System.IO.TextWriter get_BaseWriter ()  cil managed
            //

            // write method header
            m_writer.Write(".method ");

            //emit flags
            WriteMethodVisibility(method.Attributes);
            WriteMethodAttributes(method.Attributes);

            m_writer.WriteLine();
            m_writer.Indent();

            if (method.HasThis)
            {
                m_writer.Write("instance ");
            }

            //call convention
            WriteMethodCallingConvention(method.CallingConvention);

            //return type
            //method.ReturnType.ReturnType.Accept (m_reflectDis);
            //FIXME: another visitor for printing names (refs to methoddef/typedef/typeref etc
            m_writer.Write(Formater.Signature(method.ReturnType.ReturnType, false, true));
            m_writer.Write(method.Name);

            //( params )
            m_writer.Write(" (");
            method.Parameters.Accept(m_reflectDis);
            m_writer.Write(") ");
            //cil managed
            WriteMethodCodeType(method.ImplAttributes);
            WriteMethodManagedType(method.ImplAttributes);

            m_writer.Unindent();

            m_writer.OpenBlock();
            m_reflectDis.VisitCustomAttributeCollection(method.CustomAttributes);
            m_reflectDis.VisitSecurityDeclarationCollection(method.SecurityDeclarations);

            if (method.HasBody)
            {
                VisitMethodBody(method.Body);
            }

            m_writer.CloseBlock();
        }
        public void DisassembleModule(ModuleDefinition module, CilWriter writer)
        {
            m_writer = writer;

            VisitTypeDefinitionCollection(module.Types);
        }
		void WriteDisassembly (TextWriter writer)
		{
			CilWriter cw = new CilWriter (writer);
			StructureDisassembler sd = new StructureDisassembler ();
			sd.DisassembleAssembly (AssemblyFactory.GetAssembly (m_assembly), cw);
		}
Example #9
0
		//FIXME: Move to ReflectionDisassembler ?
		public void DisassembleMethod (MethodDefinition method, CilWriter writer)
		{
			m_writer = writer;
			//    .method public hidebysig  specialname
			//               instance default class [mscorlib]System.IO.TextWriter get_BaseWriter ()  cil managed
			//

			// write method header
			m_writer.Write (".method ");

			//emit flags
			WriteMethodVisibility (method.Attributes);
			WriteMethodAttributes (method.Attributes);

			if(method.IsPInvokeImpl) {
				//Console.Error.WriteLine(method.PInvokeInfo);
				String module = method.PInvokeInfo.Module.Name;
				String symbol = method.PInvokeInfo.EntryPoint;
				m_writer.BaseWriter.Write("(");
				m_writer.BaseWriter.Write(String.Format("\"{0}\" as \"{1}\"", module, symbol));
				m_writer.BaseWriter.Write(")");
			}

			m_writer.WriteLine ();
			m_writer.Indent ();

			if (method.HasThis)
				m_writer.Write ("instance ");

			//call convention
			WriteMethodCallingConvention (method.CallingConvention);

			//return type
			//method.ReturnType.ReturnType.Accept (m_reflectDis);
			//FIXME: another visitor for printing names (refs to methoddef/typedef/typeref etc
			m_writer.Write (Formater.Signature (method.ReturnType.ReturnType, false, !NoAlias));
			m_writer.Write (method.Name);

			//( params )
			m_writer.BaseWriter.Write (" (");
			method.Parameters.Accept (m_reflectDis);
			m_writer.BaseWriter.Write (") ");
			//cil managed
			WriteMethodCodeType (method.ImplAttributes);
			WriteMethodManagedType (method.ImplAttributes);

			m_writer.Unindent ();

			m_writer.OpenBlock ();
			m_reflectDis.VisitCustomAttributeCollection (method.CustomAttributes);
			m_reflectDis.VisitSecurityDeclarationCollection (method.SecurityDeclarations);

			if (method.HasBody)
				VisitMethodBody (method.Body);

			m_writer.CloseBlock ();
		}
		public void DisassembleModule (ModuleDefinition module, CilWriter writer)
		{
			m_writer = writer;

			VisitTypeDefinitionCollection (module.Types);
		}