Sign in
mgrier's WebLog
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Options
Email Blog Author
RSS for posts
Atom
RSS for comments
OK
Search
Tags
No tags have been created or used yet.
Archive
Archives
October 2006
(1)
June 2005
(11)
May 2005
(14)
April 2005
(5)
July 2004
(1)
April 2004
(1)
February 2004
(3)
Posts
Subscribe via RSS
Sort by:
Most Recent
|
Most Views
|
Most Comments
Excerpt View
|
Full Post View
mgrier's WebLog
The NT DLL Loader: FreeLibrary()
Posted
over 8 years ago
by
MGrier
6
Comments
Let's review the loader's modus operandi and derive the (once again simple!) rules for what the heck is going on. When someone calls FreeLibrary(hInstance), the loader walks the closure of the dependencies for the module/instance in question and if...
mgrier's WebLog
The NT DLL Loader: DLL_PROCESS_ATTACH reentrancy - wrap up
Posted
over 8 years ago
by
MGrier
2
Comments
Hopefully the culmination of these cautionary tales is clear: you're walking a very fine line when you attempt to reenter the loader from within a loader callout. You're (more!) subject to ordering and cycle issues, you can force initialization to proceed...
mgrier's WebLog
The NT DLL Loader: DLL_PROCESS_ATTACH reentrancy - step 4 - ramifications of questionable quality
Posted
over 8 years ago
by
MGrier
1
Comments
Last time I alluded to the world of hurt you're in when the loader is reentered during DLL_PROCESS_ATTACH and the initialization of another DLL failed. The state of the affairs is pretty derivable from the clues that I've left behind in the series...
mgrier's WebLog
The NT DLL Loader: DLL_PROCESS_ATTACH reentrancy - step 3 - quality requirements
Posted
over 8 years ago
by
MGrier
8
Comments
Now we're loaded for bear! We understand how PEs which are either launched via CreateProcess() or loaded via LoadLibrary() are the roots of directed cyclic graphs. Each new graph is turned into a linear initialization-order list where nodes further from...
mgrier's WebLog
The NT DLL Loader: DLL_PROCESS_ATTACH reentrancy - step 2 - GetProcAddress()
Posted
over 8 years ago
by
MGrier
3
Comments
Last time we pondered what does LoadLibrary() do when called inside of a DLL_PROCESS_ATTACH callout. The answer was pretty simple and predictable - the only nuance is that the initializers are not run before returning. Now place yourself in the position...
mgrier's WebLog
The NT DLL Loader: DLL_PROCESS_ATTACH reentrancy - step 1 - LoadLibrary()
Posted
over 8 years ago
by
MGrier
7
Comments
So what happens if you call back into the loader when you're inside a loader callout (DllMain) for DLL_PROCESS_ATTACH? I'll be addressing teardown (DLL_PROCESS_DETACH) after completing the DLL_PROCESS_ATTACH series. The first issue is: what about...
mgrier's WebLog
The NT DLL Loader: reentrancy - play along at home!
Posted
over 8 years ago
by
MGrier
12
Comments
Anyone care to hazard a guess about what happens if you have the following code in your DllMain()? Ignore the leak and the lack of error checking; focus on the what the loader's behavior has to be... BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason...
mgrier's WebLog
The NT DLL Loader: DLL callouts (DllMain) - DLL_PROCESS_ATTACH deadlocks
Posted
over 8 years ago
by
MGrier
14
Comments
The Windows DLL loader (I wasn't around then but I assume some of this even comes from the days of 16-bit Windows) has a feature where a DLL may have an "entry point". If a DLL has an entry point, the loader calls into it on certain significant events...
mgrier's WebLog
The NT DLL loader: dynamic unloads
Posted
over 8 years ago
by
MGrier
5
Comments
To recap our story from last time: The NT DLL loader starts from some PE (either the main EXE or the DLL which is passed in to the LoadLibrary() API), walks the graph of static imports rooted with that first PE. You can think of the loader as then...
mgrier's WebLog
The NT DLL Loader: basic operation
Posted
over 8 years ago
by
MGrier
6
Comments
Let's start simply and consider the mythical vertical application (a topic itself for another day). I'm not going to walk through what a PE is or a DLL or an EXE; if you don't know, follow the link or take a gander around MSDN. Let's call it ccalc...
mgrier's WebLog
How the NT Loader works
Posted
over 8 years ago
by
MGrier
12
Comments
My team maintained the NT loader (the component that loads DLLs) for about a year or so during Windows XP as we were adding the isolated application features to it so we got quite an interesting perspective on this lovely little piece of technology. Warning...
Page 1 of 1 (11 items)