I'm learning reversing and for that i use Ghidra. There is program i'm trying to modify so i can recompile it and make it work. I have a code that ghidra decompile like this: data=function(4) Going inside the function i think to make it work i need to pass a zero. in the assembly i can read:
PUSH RBP MOV RBP,RSP MOV EDI,0x4 CALL function MOV qword ptr [data],RAX
What i understand from that (and i'm propably wrong) is that the MOV EDI,0x4 is the 4 given in the function so i tried to rewrite it in Ghidra with 0x0 and it replace the:
bf 04 00 00 00 with bf 00 00 00 00
I thought it would be enough and i exported as an ELF but when i start the program i get a segmentation fault so i guess i'm doing something wrong with the memory.
(gdb) x/10xi $rip => 0x555555401888: mov (%rax),%rax 0x55555540188b: test %rax,%rax 0x55555540188e: jne 0x55555540189a 0x555555401890: mov $0x0,%eax 0x555555401895: jmp 0x55555540199d 0x55555540189a: movq $0x0,-0x50(%rbp) 0x5555554018a2: mov -0x60(%rbp),%rax 0x5555554018a6: mov %rax,%rdi 0x5555554018a9: call 0x5555554008f0 <strlen@plt> 0x5555554018ae: mov %rax,-0x48(%rbp)
I would like some help to understand what i'm doing wrong.