0

When I try to debug my program, I want to look at the memory where its stored, but when I search for it, theres nothing stored.

Example:

aVar byte 23d

When I debug and search through the memory 1 window, I would type &aVar. I'd assume it'd take me to its memory location but it just brings me to a memory location with 0123456789ABCDEF stored in memory. Any help?

I've tried to debug the program on a lab computer, and I got the same results as well, I cant search memory, I dont think its even writing to memory.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • 1
    `aVar byte 23d` in `.data` will make that byte part of your executable, so it's already there when your program starts. Are you doing this search after running the program, but stopped at a breakpoint before the first instruction, so nothing can have overwritten that byte yet? – Peter Cordes Feb 26 '23 at 06:37
  • 1
    I created a small project set this up. Stopped on the first instruction and put `&aVar` in the `memory 1` tab and it did show me a memory address with 0x17 (23d) in it. Are you sure the code you wrote didn't accidentally overwrite the memory `aVar` is located at? If you set a breakpoint at the first instruction of the program what does it show for `&aVar`? – Michael Petch Feb 26 '23 at 09:19
  • I did what you said with the breakpoint, and still it doesn't show up in memory, it is in .data, and it shows up when I use the watch tab – vanderbilt Feb 26 '23 at 23:38

1 Answers1

2

I add the code aVar byte 23d into my .asm file for test in VS2022 and I can see the the memory address in memory window as expected. You can compare the difference between our steps or follow my steps to recreate .asm file to test . Below are my steps.

1 create .asm file and add the following code

; program 3.1
; sample Assembly program - MASM (64-bit)

extern ExitProcess:PROC


.data
aVar byte 23d

.code
main PROC          
                         
  add aVar, 0
  call ExitProcess
main ENDP
END

2 debug with x64 and type &aVar in memory window 

enter image description here

If it doesn’t work for you ,you also could provide your screenshot of your memory window with the result 0123456789ABCDEF for further analyzing the issue.

Dou Xu-MSFT
  • 880
  • 1
  • 1
  • 4