User talk:Alcoholicspinesurgeon: Difference between revisions
Content added Content deleted
(Created page with "<syntaxhighlight lang="nasm"> ;; ;; -->> {{ LibLinux - Captured and ready for meat testing }} <<-- ;; I miss you cupcake. ;; %ifndef LIBLINUX_INC %define LIBLINUX_INC ;; the allmighty defined! %define PROT_READ 1 %define PROT_WRITE 2 %define PROT_EXEC 4 %define PROT_NONE 0 %define PROT_GDOWN 0x01 %define PROT_GROWU 0x02 %define MAP_SHARE 0x01 %define MAP_PRIVATE 0x02 %define...") |
(Blanked the page) Tag: Blanking |
||
Line 1: | Line 1: | ||
<syntaxhighlight lang="nasm"> |
|||
;; |
|||
;; -->> {{ LibLinux - Captured and ready for meat testing }} <<-- |
|||
;; I miss you cupcake. |
|||
;; |
|||
%ifndef LIBLINUX_INC |
|||
%define LIBLINUX_INC |
|||
;; the allmighty defined! |
|||
%define PROT_READ 1 |
|||
%define PROT_WRITE 2 |
|||
%define PROT_EXEC 4 |
|||
%define PROT_NONE 0 |
|||
%define PROT_GDOWN 0x01 |
|||
%define PROT_GROWU 0x02 |
|||
%define MAP_SHARE 0x01 |
|||
%define MAP_PRIVATE 0x02 |
|||
%define MAP_FIXED 0x10 |
|||
%define MAP_FILE 0 |
|||
%define MAP_ANON 0x20 |
|||
%define MAP_32BIT 0x40 |
|||
;;msync flags |
|||
%define MS_ASYNC 1 |
|||
%define MS_SYNC 4 |
|||
%define MS_INVALIDATE 2 |
|||
;;Just cause I use them sometimes |
|||
%define MREMAP_MAYMOVE 1 |
|||
%define MREMAP_FIXED 2 |
|||
;; Syscall defines, macro'd for extra flavour |
|||
;; actually I'm just lazy or drunk. or both... |
|||
%macro sysdef 2 |
|||
%define sys_%1 %2 |
|||
%endmacro |
|||
sysdef read, 0 |
|||
sysdef write, 1 |
|||
sysdef open, 2 |
|||
sysdef close, 3 |
|||
sysdef poll, 7 |
|||
sysdef mmap, 9 |
|||
sysdef mprotect, 10 |
|||
sysdef munmap, 11 |
|||
sysdef sigaction, 13 |
|||
sysdef sigprocmask, 14 |
|||
sysdef sigreturn, 15 |
|||
sysdef ioctl, 16 |
|||
sysdef pread, 17 |
|||
sysdef pwrite, 18 |
|||
sysdef select, 23 |
|||
sysdef mremap, 25 |
|||
sysdef msync, 26 |
|||
sysdef pause, 34 |
|||
sysdef nanosleep, 35 |
|||
sysdef getitimer, 36 |
|||
sysdef alarm, 37 |
|||
sysdef setitimer, 38 |
|||
sysdef getpid, 39 |
|||
sysdef socket, 41 |
|||
sysdef connect, 42 |
|||
sysdef accept, 43 |
|||
sysdef bind, 49 |
|||
sysdef listen, 50 |
|||
sysdef clone, 56 |
|||
sysdef fork, 57 |
|||
sysdef exit, 60 |
|||
;; Libc imports - For his and her pleasure. |
|||
extern printf |
|||
extern vsnprintf |
|||
extern fprintf |
|||
extern strerror |
|||
extern malloc |
|||
extern free |
|||
extern dlopen |
|||
extern dlclose |
|||
extern dlsym |
|||
extern dlerror |
|||
;; Lazy macros for lazy people |
|||
%macro prolog 1 |
|||
push rbp |
|||
mov rbp, rsp |
|||
sub rsp, %1 |
|||
%endmacro |
|||
%macro epilog 1 |
|||
add rsp, %1 |
|||
pop rbp |
|||
%endmacro |
|||
;;default rel does some crazy shit |
|||
;;so here we are because of it. T_T |
|||
%macro xcall 1 |
|||
call [rel %1 wrt ..got] |
|||
%endmacro |
|||
%macro xlea 2 |
|||
lea %1, [rel %2] |
|||
%endmacro |
|||
;; Syscall macro.. |
|||
;; Everything is optional. |
|||
;; EXCEPT for the syscall name |
|||
;; which can be done without |
|||
;; adding the sys_part. ^_^ |
|||
;; so exit for example would be |
|||
;; |
|||
;; inv exit, 0 |
|||
;; all unused parameters default to 0. |
|||
%macro inv 1-7 0,0,0,0,0,0 |
|||
mov r9,%7 |
|||
mov r8,%6 |
|||
mov r10,%5 |
|||
mov rdx,%4 |
|||
mov rsi,%3 |
|||
mov rdi,%2 |
|||
mov rax,sys_%1 |
|||
syscall |
|||
%endmacro |
|||
%macro va_start 2 |
|||
mov dword [%1], %2 |
|||
mov dword [rbp-0xcc], 0x30 |
|||
lea rax, [rbp-0x10] |
|||
mov qword [rbp-0xc8], rax |
|||
lea rax, [rbp-0xb0] |
|||
mov qword [rbp-0xc0], rax |
|||
%endmacro |
|||
%endif |
|||
</syntaxhighlight> |