Changeset 168 for trunk/include
- Timestamp:
- 03/02/10 19:08:42 (15 years ago)
- Location:
- trunk/include
- Files:
-
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/byteorder.h
r111 r168 1 /* 1 /* 2 2 * Branched from Samba project Subversion repository, version #2: 3 3 * http://websvn.samba.org/cgi-bin/viewcvs.cgi/trunk/source/include/byteorder.h … … 28 28 #define _BYTEORDER_H 29 29 30 /* 31 This file implements macros for machine independent short and 32 int manipulation 30 /** 31 * @file 32 * 33 * This file implements macros for machine independent short and 34 * int manipulation 35 36 @verbatim 33 37 34 38 Here is a description of this file that I emailed to the samba list once: … … 54 58 Ok, now to the macros themselves. I'll take a simple example, say we 55 59 want to extract a 2 byte integer from a SMB packet and put it into a 56 type called uint16 that is in the local machines byte order, and you57 want to do it with only the assumption that uint16 is _at_least_ 1660 type called uint16_t that is in the local machines byte order, and you 61 want to do it with only the assumption that uint16_t is _at_least_ 16 58 62 bits long (this last condition is very important for architectures 59 63 that don't have any int types that are 2 bytes long) … … 65 69 #define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8) 66 70 67 then to extract a uint16 value at offset 25 in a buffer you do this:71 then to extract a uint16_t value at offset 25 in a buffer you do this: 68 72 69 73 char *buffer = foo_bar(); 70 uint16 xx = SVAL(buffer,25);74 uint16_t xx = SVAL(buffer,25); 71 75 72 76 We are using the byteoder independence of the ANSI C bitshifts to do … … 98 102 it also defines lots of intermediate macros, just ignore those :-) 99 103 104 @endverbatim 105 100 106 */ 101 107 … … 124 130 #define SSVALX(buf,pos,val) (CVAL_NC(buf,pos)=(unsigned char)((val)&0xFF),CVAL_NC(buf,pos+1)=(unsigned char)((val)>>8)) 125 131 #define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16)) 126 #define SVALS(buf,pos) ((int16 )SVAL(buf,pos))127 #define IVALS(buf,pos) ((int32 )IVAL(buf,pos))128 #define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16 )(val)))129 #define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32 )(val)))130 #define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16 )(val)))131 #define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32 )(val)))132 #define SVALS(buf,pos) ((int16_t)SVAL(buf,pos)) 133 #define IVALS(buf,pos) ((int32_t)IVAL(buf,pos)) 134 #define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16_t)(val))) 135 #define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32_t)(val))) 136 #define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16_t)(val))) 137 #define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32_t)(val))) 132 138 133 139 #else /* CAREFUL_ALIGNMENT */ … … 136 142 alignment errors */ 137 143 /* 138 WARNING: This section is dependent on the length of int16 and int32144 WARNING: This section is dependent on the length of int16_t and int32_t 139 145 being correct 140 146 */ 141 147 142 148 /* get single value from an SMB buffer */ 143 #define SVAL(buf,pos) (*(const uint16 *)((const char *)(buf) + (pos)))144 #define SVAL_NC(buf,pos) (*(uint16 *)((char *)(buf) + (pos))) /* Non const version of above. */145 #define IVAL(buf,pos) (*(const uint32 *)((const char *)(buf) + (pos)))146 #define IVAL_NC(buf,pos) (*(uint32 *)((char *)(buf) + (pos))) /* Non const version of above. */147 #define SVALS(buf,pos) (*(const int16 *)((const char *)(buf) + (pos)))148 #define SVALS_NC(buf,pos) (*(int16 *)((char *)(buf) + (pos))) /* Non const version of above. */149 #define IVALS(buf,pos) (*(const int32 *)((const char *)(buf) + (pos)))150 #define IVALS_NC(buf,pos) (*(int32 *)((char *)(buf) + (pos))) /* Non const version of above. */149 #define SVAL(buf,pos) (*(const uint16_t *)((const char *)(buf) + (pos))) 150 #define SVAL_NC(buf,pos) (*(uint16_t *)((char *)(buf) + (pos))) /* Non const version of above. */ 151 #define IVAL(buf,pos) (*(const uint32_t *)((const char *)(buf) + (pos))) 152 #define IVAL_NC(buf,pos) (*(uint32_t *)((char *)(buf) + (pos))) /* Non const version of above. */ 153 #define SVALS(buf,pos) (*(const int16_t *)((const char *)(buf) + (pos))) 154 #define SVALS_NC(buf,pos) (*(int16_t *)((char *)(buf) + (pos))) /* Non const version of above. */ 155 #define IVALS(buf,pos) (*(const int32_t *)((const char *)(buf) + (pos))) 156 #define IVALS_NC(buf,pos) (*(int32_t *)((char *)(buf) + (pos))) /* Non const version of above. */ 151 157 152 158 /* store single value in an SMB buffer */ 153 #define SSVAL(buf,pos,val) SVAL_NC(buf,pos)=((uint16 )(val))154 #define SIVAL(buf,pos,val) IVAL_NC(buf,pos)=((uint32 )(val))155 #define SSVALS(buf,pos,val) SVALS_NC(buf,pos)=((int16 )(val))156 #define SIVALS(buf,pos,val) IVALS_NC(buf,pos)=((int32 )(val))159 #define SSVAL(buf,pos,val) SVAL_NC(buf,pos)=((uint16_t)(val)) 160 #define SIVAL(buf,pos,val) IVAL_NC(buf,pos)=((uint32_t)(val)) 161 #define SSVALS(buf,pos,val) SVALS_NC(buf,pos)=((int16_t)(val)) 162 #define SIVALS(buf,pos,val) IVALS_NC(buf,pos)=((int32_t)(val)) 157 163 158 164 #endif /* CAREFUL_ALIGNMENT */ -
trunk/include/lru_cache.h
r147 r168 1 /* 1 /** 2 * @file 3 * 2 4 * Copyright (C) 2008-2009 Timothy D. Morgan 3 5 * -
trunk/include/range_list.h
r148 r168 1 /* 1 /** 2 * @file 3 * 2 4 * Copyright (C) 2008-2009 Timothy D. Morgan 3 5 * -
trunk/include/regfi.h
r167 r168 1 /* 1 /** @file 2 * Windows NT (and later) registry parsing library 3 * 2 4 * Branched from Samba project Subversion repository, version #6903: 3 5 * http://viewcvs.samba.org/cgi-bin/viewcvs.cgi/trunk/source/include/regfio.h?rev=6903&view=auto 4 6 * 5 * Windows NT (and later) registry parsing library 6 * 7 * Copyright (C) 2005-2009 Timothy D. Morgan 7 * Copyright (C) 2005-2010 Timothy D. Morgan 8 8 * Copyright (C) 2005 Gerald (Jerry) Carter 9 9 * … … 29 29 * Thanks Nigel! 30 30 ***********************************************************/ 31 32 /** 33 * @mainpage Home 34 * 35 * See \ref regfiTopLayer 36 */ 31 37 32 38 #ifndef _REGFI_H … … 47 53 #include <iconv.h> 48 54 55 #include "byteorder.h" 49 56 #include "talloc.h" 50 #include "smb_deps.h"51 57 #include "winsec.h" 52 58 #include "void_stack.h" … … 61 67 #define REGFI_MSG_ERROR 0x0010 62 68 63 typedef uint8 REGFI_ENCODING;69 typedef uint8_t REGFI_ENCODING; 64 70 /* regfi library supported character encodings */ 65 71 #define REGFI_ENCODING_ASCII 0 … … 210 216 | REGFI_NK_FLAG_UNKNOWN3) 211 217 218 219 #define CHAR_BIT 8 220 #define TIME_T_MIN ((time_t)0 < (time_t) -1 ? (time_t) 0 \ 221 : ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1)) 222 #define TIME_T_MAX (~ (time_t) 0 - TIME_T_MIN) 223 #define TIME_FIXUP_CONSTANT (369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60)) 224 225 typedef struct _regfi_nttime 226 { 227 uint32_t low; 228 uint32_t high; 229 } REGFI_NTTIME; 230 231 212 232 /* HBIN block */ 213 233 typedef struct _regfi_hbin 214 234 { 215 uint32 file_off; /* my offset in the registry file */216 uint32 ref_count; /* how many active records are pointing to this235 uint32_t file_off; /* my offset in the registry file */ 236 uint32_t ref_count; /* how many active records are pointing to this 217 237 * block (not used currently) 218 238 */ 219 239 220 uint32 first_hbin_off; /* offset from first hbin block */221 uint32 block_size; /* block size of this block240 uint32_t first_hbin_off; /* offset from first hbin block */ 241 uint32_t block_size; /* block size of this block 222 242 * Should be a multiple of 4096 (0x1000) 223 243 */ 224 uint32 next_block; /* relative offset to next block.244 uint32_t next_block; /* relative offset to next block. 225 245 * NOTE: This value may be unreliable! 226 246 */ 227 247 228 uint8 magic[REGFI_HBIN_MAGIC_SIZE]; /* "hbin" */248 uint8_t magic[REGFI_HBIN_MAGIC_SIZE]; /* "hbin" */ 229 249 } REGFI_HBIN; 230 250 … … 236 256 * depending on this list's type. 237 257 */ 238 uint32 offset;239 240 uint32 hash;258 uint32_t offset; 259 260 uint32_t hash; 241 261 } REGFI_SUBKEY_LIST_ELEM; 242 262 … … 245 265 { 246 266 /* Real offset of this record's cell in the file */ 247 uint32 offset;248 249 uint32 cell_size;267 uint32_t offset; 268 269 uint32_t cell_size; 250 270 251 271 /* Number of immediate children */ 252 uint32 num_children;272 uint32_t num_children; 253 273 254 274 /* Total number of keys referenced by this list and it's children */ 255 uint32 num_keys;275 uint32_t num_keys; 256 276 257 277 REGFI_SUBKEY_LIST_ELEM* elements; 258 uint8 magic[REGFI_CELL_MAGIC_SIZE];278 uint8_t magic[REGFI_CELL_MAGIC_SIZE]; 259 279 260 280 /* Set if the magic indicates this subkey list points to child subkey lists */ … … 263 283 264 284 265 typedef uint32 REGFI_VALUE_LIST_ELEM;285 typedef uint32_t REGFI_VALUE_LIST_ELEM; 266 286 typedef struct _regfi_value_list 267 287 { … … 269 289 * May differ from parent key's num_values if there were parsing errors. 270 290 */ 271 uint32 num_values;291 uint32_t num_values; 272 292 273 293 REGFI_VALUE_LIST_ELEM* elements; … … 281 301 282 302 /* Represents raw buffer read from classname cell. */ 283 uint8 * raw;303 uint8_t* raw; 284 304 285 305 /* Length of the raw data. May be shorter than that indicated by parent key.*/ 286 uint16 size;306 uint16_t size; 287 307 } REGFI_CLASSNAME; 288 308 … … 290 310 typedef struct _regfi_data 291 311 { 292 uint32 type;312 uint32_t type; 293 313 294 314 /* Length of the raw data. */ 295 uint32 size;315 uint32_t size; 296 316 297 317 /* This is always present, representing the raw data cell contents. */ 298 uint8 * raw;318 uint8_t* raw; 299 319 300 320 /* Represents the length of the interpreted value. Meaning is type-specific.*/ 301 uint32 interpreted_size;321 uint32_t interpreted_size; 302 322 303 323 /* These items represent interpreted versions of the raw attribute above. … … 307 327 union _regfi_data_interpreted 308 328 { 309 uint8 * none; /* */310 uint8 * string;311 uint8 * expand_string;312 uint8 * binary; /* */313 uint32 dword;314 uint32 dword_be;315 uint8 * link;316 uint8 ** multiple_string;317 uint64 qword;329 uint8_t* none; /* */ 330 uint8_t* string; 331 uint8_t* expand_string; 332 uint8_t* binary; /* */ 333 uint32_t dword; 334 uint32_t dword_be; 335 uint8_t* link; 336 uint8_t** multiple_string; 337 uint64_t qword; 318 338 319 339 /* The following are treated as binary currently, but this may change in 320 340 * the future as the formats become better understood. 321 341 */ 322 uint8 * resource_list;323 uint8 * full_resource_descriptor;324 uint8 * resource_requirements_list;342 uint8_t* resource_list; 343 uint8_t* full_resource_descriptor; 344 uint8_t* resource_requirements_list; 325 345 } interpreted; 326 346 } REGFI_DATA; … … 330 350 typedef struct 331 351 { 332 uint32 offset; /* Real offset of this record's cell in the file */333 uint32 cell_size; /* ((start_offset - end_offset) & 0xfffffff8) */352 uint32_t offset; /* Real offset of this record's cell in the file */ 353 uint32_t cell_size; /* ((start_offset - end_offset) & 0xfffffff8) */ 334 354 335 355 REGFI_DATA* data; /* XXX: deprecated */ 336 356 337 357 char* valuename; 338 uint8 * valuename_raw;339 uint16 name_length;340 uint32 hbin_off; /* offset from beginning of this hbin block */358 uint8_t* valuename_raw; 359 uint16_t name_length; 360 uint32_t hbin_off; /* offset from beginning of this hbin block */ 341 361 342 uint32 data_size; /* As reported in the VK record. May be different than362 uint32_t data_size; /* As reported in the VK record. May be different than 343 363 * That obtained while parsing the data cell itself. */ 344 uint32 data_off; /* Offset of data cell (virtual) */345 uint32 type;346 uint8 magic[REGFI_CELL_MAGIC_SIZE];347 uint16 flags;348 uint16 unknown1;364 uint32_t data_off; /* Offset of data cell (virtual) */ 365 uint32_t type; 366 uint8_t magic[REGFI_CELL_MAGIC_SIZE]; 367 uint16_t flags; 368 uint16_t unknown1; 349 369 bool data_in_offset; 350 370 } REGFI_VK_REC; … … 356 376 typedef struct _regfi_sk_rec 357 377 { 358 uint32 offset; /* Real file offset of this record */359 uint32 cell_size; /* ((start_offset - end_offset) & 0xfffffff8) */378 uint32_t offset; /* Real file offset of this record */ 379 uint32_t cell_size; /* ((start_offset - end_offset) & 0xfffffff8) */ 360 380 361 381 WINSEC_DESC* sec_desc; 362 uint32 hbin_off; /* offset from beginning of this hbin block */382 uint32_t hbin_off; /* offset from beginning of this hbin block */ 363 383 364 uint32 prev_sk_off;365 uint32 next_sk_off;366 uint32 ref_count;367 uint32 desc_size; /* size of security descriptor */368 uint16 unknown_tag;369 uint8 magic[REGFI_CELL_MAGIC_SIZE];384 uint32_t prev_sk_off; 385 uint32_t next_sk_off; 386 uint32_t ref_count; 387 uint32_t desc_size; /* size of security descriptor */ 388 uint16_t unknown_tag; 389 uint8_t magic[REGFI_CELL_MAGIC_SIZE]; 370 390 } REGFI_SK_REC; 371 391 … … 374 394 typedef struct 375 395 { 376 uint32 offset; /* Real offset of this record's cell in the file */377 uint32 cell_size; /* Actual or estimated length of the cell.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. 378 398 * Always in multiples of 8. 379 399 */ … … 384 404 385 405 /* header information */ 386 uint16 flags;387 uint8 magic[REGFI_CELL_MAGIC_SIZE];388 NTTIME mtime;389 uint16 name_length;390 uint16 classname_length;406 uint16_t flags; 407 uint8_t magic[REGFI_CELL_MAGIC_SIZE]; 408 REGFI_NTTIME mtime; 409 uint16_t name_length; 410 uint16_t classname_length; 391 411 char* keyname; 392 uint8 * keyname_raw;393 uint32 parent_off; /* pointer to parent key */394 uint32 classname_off;412 uint8_t* keyname_raw; 413 uint32_t parent_off; /* pointer to parent key */ 414 uint32_t classname_off; 395 415 396 416 /* max lengths */ 397 uint32 max_bytes_subkeyname; /* max subkey name * 2 */398 uint32 max_bytes_subkeyclassname; /* max subkey classname length (as if) */399 uint32 max_bytes_valuename; /* max valuename * 2 */400 uint32 max_bytes_value; /* max value data size */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 */ 401 421 402 422 /* unknowns */ 403 uint32 unknown1;404 uint32 unknown2;405 uint32 unknown3;406 uint32 unk_index; /* nigel says run time index ? */423 uint32_t unknown1; 424 uint32_t unknown2; 425 uint32_t unknown3; 426 uint32_t unk_index; /* nigel says run time index ? */ 407 427 408 428 /* children */ 409 uint32 num_subkeys;410 uint32 subkeys_off; /* offset of subkey list that points to NK records */411 uint32 num_values;412 uint32 values_off; /* value lists which point to VK records */413 uint32 sk_off; /* offset to SK record */429 uint32_t num_subkeys; 430 uint32_t subkeys_off; /* offset of subkey list that points to NK records */ 431 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 */ 414 434 } REGFI_NK_REC; 415 435 … … 425 445 426 446 /* For sanity checking (not part of the registry header) */ 427 uint32 file_length;447 uint32_t file_length; 428 448 429 449 /* Metadata about hbins */ … … 437 457 438 458 /* Mask for error message types that will be stored. */ 439 uint16 msg_mask;459 uint16_t msg_mask; 440 460 441 461 442 462 /* Data parsed from file header */ 443 463 /********************************/ 444 uint8 magic[REGFI_REGF_MAGIC_SIZE];/* "regf" */464 uint8_t magic[REGFI_REGF_MAGIC_SIZE];/* "regf" */ 445 465 446 466 /* These sequence numbers should match if 447 467 * the hive was properly synced to disk. 448 468 */ 449 uint32 sequence1;450 uint32 sequence2;451 452 NTTIME mtime;453 uint32 major_version; /* Set to 1 in all known hives */454 uint32 minor_version; /* Set to 3 or 5 in all known hives */455 uint32 type; /* XXX: Unverified. Set to 0 in all known hives */456 uint32 format; /* XXX: Unverified. Set to 1 in all known hives */457 458 uint32 root_cell; /* Offset to root cell in the first (or any?) hbin block */459 uint32 last_block; /* Offset to last hbin block in file */460 461 uint32 cluster; /* XXX: Unverified. Set to 1 in all known hives */469 uint32_t sequence1; 470 uint32_t sequence2; 471 472 REGFI_NTTIME mtime; 473 uint32_t major_version; /* Set to 1 in all known hives */ 474 uint32_t minor_version; /* Set to 3 or 5 in all known hives */ 475 uint32_t type; /* XXX: Unverified. Set to 0 in all known hives */ 476 uint32_t format; /* XXX: Unverified. Set to 1 in all known hives */ 477 478 uint32_t root_cell; /* Offset to root cell in the first (or any?) hbin block */ 479 uint32_t last_block; /* Offset to last hbin block in file */ 480 481 uint32_t cluster; /* XXX: Unverified. Set to 1 in all known hives */ 462 482 463 483 /* Matches hive's base file name. Stored in UTF-16LE */ 464 uint8 file_name[REGFI_REGF_NAME_SIZE];484 uint8_t file_name[REGFI_REGF_NAME_SIZE]; 465 485 466 486 WINSEC_UUID* rm_id; /* XXX: Unverified. */ 467 487 WINSEC_UUID* log_id; /* XXX: Unverified. */ 468 488 WINSEC_UUID* tm_id; /* XXX: Unverified. */ 469 uint32 flags; /* XXX: Unverified. */470 uint32 guid_signature; /* XXX: Unverified. */471 472 uint32 checksum; /* Stored checksum from file */473 uint32 computed_checksum; /* Our own calculation of the checksum.489 uint32_t flags; /* XXX: Unverified. */ 490 uint32_t guid_signature; /* XXX: Unverified. */ 491 492 uint32_t checksum; /* Stored checksum from file */ 493 uint32_t computed_checksum; /* Our own calculation of the checksum. 474 494 * (XOR of bytes 0x0000 - 0x01FB) */ 475 495 … … 477 497 WINSEC_UUID* thaw_rm_id; /* XXX: Unverified. */ 478 498 WINSEC_UUID* thaw_log_id; /* XXX: Unverified. */ 479 uint32 boot_type; /* XXX: Unverified. */480 uint32 boot_recover; /* XXX: Unverified. */499 uint32_t boot_type; /* XXX: Unverified. */ 500 uint32_t boot_recover; /* XXX: Unverified. */ 481 501 482 502 /* This seems to include random junk. Possibly unsanitized memory left over 483 503 * from when header block was written. For instance, chunks of nk records 484 504 * can be found, though often it's all 0s. */ 485 uint8 reserved1[REGFI_REGF_RESERVED1_SIZE];505 uint8_t reserved1[REGFI_REGF_RESERVED1_SIZE]; 486 506 487 507 /* This is likely reserved and unusued currently. (Should be all 0s.) 488 508 * Included here for easier access in looking for hidden data 489 509 * or doing research. */ 490 uint8 reserved2[REGFI_REGF_RESERVED2_SIZE];510 uint8_t reserved2[REGFI_REGF_RESERVED2_SIZE]; 491 511 492 512 } REGFI_FILE; … … 499 519 REGFI_NK_REC* cur_key; 500 520 REGFI_ENCODING string_encoding; 501 uint32 cur_subkey;502 uint32 cur_value;521 uint32_t cur_subkey; 522 uint32_t cur_value; 503 523 } REGFI_ITERATOR; 504 524 … … 507 527 { 508 528 REGFI_NK_REC* nk; 509 uint32 cur_subkey;529 uint32_t cur_subkey; 510 530 /* We could store a cur_value here as well, but didn't see 511 531 * the use in it right now. … … 516 536 typedef struct _regfi_buffer 517 537 { 518 uint8 * buf;538 uint8_t* buf; 519 539 uint32_t len; 520 540 } REGFI_BUFFER; 521 541 522 542 523 524 525 543 /******************************************************************************/ 526 /* Main iterator API */ 544 /** 545 * @defgroup regfiBase Base Functions: Usable with Any Layer 546 * 547 * These functions don't fit particularly well in any of the other layers or 548 * are intended for use with any of the API layers. 549 */ 527 550 /******************************************************************************/ 528 551 529 /* regfi_open: Attempts to open a registry hive and allocate related data 530 * structures. 531 * 532 * Arguments: 533 * filename -- A string containing the relative or absolute path of the 552 553 /** Attempts to open a registry hive and allocate related data structures. 554 * 555 * @param filename A string containing the relative or absolute path of the 534 556 * registry hive to be opened. 535 557 * 536 * Returns: 537 * A reference to a newly allocated REGFI_FILE structure, if successful. 538 * NULL on error. 558 * @return A reference to a newly allocated REGFI_FILE structure, 559 * if successful; NULL on error. 560 * 561 * @ingroup regfiBase 539 562 */ 540 563 REGFI_FILE* regfi_open(const char* filename); 541 564 542 565 543 /* regfi_alloc:Parses file headers of an already open registry hive file and544 * 545 * 546 * Arguments:547 * fd -- A file descriptor of an already open file. Must be seekable.548 * 549 * Returns:550 * A reference to a newly allocated REGFI_FILE structure, if successful.551 * NULL on error.566 /** Parses file headers of an already open registry hive file and 567 * allocates related structures for further parsing. 568 * 569 * @param fd A file descriptor of an already open file. Must be seekable. 570 * 571 * @return A reference to a newly allocated REGFI_FILE structure, if successful; 572 * NULL on error. 573 * 574 * @ingroup regfiBase 552 575 */ 553 576 REGFI_FILE* regfi_alloc(int fd); 554 577 555 578 556 /* regfi_close:Closes and frees an open registry hive.557 * 558 * Arguments:559 * file -- The registry structure to close.560 * 561 * Returns:562 * 0 on success, -1 on failure with errno set.563 * errno codes are similar to those of close(2).579 /** Closes and frees an open registry hive. 580 * 581 * @param file The registry structure to close. 582 * 583 * @return 0 on success, -1 on failure with errno set. 584 * errno codes are similar to those of close(2). 585 * 586 * @ingroup regfiBase 564 587 */ 565 588 int regfi_close(REGFI_FILE* file); 566 589 567 590 568 /* regfi_free: Frees a hive's data structures without closing the underlying569 * file.570 * 571 * Arguments:572 * file -- The registry structure to free.591 /** Frees a hive's data structures without closing the underlying file. 592 * 593 * @param file The registry structure to free. 594 * 595 * @ingroup regfiBase 573 596 */ 574 597 void regfi_free(REGFI_FILE* file); 575 598 576 599 577 /* regfi_get_messages: Get errors, warnings, and/or verbose information578 * relating to processing ofthe given registry file.579 * 580 * Arguments:581 * file -- the structure for the registry file582 * 583 * Returns:584 * A newly allocated char* which must be free()d by the caller.600 /** Get errors, warnings, and/or verbose information relating to processing of 601 * the given registry file. 602 * 603 * @param file the structure for the registry file 604 * 605 * @return A newly allocated char* which must be free()d by the caller. 606 * 607 * @ingroup regfiBase 585 608 */ 586 609 char* regfi_get_messages(REGFI_FILE* file); 587 610 588 611 589 /* regfi_set_message_mask: Set the verbosity level of errors and warnings 590 * generated by the library 591 * (as accessible via regfi_get_messages). 592 * 593 * Arguments: 594 * file -- the structure for the registry file 595 * mask -- an integer representing the types of messages desired. 612 /** Set the verbosity level of errors and warnings generated by the library 613 * (as accessible via regfi_get_messages). 614 * 615 * This may be called at any time and will take effect immediately. 616 * 617 * @param file the structure for the registry file 618 * 619 * @param mask an integer representing the types of messages desired. 596 620 * Acceptable values are created through bitwise ORs of 597 621 * REGFI_MSG_* values. For instance, if only errors and … … 606 630 * will prevent message accumulation. 607 631 * 608 * This may be called at any time and will take effect immediately. 609 */ 610 void regfi_set_message_mask(REGFI_FILE* file, uint16 mask); 611 612 613 /* regfi_iterator_new: Creates a new iterator for the provided registry file. 614 * 615 * Arguments: 616 * file -- The opened registry file the iterator should be 617 * created for. 618 * output_encoding -- Character encoding that strings should be returned in. 619 * Only supply the REGFI_ENCODING_* constants, as others 620 * will be rejected. 621 * The following values are currently accepted: 622 * REGFI_ENCODING_DEFAULT (currently REGFI_ENCODING_ASCII) 623 * REGFI_ENCODING_ASCII 624 * REGFI_ENCODING_UTF8 625 * 626 * Returns: 627 * A newly allocated REGFI_ITERATOR. Must be free()d with regfi_iterator_free. 632 * @ingroup regfiBase 633 */ 634 void regfi_set_message_mask(REGFI_FILE* file, uint16_t mask); 635 636 637 /* Dispose of previously parsed records */ 638 639 /** Frees a key structure previously returned by one of the API functions 640 * 641 * XXX: finish documenting 642 * 643 * @ingroup regfiBase 644 */ 645 void regfi_free_key(REGFI_NK_REC* nk); 646 647 648 /** Frees a value structure previously returned by one of the API functions 649 * 650 * XXX: finish documenting 651 * 652 * @ingroup regfiBase 653 */ 654 void regfi_free_value(REGFI_VK_REC* vk); 655 656 657 658 /******************************************************************************/ 659 /** 660 * @defgroup regfiTopLayer Top Layer: Primary regfi Library Interface 661 * 662 * This top layer of API functions provides an iterator interface which makes 663 * traversing registry data structures easy in both single-threaded and 664 * multi-threaded scenarios. 665 */ 666 /******************************************************************************/ 667 668 /** Creates a new iterator for the provided registry file. 669 * 670 * @param file The opened registry file the iterator should be created for. 671 * 672 * @param output_encoding Character encoding that strings should be returned in. 673 * Only supply the REGFI_ENCODING_* constants, as others 674 * will be rejected. 675 * The following values are currently accepted: 676 * REGFI_ENCODING_DEFAULT (currently REGFI_ENCODING_ASCII) 677 * REGFI_ENCODING_ASCII 678 * REGFI_ENCODING_UTF8 679 * 680 * @return A newly allocated REGFI_ITERATOR. 681 * Must be free()d with regfi_iterator_free. 682 * 683 * @ingroup regfiTopLayer 628 684 */ 629 685 REGFI_ITERATOR* regfi_iterator_new(REGFI_FILE* file, … … 631 687 632 688 633 /* regfi_iterator_free: Frees a registry file iterator previously created by 634 * regfi_iterator_new. 689 /** Frees a registry file iterator previously created by regfi_iterator_new. 635 690 * 636 691 * This does not affect the underlying registry file's allocation status. 637 692 * 638 * Arguments: 639 * file -- the iterator to be freed 693 * @param i the iterator to be freed 694 * 695 * @ingroup regfiTopLayer 640 696 */ 641 697 void regfi_iterator_free(REGFI_ITERATOR* i); 642 698 643 699 644 /* regfi_iterator_down: Traverse deeper into the registry tree at the645 * current subkey.646 * 647 * Arguments:648 * i -- the iterator649 * 650 * Returns:651 * true on success, false on failure. Note that subkey and value indexes652 * are preserved. That is, if a regfi_iterator_up call occurs later653 * (reversing the effect of this call) then the subkey and value referenced654 * prior to the regfi_iterator_down call will still be referenced. This655 * makes depth-first iteration particularly easy.700 /** Traverse deeper into the registry tree at the current subkey. 701 * 702 * @param i the iterator 703 * 704 * @return true on success, false on failure. 705 * Note that subkey and value indexes are preserved. That is, if a 706 * regfi_iterator_up call occurs later (reversing the effect of this 707 * call) then the subkey and value referenced prior to the 708 * regfi_iterator_down call will still be referenced. This makes 709 * depth-first iteration particularly easy. 710 * 711 * @ingroup regfiTopLayer 656 712 */ 657 713 bool regfi_iterator_down(REGFI_ITERATOR* i); 658 714 659 715 660 /* regfi_iterator_up:Traverse up to the current key's parent key.661 * 662 * Arguments:663 * i -- the iterator664 * 665 * Returns:666 * true on success, false on failure. Any subkey or value state667 * associated with the current key is lost.716 /** Traverse up to the current key's parent key. 717 * 718 * @param i the iterator 719 * 720 * @return true on success, false on failure. Any subkey or value state 721 * associated with the current key is lost. 722 * 723 * @ingroup regfiTopLayer 668 724 */ 669 725 bool regfi_iterator_up(REGFI_ITERATOR* i); 670 726 671 727 672 /* regfi_iterator_to_root:Traverse up to the root key of the hive.673 * 674 * Arguments:675 * i -- the iterator676 * 677 * Returns:678 * true on success, false on failure.728 /** Traverse up to the root key of the hive. 729 * 730 * @param i the iterator 731 * 732 * @return true on success, false on failure. 733 * 734 * @ingroup regfiTopLayer 679 735 */ 680 736 bool regfi_iterator_to_root(REGFI_ITERATOR* i); 681 737 682 738 683 /* regfi_iterator_walk_path: Traverse down multiple levels in the registry hive. 684 * 685 * Arguments: 686 * i -- the iterator 687 * path -- a list of key names representing the path. This list must 688 * contain NUL terminated strings. The list itself is 689 * terminated with a NULL pointer. All path elements must be 690 * keys; value names are not accepted (even as the last 691 * element). 739 /** Traverse down multiple levels in the registry hive. 692 740 * 693 741 * XXX: This currently only accepts ASCII key names. Need to look into 694 742 * accepting other encodings. 695 743 * 696 * Returns: 697 * true on success, false on failure. If any element of path is not found, 698 * false will be returned and the iterator will remain in its original 699 * position. 700 */ 701 bool regfi_iterator_walk_path(REGFI_ITERATOR* i, 702 const char** path); 703 704 705 /* regfi_iterator_cur_key: Returns the currently referenced key. 706 * 707 * Arguments: 708 * i -- the iterator 709 * 710 * Returns: 711 * A read-only key structure for the current key, or NULL on failure. 744 * @param i the iterator 745 * @param path a list of key names representing the path. This list must 746 * contain NUL terminated strings. The list itself is 747 * terminated with a NULL pointer. All path elements must be 748 * keys; value names are not accepted (even as the last 749 * element). 750 * 751 * @return true on success, false on failure. If any element of path is not 752 * found, false will be returned and the iterator will remain 753 * in its original position. 754 * 755 * @ingroup regfiTopLayer 756 */ 757 bool regfi_iterator_walk_path(REGFI_ITERATOR* i, const char** path); 758 759 760 /** Returns the currently referenced key. 761 * 762 * @param i the iterator 763 * 764 * @return A read-only key structure for the current key, or NULL on failure. 765 * 766 * @ingroup regfiTopLayer 712 767 */ 713 768 const REGFI_NK_REC* regfi_iterator_cur_key(REGFI_ITERATOR* i); 714 769 715 770 716 /* regfi_iterator_cur_sk: Returns the SK (security) record referenced by the 717 * current key. 718 * 719 * Arguments: 720 * i -- the iterator 721 * 722 * Returns: 723 * A read-only SK structure, or NULL on failure. 771 /** Returns the SK (security) record referenced by the current key. 772 * 773 * @param i the iterator 774 * 775 * @return A read-only SK structure, or NULL on failure. 776 * 777 * @ingroup regfiTopLayer 724 778 */ 725 779 const REGFI_SK_REC* regfi_iterator_cur_sk(REGFI_ITERATOR* i); 726 780 727 781 728 /* regfi_iterator_first_subkey: Sets the internal subkey index to the first729 * subkey referenced by the current key and returns730 * that key.731 * 732 * Arguments:733 * i -- the iterator734 * 735 * Returns:736 * A newly allocated key structure for the newly referenced first subkey, or737 * NULL on failure. Failure may be due to a lack of any subkeys or other738 * errors. Newly allocated keys must be freed with regfi_free_key.782 /** Sets the internal subkey index to the first subkey referenced by the current 783 * key and returns that key. 784 * 785 * @param i the iterator 786 * 787 * @return A newly allocated key structure for the newly referenced first 788 * subkey, or NULL on failure. Failure may be due to a lack of any 789 * subkeys or other errors. Newly allocated keys must be freed with 790 * regfi_free_key. 791 * 792 * @ingroup regfiTopLayer 739 793 */ 740 794 REGFI_NK_REC* regfi_iterator_first_subkey(REGFI_ITERATOR* i); 741 795 742 796 743 /* regfi_iterator_cur_subkey:Returns the currently indexed subkey.744 * 745 * Arguments:746 * i -- the iterator747 * 748 * Returns:749 * A newly allocated key structure for the currently referenced subkey,750 * or NULL on failure. Newly allocated keys must be freed with751 * regfi_free_key.797 /** Returns the currently indexed subkey. 798 * 799 * @param i the iterator 800 * 801 * @return A newly allocated key structure for the currently referenced subkey, 802 * or NULL on failure. Newly allocated keys must be freed with 803 * regfi_free_key. 804 * 805 * @ingroup regfiTopLayer 752 806 */ 753 807 REGFI_NK_REC* regfi_iterator_cur_subkey(REGFI_ITERATOR* i); 754 808 755 809 756 /* regfi_iterator_next_subkey: Increments the internal subkey index to the next 757 * key in the subkey-list and returns the subkey 758 * for that index. 759 * 760 * Arguments: 761 * i -- the iterator 762 * 763 * Returns: 764 * A newly allocated key structure for the next subkey or NULL on 765 * failure. Newly allocated keys must be freed with 766 * regfi_free_key. 810 /** Increments the internal subkey index to the next key in the subkey-list and 811 * returns the subkey for that index. 812 * 813 * @param i the iterator 814 * 815 * @return A newly allocated key structure for the next subkey or NULL on 816 * failure. Newly allocated keys must be freed with regfi_free_key. 817 * 818 * @ingroup regfiTopLayer 767 819 */ 768 820 REGFI_NK_REC* regfi_iterator_next_subkey(REGFI_ITERATOR* i); 769 821 770 822 771 /* regfi_iterator_find_subkey: Searches for a subkey with a given name under the 772 * current key. 773 * 774 * Arguments: 775 * i -- the iterator 776 * subkey_name -- subkey name to search for 777 * 778 * Returns: 779 * True if such a subkey was found, false otherwise. If a subkey is found, 780 * the current subkey index is set to that subkey. Otherwise, the subkey 781 * index remains at the same location as before the call. 823 /** Searches for a subkey with a given name under the current key. 824 * 825 * @param i the iterator 826 * @param subkey_name subkey name to search for 827 * 828 * @return True if such a subkey was found, false otherwise. If a subkey is 829 * found, the current subkey index is set to that subkey. Otherwise, 830 * the subkey index remains at the same location as before the call. 831 * 832 * @ingroup regfiTopLayer 782 833 */ 783 834 bool regfi_iterator_find_subkey(REGFI_ITERATOR* i, 784 835 const char* subkey_name); 785 836 786 /* regfi_iterator_first_value: Sets the internal value index to the first787 * value referenced by the current key and returns788 * that value.789 * 790 * Arguments:791 * i -- the iterator792 * 793 * Returns:794 * A newly allocated value structure for the newly referenced first value,795 * or NULL on failure. Failure may be due to a lack of any values or other796 * errors. Newly allocated keys must be freed with regfi_free_value.837 /** Sets the internal value index to the first value referenced by the current 838 * key and returns that value. 839 * 840 * @param i the iterator 841 * 842 * @return A newly allocated value structure for the newly referenced first 843 * value, or NULL on failure. Failure may be due to a lack of any 844 * values or other errors. Newly allocated keys must be freed with 845 * regfi_free_value. 846 * 847 * @ingroup regfiTopLayer 797 848 */ 798 849 REGFI_VK_REC* regfi_iterator_first_value(REGFI_ITERATOR* i); 799 850 800 851 801 /* regfi_iterator_cur_value:Returns the currently indexed value.802 * 803 * Arguments:804 * i -- the iterator805 * 806 * Returns:807 * A newly allocated value structure for the currently referenced value,808 * or NULL on failure. Newly allocated values must be freed with809 * regfi_free_value.852 /** Returns the currently indexed value. 853 * 854 * @param i the iterator 855 * 856 * @return A newly allocated value structure for the currently referenced value, 857 * or NULL on failure. Newly allocated values must be freed with 858 * regfi_free_value. 859 * 860 * @ingroup regfiTopLayer 810 861 */ 811 862 REGFI_VK_REC* regfi_iterator_cur_value(REGFI_ITERATOR* i); 812 863 813 864 814 /* regfi_iterator_next_value: Increments the internal value index to the next 815 * value in the value-list and returns the value 816 * for that index. 817 * 818 * Arguments: 819 * i -- the iterator 820 * 821 * Returns: 822 * A newly allocated key structure for the next value or NULL on failure. 823 * Newly allocated keys must be freed with regfi_free_value. 865 /** Increments the internal value index to the next value in the value-list and 866 * returns the value for that index. 867 * 868 * @param i the iterator 869 * 870 * @return A newly allocated key structure for the next value or NULL on 871 * failure. Newly allocated keys must be freed with regfi_free_value. 872 * 873 * @ingroup regfiTopLayer 824 874 */ 825 875 REGFI_VK_REC* regfi_iterator_next_value(REGFI_ITERATOR* i); 826 876 827 877 828 /* regfi_iterator_find_value: Searches for a value with a given name under the 829 * current key. 830 * 831 * Arguments: 832 * i -- the iterator 833 * value_name -- value name to search for 834 * 835 * Returns: 836 * True if such a value was found, false otherwise. If a value is found, 837 * the current value index is set to that value. Otherwise, the value 838 * index remains at the same location as before the call. 878 /** Searches for a value with a given name under the current key. 879 * 880 * @param i the iterator 881 * @param value_name value name to search for 882 * 883 * @return True if such a value was found, false otherwise. If a value is 884 * found, the current value index is set to that value. Otherwise, 885 * the value index remains at the same location as before the call. 886 * 887 * @ingroup regfiTopLayer 839 888 */ 840 889 bool regfi_iterator_find_value(REGFI_ITERATOR* i, 841 890 const char* value_name); 842 891 843 844 /* regfi_iterator_fetch_classname: Retrieves classname for a given key. 845 * 846 * Arguments: 847 * i -- the iterator 848 * key -- the key whose classname is desired 849 * 850 * Returns: 851 * Returns a newly allocated classname structure, or NULL on failure. 852 * Classname structures must be freed with regfi_free_classname. 892 /** Retrieves classname for a given key. 893 * 894 * @param i the iterator 895 * @param key the key whose classname is desired 896 * 897 * @return Returns a newly allocated classname structure, or NULL on failure. 898 * Classname structures must be freed with regfi_free_classname. 899 * 900 * @ingroup regfiTopLayer 853 901 */ 854 902 REGFI_CLASSNAME* regfi_iterator_fetch_classname(REGFI_ITERATOR* i, … … 856 904 857 905 858 /* regfi_iterator_fetch_data:Retrieves data for a given value.859 * 860 * Arguments:861 * i -- the iterator862 * value -- the value whose data is desired863 * 864 * Returns:865 * Returns a newly allocated data structure, or NULL on failure.866 * Data structures must be freed with regfi_free_data.906 /** Retrieves data for a given value. 907 * 908 * @param i the iterator 909 * @param value the value whose data is desired 910 * 911 * @return Returns a newly allocated data structure, or NULL on failure. 912 * Data structures must be freed with regfi_free_data. 913 * 914 * @ingroup regfiTopLayer 867 915 */ 868 916 REGFI_DATA* regfi_iterator_fetch_data(REGFI_ITERATOR* i, … … 870 918 871 919 872 /********************************************************/ 873 /* Middle-layer structure loading, linking, and caching */ 874 /********************************************************/ 875 REGFI_NK_REC* regfi_load_key(REGFI_FILE* file, uint32 offset, 920 921 /******************************************************************************/ 922 /** 923 * @defgroup regfiMiddleLayer Middle Layer: Logical Data Structure Loading 924 */ 925 /******************************************************************************/ 926 927 /** Loads a key at a given file offset along with associated data structures. 928 * 929 * XXX: finish documenting 930 * 931 * @ingroup regfiMiddleLayer 932 */ 933 REGFI_NK_REC* regfi_load_key(REGFI_FILE* file, uint32_t offset, 876 934 REGFI_ENCODING output_encoding, 877 935 bool strict); 878 REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32 offset, 936 937 938 /** Loads a value at a given file offset alng with associated data structures. 939 * 940 * XXX: finish documenting 941 * 942 * @ingroup regfiMiddleLayer 943 */ 944 REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32_t offset, 879 945 REGFI_ENCODING output_encoding, 880 946 bool strict); 881 REGFI_SUBKEY_LIST* regfi_load_subkeylist(REGFI_FILE* file, uint32 offset, 882 uint32 num_keys, uint32 max_size, 947 948 949 /** Loads a logical subkey list in its entirety which may span multiple records. 950 * 951 * XXX: finish documenting 952 * 953 * @ingroup regfiMiddleLayer 954 */ 955 REGFI_SUBKEY_LIST* regfi_load_subkeylist(REGFI_FILE* file, uint32_t offset, 956 uint32_t num_keys, uint32_t max_size, 883 957 bool strict); 884 REGFI_VALUE_LIST* regfi_load_valuelist(REGFI_FILE* file, uint32 offset, 885 uint32 num_values, uint32 max_size, 958 959 960 /** Loads a valuelist. 961 * 962 * XXX: finish documenting 963 * 964 * @ingroup regfiMiddleLayer 965 */ 966 REGFI_VALUE_LIST* regfi_load_valuelist(REGFI_FILE* file, uint32_t offset, 967 uint32_t num_values, uint32_t max_size, 886 968 bool strict); 887 969 888 REGFI_BUFFER regfi_load_data(REGFI_FILE* file, uint32 voffset, 889 uint32 length, bool data_in_offset, 970 971 /** Loads a data record which may be contained in the virtual offset, in a 972 * single cell, or in multiple cells through big data records. 973 * 974 * XXX: finish documenting 975 * 976 * @ingroup regfiMiddleLayer 977 */ 978 REGFI_BUFFER regfi_load_data(REGFI_FILE* file, uint32_t voffset, 979 uint32_t length, bool data_in_offset, 890 980 bool strict); 891 981 892 REGFI_BUFFER regfi_load_big_data(REGFI_FILE* file, uint32 offset, 893 uint32 data_length,uint32 cell_length, 982 983 /** Loads the data associated with a big data record at the specified offset. 984 * 985 * XXX: finish documenting 986 * 987 * @ingroup regfiMiddleLayer 988 */ 989 REGFI_BUFFER regfi_load_big_data(REGFI_FILE* file, uint32_t offset, 990 uint32_t data_length,uint32_t cell_length, 894 991 range_list* used_ranges, 895 992 bool strict); 993 994 995 /** Given raw data, attempts to interpret the data based on a specified registry 996 * data type. 997 * 998 * XXX: finish documenting 999 * 1000 * @ingroup regfiMiddleLayer 1001 */ 896 1002 bool regfi_interpret_data(REGFI_FILE* file, 897 1003 REGFI_ENCODING string_encoding, 898 uint32 type, REGFI_DATA* data); 1004 uint32_t type, REGFI_DATA* data); 1005 1006 1007 /** Frees the memory associated with a REGFI_CLASSNAME data structure. 1008 * 1009 * XXX: finish documenting 1010 * 1011 * @ingroup regfiMiddleLayer 1012 */ 899 1013 void regfi_free_classname(REGFI_CLASSNAME* classname); 1014 1015 1016 /** Frees the memory associated with a REGFI_DATA data structure. 1017 * 1018 * XXX: finish documenting 1019 * 1020 * @ingroup regfiMiddleLayer 1021 */ 900 1022 void regfi_free_data(REGFI_DATA* data); 901 1023 902 1024 903 1025 /* These are cached so return values don't need to be freed. */ 904 const REGFI_SK_REC* regfi_load_sk(REGFI_FILE* file, uint32 offset, 1026 1027 /** Loads an "sk" security record at the specified offset. 1028 * 1029 * XXX: finish documenting 1030 * 1031 * @ingroup regfiMiddleLayer 1032 */ 1033 const REGFI_SK_REC* regfi_load_sk(REGFI_FILE* file, uint32_t offset, 905 1034 bool strict); 906 const REGFI_HBIN* regfi_lookup_hbin(REGFI_FILE* file, uint32 offset); 907 908 909 /************************************/ 910 /* Low-layer data structure access */ 911 /************************************/ 1035 1036 1037 /** Retrieves the HBIN data structure stored at the specified offset. 1038 * 1039 * XXX: finish documenting 1040 * 1041 * @ingroup regfiMiddleLayer 1042 */ 1043 const REGFI_HBIN* regfi_lookup_hbin(REGFI_FILE* file, uint32_t offset); 1044 1045 1046 1047 /******************************************************************************/ 1048 /** 1049 * @defgroup regfiBottomLayer Bottom Layer: Direct Data Structure Access 1050 */ 1051 /******************************************************************************/ 1052 912 1053 REGFI_FILE* regfi_parse_regf(int fd, bool strict); 913 REGFI_HBIN* regfi_parse_hbin(REGFI_FILE* file, uint32 offset,1054 REGFI_HBIN* regfi_parse_hbin(REGFI_FILE* file, uint32_t offset, 914 1055 bool strict); 915 1056 916 1057 917 /* regfi_parse_nk: Parses an NK record. 918 * 919 * Arguments: 920 * f -- the registry file structure 921 * offset -- the offset of the cell (not the record) to be parsed. 922 * max_size -- the maximum size the NK cell could be. (for validation) 923 * strict -- if true, rejects any malformed records. Otherwise, 924 * tries to minimally validate integrity. 925 * Returns: 926 * A newly allocated NK record structure, or NULL on failure. 927 */ 928 REGFI_NK_REC* regfi_parse_nk(REGFI_FILE* file, uint32 offset, 929 uint32 max_size, bool strict); 930 931 REGFI_SUBKEY_LIST* regfi_parse_subkeylist(REGFI_FILE* file, uint32 offset, 932 uint32 max_size, bool strict); 933 934 REGFI_VK_REC* regfi_parse_vk(REGFI_FILE* file, uint32 offset, 935 uint32 max_size, bool strict); 936 937 REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32 offset, 938 uint32 max_size, bool strict); 939 1058 /** Parses an NK record at the specified offset 1059 * 1060 * @param file the registry file structure 1061 * @param offset the offset of the cell (not the record) to be parsed. 1062 * @param max_size the maximum size the NK cell could be. (for validation) 1063 * @param strict if true, rejects any malformed records. Otherwise, 1064 * tries to minimally validate integrity. 1065 * 1066 * @return A newly allocated NK record structure, or NULL on failure. 1067 * 1068 * @ingroup regfiBottomLayer 1069 */ 1070 REGFI_NK_REC* regfi_parse_nk(REGFI_FILE* file, uint32_t offset, 1071 uint32_t max_size, bool strict); 1072 1073 1074 /** Parses a single cell containing a subkey-list record. 1075 * 1076 * XXX: finish documenting 1077 * 1078 * @ingroup regfiBottomLayer 1079 */ 1080 REGFI_SUBKEY_LIST* regfi_parse_subkeylist(REGFI_FILE* file, uint32_t offset, 1081 uint32_t max_size, bool strict); 1082 1083 1084 /** Parses a VK (value) record at the specified offset 1085 * 1086 * XXX: finish documenting 1087 * 1088 * @ingroup regfiBottomLayer 1089 */ 1090 REGFI_VK_REC* regfi_parse_vk(REGFI_FILE* file, uint32_t offset, 1091 uint32_t max_size, bool strict); 1092 1093 1094 /** Parses an SK (security) record at the specified offset 1095 * 1096 * XXX: finish documenting 1097 * 1098 * @ingroup regfiBottomLayer 1099 */ 1100 REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32_t offset, 1101 uint32_t max_size, bool strict); 1102 1103 1104 /** Retrieves information on all cells in the registry hive which are 1105 * currently in the unallocated status. 1106 * 1107 * The unallocated status is determined based soley on the cell length sign. 1108 * 1109 * XXX: finish documenting 1110 * 1111 * @ingroup regfiBottomLayer 1112 */ 940 1113 range_list* regfi_parse_unalloc_cells(REGFI_FILE* file); 941 1114 942 bool regfi_parse_cell(int fd, uint32 offset, 943 uint8* hdr, uint32 hdr_len, 944 uint32* cell_length, bool* unalloc); 945 946 uint8* regfi_parse_classname(REGFI_FILE* file, uint32 offset, 947 uint16* name_length, 948 uint32 max_size, bool strict); 949 950 REGFI_BUFFER regfi_parse_data(REGFI_FILE* file, uint32 offset, 951 uint32 length, bool strict); 952 953 REGFI_BUFFER regfi_parse_little_data(REGFI_FILE* file, uint32 voffset, 954 uint32 length, bool strict); 955 956 957 /* Dispose of previously parsed records */ 958 void regfi_free_key(REGFI_NK_REC* nk); 959 void regfi_free_value(REGFI_VK_REC* vk); 960 961 962 963 /************************************/ 964 /* Private Functions */ 965 /************************************/ 1115 1116 /** Helper function to parse a cell 1117 * 1118 * XXX: finish documenting 1119 * 1120 * @ingroup regfiBottomLayer 1121 */ 1122 bool regfi_parse_cell(int fd, uint32_t offset, 1123 uint8_t* hdr, uint32_t hdr_len, 1124 uint32_t* cell_length, bool* unalloc); 1125 1126 1127 /** Parses a classname cell 1128 * 1129 * XXX: finish documenting 1130 * 1131 * @ingroup regfiBottomLayer 1132 */ 1133 uint8_t* regfi_parse_classname(REGFI_FILE* file, uint32_t offset, 1134 uint16_t* name_length, 1135 uint32_t max_size, bool strict); 1136 1137 1138 /** Parses a single-cell data record 1139 * 1140 * XXX: finish documenting 1141 * 1142 * @ingroup regfiBottomLayer 1143 */ 1144 REGFI_BUFFER regfi_parse_data(REGFI_FILE* file, uint32_t offset, 1145 uint32_t length, bool strict); 1146 1147 1148 /** Parses a "little data" record which is stored entirely within the 1149 * provided virtual offset. 1150 * 1151 * XXX: finish documenting 1152 * 1153 * @ingroup regfiBottomLayer 1154 */ 1155 REGFI_BUFFER regfi_parse_little_data(REGFI_FILE* file, uint32_t voffset, 1156 uint32_t length, bool strict); 1157 1158 1159 /******************************************************************************/ 1160 /* Private Functions */ 1161 /******************************************************************************/ 966 1162 REGFI_NK_REC* regfi_rootkey(REGFI_FILE* file, 967 1163 REGFI_ENCODING output_encoding); 968 1164 void regfi_subkeylist_free(REGFI_SUBKEY_LIST* list); 969 uint32 regfi_read(int fd, uint8* buf, uint32* length);1165 uint32_t regfi_read(int fd, uint8_t* buf, uint32_t* length); 970 1166 971 1167 const char* regfi_type_val2str(unsigned int val); … … 977 1173 char* regfi_get_group(WINSEC_DESC* sec_desc); 978 1174 979 REGFI_SUBKEY_LIST* regfi_merge_subkeylists(uint16 num_lists,1175 REGFI_SUBKEY_LIST* regfi_merge_subkeylists(uint16_t num_lists, 980 1176 REGFI_SUBKEY_LIST** lists, 981 1177 bool strict); 982 REGFI_SUBKEY_LIST* regfi_load_subkeylist_aux(REGFI_FILE* file, uint32 offset,983 uint32 max_size, bool strict,984 uint8 depth_left);985 void regfi_add_message(REGFI_FILE* file, uint16 msg_type,1178 REGFI_SUBKEY_LIST* regfi_load_subkeylist_aux(REGFI_FILE* file, uint32_t offset, 1179 uint32_t max_size, bool strict, 1180 uint8_t depth_left); 1181 void regfi_add_message(REGFI_FILE* file, uint16_t msg_type, 986 1182 const char* fmt, ...); 987 1183 REGFI_NK_REC* regfi_copy_nk(const REGFI_NK_REC* nk); 988 1184 REGFI_VK_REC* regfi_copy_vk(const REGFI_VK_REC* vk); 989 int32 regfi_calc_maxsize(REGFI_FILE* file, uint32offset);990 int32 1185 int32_t regfi_calc_maxsize(REGFI_FILE* file, uint32_t offset); 1186 int32_t regfi_conv_charset(const char* input_charset, 991 1187 const char* output_charset, 992 uint8 * input, char* output,993 uint32 input_len, uint32output_max);1188 uint8_t* input, char* output, 1189 uint32_t input_len, uint32_t output_max); 994 1190 REGFI_DATA* regfi_buffer_to_data(REGFI_BUFFER raw_data); 995 1191 1192 /* XXX: move to base API and document */ 1193 void regfi_unix2nt_time(REGFI_NTTIME* nt, time_t t); 1194 time_t regfi_nt2unix_time(const REGFI_NTTIME* nt); 1195 1196 996 1197 #endif /* _REGFI_H */ -
trunk/include/talloc.h
r147 r168 33 33 #include <string.h> 34 34 #include <stdbool.h> 35 #include "smb_deps.h" /* MAX macro */ 35 36 #ifndef MAX 37 #define MAX(a,b) ((a)>(b)?(a):(b)) 38 #endif 39 40 #ifndef MIN 41 #define MIN(a,b) ((a)<(b)?(a):(b)) 42 #endif 36 43 37 44 /* -
trunk/include/void_stack.h
r150 r168 1 /* 1 /** 2 * @file 3 * 2 4 * Copyright (C) 2005,2007,2009 Timothy D. Morgan 3 5 * -
trunk/include/winsec.h
r148 r168 1 /* 1 /** @file 2 2 * This file contains refactored Samba code used to interpret Windows 3 3 * Security Descriptors. See: … … 41 41 #include <unistd.h> 42 42 43 #include "smb_deps.h"44 43 #include "talloc.h" 44 #include "byteorder.h" 45 45 46 46 … … 72 72 typedef struct _winsec_uuid 73 73 { 74 uint32 time_low;75 uint16 time_mid;76 uint16 time_hi_and_version;77 uint8 clock_seq[2];78 uint8 node[6];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 79 } WINSEC_UUID; 80 80
Note: See TracChangeset
for help on using the changeset viewer.