Example #1
0
 public AssemblyOS(IRawFile peFile, long offset, HeapSizes heapSizes, IndexSize indexSizes)
     : base(peFile, offset, heapSizes, indexSizes)
 {
     OSPlatformID   = ReadSize(4);
     OSMajorVersion = ReadSize(4);
     OSMinorVersion = ReadSize(4);
 }
Example #2
0
 public Property(IRawFile peFile, long offset, HeapSizes heapSizes, IndexSize indexSizes)
     : base(peFile, offset, heapSizes, indexSizes)
 {
     Flags = (ushort)ReadSize(2);
     Name  = ReadSize(HeapSizes.String);
     Type  = ReadSize(HeapSizes.Blob);
 }
Example #3
0
 public Param(IRawFile peFile, long offset, HeapSizes heapSizes, IndexSize indexSizes)
     : base(peFile, offset, heapSizes, indexSizes)
 {
     Flags    = (ushort)ReadSize(2);
     Sequence = (ushort)ReadSize(2);
     Name     = ReadSize(HeapSizes.String);
 }
Example #4
0
 public TypeRef(IRawFile peFile, long offset, HeapSizes heapSizes, IndexSize indexSizes)
     : base(peFile, offset, heapSizes, indexSizes)
 {
     ResolutionScope = ReadSize(IndexSizes[Index.ResolutionScope]);
     TypeName        = ReadSize(HeapSizes.String);
     TypeNamespace   = ReadSize(HeapSizes.String);
 }
Example #5
0
 public AbstractTable(IRawFile peFile, long offset, HeapSizes heapSizes, IndexSize indexSizes)
     : base(peFile, offset)
 {
     HeapSizes     = heapSizes;
     IndexSizes    = indexSizes;
     CurrentOffset = Offset;
 }
Example #6
0
        private O18QuanEnvelope GetCorrespondingEnvelope(IRawFile rawFile, double theoreticalMz, int charge, double mzTolerance, int scan)
        {
            PeakList <Peak> pkl = rawFile.GetPeakList(scan);

            if (pkl.ScanTimes.Count == 0)
            {
                pkl.ScanTimes.Add(new ScanTime(scan, rawFile.ScanToRetentionTime(scan)));
            }

            PeakList <Peak> O16 = pkl.FindEnvelopeDirectly(theoreticalMz, charge, mzTolerance, 4, () => new Peak());

            PeakList <Peak> O181 = pkl.FindEnvelopeDirectly(theoreticalMz + chargeGapMap1[charge], charge, mzTolerance, 2, () => new Peak());

            for (int i = 2; i < 4; i++)
            {
                if (O16[i].Intensity < O181[i - 2].Intensity)
                {
                    O16[i].Mz        = O181[i - 2].Mz;
                    O16[i].Intensity = O181[i - 2].Intensity;
                }
            }

            PeakList <Peak> O182 = pkl.FindEnvelopeDirectly(theoreticalMz + chargeGapMap2[charge], charge, mzTolerance, 2, () => new Peak());

            O16.AddRange(O182);

            return(new O18QuanEnvelope(O16));
        }
Example #7
0
 public DeclSecurity(IRawFile peFile, long offset, HeapSizes heapSizes, IndexSize indexSizes)
     : base(peFile, offset, heapSizes, indexSizes)
 {
     Action        = (ushort)ReadSize(2);
     Parent        = ReadSize(IndexSizes[Index.HasDeclSecurity]);
     PermissionSet = ReadSize(HeapSizes.Blob);
 }
Example #8
0
        public PeFile(IRawFile peFile)
        {
            RawFile = peFile;

            _nativeStructureParsers = new NativeStructureParsers(RawFile);

            if (ImageNtHeaders?.OptionalHeader?.DataDirectory != null)
            {
                if (ImageSectionHeaders != null)
                {
                    _dataDirectoryParsers = new DataDirectoryParsers(
                        RawFile,
                        ImageNtHeaders.OptionalHeader.DataDirectory,
                        ImageSectionHeaders,
                        Is32Bit
                        );
                }
            }

            _dotNetStructureParsers = new DotNetStructureParsers(
                RawFile,
                ImageComDescriptor,
                ImageSectionHeaders
                );

            _authenticodeParser = new AuthenticodeParser(this);
        }
