Now I encounter problem. My project works on assembly-level. So I need assembly-level programming but the project scale is too large to do work on assembly-level only. Because of this issue, I determine get hexcodes from c-source-file made by gcc. but how? How can I get certain function's HEXCODES by using gcc?
I have a idea,
int function_name(){
int a=1;
return a;
}
write(fd, (char *)function_name, sizeof(function_name))
I would get hexcodes of function_name after this doing. but It's not good way to solve this problem, It would make me need to handle many file when I need many function as target.
Is there other good way to solve this problem? I think ideal solution that need only function name(and output file name if needed) and works on command-line. Is ideal solution which I think impossible?
Also I assume that compiler's optimization options is off so I would get hexcodes from function_name is '\x55\x8B\xEC\x83\xEC\x04\xC7\x45\xFC\x01\x00\x00\x00\x8B\x45\xFC\x8B\xE5\x5D\xC3' function_name's assembly code is below.
PUSH EBP
MOV EBP, ESP
SUB ESP, 4
MOV DWORD PTR[EBP-4], 1
MOV EAX, DWORD PTR[EBP-4]
MOV ESP, EBP
POP EBP
RETN