Igor Delovski Board Forum Index Igor Delovski Board
My Own Personal Slashdot!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Best Practices for Creating DLLs

 
Post new topic   Reply to topic    Igor Delovski Board Forum Index -> Win32
Win32  
Author Message
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Fri Jun 16, 2006 11:47 pm    Post subject: Best Practices for Creating DLLs Reply with quote

Microsoft.com: Best Practices for Creating DLLs

"Included in this paper:

• The Library Loader, DLLMain, and the Loader Lock

• Interactions Between the Loader, the Loader Lock, and DLLMain

• Best Practices for Implementing DLLMain"
Back to top
View user's profile Send private message
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Fri Jun 16, 2006 11:55 pm    Post subject: DLLs 4 Dummies Reply with quote

"Does anyone have suggestions for good sites that will help a beginner create a DLL?"

How about Win32 DLL tutorial for beginners?
Back to top
View user's profile Send private message
Tiger
Guest





PostPosted: Tue Jun 20, 2006 2:55 pm    Post subject: Writing a Windows-Versioned File Reply with quote

On Google Groups: Writing a Windows-Versioned File

"If you want to write an new PE file with an information resource from
your own application you can take a look at the image helper och debug
helper API and download the PE/COFF specification.
http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx "
Back to top
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Sat Jul 01, 2006 10:51 pm    Post subject: RC Reply with quote

Old New Thing: Why can't I GetProcAddress a function I dllexport'ed?

"The dllexport attribute tells the linker to generate an export table entry
for the specified function. This export entry is decorated. This is necessary
to support dllexporting of overloaded functions. But it also means that the
string you pass to GetProcAddress needs to be decorated."
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3026
Location: Europe

PostPosted: Thu Jul 06, 2006 5:06 pm    Post subject: Reply with quote

At CodeGuru: DLL can be truly used across linkers?


"It is well known that DLL file can be used across different linkers, for
example, a DLL created by VC can be linked with a VB application. In my
context, I mean implicit linking."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Wed Jul 19, 2006 9:17 pm    Post subject: Reply with quote

Few more articles by Raymond Chen:

Tuesday, July 18 - How are DLL functions exported in 32-bit Windows?

"The designers of 32-bit Windows didn't have to worry quite so much
about squeezing everything into 256KB of memory. Since modules in
Win32 are based on demand-paging, all you have to do is map the entire
image into memory and then run around accessing the parts you need."


Wednesday, July 19 - Exported functions that are really forwarders

"A forwarder looks just like a regular exported function, except that the
entry in the ordinal export table says, 'Oh, I'm not really a function in this
DLL. I'm really a function in that DLL over there.'"


Last edited by delovski on Mon Jul 24, 2006 8:11 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3026
Location: Europe

PostPosted: Mon Jul 24, 2006 4:13 pm    Post subject: Reply with quote

Thu: Rethinking the way DLL exports are resolved for 32-bit Windows

"This means that resolving imported functions is a simple matter of
looking up the target addresses and writing the results into the table of
imported function addresses."


Fri: Calling an imported function, the naive way

"Note that with a naive compiler, if your code tries to take the address
of an imported function, it gets the address of the FunctionName stub,
since a naive compiler simply asks for the address of the FunctionName
symbol, unaware that it's really coming from an import library."


Mon: How a less naive compiler calls an imported function

"As a result of this extra knowledge imparted to the compiler, the stub
function is no longer needed; the compiler knows to go straight to the
imported function address table."
Back to top
View user's profile Send private message
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Fri Jul 28, 2006 12:01 am    Post subject: Reply with quote

Raymond Chen: Index to the series on DLL imports and exports

Titles of all the articles:

  • How were DLL functions exported in 16-bit Windows?
  • How were DLL functions imported in 16-bit Windows?
  • How are DLL functions exported in 32-bit Windows?
  • Exported functions that are really forwarders
  • Rethinking the way DLL exports are resolved for 32-bit Windows
  • Calling an imported function, the naive way
  • How a less naive compiler calls an imported function
  • Issues related to forcing a stub to be created for an imported function
  • What happens when you get dllimport wrong?
  • Names in the import library are decorated for a reason
  • The dangers of dllexport (bonus posting from a few years ago)

Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Sat Jul 29, 2006 12:45 pm    Post subject: Reply with quote

