public void ReadCommonExeFields() { ImageReader rdr = new LeImageReader(RawImage, 0); e_magic = rdr.ReadLeUInt16(); e_cbLastPage = rdr.ReadLeUInt16(); e_cpImage = rdr.ReadLeUInt16(); this.e_cRelocations = rdr.ReadLeUInt16(); e_cparHeader = rdr.ReadLeUInt16(); e_minalloc = rdr.ReadLeUInt16(); e_maxalloc = rdr.ReadLeUInt16(); e_ss = rdr.ReadLeUInt16(); e_sp = rdr.ReadLeUInt16(); e_csum = rdr.ReadLeUInt16(); e_ip = rdr.ReadLeUInt16(); e_cs = rdr.ReadLeUInt16(); e_lfaRelocations = rdr.ReadLeUInt16(); e_ovno = rdr.ReadLeUInt16(); e_res = new ushort[4]; for (int i = 0; i != 4; ++i) { e_res[i] = rdr.ReadLeUInt16(); } e_oemid = rdr.ReadLeUInt16(); e_oeminfo = rdr.ReadLeUInt16(); e_res2 = new ushort[10]; for (int i = 0; i != 10; ++i) { e_res2[i] = rdr.ReadLeUInt16(); } e_lfanew = rdr.ReadLeUInt32(); }
public void ApplyRelocations(uint rvaReloc, uint size, uint baseOfImage, RelocationDictionary relocations) { ImageReader rdr = new LeImageReader(RawImage, rvaReloc); uint rvaStop = rvaReloc + size; while (rdr.Offset < rvaStop) { // Read fixup block header. uint page = rdr.ReadLeUInt32(); int cbBlock = rdr.ReadLeInt32(); if (page == 0 || cbBlock == 0) break; uint offBlockEnd = (uint)((int)rdr.Offset + cbBlock - 8); while (rdr.Offset < offBlockEnd) { ApplyRelocation(baseOfImage, page, rdr, relocations); } } }