Example #9
0
 public MetaDataStreamGuid(IRawFile peFile, long offset, uint size)
     : base(peFile, offset)
 {
     _size           = size;
     GuidsAndIndices = ParseGuidsAndIndices();
     Guids           = GuidsAndIndices.Select(x => x.Item1).ToList();
 }
Example #10
0
        public DataDirectoryParsers(
            IRawFile peFile,
            IEnumerable <ImageDataDirectory>?dataDirectories,
            IEnumerable <ImageSectionHeader>?sectionHeaders,
            bool is32Bit
            )
        {
            _peFile          = peFile;
            _dataDirectories = dataDirectories.ToArray();
            _sectionHeaders  = sectionHeaders.ToArray();
            _is32Bit         = is32Bit;

            // Init all parsers
            _imageExportDirectoriesParser     = InitImageExportDirectoryParser();
            _runtimeFunctionsParser           = InitRuntimeFunctionsParser();
            _imageImportDescriptorsParser     = InitImageImportDescriptorsParser();
            _imageBaseRelocationsParser       = InitImageBaseRelocationsParser();
            _imageResourceDirectoryParser     = InitImageResourceDirectoryParser();
            _imageDebugDirectoryParser        = InitImageDebugDirectoryParser();
            _winCertificateParser             = InitWinCertificateParser();
            _exportedFunctionsParser          = InitExportFunctionParser();
            _importedFunctionsParser          = InitImportedFunctionsParser();
            _imageBoundImportDescriptorParser = InitBoundImportDescriptorParser();
            _imageTlsDirectoryParser          = InitImageTlsDirectoryParser();
            _imageDelayImportDescriptorParser = InitImageDelayImportDescriptorParser();
            _imageLoadConfigDirectoryParser   = InitImageLoadConfigDirectoryParser();
            _imageCor20HeaderParser           = InitImageComDescriptorParser();
            _resourcesParser = InitResourcesParser();
        }
        protected override void DoWritePeakList(IRawFile rawReader, PeakList <Peak> pkl, string rawFileName, List <string> result)
        {
            var sw   = GetStreamWriter(rawReader, pkl.ScanMode, pkl.MsLevel, rawFileName);
            var scan = pkl.ScanTimes[0].Scan;

            if (pkl.MsLevel == 1)
            {
                sw.Flush();

                sw1Index.Write("{0}\t{1}\n", scan, sw.BaseStream.Position);

                sw.Write("S\t{0}\t{0}\n", scan);
                sw.Write("I\tRetTime\t{0:0.####}\n", pkl.ScanTimes[0].RetentionTime);

                foreach (Peak p in pkl)
                {
                    sw.Write("{0:0.#####} {1:0.#} {2}\n", p.Mz, p.Intensity, p.Charge);
                }
            }
            else
            {
                sw.WriteLine("S\t{0}\t{1}\t{2}", scan, scan, pkl.PrecursorMZ);
                int[] charges = 0 != pkl.PrecursorCharge ? new[] { pkl.PrecursorCharge } : new[] { 2, 3 };
                foreach (var charge in charges)
                {
                    sw.WriteLine("Z\t{0}\t{1:0.#####}", charge, PrecursorUtils.MzToMH(pkl.PrecursorMZ, charge, true));
                }
                foreach (var peak in pkl)
                {
                    sw.WriteLine("{0:0.#####}\t{1:0.#}", peak.Mz, peak.Intensity);
                }
            }
        }
Example #12
0
 public ClassLayout(IRawFile peFile, long offset, HeapSizes heapSizes, IndexSize indexSizes)
     : base(peFile, offset, heapSizes, indexSizes)
 {
     PackingSize = (ushort)ReadSize(2);
     ClassSize   = ReadSize(4);
     Parent      = ReadSize(IndexSizes[Index.TypeDef]);
 }
Example #13
0
 public MetaDataStreamUs(IRawFile peFile, long offset, uint size)
     : base(peFile, offset)
 {
     _size = size;
     UserStringsAndIndices = ParseUserStringsAndIndices();
     UserStrings           = UserStringsAndIndices.Select(x => x.Item1).ToList();
 }
