public override void Read(BinaryReader r) { var sstSrcModuleBaseAddress = r.BaseStream.Position; // Number of source files contributing code to segments. var cFile = r.ReadUInt16(); // Number of code segments receiving code from this module. var cSeg = r.ReadUInt16(); baseSrcFile = new uint[cFile]; for (int i = 0; i < cFile; i++) baseSrcFile[i] = r.ReadUInt32(); /* * An array of two 32-bit offsets per segment that receives code from * this module. The first offset is the offset within the segment of the * first byte of code from this module. The second offset is the ending * address of the code from this module. The order of these pairs * corresponds to the ordering of the segments in the seg array. Zeroes * in these entries means that the information is not known, and the file * and line tables described below need to be examined to determine if * an address of interest is contained within the code from this module. */ starts = new uint[cSeg]; ends = new uint[cSeg]; for (int i = 0; i < cSeg; i++) { starts[i] = r.ReadUInt32(); ends[i] = r.ReadUInt32(); } segmentIndices=new ushort[cSeg]; for (int i = 0; i < cSeg; i++) segmentIndices[i] = r.ReadUInt16(); //if (cSeg % 2==1) r.ReadUInt16(); FileInfo=new SourceFileInformation[cFile]; for (int i = 0; i < cFile; i++) { r.BaseStream.Position = sstSrcModuleBaseAddress + baseSrcFile[i]; var sfi=new SourceFileInformation(); var cSeg2 = r.ReadUInt16(); var pad=r.ReadUInt16(); // pad if (pad != 0) throw new Exception("Wrong pad value!"); sfi.baseSrcLn = new uint[cSeg2]; for (int j = 0; j < cSeg2; j++) sfi.baseSrcLn[j] = r.ReadUInt32(); sfi.segmentStartOffsets=new uint[cSeg2]; sfi.segmentEndOffsets = new uint[cSeg2]; for (int j = 0; j < cSeg2; j++) { sfi.segmentStartOffsets[j] = r.ReadUInt32(); sfi.segmentEndOffsets[j] = r.ReadUInt32(); } sfi.SourceFileName = r.ReadString(); sfi.Segments = new SourceSegmentInfo[cSeg2]; for (int j = 0; j < cSeg2; j++) { r.BaseStream.Position = sstSrcModuleBaseAddress + sfi.baseSrcLn[j]; var ssi = new SourceSegmentInfo(); ssi.SegmentId = r.ReadUInt16(); var cPair = r.ReadUInt16(); ssi.Offsets = new uint[cPair]; for (int k = 0; k < cPair; k++) ssi.Offsets[k] = r.ReadUInt32(); ssi.Lines = new ushort[cPair]; for (int k = 0; k < cPair; k++) ssi.Lines[k] = r.ReadUInt16(); sfi.Segments[j] = ssi; } FileInfo[i] = sfi; } }
public override void Read(BinaryReader r) { var sstSrcModuleBaseAddress = r.BaseStream.Position; // Number of source files contributing code to segments. var cFile = r.ReadUInt16(); // Number of code segments receiving code from this module. var cSeg = r.ReadUInt16(); baseSrcFile = new uint[cFile]; for (int i = 0; i < cFile; i++) { baseSrcFile[i] = r.ReadUInt32(); } /* * An array of two 32-bit offsets per segment that receives code from * this module. The first offset is the offset within the segment of the * first byte of code from this module. The second offset is the ending * address of the code from this module. The order of these pairs * corresponds to the ordering of the segments in the seg array. Zeroes * in these entries means that the information is not known, and the file * and line tables described below need to be examined to determine if * an address of interest is contained within the code from this module. */ starts = new uint[cSeg]; ends = new uint[cSeg]; for (int i = 0; i < cSeg; i++) { starts[i] = r.ReadUInt32(); ends[i] = r.ReadUInt32(); } segmentIndices = new ushort[cSeg]; for (int i = 0; i < cSeg; i++) { segmentIndices[i] = r.ReadUInt16(); } //if (cSeg % 2==1) r.ReadUInt16(); FileInfo = new SourceFileInformation[cFile]; for (int i = 0; i < cFile; i++) { r.BaseStream.Position = sstSrcModuleBaseAddress + baseSrcFile[i]; var sfi = new SourceFileInformation(); var cSeg2 = r.ReadUInt16(); var pad = r.ReadUInt16(); // pad if (pad != 0) { throw new Exception("Wrong pad value!"); } sfi.baseSrcLn = new uint[cSeg2]; for (int j = 0; j < cSeg2; j++) { sfi.baseSrcLn[j] = r.ReadUInt32(); } sfi.segmentStartOffsets = new uint[cSeg2]; sfi.segmentEndOffsets = new uint[cSeg2]; for (int j = 0; j < cSeg2; j++) { sfi.segmentStartOffsets[j] = r.ReadUInt32(); sfi.segmentEndOffsets[j] = r.ReadUInt32(); } sfi.SourceFileName = r.ReadString(); sfi.Segments = new SourceSegmentInfo[cSeg2]; for (int j = 0; j < cSeg2; j++) { r.BaseStream.Position = sstSrcModuleBaseAddress + sfi.baseSrcLn[j]; var ssi = new SourceSegmentInfo(); ssi.SegmentId = r.ReadUInt16(); var cPair = r.ReadUInt16(); ssi.Offsets = new uint[cPair]; for (int k = 0; k < cPair; k++) { ssi.Offsets[k] = r.ReadUInt32(); } ssi.Lines = new ushort[cPair]; for (int k = 0; k < cPair; k++) { ssi.Lines[k] = r.ReadUInt16(); } sfi.Segments[j] = ssi; } FileInfo[i] = sfi; } }
public static List <ProjectItemInformation> GetItemsFromDirectory(string directoryPath, string parentGroupName, bool isRoot) { string[] files = System.IO.Directory.GetFiles(directoryPath); List <ProjectItemInformation> fileInfos = new List <ProjectItemInformation>(); foreach (string file in files) { string extension = System.IO.Path.GetExtension(file); if (!extension.Equals(".meta") && !extension.Equals(".DS_Store")) { if (extension.Equals(".a") || extension.Equals(".h") || extension.Equals(".m") || extension.Equals(".mm")) { SourceFileInformation sourceInfo = new SourceFileInformation(); sourceInfo.FileName = System.IO.Path.GetFileName(file); sourceInfo.FilePath = file; sourceInfo.ParentGroupName = parentGroupName; fileInfos.Add(sourceInfo); } } } string[] directories = System.IO.Directory.GetDirectories(directoryPath); List <ProjectItemInformation> directoryInfos = new List <ProjectItemInformation>(); foreach (string directory in directories) { string extension = System.IO.Path.GetExtension(directory); if (!extension.Equals(".meta") && !extension.Equals(".DS_Store")) { if (System.IO.Path.GetExtension(directory).Equals(".framework")) { FrameworkFileInformation frameworkInfo = new FrameworkFileInformation(); frameworkInfo.FileName = System.IO.Path.GetFileName(directory); Debug.Log(frameworkInfo.FileName); frameworkInfo.FilePath = directory; frameworkInfo.FrameworkType = FrameworkType.Custom; frameworkInfo.ParentGroupName = parentGroupName; directoryInfos.Add(frameworkInfo); } else if (System.IO.Path.GetExtension(directory).Equals(".bundle")) { ResourceFileInformation resourceInfo = new ResourceFileInformation(); resourceInfo.FileName = System.IO.Path.GetFileName(directory); resourceInfo.FilePath = directory; resourceInfo.ParentGroupName = parentGroupName; directoryInfos.Add(resourceInfo); } else { ProjectGroupInformation groupInfo = new ProjectGroupInformation(); groupInfo.GroupName = System.IO.Path.GetFileName(directory); if (isRoot) { groupInfo.GroupPath = directory; groupInfo.IsRoot = true; } else { groupInfo.GroupPath = groupInfo.GroupName; groupInfo.IsRoot = false; } groupInfo.ParentGroupName = parentGroupName; directoryInfos.Add(groupInfo); directoryInfos.AddRange(GetItemsFromDirectory(directory, groupInfo.GroupName, false)); } } } List <ProjectItemInformation> result = new List <ProjectItemInformation>(); result.AddRange(fileInfos); result.AddRange(directoryInfos); return(result); }