mirror of
https://github.com/qilingframework/qiling.git
synced 2026-10-12 02:21:40 +00:00
Use align and align_up where appropriate
This commit is contained in:
@@ -11,8 +11,8 @@ from qiling.const import QL_VERBOSE
|
||||
def mem_crash(ql: Qiling, access: int, address: int, size: int, value: int):
|
||||
print(f'got crash')
|
||||
|
||||
PAGE_SIZE = 0x1000
|
||||
aligned = address & ~(PAGE_SIZE - 1)
|
||||
PAGE_SIZE = ql.mem.pagesize
|
||||
aligned = ql.mem.align(address)
|
||||
|
||||
# map the entire page containing the invalid address and fill it with 'Q's
|
||||
ql.mem.map(aligned, PAGE_SIZE)
|
||||
|
||||
@@ -42,7 +42,7 @@ from PyQt5 import QtCore, QtWidgets
|
||||
from PyQt5.QtWidgets import (QPushButton, QHBoxLayout)
|
||||
|
||||
# Qiling
|
||||
from qiling import *
|
||||
from qiling import Qiling
|
||||
from qiling.const import *
|
||||
from qiling.arch.x86_const import reg_map_32 as x86_reg_map_32
|
||||
from qiling.arch.x86_const import reg_map_64 as x86_reg_map_64
|
||||
@@ -1568,16 +1568,16 @@ class QlEmuPlugin(plugin_t, UI_Hooks):
|
||||
self.paths[start_bb_id].append(cur_bb.id)
|
||||
ql.emu_stop()
|
||||
|
||||
def _skip_unmapped_rw(self, ql, type, addr, size, value):
|
||||
alignment = 0x1000
|
||||
# Round down
|
||||
map_addr = addr & (~(alignment - 1))
|
||||
# Round up
|
||||
map_size = ((size + (alignment - 1)) & (~(alignment - 1)))
|
||||
def _skip_unmapped_rw(self, ql: Qiling, type, addr, size, value):
|
||||
map_addr = ql.mem.align(addr)
|
||||
map_size = ql.mem.align_up(size)
|
||||
|
||||
if not ql.mem.is_mapped(map_addr, map_size):
|
||||
logging.warning(f"Invalid memory R/W, trying to map {hex(map_size)} at {hex(map_addr)}")
|
||||
|
||||
ql.mem.map(map_addr, map_size)
|
||||
ql.mem.write(map_addr, b'\x00'*map_size)
|
||||
ql.mem.write(map_addr, b'\x00' * map_size)
|
||||
|
||||
return True
|
||||
|
||||
def _find_branch_in_real_block(self, bb):
|
||||
|
||||
@@ -84,11 +84,12 @@ def syscall_mmap_impl(ql: Qiling, addr: int, mlen: int, prot: int, flags: int, f
|
||||
|
||||
need_mmap = True
|
||||
mmap_base = addr
|
||||
mmap_size = (mlen - (addr & (pagesize - 1)) + pagesize - 1) & ~(pagesize - 1)
|
||||
mmap_size = ql.mem.align_up(mlen - ql.mem.align(addr))
|
||||
|
||||
if ql.ostype != QL_OS.QNX:
|
||||
mmap_base &= ~(pagesize - 1)
|
||||
if (flags & MAP_FIXED) > 0 and mmap_base != addr:
|
||||
mmap_base = ql.mem.align(mmap_base)
|
||||
|
||||
if (flags & MAP_FIXED) and mmap_base != addr:
|
||||
return MAP_FAILED
|
||||
|
||||
# initial ql.loader.mmap_address
|
||||
|
||||
Reference in New Issue
Block a user