The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: emre_tinaztepe on July 20, 2007, 11:27:46 PM

Title: .code or .data section
Post by: emre_tinaztepe on July 20, 2007, 11:27:46 PM
Hi there,
I am struggling with something weird. I am trying to put my byte string in .code section and after using it with MessageBox api, it works but Windows XP gives and error,
as you know bla. bla. an exception occured, SEND it DONT SEND IT bla. bla.
  But if i put my byte string into .data section, it gives error...
  Code is like this :
.486
.model flat,stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

.data


.code
_start:   
   push 0
   push offset mesaj
   push offset mesaj
   push NULL
   call MessageBox
   
    push 0
   push offset mesaj
   push offset mesaj
   push NULL
   call MessageBox
   
    mesaj db 'emre',0   


_end:
   push 0
   call ExitProcess
end _start

Does anyone have any idea?
Title: Re: .code or .data section
Post by: mnemonic on July 21, 2007, 12:44:20 AM
There is a simple cure: put a
jmp _end
straight after the second
call MessageBox

I think you get the idea and can figure out yourself why your app got closed down by Windows, resulting in the mentioned error message.
If not, just ask. ;)

HTH
Title: Re: .code or .data section
Post by: hutch-- on July 21, 2007, 12:48:36 AM
The fault occurs because you are trying to execute data.


    mesaj db 'emre',0


Put it in the .DATA section and it will not be a problem.