Skip to content

Commit 187e0f3

Browse files
authored
Merge pull request #945 from SwordFaith/swordfaith-fix-setmem
Fix bytes api misuse bug
2 parents dff536b + 7b7a921 commit 187e0f3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

qiling/os/uefi/bs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from binascii import crc32
77

8+
from qiling.const import QL_ENDIAN
89
from qiling.os.const import *
910
from qiling.os.uefi.const import *
1011
from qiling.os.uefi.fncc import dxeapi
@@ -494,10 +495,11 @@ def hook_CopyMem(ql: Qiling, address: int, params):
494495
})
495496
def hook_SetMem(ql: Qiling, address: int, params):
496497
buffer = params["Buffer"]
497-
value = params["Value"] & 0xff
498+
value: int = params["Value"] & 0xff
498499
size = params["Size"]
499500

500-
ql.mem.write(buffer, bytes(value) * size)
501+
byteorder = 'little' if ql.archendian == QL_ENDIAN.EL else 'big'
502+
ql.mem.write(buffer, bytes([value]) * size)
501503

502504
@dxeapi(params = {
503505
"Type" : UINT, # UINT32

0 commit comments

Comments
 (0)