Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3323910
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:21:31+00:00 2026-05-17T23:21:31+00:00

I got the following simple C++ code: #include <stdio.h> int main(void) { ::printf(\nHello,debugger!\n); }

  • 0

I got the following simple C++ code:

#include <stdio.h>
int main(void)
{
    ::printf("\nHello,debugger!\n");
}

And from WinDbg, I got the following disassembly code:

SimpleDemo!main:
01111380 55              push    ebp
01111381 8bec            mov     ebp,esp
01111383 81ecc0000000    sub     esp,0C0h
01111389 53              push    ebx
0111138a 56              push    esi
0111138b 57              push    edi
0111138c 8dbd40ffffff    lea     edi,[ebp-0C0h]
01111392 b930000000      mov     ecx,30h
01111397 b8cccccccc      mov     eax,0CCCCCCCCh
0111139c f3ab            rep stos dword ptr es:[edi]
0111139e 8bf4            mov     esi,esp
011113a0 683c571101      push    offset SimpleDemo!`string' (0111573c)
011113a5 ff15b0821101    call    dword ptr [SimpleDemo!_imp__printf (011182b0)]
011113ab 83c404          add     esp,4
011113ae 3bf4            cmp     esi,esp
011113b0 e877fdffff      call    SimpleDemo!ILT+295(__RTC_CheckEsp) (0111112c)
011113b5 33c0            xor     eax,eax
011113b7 5f              pop     edi
011113b8 5e              pop     esi
011113b9 5b              pop     ebx
011113ba 81c4c0000000    add     esp,0C0h
011113c0 3bec            cmp     ebp,esp
011113c2 e865fdffff      call    SimpleDemo!ILT+295(__RTC_CheckEsp) (0111112c)
011113c7 8be5            mov     esp,ebp
011113c9 5d              pop     ebp
011113ca c3              ret

I have some difficulties to fully understand it. What is the SimpleDemo!ILT things doing here?

What’s the point of the instruction comparing ebp and esp at 011113c0?

Since I don’t have any local variables in main() function, why there’s still a sub esp,0C0h at the loacation of 01111383?

Many thanks.

Update 1

Though I still don’t know what ILT means, but the __RTC_CheckESP is for runtime checks. These code can be elimiated by placing the following pragma before the main() function.

#pragma runtime_checks( "su", off )

Reference:

http://msdn.microsoft.com/en-us/library/8wtf2dfz.aspx

http://msdn.microsoft.com/en-us/library/6kasb93x.aspx

Update 2

The sub esp,0C0h instruction allocate another 0C0h bytes extra space on the stack. Then EAX is filled with 0xCCCCCCCC, this is 4 bytes, since ECX=30h, 4*30h=0C0h, so the instruction rep stos dword ptr es:[edi] fill exactly the extra spaces with 0xCC. But what is this extra space on stack for? Is this some kind of safe belt? Also I notice that if I turn off the runtime check as Update 1 shows, there’s still such extra space on stack, though much smaller. And this space is not filled with 0xCC.

The assembly code without runtime check is like below:

SimpleDemo!main:
00231250 55              push    ebp
00231251 8bec            mov     ebp,esp
00231253 83ec40          sub     esp,40h <-- Still extra space allocated from stack, but smaller
00231256 53              push    ebx
00231257 56              push    esi
00231258 57              push    edi
00231259 683c472300      push    offset SimpleDemo!`string' (0023473c)
0023125e ff1538722300    call    dword ptr [SimpleDemo!_imp__printf (00237238)]
00231264 83c404          add     esp,4
00231267 33c0            xor     eax,eax
00231269 5f              pop     edi
0023126a 5e              pop     esi
0023126b 5b              pop     ebx
0023126c 8be5            mov     esp,ebp
0023126e 5d              pop     ebp
0023126f c3              ret
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:21:32+00:00Added an answer on May 17, 2026 at 11:21 pm

    Most of the instructions are part of MSVC runtime checking, enabled by default for debug builds. Just calling printf and returning 0 in an optimized build takes much less code. (Godbolt compiler explorer). Other compilers (like GCC and clang) don’t do as much stuff like stack-pointer comparison after calls, or poisoning stack memory with a recognizable 0xCC pattern to detect use-uninitialized, so their debug builds are like MSVC debug mode without its extra runtime checks.

    I’ve annotated the assembler, hopefully that will help you a bit. Lines starting ‘d’ are debug code lines, lines starting ‘r’ are run time check code lines. I’ve also put in what I think a debug with no runtime checks version and release version would look like.

      ; The ebp register is used to access local variables that are stored on the stack, 
      ; this is known as a stack frame. Before we start doing anything, we need to save 
      ; the stack frame of the calling function so it can be restored when we finish.
      push    ebp                   
      ; These two instructions create our stack frame, in this case, 192 bytes
      ; This space, although not used in this case, is useful for edit-and-continue. If you
      ; break the program and add code which requires a local variable, the space is 
      ; available for it. This is much simpler than trying to relocate stack variables, 
      ; especially if you have pointers to stack variables.
      mov     ebp,esp             
    d sub     esp,0C0h              
      ; C/C++ functions shouldn't alter these three registers in 32-bit calling conventions,
      ; so save them. These are stored below our stack frame (the stack moves down in memory)
    r push    ebx
    r push    esi
    r push    edi                   
      ; This puts the address of the stack frame bottom (lowest address) into edi...
    d lea     edi,[ebp-0C0h]        
      ; ...and then fill the stack frame with the uninitialised data value (ecx = number of
      ; dwords, eax = value to store)
    d mov     ecx,30h
    d mov     eax,0CCCCCCCCh     
    d rep stos dword ptr es:[edi]   
      ; Stack checking code: the stack pointer is stored in esi
    r mov     esi,esp               
      ; This is the first parameter to printf. Parameters are pushed onto the stack 
      ; in reverse order (i.e. last parameter pushed first) before calling the function.
      push    offset SimpleDemo!`string' 
      ; This is the call to printf. Note the call is indirect, the target address is
      ; specified in the memory address SimpleDemo!_imp__printf, which is filled in when
      ; the executable is loaded into RAM.
      call    dword ptr [SimpleDemo!_imp__printf] 
      ; In C/C++, the caller is responsible for removing the parameters. This is because
      ; the caller is the only code that knows how many parameters were put on the stack
      ; (thanks to the '...' parameter type)
      add     esp,4                 
      ; More stack checking code - this sets the zero flag if the stack pointer is pointing
      ; where we expect it to be pointing. 
    r cmp     esi,esp               
      ; ILT - Import Lookup Table? This is a statically linked function which throws an
      ; exception/error if the zero flag is cleared (i.e. the stack pointer is pointing
      ; somewhere unexpected)
    r call    SimpleDemo!ILT+295(__RTC_CheckEsp)) 
      ; The return value is stored in eax by convention
      xor     eax,eax               
      ; Restore the values we shouldn't have altered
    r pop     edi
    r pop     esi
    r pop     ebx                   
      ; Destroy the stack frame
    r add     esp,0C0h              
      ; More stack checking code - this sets the zero flag if the stack pointer is pointing
      ; where we expect it to be pointing. 
    r cmp     ebp,esp               
      ; see above
    r call    SimpleDemo!ILT+295(__RTC_CheckEsp) 
      ; This is the usual way to destroy the stack frame, but here it's not really necessary
      ; since ebp==esp
      mov     esp,ebp               
      ; Restore the caller's stack frame
      pop     ebp                   
      ; And exit
      ret                           
      
    
          ; Debug only, no runtime checks  
          push    ebp                   
          mov     ebp,esp             
        d sub     esp,0C0h              
        d lea     edi,[ebp-0C0h]        
        d mov     ecx,30h
        d mov     eax,0CCCCCCCCh     
        d rep stos dword ptr es:[edi]   
          push    offset SimpleDemo!`string' 
          call    dword ptr [SimpleDemo!_imp__printf] 
          add     esp,4                 
          xor     eax,eax               
          mov     esp,ebp               
          pop     ebp                   
          ret                             
    
          ; Release mode (The optimiser is clever enough to drop the frame pointer setup with no VLAs or other complications)
          push    offset SimpleDemo!`string' 
          call    dword ptr [SimpleDemo!_imp__printf] 
          add     esp,4                 
          xor     eax,eax               
          ret
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’ve got the following code: #include <iostream> using namespace std; int main() { char*
I've got the following code, think simple shooter in c++: // world.hpp //---------- class
I've got the following SQL: select * from transaction_log where stoptime like '%2008%' How
I've got the following code to end a process, but I still receive an
I got the following class : class ConstraintFailureSet(dict, Exception) : Container for constraint failures.
I've got the following in my .css file creating a little image next to
I've got the following situation A rails application that makes use of rjs /
I've got the following JavaScript on my web page... 64 var description = new
I've got the following query to determine how many votes a story has received:
Suppose I've got the following program: namespace ReflectionTest { public class Example { private

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.