コード例 #1
0
ファイル: datatypes.py プロジェクト: clayne/syringe-1
    def details(self):
        bytes_per_row = 8
        iterable = iter(bitmap.string(self.bitmap()))
        rows = izip_longest(*[iterable] * 8 * bytes_per_row)
        res = map(lambda columns: (' ' if column is None else column for column in columns), rows)
        items = map(str().join, res)

        width = len("{:x}".format(self.bits()))
        return '\n'.join(("[{:x}] {{{:0{:d}x}:{:0{:d}x}}} {:s}".format(self.getoffset() + i * bytes_per_row, 8 * i * bytes_per_row, width, min(self.bits(), 8 * i * bytes_per_row + 8 * bytes_per_row) - 1, width, item) for i, item in enumerate(items)))
コード例 #2
0
ファイル: bitmap.py プロジェクト: lotusexpeditor/syringe
    def set_bitmap_unsigned():
        x = bitmap.new(0xf000000000000000, 64)
        #x = bitmap.set(x, 60, count=4)
        print(bitmap.string(x))

        y, res = bitmap.shift(x, 4)
        print(res, bitmap.string(y))

        x = bitmap.new(0, 0)
        x = bitmap.push(x, (0x1, 4))
        x = bitmap.push(x, (0x2, 4))
        x = bitmap.push(x, (0x3, 4))
        x = bitmap.push(x, (0x4, 4))
        print(x, bitmap.string(x))

        x = bitmap.new(0, 0)
        x = bitmap.insert(x, (0x1, 4))
        x = bitmap.insert(x, (0x2, 4))
        x = bitmap.insert(x, (0x3, 4))
        x = bitmap.insert(x, (0x4, 4))
        print(x, bitmap.string(x))

        x = bitmap.consumer(b'\x12\x34')
        print(x.consume(4))
        print(x.consume(4))
        print(x.consume(4))
        print(x.consume(4))

        x = bitmap.new(0, 4)
        for i in range(6):
            print(x)
            x = bitmap.add(x, 3)

        for i in range(6):
            print(x)
            x = bitmap.sub(x, 6)

        x = bitmap.new(4, 4)
        print(bitmap.string(bitmap.ror(bitmap.ror(bitmap.ror(x)))))
コード例 #3
0
ファイル: datatypes.py プロジェクト: lotusexpeditor/syringe
    def details(self):
        bytes_per_item = self.new(self._object_).a.size()
        bits_per_item = bytes_per_item * 8
        bytes_per_row = bytes_per_item * (1 if self.bits() < 0x200 else 2)
        bits_per_row = bits_per_item * (1 if self.bits() < 0x200 else 2)

        items = bitmap.split(self.bitmap(), bits_per_row)

        width = len("{:x}".format(self.bits()))
        return '\n'.join(("[{:x}] {{{:0{:d}x}:{:0{:d}x}}} {:s}".format(
            self.getoffset() + i * bytes_per_row, i * bits_per_row, width,
            min(self.bits(), i * bits_per_row + bits_per_row) - 1, width,
            bitmap.string(item)) for i, item in enumerate(items)))
コード例 #4
0
ファイル: __init__.py プロジェクト: d0c-s4vage/syringe
    def __alloc_from_bucket(self, bucket, size):
        for i,n in zip(range(len(bucket)), bucket):
            pointer,(chunksize,layout) = n
            count = (size / chunksize)+1

            try:
                freeslot = bitmap.runscan(layout, 0, count)
            except ValueError:
                raise NotImplementedError('none free in index %d -> %s'% (i, bitmap.string(layout)))    # just because i haven't done this test case yet
                continue

            layout = bitmap.set(layout, freeslot, 1, count)

            # found a free slot, write it directly into bucket
            bucket[i] = (pointer, (chunksize, layout))
            return pointer + freeslot*chunksize, bucket[i]

        raise ValueError('Unable to allocate %d bytes out of bucket %s'% (size, repr(bucket)))
