internal static VarFileInfo ReadVarFileInfo(this PeReader reader) { var orgPos = reader.GetPosition(); var info = new VarFileInfo(); if (!reader.ReadFileInfo(info, "VarFileInfo")) { return(null); } var var = new Var(); if (!reader.ReadFileInfo(var, "Translation")) { return(null); } info.Value = var; var codes = new List <ulong>(); while (reader.GetPosition() < var.Position + var.Length) { ulong code = reader.ReadUInt16(); code = reader.ReadUInt16() | (code << 16); codes.Add(code); } info.Value.LanguageCodes = codes.ToImmutableArray(); return(info); }
internal static void ReadFileInfo(this PeReader reader, FileInfo info, int keyLen) { info.Position = reader.GetPosition(); info.Length = reader.ReadUInt16(); info.ValueLength = reader.ReadUInt16(); info.Type = reader.ReadUInt16(); info.Key = reader.ReadStringZ(keyLen); info.Padding1 = reader.ReadPadding(); }
public override void Read(PeReader rdr) { rdr.SetPosition(PEHeaderOffset); m = (MachineType)rdr.ReadUInt16(); noSect = rdr.ReadUInt16(); stamp = rdr.ReadStamp(); ptrSym = rdr.ReadUInt32(); noSym = rdr.ReadUInt32(); sOh = rdr.ReadUInt16(); c = (PeCharacteristics)rdr.ReadUInt16(); }
public void Load(PeReader rdr, uint adr) { rdr.SetPosition(adr); uint s = Location.Size; while (rdr.BaseStream.Position - adr < s) { CertificateEntry e = new CertificateEntry(); uint len = rdr.ReadUInt32(); e.Revision = (CertificateRevision)rdr.ReadUInt16(); e.CertificateType = (CertificateType)rdr.ReadUInt16(); e.CertificateData = rdr.ReadBytes((int)len - 8); items.Add(e); } }
internal ImageResourceDirectory ReadResourceDirectory(ulong virtualAddress, int index, ImageResourceDirectoryEntry?entry) { _reader.SetPosition(_baseAddress, entry?.OffsetToData ?? 0); var result = new ImageResourceDirectory() { Index = index, Id = entry?.Id ?? 0, Level = entry?.Level ?? 0, HasName = entry?.IdIsName ?? true, Name = entry?.Name ?? "<root>", Characteristics = _reader.ReadUInt32(), TimeDateStamp = _reader.ReadUInt32(), MajorVersion = _reader.ReadUInt16(), MinorVersion = _reader.ReadUInt16(), NumberOfNamedEntries = _reader.ReadUInt16(), NumberOfIdEntries = _reader.ReadUInt16() }; var totalEntries = result.NumberOfIdEntries + result.NumberOfNamedEntries; var entries = new ImageResourceDirectoryEntry[totalEntries]; for (var i = 0; i < entries.Length; i++) { entries[i] = ReadResourceDirectoryEntry(result.Level + 1); } var dirEntries = new List <ImageResourceDirectory>(); var dataEntries = new List <ImageResourceData>(); var idx = 0; foreach (var dir in entries.Where(e => e.IsDirectory)) { dirEntries.Add(ReadResourceDirectory(virtualAddress, idx++, dir)); } foreach (var data in entries.Where(e => e.IsData)) { dataEntries.Add(ReadResourceData(virtualAddress, data)); } result.Directories = dirEntries.ToImmutableArray(); result.Data = dataEntries.ToImmutableArray(); return(result); }
public override void Read(PeReader rdr) { rdr.BaseStream.Position = 0; m = rdr.ReadUInt16(); hc = rdr.ReadBytes(0x3a); o = rdr.ReadUInt32(); ds = rdr.ReadBytes((int)(o - 0x40)); }
internal void Read(PeReader rdr) { n = new string(rdr.ReadChars(8)).Trim('\0'); vSize = rdr.ReadUInt32(); vPtr = rdr.ReadUInt32(); uint rSize = rdr.ReadUInt32(); uint rPtr = rdr.ReadUInt32(); relocPtr = rdr.ReadUInt32(); lnPtr = rdr.ReadUInt32(); relocNo = rdr.ReadUInt16(); lnNo = rdr.ReadUInt16(); c = (SectionFlags)rdr.ReadUInt32(); rdr.SaveLocation(); rdr.SetPosition(rPtr); dat = rdr.ReadBytes((int)rSize); rdr.LoadLocation(); }
public void Read(PeReader rdr) { rdr.SetPosition(StandardFieldsOffset); t = (ExecutableType)rdr.ReadUInt16(); sf = new StandardFieldsHeader(file, this); sf.Read(rdr); wsf = new WindowsSpecificFieldsHeader(file, this); wsf.Read(rdr); dd = new DataDirectoriesHeader(this); dd.Read(rdr); }
public override void Read(PeReader rdr) { rdr.SetPosition(hdr.StandardFieldsOffset); rdr.ReadUInt16(); maL = rdr.ReadByte(); miL = rdr.ReadByte(); sC = rdr.ReadUInt32(); sI = rdr.ReadUInt32(); sU = rdr.ReadUInt32(); entry = rdr.ReadUInt32(); bc = rdr.ReadUInt32(); if (Magic != ExecutableType.PE32Plus) { bd = rdr.ReadUInt32(); } }
public override void Read(PeReader rdr) { rdr.SetPosition(hdr.WindowsSpecificFieldsOffset); if (hdr.Type == ExecutableType.PE32Plus) { imgBas = rdr.ReadUInt64(); sectA = rdr.ReadUInt32(); fA = rdr.ReadUInt32(); maOs = rdr.ReadUInt16(); miOs = rdr.ReadUInt16(); maImg = rdr.ReadUInt16(); miImg = rdr.ReadUInt16(); maSs = rdr.ReadUInt16(); miSs = rdr.ReadUInt16(); winVer = rdr.ReadUInt32(); sImg = rdr.ReadUInt32(); sHdr = rdr.ReadUInt32(); cs = rdr.ReadUInt32(); Ss = (WindowsSubsystem)rdr.ReadUInt16(); dll = (DLLCharacteristics)rdr.ReadUInt16(); sSr = rdr.ReadUInt64(); sSc = rdr.ReadUInt64(); sHr = rdr.ReadUInt64(); sHc = rdr.ReadUInt64(); ldrF = rdr.ReadUInt32(); noDd = rdr.ReadUInt32(); } else { imgBas = rdr.ReadUInt32(); sectA = rdr.ReadUInt32(); fA = rdr.ReadUInt32(); maOs = rdr.ReadUInt16(); miOs = rdr.ReadUInt16(); maImg = rdr.ReadUInt16(); miImg = rdr.ReadUInt16(); maSs = rdr.ReadUInt16(); miSs = rdr.ReadUInt16(); winVer = rdr.ReadUInt32(); sImg = rdr.ReadUInt32(); sHdr = rdr.ReadUInt32(); cs = rdr.ReadUInt32(); Ss = (WindowsSubsystem)rdr.ReadUInt16(); dll = (DLLCharacteristics)rdr.ReadUInt16(); sSr = rdr.ReadUInt32(); sSc = rdr.ReadUInt32(); sHr = rdr.ReadUInt32(); sHc = rdr.ReadUInt32(); ldrF = rdr.ReadUInt32(); noDd = rdr.ReadUInt32(); } }