Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

How to look into memory?

  • Please log in to reply
3 replies to this topic

#1 jwxie518


    Speaks fluent binary

  • Senior Member
  • PipPipPipPipPipPip
  • 517 posts

Posted 30 September 2011 - 06:23 PM

Professor gave us a challenge. He said the following (LOL fine.. paraphrased)

Suppose you have the following C++ statement:
c = a + b;
I don't care what u put for a and b.
a = 10, b = 200; I don't care.

I want you guys to be able to tell me the address of c, and in essence you can find the value before a+b and after a+b;
I don't want you to use cout. No printing on the screen. NO. This mean no reference, no pointer.

Now the problem is: I have never done any memory dump. I have linux by the way.
I was reading about hex dump (Hex dump - Wikipedia, the free encyclopedia)

Anyone can think of a good approach?

  • 0

#2 Alexander



  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 30 September 2011 - 08:51 PM

I am unsure of what he is looking for, however to point you in the right direction (yours at least) a hex editor would be hard to use.

For example, how could you find (so incredibly quickly) what value (among millions) relates to the integer c, and note what it contains before it is (nearly instantaneously) changed?

Try to guess at what software tool can track execution and track memory.
  • 0

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.

#3 WingedPanther73


    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 01 October 2011 - 06:02 AM

You could use a debugger to get the current location of c in memory while it's running.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/

#4 dargueta


    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 02 October 2011 - 12:11 AM

"[...] no reference, no pointer." Sounds like a register thing to me.
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download