Click here to Skip to main content
15,888,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello!

I want to debug some binary stuff in C#, especially integer (uint, int, ushort etc.)-variables or byte-arrays.
For this case it would be great, if I could display how the data is stored in memory.

I already discovered the memory view, but it is only possible to jump to reference-types (like class-instances) by typing the variable name into the address field.
How can I go to local variables (like int or short) without calculating the address manually with the Disassembly-window?
The disassembly windows reads something like "dword ptr [ebp-40h],1267Dh" - so the address I need is ebp-40h (this works, but is very cumbersome).
When I insert the variable name of an integer, the memory-view picks up the integer as pointer and doesn't jump to the place where the value itself is stored.

Greetings,
Henning
Posted

Just type a name of that variable and VS will display memory starting from where that variable begins.
 
Share this answer
 
Comments
Henning Dieterichs 2-Apr-12 18:50pm    
Where do I have to type the variable?

>> I already discovered the memory view, but it is only possible to jump to reference-types (like class-instances) by typing the variable name into the address field.
Eugene Sadovoi 3-Apr-12 9:35am    
It will work for both managed and unmanaged types. If you want to see variables on the stack, there is a window for that.
1. In Visual Studio (VS), make a break point after the value change for your variable you want to view the value. This will make the debugger stop there and allow you to see the value for that local variable

2. in VS, After the debugger stop where you want to see the value, there are two ways to see the value for your local variable.
a. Right click on the variable and Add to Watch ==> The value will be displayed in the Watch Windows
b. You can just move your cursor on top of the variable, and you would be to view the value for your variable.

Note: if the local variable is a object, you would be able to see all the public, private member variables of your object via clicking on the + sign in front of your variable.
 
Share this answer
 
Comments
Henning Dieterichs 2-Apr-12 18:52pm    
I know this...
My question was not to view the value, but to view the binary representation in memory. But for that I need the address of this variable.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900