flat assembler
Message board for the users of flat assembler.

Index > Windows > Bug in DLL example - won't compile

Author
Thread Post new topic Reply to topic
ejamesr



Joined: 04 Feb 2011
Posts: 52
Location: Provo, Utah, USA
ejamesr
I copied the 'display' example from the documentation (section 2.2.5) into the ERRORMSG.ASM example file that comes with version 1.69.31. FASM displays the message "Error: invalid expression" at line 19 for the command:

d = '0' + $ shr (bits-%*4) and 0Fh

If I comment our the rest of the line after after "d = '0'" then it compiles - but of course, then it doesn't produce the desired answer. In a new blank .asm file, the entire display example works fine. Here's the example code, pulled directly from the documentation:

Code:
    bits = 16
    display 'Current offset is 0x'
    repeat bits/4
        d = '0' + $ shr (bits-%*4) and 0Fh
        if d > '9'
            d = d + 'A'-'9'-1
        end if
        display d
    end repeat
    display 13,10
    



Can anyone else confirm this problem? Is this a known bug? Or did I do something wrong? I've attached the asm file.

Thank you,

Eric


Description: This is the Errormsg.asm example file (from \FASM\Examples\DLL), with display example inserted
Download
Filename: ERRORMSG.ASM
Filesize: 1.37 KB
Downloaded: 25 Time(s)

Post 15 Feb 2011, 07:28
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17287
Location: In your JS exploiting you and your system
revolution
You can't use the $ symbol like that in relocatable code. Since DLLs are relocatable, that means that you can't do assembly time program counter ($) arithmetic because the program counter is unknown at assembly time.

You can use RVA $ instead of just $ to show the relative offset of the program counter at assembly time.
Post 15 Feb 2011, 08:41
View user's profile Send private message Visit poster's website Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 140
Location: Severodvinsk, Russia
SFeLi
Code:
virtual
  dd $
  load x dword from $-4
end virtual

; then you can display x, but read revolution's post first.
    
Post 15 Feb 2011, 15:23
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
ejamesr



Joined: 04 Feb 2011
Posts: 52
Location: Provo, Utah, USA
ejamesr
Revolution and SFeLi,

Thank you for your responses. I'll work on this some more, taking into account your information and suggestions.

Eric
Post 15 Feb 2011, 15:37
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17287
Location: In your JS exploiting you and your system
revolution
SFeLi wrote:
Code:
virtual
  dd $
  load x dword from $-4
end virtual    
This will give you the value of base_address + RVA $, but it won't give you the value of the PC at runtine. The OS can relocate the DLL.
Post 15 Feb 2011, 15:42
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.