32 lines
827 B
Python
32 lines
827 B
Python
|
#! /usr/bin/env python
|
||
|
# encoding: utf-8
|
||
|
|
||
|
import struct
|
||
|
import mmap
|
||
|
import ctypes
|
||
|
|
||
|
class Sins:
|
||
|
def __init__(self):
|
||
|
self.seed = open('./build/scrap.asm.2.o', 'rb').read()
|
||
|
self.pic = self.pic_load()
|
||
|
|
||
|
def pic_load(self):
|
||
|
prot = (mmap.PROT_READ | mmap.PROT_WRITE | mmap.PROT_EXEC)
|
||
|
page = mmap.mmap(-1, len(self.seed), prot=prot)
|
||
|
page.write(self.seed)
|
||
|
addr = ctypes.addressof((ctypes.c_char * len(self.seed)).from_buffer(page))
|
||
|
func = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint)(addr)
|
||
|
func.page = page
|
||
|
|
||
|
return func(addr, len(self.seed))
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
import pprint
|
||
|
pp = pprint.PrettyPrinter()
|
||
|
|
||
|
sins = Sins()
|
||
|
print('Seed')
|
||
|
pp.pprint(sins.seed)
|
||
|
print('pic_load')
|
||
|
pp.pprint(sins.pic_load())
|