Don't need -b when piping to a text file. -b is used to pause the output after a page of text.
Use -v to get more info from a handle.
Use -d to get driver related info (child/parent relationships) from a handle.
To get info on all PCI devices, do this:
dh -v -d -p PciIo > dh_v_d_p_PciIo.txt
If the driver is not in a PCI option rom, then may be search all LoadedImage
dh -v -d -p LoadedImage > dh_v_d_p_LoadedImage.txt
You can see the contents of the text file like this:
type -b dh_v_d_p_LoadedImage.txt
but the text coloring will be gone so maybe redo the commands without piping to a text file.
dh -b -v -d -p PciIo
dh -b -v -d -p LoadedImage
You could try looking for the Gop (-p GraphicsOutput). The parent or grand parent may have the PciIo protocol with the rom. The GraphicsOutput protocol address points to a pointer to the QueryMode function which probably exists inside a LoadedImage.
Might be nice if the dh command would output the protocol function addresses and what loaded image they are pointing to.
For example, my Parallels Desktop VM is like this:
dh -d -v -p GraphicsOutput
Code:
92: ConsoleOut(0)
SimpleTextOut(7DEE4430)
Address: 7DEE4430 Attrib 07
GraphicsOutput(7DEE51B8)
Managed by :
Drv[50] : Platform Console Management Driver
Drv[54] : Console Splitter Driver
Drv[59] : Graphics Console Driver
Parent Controllers :
Parent[86] : PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)
Child Controllers :
Child[57] : Primary Console Output Device
dmem 7DEE51B8
Code:
Memory Address 000000007DEE51B8 200 Bytes
7DEE51B8: 34 52 F2 7C 00 00 00 00-37 55 F2 7C 00 00 00 00 *4R.|....7U.|....*
So you want to search for 7CF25234.
You can get info on all the handles
dh -d -v > dh_d_v.txt
Then look at all the loaded images that contain 7CF25234.
Code:
find_address_in_dh () {
local theaddress="$1"
local thefile="$2"
IFS=$'\n'
for theimage in $(
iconv -f UCS-2 -t UTF-8 "$thefile" | perl -0777 -nE 'while ( / +ImageBase.....: (\w+)\r\n +ImageSize.....: (\w+)/g ) { print $1 . " " . $2 . "\n" }'
) ; do
if (( theaddress >= 0x${theimage% *} && theaddress <= 0x${theimage% *} + 0x${theimage#* } )) ; then
iconv -f UCS-2 -t UTF-8 "$thefile" | perl -0777 -nE '/(^\w+.*\r\n( .*\r\n)* +ImageBase.....: '"${theimage% *}"'\r\n( .*\r\n)*)/mg && print $1' | tr -d '\r'
fi
done
}
find_address_in_dh 0x7CF25234 /Volumes/UEFITEST/shell_udk2018/dh_d_v.txt
Result:
Code:
79: 2E3044AC-879F-490F-9760-BBDFAF695F50(0)
ComponentName2(7CF27E50)
ComponentName(7CF27F60)
DriverBinding(7CF27E80)
ImageDevicePath(7DEFB998)
MemoryMapped(0xB,0x7EC10010,0x7F0D000F)/FvFile(0B04B2ED-861C-42CD-A22F-C3AAFACCB896)
LoadedImage(7DEFB1C0)
Name..........: BiosVideoDxe
Revision......: 0x00001000
ParentHandle..: 7E348F98
SystemTable...: 7E7E8018
DeviceHandle..: 7E33FE18
FilePath......: FvFile(0B04B2ED-861C-42CD-A22F-C3AAFACCB896)
PdbFileName...: /home/integrator/jenkins/workspace/PDFM-17.0.0-rc/edk2/Build/PrlEfi-X64/DEBUG_GCC5/X64/IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/VideoDxe/DEBUG/BiosVideoDxe.dll
OptionsSize...: 0
LoadOptions...: 0
ImageBase.....: 7CF22000
ImageSize.....: 62C0
CodeType......: EfiBootServicesCode
DataType......: EfiBootServicesData
Unload........: 0
Driver Name [79] : BIOS[INT10] Video Driver
Driver Image Name : FvFile(0B04B2ED-861C-42CD-A22F-C3AAFACCB896)
Driver Version : 00000003
Driver Type : Bus
Configuration : NO
Diagnostics : NO
Managing :
Ctrl[86] : PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)
Child[92] : PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)/AcpiAdr(0x80010100)
In this case, the GOP (Graphics Output Protocol) is provided by a driver in the firmware called BiosVideoDxe.
This is probably because the option rom of the GPU contains a BIOS driver instead of a GOP driver.
BiosVideoDxe is a GOP driver that calls the BIOS driver.
It would be cool if Macs could use a BIOS driver the same way. Has that ever been attempted before? It would probably require some work to make it work in the Mac EFI.