コード例 #5
0
    def __alloc_from_bucket(self, bucket, size):
        for i, n in zip(range(len(bucket)), bucket):
            pointer, (chunksize, layout) = n
            count = (size // chunksize) + 1

            try:
                freeslot = bitmap.runscan(layout, 0, count)
            except ValueError:
                raise NotImplementedError(
                    'none free in index %d -> %s' % (i, bitmap.string(layout))
                )  # just because i haven't done this test case yet
                continue

            layout = bitmap.set(layout, freeslot, 1, count)

            # found a free slot, write it directly into bucket
            bucket[i] = (pointer, (chunksize, layout))
            return pointer + freeslot * chunksize, bucket[i]

        raise ValueError(
            'Unable to allocate {:d} bytes out of bucket {!r}'.format(
                size, bucket))
コード例 #6
0
ファイル: bitmap.py プロジェクト: arizvisa/syringe
    def set_bitmap_unsigned():
        x = bitmap.new(0xf000000000000000,64)
        #x = bitmap.set(x, 60, count=4)
        print bitmap.string(x)

        y,res = bitmap.shift(x, 4)
        print res,bitmap.string(y)

        x = bitmap.new(0,0)
        x = bitmap.push(x, (0x1,4) )
        x = bitmap.push(x, (0x2,4) )
        x = bitmap.push(x, (0x3,4) )
        x = bitmap.push(x, (0x4,4) )
        print x,bitmap.string(x)

        x = bitmap.new(0,0)
        x = bitmap.insert(x, (0x1,4) )
        x = bitmap.insert(x, (0x2,4) )
        x = bitmap.insert(x, (0x3,4) )
        x = bitmap.insert(x, (0x4,4) )
        print x,bitmap.string(x)

        x = bitmap.consumer('\x12\x34')
        print x.consume(4)
        print x.consume(4)
        print x.consume(4)
        print x.consume(4)

        x = bitmap.new(0, 4)
        for i in six.moves.range(6):
            print x
            x = bitmap.add(x, 3)

        for i in six.moves.range(6):
            print x
            x = bitmap.sub(x, 6)

        x = bitmap.new(4,4)
        print bitmap.string(bitmap.ror(bitmap.ror(bitmap.ror(x))))
コード例 #7
0
ファイル: as3.py プロジェクト: lotusexpeditor/syringe
 def details(self):
     bmp = self.bitmap()
     return ' '.join([bitmap.repr(bmp), bitmap.string(bmp)])
コード例 #8
0
ファイル: as3.py プロジェクト: arizvisa/syringe
 def details(self):
     bmp = self.bitmap()
     return ' '.join([bitmap.repr(bmp), bitmap.string(bmp)])
コード例 #9
0
                x &= mask

        result.append(x)

    return special, tuple(result)


def decode(string, *args, **kwds):
    return consume(iter(string), *args, **kwds)


if True:
    a = bitmap.new(0x0b058547, 32)
    b = bitmap.data(a)

    print bitmap.string(a)
    j, (instr_index, ) = decode(b)
    print hex(instr_index << 2)

    #RAM:8C161580 0B 05 85 47                             j       loc_9FC7A134     # [note] simulator branches to 8c16151c
    #AC 82 00 00
    #ROM:9FC7A138 14 40 FF D0                             bnez    $v0, loc_9FC7A07C
    #RAM:8C161560 14 40 FF D0                             bnez    $v0, loc_9FC7A0BC  # 8c1614a4 #8c161564

if True:
    a = bitmap.new(0x1440ffd0, 32)
    b = bitmap.data(a)

    addr, (bne, (rs, rt, offset)) = 0x8c161560, decode(b, (5, 5, -16))
    print '%x: bne $%d, $%d, %x   # %x' % (addr, rs, rt, offset, addr + 4 +
                                           (offset * 4))
コード例 #10
0
ファイル: macheap.py プロジェクト: KorayAgaya/MacHeap
 def summary(self):
     res = self.bitmap()
     return '0x{:0{:d}x} bitmap:{:s}'.format(self.int(), self.size()*2, bitmap.string(res))
コード例 #11
0
ファイル: macheap.py プロジェクト: KorayAgaya/MacHeap
 def summary(self):
     res = self.bitmap()
     align = ' ' if self.name() == 'inuse' else ''
     return align+'0x{:0{:d}x} bitmap:{:s}'.format(self.int(), self.size()*2, bitmap.string(res))
コード例 #12
0
ファイル: macheap.py プロジェクト: mr-wrmsr/BlackServerOS
 def summary(self):
     res = self.bitmap()
     return '0x{:0{:d}x} bitmap:{:s}'.format(
         self.int(),
         self.size() * 2, bitmap.string(res))
コード例 #13
0
ファイル: macheap.py プロジェクト: mr-wrmsr/BlackServerOS
 def summary(self):
     res = self.bitmap()
     align = ' ' if self.name() == 'inuse' else ''
     return align + '0x{:0{:d}x} bitmap:{:s}'.format(
         self.int(),
         self.size() * 2, bitmap.string(res))
コード例 #14
0
ファイル: mips64.py プロジェクト: lotusexpeditor/syringe
                x *= -1
            else:
                x &= mask

        result.append(x)

    return special,tuple(result)

def decode(string, *args, **kwds):
    return consume( iter(string), *args, **kwds )

if True:
    a = bitmap.new(0x0b058547, 32)
    b = bitmap.data(a)

    print(bitmap.string(a))
    j,(instr_index,) = decode(b)
    print(hex(instr_index<<2))

    #RAM:8C161580 0B 05 85 47                             j       loc_9FC7A134     # [note] simulator branches to 8c16151c
    #AC 82 00 00
    #ROM:9FC7A138 14 40 FF D0                             bnez    $v0, loc_9FC7A07C
    #RAM:8C161560 14 40 FF D0                             bnez    $v0, loc_9FC7A0BC  # 8c1614a4 #8c161564

if True:
    a = bitmap.new(0x1440ffd0, 32)
    b = bitmap.data(a)

    addr,(bne,(rs,rt,offset)) = 0x8c161560, decode(b, (5,5,-16))
    print('%x: bne $%d, $%d, %x   # %x'%(addr, rs,rt,offset, addr+4+(offset*4)))
コード例 #15
0
ファイル: mips64.py プロジェクト: arizvisa/syringe
                x *= -1
            else:
                x &= mask

        result.append(x)

    return special,tuple(result)

def decode(string, *args, **kwds):
    return consume( iter(string), *args, **kwds )

if True:
    a = bitmap.new(0x0b058547, 32)
    b = bitmap.data(a)

    print bitmap.string(a)
    j,(instr_index,) = decode(b)
    print hex(instr_index<<2)

    #RAM:8C161580 0B 05 85 47                             j       loc_9FC7A134     # [note] simulator branches to 8c16151c
    #AC 82 00 00
    #ROM:9FC7A138 14 40 FF D0                             bnez    $v0, loc_9FC7A07C
    #RAM:8C161560 14 40 FF D0                             bnez    $v0, loc_9FC7A0BC  # 8c1614a4 #8c161564

if True:
    a = bitmap.new(0x1440ffd0, 32)
    b = bitmap.data(a)

    addr,(bne,(rs,rt,offset)) = 0x8c161560, decode(b, (5,5,-16))
    print '%x: bne $%d, $%d, %x   # %x'%(addr, rs,rt,offset, addr+4+(offset*4))