I have assembly code that I need to look at and re-created the code but in c++. Essentially, I have assembly and need to

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

I have assembly code that I need to look at and re-created the code but in c++. Essentially, I have assembly and need to

Post by answerhappygod »

I have assembly code that I need to look at and re-created thecode but in c++.
Essentially, I have assembly and need to convert it toc++.
I know there is a function and there is an array.
I Have Assembly Code That I Need To Look At And Re Created The Code But In C Essentially I Have Assembly And Need To 1
I Have Assembly Code That I Need To Look At And Re Created The Code But In C Essentially I Have Assembly And Need To 1 (63.07 KiB) Viewed 11 times
I Have Assembly Code That I Need To Look At And Re Created The Code But In C Essentially I Have Assembly And Need To 2
I Have Assembly Code That I Need To Look At And Re Created The Code But In C Essentially I Have Assembly And Need To 2 (49.22 KiB) Viewed 11 times
I Have Assembly Code That I Need To Look At And Re Created The Code But In C Essentially I Have Assembly And Need To 3
I Have Assembly Code That I Need To Look At And Re Created The Code But In C Essentially I Have Assembly And Need To 3 (64.76 KiB) Viewed 11 times
I Have Assembly Code That I Need To Look At And Re Created The Code But In C Essentially I Have Assembly And Need To 4
I Have Assembly Code That I Need To Look At And Re Created The Code But In C Essentially I Have Assembly And Need To 4 (65.2 KiB) Viewed 11 times
main function 401070 var_28 = dword ptr -28h var 24 = dword ptr -24h var 20 = dword ptr -20h var_4 = dword. ptr -4 push ebp mov ebp, esp sub esp, 28h mov Xor eax, ebp push esi push edi ecx, 6 mov eax, dword_413020 mov lea edi, [ebp+var_20] esi, offset aUggcJjj ongthl movsw movsb rep movsd mov [ebp+var_28], 0 mov_[ebp+var_24], 0 mov_[ebp+var_28], 1Bh mov_[ebp+var_24],0 jmp short loc 4010BB Comments Local variable (a) Local variable (i), this is the counter in the for loop Local variable (c) var_4 stores random number used for stack canary Prolog Room on stack for local variables Stores random value to be used for stack canary Push eşi, to the stack Push edi to the stack Moving a 6 into ecx String array from memory Load effect address, placing var_20 (C) in edi 4 bytes will be moved until there are no more chunks of 4 bytes. Moving 2 bytes Moving 1 byte Move 0 into var_28 (a) Move 0 into var_24 (i) Move 27 into var_28 (a) Move 0 into var_24 (i) Jump to for loop
loc_4010B2: mov eax, [ebp+var_24 add eax, 1 mov [ebp+var_24], eax loc 4010BB mov ecx, [ebp+var_24] cmp ecx, [ebp+var_28] jnb short loc 4010DD mov edx, [ebp+var_24] movzx eax, byte ptr [ebp+edx+var_20 push eax call sub_401000 I++ for the For Loop Moving var_24 (i) into eax Adding 1 to eax Moving eax back into var_24 (i) esp, 4 ecx, [ebp+var_24] byte ptr [ebp+ecx+var_20], al FOR LOOP Move var_24 (i) into ecx Comparing ecx, (i), to var_28, (27) Jump if not carry Move var 28 (27) to edx move one byte from vara_20 (c) to eax Push eax to stack Call the function foo add mov mov jmp short loc 4010B2 The rest is Function prolog and stack canary check. Add 4 to esp Move var_24 (i) to ecx Store the value of al into the byte location var_20 (c) Jump to section of code
Function Code (00401000) arg_0 =byte ptr 8 push ebp mov ebp, esp movzx eax, [ebp+arg_0] cmp eax, 61h jl short loc 401034 moyzx ecx, [ebp+arg_0] ecx, 7Ah cmp ję short loc 401034 moyzx edx. [ebp+arg_0] add edx, 0Dh mov_[ebp+arg_0], dl moyzx eax, [ebp+arg_0] smp sax, 7Ah jle short loc 401032 movzx ecx, [ebp+arg_0] ecx, 1Ah sub [ebp+arg_0], cl mov loc 401032: jmp short loc_401063 Comment Parameter passed to function, one byte (a) Function prolog Function prolog Moves multiple bytes (zero extension) Compare eax and 61h (which is 'a') Jump if less, which should be ‘>' as the sign Moves multiple bytes (zero extension) Compar ecx and 'z' or 7Ah Jump if greater, which should be ‘<' sign Moves multiple bytes (zero extension) Adding 0Dh (13) to edx Moving dl into arg_0 (a) Moving arg_0 (a) into eax with zero extension Comparing eax and 7Ah (‘z') Jump if eax >= 7Ah (‘z') Move arg_0 into ecx with zero extension Subtract 1Ah (26) from the ecx Move cl into arg_0 Jump to 401063 (whatever that is)
loc 401034: moyzx edx. [ebp+arg_0] cmp edx, 41h jl short loc 401063 movzx eax, [ebp+arg_0] smp eax, 5Ah jg short loc 401063 movzx ecx, [ebp+arg_0] add ecx, 0Dh mov [ebp+arg_0], cl movzx eax, [ebp+arg_0] cmp eax, 5Ah jle short loc 401063 moyzx eax, [ebp+arg_0] eax, 1Ah sub mov_[ebp+arg_0], al loc 401063: mov al, [ebp+arg_0] pop ebp Moving arg_0 (a) into edx with zero extension Comparing 41h (65) with value in edx (essentially what is in a) Jumping if less [if(a <65)] Moving arg_0 (a) into eax with zero extension Comparing 5Ah (90) with value inside eax (essentially what is a) Jump if greater [if(a >90)] Moving arg_0 (a) into ecx with zero extension Adding 0Dh (13) to the ecx register Moving cl, the lower 8 bits, into arg_0 (a) Moving arg_0 (a) into the eax register with zero extension Comparing 5Ah (90) with value in eax Jump if less or equal [if(90 <= eax)] Moving arg_0 (a) into the eax register with zero extension Subtracting 1Ah (26) from the eax register Moving al into arg_0 (a) Moving arg_0 (a) into al, (al is a lower 8 bits) Function Epilog etc.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply