Skip to content

Commit cbd33e8

Browse files
committed
Deduplicate protocol notifications handling
1 parent 08bd587 commit cbd33e8

File tree

3 files changed

+3
-19
lines changed

3 files changed

+3
-19
lines changed

examples/simple_efi_x8664.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from qiling import Qiling
1212
from qiling.const import QL_INTERCEPT, QL_VERBOSE
1313
from qiling.os.uefi.const import EFI_SUCCESS, EFI_INVALID_PARAMETER
14-
from qiling.os.uefi.utils import check_and_notify_protocols, signal_event
14+
from qiling.os.uefi.utils import execute_protocol_notifications, signal_event
1515

1616
def force_notify_RegisterProtocolNotify(ql: Qiling, address: int, params):
1717
event_id = params['Event']
@@ -23,7 +23,7 @@ def force_notify_RegisterProtocolNotify(ql: Qiling, address: int, params):
2323
event["Set"] = False
2424

2525
signal_event(ql, event_id)
26-
check_and_notify_protocols(ql, True)
26+
execute_protocol_notifications(ql, True)
2727

2828
return EFI_SUCCESS
2929

qiling/os/uefi/bs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def hook_InstallMultipleProtocolInterfaces(ql: Qiling, address: int, params):
436436
index += 2
437437

438438
ql.loader.dxe_context.protocols[handle] = dic
439-
check_and_notify_protocols(ql, True)
439+
execute_protocol_notifications(ql, True)
440440
write_int64(ql, params["Handle"], handle)
441441

442442
return EFI_SUCCESS

qiling/os/uefi/utils.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,6 @@ def __notify_next(ql: Qiling):
6363

6464
return True
6565

66-
def check_and_notify_protocols(ql: Qiling, from_hook: bool = False) -> bool:
67-
if ql.loader.notify_list:
68-
event_id, notify_func, notify_context = ql.loader.notify_list.pop(0)
69-
ql.log.info(f'Notify event: id = {event_id}, calling: {notify_func:#x} context: {notify_context}')
70-
71-
if from_hook:
72-
# When running from a hook the caller pops the return address from the stack.
73-
# We need to push the address to the stack as opposed to setting it to the instruction pointer.
74-
ql.loader.call_function(0, notify_context, notify_func)
75-
else:
76-
ql.loader.call_function(notify_func, notify_context, ql.loader.context.end_of_execution_ptr)
77-
78-
return True
79-
80-
return False
81-
8266
def ptr_read8(ql: Qiling, addr: int) -> int:
8367
"""Read BYTE data from a pointer
8468
"""

0 commit comments

Comments
 (0)