flat assembler
Message board for the users of flat assembler.

Index > Windows > Export variables in dll and access them

Author
Thread Post new topic Reply to topic
ass0



Joined: 31 Dec 2008
Posts: 521
Location: ( . Y . )
ass0
Hi there,

I already know how to export function from a dll:

Code:
format PE GUI 4.0 DLL
entry start

section '.code' code readable executable

start:
        mov  eax,1
           ret
exit_program:
                movzx   eax,al
              push    eax
         call    [ExitProcess]
               ret

section '.iDaTa' import data readable writeable
 
   dd 0,0,0,RVA kernel_name,RVA kernel_table
   dd 0,0,0,0,0
 
  kernel_table:
     ExitProcess dd RVA _ExitProcess,0
 
  kernel_name db 'KERNEL32.DLL',0

  _ExitProcess dw 0
     db 'ExitProcess',0

section '.edata' export data readable

  dd 0,0,0,RVA dll_name,1
  dd 1,1,RVA addresses_table,RVA names_table,RVA ordinal_table

  addresses_table:
    dd RVA exit_program

  names_table:
    dd RVA _exit_program
  ordinal_table:
    dw 0

  dll_name db 'a1.dll',0

  _exit_program db 'exit_program',0

section '.reloc' fixups data readable discardable
    


but i can't export variables yet...
variables like:

Code:
var1 db 'some string'
var2 dd ?
var3 rd 8
    


I'd love some hint please.


Last edited by ass0 on 03 Aug 2009, 01:29; edited 1 time in total
Post 02 Aug 2009, 23:37
View user's profile Send private message Reply with quote
asmcoder



Joined: 02 Jun 2008
Posts: 784
asmcoder
[content deleted]


Last edited by asmcoder on 14 Aug 2009, 14:47; edited 1 time in total
Post 03 Aug 2009, 00:00
View user's profile Send private message Reply with quote
ass0



Joined: 31 Dec 2008
Posts: 521
Location: ( . Y . )
ass0
Thank you, but it stills not solve my problem, because you are using from the same executable the vars.

Maybe i didn't explain myself correctly, what i want is to use the vars of a dll from others dlls, exes, etc.

I can compile without errors the dll and the exe "caller", but when i call the var from the exe caller i got runtime error:(0xc0000005).

i.e.
Code:
;var in a1.dll succesfully exported
var1 db 'Hello World Very Happy'
    


then i import the a1.dll doing the rva a1_name,rva a1_table...
but when i want to use the var1:

Code:
mov esi,var1
; i can't use brackets like [var1] because it will treat it as contents and not like address
    


In few words i want to load all my vars stored in a dll from others dlls, exes, etc.
Post 03 Aug 2009, 01:24
View user's profile Send private message Reply with quote
ass0



Joined: 31 Dec 2008
Posts: 521
Location: ( . Y . )
ass0
Another question: How can i create variables at runtime and share them?
Post 03 Aug 2009, 01:37
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
I have no help for you, But I do have a question.
Are you coming down from a HLL? Just wondering.
Post 03 Aug 2009, 01:39
View user's profile Send private message Reply with quote
ass0



Joined: 31 Dec 2008
Posts: 521
Location: ( . Y . )
ass0
Yeah i code in Actionscript 3.0 xD and i also know a bit of python, C, php, (javascript of course)...

Why? Do I seem so stupid? xD
Post 03 Aug 2009, 01:44
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
No, its just the things you want to do seem HLL'ish(at least to me). Is there a reason you don't use the FASM includes? They makes things much easier:

Code:
invoke ExitProcess,eax
    

instead of
Code:
push    eax
call    [ExitProcess] 
    


And importing and exporting are similarly simple.
Hand coding stuff your way at most just saves a few bytes.
Post 03 Aug 2009, 01:56
View user's profile Send private message Reply with quote
asmcoder



Joined: 02 Jun 2008
Posts: 784
asmcoder
[content deleted]


Last edited by asmcoder on 14 Aug 2009, 14:47; edited 1 time in total
Post 03 Aug 2009, 02:02
View user's profile Send private message Reply with quote
ass0



Joined: 31 Dec 2008
Posts: 521
Location: ( . Y . )
ass0
All i want is pretty simple, i want to get my dlls sorted:

a1.dll will only contain vars, lots of them (strings and integers).
a2.dll will only contain functions.
a.exe will only load a1.dll and a2.dll.

That's so much to ask?

In any case, thank you very much asmcoder, you rock my world xD.
Post 03 Aug 2009, 02:24
View user's profile Send private message Reply with quote
asmcoder



Joined: 02 Jun 2008
Posts: 784
asmcoder
[content deleted]


Last edited by asmcoder on 14 Aug 2009, 14:47; edited 1 time in total
Post 03 Aug 2009, 02:43
View user's profile Send private message Reply with quote
ass0



Joined: 31 Dec 2008
Posts: 521
Location: ( . Y . )
ass0
I don't know, i think is the only reason for the dlls existence xD
Post 03 Aug 2009, 03:00
View user's profile Send private message Reply with quote
asmcoder



Joined: 02 Jun 2008
Posts: 784
asmcoder
[content deleted]
Post 03 Aug 2009, 04:22
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.