Took a little while to run through, but this is where we end up.
On line 85 of
wp-settings.php, it checks if the
MULTISITE constant has been defined. If so, it loads the multisite files that handle things like figuring out which blog you are on.
One of those files is
/wp-includes/ms-settings.php. I believe it decides which blog you are on at line 50.
$current_site->blog_id = $wpdb->get_var( .... 'SELECT blog_id FROM ... WHERE path = ...' );
$current_site is a global stdClass that gets returned from
ms-settings.php it overwrites it if it hasn't already been forced via config settings.
Also check out
/wp-includes/ms-load.php for info on