From 91bc014b6663937eab0e8b82c4d2c5fde46757c1 Mon Sep 17 00:00:00 2001 From: Ariel Date: Sun, 11 Feb 2024 16:02:26 +0800 Subject: [PATCH] Create asm.py --- asm.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 asm.py diff --git a/asm.py b/asm.py new file mode 100644 index 0000000..5585995 --- /dev/null +++ b/asm.py @@ -0,0 +1,14 @@ +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)))