O'Reilly logo

Windows Debugging: Practical Foundations by Dmitry Vostokov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Debug and Release Binaries

"Arithmetic" Project: C/C++ Program

Let's rewrite our "Arithmetic" program in C++. Corresponding assembly language instructions are put in comments:

int a, b;
int main(int argc, char* argv[])
{

        a = 1;         // mov [a], 1
        b = 1;         // mov [b], 1
        b = b + a;     // mov eax, [a]
                       // add [b], eax
        ++a;           // inc eax
                       // mov [a], eax
        b = a * b;     // imul [b]
                       // mov [b], eax
        // results: [a] = 2 and [b] = 4
        return 0;
}

If we compile and link the program in debug mode we get the binary executable module which we can load in WinDbg and inspect assembly code.

Downloading and Configuring WinDbg Debugger

WinDbg from Debugging Tools for Windows can be downloaded from Microsoft web site or we can use windbg.org pointing to a Microsoft download link ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required