Max Vernon takes us through the sys.dm_db_database_page_allocations Dynamic Management Function:
sys.dm_db_database_page_allocations is an undocumented SQL Server T-SQL Dynamic Management Function. This DMF provides details about allocated pages, allocation units, and allocation extents.
Read on for additional details. This is an undocumented function, so it might change between versions but it will give you an idea of how it works under the covers.