It differentiates between forums based on the requested URL. It takes the whole filepath requested on the server, such as mybb/forumname/index.php and I chop it down so that it cuts down the mybb/ and /index.php and leaves only the forumname part. Then it uses forumname plus an underscore as the table prefix in config.php for the database tables. Currently though the forumname part can only be 6 or 7 characters because of the way I do the chopping. If you want to see the code look in the modified config.php file included in my script.
As far as the same userbase goes, there is an easy part and a hard part. The easy part would be copying users from an already established forum, such as the master forum, to a new forum. See my code in mkforum.php for copying the settings table, the same could be done for the users table. (I tried this actually though and it was a bit buggy, which is why I modified things in the final release.) The hard part would be making it when one user registers all forums get the new user. For that to happen you would need to edit the MyBB files so that any time it calls up the users table in the database it calls it up from a master table and not the individual forum's table. You can also add other "default" users so that when a forum is created they are included. You can see my default user named "admin" in the mkforum.php file. This would be good for having say a support user or something similar.
There are, however, greater security concerns with many forums sharing one userbase. The hardest part would be having it where a member is an admin on their own forum but not on all forums when the users table is shared.
BMR777