Ask a questionAsk a question
 

QuestionPhx.PEModuleUnit.Open

  • Wednesday, October 28, 2009 1:23 PMJohn Connor Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    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???????????????????????????????????

All Replies

  • Thursday, October 29, 2009 6:27 AMAndy Ayers - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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
  • Thursday, October 29, 2009 11:16 AMJohn Connor Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    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
  • Friday, October 30, 2009 7:54 AMAndy Ayers - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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
  • Tuesday, November 03, 2009 2:05 AMJohn Connor Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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
  • Friday, November 06, 2009 6:54 AMAndy Ayers - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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