public static IMAGE_DATA_DIRECTORY Deserialize(Stream stream)
        {
            var idd = new IMAGE_DATA_DIRECTORY();

            idd.VirtualAddress = stream.ReadUInt32();
            idd.Size           = stream.ReadUInt32();

            return(idd);
        }
Exemplo n.º 2
0
        public static IMAGE_OPTIONAL_HEADER Deserialize(Stream stream)
        {
            var ioh = new IMAGE_OPTIONAL_HEADER();

            ioh.Magic = stream.ReadUInt16();
            ioh.MajorLinkerVersion      = stream.ReadByteValue();
            ioh.MinorLinkerVersion      = stream.ReadByteValue();
            ioh.SizeOfCode              = stream.ReadUInt32();
            ioh.SizeOfInitializedData   = stream.ReadUInt32();
            ioh.SizeOfUninitializedData = stream.ReadUInt32();
            ioh.AddressOfEntryPoint     = stream.ReadUInt32();
            ioh.BaseOfCode              = stream.ReadUInt32();
            ioh.BaseOfData              = stream.ReadUInt32();

            ioh.ImageBase                   = stream.ReadUInt32();
            ioh.SectionAlignment            = stream.ReadUInt32();
            ioh.FileAlignment               = stream.ReadUInt32();
            ioh.MajorOperatingSystemVersion = stream.ReadUInt16();
            ioh.MinorOperatingSystemVersion = stream.ReadUInt16();
            ioh.MajorImageVersion           = stream.ReadUInt16();
            ioh.MinorImageVersion           = stream.ReadUInt16();
            ioh.MajorSubsystemVersion       = stream.ReadUInt16();
            ioh.MinorSubsystemVersion       = stream.ReadUInt16();
            ioh.Reserved1                   = stream.ReadUInt32();
            ioh.SizeOfImage                 = stream.ReadUInt32();
            ioh.SizeOfHeaders               = stream.ReadUInt32();
            ioh.CheckSum            = stream.ReadUInt32();
            ioh.Subsystem           = stream.ReadUInt16();
            ioh.DllCharacteristics  = stream.ReadUInt16();
            ioh.SizeOfStackReserve  = stream.ReadUInt32();
            ioh.SizeOfStackCommit   = stream.ReadUInt32();
            ioh.SizeOfHeapReserve   = stream.ReadUInt32();
            ioh.SizeOfHeapCommit    = stream.ReadUInt32();
            ioh.LoaderFlags         = stream.ReadUInt32();
            ioh.NumberOfRvaAndSizes = stream.ReadUInt32();
            ioh.DataDirectory       = new IMAGE_DATA_DIRECTORY[Constants.IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
            for (int i = 0; i < Constants.IMAGE_NUMBEROF_DIRECTORY_ENTRIES; i++)
            {
                ioh.DataDirectory[i] = IMAGE_DATA_DIRECTORY.Deserialize(stream);
            }

            return(ioh);
        }