예제 #1
0
 public XDecompile(XNodeOut intRoot, XNodeOut extRoot, XRayedFile item, BuildModel build)
 {
     ExtRoot = extRoot;
     OriginalPath = item.FilePath;
     item.RecompiledPath = null; // reset
     XFile = item;
     Build = build;
 }
예제 #2
0
        public XDecompile(BuildModel build, XNodeOut intRoot, XNodeOut extRoot, XRayedFile item, 
                          Dictionary<int, FunctionCall> callMap, Dictionary<int, FunctionCall> initMap)
        {
            Build = build;
            ExtRoot = extRoot;
            OriginalPath = item.FilePath;
            item.RecompiledPath = null; // reset
            XFile = item;

            CallMap = callMap;
            InitMap = initMap;
        }
예제 #3
0
        public long WriteNode(FileStream stream)
        {
            if (Exclude)
            {
                return(0);
            }

            // total size 4
            // name size 4
            // name x
            // type 4
            // value 4
            // external 1
            // anon 1
            // id 8
            // parent exist? 1
            //      parent id 4
            // dependencies? 1
            //      dependency count 4
            //      dependent ids 4x

            long startPos = stream.Length;

            // write empty size of packet to be set at the end of the function
            stream.Write(BitConverter.GetBytes(0));

            stream.WriteByte((byte)XPacketType.Node);

            BuildModel.WriteString(stream, Name);

            stream.Write(BitConverter.GetBytes((int)ObjType));

            stream.Write(BitConverter.GetBytes(Lines));

            stream.Write(BitConverter.GetBytes(External));

            stream.Write(BitConverter.GetBytes(IsAnon));

            stream.Write(BitConverter.GetBytes(ID));

            // parent
            stream.Write(BitConverter.GetBytes(Parent != null));

            if (Parent != null)
            {
                stream.Write(BitConverter.GetBytes(Parent.ID));
            }

            // return
            stream.Write(BitConverter.GetBytes(ReturnID));

            // params
            int paramCount = 0;

            if (ParamIDs != null)
            {
                paramCount = ParamIDs.Length;
            }
            stream.Write(BitConverter.GetBytes(paramCount));

            if (paramCount > 0)
            {
                for (int i = 0; i < paramCount; i++)
                {
                    stream.Write(BitConverter.GetBytes(ParamIDs[i]));
                    BuildModel.WriteString(stream, ParamNames[i]);
                }
            }

            // dependencies
            int dependencyCount = 0;

            if (ClassDependencies != null)
            {
                dependencyCount = ClassDependencies.Count;
            }
            stream.Write(BitConverter.GetBytes(dependencyCount));

            if (dependencyCount > 0)
            {
                foreach (int dependentId in ClassDependencies)
                {
                    stream.Write(BitConverter.GetBytes(dependentId));
                }
            }

            // write C#
            int csharpLength = (CSharp != null) ? CSharp.Length : 0;

            stream.Write(BitConverter.GetBytes(csharpLength));

            if (csharpLength > 0)
            {
                stream.Write(CSharp);
            }

            // write MSIL
            int codeLines = (Msil != null) ? Msil.Count : 0;

            stream.Write(BitConverter.GetBytes(codeLines));

            if (codeLines > 0)
            {
                foreach (var inst in Msil)
                {
                    stream.Write(BitConverter.GetBytes(inst.Offset));
                    BuildModel.WriteString(stream, inst.OpCode);
                    BuildModel.WriteString(stream, inst.Line);
                    stream.Write(BitConverter.GetBytes(inst.RefId));
                }
            }

            // write size of packet
            stream.Position = startPos;
            stream.Write(BitConverter.GetBytes((int)(stream.Length - startPos)));
            stream.Position = stream.Length;

            long trackedObjects = 1;

            foreach (XNodeOut child in Nodes.Cast <XNodeOut>())
            {
                trackedObjects += child.WriteNode(stream);
            }

            return(trackedObjects);
        }