Ejemplo n.º 1
0
 public void Read(BinaryReader br)
 {
     Magic = br.ReadUInt16();
     if (Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC && Magic != IMAGE_NT_OPTIONAL_HDR64_MAGIC)
     {
         throw new BadImageFormatException();
     }
     MajorLinkerVersion      = br.ReadByte();
     MinorLinkerVersion      = br.ReadByte();
     SizeOfCode              = br.ReadUInt32();
     SizeOfInitializedData   = br.ReadUInt32();
     SizeOfUninitializedData = br.ReadUInt32();
     AddressOfEntryPoint     = br.ReadUInt32();
     BaseOfCode              = br.ReadUInt32();
     if (Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
     {
         BaseOfData = br.ReadUInt32();
         ImageBase  = br.ReadUInt32();
     }
     else
     {
         ImageBase = br.ReadUInt64();
     }
     SectionAlignment            = br.ReadUInt32();
     FileAlignment               = br.ReadUInt32();
     MajorOperatingSystemVersion = br.ReadUInt16();
     MinorOperatingSystemVersion = br.ReadUInt16();
     MajorImageVersion           = br.ReadUInt16();
     MinorImageVersion           = br.ReadUInt16();
     MajorSubsystemVersion       = br.ReadUInt16();
     MinorSubsystemVersion       = br.ReadUInt16();
     Win32VersionValue           = br.ReadUInt32();
     SizeOfImage        = br.ReadUInt32();
     SizeOfHeaders      = br.ReadUInt32();
     CheckSum           = br.ReadUInt32();
     Subsystem          = br.ReadUInt16();
     DllCharacteristics = br.ReadUInt16();
     if (Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
     {
         SizeOfStackReserve = br.ReadUInt32();
         SizeOfStackCommit  = br.ReadUInt32();
         SizeOfHeapReserve  = br.ReadUInt32();
         SizeOfHeapCommit   = br.ReadUInt32();
     }
     else
     {
         SizeOfStackReserve = br.ReadUInt64();
         SizeOfStackCommit  = br.ReadUInt64();
         SizeOfHeapReserve  = br.ReadUInt64();
         SizeOfHeapCommit   = br.ReadUInt64();
     }
     LoaderFlags         = br.ReadUInt32();
     NumberOfRvaAndSizes = br.ReadUInt32();
     DataDirectory       = new IMAGE_DATA_DIRECTORY[NumberOfRvaAndSizes];
     for (uint i = 0; i < NumberOfRvaAndSizes; i++)
     {
         DataDirectory[i] = new IMAGE_DATA_DIRECTORY();
         DataDirectory[i].Read(br);
     }
 }
Ejemplo n.º 2
0
 public void Read(BinaryReader br)
 {
     cb = br.ReadUInt32();
     MajorRuntimeVersion = br.ReadUInt16();
     MinorRuntimeVersion = br.ReadUInt16();
     MetaData            = new IMAGE_DATA_DIRECTORY();
     MetaData.Read(br);
     Flags           = br.ReadUInt32();
     EntryPointToken = br.ReadUInt32();
     Resources       = new IMAGE_DATA_DIRECTORY();
     Resources.Read(br);
     StrongNameSignature = new IMAGE_DATA_DIRECTORY();
     StrongNameSignature.Read(br);
     CodeManagerTable = new IMAGE_DATA_DIRECTORY();
     CodeManagerTable.Read(br);
     VTableFixups = new IMAGE_DATA_DIRECTORY();
     VTableFixups.Read(br);
     ExportAddressTableJumps = new IMAGE_DATA_DIRECTORY();
     ExportAddressTableJumps.Read(br);
     ManagedNativeHeader = new IMAGE_DATA_DIRECTORY();
     ManagedNativeHeader.Read(br);
 }
Ejemplo n.º 3
0
 public void Read(BinaryReader br)
 {
     Magic = br.ReadUInt16();
     if (Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC && Magic != IMAGE_NT_OPTIONAL_HDR64_MAGIC)
     {
         throw new BadImageFormatException();
     }
     MajorLinkerVersion = br.ReadByte();
     MinorLinkerVersion = br.ReadByte();
     SizeOfCode = br.ReadUInt32();
     SizeOfInitializedData = br.ReadUInt32();
     SizeOfUninitializedData = br.ReadUInt32();
     AddressOfEntryPoint = br.ReadUInt32();
     BaseOfCode = br.ReadUInt32();
     if (Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
     {
         BaseOfData = br.ReadUInt32();
         ImageBase = br.ReadUInt32();
     }
     else
     {
         ImageBase = br.ReadUInt64();
     }
     SectionAlignment = br.ReadUInt32();
     FileAlignment = br.ReadUInt32();
     MajorOperatingSystemVersion = br.ReadUInt16();
     MinorOperatingSystemVersion = br.ReadUInt16();
     MajorImageVersion = br.ReadUInt16();
     MinorImageVersion = br.ReadUInt16();
     MajorSubsystemVersion = br.ReadUInt16();
     MinorSubsystemVersion = br.ReadUInt16();
     Win32VersionValue = br.ReadUInt32();
     SizeOfImage = br.ReadUInt32();
     SizeOfHeaders = br.ReadUInt32();
     CheckSum = br.ReadUInt32();
     Subsystem = br.ReadUInt16();
     DllCharacteristics = br.ReadUInt16();
     if (Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
     {
         SizeOfStackReserve = br.ReadUInt32();
         SizeOfStackCommit = br.ReadUInt32();
         SizeOfHeapReserve = br.ReadUInt32();
         SizeOfHeapCommit = br.ReadUInt32();
     }
     else
     {
         SizeOfStackReserve = br.ReadUInt64();
         SizeOfStackCommit = br.ReadUInt64();
         SizeOfHeapReserve = br.ReadUInt64();
         SizeOfHeapCommit = br.ReadUInt64();
     }
     LoaderFlags = br.ReadUInt32();
     NumberOfRvaAndSizes = br.ReadUInt32();
     DataDirectory = new IMAGE_DATA_DIRECTORY[NumberOfRvaAndSizes];
     for (uint i = 0; i < NumberOfRvaAndSizes; i++)
     {
         DataDirectory[i] = new IMAGE_DATA_DIRECTORY();
         DataDirectory[i].Read(br);
     }
 }
Ejemplo n.º 4
0
 public void Read(BinaryReader br)
 {
     cb = br.ReadUInt32();
     MajorRuntimeVersion = br.ReadUInt16();
     MinorRuntimeVersion = br.ReadUInt16();
     MetaData = new IMAGE_DATA_DIRECTORY();
     MetaData.Read(br);
     Flags = br.ReadUInt32();
     EntryPointToken = br.ReadUInt32();
     Resources = new IMAGE_DATA_DIRECTORY();
     Resources.Read(br);
     StrongNameSignature = new IMAGE_DATA_DIRECTORY();
     StrongNameSignature.Read(br);
     CodeManagerTable = new IMAGE_DATA_DIRECTORY();
     CodeManagerTable.Read(br);
     VTableFixups = new IMAGE_DATA_DIRECTORY();
     VTableFixups.Read(br);
     ExportAddressTableJumps = new IMAGE_DATA_DIRECTORY();
     ExportAddressTableJumps.Read(br);
     ManagedNativeHeader = new IMAGE_DATA_DIRECTORY();
     ManagedNativeHeader.Read(br);
 }