flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Help me with macros!!

Author
Thread Post new topic Reply to topic
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY 22 Sep 2006, 02:39
Code:
include '%fasminc%\win32ax.inc'

main:

macro loadapi api,lib
{
        invoke LoadLibrary,lib
        invoke GetProcAddress,eax,api
;the problem begins here
        mov [_#api],eax
        jmp @f
        _#api: dd 0
        @@:
}

        loadapi 'URLDownloadToFileA','urlmon.dll'
        invoke _URLDownloadToFileA,0,htmlfile,localfile,0,0
        ret


htmlfile db 'http://flatassembler.net/download.php',0
localfile db 'html.txt',0

.end main
    


As you see, I'm trying to create a macro to load functions on the fly and create a dword to store the address, so I can call it without too much typing.
But this doesn't work. Please help me make this idea work!! Smile
Post 22 Sep 2006, 02:39
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 22 Sep 2006, 03:06
I don't know how to tokenize a string but I now the inverse so here it is Very Happy
Code:
include '%fasminc%\win32ax.inc'

main: 

macro loadapi api,lib 
{ 
        invoke LoadLibrary,lib 
        invoke GetProcAddress,eax,`api
;the problem begins here 
        mov [_#api],eax
        jmp @f 
        _#api dd 0
        @@: 
} 

        loadapi URLDownloadToFileA,'urlmon.dll'
        invoke _URLDownloadToFileA,0,htmlfile,localfile,0,0 
        ret 


htmlfile db 'http://flatassembler.net/download.php',0 
localfile db 'html.txt',0 

.end main    


Check if it helps (I hope so)

Regards
Post 22 Sep 2006, 03:06
View user's profile Send private message Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY 22 Sep 2006, 03:11
Yes, Thanks!!
That was what I was looking for!! Very Happy
Post 22 Sep 2006, 03:11
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.