GJDuck / e9patch

A powerful static binary rewriting tool
GNU General Public License v3.0
964 stars 65 forks source link

Newbie to this tool but met with something wrong. #66

Closed Ganliber closed 12 months ago

Ganliber commented 12 months ago

Hi, I write a simple program like

#include <stdio.h>

void c() {
        printf("this is c\n");
}

void b() {
        printf("this is b\n\t");
        c();
}

int main() {
        c();
        b();
        return 0;
}

but when I use this tool as what the guide writes, errors reported as follows:

$ e9tool -M jmp -P print a.out
..........
+MMMMM+MMM
[0000000000000000FF00000000073E00][071E000000000001C00000000001FF00]
error: failed to write output to file "a.out": Bad address
error  : backend process (1273318) exitted with a non-zero status (1)

I am confused...

GJDuck commented 12 months ago

The problem is that the input and output binary have the same name (a.out). You should be able to fix it by specifying a different name for the output binary:

    $ e9tool -M jmp -P print a.out -o b.out

I should add a more user-friendly error message for this problem.

Ganliber commented 12 months ago

Thank you very much!