1
0
Fork 0
cp-templates/asm.py

15 lines
429 B
Python
Raw Normal View History

2024-02-11 16:02:26 +08:00
import time
from ctypes import *
import mmap
buf=mmap.mmap(-1,mmap.PAGESIZE,prot=mmap.PROT_READ|mmap.PROT_WRITE|mmap.PROT_EXEC)
def compile_asm_raw(s,ftype):
buf.write(s)
return ftype(addressof(c_void_p.from_buffer(buf)))
#https://gcc.godbolt.org/
#https://defuse.ca/online-x86-assembler.htm
#order: edi,esi,edx,ecx,r8d
asm_solve=compile_asm_raw(b"", CFUNCTYPE(c_void_p, POINTER(c_int), c_int, c_int, POINTER(c_int)))