flat assembler
Message board for the users of flat assembler.

Index > Main > use addr macro

Author
Thread Post new topic Reply to topic
e4key



Joined: 30 Jul 2009
Posts: 8
e4key 26 Sep 2009, 15:21
hi all. how i can use addr macro? i write next code in proc:

Code:
locals
        ...
        nameBuffer    db 'hello', 0
        ...
endl

invoke  lstrlen, addr nameBuffer    


and get error: extra characters on line. instruction: lea edx,[..]ess]

thanks.
Post 26 Sep 2009, 15:21
View user's profile Send private message ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18944
Location: In your JS exploiting you and your system
revolution 26 Sep 2009, 15:42
Always show all of your code because faults like this can be caused by other parts of the code.

Check that you have included the 'x' versions of the win functions (win32ax.inc & win32wx.inc):
Code:
include 'win32ax.inc'    
Post 26 Sep 2009, 15:42
View user's profile Send private message Visit poster's website Reply with quote
e4key



Joined: 30 Jul 2009
Posts: 8
e4key 26 Sep 2009, 15:47
win32ax included. in my file > 500 lines Smile i write callback function for work with sqlite :

Code:
proc CallBack c, data, nCols, rows, headers
        locals
                  hostBuffer    rb 45
                  nameBuffer    rb 45
        endl

        mov     ebx, [rows]
        ...

        sub     eax, eax
        ret
endp    

and error shows in my first function in this procedure.
Post 26 Sep 2009, 15:47
View user's profile Send private message ICQ Number Reply with quote
e4key



Joined: 30 Jul 2009
Posts: 8
e4key 26 Sep 2009, 15:48
if i write:

Code:
lea eax, [nameBuffer]
push eax
call [lstrlen]    

all works Smile
Post 26 Sep 2009, 15:48
View user's profile Send private message ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18944
Location: In your JS exploiting you and your system
revolution 26 Sep 2009, 15:52
We can't help you because you have not included enough code to show the place of the error.

If you don't want to post it all then minimize to the point of just one function or something and strip out lines until just the fault is present. Give us something that we can assemble and see the error. BTW: just doing this part can often show the error to you and you won't need to wait for someone here to help.
Post 26 Sep 2009, 15:52
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 26 Sep 2009, 15:58
This compiles to me:
Code:
include 'win32ax.inc'

proc CallBack c, data, nCols, rows, headers
        locals
                  hostBuffer    rb 45
                  nameBuffer    rb 45
        endl

        invoke  lstrlen, addr nameBuffer

        ret
endp

.end CallBack    
So yes, we need more code.
Post 26 Sep 2009, 15:58
View user's profile Send private message Reply with quote
e4key



Joined: 30 Jul 2009
Posts: 8
e4key 26 Sep 2009, 16:03
ok Smile i write next small example Smile

Code:
format PE GUI 4.0
entry main

include 'win32ax.inc'

section '.data' data readable writeable
  hello         db 'hello', 0
  hdb           dd ?
  dbName        db 'hehe.sqlite', 0
  sql           db 'SELECT hehe FROM hello', 0

  dumpbuff      rb 1024
  dumpfmt       db 'hehe: %s', 0

section '.code' code readable executable
  main:
        invoke  sqlite3_open, dbName, hdb
        invoke  sqlite3_exec, [hdb], sql, CallBack, 0, 0
        invoke  sqlite3_close, [hdb]
        invoke  ExitProcess, 0

proc CallBack c, data, nCols, rows, headers
        locals
                  hostBuffer    rb 45
        endl

        mov     ebx, [rows]
        invoke  lstrcpy, addr hostBuffer, [ebx]

        sub     eax, eax
        ret
endp

section '.idata' import data readable writeable
  library kernel32, 'kernel32.dll',\
          user32, 'user32.dll',\
          sqlite3, 'sqlite3.dll'

  import sqlite3,\
         sqlite3_open, 'sqlite3_open',\
         sqlite3_exec, 'sqlite3_exec',\
         sqlite3_close, 'sqlite3_close'

  include 'api\kernel32.inc'
  include 'api\user32.inc'    
Post 26 Sep 2009, 16:03
View user's profile Send private message ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18944
Location: In your JS exploiting you and your system
revolution 26 Sep 2009, 16:08
Are you sure this code generates the same error? I get "error: operand size not specified." because of the the [ebx] parameter. If I remove the [ebx] then it compiles fine.
Post 26 Sep 2009, 16:08
View user's profile Send private message Visit poster's website Reply with quote
e4key



Joined: 30 Jul 2009
Posts: 8
e4key 26 Sep 2009, 16:09
LocoDelAssembly. hmm... this code not compiles Sad
fasm v1.69.04
Post 26 Sep 2009, 16:09
View user's profile Send private message ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 26 Sep 2009, 16:09
invoke lstrcpy, addr hostBuffer, [ebx] > invoke lstrcpy, addr hostBuffer, ebx

If rows is pointer to pointer then invoke lstrcpy, addr hostBuffer, dword [ebx]
Post 26 Sep 2009, 16:09
View user's profile Send private message Reply with quote
e4key



Joined: 30 Jul 2009
Posts: 8
e4key 26 Sep 2009, 16:14
LocoDelAssembly, yes, rows is pointer to pointer Smile thanks.
Post 26 Sep 2009, 16:14
View user's profile Send private message ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 26 Sep 2009, 16:14
Quote:

LocoDelAssembly. hmm... this code not compiles Sad
fasm v1.69.04

I've used FASMW 1.69.05 and it compiles if it is copied and pasted exactly (and Include in FASMW.INI is set to point to the package includes)

Don't run it however, since the application will surely crash.
Post 26 Sep 2009, 16:14
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier 26 Sep 2009, 18:34
e4key,

You should be using the cinvoke instead of invoke to call the sqlite functions, since they are not stdcall functions.

hth,

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 26 Sep 2009, 18:34
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.