Phx.PEModuleUnit.Open
- 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
- 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 - hi ,Andy Ayers!
the whole codes are here :
the error is at "Phx.ContributionUnitIterator contribUnitIterator =moduleUnit.GetEnumerableContributionUnit().GetEnumerator();"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 message are Phx.FatalError.
this is also a example codes in documentation. why are there so many wrongs in mine - 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 - 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 - 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


