Skip to content

Commit f49d35d

Browse files
authored
Merge pull request #682 from assafcarlsbad/signal_event_on_install_protocol
Signal event upon InstallProtocolInterface.
2 parents b5e88ab + 811312a commit f49d35d

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

qiling/os/uefi/bs.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,7 @@ def hook_SignalEvent(ql, address, params):
132132
event_id = params["Event"]
133133

134134
if event_id in ql.loader.events:
135-
event = ql.loader.events[event_id]
136-
137-
if not event["Set"]:
138-
event["Set"] = True
139-
notify_func = event["NotifyFunction"]
140-
notify_context = event["NotifyContext"]
141-
ql.loader.notify_list.append((event_id, notify_func, notify_context))
142-
135+
signal_event(ql, event_id)
143136
return EFI_SUCCESS
144137
else:
145138
return EFI_INVALID_PARAMETER

qiling/os/uefi/protocols/common.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55

66
from qiling.os.uefi.const import EFI_SUCCESS, EFI_NOT_FOUND, EFI_UNSUPPORTED, EFI_BUFFER_TOO_SMALL, EFI_INVALID_PARAMETER
7-
from qiling.os.uefi.utils import read_int64, write_int64, check_and_notify_protocols
7+
from qiling.os.uefi.utils import read_int64, write_int64, check_and_notify_protocols, signal_event
88
from qiling.os.uefi.UefiSpec import EFI_LOCATE_SEARCH_TYPE
99

1010
# TODO: get rid of this
@@ -37,6 +37,12 @@ def InstallProtocolInterface(context, params):
3737

3838
dic[params["Protocol"]] = params["Interface"]
3939
context.protocols[handle] = dic
40+
41+
for (event_id, event_dic) in context.ql.loader.events.items():
42+
if event_dic['Guid'] == params['Protocol']:
43+
# The event was previously registered by 'RegisterProtocolNotify'.
44+
signal_event(context.ql, event_id)
45+
4046
check_and_notify_protocols(context.ql)
4147
write_int64(context.ql, params["Handle"], handle)
4248

qiling/os/uefi/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
from qiling.os.uefi.UefiSpec import EFI_CONFIGURATION_TABLE, EFI_SYSTEM_TABLE
1313
from qiling.os.uefi.UefiBaseType import EFI_GUID
1414

15+
def signal_event(ql, event_id: int) -> None:
16+
event = ql.loader.events[event_id]
17+
18+
if not event["Set"]:
19+
event["Set"] = True
20+
notify_func = event["NotifyFunction"]
21+
notify_context = event["NotifyContext"]
22+
ql.loader.notify_list.append((event_id, notify_func, notify_context))
23+
1524
def check_and_notify_protocols(ql) -> bool:
1625
if ql.loader.notify_list:
1726
event_id, notify_func, notify_context = ql.loader.notify_list.pop(0)

0 commit comments

Comments
 (0)