I need some machine code to give me the current pid. I got the following syscalls 4 = write and 20 = getpid , This is the code I used from another source.
SECTION .data
LookUpDig db "0123456789"
PIDString db "PID: "
PIDLength equ $-PIDString
SECTION .bss
PID: resb 8
SECTION .text
global _start
_start:
mov eax, 20
int 0x80
mov ebx, 0xA
lea ebp, [PID+6]
ASCIIConv:
div ebx
mov byte cl, [LookUpDig+edx]
mov [ebp], cl
dec ebp
xor edx, edx
inc eax
dec eax
jnz ASCIIConv
jz .printOut
.printOut:
push PIDLength
push PIDString
push 0x1
mov eax, 4
push eax
int 0x80
add esp, 0x10
mov [PID+7], byte 0xA
push 0x8
push PID
push 0x1
mov eax, 4
push eax
int 0x80
add esp, 0x10
mov eax, 0x1
push 0x0
int 0x80
I use this to compile it:
nasm -f elf32 -o try.o try.asm
ld -m elf_i386 -o try try.o
Where try is the asm file im working with. The output I get is nothing and it return normally.
Thanks for any help! :) NOTE: First time ever Ive dealt with Assembly