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
124
125template<typename T>
143static_assert(sizeof(root<ulong>) == 40, "root<ulong> incorrect size");
144static_assert(sizeof(root<ulonglong>) == 80, "root<ulonglong> incorrect size");
145static_assert(offsetof(root<ulonglong>, cOrphans) == 0, "root<ulonglong> cOrphans at incorrect offset");
146static_assert(offsetof(root<ulonglong>, ibFileEof) == 8, "root<ulonglong> ibFileEof at incorrect offset");
147static_assert(offsetof(root<ulonglong>, ibAMapLast) == 16, "root<ulonglong> ibAMapLast at incorrect offset");
148static_assert(offsetof(root<ulonglong>, cbAMapFree) == 24, "root<ulonglong> cbAMapFree at incorrect offset");
149static_assert(offsetof(root<ulonglong>, cbPMapFree) == 32, "root<ulonglong> cbPMapFree at incorrect offset");
150static_assert(offsetof(root<ulonglong>, brefNBT) == 40, "root<ulonglong> brefNBT at incorrect offset");
151static_assert(offsetof(root<ulonglong>, brefBBT) == 56, "root<ulonglong> brefBBT at incorrect offset");
152static_assert(offsetof(root<ulonglong>, fAMapValid) == 72, "root<ulonglong> fAMapValid at incorrect offset");
153static_assert(offsetof(root<ulonglong>, bARVec) == 73, "root<ulonglong> bARVec at incorrect offset");
154static_assert(offsetof(root<ulonglong>, cARVec) == 74, "root<ulonglong> cARVec at incorrect offset");
156
162const uint hlmagic = 0x4e444221;
163
165template<typename T>
166struct header
167{
170
178template<>
179struct header<ulonglong>
180{
183 typedef ulonglong count;
184
200 byte rgbFP[header_fpmap_size];
203 byte rgbReserved[2];
204#ifdef __GNUC__
205 // GCC refuses to pack this next to rgbReserved
206 byte bidNextB[8];
207#else
208#pragma pack(4)
210#pragma pack()
211#endif
213 byte rgbVersionEncoded[3];
215 byte rgbLock[header_lock_entries];
218static_assert(sizeof(header<ulonglong>) == 568, "header<ulonglong> incorrect size");
219static_assert(offsetof(header<ulonglong>, rgnid) == 44, "header<ulonglong> rgnid at incorrect offset");
220static_assert(offsetof(header<ulonglong>, root_info) == 176, "header<ulonglong> root_info at incorrect offset");
221static_assert(offsetof(header<ulonglong>, rgbFM) == 256, "header<ulonglong> rgbFM at incorrect offset");
222static_assert(offsetof(header<ulonglong>, dwCRCFull) == 524, "header<ulonglong> dwCRCFull at incorrect offset");
224
231template<>
268static_assert(sizeof(header<ulong>) == 512, "header<ulong> incorrect size");
269static_assert(offsetof(header<ulong>, rgnid) == 36, "header<ulong> rgnid at incorrect offset");
270static_assert(offsetof(header<ulong>, rgbFM) == 204, "header<ulong> rgbFM at incorrect offset");
272
274template<typename T>
275struct header_crc_locations
276{
279
283template<>
284struct header_crc_locations<ulong>
285{
286 static const size_t start = offsetof(header<ulong>, wMagicClient);
287 static const size_t end = offsetof(header<ulong>, bLockSemaphore);
288 static const size_t length = end - start;
290
295template<>
296struct header_crc_locations<ulonglong>
297{
298 static const size_t partial_start = header_crc_locations<ulong>::start;
299 static const size_t partial_end = header_crc_locations<ulong>::end;
300 static const size_t partial_length = header_crc_locations<ulong>::length;
301 static const size_t full_start = offsetof(header<ulonglong>, wMagicClient);
302 static const size_t full_end = offsetof(header<ulonglong>, dwCRCFull);
303 static const size_t full_length = full_end - full_start;
305
306//
307// utility functions
308//
309
312
315const ulong crc_table[] = {
316 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F,
317 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
318 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2,
319 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
320 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9,
321 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
322 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C,
323 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
324 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423,
325 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
326 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106,
327 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
328 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D,
329 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
330 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950,
331 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
332 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7,
333 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
334 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA,
335 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
336 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81,
337 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
338 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84,
339 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
340 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB,
341 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
342 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E,
343 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
344 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55,
345 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
346 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28,
347 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
348 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F,
349 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
350 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242,
351 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
352 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69,
353 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
354 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC,
355 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
356 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693,
357 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
358 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
359};
360
364const byte table1[] =
365{
366 65, 54, 19, 98, 168, 33, 110, 187,
367 244, 22, 204, 4, 127, 100, 232, 93,
368 30, 242, 203, 42, 116, 197, 94, 53,
369 210, 149, 71, 158, 150, 45, 154, 136,
370 76, 125, 132, 63, 219, 172, 49, 182,
371 72, 95, 246, 196, 216, 57, 139, 231,
372 35, 59, 56, 142, 200, 193, 223, 37,
373 177, 32, 165, 70, 96, 78, 156, 251,
374 170, 211, 86, 81, 69, 124, 85, 0,
375 7, 201, 43, 157, 133, 155, 9, 160,
376 143, 173, 179, 15, 99, 171, 137, 75,
377 215, 167, 21, 90, 113, 102, 66, 191,
378 38, 74, 107, 152, 250, 234, 119, 83,
379 178, 112, 5, 44, 253, 89, 58, 134,
380 126, 206, 6, 235, 130, 120, 87, 199,
381 141, 67, 175, 180, 28, 212, 91, 205,
382 226, 233, 39, 79, 195, 8, 114, 128,
383 207, 176, 239, 245, 40, 109, 190, 48,
384 77, 52, 146, 213, 14, 60, 34, 50,
385 229, 228, 249, 159, 194, 209, 10, 129,
386 18, 225, 238, 145, 131, 118, 227, 151,
387 230, 97, 138, 23, 121, 164, 183, 220,
388 144, 122, 92, 140, 2, 166, 202, 105,
389 222, 80, 26, 17, 147, 185, 82, 135,
390 88, 252, 237, 29, 55, 73, 27, 106,
391 224, 41, 51, 153, 189, 108, 217, 148,
392 243, 64, 84, 111, 240, 198, 115, 184,
393 214, 62, 101, 24, 68, 31, 221, 103,
394 16, 241, 12, 25, 236, 174, 3, 161,
395 20, 123, 169, 11, 255, 248, 163, 192,
396 162, 1, 247, 46, 188, 36, 104, 117,
397 13, 254, 186, 47, 181, 208, 218, 61,
398};
399
403const byte table2[] =
404{
405 20, 83, 15, 86, 179, 200, 122, 156,
406 235, 101, 72, 23, 22, 21, 159, 2,
407 204, 84, 124, 131, 0, 13, 12, 11,
408 162, 98, 168, 118, 219, 217, 237, 199,
409 197, 164, 220, 172, 133, 116, 214, 208,
410 167, 155, 174, 154, 150, 113, 102, 195,
411 99, 153, 184, 221, 115, 146, 142, 132,
412 125, 165, 94, 209, 93, 147, 177, 87,
413 81, 80, 128, 137, 82, 148, 79, 78,
414 10, 107, 188, 141, 127, 110, 71, 70,
415 65, 64, 68, 1, 17, 203, 3, 63,
416 247, 244, 225, 169, 143, 60, 58, 249,
417 251, 240, 25, 48, 130, 9, 46, 201,
418 157, 160, 134, 73, 238, 111, 77, 109,
419 196, 45, 129, 52, 37, 135, 27, 136,
420 170, 252, 6, 161, 18, 56, 253, 76,
421 66, 114, 100, 19, 55, 36, 106, 117,
422 119, 67, 255, 230, 180, 75, 54, 92,
423 228, 216, 53, 61, 69, 185, 44, 236,
424 183, 49, 43, 41, 7, 104, 163, 14,
425 105, 123, 24, 158, 33, 57, 190, 40,
426 26, 91, 120, 245, 35, 202, 42, 176,
427 175, 62, 254, 4, 140, 231, 229, 152,
428 50, 149, 211, 246, 74, 232, 166, 234,
429 233, 243, 213, 47, 112, 32, 242, 31,
430 5, 103, 173, 85, 16, 206, 205, 227,
431 39, 59, 218, 186, 215, 194, 38, 212,
432 145, 29, 210, 28, 34, 51, 248, 250,
433 241, 90, 239, 207, 144, 182, 139, 181,
434 189, 192, 191, 8, 151, 30, 108, 226,
435 97, 224, 198, 193, 89, 171, 187, 88,
436 222, 95, 223, 96, 121, 126, 178, 138,
437};
438
442const byte table3[] =
443{
444 71, 241, 180, 230, 11, 106, 114, 72,
445 133, 78, 158, 235, 226, 248, 148, 83,
446 224, 187, 160, 2, 232, 90, 9, 171,
447 219, 227, 186, 198, 124, 195, 16, 221,
448 57, 5, 150, 48, 245, 55, 96, 130,
449 140, 201, 19, 74, 107, 29, 243, 251,
450 143, 38, 151, 202, 145, 23, 1, 196,
451 50, 45, 110, 49, 149, 255, 217, 35,
452 209, 0, 94, 121, 220, 68, 59, 26,
453 40, 197, 97, 87, 32, 144, 61, 131,
454 185, 67, 190, 103, 210, 70, 66, 118,
455 192, 109, 91, 126, 178, 15, 22, 41,
456 60, 169, 3, 84, 13, 218, 93, 223,
457 246, 183, 199, 98, 205, 141, 6, 211,
458 105, 92, 134, 214, 20, 247, 165, 102,
459 117, 172, 177, 233, 69, 33, 112, 12,
460 135, 159, 116, 164, 34, 76, 111, 191,
461 31, 86, 170, 46, 179, 120, 51, 80,
462 176, 163, 146, 188, 207, 25, 28, 167,
463 99, 203, 30, 77, 62, 75, 27, 155,
464 79, 231, 240, 238, 173, 58, 181, 89,
465 4, 234, 64, 85, 37, 81, 229, 122,
466 137, 56, 104, 82, 123, 252, 39, 174,
467 215, 189, 250, 7, 244, 204, 142, 95,
468 239, 53, 156, 132, 43, 21, 213, 119,
469 52, 73, 182, 18, 10, 127, 113, 136,
470 253, 157, 24, 65, 125, 147, 216, 88,
471 44, 206, 254, 36, 175, 222, 184, 54,
472 200, 161, 128, 166, 153, 152, 168, 47,
473 14, 129, 101, 115, 228, 194, 162, 138,
474 212, 225, 17, 208, 8, 139, 42, 242,
475 237, 154, 100, 63, 193, 108, 249, 236
476};
477
485template<typename T>
486ushort compute_signature(T id, T address);
487
494template<typename T>
495ushort compute_signature(const block_reference<T>& reference) { return compute_signature(reference.bid, reference.ib); }
496
503ulong compute_crc(const void * pdata, ulong cb);
504
514void permute(void * pdata, ulong cb, bool encrypt);
515
525void cyclic(void * pdata, ulong cb, ulong key);
526
527
528//
529// page structures
530//
531
534
535
539const size_t page_size = 512;
540
556
558template<typename T>
559struct page_trailer
560{
563
569template<>
581static_assert(sizeof(page_trailer<ulonglong>) == 16, "page_trailer<ulonglong> incorrect size");
583
590template<>
602static_assert(sizeof(page_trailer<ulong>) == 12, "page_trailer<ulong> incorrect size");
604
609template<typename T>
610struct page
611{
612 static const size_t page_data_size = page_size - sizeof(page_trailer<T>);
613
615 page_trailer<T> trailer;
618static_assert(sizeof(page<ulong>) == page_size, "page<ulong> incorrect size");
619static_assert(sizeof(page<ulonglong>) == page_size, "page<ulonglong> incorrect size");
621
625const size_t bytes_per_slot = 64;
626
630const size_t first_amap_page_location = 0x4400;
631
643template<typename T>
644struct amap_page : public page<T>
645{
648static_assert(sizeof(amap_page<ulong>) == page_size, "amap_page<ulong> incorrect size");
649static_assert(sizeof(amap_page<ulonglong>) == page_size, "amap_page<ulonglong> incorrect size");
651
662template<typename T>
663struct pmap_page : public page<T>
664{
667static_assert(sizeof(pmap_page<ulong>) == page_size, "pmap_page<ulong> incorrect size");
668static_assert(sizeof(pmap_page<ulonglong>) == page_size, "pmap_page<ulonglong> incorrect size");
670
680template<typename T>
681struct fmap_page : public page<T>
682{
685static_assert(sizeof(fmap_page<ulong>) == page_size, "fmap_page<ulong> incorrect size");
686static_assert(sizeof(fmap_page<ulonglong>) == page_size, "fmap_page<ulonglong> incorrect size");
688
702template<typename T>
703struct fpmap_page : public page<T>
704{
707static_assert(sizeof(fpmap_page<ulong>) == page_size, "fpmap_page<ulong> incorrect size");
708static_assert(sizeof(fpmap_page<ulonglong>) == page_size, "fpmap_page<ulonglong> incorrect size");
710
714const size_t dlist_page_location = 0x4200;
715
725template<typename T>
727{
728 static const size_t extra_space = page<T>::page_data_size - 8;
729 static const size_t max_entries = extra_space / sizeof(ulong);
730
731 byte flags;
733 union
734 {
737 };
738 union
739 {
742 };
743 page_trailer<T> trailer;
746static_assert(sizeof(dlist_page<ulong>) == page_size, "dlist_page<ulong> incorrect size");
747static_assert(sizeof(dlist_page<ulonglong>) == page_size, "dlist_page<ulonglong> incorrect size");
749
753const ulong dlist_page_num_mask = 0x0000FFFF;
754
759
764inline ulong dlist_get_page_num(ulong entry) { return entry & dlist_page_num_mask; }
765
770inline ulong dlist_get_slots(ulong entry) { return entry >> dlist_slots_shift; }
771
778template<typename T>
787static_assert(sizeof(bt_entry<ulong>) == 12, "bt_entry<ulong> incorrect size");
788static_assert(sizeof(bt_entry<ulonglong>) == 24, "bt_entry<ulonglong> incorrect size");
790
797template<typename T>
809static_assert(sizeof(nbt_leaf_entry<ulong>) == 16, "nbt_leaf_entry<ulong> incorrect size");
810static_assert(sizeof(nbt_leaf_entry<ulonglong>) == 32, "nbt_leaf_entry<ulonglong> incorrect size");
812
820
827template<typename T>
835static_assert(sizeof(bbt_leaf_entry<ulong>) == 12, "bbt_leaf_entry<ulong> incorrect size");
836static_assert(sizeof(bbt_leaf_entry<ulonglong>) == 24, "bbt_leaf_entry<ulonglong> incorrect size");
838
849template<typename T, typename EntryType>
851{
852 static const size_t extra_space = page<T>::page_data_size - (sizeof(T) * sizeof(byte));
853 static const size_t max_entries = extra_space / sizeof(EntryType);
854 union
855 {
858 };
859
863 byte level;
864
865 page_trailer<T> trailer;
868namespace detail {
869 // We can't pass types containing "," to offsetof, because it's a
870 // preprocessor macro, and it doesn't really understand how to parse an
871 // argument list. So we declare some aliases in a "detail" namespace
872 // where they won't pollute the header.
873 typedef bt_page<ulong, bt_entry<ulong> > bt_page_ulong;
874 typedef bt_page<ulonglong, bt_entry<ulonglong> > bt_page_ulonglong;
875}
876static_assert(offsetof(detail::bt_page_ulong, num_entries) == 496, "bt_page<ulong, bt_entry<ulong> > num_entries at incorrect offset");
877static_assert(offsetof(detail::bt_page_ulonglong, num_entries) == 488, "bt_page<ulonglong, bt_entry<ulonglong> > num_entries at incorrect offset");
878static_assert(offsetof(detail::bt_page_ulong, trailer) == 500, "bt_page<ulong, bt_entry<ulong> > trailer at incorrect offset");
879static_assert(offsetof(detail::bt_page_ulonglong, trailer) == 496, "bt_page<ulonglong, bt_entry<ulonglong> > trailer at incorrect offset");
881
888template<typename T>
889struct nbt_nonleaf_page : public bt_page<T, bt_entry<T> >
890{
893static_assert(sizeof(nbt_nonleaf_page<ulong>) == page_size, "nbt_nonleaf_page<ulong> incorrect size");
894static_assert(sizeof(nbt_nonleaf_page<ulonglong>) == page_size, "nbt_nonleaf_page<ulonglong> incorrect size");
896
904template<typename T>
905struct bbt_nonleaf_page : public bt_page<T, bt_entry<T> >
906{
909static_assert(sizeof(bbt_nonleaf_page<ulong>) == page_size, "bbt_nonleaf_page<ulong> incorrect size");
910static_assert(sizeof(bbt_nonleaf_page<ulonglong>) == page_size, "bbt_nonleaf_page<ulonglong> incorrect size");
912
920template<typename T>
921struct nbt_leaf_page : public bt_page<T, nbt_leaf_entry<T> >
922{
925static_assert(sizeof(nbt_leaf_page<ulong>) == page_size, "nbt_leaf_page<ulong> incorrect size");
926static_assert(sizeof(nbt_leaf_page<ulonglong>) == page_size, "nbt_leaf_page<ulonglong> incorrect size");
928
936template<typename T>
937struct bbt_leaf_page : public bt_page<T, bbt_leaf_entry<T> >
938{
941static_assert(sizeof(bbt_leaf_page<ulong>) == page_size, "bbt_leaf_page<ulong> incorrect size");
942static_assert(sizeof(bbt_leaf_page<ulonglong>) == page_size, "bbt_leaf_page<ulonglong> incorrect size");
944
945//
946// block structures
947//
948
951
955const size_t max_block_disk_size = 8 * 1024;
956
966
975template<typename T>
976size_t align_disk(size_t size);
977
985size_t align_slot(size_t size);
986
991
996
1001
1008template<typename T>
1009bool bid_is_external(T bid) { return ((bid & block_id_internal_bit) == 0); }
1010
1017template<typename T>
1018bool bid_is_internal(T bid) { return !bid_is_external(bid); }
1019
1021template<typename T>
1022struct block_trailer
1023{
1026
1036template<>
1047static_assert(sizeof(block_trailer<ulonglong>) == 16, "block_trailer<ulonglong> incorrect size");
1049
1057template<>
1068static_assert(sizeof(block_trailer<ulong>) == 12, "block_trailer<ulong> incorrect size");
1070
1079template<typename T>
1081{
1082 static const size_t max_size = max_block_disk_size - sizeof(block_trailer<T>);
1083 byte data[1];
1085
1087template<typename T>
1088struct extended_block
1089{
1092
1104template<>
1118
1126template<>
1128{
1130
1131 static const size_t max_count = ((4096L) - sizeof(block_trailer<ulong>) - 8) / sizeof(extended_block<ulong>::block_id_disk);
1133
1135 byte level;
1140
1148template<typename T>
1158static_assert(sizeof(sub_leaf_entry<ulong>) == 12, "sub_leaf_entry<ulong> incorrect size");
1159static_assert(sizeof(sub_leaf_entry<ulonglong>) == 24, "sub_leaf_entry<ulonglong> incorrect size");
1161
1169template<typename T>
1178static_assert(sizeof(sub_nonleaf_entry<ulong>) == 8, "sub_nonleaf_entry<ulong> incorrect size");
1179static_assert(sizeof(sub_nonleaf_entry<ulonglong>) == 16, "sub_nonleaf_entry<ulonglong> incorrect size");
1181
1191template<typename T, typename EntryType>
1193{
1195 byte level;
1197 EntryType entry[1];
1199
1207template<typename T>
1208struct sub_nonleaf_block : public sub_block<T, sub_nonleaf_entry<T> >
1209{
1211
1219template<typename T>
1220struct sub_leaf_block : public sub_block<T, sub_leaf_entry<T> >
1221{
1223
1224//
1225// heap structures
1226//
1227
1230
1234const byte heap_signature = 0xEC;
1235
1239
1243
1248{
1249 heap_sig_gmp = 0x6C, //< Internal
1250 heap_sig_tc = 0x7C, //< Table context
1251 heap_sig_smp = 0x8C, //< Internal
1252 heap_sig_hmp = 0x9C, //< Internal
1253 heap_sig_ch = 0xA5, //< \deprecated Internal
1254 heap_sig_chtc = 0xAC, //< \deprecated Internal
1255 heap_sig_bth = 0xB5, //< BTree on Heap
1256 heap_sig_pc = 0xBC, //< Property Context
1257};
1258
1262{
1263 heap_fill_empty, //< >= 3584 bytes free
1264 heap_fill_1, //< 2560 - 3583 bytes free
1265 heap_fill_2, //< 2048 - 2559 bytes free
1266 heap_fill_3, //< 1792 - 2047 bytes free
1267 heap_fill_4, //< 1536 - 1791 bytes free
1268 heap_fill_5, //< 1280 - 1535 bytes free
1269 heap_fill_6, //< 1024 - 1279 bytes free
1270 heap_fill_7, //< 768 - 1023 bytes free
1271 heap_fill_8, //< 512 - 767 bytes free
1272 heap_fill_9, //< 256 - 511 bytes free
1273 heap_fill_10, //< 128 - 255 bytes free
1274 heap_fill_11, //< 64 - 127 bytes free
1275 heap_fill_12, //< 32 - 63 bytes free
1276 heap_fill_13, //< 16 - 31 bytes free
1277 heap_fill_14, //< 8 - 15 bytes free
1278 heap_fill_full //< < 8 bytes free
1280
1294
1302
1313
1333
1334//
1335// bth structures
1336//
1337
1340
1353
1362#pragma pack(2)
1363template<typename K>
1369#pragma pack()
1371static_assert(sizeof(bth_nonleaf_entry<ushort>) == 6, "bth_nonleaf_entry<ushort> incorrect size");
1373
1381template<typename K, typename V>
1387
1400template<typename EntryType>
1402{
1403 EntryType entries[1];
1405
1413template<typename K, typename V>
1414struct bth_leaf_node : bth_node<bth_leaf_entry<K,V> >
1415{
1417
1425template<typename K>
1426struct bth_nonleaf_node : bth_node<bth_nonleaf_entry<K> >
1427{
1429
1430//
1431// pc structures
1432//
1433
1436
1444#pragma pack(2)
1446{
1447 ushort type; //$< Property type
1448 heapnode_id id; //$< Heapnode id for variable length properties, or the value directly for fixed size property types
1449};
1450#pragma pack()
1452static_assert(sizeof(bth_leaf_entry<ushort, prop_entry>) == 8, "bth_leaf_entry<ushort, prop_entry> incorrect size");
1454
1461{
1462 node_id nid; //$< The subnode id containing the data for the object
1463 ulong size; //$< The size of the object
1465
1474{
1475 ulong count; //$< Number of entries in the TOC
1476 ulong offsets[1]; //$< Array of offsets for the start of each entry
1478
1479//
1480// tc structures
1481//
1482
1485
1490{
1491 tc_offsets_four, //$< Offset of the end of the four and eight byte columns
1492 tc_offsets_two, //$< Offset of the end of the two byte columns
1493 tc_offsets_one, //$< Offset of the end of the one byte columns
1494 tc_offsets_bitmap, //$< Offset of the end of the existance bitmap
1495 tc_offsets_max //$< Number of entries in the offset array
1497
1501#pragma pack(2)
1503{
1504 ushort type; //$< Column property type
1505 prop_id id; //$< Column property id
1506 ushort offset; //$< Offset into the row
1507 byte size; //$< Width of the column
1508 byte bit_offset; //$< Bit offset into the existance bitmap
1509};
1510
1528
1533{
1534 byte signature; //$< TC signature, \ref heap_sig_tc
1535 byte num_columns; //$< Number of columns in this table
1536 ushort size_offsets[tc_offsets_max]; // Row offset array, see \ref tc_offsets
1537 heap_id row_btree_id; //$< The bth_header allocation for the row mapping btree
1538 heapnode_id row_matrix_id; //$< The heapnode_id allocation for the row matrix
1539 byte unused[4];
1540 column_description columns[1]; //$< Column description array, of length num_columns
1541};
1542
1559#pragma pack()
1560
1561//
1562// nameid structures
1563//
1564
1567
1575{
1576 union
1577 {
1580 };
1583
1598static_assert(sizeof(nameid) == 8, "nameid incorrect size");
1599static_assert(sizeof(nameid_hash_entry) == 8, "nameid incorrect size");
1601
1607inline ushort nameid_get_prop_index(const nameid& n) { return (ushort)(n.index >> 16); }
1608
1614inline ushort nameid_get_guid_index(const nameid& n) { return (ushort)((ushort)n.index >> 1); }
1615
1621inline bool nameid_is_string(const nameid& n) { return n.index & 0x1; }
1622
1628inline ushort nameid_get_prop_index(const nameid_hash_entry& n) { return (ushort)(n.index >> 16); }
1629
1635inline ushort nameid_get_guid_index(const nameid_hash_entry& n) { return (ushort)((ushort)n.index >> 1); }
1636
1642inline bool nameid_is_string(const nameid_hash_entry& n) { return n.index & 0x1; }
1643
1644} // end disk namespace
1645} // end pstsdk namespace
1646
1647
1648template<typename T>
1649inline pstsdk::ushort pstsdk::disk::compute_signature(T id, T address)
1650{
1651 T value = address ^ id;
1652
1653 return (ushort(ushort(value >> 16) ^ ushort(value)));
1654}
1655
1656inline pstsdk::ulong pstsdk::disk::compute_crc(const void * pdata, ulong cb)
1657{
1658 ulong crc = 0;
1659 const byte * pb = reinterpret_cast<const byte*>(pdata);
1660
1661 while(cb-- > 0)
1662 crc = crc_table[(int)(byte)crc ^ *pb++] ^ (crc >> 8);
1663
1664 return crc;
1665}
1666
1667inline void pstsdk::disk::permute(void * pdata, ulong cb, bool encrypt)
1668{
1669 byte * pb = reinterpret_cast<byte*>(pdata);
1670 const byte * ptable = encrypt ? table1 : table3;
1671 byte b;
1672
1673 while(cb-- > 0)
1674 {
1675 b = *pb;
1676 *pb++ = ptable[b];
1677 }
1678}
1679
1680inline void pstsdk::disk::cyclic(void * pdata, ulong cb, ulong key)
1681{
1682 byte * pb = reinterpret_cast<byte*>(pdata);
1683 byte b;
1684 ushort w;
1685
1686 w = (ushort)(key ^ (key >> 16));
1687
1688 while (cb-- > 0)
1689 {
1690 b = *pb;
1691 b = (byte)(b + (byte)w);
1692 b = table1[b];
1693 b = (byte)(b + (byte)(w >> 8));
1694 b = table2[b];
1695 b = (byte)(b - (byte)(w >> 8));
1696 b = table3[b];
1697 b = (byte)(b - (byte)w);
1698 *pb++ = b;
1699
1700 w = (ushort)(w + 1);
1701 }
1702}
1703
1704template<typename T>
1705inline size_t pstsdk::disk::align_disk(size_t size)
1706{
1707 return align_slot(size + sizeof(block_trailer<T>));
1708}
1709
1710inline size_t pstsdk::disk::align_slot(size_t size)
1711{
1712 return ((size + bytes_per_slot - 1) & ~(bytes_per_slot - 1));
1713}
1714
1715#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:1710
const uint block_id_internal_bit
The internal bit indicates a block is an extended_block or a subnode_block.
Definition disk.h:995
const uint block_id_increment
The block id counter in the header is incremented by this amount for each block.
Definition disk.h:1000
bool bid_is_internal(T bid)
Determines if a block is internal or not.
Definition disk.h:1018
const size_t max_block_disk_size
The maximum individual block size.
Definition disk.h:955
block_types
The different block types.
Definition disk.h:961
bool bid_is_external(T bid)
Determines if a block is external or not.
Definition disk.h:1009
size_t align_disk(size_t size)
Aligns a block size to the size on disk.
Definition disk.h:1705
@ block_type_external
An external data block.
Definition disk.h:962
@ block_type_sub
A subnode block type.
Definition disk.h:964
@ block_type_extended
An extended block type.
Definition disk.h:963
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
amap_validity
The root of the database.
Definition disk.h:119
const uint hlmagic
High/Low magic number.
Definition disk.h:162
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
@ valid_amap1
Definition disk.h:121
@ valid_amap2
Valid.
Definition disk.h:122
@ invalid_amap
The AMaps are stale and must be rebuilt before use.
Definition disk.h:120
@ 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:1242
const byte heap_signature
Signature of a heap.
Definition disk.h:1234
heap_client_signature
Different heap client signature types.
Definition disk.h:1248
const uint heap_max_alloc_size
Maximum allocation size in a heap.
Definition disk.h:1238
@ heap_sig_chtc
Definition disk.h:1254
@ heap_sig_pc
Definition disk.h:1256
@ heap_sig_hmp
Definition disk.h:1252
@ heap_sig_bth
Definition disk.h:1255
@ heap_sig_gmp
Definition disk.h:1249
@ heap_sig_tc
Definition disk.h:1250
@ heap_sig_smp
Definition disk.h:1251
@ heap_sig_ch
Definition disk.h:1253
ushort nameid_get_prop_index(const nameid &n)
Returns the index of a given nameid structure.
Definition disk.h:1607
bool nameid_is_string(const nameid &n)
Returns true if the nameid structure is named by a string.
Definition disk.h:1621
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:1614
const size_t page_size
Size of all pages in the file in bytes, including the page trailer.
Definition disk.h:539
page_type
Valid page types.
Definition disk.h:547
const size_t first_amap_page_location
The location of the first AMap page in the file.
Definition disk.h:630
const size_t dlist_page_location
The location of the only DList page in the file.
Definition disk.h:714
ulong dlist_get_page_num(ulong entry)
Get a amap page number (ordinal) from a DLIST entry.
Definition disk.h:764
ulong dlist_get_slots(ulong entry)
Get the number of free slots from a DLIST entry.
Definition disk.h:770
const ulong dlist_page_num_mask
The portion of the dlist entry which refers to the amap page number.
Definition disk.h:753
const size_t bytes_per_slot
Number of bytes each slot (bit) in an AMap page refers to.
Definition disk.h:625
const ushort block_unreferenced
The value of bbt_leaf_entry::ref_count for an unreferenced block.
Definition disk.h:819
const ulong dlist_slots_shift
The bits to shift a dlist entry to get the slots on that amap page.
Definition disk.h:758
@ page_type_amap
An AMap (Allocation Map) page.
Definition disk.h:552
@ page_type_pmap
Definition disk.h:551
@ page_type_fmap
Definition disk.h:550
@ page_type_fpmap
Definition disk.h:553
@ page_type_nbt
A NBT (Nodes BTree) page.
Definition disk.h:549
@ page_type_bbt
A BBT (Blocks BTree) page.
Definition disk.h:548
@ page_type_dlist
A DList (Density List) page.
Definition disk.h:554
tc_offsets
Indices into the size offsets array.
Definition disk.h:1490
@ tc_offsets_four
Definition disk.h:1491
@ tc_offsets_max
Definition disk.h:1495
@ tc_offsets_two
Definition disk.h:1492
@ tc_offsets_one
Definition disk.h:1493
@ tc_offsets_bitmap
Definition disk.h:1494
void permute(void *pdata, ulong cb, bool encrypt)
Modifies the data block in place, according to the permute method.
Definition disk.h:1667
void cyclic(void *pdata, ulong cb, ulong key)
Modifies the data block in place, according to the cyclic method.
Definition disk.h:1680
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:1656
const ulong crc_table[]
Precalulated CRC table, used by compute_crc.
Definition disk.h:315
const byte table1[]
Data table1 used by permute and cyclic.
Definition disk.h:364
const byte table3[]
Data table3 used by permute and cyclic.
Definition disk.h:442
const byte table2[]
Data table2 used by permute and cyclic.
Definition disk.h:403
@ heap_fill_3
Definition disk.h:1266
@ heap_fill_7
Definition disk.h:1270
@ heap_fill_10
Definition disk.h:1273
@ heap_fill_8
Definition disk.h:1271
@ heap_fill_1
Definition disk.h:1264
@ heap_fill_13
Definition disk.h:1276
@ heap_fill_11
Definition disk.h:1274
@ heap_fill_9
Definition disk.h:1272
@ heap_fill_14
Definition disk.h:1277
@ heap_fill_12
Definition disk.h:1275
@ heap_fill_full
Definition disk.h:1278
@ heap_fill_5
Definition disk.h:1268
@ heap_fill_4
Definition disk.h:1267
@ heap_fill_2
Definition disk.h:1265
@ heap_fill_6
Definition disk.h:1269
@ heap_fill_empty
Definition disk.h:1263
const uint block_id_attached_bit
The attached bit indicates a block is referenced in memory This is an implementation detail,...
Definition disk.h:990
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:645
BBT Leaf Entry.
Definition disk.h:829
ushort size
The unaligned size of this block.
Definition disk.h:831
block_reference< T > ref
A reference to this block on disk.
Definition disk.h:830
ushort ref_count
The reference count of this block.
Definition disk.h:832
BBT leaf page.
Definition disk.h:938
BBT non-leaf page.
Definition disk.h:906
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:1043
block_id_disk bid
The id of this block.
Definition disk.h:1044
ushort cb
Size of the block (unaligned)
Definition disk.h:1041
ushort signature
Signature of this block, as calculated by the compute_signature function.
Definition disk.h:1042
BTree Entry.
Definition disk.h:780
bt_key key
The key of the page in ref.
Definition disk.h:783
block_reference< T > ref
A reference to a lower level page.
Definition disk.h:784
T bt_key
Definition disk.h:781
The fundamental page structure which forms the basis of the two BTrees.
Definition disk.h:851
static const size_t extra_space
Definition disk.h:852
byte _ignore[extra_space]
Definition disk.h:857
byte num_entries
Number of entries on this page.
Definition disk.h:860
byte entry_size
The size of each entry.
Definition disk.h:862
byte level
The level of this page. A level of zero indicates a leaf.
Definition disk.h:863
EntryType entries[max_entries]
Definition disk.h:856
static const size_t max_entries
Maximum number of entries on a page.
Definition disk.h:853
byte num_entries_max
Maximum number of entries on this page.
Definition disk.h:861
page_trailer< T > trailer
The page trailer.
Definition disk.h:865
Describes the BTH, including the size of the keys/values and the heap_id of the root allocation.
Definition disk.h:1346
byte num_levels
Number of levels.
Definition disk.h:1350
byte entry_size
Entry size in bytes.
Definition disk.h:1349
byte bth_signature
Always heap_sig_bth.
Definition disk.h:1347
byte key_size
Key size in bytes.
Definition disk.h:1348
heap_id root
Root of the actual tree structure.
Definition disk.h:1351
Entries which make up a "leaf" BTH allocation.
Definition disk.h:1383
V value
Value instance.
Definition disk.h:1385
K key
Key instance.
Definition disk.h:1384
EntryType entries[1]
Array of entries.
Definition disk.h:1403
Entries which make up a "non-leaf" BTH allocation.
Definition disk.h:1365
K key
Key of the lower level page.
Definition disk.h:1366
heap_id page
Heap id of the lower level page.
Definition disk.h:1367
BTH Nonleaf node.
Definition disk.h:1427
Describes a column.
Definition disk.h:1503
A metapage holding information about AMap pages.
Definition disk.h:727
ulong backfill_location
The current backfill marker, when backfilling.
Definition disk.h:736
byte _ignore[extra_space]
Definition disk.h:741
ulong current_page
The current AMap page used for allocations.
Definition disk.h:735
byte num_entries
Number of entries in the entries array.
Definition disk.h:732
ulong entries[max_entries]
Each entry has bits for the amap page (ordinal) and free space (slots)
Definition disk.h:740
static const size_t max_entries
Maximum number of entries in the dlist page.
Definition disk.h:729
static const size_t extra_space
Definition disk.h:728
page_trailer< T > trailer
The page trailer.
Definition disk.h:743
byte flags
Flags indicating the state of the dlist page.
Definition disk.h:731
byte block_type
Always block_type_extended.
Definition disk.h:1112
byte level
If zero, this block points to external blocks. If one, this block points to level zero extended block...
Definition disk.h:1113
ulong total_size
Total logical size of this block.
Definition disk.h:1115
ushort count
Number of entries in the bid array.
Definition disk.h:1114
External block definition.
Definition disk.h:1081
byte data[1]
Data contained in this block.
Definition disk.h:1083
static const size_t max_size
Definition disk.h:1082
A deprecated allocation system optimized for AMap page searching.
Definition disk.h:682
A deprecated allocation system optimized for PMap page searching.
Definition disk.h:704
GUST Column description structure.
Definition disk.h:1518
GUST TC Header.
Definition disk.h:1547
ushort size_offsets[tc_offsets_max]
Definition disk.h:1550
heapnode_id row_matrix_id
Definition disk.h:1552
block_id_disk bidNextP
Definition disk.h:252
block_id_disk bidNextB
Definition disk.h:250
root< ulong > root_info
Definition disk.h:255
byte bPlatformCreate
Always 0x1.
Definition disk.h:190
ulong dwOpenDBID
Implementation specific.
Definition disk.h:192
byte bLockSemaphore
Implementation specific.
Definition disk.h:214
ulong dwOpenClaimID
Implementation specific.
Definition disk.h:193
ushort wVerClient
Client version, database_type.
Definition disk.h:189
block_id_disk bidNextB
The block id counter.
Definition disk.h:209
ulonglong location
The location type used in the file.
Definition disk.h:182
ulonglong count
The count type used in the file.
Definition disk.h:183
root< ulonglong > root_info
The root info for this database.
Definition disk.h:198
block_id_disk bidNextP
The page id counter.
Definition disk.h:195
byte bCryptMethod
The crypt_method used in this file.
Definition disk.h:202
block_id_disk bidUnused
Unused.
Definition disk.h:194
ulonglong block_id_disk
The id type used for blocks and pages in the file.
Definition disk.h:181
ushort wVer
Version of the file, database_format.
Definition disk.h:188
ushort wMagicClient
Client magic number, eg pst_magic.
Definition disk.h:187
ulong dwMagic
Always hlmagic.
Definition disk.h:185
byte bPlatformAccess
Always 0x1.
Definition disk.h:191
Header structure on the first heap block.
Definition disk.h:1285
byte client_signature
Client defined signature, see heap_client_signature.
Definition disk.h:1290
static const uint fill_level_size
Number of bytes in the page_fill_levels map on this block.
Definition disk.h:1286
byte signature
Always heap_signature.
Definition disk.h:1289
heap_id root_id
Root allocation. This has specific meaning to the owner of this heap.
Definition disk.h:1291
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:1292
ushort page_map_offset
Offset of the start of the heap_page_map.
Definition disk.h:1288
Header structure on non-first/fill blocks.
Definition disk.h:1307
ushort page_map_offset
Offset of the start of the page map.
Definition disk.h:1310
byte page_fill_levels[fill_level_size]
Fill level of this and next 127 heap blocks.
Definition disk.h:1311
static const uint fill_level_size
Number of bytes in the page_fill_levels map on this block.
Definition disk.h:1308
Header structure on non-first/non-fill blocks.
Definition disk.h:1299
ushort page_map_offset
offset of the start of the page map
Definition disk.h:1300
Provides a map of the allocations on a heap block.
Definition disk.h:1328
ushort num_allocs
Number of allocations on this block.
Definition disk.h:1329
ushort num_frees
Number of empty allocations on this.
Definition disk.h:1330
ushort allocs[1]
The offset of each allocation.
Definition disk.h:1331
Multi-valued, variable length property TOC.
Definition disk.h:1474
ulong offsets[1]
Definition disk.h:1476
A modified nameid structure used in the hash buckets.
Definition disk.h:1593
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:1595
ulong hash_base
For numeric named props, this is just the id. Hash value of string props.
Definition disk.h:1594
Defines a id to name mapping.
Definition disk.h:1575
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:1581
ulong string_offset
offset into the string stream of the name of this prop
Definition disk.h:1579
ulong id
id of the named prop (for named props defined by an id)
Definition disk.h:1578
NBT Leaf Entry.
Definition disk.h:799
block_id_disk data
The block id of the data block.
Definition disk.h:804
T nid_index
Definition disk.h:800
block_id_disk sub
The block id of the subnode block.
Definition disk.h:805
T block_id_disk
Definition disk.h:801
node_id parent_nid
The parent node id.
Definition disk.h:806
nid_index nid
The node id.
Definition disk.h:803
NBT leaf page.
Definition disk.h:922
NBT non-leaf page.
Definition disk.h:890
ushort signature
Signature of this page, as calculated by the compute_signature function.
Definition disk.h:576
byte page_type_repeat
Same as the page_type field, for validation purposes.
Definition disk.h:575
ulong crc
CRC of this page, as calculated by the compute_crc function.
Definition disk.h:577
byte page_type
The page_type of this page.
Definition disk.h:574
block_id_disk bid
The id of this page.
Definition disk.h:578
Generic page structure.
Definition disk.h:611
byte data[page_data_size]
space used for actual data
Definition disk.h:614
static const size_t page_data_size
Amount of usable space in a page.
Definition disk.h:612
page_trailer< T > trailer
The page trailer for this page.
Definition disk.h:615
An old allocation system optimized for pages.
Definition disk.h:664
The value type of the BTH backing a pc.
Definition disk.h:1446
ushort type
Definition disk.h:1447
heapnode_id id
Definition disk.h:1448
byte bARVec
Indicates which AddRef vector is used.
Definition disk.h:139
location ibFileEof
EOF of the file, according the header.
Definition disk.h:132
location ibAMapLast
The location of the last valid AMap page.
Definition disk.h:133
ulong cOrphans
The number of "orphans" in the BBT.
Definition disk.h:131
count cbPMapFree
Amount of space free in all PMap pages.
Definition disk.h:135
ushort cARVec
Number of elements in the AddRef vector.
Definition disk.h:140
byte fAMapValid
Indicates if the AMap pages are valid or not.
Definition disk.h:138
block_reference< T > brefBBT
The location of the root of the BBT.
Definition disk.h:137
count cbAMapFree
Amount of space free in all AMap pages.
Definition disk.h:134
block_reference< T > brefNBT
The location of the root of the NBT.
Definition disk.h:136
Subnode Blocks.
Definition disk.h:1193
ushort count
Number of entries in the entry array.
Definition disk.h:1196
EntryType entry[1]
Array of entries.
Definition disk.h:1197
byte level
One for non-leaf, zero for leaf.
Definition disk.h:1195
byte block_type
Always block_type_sub.
Definition disk.h:1194
Subnode leaf block.
Definition disk.h:1221
Entries on a leaf sub_block.
Definition disk.h:1150
node_id nid
Subnode id.
Definition disk.h:1153
block_id_disk sub
Subnode block of this subnode. Yes, subnodes can and do themselves had subnodes.
Definition disk.h:1155
T block_id_disk
Definition disk.h:1151
block_id_disk data
Data block of this subnode.
Definition disk.h:1154
Subnode non-leaf block.
Definition disk.h:1209
Entries on a nonleaf sub_block.
Definition disk.h:1171
block_id_disk sub_block_bid
Id of the subnode block.
Definition disk.h:1175
T block_id_disk
Definition disk.h:1172
node_id nid_key
Key of the subnode block.
Definition disk.h:1174
The root_id allocation out of the Heap of a TC node.
Definition disk.h:1533
column_description columns[1]
Definition disk.h:1540
ushort size_offsets[tc_offsets_max]
Definition disk.h:1536
heapnode_id row_matrix_id
Definition disk.h:1538