Formular una preguntaFormular una pregunta
 

PreguntaPhx.PEModuleUnit.Open

  • miércoles, 28 de octubre de 2009 13:23John Connor Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Tiene código
    Hello.
    What should I do to make the following code work?
    Phx.PEModuleUnit moduleUnit = Phx.PEModuleUnit.Open("test.exe");
    this is a simple line. I am so suprised that it occur a fatal error when i was building my project. why???????????????????????????????????

Todas las respuestas

  • jueves, 29 de octubre de 2009 6:27Andy Ayers - MSFTModeradorMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    I would need to know more about what other code you have written before I can help you figure out what is wrong. Before you can call into Phoenix methods you need to do some initialization. There are examples of this in the various samples.
    Architect - Microsoft Phoenix Project
  • jueves, 29 de octubre de 2009 11:16John Connor Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Tiene código
    hi ,Andy Ayers!

    the whole codes are here :
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Phx;
    namespace CallGraph
    {
        class Program
        {
            static void Main(string[] args)
            {
                Phx.Targets.Architectures.Architecture architecture =
                   Phx.Targets.Architectures.X86.Architecture.New();
                Phx.Targets.Runtimes.Runtime runtime =
                   Phx.Targets.Runtimes.Vccrt.Win32.X86.Runtime.New(architecture);
                Phx.GlobalData.RegisterTargetArchitecture(architecture);
                Phx.GlobalData.RegisterTargetRuntime(runtime);
                Phx.Initialize.BeginInitialization();
                Phx.Initialize.EndInitialization("PHX|*|_PHX_", args);
    
                Phx.PEModuleUnit moduleUnit = Phx.PEModuleUnit.Open("RandMatrixMul.exe");
    
                moduleUnit.OutputImagePath = "output.exe";
                moduleUnit.OutputPdbPath = "output.pdb";
    
                for (Phx.ContributionUnitIterator contribUnitIterator =moduleUnit.GetEnumerableContributionUnit().GetEnumerator();contribUnitIterator.MoveNext(); )
                {
                    if (!contribUnitIterator.Current.IsFunctionUnit)
                    {
                        continue;
                    }
                    Phx.FunctionUnit functionUnit = contribUnitIterator.Current.AsFunctionUnit;
                    functionUnit.DisassembleToBeforeLayout();
                }
                moduleUnit.Close();
            }
        }
    }
    
    the error is at "Phx.ContributionUnitIterator contribUnitIterator =moduleUnit.GetEnumerableContributionUnit().GetEnumerator();"

    the error message are Phx.FatalError.


    this is also a example codes in documentation. why are there so many wrongs in mine
  • viernes, 30 de octubre de 2009 7:54Andy Ayers - MSFTModeradorMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    How did you create RandMatrixMul.exe?

    When you want to use Phoenix to read a binary,  you need to make sure that (a) all object files going into the .exe were compiled with /Zi or /Z7; and (b) the .exe was build with linker options -debug and -profile.

    Eg:

    cl -c -Zi myRandomMatrix.cpp
    link -out:RandMatrixMult.exe myRandomMatrix.obj -debug -profile
    Architect - Microsoft Phoenix Project
  • martes, 03 de noviembre de 2009 2:05John Connor Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    hello ,Andy Ayers


        i did as you said here ,but it didn't do as you think .
        there also is the same problem,i don't know why
  • viernes, 06 de noviembre de 2009 6:54Andy Ayers - MSFTModeradorMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    Is your RandMulMatrix.exe native code or managed code? Can you run this under the debugger, enable breaking into the debugger when a CLR exception is raised, and tell me the call stack and what the exception object's message string is?
    Architect - Microsoft Phoenix Project