Last active
August 14, 2018 04:04
-
-
Save Barakat/ae93fc42d9a3c21faa7333e1664b77ea to your computer and use it in GitHub Desktop.
Decompile C++ into C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
typedef struct _Object | |
{ | |
int x; | |
int y; | |
} Object; | |
void | |
Object_init(Object *this, int x, int y) | |
{ | |
this->x = x; | |
this->y = y; | |
} | |
void | |
Object_foo0(Object *this) | |
{ | |
printf("Object::foo %d\n", this->x); | |
} | |
void | |
Object_foo1(Object *this, int z) | |
{ | |
printf("Object::foo %d, %d, %d\n", this->x, this->y, z); | |
} | |
int | |
main() | |
{ | |
Object object; | |
Object_init(&object, 1, 2); | |
Object_foo0(&object); | |
Object_foo1(&object, 3); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object_init(Object *, int, int) proc near | |
arg_0= qword ptr 10h | |
arg_8= dword ptr 18h | |
arg_10= dword ptr 20h | |
push rbp | |
mov rbp, rsp | |
mov [rbp+arg_0], rcx | |
mov [rbp+arg_8], edx | |
mov [rbp+arg_10], r8d | |
mov rax, [rbp+arg_0] | |
mov edx, [rbp+arg_8] | |
mov [rax], edx | |
mov rax, [rbp+arg_0] | |
mov edx, [rbp+arg_10] | |
mov [rax+4], edx | |
nop | |
pop rbp | |
retn | |
Object_init(Object *, int, int) endp | |
------------------------------------------------------------------------------- | |
Object_foo0(Object *) proc near | |
arg_0= qword ptr 10h | |
push rbp | |
mov rbp, rsp | |
sub rsp, 20h | |
mov [rbp+arg_0], rcx | |
mov rax, [rbp+arg_0] | |
mov eax, [rax] | |
mov edx, eax | |
lea rcx, Format ; "Object::foo %d\n" | |
call printf | |
nop | |
add rsp, 20h | |
pop rbp | |
retn | |
Object_foo0 endp | |
------------------------------------------------------------------------------- | |
Object_foo1(Object *, int) proc near | |
arg_0= qword ptr 10h | |
arg_8= dword ptr 18h | |
push rbp | |
mov rbp, rsp | |
sub rsp, 20h | |
mov [rbp+arg_0], rcx | |
mov [rbp+arg_8], edx | |
mov rax, [rbp+arg_0] | |
mov edx, [rax+4] | |
mov rax, [rbp+arg_0] | |
mov eax, [rax] | |
mov ecx, [rbp+arg_8] | |
mov r9d, ecx | |
mov r8d, edx | |
mov edx, eax | |
lea rcx, aObjectFooDDD ; "Object::foo %d, %d, %d\n" | |
call printf | |
nop | |
add rsp, 20h | |
pop rbp | |
retn | |
Object_foo1 endp | |
------------------------------------------------------------------------------- | |
main proc near | |
var_8= byte ptr -8 | |
push rbp | |
mov rbp, rsp | |
sub rsp, 30h | |
call sub_4016F0 | |
lea rax, [rbp+var_8] | |
mov r8d, 2 | |
mov edx, 1 | |
mov rcx, rax | |
call Object_init(Object *, int, int) | |
lea rax, [rbp+var_8] | |
mov rcx, rax | |
call Object_foo0(Object *) | |
lea rax, [rbp+var_8] | |
mov edx, 3 | |
mov rcx, rax | |
call Object_foo1(Object *, int) | |
mov eax, 0 | |
add rsp, 30h | |
pop rbp | |
retn | |
main endp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
class Object | |
{ | |
int x; | |
int y; | |
Object(int x, int y) | |
: x(x), y(y) | |
{ | |
} | |
void foo() | |
{ | |
std::printf("Object::foo %d\n", x); | |
} | |
void foo(int z) | |
{ | |
std::printf("Object::foo %d, %d, %d\n", x, y, z); | |
} | |
}; | |
int | |
main() | |
{ | |
Object object(1, 2); | |
object.foo(); | |
object.foo(3); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object::Object(int, int) proc near | |
arg_0= qword ptr 10h | |
arg_8= dword ptr 18h | |
arg_10= dword ptr 20h | |
push rbp | |
mov rbp, rsp | |
mov [rbp+arg_0], rcx | |
mov [rbp+arg_8], edx | |
mov [rbp+arg_10], r8d | |
mov rax, [rbp+arg_0] | |
mov edx, [rbp+arg_8] | |
mov [rax], edx | |
mov rax, [rbp+arg_0] | |
mov edx, [rbp+arg_10] | |
mov [rax+4], edx | |
nop | |
pop rbp | |
retn | |
Object::Object endp | |
------------------------------------------------------------------------------- | |
Object::foo() proc near | |
arg_0= qword ptr 10h | |
push rbp | |
mov rbp, rsp | |
sub rsp, 20h | |
mov [rbp+arg_0], rcx | |
mov rax, [rbp+arg_0] | |
mov eax, [rax] | |
mov edx, eax | |
lea rcx, aObjectFooD ; "Object::foo %d\n" | |
call sub_407A50 | |
nop | |
add rsp, 20h | |
pop rbp | |
retn | |
Object::foo endp | |
------------------------------------------------------------------------------- | |
Object::foo(int) proc near | |
arg_0= qword ptr 10h | |
arg_8= dword ptr 18h | |
push rbp | |
mov rbp, rsp | |
sub rsp, 20h | |
mov [rbp+arg_0], rcx | |
mov [rbp+arg_8], edx | |
mov rax, [rbp+arg_0] | |
mov edx, [rax+4] | |
mov rax, [rbp+arg_0] | |
mov eax, [rax] | |
mov ecx, [rbp+arg_8] | |
mov r9d, ecx | |
mov r8d, edx | |
mov edx, eax | |
lea rcx, aObjectFooDDD ; "Object::foo %d, %d, %d\n" | |
call sub_407A50 | |
nop | |
add rsp, 20h | |
pop rbp | |
retn | |
Object::foo endp | |
------------------------------------------------------------------------------- | |
main() proc near | |
var_8= byte ptr -8 | |
push rbp | |
mov rbp, rsp | |
sub rsp, 30h | |
call sub_401660 | |
lea rax, [rbp+var_8] | |
mov r8d, 2 | |
mov edx, 1 | |
mov rcx, rax | |
call Object::Object(int, int) | |
lea rax, [rbp+var_8] | |
mov rcx, rax | |
call Object::foo() | |
lea rax, [rbp+var_8] | |
mov edx, 3 | |
mov rcx, rax | |
call Object::foo(int) | |
mov eax, 0 | |
add rsp, 30h | |
pop rbp | |
retn | |
main endp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment