qiling icon indicating copy to clipboard operation
qiling copied to clipboard

UEFI does not work with qdb

Open dotCirill opened this issue 1 year ago • 4 comments

The code (emulation of Combined DXE/SMM module):

from qiling import Qiling

if __name__ == "__main__":
    ql = Qiling([
        "files/SuperSMM_DXE_module.efi"
    ], "files")
    ql.debugger = "qdb"


    ql.run()

On 1.4.6 release and current master branch it dies with this error:

... init logs ...
Qdb> *several n (next-steps)*
AttributeError: 'QlOsUefi' object has no attribute 'smm'

backtrace:

# qiling/core.py
debugger(self) # self.os.run is below
# qiling/debugger/qdb/qdb.py
elf.dbg_hook(init_hook)
self.interactive()
self.cmdloop()
...
# qiling/core_hooks.py
hook.call(ql)
# qiling/core_hooks_types.py
self.callback(ql, *args)
# qiling/os/uefi/fncc.py
ql.os.call(pc, f, params, onenter, onexit)
self.fcall.call(func, proto, args, onenter, onexit, passthru)
# qiling/os/fcall.py
func(ql, pc, params)
# qiling/os/uefi/protocols/EfiSmmBase2Protocol.py
ql.log.debug(f'InSmram = {ql.os.smm.active}')

As I understand ql.os.run should be runned but it isn't.

On dev branch I have this backtrace:

ql.run()
# qiling/core.py
debugger = debugger(self) 
# qiling/debugger/qdb/qdb.py
if addr_elf_entry := getattr(self.ql.loader, 'elf_entry'):

AttributeError: 'QlLoaderPE_UEFI' object has no attribute 'elf_entry'

dotCirill avatar Dec 07 '23 22:12 dotCirill

Hi, I think it should be getattr(self.ql.loader, 'elf_entry', None), please let me know if this fix the issue.

ucgJhe avatar Dec 14 '23 18:12 ucgJhe

Hi, it seems to be OK with that (should be fixed in do_show and gdb_hook).

dotCirill avatar Dec 15 '23 13:12 dotCirill

is this fixed?

loki52501 avatar Dec 25 '23 17:12 loki52501

is this fixed?

Yes qdb works after the fix

dotCirill avatar Dec 26 '23 21:12 dotCirill