Пример #1
0
func (loader *PELoader) loadPESection(
	ws *workspace.Workspace,
	mod *workspace.LoadedModule,
	section *pe.Section) error {

	h := section.SectionHeader

	logrus.Infof("section: %s", section.SectionHeader.Name)
	logrus.Infof("  virtual address: 0x%x", section.SectionHeader.VirtualAddress)
	logrus.Infof("  virtual size: 0x%x", section.SectionHeader.VirtualSize)
	logrus.Infof("  file offset: 0x%x", section.SectionHeader.Offset)
	logrus.Infof("  file size: 0x%x", section.SectionHeader.Size)

	rvaSecStart := AS.RVA(h.VirtualAddress)
	secStart := mod.VA(rvaSecStart)
	secLength := roundUpToPage(uint64(h.VirtualSize))
	e := ws.MemMap(secStart, secLength, fmt.Sprintf("%s/%s", mod.Name, section.SectionHeader.Name))
	check(e)

	d, e := section.Data()
	check(e)

	e = mod.MemWrite(ws, rvaSecStart, d)
	check(e)

	// TODO: apply permissions

	return nil
}