Example #14
0
 public MethodImpl(IRawFile peFile, long offset, HeapSizes heapSizes, IndexSize indexSizes)
     : base(peFile, offset, heapSizes, indexSizes)
 {
     Class             = ReadSize(IndexSizes[Index.TypeDef]);
     MethodBody        = ReadSize(IndexSizes[Index.MethodDefOrRef]);
     MethodDeclaration = ReadSize(IndexSizes[Index.MethodDefOrRef]);
 }
        private StreamWriter GetStreamWriter(IRawFile rawReader, string peakMode, int msLevel, string fileName)
        {
            string mgfFile = GetPeakModeFileName(rawReader, peakMode, msLevel, fileName) + ".tmp";

            if (swMap.ContainsKey(mgfFile))
            {
                return(swMap[mgfFile]);
            }

            outputFiles.Add(mgfFile);

            var result = new StreamWriter(mgfFile);

            swMap[mgfFile] = result;

            foreach (var comment in Writer.Comments)
            {
                result.WriteLine("###" + comment);
            }

            foreach (var comment in this.PeakListProcessor.ToString().Split('\n'))
            {
                result.WriteLine("###" + comment);
            }

            return(result);
        }
Example #16
0
 public MethodSemantics(IRawFile peFile, long offset, HeapSizes heapSizes, IndexSize indexSizes)
     : base(peFile, offset, heapSizes, indexSizes)
 {
     Semantics   = (ushort)ReadSize(2);
     Method      = ReadSize(IndexSizes[Index.MethodDef]);
     Association = ReadSize(IndexSizes[Index.HasSemantics]);
 }
        public QuantificationChromotograph Build(IIdentifiedSpectrum mphit, IRawFile reader)
        {
            QuantificationChromotograph result = new QuantificationChromotograph();

            var envelopes = builder.Build(mphit);

            int startScan = mphit.Query.FileScan.FirstScan;

            double mzTolerance = PrecursorUtils.ppm2mz(envelopes[0][0], ppmTolerance);

            bool bFirst = true;

            int firstScanNumber = reader.GetFirstSpectrumNumber();
            int lastScanNumber  = reader.GetLastSpectrumNumber();

            //backward
            for (int scan = startScan; scan >= firstScanNumber; scan--)
            {
                if (1 == reader.GetMsLevel(scan))
                {
                    QuantificationScan qscan = reader.GetPeakList(scan).GetQuantificationScan(envelopes, mzTolerance);

                    if (!validate(qscan))
                    {
                        break;
                    }

                    if (bFirst)
                    {
                        qscan.IsIdentified = true;
                        bFirst             = false;
                    }
                    result.Insert(0, qscan);
                }
            }

            //forward
            for (int scan = startScan + 1; scan <= lastScanNumber; scan++)
            {
                if (1 == reader.GetMsLevel(scan))
                {
                    QuantificationScan qscan = reader.GetPeakList(scan).GetQuantificationScan(envelopes, mzTolerance);

                    if (!validate(qscan))
                    {
                        break;
                    }

                    result.Add(qscan);
                }
            }

            if (result.Count > 0)
            {
                result.IdentifiedSpectra.Add(mphit);
            }

            return(result);
        }
        public static List <ScanLevel> GetScanLevels(IRawFile rawFile)
        {
            var levels = new List <ScanLevel>();

            FillScanLevels(levels, rawFile);
            BuildScanLevels(levels);
            return(levels);
        }
Example #19
0
 public TxLog(IRawFile data)
 {
     _data = data;
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
 }
Example #20
0
 public Constant(IRawFile peFile, long offset, HeapSizes heapSizes, IndexSize indexSizes)
     : base(peFile, offset, heapSizes, indexSizes)
 {
     Type           = (byte)ReadSize(1);
     CurrentOffset += 1; // Padding after "Type"
     Parent         = ReadSize(IndexSizes[Index.HasConstant]);
     Value          = ReadSize(HeapSizes.Blob);
 }
 public MetaDataStreamBlobParser(
     IRawFile peFile,
     long offset,
     uint size)
     : base(peFile, offset)
 {
     _size = size;
 }