At Flipcode: Creating And Using DLLs,
by Kurt Miller

"So you're interested in making an oh-so-fashionable DLL? Well look no
further. Creating a DLL is a lot easier than you probably think. DLLs
(Dynamic Link Libraries) are very useful when you're writing windows
programs. A good example use would be if you create a number of
programs that all use common functions. In such a case, you can create a
library that they all call functions from."


Plus, Creating Dynamic Link Libraries

"When you want to create a DLL you must generate an export list, which
lists all of the functions which you will allow programs to call directly. It is
a good idea to keep the export list for any one DLL to a managable size.
You create an export list by writing a .def file, which you can use as input
to the dlltool program to create import libraries for your DLL and to create
the special export table that needs to be linked into your DLL."


Last edited by delovski on Mon Dec 11, 2006 5:59 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3026
Location: Europe

PostPosted: Fri Sep 15, 2006 8:07 pm    Post subject: Reply with quote

CBoard: Need someone familiar with DLLs

"I've never written a DLL before and after searching the board and the
web I'm thinking about using them for a program I'm writing. From
someone who has used DLLs I just wanted some input as to whether what
I'm doing is stupid/mis-usage of DLLs or not."


...

"Yeppers, that satisfied me. Didn't know the compiler was renaming my
functions.. what a dirty thing to do Smile"
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Mon Dec 11, 2006 5:45 pm    Post subject: Reply with quote

DLL Tutorial: A Tutorial on creating DLLs with VC++

"Start VC++ IDE , select New from File menu.

Then select Win32 Dynamic - link library from Projects tab. Enter project
name as example1 , then click OK button. Now you can see a dialog box
with caption Win32 Dynamic - Link library - step 1 of 1."
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Mon Dec 11, 2006 5:54 pm    Post subject: Reply with quote

msdn: Rebasing Win32 DLLs: The Whole Story,
by Ruediger R. Asche, September 18, 1995

"This article discusses the ramifications of dynamic-link library (DLL)
rebasing under both Microsoft® Windows NT® and Windows® 95.
("Rebasing" in this context refers to the process of changing the base
address of a DLL in memory space.) A sample application accompanies
this article, as well as a suite of DLLs to provide comparison figures."
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Thu Jan 11, 2007 10:21 am    Post subject: Reply with quote

C Board: Who Called My DLL? And Component Security

"Unfortunately, the GUI is provided by C# applications, which are for the
most part a reversable language. Any password would be easy to duplicate
and fool. My current implimentation actually uses the filename, and produces
a MD5 hash of the calling executable. The valid md5 hashes are hard coded
and base64'd inside the DLL, so it wont be easy to find and hex edit."
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3026
Location: Europe

PostPosted: Thu Jul 03, 2008 6:46 pm    Post subject: Reply with quote

RC: Uninitialized floating point variables can be deadly

"The problem was that, if you are sufficiently unlucky, the leftover values
in the memory assigned to the dblValue will happen to have a bit pattern
corresponding to a SNaN. And then when the processor tries to copy it to
dblResult, then exception is raised."


Next Day: How did the invalid floating point operand exception get
raised when I disabled it?


"It turns out that the customer's printer driver was re-enabling the invalid
operand exception in its DLL_PROCESS_ATTACH handler. ... This behavior
can be traced back to old versions of the C runtime library which reset the
floating point state as part of their DLL_PROCESS_ATTACH"
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3026
Location: Europe

PostPosted: Sun Aug 17, 2008 7:32 pm    Post subject: Reply with quote

RC: If you return FALSE from DLL_PROCESS_ATTACH, will you get a DLL_PROCESS_DETACH?

"However, most C and C++ programs do not use the raw DLL entry point.
Instead, they use the C runtime entry point, which will have a name something
like DllMainCRTStartup. That entry point function does work to manage the C
runtime library and calls your entry point (which you've probably called DllMain)
to see what you think."
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Igor Delovski Board Forum Index -> Win32 All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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


Delovski.hr
Powered by php-B.B. © 2001, 2005 php-B.B. Group