Darmawan Salihun (@Pinczakko) wrote an excellent article a few years ago on PCI Expansion ROMs. It shows how to write custom code and use it from an Expansion ROM, very detailed article, with pointers to related ones for background, and sample code. If you haven’t read this, it’s a great primer on PCI OpROM security. And that is just ONE of the MANY excellent articles on BIOS he’s written. Read the “Malicious PCI Expansion ROM” article listed there, in addition to above-described research. I wish Pinczakko would write more articles!