Skip to content

MapViewOfFile ¤

convert_prot ¤

convert_prot(prot)

Convert from a windows memory protection constant to an angr bitmask

Source code in sema_toolchain/sema_scdg/application/procedures/windows/custom_package/MapViewOfFile.py
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
def convert_prot(prot):
    """
    Convert from a windows memory protection constant to an angr bitmask
    """
    # https://msdn.microsoft.com/en-us/library/windows/desktop/aa366786(v=vs.85).aspx
    if prot & 0x10:
        return 4
    if prot & 0x20:
        return 5
    if prot & 0x40:
        return 7
    if prot & 0x80:
        return 7
    if prot & 0x01:
        return 0
    if prot & 0x02:
        return 1
    if prot & 0x04:
        return 3
    if prot & 0x08:
        return 3
    raise angr.errors.SimValueError("Unknown windows memory protection constant: %#x" % prot)

deconvert_prot ¤

deconvert_prot(prot)

Convert from a angr bitmask to a windows memory protection constant

Source code in sema_toolchain/sema_scdg/application/procedures/windows/custom_package/MapViewOfFile.py
 95
 96
 97
 98
 99
100
101
def deconvert_prot(prot):
    """
    Convert from a angr bitmask to a windows memory protection constant
    """
    if prot in (2, 6):
        raise angr.errors.SimValueError("Invalid memory protection for windows process")
    return [0x01, 0x02, None, 0x04, 0x10, 0x20, None, 0x40][prot]