Example #22
0
 public SymbolMapColumn(int columnID, int partitionID, IRawFile data, IRawFile datak, IRawFile datar,
                        IRawFile symd, IRawFile symi,
                        IRawFile symk, IRawFile symr,
                        string propertyName, int capacity, long recordCountHint, int maxLen) : this(columnID, partitionID, data, symd, symi, symk, symr, propertyName, capacity, maxLen)
 {
     _datarIndex = new IndexColumn(datak, datar, capacity, recordCountHint);
     _isIndexed  = true;
 }
Example #23
0
 public ImplMap(IRawFile peFile, long offset, HeapSizes heapSizes, IndexSize indexSizes)
     : base(peFile, offset, heapSizes, indexSizes)
 {
     MappingFlags    = (ushort)ReadSize(2);
     MemberForwarded = ReadSize(IndexSizes[Index.MemberForwarded]);
     ImportName      = ReadSize(HeapSizes.String);
     ImportScope     = ReadSize(IndexSizes[Index.ModuleRef]);
 }
Example #24
0
 public BinaryColumn(IRawFile data, IRawFile index,
                     int maxSize, string propertyName)
 {
     PropertyName = propertyName;
     _data        = data;
     _maxSize     = maxSize;
     _index       = index;
 }
Example #25
0
 public ExportedType(IRawFile peFile, long offset, HeapSizes heapSizes, IndexSize indexSizes)
     : base(peFile, offset, heapSizes, indexSizes)
 {
     Flags         = ReadSize(4);
     TypeDefId     = ReadSize(IndexSizes[Index.TypeDef]);
     TypeName      = ReadSize(HeapSizes.String);
     TypeNamespace = ReadSize(HeapSizes.String);
 }
Example #26
0
 public ManifestResource(IRawFile peFile, long offset, HeapSizes heapSizes, IndexSize indexSizes)
     : base(peFile, offset, heapSizes, indexSizes)
 {
     Offset         = ReadSize(4);
     Flags          = ReadSize(4);
     Name           = ReadSize(HeapSizes.String);
     Implementation = ReadSize(IndexSizes[Index.Implementation]);
 }
Example #27
0
 public GenericParam(IRawFile peFile, long offset, HeapSizes heapSizes, IndexSize indexSizes)
     : base(peFile, offset, heapSizes, indexSizes)
 {
     Number = (ushort)ReadSize(2);
     Flags  = (ushort)ReadSize(2);
     Owner  = ReadSize(IndexSizes[Index.TypeOrMethodDef]);
     Name   = ReadSize(HeapSizes.String);
 }
        protected override void DoFinalize(bool bReadAgain, IRawFile rawReader, string rawFileName, List <string> result)
        {
            foreach (var sw in swMap.Values)
            {
                sw.Close();
            }

            if (!Progress.IsCancellationPending() && !IsLoopStopped && !bReadAgain)
            {
                if (outputFiles.Count == 1 && (options.GroupByMode || options.GroupByMsLevel))
                {
                    var resultFile = GetResultFile(rawReader, rawFileName);
                    if (!resultFile.Equals(outputFiles[0]))
                    {
                        if (File.Exists(resultFile))
                        {
                            File.Delete(resultFile);
                        }

                        File.Move(outputFiles[0], resultFile);
                    }
                    result.Add(resultFile);
                }
                else
                {
                    foreach (var mgf in outputFiles)
                    {
                        if (mgf.EndsWith(".tmp"))
                        {
                            var res = FileUtils.ChangeExtension(mgf, "");
                            if (File.Exists(res))
                            {
                                File.Delete(res);
                            }
                            File.Move(mgf, res);
                            result.Add(res);
                        }
                        else
                        {
                            result.Add(mgf);
                        }
                    }
                }
            }
            else
            {
                foreach (var m in outputFiles)
                {
                    try
                    {
                        File.Delete(m);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
Example #29
0
 public ImageBaseRelocationsParser(
     IRawFile peFile,
     uint offset,
     uint directorySize
     )
     : base(peFile, offset)
 {
     _directorySize = directorySize;
 }
Example #30
0
        internal NativeStructureParsers(IRawFile peFile)
        {
            _peFile = peFile;

            // Init all parsers
            _imageDosHeaderParser      = InitImageDosHeaderParser();
            _imageNtHeadersParser      = InitNtHeadersParser();
            _imageSectionHeadersParser = InitImageSectionHeadersParser();
        }