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

  • Home
  • SEARCH
  • 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 117899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:24:33+00:00 2026-05-11T03:24:33+00:00

I’ve been messing around with the free Digital Mars Compiler at work (naughty I

  • 0

I’ve been messing around with the free Digital Mars Compiler at work (naughty I know), and created some code to inspect compiled functions and look at the byte code for learning purposes, seeing if I can learn anything valuable from how the compiler builds its functions. However, recreating the same method in MSVC++ has failed miserably and the results I am getting are quite confusing. I have a function like this:

unsigned int __stdcall test() {   return 42; } 

Then later I do:

unsigned char* testCode = (unsigned char*)test; 

I can’t seem to get the C++ static_cast to work in this case (it throws a compiler error)… hence the C-style cast, but that’s besides the point… I’ve also tried using the reference &test, but that helps none.

Now, when I examine the contents of the memory pointed to by testCode I am confused because what I see doesn’t even look like valid code, and even has a debug breakpoint stuck in there… it looks like this (target is IA-32):

0xe9, 0xbc, 0x18, 0x00, 0x00, 0xcc…

This is clearly wrong, 0xe9 is a relative jump instruction, and looking 0xbc bytes away it looks like this:

0xcc, 0xcc, 0xcc…

i.e. memory initialised to the debug breakpoint opcode as expected for unallocated or unused memory.

Where as what I would expect from a function returning 42 would be something like:

0x8b, 0x2a, 0x00, 0x00, 0x00, 0xc3

or at least some flavour of mov followed by a ret (0xc2, 0xc3, 0xca or 0xcb)a little further down

Is MSVC++ taking steps to prevent me from doing this sort of thing for security reasons, or am I doing something stupid and not realising it? This method seems to work fine using DMC as the compiler…

I’m also having trouble going the other way (executing bytes), but I suspect that the underlying cause is the same.

Any help or tips would be greatly appreciated.

  • 1 1 Answer
  • 3 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. 2026-05-11T03:24:34+00:00Added an answer on May 11, 2026 at 3:24 am

    I can only guess, but I’m pretty sure you are inspecting a debug build. In debug mode the MSVC++ compiler replaces all calls by calls to jump stubs. This means, that every function starts with a jump to the real function and this is exactly what you are facing here.
    The surrounding 0xCC bytes are indeed breakpoint instructions, in order to fire a possibly attached debugger in case you’re executing code where you shouldn’t.
    Try the same with a release build. That should work as expected.

    Edit: This is actually affected by the linker setting /INCREMENTAL. The reason that the effect you’re describing doesn’t show up in release builds is that these jump stubs are simply optimized away if any kind of optimization is turned on (which is of course usually the case for release builds).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 247k
  • Answers 247k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It appears the issue was because I was using synchronous… May 13, 2026 at 8:38 am
  • Editorial Team
    Editorial Team added an answer It really sounds like a configuration difference between the two… May 13, 2026 at 8:38 am
  • Editorial Team
    Editorial Team added an answer Long ago I'd switched my OSX (Snow Leopard) python version… May 13, 2026 at 8:38 am

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.