In the search results, click "Microsoft Visual C++ 2008 Express Edition"
Visual C++ 2008 Express launches, as shown below:
In the "New Project" window, on the left, click Win32, as shown below.
In the right pane, accept the default selection of "Win32 Console Application"
At the bottom of the "New Project" window, type a Name of YOURNAME-9a, replacing "YOURNAME" with your own name. Do not use any spaces in the name.
In the "Location" line, click the Browse button and navigate to a folder you have permission to save files in, such as your desktop.
Click the "Select folder" button.
In the "New Project" window, click OK.
A box opens, titled "Welcome to the Win32 Application Wizard".
Click Next. In the next screen, accept the default settings and click Finish.
A window opens, showing a simple C program.
Modify this program to match the code shown in text and the image below.
Do not use the literal string "YOURNAME"--replace it with your own name.
// YOURNAME-9a.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
int i=10;
int j=2;
int k;
i = i + 2;
k = i / j;
printf("YOURNAME-9a: %d %d %d\n", i, j, k);
return 0;
}
You should see the message "Build: 1 succeeded" at the bottom of the window. If you see errors, you need to correct them and re-compile the program.
A Command Prompt window opens, showing the output of "YOURNAME-9a: 12 2 6", as shown below:
Minimize the Visual Studio Express window.
Start IDA Pro Free.
In the "About" box, click OK.
Agree to the license.
Close the Help window.
In the "Welcome to IDA!" box, click the New button.
In the "New disassembly database" box, double-click "PE Executable".
In the "Select PE Executable to disassemble" box, navigate to the folder you used to save your program in Visual Studio Express, probably your desktop.
Double-click the "YOURNAME-9a" folder.
Double-click the Debug folder.
Double-click the YOURNAME-9a.exe file.
In the "PE Executable file loading Wizard", click Next, Next, Finish.
A box appears, saying this file was linked with debug information.
Click Yes
IDA Pro loads the file. As before, the graph mode doesn't show the interesting part of the program.
Expand the Strings. Double-click "YOURNAME-9a %d %d %d\n".
The location containing the string appears.
To the right of "YOURNAME-9a" there is a "DATA XREF" comment. To the right of the "XREF", double-click "wmain".
Now the assembly code that performs the task you wrote in C appears, as shown below.
Find the commands listed below, and see how they work. The explanations refer to the C code added to the figure below in the box with green shading.
ASM Code Explanation C Code mov [ebp+var_8], 0Ah Put the number 10 into a local variable (i) int i=10; mov [ebp+var_14], 2 Put the number 2 into a local variable (j) int j=2; mov eax, [ebp+var_8] Put i into eax add eax, 2 Add 2 to eax i = i + 2; mov [ebp+var_8], eax Put eax (the result) into a local variable (i)
mov eax, [ebp+var_8] Put i into eax
cdq Convert double to quad (required for division)
k = i / j; idiv [ebp+var_14] Divide the value in eax by a local variable (j)
mov [ebp+var_20], eax Put eax (the result) into a local variable (k)
On your keyboard, press the PrntScrn key.
Click Start, type in PAINT, and open Paint.
Press Ctrl+V to paste in the image of your desktop.
YOU MUST SUBMIT WHOLE-DESKTOP IMAGES TO GET FULL CREDIT.
Save the image with a filename of "Proj 9a from YOUR NAME".
It must show these features, as labelled in the image above:
Last Modified: 3-20-17