flat assembler
Message board for the users of flat assembler.

Index > Windows > "len = $-msg" or "len dd $-msg"?

Author
Thread Post new topic Reply to topic
FlierMate11



Joined: 13 Oct 2022
Posts: 94
FlierMate11 26 Jan 2023, 12:43
Last time I coded like this and it works.

Code:
message       db      "Hello World",13,10,0
  len           =      $ - message    


But yesterday the above not working (silent crash in Windows), so I changed it to the below and it worked again.

Code:
message       db      "Hello World",13,10,0
  len           dd      $ - message    


What is the size of "len" if I use the first approach?

I need to pass it as parameter for WriteConsoleA.
Code:
push   dword [len]    
Post 26 Jan 2023, 12:43
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20070
Location: In your JS exploiting you and your system
revolution 26 Jan 2023, 12:58
Code:
push len ; push raw number
push [len] ; push contents of memory location pointed to by len    
Post 26 Jan 2023, 12:58
View user's profile Send private message Visit poster's website Reply with quote
FlierMate11



Joined: 13 Oct 2022
Posts: 94
FlierMate11 26 Jan 2023, 13:02
revolution wrote:
Code:
push len ; push raw number
push [len] ; push contents of memory location pointed to by len    


Ah, yes, I browse back my old code, the difference is like what you have pointed out.

If I use "len=$-msg", then have to use "push len" (raw number)
But if I use "len dd $-msg", then have to use "push [len]". It was confusing but I slowly understand it now.

Thank you for the prompt reply.
Post 26 Jan 2023, 13:02
View user's profile Send private message Visit poster's website 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.