public static ContentDatabaseSession OpenDatabase(string path) { //Open file DatabaseFile file = DatabaseFile.LoadFile(path); //Open DB var db = new ContentDatabaseSession(file); //Read TOC if (db.tocPage != -1) { //Read blob byte[] tocBytes = file.ReadBlob(db.tocPage); int count = tocBytes.Length / TOC_ENTRY_LENGTH; BufferBinaryTool reader = new BufferBinaryTool(tocBytes); //Add all for (int i = 0; i < count; i++) { int offset = TOC_ENTRY_LENGTH * i; DatabaseObjectHeader entry = new DatabaseObjectHeader(); entry.object_id = reader.ReadUInt64(offset + 0); entry.page_id = reader.ReadUInt64(offset + 8); entry.commit_id = reader.ReadUInt64(offset + 16); entry.group_id = reader.ReadInt32(offset + 24); entry.commit_type = tocBytes[offset + 28]; entry.flags = tocBytes[offset + 29]; entry.reserved = reader.ReadUInt16(offset + 30); db.objects.Add(entry); } } //Read Name Table if (db.nameTablePage != -1) { //Read blob byte[] ntBytes = file.ReadBlob(db.nameTablePage); BufferBinaryTool reader = new BufferBinaryTool(ntBytes); //Begin reading int index = 0; while (index < ntBytes.Length) { //Read length int length = reader.ReadInt32(index); //Read string db.nameTable.Add(Encoding.ASCII.GetString(ntBytes, index + 4, length)); //Update index += length + 4; } } return(db); }