Skip to content

Commit f46b96d

Browse files
committed
Modify call_function to use call_native
1 parent 2302dfc commit f46b96d

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

qiling/loader/pe_uefi.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from qiling.const import QL_ARCH
1111
from qiling.exception import QlErrorArch, QlMemoryMappedError
1212
from qiling.loader.loader import QlLoader, Image
13-
from qiling.os.const import POINTER
13+
from qiling.os.const import PARAM_INTN, POINTER
1414

1515
from qiling.os.uefi import st, smst, utils
1616
from qiling.os.uefi.context import DxeContext, SmmContext, UefiContext
@@ -144,19 +144,10 @@ def call_function(self, addr: int, args: Sequence[int], ret: Optional[int]):
144144
ret : return address; may be None
145145
"""
146146

147-
# arguments gpr (ms x64 cc)
148-
regs = ('rcx', 'rdx', 'r8', 'r9')
149-
assert len(args) <= len(regs), f'currently supporting up to {len(regs)} arguments'
147+
types = (PARAM_INTN, ) * len(args)
148+
targs = tuple(zip(types, args))
150149

151-
# set up the arguments
152-
for reg, arg in zip(regs, args):
153-
self.ql.reg.write(reg, arg)
154-
155-
# if provided, set return address
156-
if ret is not None:
157-
self.ql.stack_push(ret)
158-
159-
self.ql.reg.rip = addr
150+
self.ql.os.fcall.call_native(addr, targs, ret)
160151

161152
def unload_modules(self, context: UefiContext) -> bool:
162153
"""Invoke images unload callbacks, if set.

0 commit comments

Comments
 (0)