/// <summary> /// Based on the approximate values, find the real file offset /// </summary> private bool FindReal(string outputPath) { if (!pkzip) { if (offsetApproximate < 0x100) { offsetApproximate = 0x100; } else if (offsetApproximate > 0xbf00) { offsetApproximate = 0xbf00; } } int pos; uint newcrc = 0; if (offsetApproximate >= 0 && offsetApproximate <= 0xffff) { pos = 0; do { inputFile.Seek(offsetApproximate + pos); Inflate(inputFile, Path.Combine(outputPath, "WISE0001")); newcrc = inputFile.ReadUInt32(); offsetReal = (uint)(offsetApproximate + pos); pos++; }while ((inflate.CRC != newcrc || inflate.Result != 0 || newcrc == 0) && pos != 0x100); if ((inflate.CRC != newcrc || newcrc == 0 || inflate.Result != 0) && pos == 0x100) { pos = -1; do { inputFile.Seek(offsetApproximate + pos); Inflate(inputFile, Path.Combine(outputPath, "WISE0001")); newcrc = inputFile.ReadUInt32(); offsetReal = (uint)(offsetApproximate + pos); pos -= 1; }while ((inflate.CRC != newcrc || inflate.Result != 0 || newcrc == 0) && pos != -0x100); } } else { inflate.CRC = ~newcrc; pos = -0x100; } if ((inflate.CRC != newcrc || newcrc == 0 || inflate.Result != 0) && pos == -0x100) { offsetReal = 0xffffffff; return(false); } else { return(true); } }
public static IMAGE_DATA_DIRECTORY Deserialize(MultiPartFile file) { IMAGE_DATA_DIRECTORY idd = new IMAGE_DATA_DIRECTORY(); idd.VirtualAddress = file.ReadUInt32(); idd.Size = file.ReadUInt32(); return(idd); }
public static IMAGE_RESOURCE_DIRECTORY_ENTRY Deserialize(MultiPartFile file) { IMAGE_RESOURCE_DIRECTORY_ENTRY irde = new IMAGE_RESOURCE_DIRECTORY_ENTRY(); irde.Name = file.ReadUInt32(); irde.OffsetToData = file.ReadUInt32(); return(irde); }
public static IMAGE_RESOURCE_DATA_ENTRY Deserialize(MultiPartFile file) { IMAGE_RESOURCE_DATA_ENTRY irde = new IMAGE_RESOURCE_DATA_ENTRY(); irde.OffsetToData = file.ReadUInt32(); irde.Size = file.ReadUInt32(); irde.CodePage = file.ReadUInt32(); irde.Reserved = file.ReadUInt32(); return(irde); }
public static IMAGE_RESOURCE_DIRECTORY Deserialize(MultiPartFile file) { IMAGE_RESOURCE_DIRECTORY ird = new IMAGE_RESOURCE_DIRECTORY(); ird.Characteristics = file.ReadUInt32(); ird.TimeDateStamp = file.ReadUInt32(); ird.MajorVersion = file.ReadUInt16(); ird.MinorVersion = file.ReadUInt16(); ird.NumberOfNamedEntries = file.ReadUInt16(); ird.NumberOfIdEntries = file.ReadUInt16(); return(ird); }
public static IMAGE_FILE_HEADER Deserialize(MultiPartFile file) { IMAGE_FILE_HEADER ifh = new IMAGE_FILE_HEADER(); ifh.Machine = file.ReadUInt16(); ifh.NumberOfSections = file.ReadUInt16(); ifh.TimeDateStamp = file.ReadUInt32(); ifh.PointerToSymbolTable = file.ReadUInt32(); ifh.NumberOfSymbols = file.ReadUInt32(); ifh.SizeOfOptionalHeader = file.ReadUInt16(); ifh.Characteristics = file.ReadUInt16(); return(ifh); }
public static RsrcTypeInfo Deserialize(MultiPartFile file) { RsrcTypeInfo rti = new RsrcTypeInfo(); rti.ID = file.ReadUInt16(); rti.rt_nres = file.ReadUInt16(); rti.rt_proc = file.ReadUInt32(); return(rti); }
public static TYPEINFO Deserialize(MultiPartFile file) { TYPEINFO ti = new TYPEINFO(); ti.TypeID = file.ReadUInt16(); ti.ResourceCount = file.ReadUInt16(); ti.Reserved = file.ReadUInt32(); ti.NameInfo = NAMEINFO.Deserialize(file); return(ti); }
} // 3F Windows SDK version number public static IMAGE_OS2_HEADER Deserialize(MultiPartFile file) { IMAGE_OS2_HEADER ioh = new IMAGE_OS2_HEADER(); ioh.Magic = file.ReadUInt16(); ioh.LinkerVersion = file.ReadByte(); ioh.LinkerRevision = file.ReadByte(); ioh.EntryTableOffset = file.ReadUInt16(); ioh.EntryTableSize = file.ReadUInt16(); ioh.CrcChecksum = file.ReadUInt32(); ioh.Flags = file.ReadUInt16(); ioh.Autodata = file.ReadUInt16(); ioh.InitialHeapAlloc = file.ReadUInt16(); ioh.InitialStackAlloc = file.ReadUInt16(); ioh.InitialCSIPSetting = file.ReadUInt32(); ioh.InitialSSSPSetting = file.ReadUInt32(); ioh.FileSegmentCount = file.ReadUInt16(); ioh.ModuleReferenceTableSize = file.ReadUInt16(); ioh.NonResidentNameTableSize = file.ReadUInt16(); ioh.SegmentTableOffset = file.ReadUInt16(); ioh.ResourceTableOffset = file.ReadUInt16(); ioh.ResidentNameTableOffset = file.ReadUInt16(); ioh.ModuleReferenceTableOffset = file.ReadUInt16(); ioh.ImportedNamesTableOffset = file.ReadUInt16(); ioh.NonResidentNamesTableOffset = file.ReadUInt32(); ioh.MovableEntriesCount = file.ReadUInt16(); ioh.SegmentAlignmentShiftCount = file.ReadUInt16(); ioh.ResourceEntriesCount = file.ReadUInt16(); ioh.TargetOperatingSystem = file.ReadByte(); ioh.AdditionalFlags = file.ReadByte(); ioh.Reserved = new ushort[Constants.NERESWORDS]; for (int i = 0; i < Constants.NERESWORDS; i++) { ioh.Reserved[i] = file.ReadUInt16(); } ioh.WindowsSDKRevision = file.ReadByte(); ioh.WindowsSDKVersion = file.ReadByte(); return(ioh); }
public static IMAGE_SECTION_HEADER Deserialize(MultiPartFile file) { IMAGE_SECTION_HEADER ish = new IMAGE_SECTION_HEADER(); ish.Name = file.ReadBytes(Constants.IMAGE_SIZEOF_SHORT_NAME); // Misc ish.PhysicalAddress = file.ReadUInt32(); ish.VirtualSize = ish.PhysicalAddress; ish.VirtualAddress = file.ReadUInt32(); ish.SizeOfRawData = file.ReadUInt32(); ish.PointerToRawData = file.ReadUInt32(); ish.PointerToRelocations = file.ReadUInt32(); ish.PointerToLinenumbers = file.ReadUInt32(); ish.NumberOfRelocations = file.ReadUInt16(); ish.NumberOfLinenumbers = file.ReadUInt16(); ish.Characteristics = (SectionCharacteristics)file.ReadUInt32(); return(ish); }
public static IMAGE_OPTIONAL_HEADER Deserialize(MultiPartFile file) { IMAGE_OPTIONAL_HEADER ioh = new IMAGE_OPTIONAL_HEADER(); ioh.Magic = file.ReadUInt16(); ioh.MajorLinkerVersion = file.ReadByte(); ioh.MinorLinkerVersion = file.ReadByte(); ioh.SizeOfCode = file.ReadUInt32(); ioh.SizeOfInitializedData = file.ReadUInt32(); ioh.SizeOfUninitializedData = file.ReadUInt32(); ioh.AddressOfEntryPoint = file.ReadUInt32(); ioh.BaseOfCode = file.ReadUInt32(); ioh.BaseOfData = file.ReadUInt32(); ioh.ImageBase = file.ReadUInt32(); ioh.SectionAlignment = file.ReadUInt32(); ioh.FileAlignment = file.ReadUInt32(); ioh.MajorOperatingSystemVersion = file.ReadUInt16(); ioh.MinorOperatingSystemVersion = file.ReadUInt16(); ioh.MajorImageVersion = file.ReadUInt16(); ioh.MinorImageVersion = file.ReadUInt16(); ioh.MajorSubsystemVersion = file.ReadUInt16(); ioh.MinorSubsystemVersion = file.ReadUInt16(); ioh.Reserved1 = file.ReadUInt32(); ioh.SizeOfImage = file.ReadUInt32(); ioh.SizeOfHeaders = file.ReadUInt32(); ioh.CheckSum = file.ReadUInt32(); ioh.Subsystem = file.ReadUInt16(); ioh.DllCharacteristics = file.ReadUInt16(); ioh.SizeOfStackReserve = file.ReadUInt32(); ioh.SizeOfStackCommit = file.ReadUInt32(); ioh.SizeOfHeapReserve = file.ReadUInt32(); ioh.SizeOfHeapCommit = file.ReadUInt32(); ioh.LoaderFlags = file.ReadUInt32(); ioh.NumberOfRvaAndSizes = file.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(file); } return(ioh); }