public static ImageSectionInfo[] GetPESectionInfo(IntPtr hModule) { //todo // get the location of the module's IMAGE_NT_HEADERS structure var pNtHdr = ImageNtHeader(hModule); // section table immediately follows the IMAGE_NT_HEADERS var pSectionHdr = (IntPtr)(pNtHdr + 1); var arr = new ImageSectionInfo[pNtHdr->FileHeader.NumberOfSections]; int size = Marshal.SizeOf <ImageSectionHeader>(); for (int scn = 0; scn < pNtHdr->FileHeader.NumberOfSections; ++scn) { var struc = Marshal.PtrToStructure <ImageSectionHeader>(pSectionHdr); arr[scn] = new ImageSectionInfo(struc, scn, hModule + (int)struc.VirtualAddress); pSectionHdr += size; } return(arr); }
public Segment(ImageSectionInfo p) : this(p.Address, p.Size) { }