flat assembler
Message board for the users of flat assembler.

Index > Windows > How does Shared Library (DLL) Works?

Author
Thread Post new topic Reply to topic
ivan_tux



Joined: 23 Jun 2012
Posts: 27
Location: Indonesia
ivan_tux
I have 2 libraries with same base address, say A and B.
Then a program using both A and B.

What happen?
The program run perfectly without problems...
Can you tell me what happen when i call a function from library?
Post 12 Mar 2013, 06:38
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
ivan_tux,

Remove relocations from both A and B, then you'll see. Wink
Post 12 Mar 2013, 06:41
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
Window loader will relocate one of DLLs (A or B, depending on which DLL was loaded first) to a new base address.
The base address inside of DLL itself is a suggestion and if there is a conflict -- DLL gets relocated.
Post 12 Mar 2013, 12:34
View user's profile Send private message Send e-mail Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
With ASLR enabled, images will be relocated from their base address even if there are no conflicts.
Post 12 Mar 2013, 13:24
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
ACP



Joined: 23 Sep 2006
Posts: 204
ACP
Tip: I'd suggest running the program under debugger to see how Windows manages it all for educational purposes.
Post 12 Mar 2013, 15:38
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Another tip: Matt Pietrek wrote a whole bunch of articles about Windows loader. There was (and probably still is) Windows Research Kernel available for exploration, too.
Post 12 Mar 2013, 16:07
View user's profile Send private message Reply with quote
ACP



Joined: 23 Sep 2006
Posts: 204
ACP
baldr wrote:
Another tip: Matt Pietrek wrote a whole bunch of articles about Windows loader. There was (and probably still is) Windows Research Kernel available for exploration, too.


Good point baldr! Two great articles about PE format from great Matt Pietrek (wish MS incorporated some of ideas and UI from SoftIce to windbg when they hired him):

Original one: http://msdn.microsoft.com/en-us/library/ms809762.aspx

Updated version from 2002: http://msdn.microsoft.com/en-us/magazine/cc301805.aspx
Post 12 Mar 2013, 16:13
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
ACP,

When big bucks want to shut up independent explorer, they hire him (or her). Though Mark Russinovich still struggles. Wink
Post 12 Mar 2013, 16:32
View user's profile Send private message Reply with quote
ivan_tux



Joined: 23 Jun 2012
Posts: 27
Location: Indonesia
ivan_tux
How about all global variables?
Oh, wait... I know. Does it helped by "relocation table"?
If so, how it work? i'm not understand it...
Post 17 Mar 2013, 06:13
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
ivan_tux,

They're not so global (unless section is shared). DLL simply exports some names/ordinals that have some addresses (wrt DLL image base; they don't even have to be resident to it).

What do you really want to know? How loader relocates DLL in case of VAS clash? How it snaps externals? State your problem exactly (and read that fine articles by Matt Pietrek, at least).
Post 17 Mar 2013, 06:32
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 693
Location: Adelaide
sinsi
Post 17 Mar 2013, 07:14
View user's profile Send private message Reply with quote
ivan_tux



Joined: 23 Jun 2012
Posts: 27
Location: Indonesia
ivan_tux
Ok, thanks for all..
I've found the answers Very Happy
Post 24 Mar 2013, 06:27
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.

Powered by rwasa.