Changeset 169 for trunk/include
- Timestamp:
- 03/03/10 14:24:58 (15 years ago)
- Location:
- trunk/include
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/lru_cache.h
r168 r169 1 /** 2 * @file 3 * 4 * Copyright (C) 2008-2009 Timothy D. Morgan 1 /* 2 * Copyright (C) 2008-2010 Timothy D. Morgan 5 3 * 6 4 * This program is free software; you can redistribute it and/or modify … … 19 17 * $Id$ 20 18 */ 19 20 /** 21 * @file 22 * 23 * A data structure which approximates a least recently used (LRU) cache. 24 * Implemented as a basic randomized hash table. 25 */ 26 21 27 22 28 #ifndef LRU_CACHE_H … … 44 50 }; 45 51 52 53 /** XXX: document this. */ 46 54 typedef struct _lru_cache 47 55 { … … 57 65 58 66 67 /** 68 * XXX: finish documenting. 69 */ 59 70 lru_cache* lru_cache_create(uint32_t max_keys, uint32_t secret); 71 72 73 /** 74 * XXX: finish documenting. 75 */ 60 76 lru_cache* lru_cache_create_ctx(void* talloc_ctx, uint32_t max_keys, 61 77 uint32_t secret, bool talloc_data); 78 79 80 /** 81 * XXX: finish documenting. 82 */ 62 83 void lru_cache_destroy(lru_cache* ht); 63 84 64 /* 65 * 85 86 /** 87 * XXX: finish documenting. 66 88 */ 67 89 bool lru_cache_update(lru_cache* ht, const void* index, 68 90 uint32_t index_len, void* data); 69 91 70 /* Returns pointer to data previously stored at index. 71 * If no data was found at index, NULL is returned. 92 /** 93 * XXX: finish documenting. 94 * 95 * @return A pointer to data previously stored at index. 96 * If no data was found at index, NULL is returned. 72 97 */ 73 98 void* lru_cache_find(lru_cache* ht, const void* index, 74 99 uint32_t index_len); 75 100 76 /* Removes entry from table at index. 77 * Returns pointer to data that was there previously. 78 * Returns NULL if no entry is at index. 101 /** 102 * XXX: finish documenting. 103 * 104 * Removes entry from table at index. 105 * 106 * @return A pointer to data that was there previously or NULL if no entry is 107 * at index. 79 108 */ 80 109 bool lru_cache_remove(lru_cache* ht, const void* index, -
trunk/include/range_list.h
r168 r169 1 /** 2 * @file 3 * 4 * Copyright (C) 2008-2009 Timothy D. Morgan 1 /* 2 * Copyright (C) 2008-2010 Timothy D. Morgan 5 3 * 6 4 * This program is free software; you can redistribute it and/or modify … … 18 16 * 19 17 * $Id$ 18 */ 19 20 /** 21 * @file 22 * 23 * A data structure which stores a list of address ranges. 24 * 25 * range_lists support basic in-place modifications and maintain the address 26 * space in sorted order. Looking up a range_list_element is implemented 27 * through binary search. 20 28 */ 21 29 … … 38 46 39 47 48 /** XXX: document this. */ 40 49 typedef struct _range_list 41 50 { … … 46 55 47 56 48 /* range_list_new(): 49 * Allocates a new range_list. 57 /** Allocates a new range_list. 50 58 * 51 * Returns: 52 * A newly allocated range_list, or NULL if an error occurred. 59 * @return A newly allocated range_list, or NULL if an error occurred. 53 60 */ 54 61 range_list* range_list_new(); 55 62 56 63 57 /* range_list_free(): 58 * Frees the memory associated with a range_list, including the elements, but 59 * not any data parameters referenced by those elements. If rl is NULL, does 60 * nothing. 64 /** Frees the memory associated with a range_list, including the elements, but 65 * not any data parameters referenced by those elements. 61 66 * 62 * Arguments: 63 * rl -- the range_list to be free()d. 67 * If rl is NULL, does nothing. 68 * 69 * @param rl the range_list to be free()d. 64 70 */ 65 71 void range_list_free(range_list* rl); 66 72 67 73 68 /* range_list_size(): 69 * Query the current number of elements on a range_list 74 /** Query the current number of elements on a range_list 70 75 * 71 * Arguments: 72 * rl -- the range_list to query 76 * @param rl the range_list to query 73 77 * 74 * Returns: 75 * The number of elements currently in the list. 78 * @return The number of elements currently in the list. 76 79 */ 77 80 uint32_t range_list_size(const range_list* rl); 78 81 79 82 80 /* range_list_add(): 81 * Adds an element to the range_list. 82 * The new element must not overlap with others. 83 * NOTE: this is a slow operation. 83 /** Adds an element to the range_list. 84 84 * 85 * Arguments: 86 * rl -- the range list to update 87 * offset -- the starting point for the range 88 * length -- the length of the range 89 * data -- misc data associated with this range element 90 * Returns: 91 * true on success, false on failure. 92 * Failures can occur due to memory limitations, max_size limitations, 93 * or if the submitted range overlaps with an existing element. Other 94 * errors may also be possible. 85 * The new element must not overlap with others. 86 * NOTE: this is a slow operation. 87 * 88 * @param rl the range list to update 89 * @param offset the starting point for the range 90 * @param length the length of the range 91 * @param data misc data associated with this range element 92 * 93 * @return true on success, false on failure. 94 * 95 * Failures can occur due to memory limitations, max_size limitations, 96 * or if the submitted range overlaps with an existing element. Other 97 * errors may also be possible. 95 98 */ 96 99 bool range_list_add(range_list* rl, uint32_t offset, uint32_t length, void* data); 97 100 98 101 99 /* range_list_remove(): 100 * Removes an element from the list. The element data structure will be 101 * freed, but the data property will not be. 102 /** Removes an element from the list. 102 103 * 103 * Arguments: 104 * rl -- the range_list to modify 105 * index -- the element index to remove 104 * The element data structure will be freed, but the data property will not be. 106 105 * 107 * Returns: 108 * true if the element was successfully removed, false otherwise. 106 * @param rl the range_list to modify 107 * @param index the element index to remove 108 * 109 * @return true if the element was successfully removed, false otherwise. 109 110 */ 110 111 bool range_list_remove(range_list* rl, uint32_t index); 111 112 112 113 113 /* range_list_get(): 114 * Retrieves the element for a given index. 114 /** Retrieves the element for a given index. 115 115 * 116 * Arguments: 117 * rl -- the range_list being queried. 118 * index -- the element index desired. 116 * @param rl the range_list being queried. 117 * @param index the element index desired. 119 118 * 120 * Returns:121 * The element for a given index, or NULL if the element is notavailable.119 * @return The element for a given index, or NULL if the element is not 120 * available. 122 121 */ 123 122 const range_list_element* range_list_get(const range_list* rl, uint32_t index); 124 123 125 124 126 /* range_list_find(): 127 * Attempts to find the unique element whose range encompasses offset. 125 /** Attempts to find the unique element whose range encompasses offset. 128 126 * 129 * Arguments: 130 * rl -- the range_list being queried. 131 * offset -- the location for which an element is desired. 127 * @param rl the range_list being queried. 128 * @param offset the location for which an element is desired. 132 129 * 133 * Returns: 134 * A matching element index or a negative value if none could be found. 130 * @return A matching element index or a negative value if none could be found. 135 131 */ 136 132 int32_t range_list_find(const range_list* rl, uint32_t offset); 137 133 138 134 139 /* range_list_find_data(): 140 * Same as range_list_find(), but returns the data associated with an element. 135 /** Same as range_list_find(), but returns the data associated with an element. 141 136 * 142 * Arguments: 143 * rl -- the range_list being queried. 144 * offset -- the address to search for in the ranges 137 * @param rl the range_list being queried. 138 * @param offset the address to search for in the ranges 145 139 * 146 * Returns: 147 * The data element of the matching element index or NULL if none could 148 * be found. 140 * @return The data element of the matching element index or NULL if none could 141 * be found. 149 142 * 150 * NOTE: May also return NULL if an element matched but ifthe data143 * NOTE: May also return NULL if an element matched but the data 151 144 * element was never set. 152 145 */ … … 154 147 155 148 156 /* range_list_split_element(): 157 * Splits an existing element into two elements in place. 149 /** Splits an existing element into two elements in place. 158 150 * 159 * 160 * 161 * 162 * 163 * 164 * 151 * The resulting list will contain an additional element whose offset 152 * is the one provided and whose length extends to the end of the old element 153 * (the one identified by the index). The original element's offset will 154 * remain the same while it's length is shortened such that it is contiguous 155 * with the newly created element. The newly created element will have an index 156 * of one more than the current element. 165 157 * 166 * 167 * 158 * Both the original element and the newly created element will reference the 159 * original element's data. 168 160 * 169 * Arguments: 170 * rl -- the range_list to modify 171 * index -- the index of the element to be split 172 * offset -- the at which the element will be split 161 * @param rl the range_list to modify 162 * @param index the index of the element to be split 163 * @param offset the at which the element will be split 173 164 * 174 * Returns: 175 * true if the element was successfully split, false otherwise. 176 * 177 * 165 * @return true if the element was successfully split, false otherwise. 178 166 */ 179 167 bool range_list_split_element(range_list* rl, uint32_t index, uint32_t offset); 180 168 181 169 182 /* range_list_has_range(): 183 * Determines whether or not a specified range exists contiguously within the 170 /** Determines whether or not a specified range exists contiguously within the 184 171 * range_list. 185 172 * 186 * Arguments: 187 * rl -- the range_list to search 188 * start -- the offset at the beginning of the range 189 * length -- the length of the range 173 * @param rl the range_list to search 174 * @param start the offset at the beginning of the range 175 * @param length the length of the range 190 176 * 191 * Returns: 192 * true if the specified range exists and is complete, false otherwise. 177 * @return true if the specified range exists and is complete, false otherwise. 193 178 */ 194 179 bool range_list_has_range(range_list* rl, uint32_t start, uint32_t length); -
trunk/include/regfi.h
r168 r169 1 /** @file 2 * Windows NT (and later) registry parsing library 3 * 4 * Branched from Samba project Subversion repository, version #6903: 5 * http://viewcvs.samba.org/cgi-bin/viewcvs.cgi/trunk/source/include/regfio.h?rev=6903&view=auto 6 * 1 /* 7 2 * Copyright (C) 2005-2010 Timothy D. Morgan 8 3 * Copyright (C) 2005 Gerald (Jerry) Carter … … 24 19 */ 25 20 26 /************************************************************ 27 * Most of this information was obtained from 28 * http://www.wednesday.demon.co.uk/dosreg.html 29 * Thanks Nigel! 30 ***********************************************************/ 21 /** 22 * @file 23 * Windows NT (and later) read-only registry library 24 * 25 * This library is intended for use in digital forensics investigations, but 26 * is likely useful in other applications. 27 * 28 * Branched from Samba project Subversion repository, version #6903: 29 * http://viewcvs.samba.org/cgi-bin/viewcvs.cgi/trunk/source/include/regfio.h?rev=6903&view=auto 30 * 31 * Since then, it has been heavily rewritten, simplified, and improved. 32 */ 31 33 32 34 /** 33 35 * @mainpage Home 34 36 * 35 * See \ref regfiTopLayer 36 */ 37 * The regfi library is a read-only NT registry library which serves as the main 38 * engine behind the reglookup tool. It is designed with digital forensic 39 * analysis in mind, but it should also be useful in other tools which need to 40 * efficiently traverse and query registry data structures. 41 * 42 * The library is broken down into four main parts, the 43 * @ref regfiBase "Base Layer", which any code dependent on the library will 44 * likely need to rely on, as well as three main functional layers: 45 * @li @ref regfiIteratorLayer 46 * @li @ref regfiGlueLayer 47 * @li @ref regfiParseLayer 48 * 49 * Most users will find that a combination of the Base Layer and the Iterator Layer 50 * will be sufficient for accessing registry hive files. Those who are wiling 51 * to dive deep into registry data structures, for instance to recover deleted 52 * data structures or to research Windows registry behavior in detail, will 53 * find the Parse Layer to be quite useful. 54 */ 55 37 56 38 57 #ifndef _REGFI_H … … 42 61 #include <stdio.h> 43 62 #include <stdbool.h> 44 #include <stdarg.h>45 63 #include <string.h> 46 64 #include <errno.h> … … 50 68 #include <sys/types.h> 51 69 #include <unistd.h> 52 #include <assert.h>53 70 #include <iconv.h> 54 71 … … 230 247 231 248 232 /* HBIN block */ 249 /** HBIN block information 250 * @ingroup regfiMiddleLayer 251 */ 233 252 typedef struct _regfi_hbin 234 253 { 235 uint32_t file_off; /* my offset in the registry file */ 236 uint32_t ref_count; /* how many active records are pointing to this 237 * block (not used currently) 238 */ 239 240 uint32_t first_hbin_off; /* offset from first hbin block */ 241 uint32_t block_size; /* block size of this block 242 * Should be a multiple of 4096 (0x1000) 243 */ 244 uint32_t next_block; /* relative offset to next block. 245 * NOTE: This value may be unreliable! 246 */ 247 248 uint8_t magic[REGFI_HBIN_MAGIC_SIZE]; /* "hbin" */ 254 /** Offset of this HBIN in the registry file */ 255 uint32_t file_off; 256 257 /** Number of active records pointing to this block (not used currently) */ 258 uint32_t ref_count; 259 260 /** Offset from first hbin block */ 261 uint32_t first_hbin_off; 262 263 /** Block size of this block Should be a multiple of 4096 (0x1000) */ 264 uint32_t block_size; 265 266 /** Relative offset to next block. 267 * 268 * @note This value may be unreliable! 269 */ 270 uint32_t next_block; 271 272 /** Magic number for the HBIN (should be "hbin"). */ 273 uint8_t magic[REGFI_HBIN_MAGIC_SIZE]; 249 274 } REGFI_HBIN; 250 275 … … 262 287 263 288 289 /** Subkey-list structure 290 * @ingroup regfiMiddleLayer 291 */ 264 292 typedef struct _regfi_subkey_list 265 293 { … … 284 312 285 313 typedef uint32_t REGFI_VALUE_LIST_ELEM; 314 /** Value-list structure 315 * @ingroup regfiMiddleLayer 316 */ 286 317 typedef struct _regfi_value_list 287 318 { … … 295 326 296 327 328 /** Class name structure (used in storing SysKeys) 329 * @ingroup regfiBase 330 */ 297 331 typedef struct _regfi_classname 298 332 { 299 /* As converted to requested character encoding.*/333 /** As converted to requested REGFI_ENCODING */ 300 334 char* interpreted; 301 335 302 /* Represents raw buffer read from classname cell. */ 336 /** Represents raw buffer read from classname cell. 337 * 338 * Length of this item is specified in the size field. 339 */ 303 340 uint8_t* raw; 304 341 305 /* Length of the raw data. May be shorter than that indicated by parent key.*/ 342 /** Length of the raw data. 343 * 344 * May be shorter than that indicated by parent key. 345 */ 306 346 uint16_t size; 307 347 } REGFI_CLASSNAME; 308 348 309 349 350 /** Data record structure 351 * @ingroup regfiBase 352 */ 310 353 typedef struct _regfi_data 311 354 { 355 /** Data type of this data, as indicated by the referencing VK record. */ 312 356 uint32_t type; 313 357 314 /* Length of the raw data. */358 /** Length of the raw data. */ 315 359 uint32_t size; 316 360 317 /* This is always present, representing the raw data cell contents. */361 /** This is always present, representing the raw data cell contents. */ 318 362 uint8_t* raw; 319 363 320 /* Represents the length of the interpreted value. Meaning is type-specific.*/364 /** Represents the length of the interpreted value. Meaning is type-specific. */ 321 365 uint32_t interpreted_size; 322 366 323 /* These items represent interpreted versions of the raw attribute above. 324 * Only use the appropriate member according to the type field. 325 * In the event of an unknown type, use only the raw field. 367 /** These items represent interpreted versions of the REGFI_DATA::raw field. 368 * 369 * Only use the appropriate member according to the REGFI_DATA::type field. 370 * In the event of an unknown type, use only the REGFI_DATA::raw field. 326 371 */ 327 372 union _regfi_data_interpreted 328 373 { 329 uint8_t* none; /* */ 374 /** REG_NONE 375 * 376 * Stored as a raw buffer. Use REGFI_DATA::interpreted_size to determine 377 * length. 378 */ 379 uint8_t* none; 380 381 /** REG_SZ 382 * 383 * Stored as a NUL terminated string. Converted to the specified 384 * REGFI_ENCODING. 385 */ 330 386 uint8_t* string; 387 388 /** REG_EXPAND_SZ 389 * 390 * Stored as a NUL terminated string. Converted to the specified 391 * REGFI_ENCODING. 392 */ 331 393 uint8_t* expand_string; 332 uint8_t* binary; /* */ 394 395 /** REG_BINARY 396 * 397 * Stored as a raw buffer. Use REGFI_DATA::interpreted_size to determine 398 * length. 399 */ 400 uint8_t* binary; 401 402 /** REG_DWORD */ 333 403 uint32_t dword; 404 405 /** REG_DWORD_BE */ 334 406 uint32_t dword_be; 407 408 /** REG_LINK 409 * 410 * Stored as a NUL terminated string. Converted to the specified 411 * REGFI_ENCODING. 412 */ 335 413 uint8_t* link; 414 415 /** REG_MULTI_SZ 416 * 417 * Stored as a list of uint8_t* pointers, terminated with a NULL pointer. 418 * Each string element in the list is NUL terminated, and the character set 419 * is determined by the specified REGFI_ENCODING. 420 */ 336 421 uint8_t** multiple_string; 422 423 /** REG_QWORD */ 337 424 uint64_t qword; 338 425 … … 340 427 * the future as the formats become better understood. 341 428 */ 429 430 /** REG_RESOURCE_LIST 431 * 432 * Stored as a raw buffer. Use REGFI_DATA::interpreted_size to determine 433 * length. 434 */ 342 435 uint8_t* resource_list; 436 437 /** REG_FULL_RESOURCE_DESCRIPTOR 438 * 439 * Stored as a raw buffer. Use REGFI_DATA::interpreted_size to determine 440 * length. 441 */ 343 442 uint8_t* full_resource_descriptor; 443 444 /** REG_RESOURCE_REQUIREMENTS_LIST 445 * 446 * Stored as a raw buffer. Use REGFI_DATA::interpreted_size to determine 447 * length. 448 */ 344 449 uint8_t* resource_requirements_list; 345 450 } interpreted; … … 347 452 348 453 349 /* Value record */ 350 typedef struct 454 /** Value structure 455 * @ingroup regfiBase 456 */ 457 typedef struct 351 458 { 352 uint32_t offset; /* Real offset of this record's cell in the file */ 353 uint32_t cell_size; /* ((start_offset - end_offset) & 0xfffffff8) */ 354 355 REGFI_DATA* data; /* XXX: deprecated */ 356 357 char* valuename; 459 /** Real offset of this record's cell in the file */ 460 uint32_t offset; 461 462 /** ((start_offset - end_offset) & 0xfffffff8) */ 463 uint32_t cell_size; 464 465 /* XXX: deprecated */ 466 REGFI_DATA* data; 467 468 /** The name of this value converted to desired REGFI_ENCODING. 469 * 470 * This conversion typically occurs automatically through REGFI_ITERATOR 471 * settings. String is NUL terminated. 472 */ 473 char* valuename; 474 475 /** The raw value name 476 * 477 * Length of the buffer is stored in name_length. 478 */ 358 479 uint8_t* valuename_raw; 480 481 /** Length of valuename_raw */ 359 482 uint16_t name_length; 360 uint32_t hbin_off; /* offset from beginning of this hbin block */ 483 484 /** Offset from beginning of this hbin block */ 485 uint32_t hbin_off; 361 486 362 uint32_t data_size; /* As reported in the VK record. May be different than 363 * That obtained while parsing the data cell itself. */ 364 uint32_t data_off; /* Offset of data cell (virtual) */ 487 /** Size of the value's data as reported in the VK record. 488 * 489 * May be different than that obtained while parsing the data cell itself. 490 */ 491 uint32_t data_size; 492 493 /** Virtual offset of data cell */ 494 uint32_t data_off; 495 496 /** Value's data type */ 365 497 uint32_t type; 498 499 /** VK record's magic number (should be "vk") */ 366 500 uint8_t magic[REGFI_CELL_MAGIC_SIZE]; 501 502 /** VK record flags */ 367 503 uint16_t flags; 504 505 /* XXX: A 2-byte field of unknown purpose stored in the VK record */ 368 506 uint16_t unknown1; 369 bool data_in_offset; 507 508 /** Whether or not the data record is stored in the VK record's data_off field. 509 * 510 * This information is derived from the high bit of the raw data size field. 511 */ 512 bool data_in_offset; 370 513 } REGFI_VK_REC; 371 514 … … 374 517 struct _regfi_sk_rec; 375 518 519 /** Security structure 520 * @ingroup regfiBase 521 */ 376 522 typedef struct _regfi_sk_rec 377 523 { 378 uint32_t offset; /* Real file offset of this record */ 379 uint32_t cell_size; /* ((start_offset - end_offset) & 0xfffffff8) */ 380 524 /** Real file offset of this record */ 525 uint32_t offset; 526 527 /** ((start_offset - end_offset) & 0xfffffff8) */ 528 uint32_t cell_size; 529 530 /** The stored Windows security descriptor for this SK record */ 381 531 WINSEC_DESC* sec_desc; 382 uint32_t hbin_off; /* offset from beginning of this hbin block */ 532 533 /** Offset of this record from beginning of this hbin block */ 534 uint32_t hbin_off; 383 535 536 /** Offset of the previous SK record in the linked list of SK records */ 384 537 uint32_t prev_sk_off; 538 539 /** Offset of the next SK record in the linked list of SK records */ 385 540 uint32_t next_sk_off; 541 542 /** Number of keys referencing this SK record */ 386 543 uint32_t ref_count; 387 uint32_t desc_size; /* size of security descriptor */ 544 545 /** Size of security descriptor (sec_desc) */ 546 uint32_t desc_size; 547 548 /* XXX: A 2-byte field of unknown purpose */ 388 549 uint16_t unknown_tag; 550 551 /** The magic number for this record (should be "sk") */ 389 552 uint8_t magic[REGFI_CELL_MAGIC_SIZE]; 390 553 } REGFI_SK_REC; 391 554 392 555 393 /* Key Name */ 556 /** Key structure 557 * @ingroup regfiBase 558 */ 394 559 typedef struct 395 560 { 396 uint32_t offset; /* Real offset of this record's cell in the file */ 397 uint32_t cell_size; /* Actual or estimated length of the cell. 398 * Always in multiples of 8. 399 */ 400 401 /* link in the other records here */ 561 /** Real offset of this record's cell in the file */ 562 uint32_t offset; 563 564 /** Actual or estimated length of the cell. 565 * Always in multiples of 8. 566 */ 567 uint32_t cell_size; 568 569 /** Preloaded value-list for this key. 570 * This element is loaded automatically when using the iterator interface and 571 * possibly some lower layer interfaces. 572 */ 402 573 REGFI_VALUE_LIST* values; 574 575 576 /** Preloaded subkey-list for this key. 577 * This element is loaded automatically when using the iterator interface and 578 * possibly some lower layer interfaces. 579 */ 403 580 REGFI_SUBKEY_LIST* subkeys; 404 581 405 /* header information*/582 /** Key flags */ 406 583 uint16_t flags; 584 585 /** Magic number of key (should be "nk") */ 407 586 uint8_t magic[REGFI_CELL_MAGIC_SIZE]; 587 588 /** Key's last modification time */ 408 589 REGFI_NTTIME mtime; 590 591 /** Length of keyname_raw */ 409 592 uint16_t name_length; 593 594 /** Length of referenced classname */ 410 595 uint16_t classname_length; 596 597 /** The name of this key converted to desired REGFI_ENCODING. 598 * 599 * This conversion typically occurs automatically through REGFI_ITERATOR 600 * settings. String is NUL terminated. 601 */ 411 602 char* keyname; 603 604 /** The raw key name 605 * 606 * Length of the buffer is stored in name_length. 607 */ 412 608 uint8_t* keyname_raw; 413 uint32_t parent_off; /* pointer to parent key */ 609 610 /** Virutal offset of parent key */ 611 uint32_t parent_off; 612 613 /** Virutal offset of classname key */ 414 614 uint32_t classname_off; 415 615 416 /* max lengths */ 417 uint32_t max_bytes_subkeyname; /* max subkey name * 2 */ 418 uint32_t max_bytes_subkeyclassname; /* max subkey classname length (as if) */ 419 uint32_t max_bytes_valuename; /* max valuename * 2 */ 420 uint32_t max_bytes_value; /* max value data size */ 616 /* XXX: max subkey name * 2 */ 617 uint32_t max_bytes_subkeyname; 618 619 /* XXX: max subkey classname length (as if) */ 620 uint32_t max_bytes_subkeyclassname; 621 622 /* XXX: max valuename * 2 */ 623 uint32_t max_bytes_valuename; 624 625 /* XXX: max value data size */ 626 uint32_t max_bytes_value; 421 627 422 /* unknowns*/628 /* XXX: Fields of unknown purpose */ 423 629 uint32_t unknown1; 424 630 uint32_t unknown2; … … 426 632 uint32_t unk_index; /* nigel says run time index ? */ 427 633 428 /* children*/634 /** Number of subkeys */ 429 635 uint32_t num_subkeys; 430 uint32_t subkeys_off; /* offset of subkey list that points to NK records */ 636 637 /** Virtual offset of subkey-list */ 638 uint32_t subkeys_off; 639 640 /** Number of values for this key */ 431 641 uint32_t num_values; 432 uint32_t values_off; /* value lists which point to VK records */ 433 uint32_t sk_off; /* offset to SK record */ 642 643 /** Virtual offset of value-list */ 644 uint32_t values_off; 645 646 /** Virtual offset of SK record */ 647 uint32_t sk_off; 434 648 } REGFI_NK_REC; 435 649 436 650 437 651 438 /* REGF block */ 652 /** Registry hive file data structure 653 * 654 * This essential structure stores run-time information about a single open 655 * registry hive as well as file header (REGF block) data. This structure 656 * also stores a list of warnings and error messages generated while parsing 657 * the registry hive. These can be tuned using @ref regfi_set_message_mask. 658 * Messages may be retrieved using @ref regfi_get_messages. 659 * 660 * @note If the message mask is set to record any messages, dependent code 661 * must use @ref regfi_get_messages periodically to clear the message 662 * queue. Otherwise, this structure will grow in size over time as 663 * messages queue up. 664 * 665 * @ingroup regfiBase 666 */ 439 667 typedef struct 440 668 { … … 513 741 514 742 743 /** Registry hive iterator 744 * @ingroup regfiIteratorLayer 745 */ 515 746 typedef struct _regfi_iterator 516 747 { 748 /** The registry hive this iterator is associated with */ 517 749 REGFI_FILE* f; 750 751 /** All current parent keys and associated iterator positions */ 518 752 void_stack* key_positions; 753 754 /** The current key */ 519 755 REGFI_NK_REC* cur_key; 756 757 /** The encoding that all strings are converted to as set during iterator 758 * creation. 759 */ 520 760 REGFI_ENCODING string_encoding; 761 762 /** Index of the current subkey */ 521 763 uint32_t cur_subkey; 764 765 /** Index of the current value */ 522 766 uint32_t cur_value; 523 767 } REGFI_ITERATOR; … … 534 778 535 779 780 /** General purpose buffer with stored length 781 * @ingroup regfiBottomLayer 782 */ 536 783 typedef struct _regfi_buffer 537 784 { … … 541 788 542 789 790 543 791 /******************************************************************************/ 544 792 /** 545 * @defgroup regfiBase Base Functions: Usable with Any Layer546 * 547 * These functions don't fit particularly well in any of the other layers or548 * are intended for use with any of the APIlayers.793 * @defgroup regfiBase Base Layer: Essential Functions and Data Structures 794 * 795 * These functions are either necessary for normal use of the regfi API or just 796 * don't fit particularly well in any of the other layers. 549 797 */ 550 798 /******************************************************************************/ 551 552 799 553 800 /** Attempts to open a registry hive and allocate related data structures. … … 658 905 /******************************************************************************/ 659 906 /** 660 * @defgroup regfi TopLayer TopLayer: Primary regfi Library Interface907 * @defgroup regfiIteratorLayer Iterator Layer: Primary regfi Library Interface 661 908 * 662 909 * This top layer of API functions provides an iterator interface which makes … … 681 928 * Must be free()d with regfi_iterator_free. 682 929 * 683 * @ingroup regfi TopLayer930 * @ingroup regfiIteratorLayer 684 931 */ 685 932 REGFI_ITERATOR* regfi_iterator_new(REGFI_FILE* file, … … 693 940 * @param i the iterator to be freed 694 941 * 695 * @ingroup regfi TopLayer942 * @ingroup regfiIteratorLayer 696 943 */ 697 944 void regfi_iterator_free(REGFI_ITERATOR* i); … … 709 956 * depth-first iteration particularly easy. 710 957 * 711 * @ingroup regfi TopLayer958 * @ingroup regfiIteratorLayer 712 959 */ 713 960 bool regfi_iterator_down(REGFI_ITERATOR* i); … … 721 968 * associated with the current key is lost. 722 969 * 723 * @ingroup regfi TopLayer970 * @ingroup regfiIteratorLayer 724 971 */ 725 972 bool regfi_iterator_up(REGFI_ITERATOR* i); … … 732 979 * @return true on success, false on failure. 733 980 * 734 * @ingroup regfi TopLayer981 * @ingroup regfiIteratorLayer 735 982 */ 736 983 bool regfi_iterator_to_root(REGFI_ITERATOR* i); … … 753 1000 * in its original position. 754 1001 * 755 * @ingroup regfi TopLayer1002 * @ingroup regfiIteratorLayer 756 1003 */ 757 1004 bool regfi_iterator_walk_path(REGFI_ITERATOR* i, const char** path); … … 764 1011 * @return A read-only key structure for the current key, or NULL on failure. 765 1012 * 766 * @ingroup regfi TopLayer1013 * @ingroup regfiIteratorLayer 767 1014 */ 768 1015 const REGFI_NK_REC* regfi_iterator_cur_key(REGFI_ITERATOR* i); … … 775 1022 * @return A read-only SK structure, or NULL on failure. 776 1023 * 777 * @ingroup regfi TopLayer1024 * @ingroup regfiIteratorLayer 778 1025 */ 779 1026 const REGFI_SK_REC* regfi_iterator_cur_sk(REGFI_ITERATOR* i); … … 790 1037 * regfi_free_key. 791 1038 * 792 * @ingroup regfi TopLayer1039 * @ingroup regfiIteratorLayer 793 1040 */ 794 1041 REGFI_NK_REC* regfi_iterator_first_subkey(REGFI_ITERATOR* i); … … 803 1050 * regfi_free_key. 804 1051 * 805 * @ingroup regfi TopLayer1052 * @ingroup regfiIteratorLayer 806 1053 */ 807 1054 REGFI_NK_REC* regfi_iterator_cur_subkey(REGFI_ITERATOR* i); … … 816 1063 * failure. Newly allocated keys must be freed with regfi_free_key. 817 1064 * 818 * @ingroup regfi TopLayer1065 * @ingroup regfiIteratorLayer 819 1066 */ 820 1067 REGFI_NK_REC* regfi_iterator_next_subkey(REGFI_ITERATOR* i); … … 830 1077 * the subkey index remains at the same location as before the call. 831 1078 * 832 * @ingroup regfi TopLayer1079 * @ingroup regfiIteratorLayer 833 1080 */ 834 1081 bool regfi_iterator_find_subkey(REGFI_ITERATOR* i, … … 845 1092 * regfi_free_value. 846 1093 * 847 * @ingroup regfi TopLayer1094 * @ingroup regfiIteratorLayer 848 1095 */ 849 1096 REGFI_VK_REC* regfi_iterator_first_value(REGFI_ITERATOR* i); … … 858 1105 * regfi_free_value. 859 1106 * 860 * @ingroup regfi TopLayer1107 * @ingroup regfiIteratorLayer 861 1108 */ 862 1109 REGFI_VK_REC* regfi_iterator_cur_value(REGFI_ITERATOR* i); … … 871 1118 * failure. Newly allocated keys must be freed with regfi_free_value. 872 1119 * 873 * @ingroup regfi TopLayer1120 * @ingroup regfiIteratorLayer 874 1121 */ 875 1122 REGFI_VK_REC* regfi_iterator_next_value(REGFI_ITERATOR* i); … … 885 1132 * the value index remains at the same location as before the call. 886 1133 * 887 * @ingroup regfi TopLayer1134 * @ingroup regfiIteratorLayer 888 1135 */ 889 1136 bool regfi_iterator_find_value(REGFI_ITERATOR* i, … … 898 1145 * Classname structures must be freed with regfi_free_classname. 899 1146 * 900 * @ingroup regfi TopLayer1147 * @ingroup regfiIteratorLayer 901 1148 */ 902 1149 REGFI_CLASSNAME* regfi_iterator_fetch_classname(REGFI_ITERATOR* i, … … 912 1159 * Data structures must be freed with regfi_free_data. 913 1160 * 914 * @ingroup regfi TopLayer1161 * @ingroup regfiIteratorLayer 915 1162 */ 916 1163 REGFI_DATA* regfi_iterator_fetch_data(REGFI_ITERATOR* i, … … 921 1168 /******************************************************************************/ 922 1169 /** 923 * @defgroup regfi MiddleLayer Middle Layer: Logical Data Structure Loading1170 * @defgroup regfiGlueLayer Glue Layer: Logical Data Structure Loading 924 1171 */ 925 1172 /******************************************************************************/ … … 929 1176 * XXX: finish documenting 930 1177 * 931 * @ingroup regfi MiddleLayer1178 * @ingroup regfiGlueLayer 932 1179 */ 933 1180 REGFI_NK_REC* regfi_load_key(REGFI_FILE* file, uint32_t offset, … … 940 1187 * XXX: finish documenting 941 1188 * 942 * @ingroup regfi MiddleLayer1189 * @ingroup regfiGlueLayer 943 1190 */ 944 1191 REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32_t offset, … … 951 1198 * XXX: finish documenting 952 1199 * 953 * @ingroup regfi MiddleLayer1200 * @ingroup regfiGlueLayer 954 1201 */ 955 1202 REGFI_SUBKEY_LIST* regfi_load_subkeylist(REGFI_FILE* file, uint32_t offset, … … 962 1209 * XXX: finish documenting 963 1210 * 964 * @ingroup regfi MiddleLayer1211 * @ingroup regfiGlueLayer 965 1212 */ 966 1213 REGFI_VALUE_LIST* regfi_load_valuelist(REGFI_FILE* file, uint32_t offset, … … 974 1221 * XXX: finish documenting 975 1222 * 976 * @ingroup regfi MiddleLayer1223 * @ingroup regfiGlueLayer 977 1224 */ 978 1225 REGFI_BUFFER regfi_load_data(REGFI_FILE* file, uint32_t voffset, … … 985 1232 * XXX: finish documenting 986 1233 * 987 * @ingroup regfi MiddleLayer1234 * @ingroup regfiGlueLayer 988 1235 */ 989 1236 REGFI_BUFFER regfi_load_big_data(REGFI_FILE* file, uint32_t offset, … … 998 1245 * XXX: finish documenting 999 1246 * 1000 * @ingroup regfi MiddleLayer1247 * @ingroup regfiGlueLayer 1001 1248 */ 1002 1249 bool regfi_interpret_data(REGFI_FILE* file, … … 1009 1256 * XXX: finish documenting 1010 1257 * 1011 * @ingroup regfi MiddleLayer1258 * @ingroup regfiGlueLayer 1012 1259 */ 1013 1260 void regfi_free_classname(REGFI_CLASSNAME* classname); … … 1018 1265 * XXX: finish documenting 1019 1266 * 1020 * @ingroup regfi MiddleLayer1267 * @ingroup regfiGlueLayer 1021 1268 */ 1022 1269 void regfi_free_data(REGFI_DATA* data); … … 1029 1276 * XXX: finish documenting 1030 1277 * 1031 * @ingroup regfi MiddleLayer1278 * @ingroup regfiGlueLayer 1032 1279 */ 1033 1280 const REGFI_SK_REC* regfi_load_sk(REGFI_FILE* file, uint32_t offset, … … 1039 1286 * XXX: finish documenting 1040 1287 * 1041 * @ingroup regfi MiddleLayer1288 * @ingroup regfiGlueLayer 1042 1289 */ 1043 1290 const REGFI_HBIN* regfi_lookup_hbin(REGFI_FILE* file, uint32_t offset); … … 1047 1294 /******************************************************************************/ 1048 1295 /** 1049 * @defgroup regfi BottomLayer BottomLayer: Direct Data Structure Access1296 * @defgroup regfiParseLayer Parsing Layer: Direct Data Structure Access 1050 1297 */ 1051 1298 /******************************************************************************/ … … 1066 1313 * @return A newly allocated NK record structure, or NULL on failure. 1067 1314 * 1068 * @ingroup regfi BottomLayer1315 * @ingroup regfiParseLayer 1069 1316 */ 1070 1317 REGFI_NK_REC* regfi_parse_nk(REGFI_FILE* file, uint32_t offset, … … 1076 1323 * XXX: finish documenting 1077 1324 * 1078 * @ingroup regfi BottomLayer1325 * @ingroup regfiParseLayer 1079 1326 */ 1080 1327 REGFI_SUBKEY_LIST* regfi_parse_subkeylist(REGFI_FILE* file, uint32_t offset, … … 1086 1333 * XXX: finish documenting 1087 1334 * 1088 * @ingroup regfi BottomLayer1335 * @ingroup regfiParseLayer 1089 1336 */ 1090 1337 REGFI_VK_REC* regfi_parse_vk(REGFI_FILE* file, uint32_t offset, … … 1096 1343 * XXX: finish documenting 1097 1344 * 1098 * @ingroup regfi BottomLayer1345 * @ingroup regfiParseLayer 1099 1346 */ 1100 1347 REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32_t offset, … … 1109 1356 * XXX: finish documenting 1110 1357 * 1111 * @ingroup regfi BottomLayer1358 * @ingroup regfiParseLayer 1112 1359 */ 1113 1360 range_list* regfi_parse_unalloc_cells(REGFI_FILE* file); … … 1118 1365 * XXX: finish documenting 1119 1366 * 1120 * @ingroup regfi BottomLayer1367 * @ingroup regfiParseLayer 1121 1368 */ 1122 1369 bool regfi_parse_cell(int fd, uint32_t offset, … … 1129 1376 * XXX: finish documenting 1130 1377 * 1131 * @ingroup regfi BottomLayer1378 * @ingroup regfiParseLayer 1132 1379 */ 1133 1380 uint8_t* regfi_parse_classname(REGFI_FILE* file, uint32_t offset, … … 1140 1387 * XXX: finish documenting 1141 1388 * 1142 * @ingroup regfi BottomLayer1389 * @ingroup regfiParseLayer 1143 1390 */ 1144 1391 REGFI_BUFFER regfi_parse_data(REGFI_FILE* file, uint32_t offset, … … 1151 1398 * XXX: finish documenting 1152 1399 * 1153 * @ingroup regfi BottomLayer1400 * @ingroup regfiParseLayer 1154 1401 */ 1155 1402 REGFI_BUFFER regfi_parse_little_data(REGFI_FILE* file, uint32_t voffset, … … 1163 1410 REGFI_ENCODING output_encoding); 1164 1411 void regfi_subkeylist_free(REGFI_SUBKEY_LIST* list); 1165 uint32_t 1412 uint32_t regfi_read(int fd, uint8_t* buf, uint32_t* length); 1166 1413 1167 1414 const char* regfi_type_val2str(unsigned int val); -
trunk/include/void_stack.h
r168 r169 1 /** 2 * @file 3 * 4 * Copyright (C) 2005,2007,2009 Timothy D. Morgan 1 /* 2 * Copyright (C) 2005,2007,2009-2010 Timothy D. Morgan 5 3 * 6 4 * This program is free software; you can redistribute it and/or modify … … 20 18 */ 21 19 20 /** 21 *@file 22 * 23 * This is a very simple implementation of a stack which stores chunks of 24 * memory of any type. 25 */ 26 27 22 28 #ifndef _VOID_STACK_H 23 29 #define _VOID_STACK_H … … 28 34 #include "talloc.h" 29 35 36 /** XXX: document this. */ 30 37 typedef struct _void_stack 31 38 { … … 35 42 } void_stack; 36 43 44 45 /** XXX: document this. */ 37 46 typedef struct _void_stack_iterator 38 47 { … … 42 51 43 52 44 /* void_stack_new(): 45 * Allocates a new void_stack. 53 /** Allocates a new void_stack. 46 54 * 47 * Arguments: 48 * max_size -- the maxiumum number of elements 49 * which may be pushed onto the stack. 55 * @param max_size the maxiumum number of elements 56 * which may be pushed onto the stack. 50 57 * 51 * Returns:52 * a pointer to the newly allocated void_stack,or NULL if an error occurred.58 * @return a pointer to the newly allocated void_stack, 59 * or NULL if an error occurred. 53 60 */ 54 61 void_stack* void_stack_new(unsigned short max_size); 55 62 56 63 57 /* void_stack_copy(): 58 * Makes a shallow copy of void_stack. 64 /** Makes a shallow copy of void_stack. 59 65 * 60 * Arguments: 61 * v -- the stack to make a copy of. 66 * @param v the stack to make a copy of. 62 67 * 63 * Returns: 64 * a pointer to the duplicate void_stack, or NULL If an error occurred. 68 * @return a pointer to the duplicate void_stack, or NULL if an error occurred. 65 69 */ 66 70 void_stack* void_stack_copy(const void_stack* v); 67 71 68 72 69 /* void_stack_copy_reverse(): 70 * Makes a shallow copy of void_stack in reverse order. 73 /** Makes a shallow copy of void_stack in reverse order. 71 74 * 72 * Arguments: 73 * v -- the stack to make a copy of. 75 * @param v the stack to make a copy of. 74 76 * 75 * Returns: 76 * a pointer to the duplicate void_stack (which will be in reverse order), 77 * or NULL If an error occurred. 77 * @return a pointer to the duplicate void_stack 78 * (which will be in reverse order), or NULL if an error occurred. 78 79 */ 79 80 void_stack* void_stack_copy_reverse(const void_stack* v); 80 81 81 82 82 /* void_stack_free(): 83 * Frees the memory associated with a void_stack, but not the elements held 83 /** Frees the memory associated with a void_stack, but not the elements held 84 84 * on the stack. 85 85 * 86 * Arguments: 87 * stack -- the stack to be free()d. 86 * @param stack the stack to be free()d. 88 87 */ 89 88 void void_stack_free(void_stack* stack); 90 89 91 90 92 /* void_stack_free_deep(): 93 * Frees the memory associated with a void_stack and the elements referenced 94 * by the stack. Do not use this function if the elements of the stack 95 * are also free()d elsewhere, or contain pointers to other memory which 96 * cannot be otherwise free()d. 91 /** Frees the memory associated with a void_stack and the elements referenced 92 * by the stack. 97 93 * 98 * Arguments: 99 * stack -- the stack to be free()d. 94 * Do not use this function if the elements of the stack 95 * are also free()d elsewhere, or contain pointers to other memory which 96 * cannot be otherwise free()d. 97 * 98 * @param stack the stack to be free()d. 100 99 */ 101 100 void void_stack_free_deep(void_stack* stack); 102 101 103 102 104 /* void_stack_size(): 105 * Query the current number of elements on a void_stack() 103 /** Query the current number of elements on a void_stack() 106 104 * 107 * Arguments: 108 * stack -- the void_stack to query 105 * @param stack the void_stack to query 109 106 * 110 * Returns: 111 * the number of elements currently on the stack. 107 * @return the number of elements currently on the stack. 112 108 */ 113 109 unsigned short void_stack_size(const void_stack* stack); 114 110 115 111 116 /* void_stack_pop(): 117 * Removes the top element on a void_stack and returns a reference to it. 112 /** Removes the top element on a void_stack and returns a reference to it. 118 113 * 119 * Arguments: 120 * stack -- the void_stack to pop 114 * @param stack the void_stack to pop 121 115 * 122 * Returns: 123 * a pointer to the popped stack element, or NULL if no elements exist on 124 * the stack. 116 * @return a pointer to the popped stack element, or NULL if no elements exist 117 * on the stack. 125 118 */ 126 119 void* void_stack_pop(void_stack* stack); 127 120 128 121 129 /* void_stack_push(): 130 * Puts a new element on the top of a void_stack. 122 /** Puts a new element on the top of a void_stack. 131 123 * 132 * Arguments:133 * stack -- the void_stack being modified.124 * @param stack the void_stack being modified. 125 * @param e the element to be added 134 126 * 135 * e -- the element to be added 136 * 137 * Returns: 138 * true if the element was successfully added, false otherwise. 127 * @return true if the element was successfully added, false otherwise. 139 128 */ 140 129 bool void_stack_push(void_stack* stack, void* e); 141 130 142 131 143 /* void_stack_cur(): 144 * Returns a pointer to the current element on the top of the stack. 132 /** Returns a pointer to the current element on the top of the stack. 145 133 * 146 * Arguments: 147 * stack -- the void_stack being queried. 134 * @param stack the void_stack being queried. 148 135 * 149 * Returns: 150 * a pointer to the current element on the top of the stack, or NULL if no 151 * elements exist in the stack. 136 * @return a pointer to the current element on the top of the stack, or NULL if 137 * no elements exist in the stack. 152 138 */ 153 139 const void* void_stack_cur(const void_stack* stack); 154 140 155 141 156 /* void_stack_iterator_new(): 157 * Creates a new iterator for the specified void_stack. 142 /** Creates a new iterator for the specified void_stack. 158 143 * 159 * Arguments: 160 * stack -- the void_stack to be referenced by the new iterator 144 * @param stack the void_stack to be referenced by the new iterator 161 145 * 162 * Returns: 163 * a new void_stack_iterator, or NULL if an error occurred. 146 * @return a new void_stack_iterator, or NULL if an error occurred. 164 147 */ 165 148 void_stack_iterator* void_stack_iterator_new(const void_stack* stack); 166 149 167 150 168 /* void_stack_iterator_free(): 169 * Frees a void_stack_iterator. Does not affect the void_stack referenced 170 * by the iterator. 151 /** Frees a void_stack_iterator. 171 152 * 172 * Arguments: 173 * iter -- the void_stack_iterator to be free()d. 153 * Does not affect the void_stack referenced by the iterator. 154 * 155 * @param iter the void_stack_iterator to be free()d. 174 156 */ 175 157 void void_stack_iterator_free(void_stack_iterator* iter); 176 158 177 159 178 /* void_stack_iterator_next(): 179 * Returns a pointer to the the next element in the stack. Iterates over 180 * elements starting in order from the oldest element (bottom of the stack). 160 /** Returns a pointer to the the next element in the stack. 181 161 * 182 * Arguments: 183 * iter -- the void_stack_iterator used to lookup the next element. 162 * Iterates over elements starting in order from the oldest element (bottom of the stack). 184 163 * 185 * Returns: 186 * a pointer to the next element. 164 * @param iter the void_stack_iterator used to lookup the next element. 165 * 166 * @return a pointer to the next element. 187 167 */ 188 168 const void* void_stack_iterator_next(void_stack_iterator* iter); -
trunk/include/winsec.h
r168 r169 1 /** @file 2 * This file contains refactored Samba code used to interpret Windows 3 * Security Descriptors. See: 4 * http://websvn.samba.org/cgi-bin/viewcvs.cgi/trunk/source/ 5 * 6 * Revisions have been made based on information provided by Microsoft 7 * at: 8 * http://msdn.microsoft.com/en-us/library/cc230366(PROT.10).aspx 9 * 10 * Copyright (C) 2005,2009 Timothy D. Morgan 1 /* 2 * Copyright (C) 2005,2009-2010 Timothy D. Morgan 11 3 * Copyright (C) 1992-2005 Samba development team 12 4 * … … 27 19 */ 28 20 21 /** 22 * @file 23 * 24 * A small library for interpreting Windows Security Descriptors. 25 * This library was originally based on Samba source from: 26 * http://websvn.samba.org/cgi-bin/viewcvs.cgi/trunk/source/ 27 * 28 * The library has been heavily rewritten and improved based on information 29 * provided by Microsoft at: 30 * http://msdn.microsoft.com/en-us/library/cc230366%28PROT.10%29.aspx 31 */ 32 29 33 #ifndef _WINSEC_H 30 34 #define _WINSEC_H … … 70 74 71 75 76 /** XXX: document this. */ 72 77 typedef struct _winsec_uuid 73 78 { 74 uint32_t time_low; 75 uint16_t time_mid; 76 uint16_t time_hi_and_version; 77 uint8_t clock_seq[2]; 78 uint8_t node[6]; 79 /** XXX: document this. */ 80 uint32_t time_low; 81 82 /** XXX: document this. */ 83 uint16_t time_mid; 84 85 /** XXX: document this. */ 86 uint16_t time_hi_and_version; 87 88 /** XXX: document this. */ 89 uint8_t clock_seq[2]; 90 91 /** XXX: document this. */ 92 uint8_t node[6]; 79 93 } WINSEC_UUID; 80 94 81 95 96 /** XXX: document this. */ 82 97 typedef struct _winsec_sid 83 98 { 84 uint8_t sid_rev_num; /* SID revision number */ 85 uint8_t num_auths; /* Number of sub-authorities */ 86 uint8_t id_auth[6]; /* Identifier Authority */ 87 /* 88 * Pointer to sub-authorities. 89 * 99 /** SID revision number */ 100 uint8_t sid_rev_num; 101 102 /** Number of sub-authorities */ 103 uint8_t num_auths; 104 105 /** Identifier Authority */ 106 uint8_t id_auth[6]; 107 108 /** Pointer to sub-authorities. 109 * 90 110 * @note The values in these uint32_t's are in *native* byteorder, not 91 111 * neccessarily little-endian...... JRA. 92 112 */ 93 /* XXX: Make this dynamically allocated? */ 94 uint32_t sub_auths[WINSEC_MAX_SUBAUTHS]; 113 uint32_t sub_auths[WINSEC_MAX_SUBAUTHS]; /* XXX: Make this dynamically allocated? */ 95 114 } WINSEC_DOM_SID; 96 115 97 116 117 /** XXX: document this. */ 98 118 typedef struct _winsec_ace 99 119 { 100 uint8_t type; /* xxxx_xxxx_ACE_TYPE - e.g allowed / denied etc */ 101 uint8_t flags; /* xxxx_INHERIT_xxxx - e.g OBJECT_INHERIT_ACE */ 102 uint16_t size; 103 uint32_t access_mask; 104 105 /* this stuff may be present when type is XXXX_TYPE_XXXX_OBJECT */ 106 uint32_t obj_flags; /* xxxx_ACE_OBJECT_xxxx e.g present/inherited present etc */ 107 WINSEC_UUID* obj_guid; /* object GUID */ 108 WINSEC_UUID* inh_guid; /* inherited object GUID */ 109 /* eof object stuff */ 110 111 WINSEC_DOM_SID* trustee; 120 /** xxxx_xxxx_ACE_TYPE - e.g allowed / denied etc */ 121 uint8_t type; 122 123 /** xxxx_INHERIT_xxxx - e.g OBJECT_INHERIT_ACE */ 124 uint8_t flags; 125 126 /** XXX: finish documenting */ 127 uint16_t size; 128 129 /** XXX: finish documenting */ 130 uint32_t access_mask; 131 132 /* This stuff may be present when type is XXXX_TYPE_XXXX_OBJECT */ 133 134 /** xxxx_ACE_OBJECT_xxxx e.g present/inherited present etc */ 135 uint32_t obj_flags; 136 137 /** Object GUID */ 138 WINSEC_UUID* obj_guid; 139 140 /** Inherited object GUID */ 141 WINSEC_UUID* inh_guid; 142 143 /* eof object stuff */ 144 145 /** XXX: finish documenting */ 146 WINSEC_DOM_SID* trustee; 112 147 113 148 } WINSEC_ACE; 114 149 150 151 /** XXX: document this. */ 115 152 typedef struct _winsec_acl 116 153 { 117 uint16_t revision; /* 0x0003 */ 118 uint16_t size; /* size in bytes of the entire ACL structure */ 119 uint32_t num_aces; /* number of Access Control Entries */ 120 121 WINSEC_ACE** aces; 154 /** 0x0003 */ 155 uint16_t revision; 156 157 /** Size, in bytes, of the entire ACL structure */ 158 uint16_t size; 159 160 /** Number of Access Control Entries */ 161 uint32_t num_aces; 162 163 /** XXX: document this. */ 164 WINSEC_ACE** aces; 122 165 123 166 } WINSEC_ACL; 124 167 168 169 /** XXX: document this. */ 125 170 typedef struct _winsec_desc 126 171 { 127 uint8_t revision; /* 0x01 */ 128 uint8_t sbz1; /* "If the Control field has the RM flag set, 129 * then this field contains the resource 130 * manager (RM) control value. ... Otherwise, 131 * this field is reserved and MUST be set to 132 * zero." -- Microsoft. See reference above. 133 */ 134 uint16_t control; /* WINSEC_DESC_* flags */ 135 136 uint32_t off_owner_sid; /* offset to owner sid */ 137 uint32_t off_grp_sid ; /* offset to group sid */ 138 uint32_t off_sacl ; /* offset to system list of permissions */ 139 uint32_t off_dacl ; /* offset to list of permissions */ 140 141 WINSEC_DOM_SID* owner_sid; 142 WINSEC_DOM_SID* grp_sid; 143 WINSEC_ACL* sacl; /* system ACL */ 144 WINSEC_ACL* dacl; /* user ACL */ 172 /** 0x01 */ 173 uint8_t revision; 174 175 /** XXX: better explain this 176 * 177 * "If the Control field has the RM flag set, then this field contains the 178 * resource manager (RM) control value. ... Otherwise, this field is reserved 179 * and MUST be set to zero." -- Microsoft. 180 * See: 181 * http://msdn.microsoft.com/en-us/library/cc230371%28PROT.10%29.aspx 182 */ 183 uint8_t sbz1; 184 185 /** WINSEC_DESC_* flags */ 186 uint16_t control; 187 188 /** Offset to owner sid */ 189 uint32_t off_owner_sid; 190 191 /** Offset to group sid */ 192 uint32_t off_grp_sid; 193 194 /** Offset to system list of permissions */ 195 uint32_t off_sacl; 196 197 /** Offset to list of permissions */ 198 uint32_t off_dacl; 199 200 /** XXX: document this */ 201 WINSEC_DOM_SID* owner_sid; 202 203 /** XXX: document this */ 204 WINSEC_DOM_SID* grp_sid; 205 206 /** System ACL */ 207 WINSEC_ACL* sacl; 208 209 /** User ACL */ 210 WINSEC_ACL* dacl; 145 211 146 212 } WINSEC_DESC; 147 213 214 215 /** 216 * 217 * XXX: finish documenting 218 */ 148 219 WINSEC_DESC* winsec_parse_descriptor(const uint8_t* buf, uint32_t buf_len); 220 221 222 /** 223 * 224 * XXX: finish documenting 225 */ 149 226 void winsec_free_descriptor(WINSEC_DESC* desc); 150 227 228 /** 229 * 230 * XXX: finish documenting 231 */ 151 232 WINSEC_DESC* winsec_parse_desc(void* talloc_ctx, 152 233 const uint8_t* buf, uint32_t buf_len); 234 235 /** 236 * 237 * XXX: finish documenting 238 */ 153 239 WINSEC_ACL* winsec_parse_acl(void* talloc_ctx, 154 240 const uint8_t* buf, uint32_t buf_len); 241 242 /** 243 * 244 * XXX: finish documenting 245 */ 155 246 WINSEC_ACE* winsec_parse_ace(void* talloc_ctx, 156 247 const uint8_t* buf, uint32_t buf_len); 248 249 /** 250 * 251 * XXX: finish documenting 252 */ 157 253 WINSEC_DOM_SID* winsec_parse_dom_sid(void* talloc_ctx, 158 254 const uint8_t* buf, uint32_t buf_len); 255 256 /** 257 * 258 * XXX: finish documenting 259 */ 159 260 WINSEC_UUID* winsec_parse_uuid(void* talloc_ctx, 160 261 const uint8_t* buf, uint32_t buf_len); 161 262 263 264 /** 265 * 266 * XXX: finish documenting 267 */ 162 268 size_t winsec_sid_size(const WINSEC_DOM_SID* sid); 269 270 /** 271 * 272 * XXX: finish documenting 273 */ 163 274 int winsec_sid_compare_auth(const WINSEC_DOM_SID* sid1, const WINSEC_DOM_SID* sid2); 275 276 /** 277 * 278 * XXX: finish documenting 279 */ 164 280 int winsec_sid_compare(const WINSEC_DOM_SID* sid1, const WINSEC_DOM_SID* sid2); 281 282 /** 283 * 284 * XXX: finish documenting 285 */ 165 286 bool winsec_sid_equal(const WINSEC_DOM_SID* sid1, const WINSEC_DOM_SID* sid2); 287 288 /** 289 * 290 * XXX: finish documenting 291 */ 166 292 bool winsec_desc_equal(WINSEC_DESC* s1, WINSEC_DESC* s2); 293 294 /** 295 * 296 * XXX: finish documenting 297 */ 167 298 bool winsec_acl_equal(WINSEC_ACL* s1, WINSEC_ACL* s2); 299 300 /** 301 * 302 * XXX: finish documenting 303 */ 168 304 bool winsec_ace_equal(WINSEC_ACE* s1, WINSEC_ACE* s2); 305 306 /** 307 * 308 * XXX: finish documenting 309 */ 169 310 bool winsec_ace_object(uint8_t type); 170 311
Note: See TracChangeset
for help on using the changeset viewer.