mgrier's WebLog

Canonical Function Structure

Here is a proposed canonical structure for functions/procedures. Clearly in some cases some sections...

Author: MGrier Date: 10/02/2006

The NT DLL Loader: FreeLibrary()

Let's review the loader's modus operandi and derive the (once again simple!) rules for what the heck...

Author: MGrier Date: 06/29/2005

The NT DLL Loader: DLL_PROCESS_ATTACH reentrancy - wrap up

Hopefully the culmination of these cautionary tales is clear: you're walking a very fine line when...

Author: MGrier Date: 06/28/2005

The NT DLL Loader: DLL_PROCESS_ATTACH reentrancy - step 4 - ramifications of questionable quality

Last time I alluded to the world of hurt you're in when the loader is reentered during...

Author: MGrier Date: 06/28/2005

The NT DLL Loader: DLL_PROCESS_ATTACH reentrancy - step 3 - quality requirements

Now we're loaded for bear! We understand how PEs which are either launched via CreateProcess() or...

Author: MGrier Date: 06/24/2005

The NT DLL Loader: DLL_PROCESS_ATTACH reentrancy - step 2 - GetProcAddress()

Last time we pondered what does LoadLibrary() do when called inside of a DLL_PROCESS_ATTACH callout....

Author: MGrier Date: 06/23/2005

The NT DLL Loader: DLL_PROCESS_ATTACH reentrancy - step 1 - LoadLibrary()

So what happens if you call back into the loader when you're inside a loader callout (DllMain) for...

Author: MGrier Date: 06/22/2005

The NT DLL Loader: reentrancy - play along at home!

Anyone care to hazard a guess about what happens if you have the following code in your DllMain()?...

Author: MGrier Date: 06/22/2005

The NT DLL Loader: DLL callouts (DllMain) - DLL_PROCESS_ATTACH deadlocks

The Windows DLL loader (I wasn't around then but I assume some of this even comes from the days of...

Author: MGrier Date: 06/21/2005

The NT DLL loader: dynamic unloads

To recap our story from last time: The NT DLL loader starts from some PE (either the main EXE or the...

Author: MGrier Date: 06/19/2005

How the NT Loader works

My team maintained the NT loader (the component that loads DLLs) for about a year or so during...

Author: MGrier Date: 06/18/2005

Enough about in-memory models and transactions for now

I want to follow up on this topic of transactional behavior in memory but to motivate it I'm going...

Author: MGrier Date: 06/01/2005

Transactions and in-memory data (part 3 of n)

Last time I laid out a little framework for transactional rollback. It clearly is not sufficient for...

Author: MGrier Date: 05/18/2005

Transactions and in-memory data (part 2 of n)

Buffering the opertations wasn't particularly successful. Let's look at maintaining a rollback log....

Author: MGrier Date: 05/17/2005

Transactions and in-memory data (part 1 of n)

[Maybe I'll fill in the "n" when I'm done. I haven't had time to plan out the entire series...] In...

Author: MGrier Date: 05/11/2005

No Chinese Dictionaries

I want to go on the record and note that I will not be deveoping a Chinese/English Dictionary, in...

Author: MGrier Date: 05/11/2005

More than one way to skin a (transactional) cat

Let's briefly look at how databases deal with transaction rollback. I'm going to ignore a lot of...

Author: MGrier Date: 05/10/2005

Implementation patterns to support transactional functions

Let's go back now to why I had a hard time with using the STL std::map pattern. It was because for...

Author: MGrier Date: 05/10/2005

Local vs. global analysis revisited

I posted that last item before having my coffee so it's really not suprising that I forgot to get...

Author: MGrier Date: 05/09/2005

Whole program vs. local analysis

A quick note for today. Maybe more tonight. Internally at Microsoft, as you can imagine, we have a...

Author: MGrier Date: 05/09/2005

Working with inexact error contracts

Last time I lamented that the fact that std::map::erase() is not permitted to fail made it hard to...

Author: MGrier Date: 05/08/2005

Even good design can't succeed in isolation

I tried three times to write yesterday's entry which was intended to explore the same problems with...

Author: MGrier Date: 05/07/2005

Why is fclose()'s contract so confusing?

Because it’s a long established pattern and contract, let’s explore fclose() today. Here’s my ideal...

Author: MGrier Date: 05/04/2005

What if close could fail?

Yesterday I made the claim that close() can’t fail in a meaningful way. Meaning that if it’s invoked...

Author: MGrier Date: 05/03/2005

Function transactionality

A topic that comes up repeatedly in designing function is what a coworker of mine calls...

Author: MGrier Date: 04/29/2005

Side-effects: a more useful definition

A typical CS-ish definition of whether a function has a side effect is whether the function modifies...

Author: MGrier Date: 04/28/2005

Errors and a simple invariant

Before addressing the problems with close_resource(), I want to explore another avenue which is...

Author: MGrier Date: 04/27/2005

Always check your return codes?

Is there a bug here? int do_work(char *psz) { some_type *p = NULL; int t; if ((t = foo(&p, psz))...

Author: MGrier Date: 04/26/2005

Future examples - standards, conventions

I'm going to start blogging some more and I just wanted to be explicit, as Raymond is, about the...

Author: MGrier Date: 04/26/2005

Versioning - source of all good or evil?

I don’t have a real succinct point tonight, just a long hopefully interesting rant/whine. I...

Author: MGrier Date: 04/15/2004

catch considered harmful

Spot the bug: void CFoo::Bar() { m_array1[m_i++] = null; m_array2[m_j++] = null; } I’ll give...

Author: MGrier Date: 02/18/2004

Gosh, programming is hard!

I've been programming since I was a wee tike of 9. Now, 28 years later, I'm amazed because while I...

Author: MGrier Date: 02/10/2004

Here Goes!

I don't know what to think about this blogging thing but it seems like an interesting mechanism for...

Author: MGrier Date: 02/10/2004