I really hate this. All I did was a simple #define in the C++ code and some very few lines of code (actually 4). Whatever… looking at the IDA output I am lost. What the hell is the code doing here? Can you help us to understand the code?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | .text:00401000 _main proc near .text:00401000 .text:00401000 var_10= qword ptr -10h .text:00401000 var_8= qword ptr -8 .text:00401000 argc= dword ptr 8 .text:00401000 argv= dword ptr 0Ch .text:00401000 envp= dword ptr 10h .text:00401000 .text:00401000 push ebp .text:00401001 mov ebp, esp .text:00401003 sub esp, 10h .text:00401006 fld ds:__real@4014000000000000 .text:0040100C fstp [ebp+var_10] .text:0040100F fld ds:__real@401921f9f01b866e .text:00401015 fmul [ebp+var_10] .text:00401018 fstp [ebp+var_8] .text:0040101B xor eax, eax .text:0040101D mov esp, ebp .text:0040101F pop ebp .text:00401020 retn .text:00401020 _main e |
ok, I have to admit I am a little confuse on this one. So this is what I have so far:
.text:00401000 _main proc near
.text:00401000
.text:00401000 var_10= qword ptr -10h ;double int var_10
.text:00401000 var_8= qword ptr -8 ;double int var_8
.text:00401000 argc= dword ptr 8 ;int *argc
.text:00401000 argv= dword ptr 0Ch ;char *argv
.text:00401000 envp= dword ptr 10h
.text:00401000
.text:00401000 push ebp
.text:00401001 mov ebp, esp
.text:00401003 sub esp, 10h
.text:00401006 fld
ds:__real@4014000000000000 ;loads values the values located at 4014000000000000 into a stack
.text:0040100C fstp [ebp+var_10] ;copies the values on the top of the floating point register stack to another floating point register, thus it pop var_10
.text:0040100F fld ds:__real@401921f9f01b866e ;loads the value located at 401921f9f01b866e into the stack
.text:00401015 fmul [ebp+var_10] ;multiplies two floating point values: var_8 = var_8*var_10
.text:00401018 fstp[ebp+var_8]
.text:0040101B xor eax, eax
.text:0040101D mov esp, ebp
.text:0040101F pop ebp
.text:00401020 retn
.text:00401020 _main e
How about
#define PI 3.14159265
#define PI2 (2 * PI)
int main() {
double var_10 = 1.0;
double var_8 = PI2 * var_10;
return 0;
}
The code looks correct, but if this is lifted from the modules, it looks like the first constant is 5.0, not pi. In my binary I have 5.0 and 6.28318 (2*PI).