func GetPortableExecutable(stub []byte) (*structs.PortableExecutable, error) {
	offset, size, certSizeOffset, err := getAttributes(stub)
	if err != nil {
		return nil, err
	}
	attributeCertificates := stub[offset : offset+size]
	asn1Data, appendedTag, err := processAttributeCertificates(attributeCertificates)
	if err != nil {
		return nil, err
	}
	var signedData structs.X509Certificate
	if _, err := asn1.Unmarshal(asn1Data, &signedData); err != nil {
		return nil, errors.NewError(1010)
	}
	der, errm := asn1.Marshal(signedData)
	if errm != nil {
		return nil, errors.NewError(1011)
	}
	if !bytes.Equal(der, asn1Data) {
		return nil, errors.NewError(1012)
	}
	return &structs.PortableExecutable{
		Contents:        stub,
		AttrCertOffset:  offset,
		CertSizeOffset:  certSizeOffset,
		Asn1Data:        asn1Data,
		AppendedTag:     appendedTag,
		X509Certificate: &signedData,
	}, nil
}
Takes a given input file and creates a Portable Executable wrapper.
See the getAttributes documentation for more information.
package windows
import (
	"bytes"
	"encoding/asn1"
	"encoding/binary"
	"io"
	"unsafe"
	"github.com/RainwayApp/metapod/errors"
	"github.com/RainwayApp/metapod/structs"
)
const (
	certificateRevision   = 0x200
	certificateType       = 2
	certificateTableIndex = 4
)