flat assembler
Message board for the users of flat assembler.

Index > Windows > how to put data-string to .data section?

Author
Thread Post new topic Reply to topic
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle 30 Mar 2004, 13:50
this masm's code :
Code:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    .486
    .model flat, stdcall
    option casemap :none   ; case sensitive

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

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

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

    main PROTO

    ; ---------------------
    ; literal string MACRO
    ; ---------------------
      literal MACRO quoted_text:VARARG
        LOCAL local_text
        .data
          local_text db quoted_text,0
        .code
        EXITM <local_text>
      ENDM
    ; --------------------------------
    ; string address in INVOKE format
    ; --------------------------------
      SADD MACRO quoted_text:VARARG
        EXITM <ADDR literal(quoted_text)>
      ENDM

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    .code

start:

    call main

    invoke ExitProcess,0

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

main proc

    invoke MessageBox,0,SADD("blabla 1"),SADD("hejka Privalov"),MB_OK

    ret

main endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

end start
    


puts all te strings to data section and code to .text section.

How should be writen the fasm code to do not mixed .code and .data after:

Code:
invoke MessageBox,0,"asasdasda","ytutrutrytry",0
    


because mixed code with the data is unreadable after disassembling.

I see that Privalov used call-trick and put in fasm strings data after call instruction (which pushed eip into the stack to point it)

regards!
harry

_________________
Microsoft: brings power of yesterday to computers of today.
Post 30 Mar 2004, 13:50
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 30 Mar 2004, 14:31
You cannot put arbitrarily in the .data section, not even with new store directive. But, you can allocate sufficient space in .code section, just before entrypoint. Then using store and an accumulating pointer you can put all strings there.

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 30 Mar 2004, 14:31
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 30 Mar 2004, 15:18
There is also a solution based on fix feature, which is cumullating all the strings for the data section that is generated after the code section.
Post 30 Mar 2004, 15:18
View user's profile Send private message Visit poster's website Reply with quote
S.T.A.S.



Joined: 09 Jan 2004
Posts: 173
Location: Ru#27
S.T.A.S. 31 Mar 2004, 08:35
Post 31 Mar 2004, 08:35
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.