0

I used vs 2015 to write x64 masm program.

ExitProcess PROTO
MessageBoxA PROTO
.data
    text  db "Winter hat", 0Ah, "Upon my head - ", 0Ah, "My head stays warm,", 0Ah, "But my nose is red!;", 0
    header  db "Task1", 0

.code

main proc

xor rcx, rcx
mov r9b, 0
lea rdx, text
lea r8, header

call MessageBoxA

call ExitProcess

main endp

end

From time to time i get next error:

Exception thrown at 0x00007FF9C65261BE (gdi32.dll) in ConsoleApplication1.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

If there is a handler for this exception, the program may be safely continued.

Could you clarify where can be mistake in my code?

1 Answers1

0

This error could happen when you call the procedures without parameters, It's better to call them with INVOKE instead of CALL to get proper error message. Also I think MessageBoxA need parameters on stack not in registers, so you can put params like this:

.data
text  db "your message box text", 0
header  db "message box caption",0

.code
start:
push MB_OK
push addr header
push addr text
push 0
call MessageBox

OR

invoke MessageBox, 0, addr text, addr header, MB_OK
Rassoul
  • 160
  • 11