Skip to content

Commit

Permalink
Fixes related to latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
elicn committed Jul 2, 2024
1 parent 055d474 commit 4371215
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 4 additions & 6 deletions qiling/os/posix/syscall/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ def __getrlimit_common(ql: Qiling, res: int, rlim: int) -> int:
else:
rlimit = resource.getrlimit(res)

# FIXME: not sure whether these should be pointersize values or always 32 bits
ql.mem.write_ptr(rlim + 0 * 4, rlimit[0], 4, signed=True)
ql.mem.write_ptr(rlim + 1 * 4, rlimit[1], 4, signed=True)
ql.mem.write_ptr(rlim + 0 * ql.arch.pointersize, rlimit[0], signed=True)
ql.mem.write_ptr(rlim + 1 * ql.arch.pointersize, rlimit[1], signed=True)

return 0

Expand All @@ -57,9 +56,8 @@ def ql_syscall_prlimit64(ql: Qiling, pid: int, res: int, new_limit: int, old_lim
try:
rlim = resource.getrlimit(res)

# FIXME: not sure whether these should be pointersize values or always 32 bits
ql.mem.write_ptr(old_limit + 0 * 4, rlim[0], 4, signed=True)
ql.mem.write_ptr(old_limit + 1 * 4, rlim[1], 4, signed=True)
ql.mem.write_ptr(old_limit + 0 * ql.arch.pointersize, rlim[0], signed=True)
ql.mem.write_ptr(old_limit + 1 * ql.arch.pointersize, rlim[1], signed=True)

return 0
except:
Expand Down
3 changes: 2 additions & 1 deletion qiling/os/windows/dlls/kernel32/fileapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,10 @@ def _CreateFileMapping(ql: Qiling, address: int, params):
dwMaximumSizeLow = params['dwMaximumSizeLow']
lpName = params['lpName']

hFile = ql.os.utils.as_signed(hFile, ql.arch.bits)
req_size = (dwMaximumSizeHigh << 32) | dwMaximumSizeLow

if hFile == ql.os.utils.as_signed(INVALID_HANDLE_VALUE, ql.arch.bits):
if hFile == INVALID_HANDLE_VALUE:
fmobj = FileMappingMem()

else:
Expand Down
7 changes: 6 additions & 1 deletion tests/test_pe_sys.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
#
#
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
#

Expand All @@ -8,6 +8,8 @@

from unicorn import UcError

from qiling.os.stats import QlWinNullStats

sys.path.append("..")
from qiling import Qiling
from qiling.const import QL_STOP, QL_VERBOSE
Expand Down Expand Up @@ -181,6 +183,9 @@ def hook_third_stop_address(ql: Qiling, stops: List[bool]):

ql = Qiling(["../examples/rootfs/x86_windows/bin/sality.dll"], "../examples/rootfs/x86_windows", verbose=QL_VERBOSE.DEBUG)

# discard strings and api calls stats to gain a bit of speedup
ql.os.stats = QlWinNullStats()

# emulate some Windows API
ql.os.set_api("CreateThread", hook_CreateThread)
ql.os.set_api("CreateFileA", hook_CreateFileA)
Expand Down

0 comments on commit 4371215

Please sign in to comment.