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 13. Function Pointer Parameters

"FunctionPointerParameters" Project

This is our final project and it can be downloaded from ftp://dumpanalysis.org/pub/WDPF/Chapter13/

The summary of the project source code:

// FunctionParameters.cpp
int main(int argc, char* argv[])
{
        int a, b;

        printf("Enter a and b: ");
        scanf("%d %d", &a, &b);

        if (arithmetic (a, &b))
        {
               printf("Result = %d", b);
        }

        return 0;
}

// Arithmetic.cpp
bool arithmetic (int a, int *b)
{
       if (!b)
       {
              return false;
       }

       *b = *b + a;
       ++a;
       *b = a * *b;

       return true;
}

Commented Disassembly

Here is the commented disassembly from \Debug executable. FPO optimization was disabled.

FunctionParameters!main:
push    ebp                   ; establishing stack frame
mov     ebp,esp               ; sub esp,0xd8 ; creating stack frame for locals ...

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