PST File Format SDK v0.4
Loading...
Searching...
No Matches
disk.h
Go to the documentation of this file.
1
9
10#ifndef PSTSDK_DISK_DISK_H
11#define PSTSDK_DISK_DISK_H
12
13#include <cstddef>
14
16
18namespace pstsdk
19{
21namespace disk
22{
23
28template<typename T>
38static_assert(sizeof(block_reference<ulong>) == 8, "block_reference<ulong> incorrect size");
39static_assert(sizeof(block_reference<ulonglong>) == 16, "block_reference<ulonglong> incorrect size");
41
42//
43// header
44//
45
48
52const size_t header_fmap_entries = 128;
53
57const size_t header_fpmap_size = 128;
58
62const size_t header_lock_entries = 32;
63
74
83
86const ushort pst_magic = 0x4D53;
89const ushort ost_magic = 0x4F53;
90
102
111template<typename T>
129static_assert(sizeof(root<ulong>) == 40, "root<ulong> incorrect size");
130static_assert(sizeof(root<ulonglong>) == 80, "root<ulonglong> incorrect size");
131static_assert(offsetof(root<ulonglong>, cOrphans) == 0, "root<ulonglong> cOrphans at incorrect offset");
132static_assert(offsetof(root<ulonglong>, ibFileEof) == 8, "root<ulonglong> ibFileEof at incorrect offset");
133static_assert(offsetof(root<ulonglong>, ibAMapLast) == 16, "root<ulonglong> ibAMapLast at incorrect offset");
134static_assert(offsetof(root<ulonglong>, cbAMapFree) == 24, "root<ulonglong> cbAMapFree at incorrect offset");
135static_assert(offsetof(root<ulonglong>, cbPMapFree) == 32, "root<ulonglong> cbPMapFree at incorrect offset");
136static_assert(offsetof(root<ulonglong>, brefNBT) == 40, "root<ulonglong> brefNBT at incorrect offset");
137static_assert(offsetof(root<ulonglong>, brefBBT) == 56, "root<ulonglong> brefBBT at incorrect offset");
138static_assert(offsetof(root<ulonglong>, fAMapValid) == 72, "root<ulonglong> fAMapValid at incorrect offset");
139static_assert(offsetof(root<ulonglong>, bARVec) == 73, "root<ulonglong> bARVec at incorrect offset");
140static_assert(offsetof(root<ulonglong>, cARVec) == 74, "root<ulonglong> cARVec at incorrect offset");
142
148const uint hlmagic = 0x4e444221;
149
151template<typename T>
152struct header
153{
156
164template<>
165struct header<ulonglong>
166{
169 typedef ulonglong count;
170
186 byte rgbFP[header_fpmap_size];
189 byte rgbReserved[2];
190#ifdef __GNUC__
191 // GCC refuses to pack this next to rgbReserved
192 byte bidNextB[8];
193#else
194#pragma pack(4)
196#pragma pack()
197#endif
199 byte rgbVersionEncoded[3];
201 byte rgbLock[header_lock_entries];
204static_assert(sizeof(header<ulonglong>) == 568, "header<ulonglong> incorrect size");
205static_assert(offsetof(header<ulonglong>, rgnid) == 44, "header<ulonglong> rgnid at incorrect offset");
206static_assert(offsetof(header<ulonglong>, root_info) == 176, "header<ulonglong> root_info at incorrect offset");
207static_assert(offsetof(header<ulonglong>, rgbFM) == 256, "header<ulonglong> rgbFM at incorrect offset");
208static_assert(offsetof(header<ulonglong>, dwCRCFull) == 524, "header<ulonglong> dwCRCFull at incorrect offset");
210
217template<>
254static_assert(sizeof(header<ulong>) == 512, "header<ulong> incorrect size");
255static_assert(offsetof(header<ulong>, rgnid) == 36, "header<ulong> rgnid at incorrect offset");
256static_assert(offsetof(header<ulong>, rgbFM) == 204, "header<ulong> rgbFM at incorrect offset");
258
260template<typename T>
261struct header_crc_locations
262{
265
269template<>
270struct header_crc_locations<ulong>
271{
272 static const size_t start = offsetof(header<ulong>, wMagicClient);
273 static const size_t end = offsetof(header<ulong>, bLockSemaphore);
274 static const size_t length = end - start;
276
281template<>
282struct header_crc_locations<ulonglong>
283{
284 static const size_t partial_start = header_crc_locations<ulong>::start;
285 static const size_t partial_end = header_crc_locations<ulong>::end;
286 static const size_t partial_length = header_crc_locations<ulong>::length;
287 static const size_t full_start = offsetof(header<ulonglong>, wMagicClient);
288 static const size_t full_end = offsetof(header<ulonglong>, dwCRCFull);
289 static const size_t full_length = full_end - full_start;
291
292//
293// utility functions
294//
295
298
301const ulong crc_table[] = {
302 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F,
303 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
304 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2,
305 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
306 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9,
307 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
308 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C,
309 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
310 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423,
311 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
312 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106,
313 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
314 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D,
315 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
316 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950,
317 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
318 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7,
319 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
320 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA,
321 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
322 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81,
323 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
324 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84,
325 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
326 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB,
327 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
328 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E,
329 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
330 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55,
331 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
332 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28,
333 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
334 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F,
335 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
336 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242,
337 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
338 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69,
339 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
340 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC,
341 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
342 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693,
343 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
344 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
345};
346
350const byte table1[] =
351{
352 65, 54, 19, 98, 168, 33, 110, 187,
353 244, 22, 204, 4, 127, 100, 232, 93,
354 30, 242, 203, 42, 116, 197, 94, 53,
355 210, 149, 71, 158, 150, 45, 154, 136,
356 76, 125, 132, 63, 219, 172, 49, 182,
357 72, 95, 246, 196, 216, 57, 139, 231,
358 35, 59, 56, 142, 200, 193, 223, 37,
359 177, 32, 165, 70, 96, 78, 156, 251,
360 170, 211, 86, 81, 69, 124, 85, 0,
361 7, 201, 43, 157, 133, 155, 9, 160,
362 143, 173, 179, 15, 99, 171, 137, 75,
363 215, 167, 21, 90, 113, 102, 66, 191,
364 38, 74, 107, 152, 250, 234, 119, 83,
365 178, 112, 5, 44, 253, 89, 58, 134,
366 126, 206, 6, 235, 130, 120, 87, 199,
367 141, 67, 175, 180, 28, 212, 91, 205,
368 226, 233, 39, 79, 195, 8, 114, 128,
369 207, 176, 239, 245, 40, 109, 190, 48,
370 77, 52, 146, 213, 14, 60, 34, 50,
371 229, 228, 249, 159, 194, 209, 10, 129,
372 18, 225, 238, 145, 131, 118, 227, 151,
373 230, 97, 138, 23, 121, 164, 183, 220,
374 144, 122, 92, 140, 2, 166, 202, 105,
375 222, 80, 26, 17, 147, 185, 82, 135,
376 88, 252, 237, 29, 55, 73, 27, 106,
377 224, 41, 51, 153, 189, 108, 217, 148,
378 243, 64, 84, 111, 240, 198, 115, 184,
379 214, 62, 101, 24, 68, 31, 221, 103,
380 16, 241, 12, 25, 236, 174, 3, 161,
381 20, 123, 169, 11, 255, 248, 163, 192,
382 162, 1, 247, 46, 188, 36, 104, 117,
383 13, 254, 186, 47, 181, 208, 218, 61,
384};
385
389const byte table2[] =
390{
391 20, 83, 15, 86, 179, 200, 122, 156,
392 235, 101, 72, 23, 22, 21, 159, 2,
393 204, 84, 124, 131, 0, 13, 12, 11,
394 162, 98, 168, 118, 219, 217, 237, 199,
395 197, 164, 220, 172, 133, 116, 214, 208,
396 167, 155, 174, 154, 150, 113, 102, 195,
397 99, 153, 184, 221, 115, 146, 142, 132,
398 125, 165, 94, 209, 93, 147, 177, 87,
399 81, 80, 128, 137, 82, 148, 79, 78,
400 10, 107, 188, 141, 127, 110, 71, 70,
401 65, 64, 68, 1, 17, 203, 3, 63,
402 247, 244, 225, 169, 143, 60, 58, 249,
403 251, 240, 25, 48, 130, 9, 46, 201,
404 157, 160, 134, 73, 238, 111, 77, 109,
405 196, 45, 129, 52, 37, 135, 27, 136,
406 170, 252, 6, 161, 18, 56, 253, 76,
407 66, 114, 100, 19, 55, 36, 106, 117,
408 119, 67, 255, 230, 180, 75, 54, 92,
409 228, 216, 53, 61, 69, 185, 44, 236,
410 183, 49, 43, 41, 7, 104, 163, 14,
411 105, 123, 24, 158, 33, 57, 190, 40,
412 26, 91, 120, 245, 35, 202, 42, 176,
413 175, 62, 254, 4, 140, 231, 229, 152,
414 50, 149, 211, 246, 74, 232, 166, 234,
415 233, 243, 213, 47, 112, 32, 242, 31,
416 5, 103, 173, 85, 16, 206, 205, 227,
417 39, 59, 218, 186, 215, 194, 38, 212,
418 145, 29, 210, 28, 34, 51, 248, 250,
419 241, 90, 239, 207, 144, 182, 139, 181,
420 189, 192, 191, 8, 151, 30, 108, 226,
421 97, 224, 198, 193, 89, 171, 187, 88,
422 222, 95, 223, 96, 121, 126, 178, 138,
423};
424
428const byte table3[] =
429{
430 71, 241, 180, 230, 11, 106, 114, 72,
431 133, 78, 158, 235, 226, 248, 148, 83,
432 224, 187, 160, 2, 232, 90, 9, 171,
433 219, 227, 186, 198, 124, 195, 16, 221,
434 57, 5, 150, 48, 245, 55, 96, 130,
435 140, 201, 19, 74, 107, 29, 243, 251,
436 143, 38, 151, 202, 145, 23, 1, 196,
437 50, 45, 110, 49, 149, 255, 217, 35,
438 209, 0, 94, 121, 220, 68, 59, 26,
439 40, 197, 97, 87, 32, 144, 61, 131,
440 185, 67, 190, 103, 210, 70, 66, 118,
441 192, 109, 91, 126, 178, 15, 22, 41,
442 60, 169, 3, 84, 13, 218, 93, 223,
443 246, 183, 199, 98, 205, 141, 6, 211,
444 105, 92, 134, 214, 20, 247, 165, 102,
445 117, 172, 177, 233, 69, 33, 112, 12,
446 135, 159, 116, 164, 34, 76, 111, 191,
447 31, 86, 170, 46, 179, 120, 51, 80,
448 176, 163, 146, 188, 207, 25, 28, 167,
449 99, 203, 30, 77, 62, 75, 27, 155,
450 79, 231, 240, 238, 173, 58, 181, 89,
451 4, 234, 64, 85, 37, 81, 229, 122,
452 137, 56, 104, 82, 123, 252, 39, 174,
453 215, 189, 250, 7, 244, 204, 142, 95,
454 239, 53, 156, 132, 43, 21, 213, 119,
455 52, 73, 182, 18, 10, 127, 113, 136,
456 253, 157, 24, 65, 125, 147, 216, 88,
457 44, 206, 254, 36, 175, 222, 184, 54,
458 200, 161, 128, 166, 153, 152, 168, 47,
459 14, 129, 101, 115, 228, 194, 162, 138,
460 212, 225, 17, 208, 8, 139, 42, 242,
461 237, 154, 100, 63, 193, 108, 249, 236
462};
463
471template<typename T>
472ushort compute_signature(T id, T address);
473
480template<typename T>
481ushort compute_signature(const block_reference<T>& reference) { return compute_signature(reference.bid, reference.ib); }
482
489ulong compute_crc(const void * pdata, ulong cb);
490
500void permute(void * pdata, ulong cb, bool encrypt);
501
511void cyclic(void * pdata, ulong cb, ulong key);
512
513
514//
515// page structures
516//
517
520
521
525const size_t page_size = 512;
526
542
544template<typename T>
545struct page_trailer
546{
549
555template<>
567static_assert(sizeof(page_trailer<ulonglong>) == 16, "page_trailer<ulonglong> incorrect size");
569
576template<>
588static_assert(sizeof(page_trailer<ulong>) == 12, "page_trailer<ulong> incorrect size");
590
595template<typename T>
596struct page
597{
598 static const size_t page_data_size = page_size - sizeof(page_trailer<T>);
599
601 page_trailer<T> trailer;
604static_assert(sizeof(page<ulong>) == page_size, "page<ulong> incorrect size");
605static_assert(sizeof(page<ulonglong>) == page_size, "page<ulonglong> incorrect size");
607
611const size_t bytes_per_slot = 64;
612
616const size_t first_amap_page_location = 0x4400;
617
629template<typename T>
630struct amap_page : public page<T>
631{
634static_assert(sizeof(amap_page<ulong>) == page_size, "amap_page<ulong> incorrect size");
635static_assert(sizeof(amap_page<ulonglong>) == page_size, "amap_page<ulonglong> incorrect size");
637
648template<typename T>
649struct pmap_page : public page<T>
650{
653static_assert(sizeof(pmap_page<ulong>) == page_size, "pmap_page<ulong> incorrect size");
654static_assert(sizeof(pmap_page<ulonglong>) == page_size, "pmap_page<ulonglong> incorrect size");
656
666template<typename T>
667struct fmap_page : public page<T>
668{
671static_assert(sizeof(fmap_page<ulong>) == page_size, "fmap_page<ulong> incorrect size");
672static_assert(sizeof(fmap_page<ulonglong>) == page_size, "fmap_page<ulonglong> incorrect size");
674
688template<typename T>
689struct fpmap_page : public page<T>
690{
693static_assert(sizeof(fpmap_page<ulong>) == page_size, "fpmap_page<ulong> incorrect size");
694static_assert(sizeof(fpmap_page<ulonglong>) == page_size, "fpmap_page<ulonglong> incorrect size");
696
700const size_t dlist_page_location = 0x4200;
701
711template<typename T>
713{
714 static const size_t extra_space = page<T>::page_data_size - 8;
715 static const size_t max_entries = extra_space / sizeof(ulong);
716
717 byte flags;
719 union
720 {
723 };
724 union
725 {
728 };
729 page_trailer<T> trailer;
732static_assert(sizeof(dlist_page<ulong>) == page_size, "dlist_page<ulong> incorrect size");
733static_assert(sizeof(dlist_page<ulonglong>) == page_size, "dlist_page<ulonglong> incorrect size");
735
739const ulong dlist_page_num_mask = 0x0000FFFF;
740
745
750inline ulong dlist_get_page_num(ulong entry) { return entry & dlist_page_num_mask; }
751
756inline ulong dlist_get_slots(ulong entry) { return entry >> dlist_slots_shift; }
757
764template<typename T>
773static_assert(sizeof(bt_entry<ulong>) == 12, "bt_entry<ulong> incorrect size");
774static_assert(sizeof(bt_entry<ulonglong>) == 24, "bt_entry<ulonglong> incorrect size");
776
783template<typename T>
795static_assert(sizeof(nbt_leaf_entry<ulong>) == 16, "nbt_leaf_entry<ulong> incorrect size");
796static_assert(sizeof(nbt_leaf_entry<ulonglong>) == 32, "nbt_leaf_entry<ulonglong> incorrect size");
798
805template<typename T>
813static_assert(sizeof(bbt_leaf_entry<ulong>) == 12, "bbt_leaf_entry<ulong> incorrect size");
814static_assert(sizeof(bbt_leaf_entry<ulonglong>) == 24, "bbt_leaf_entry<ulonglong> incorrect size");
816
827template<typename T, typename EntryType>
829{
830 static const size_t extra_space = page<T>::page_data_size - (sizeof(T) * sizeof(byte));
831 static const size_t max_entries = extra_space / sizeof(EntryType);
832 union
833 {
836 };
837
841 byte level;
842
843 page_trailer<T> trailer;
846namespace detail {
847 // We can't pass types containing "," to offsetof, because it's a
848 // preprocessor macro, and it doesn't really understand how to parse an
849 // argument list. So we declare some aliases in a "detail" namespace
850 // where they won't pollute the header.
851 typedef bt_page<ulong, bt_entry<ulong> > bt_page_ulong;
852 typedef bt_page<ulonglong, bt_entry<ulonglong> > bt_page_ulonglong;
853}
854static_assert(offsetof(detail::bt_page_ulong, num_entries) == 496, "bt_page<ulong, bt_entry<ulong> > num_entries at incorrect offset");
855static_assert(offsetof(detail::bt_page_ulonglong, num_entries) == 488, "bt_page<ulonglong, bt_entry<ulonglong> > num_entries at incorrect offset");
856static_assert(offsetof(detail::bt_page_ulong, trailer) == 500, "bt_page<ulong, bt_entry<ulong> > trailer at incorrect offset");
857static_assert(offsetof(detail::bt_page_ulonglong, trailer) == 496, "bt_page<ulonglong, bt_entry<ulonglong> > trailer at incorrect offset");
859
866template<typename T>
867struct nbt_nonleaf_page : public bt_page<T, bt_entry<T> >
868{
871static_assert(sizeof(nbt_nonleaf_page<ulong>) == page_size, "nbt_nonleaf_page<ulong> incorrect size");
872static_assert(sizeof(nbt_nonleaf_page<ulonglong>) == page_size, "nbt_nonleaf_page<ulonglong> incorrect size");
874
882template<typename T>
883struct bbt_nonleaf_page : public bt_page<T, bt_entry<T> >
884{
887static_assert(sizeof(bbt_nonleaf_page<ulong>) == page_size, "bbt_nonleaf_page<ulong> incorrect size");
888static_assert(sizeof(bbt_nonleaf_page<ulonglong>) == page_size, "bbt_nonleaf_page<ulonglong> incorrect size");
890
898template<typename T>
899struct nbt_leaf_page : public bt_page<T, nbt_leaf_entry<T> >
900{
903static_assert(sizeof(nbt_leaf_page<ulong>) == page_size, "nbt_leaf_page<ulong> incorrect size");
904static_assert(sizeof(nbt_leaf_page<ulonglong>) == page_size, "nbt_leaf_page<ulonglong> incorrect size");
906
914template<typename T>
915struct bbt_leaf_page : public bt_page<T, bbt_leaf_entry<T> >
916{
919static_assert(sizeof(bbt_leaf_page<ulong>) == page_size, "bbt_leaf_page<ulong> incorrect size");
920static_assert(sizeof(bbt_leaf_page<ulonglong>) == page_size, "bbt_leaf_page<ulonglong> incorrect size");
922
923//
924// block structures
925//
926
929
933const size_t max_block_disk_size = 8 * 1024;
934
944
953template<typename T>
954size_t align_disk(size_t size);
955
963size_t align_slot(size_t size);
964
969
974
979
986template<typename T>
987bool bid_is_external(T bid) { return ((bid & block_id_internal_bit) == 0); }
988
995template<typename T>
996bool bid_is_internal(T bid) { return !bid_is_external(bid); }
997
999template<typename T>
1000struct block_trailer
1001{
1004
1014template<>
1025static_assert(sizeof(block_trailer<ulonglong>) == 16, "block_trailer<ulonglong> incorrect size");
1027
1035template<>
1046static_assert(sizeof(block_trailer<ulong>) == 12, "block_trailer<ulong> incorrect size");
1048
1057template<typename T>
1059{
1060 static const size_t max_size = max_block_disk_size - sizeof(block_trailer<T>);
1061 byte data[1];
1063
1065template<typename T>
1066struct extended_block
1067{
1070
1082template<>
1096
1104template<>
1106{
1108
1109 static const size_t max_count = ((4096L) - sizeof(block_trailer<ulong>) - 8) / sizeof(extended_block<ulong>::block_id_disk);
1111
1113 byte level;
1118
1126template<typename T>
1136static_assert(sizeof(sub_leaf_entry<ulong>) == 12, "sub_leaf_entry<ulong> incorrect size");
1137static_assert(sizeof(sub_leaf_entry<ulonglong>) == 24, "sub_leaf_entry<ulonglong> incorrect size");
1139
1147template<typename T>
1156static_assert(sizeof(sub_nonleaf_entry<ulong>) == 8, "sub_nonleaf_entry<ulong> incorrect size");
1157static_assert(sizeof(sub_nonleaf_entry<ulonglong>) == 16, "sub_nonleaf_entry<ulonglong> incorrect size");
1159
1169template<typename T, typename EntryType>
1171{
1173 byte level;
1175 EntryType entry[1];
1177
1185template<typename T>
1186struct sub_nonleaf_block : public sub_block<T, sub_nonleaf_entry<T> >
1187{
1189
1197template<typename T>
1198struct sub_leaf_block : public sub_block<T, sub_leaf_entry<T> >
1199{
1201
1202//
1203// heap structures
1204//
1205
1208
1212const byte heap_signature = 0xEC;
1213
1217
1221
1226{
1227 heap_sig_gmp = 0x6C, //< Internal
1228 heap_sig_tc = 0x7C, //< Table context
1229 heap_sig_smp = 0x8C, //< Internal
1230 heap_sig_hmp = 0x9C, //< Internal
1231 heap_sig_ch = 0xA5, //< \deprecated Internal
1232 heap_sig_chtc = 0xAC, //< \deprecated Internal
1233 heap_sig_bth = 0xB5, //< BTree on Heap
1234 heap_sig_pc = 0xBC, //< Property Context
1235};
1236
1240{
1241 heap_fill_empty, //< >= 3584 bytes free
1242 heap_fill_1, //< 2560 - 3583 bytes free
1243 heap_fill_2, //< 2048 - 2559 bytes free
1244 heap_fill_3, //< 1792 - 2047 bytes free
1245 heap_fill_4, //< 1536 - 1791 bytes free
1246 heap_fill_5, //< 1280 - 1535 bytes free
1247 heap_fill_6, //< 1024 - 1279 bytes free
1248 heap_fill_7, //< 768 - 1023 bytes free
1249 heap_fill_8, //< 512 - 767 bytes free
1250 heap_fill_9, //< 256 - 511 bytes free
1251 heap_fill_10, //< 128 - 255 bytes free
1252 heap_fill_11, //< 64 - 127 bytes free
1253 heap_fill_12, //< 32 - 63 bytes free
1254 heap_fill_13, //< 16 - 31 bytes free
1255 heap_fill_14, //< 8 - 15 bytes free
1256 heap_fill_full //< < 8 bytes free
1258
1272
1280
1291
1311
1312//
1313// bth structures
1314//
1315
1318
1331
1340#pragma pack(2)
1341template<typename K>
1347#pragma pack()
1349static_assert(sizeof(bth_nonleaf_entry<ushort>) == 6, "bth_nonleaf_entry<ushort> incorrect size");
1351
1359template<typename K, typename V>
1365
1378template<typename EntryType>
1380{
1381 EntryType entries[1];
1383
1391template<typename K, typename V>
1392struct bth_leaf_node : bth_node<bth_leaf_entry<K,V> >
1393{
1395
1403template<typename K>
1404struct bth_nonleaf_node : bth_node<bth_nonleaf_entry<K> >
1405{
1407
1408//
1409// pc structures
1410//
1411
1414
1422#pragma pack(2)
1424{
1425 ushort type; //$< Property type
1426 heapnode_id id; //$< Heapnode id for variable length properties, or the value directly for fixed size property types
1427};
1428#pragma pack()
1430static_assert(sizeof(bth_leaf_entry<ushort, prop_entry>) == 8, "bth_leaf_entry<ushort, prop_entry> incorrect size");
1432
1439{
1440 node_id nid; //$< The subnode id containing the data for the object
1441 ulong size; //$< The size of the object
1443
1452{
1453 ulong count; //$< Number of entries in the TOC
1454 ulong offsets[1]; //$< Array of offsets for the start of each entry
1456
1457//
1458// tc structures
1459//
1460
1463
1468{
1469 tc_offsets_four, //$< Offset of the end of the four and eight byte columns
1470 tc_offsets_two, //$< Offset of the end of the two byte columns
1471 tc_offsets_one, //$< Offset of the end of the one byte columns
1472 tc_offsets_bitmap, //$< Offset of the end of the existance bitmap
1473 tc_offsets_max //$< Number of entries in the offset array
1475
1479#pragma pack(2)
1481{
1482 ushort type; //$< Column property type
1483 prop_id id; //$< Column property id
1484 ushort offset; //$< Offset into the row
1485 byte size; //$< Width of the column
1486 byte bit_offset; //$< Bit offset into the existance bitmap
1487};
1488
1506
1511{
1512 byte signature; //$< TC signature, \ref heap_sig_tc
1513 byte num_columns; //$< Number of columns in this table
1514 ushort size_offsets[tc_offsets_max]; // Row offset array, see \ref tc_offsets
1515 heap_id row_btree_id; //$< The bth_header allocation for the row mapping btree
1516 heapnode_id row_matrix_id; //$< The heapnode_id allocation for the row matrix
1517 byte unused[4];
1518 column_description columns[1]; //$< Column description array, of length num_columns
1519};
1520
1537#pragma pack()
1538
1539//
1540// nameid structures
1541//
1542
1545
1553{
1554 union
1555 {
1558 };
1561
1576static_assert(sizeof(nameid) == 8, "nameid incorrect size");
1577static_assert(sizeof(nameid_hash_entry) == 8, "nameid incorrect size");
1579
1585inline ushort nameid_get_prop_index(const nameid& n) { return (ushort)(n.index >> 16); }
1586
1592inline ushort nameid_get_guid_index(const nameid& n) { return (ushort)((ushort)n.index >> 1); }
1593
1599inline bool nameid_is_string(const nameid& n) { return n.index & 0x1; }
1600
1606inline ushort nameid_get_prop_index(const nameid_hash_entry& n) { return (ushort)(n.index >> 16); }
1607
1613inline ushort nameid_get_guid_index(const nameid_hash_entry& n) { return (ushort)((ushort)n.index >> 1); }
1614
1620inline bool nameid_is_string(const nameid_hash_entry& n) { return n.index & 0x1; }
1621
1622} // end disk namespace
1623} // end pstsdk namespace
1624
1625
1626template<typename T>
1627inline pstsdk::ushort pstsdk::disk::compute_signature(T id, T address)
1628{
1629 T value = address ^ id;
1630
1631 return (ushort(ushort(value >> 16) ^ ushort(value)));
1632}
1633
1634inline pstsdk::ulong pstsdk::disk::compute_crc(const void * pdata, ulong cb)
1635{
1636 ulong crc = 0;
1637 const byte * pb = reinterpret_cast<const byte*>(pdata);
1638
1639 while(cb-- > 0)
1640 crc = crc_table[(int)(byte)crc ^ *pb++] ^ (crc >> 8);
1641
1642 return crc;
1643}
1644
1645inline void pstsdk::disk::permute(void * pdata, ulong cb, bool encrypt)
1646{
1647 byte * pb = reinterpret_cast<byte*>(pdata);
1648 const byte * ptable = encrypt ? table1 : table3;
1649 byte b;
1650
1651 while(cb-- > 0)
1652 {
1653 b = *pb;
1654 *pb++ = ptable[b];
1655 }
1656}
1657
1658inline void pstsdk::disk::cyclic(void * pdata, ulong cb, ulong key)
1659{
1660 byte * pb = reinterpret_cast<byte*>(pdata);
1661 byte b;
1662 ushort w;
1663
1664 w = (ushort)(key ^ (key >> 16));
1665
1666 while (cb-- > 0)
1667 {
1668 b = *pb;
1669 b = (byte)(b + (byte)w);
1670 b = table1[b];
1671 b = (byte)(b + (byte)(w >> 8));
1672 b = table2[b];
1673 b = (byte)(b - (byte)(w >> 8));
1674 b = table3[b];
1675 b = (byte)(b - (byte)w);
1676 *pb++ = b;
1677
1678 w = (ushort)(w + 1);
1679 }
1680}
1681
1682template<typename T>
1683inline size_t pstsdk::disk::align_disk(size_t size)
1684{
1685 return align_slot(size + sizeof(block_trailer<T>));
1686}
1687
1688inline size_t pstsdk::disk::align_slot(size_t size)
1689{
1690 return ((size + bytes_per_slot - 1) & ~(bytes_per_slot - 1));
1691}
1692
1693#endif
A data block which refers to other data blocks, in order to extend the physical size limit (8k) to a ...
Definition node.h:629
size_t align_slot(size_t size)
Aligns a block size to the slot size.
Definition disk.h:1688
const uint block_id_internal_bit
The internal bit indicates a block is an extended_block or a subnode_block.
Definition disk.h:973
const uint block_id_increment
The block id counter in the header is incremented by this amount for each block.
Definition disk.h:978
bool bid_is_internal(T bid)
Determines if a block is internal or not.
Definition disk.h:996
const size_t max_block_disk_size
The maximum individual block size.
Definition disk.h:933
block_types
The different block types.
Definition disk.h:939
bool bid_is_external(T bid)
Determines if a block is external or not.
Definition disk.h:987
size_t align_disk(size_t size)
Aligns a block size to the size on disk.
Definition disk.h:1683
@ block_type_external
An external data block.
Definition disk.h:940
@ block_type_sub
A subnode block type.
Definition disk.h:942
@ block_type_extended
An extended block type.
Definition disk.h:941
const ushort ost_magic
OST Magic number.
Definition disk.h:89
const ushort pst_magic
PST Magic number.
Definition disk.h:86
database_format
Valid database format values (ANSI vs. Unicode)
Definition disk.h:68
const uint hlmagic
High/Low magic number.
Definition disk.h:148
const size_t header_lock_entries
The number of entries in the header's lock structure.
Definition disk.h:62
const size_t header_fmap_entries
The number of entries in the header's fmap structure.
Definition disk.h:52
crypt_method
Valid "encryption" methods.
Definition disk.h:97
database_type
Vaild database types (OST vs. PST)
Definition disk.h:79
const size_t header_fpmap_size
The number of entries in the header's fpmap structure.
Definition disk.h:57
@ database_format_ansi
Current ANSI file version number.
Definition disk.h:70
@ database_format_unicode_min
Initial unicode version number.
Definition disk.h:71
@ database_format_ansi_min
Initial ANSI file version number.
Definition disk.h:69
@ database_format_unicode
Current unicode version number.
Definition disk.h:72
@ crypt_method_permute
The permute method is used in this file.
Definition disk.h:99
@ crypt_method_cyclic
The cyclic method is used in this file.
Definition disk.h:100
@ crypt_method_none
No "encryption" was used.
Definition disk.h:98
@ database_pst
A PST file.
Definition disk.h:81
@ database_ost
A OST file.
Definition disk.h:80
const uint heap_max_alloc_size_wver_14
Maximum allocation size in a heap in a version 14 ANSI file.
Definition disk.h:1220
const byte heap_signature
Signature of a heap.
Definition disk.h:1212
heap_client_signature
Different heap client signature types.
Definition disk.h:1226
const uint heap_max_alloc_size
Maximum allocation size in a heap.
Definition disk.h:1216
@ heap_sig_chtc
Definition disk.h:1232
@ heap_sig_pc
Definition disk.h:1234
@ heap_sig_hmp
Definition disk.h:1230
@ heap_sig_bth
Definition disk.h:1233
@ heap_sig_gmp
Definition disk.h:1227
@ heap_sig_tc
Definition disk.h:1228
@ heap_sig_smp
Definition disk.h:1229
@ heap_sig_ch
Definition disk.h:1231
ushort nameid_get_prop_index(const nameid &n)
Returns the index of a given nameid structure.
Definition disk.h:1585
bool nameid_is_string(const nameid &n)
Returns true if the nameid structure is named by a string.
Definition disk.h:1599
ushort nameid_get_guid_index(const nameid &n)
Returns the index into the guid stream of the guid of a given nameid structure.
Definition disk.h:1592
const size_t page_size
Size of all pages in the file in bytes, including the page trailer.
Definition disk.h:525
page_type
Valid page types.
Definition disk.h:533
const size_t first_amap_page_location
The location of the first AMap page in the file.
Definition disk.h:616
const size_t dlist_page_location
The location of the only DList page in the file.
Definition disk.h:700
ulong dlist_get_page_num(ulong entry)
Get a amap page number (ordinal) from a DLIST entry.
Definition disk.h:750
ulong dlist_get_slots(ulong entry)
Get the number of free slots from a DLIST entry.
Definition disk.h:756
const ulong dlist_page_num_mask
The portion of the dlist entry which refers to the amap page number.
Definition disk.h:739
const size_t bytes_per_slot
Number of bytes each slot (bit) in an AMap page refers to.
Definition disk.h:611
const ulong dlist_slots_shift
The bits to shift a dlist entry to get the slots on that amap page.
Definition disk.h:744
@ page_type_amap
An AMap (Allocation Map) page.
Definition disk.h:538
@ page_type_pmap
Definition disk.h:537
@ page_type_fmap
Definition disk.h:536
@ page_type_fpmap
Definition disk.h:539
@ page_type_nbt
A NBT (Nodes BTree) page.
Definition disk.h:535
@ page_type_bbt
A BBT (Blocks BTree) page.
Definition disk.h:534
@ page_type_dlist
A DList (Density List) page.
Definition disk.h:540
tc_offsets
Indices into the size offsets array.
Definition disk.h:1468
@ tc_offsets_four
Definition disk.h:1469
@ tc_offsets_max
Definition disk.h:1473
@ tc_offsets_two
Definition disk.h:1470
@ tc_offsets_one
Definition disk.h:1471
@ tc_offsets_bitmap
Definition disk.h:1472
void permute(void *pdata, ulong cb, bool encrypt)
Modifies the data block in place, according to the permute method.
Definition disk.h:1645
void cyclic(void *pdata, ulong cb, ulong key)
Modifies the data block in place, according to the cyclic method.
Definition disk.h:1658
boost::uint64_t ulonglong
Definition primitives.h:70
boost::uint8_t byte
Definition primitives.h:72
boost::uint32_t uint
Definition primitives.h:67
ulong node_id
Definition primitives.h:86
boost::uint32_t ulong
Definition primitives.h:68
ulong heap_id
Definition primitives.h:90
ulong heapnode_id
Definition primitives.h:91
boost::uint16_t ushort
Definition primitives.h:73
ushort prop_id
Definition primitives.h:93
@ nid_type_max
Definition primitives.h:149
ushort compute_signature(T id, T address)
Calculate the signature of an item.
ulong compute_crc(const void *pdata, ulong cb)
Compute the CRC of a block of data.
Definition disk.h:1634
const ulong crc_table[]
Precalulated CRC table, used by compute_crc.
Definition disk.h:301
const byte table1[]
Data table1 used by permute and cyclic.
Definition disk.h:350
const byte table3[]
Data table3 used by permute and cyclic.
Definition disk.h:428
const byte table2[]
Data table2 used by permute and cyclic.
Definition disk.h:389
@ heap_fill_3
Definition disk.h:1244
@ heap_fill_7
Definition disk.h:1248
@ heap_fill_10
Definition disk.h:1251
@ heap_fill_8
Definition disk.h:1249
@ heap_fill_1
Definition disk.h:1242
@ heap_fill_13
Definition disk.h:1254
@ heap_fill_11
Definition disk.h:1252
@ heap_fill_9
Definition disk.h:1250
@ heap_fill_14
Definition disk.h:1255
@ heap_fill_12
Definition disk.h:1253
@ heap_fill_full
Definition disk.h:1256
@ heap_fill_5
Definition disk.h:1246
@ heap_fill_4
Definition disk.h:1245
@ heap_fill_2
Definition disk.h:1243
@ heap_fill_6
Definition disk.h:1247
@ heap_fill_empty
Definition disk.h:1241
const uint block_id_attached_bit
The attached bit indicates a block is referenced in memory This is an implementation detail,...
Definition disk.h:968
Contains the definition of all in memory representations of disk structures.
Definition disk.h:19
Primitive structures defined by MS-PST and MAPI.
#define PSTSDK_MS_STRUCT
Definition primitives.h:58
The authoritative source of free space in the file.
Definition disk.h:631
BBT Leaf Entry.
Definition disk.h:807
ushort size
The unaligned size of this block.
Definition disk.h:809
block_reference< T > ref
A reference to this block on disk.
Definition disk.h:808
ushort ref_count
The reference count of this block.
Definition disk.h:810
BBT leaf page.
Definition disk.h:916
BBT non-leaf page.
Definition disk.h:884
The combination of the id and physical location of a block or page.
Definition disk.h:30
block_id_disk bid
The id of the referenced object.
Definition disk.h:34
location ib
The location on disk (index byte) of the referenced object.
Definition disk.h:35
ulong crc
CRC of this block, as calculated by the compute_crc function.
Definition disk.h:1021
block_id_disk bid
The id of this block.
Definition disk.h:1022
ushort cb
Size of the block (unaligned)
Definition disk.h:1019
ushort signature
Signature of this block, as calculated by the compute_signature function.
Definition disk.h:1020
BTree Entry.
Definition disk.h:766
bt_key key
The key of the page in ref.
Definition disk.h:769
block_reference< T > ref
A reference to a lower level page.
Definition disk.h:770
T bt_key
Definition disk.h:767
The fundamental page structure which forms the basis of the two BTrees.
Definition disk.h:829
static const size_t extra_space
Definition disk.h:830
byte _ignore[extra_space]
Definition disk.h:835
byte num_entries
Number of entries on this page.
Definition disk.h:838
byte entry_size
The size of each entry.
Definition disk.h:840
byte level
The level of this page. A level of zero indicates a leaf.
Definition disk.h:841
EntryType entries[max_entries]
Definition disk.h:834
static const size_t max_entries
Maximum number of entries on a page.
Definition disk.h:831
byte num_entries_max
Maximum number of entries on this page.
Definition disk.h:839
page_trailer< T > trailer
The page trailer.
Definition disk.h:843
Describes the BTH, including the size of the keys/values and the heap_id of the root allocation.
Definition disk.h:1324
byte num_levels
Number of levels.
Definition disk.h:1328
byte entry_size
Entry size in bytes.
Definition disk.h:1327
byte bth_signature
Always heap_sig_bth.
Definition disk.h:1325
byte key_size
Key size in bytes.
Definition disk.h:1326
heap_id root
Root of the actual tree structure.
Definition disk.h:1329
Entries which make up a "leaf" BTH allocation.
Definition disk.h:1361
V value
Value instance.
Definition disk.h:1363
K key
Key instance.
Definition disk.h:1362
EntryType entries[1]
Array of entries.
Definition disk.h:1381
Entries which make up a "non-leaf" BTH allocation.
Definition disk.h:1343
K key
Key of the lower level page.
Definition disk.h:1344
heap_id page
Heap id of the lower level page.
Definition disk.h:1345
BTH Nonleaf node.
Definition disk.h:1405
Describes a column.
Definition disk.h:1481
A metapage holding information about AMap pages.
Definition disk.h:713
ulong backfill_location
The current backfill marker, when backfilling.
Definition disk.h:722
byte _ignore[extra_space]
Definition disk.h:727
ulong current_page
The current AMap page used for allocations.
Definition disk.h:721
byte num_entries
Number of entries in the entries array.
Definition disk.h:718
ulong entries[max_entries]
Each entry has bits for the amap page (ordinal) and free space (slots)
Definition disk.h:726
static const size_t max_entries
Maximum number of entries in the dlist page.
Definition disk.h:715
static const size_t extra_space
Definition disk.h:714
page_trailer< T > trailer
The page trailer.
Definition disk.h:729
byte flags
Flags indicating the state of the dlist page.
Definition disk.h:717
byte block_type
Always block_type_extended.
Definition disk.h:1090
byte level
If zero, this block points to external blocks. If one, this block points to level zero extended block...
Definition disk.h:1091
ulong total_size
Total logical size of this block.
Definition disk.h:1093
ushort count
Number of entries in the bid array.
Definition disk.h:1092
External block definition.
Definition disk.h:1059
byte data[1]
Data contained in this block.
Definition disk.h:1061
static const size_t max_size
Definition disk.h:1060
A deprecated allocation system optimized for AMap page searching.
Definition disk.h:668
A deprecated allocation system optimized for PMap page searching.
Definition disk.h:690
GUST Column description structure.
Definition disk.h:1496
GUST TC Header.
Definition disk.h:1525
ushort size_offsets[tc_offsets_max]
Definition disk.h:1528
heapnode_id row_matrix_id
Definition disk.h:1530
block_id_disk bidNextP
Definition disk.h:238
block_id_disk bidNextB
Definition disk.h:236
root< ulong > root_info
Definition disk.h:241
byte bPlatformCreate
Always 0x1.
Definition disk.h:176
ulong dwOpenDBID
Implementation specific.
Definition disk.h:178
byte bLockSemaphore
Implementation specific.
Definition disk.h:200
ulong dwOpenClaimID
Implementation specific.
Definition disk.h:179
ushort wVerClient
Client version, database_type.
Definition disk.h:175
block_id_disk bidNextB
The block id counter.
Definition disk.h:195
ulonglong location
The location type used in the file.
Definition disk.h:168
ulonglong count
The count type used in the file.
Definition disk.h:169
root< ulonglong > root_info
The root info for this database.
Definition disk.h:184
block_id_disk bidNextP
The page id counter.
Definition disk.h:181
byte bCryptMethod
The crypt_method used in this file.
Definition disk.h:188
block_id_disk bidUnused
Unused.
Definition disk.h:180
ulonglong block_id_disk
The id type used for blocks and pages in the file.
Definition disk.h:167
ushort wVer
Version of the file, database_format.
Definition disk.h:174
ushort wMagicClient
Client magic number, eg pst_magic.
Definition disk.h:173
ulong dwMagic
Always hlmagic.
Definition disk.h:171
byte bPlatformAccess
Always 0x1.
Definition disk.h:177
Header structure on the first heap block.
Definition disk.h:1263
byte client_signature
Client defined signature, see heap_client_signature.
Definition disk.h:1268
static const uint fill_level_size
Number of bytes in the page_fill_levels map on this block.
Definition disk.h:1264
byte signature
Always heap_signature.
Definition disk.h:1267
heap_id root_id
Root allocation. This has specific meaning to the owner of this heap.
Definition disk.h:1269
byte page_fill_levels[fill_level_size]
Fill level of this and next seven heap blocks (4 bits each), see heap_fill_level.
Definition disk.h:1270
ushort page_map_offset
Offset of the start of the heap_page_map.
Definition disk.h:1266
Header structure on non-first/fill blocks.
Definition disk.h:1285
ushort page_map_offset
Offset of the start of the page map.
Definition disk.h:1288
byte page_fill_levels[fill_level_size]
Fill level of this and next 127 heap blocks.
Definition disk.h:1289
static const uint fill_level_size
Number of bytes in the page_fill_levels map on this block.
Definition disk.h:1286
Header structure on non-first/non-fill blocks.
Definition disk.h:1277
ushort page_map_offset
offset of the start of the page map
Definition disk.h:1278
Provides a map of the allocations on a heap block.
Definition disk.h:1306
ushort num_allocs
Number of allocations on this block.
Definition disk.h:1307
ushort num_frees
Number of empty allocations on this.
Definition disk.h:1308
ushort allocs[1]
The offset of each allocation.
Definition disk.h:1309
Multi-valued, variable length property TOC.
Definition disk.h:1452
ulong offsets[1]
Definition disk.h:1454
A modified nameid structure used in the hash buckets.
Definition disk.h:1571
ulong index
Bits 16-31 are the index into the entry stream. Bits 1-16 are the index into the guid stream....
Definition disk.h:1573
ulong hash_base
For numeric named props, this is just the id. Hash value of string props.
Definition disk.h:1572
Defines a id to name mapping.
Definition disk.h:1553
ulong index
Bits 16-31 are the index into the entry stream. Bits 1-16 are the index into the guid stream....
Definition disk.h:1559
ulong string_offset
offset into the string stream of the name of this prop
Definition disk.h:1557
ulong id
id of the named prop (for named props defined by an id)
Definition disk.h:1556
NBT Leaf Entry.
Definition disk.h:785
block_id_disk data
The block id of the data block.
Definition disk.h:790
T nid_index
Definition disk.h:786
block_id_disk sub
The block id of the subnode block.
Definition disk.h:791
T block_id_disk
Definition disk.h:787
node_id parent_nid
The parent node id.
Definition disk.h:792
nid_index nid
The node id.
Definition disk.h:789
NBT leaf page.
Definition disk.h:900
NBT non-leaf page.
Definition disk.h:868
ushort signature
Signature of this page, as calculated by the compute_signature function.
Definition disk.h:562
byte page_type_repeat
Same as the page_type field, for validation purposes.
Definition disk.h:561
ulong crc
CRC of this page, as calculated by the compute_crc function.
Definition disk.h:563
byte page_type
The page_type of this page.
Definition disk.h:560
block_id_disk bid
The id of this page.
Definition disk.h:564
Generic page structure.
Definition disk.h:597
byte data[page_data_size]
space used for actual data
Definition disk.h:600
static const size_t page_data_size
Amount of usable space in a page.
Definition disk.h:598
page_trailer< T > trailer
The page trailer for this page.
Definition disk.h:601
An old allocation system optimized for pages.
Definition disk.h:650
The value type of the BTH backing a pc.
Definition disk.h:1424
ushort type
Definition disk.h:1425
heapnode_id id
Definition disk.h:1426
The root of the database.
Definition disk.h:113
byte bARVec
Indicates which AddRef vector is used.
Definition disk.h:125
location ibFileEof
EOF of the file, according the header.
Definition disk.h:118
location ibAMapLast
The location of the last valid AMap page.
Definition disk.h:119
ulong cOrphans
The number of "orphans" in the BBT.
Definition disk.h:117
count cbPMapFree
Amount of space free in all PMap pages.
Definition disk.h:121
ushort cARVec
Number of elements in the AddRef vector.
Definition disk.h:126
byte fAMapValid
Indicates if the AMap pages are valid or not.
Definition disk.h:124
block_reference< T > brefBBT
The location of the root of the BBT.
Definition disk.h:123
count cbAMapFree
Amount of space free in all AMap pages.
Definition disk.h:120
block_reference< T > brefNBT
The location of the root of the NBT.
Definition disk.h:122
Subnode Blocks.
Definition disk.h:1171
ushort count
Number of entries in the entry array.
Definition disk.h:1174
EntryType entry[1]
Array of entries.
Definition disk.h:1175
byte level
One for non-leaf, zero for leaf.
Definition disk.h:1173
byte block_type
Always block_type_sub.
Definition disk.h:1172
Subnode leaf block.
Definition disk.h:1199
Entries on a leaf sub_block.
Definition disk.h:1128
node_id nid
Subnode id.
Definition disk.h:1131
block_id_disk sub
Subnode block of this subnode. Yes, subnodes can and do themselves had subnodes.
Definition disk.h:1133
T block_id_disk
Definition disk.h:1129
block_id_disk data
Data block of this subnode.
Definition disk.h:1132
Subnode non-leaf block.
Definition disk.h:1187
Entries on a nonleaf sub_block.
Definition disk.h:1149
block_id_disk sub_block_bid
Id of the subnode block.
Definition disk.h:1153
T block_id_disk
Definition disk.h:1150
node_id nid_key
Key of the subnode block.
Definition disk.h:1152
The root_id allocation out of the Heap of a TC node.
Definition disk.h:1511
column_description columns[1]
Definition disk.h:1518
ushort size_offsets[tc_offsets_max]
Definition disk.h:1514
heapnode_id row_matrix_id
Definition disk.h:1516