- Timestamp:
- 03/02/10 19:08:42 (15 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 16 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 -
trunk/lib/Makefile
r147 r168 3 3 ################################################################################ 4 4 5 FILES=regfi.o smb_deps.owinsec.o void_stack.o range_list.o lru_cache.o talloc.o5 FILES=regfi.o winsec.o void_stack.o range_list.o lru_cache.o talloc.o 6 6 7 7 all: $(FILES) … … 9 9 regfi.o: regfi.c 10 10 $(CC) $(CFLAGS) $(OPTS) $(INC) -c -o $@ regfi.c 11 12 smb_deps.o: smb_deps.c13 $(CC) $(CFLAGS) $(OPTS) $(INC) -c -o $@ smb_deps.c14 11 15 12 winsec.o: winsec.c -
trunk/lib/lru_cache.c
r147 r168 1 /* 1 /** 2 * @file 3 * 2 4 * Copyright (C) 2008-2009 Timothy D. Morgan 3 5 * -
trunk/lib/range_list.c
r150 r168 1 /* 1 /** 2 * @file 3 * 2 4 * Copyright (C) 2008-2009 Timothy D. Morgan 3 5 * -
trunk/lib/regfi.c
r167 r168 24 24 */ 25 25 26 /** @file */ 27 26 28 #include "regfi.h" 27 29 … … 39 41 /****************************************************************************** 40 42 ******************************************************************************/ 41 void regfi_add_message(REGFI_FILE* file, uint16 msg_type, const char* fmt, ...)43 void regfi_add_message(REGFI_FILE* file, uint16_t msg_type, const char* fmt, ...) 42 44 { 43 45 /* XXX: This function is not particularly efficient, 44 46 * but then it is mostly used during errors. 45 47 */ 46 uint32 buf_size, buf_used;48 uint32_t buf_size, buf_used; 47 49 char* new_msg; 48 50 va_list args; … … 98 100 99 101 100 void regfi_set_message_mask(REGFI_FILE* file, uint16 mask)102 void regfi_set_message_mask(REGFI_FILE* file, uint16_t mask) 101 103 { 102 104 file->msg_mask = mask; … … 154 156 /* Security descriptor formatting functions */ 155 157 156 const char* regfi_ace_type2str(uint8 type)158 const char* regfi_ace_type2str(uint8_t type) 157 159 { 158 160 static const char* map[7] … … 174 176 * http://msdn2.microsoft.com/en-us/library/aa772242.aspx 175 177 */ 176 char* regfi_ace_flags2str(uint8 flags)178 char* regfi_ace_flags2str(uint8_t flags) 177 179 { 178 180 static const char* flag_map[32] = … … 189 191 char* ret_val = malloc(35*sizeof(char)); 190 192 char* fo = ret_val; 191 uint32 i;192 uint8 f;193 uint32_t i; 194 uint8_t f; 193 195 194 196 if(ret_val == NULL) … … 223 225 224 226 225 char* regfi_ace_perms2str(uint32 perms)226 { 227 uint32 i, p;227 char* regfi_ace_perms2str(uint32_t perms) 228 { 229 uint32_t i, p; 228 230 /* This is more than is needed by a fair margin. */ 229 231 char* ret_val = malloc(350*sizeof(char)); … … 304 306 char* regfi_sid2str(WINSEC_DOM_SID* sid) 305 307 { 306 uint32 i, size = WINSEC_MAX_SUBAUTHS*11 + 24;307 uint32 left = size;308 uint8 comps = sid->num_auths;308 uint32_t i, size = WINSEC_MAX_SUBAUTHS*11 + 24; 309 uint32_t left = size; 310 uint8_t comps = sid->num_auths; 309 311 char* ret_val = malloc(size); 310 312 … … 326 328 char* regfi_get_acl(WINSEC_ACL* acl) 327 329 { 328 uint32 i, extra, size = 0;330 uint32_t i, extra, size = 0; 329 331 const char* type_str; 330 332 char* flags_str; … … 425 427 * returned as 0, then EOF was encountered immediately 426 428 *****************************************************************************/ 427 uint32 regfi_read(int fd, uint8* buf, uint32* length)428 { 429 uint32 rsize = 0;430 uint32 rret = 0;429 uint32_t regfi_read(int fd, uint8_t* buf, uint32_t* length) 430 { 431 uint32_t rsize = 0; 432 uint32_t rret = 0; 431 433 432 434 do … … 449 451 * 450 452 *****************************************************************************/ 451 bool regfi_parse_cell(int fd, uint32 offset, uint8* hdr, uint32hdr_len,452 uint32 * cell_length, bool* unalloc)453 { 454 uint32 length;455 int32 raw_length;456 uint8 tmp[4];453 bool regfi_parse_cell(int fd, uint32_t offset, uint8_t* hdr, uint32_t hdr_len, 454 uint32_t* cell_length, bool* unalloc) 455 { 456 uint32_t length; 457 int32_t raw_length; 458 uint8_t tmp[4]; 457 459 458 460 if(lseek(fd, offset, SEEK_SET) == -1) … … 493 495 * The offset is a virtual file offset. 494 496 ******************************************************************************/ 495 static bool regfi_offset_in_hbin(const REGFI_HBIN* hbin, uint32 voffset)497 static bool regfi_offset_in_hbin(const REGFI_HBIN* hbin, uint32_t voffset) 496 498 { 497 499 if(!hbin) … … 511 513 * block for it. NULL if one doesn't exist. 512 514 ******************************************************************************/ 513 const REGFI_HBIN* regfi_lookup_hbin(REGFI_FILE* file, uint32 offset)515 const REGFI_HBIN* regfi_lookup_hbin(REGFI_FILE* file, uint32_t offset) 514 516 { 515 517 return (const REGFI_HBIN*)range_list_find_data(file->hbins, offset); … … 523 525 * (Since cells can only be ~2^31 in size, this works out.) 524 526 ******************************************************************************/ 525 int32 regfi_calc_maxsize(REGFI_FILE* file, uint32offset)527 int32_t regfi_calc_maxsize(REGFI_FILE* file, uint32_t offset) 526 528 { 527 529 const REGFI_HBIN* hbin = regfi_lookup_hbin(file, offset); … … 535 537 /****************************************************************************** 536 538 ******************************************************************************/ 537 REGFI_SUBKEY_LIST* regfi_load_subkeylist(REGFI_FILE* file, uint32 offset,538 uint32 num_keys, uint32max_size,539 REGFI_SUBKEY_LIST* regfi_load_subkeylist(REGFI_FILE* file, uint32_t offset, 540 uint32_t num_keys, uint32_t max_size, 539 541 bool strict) 540 542 { … … 568 570 /****************************************************************************** 569 571 ******************************************************************************/ 570 REGFI_SUBKEY_LIST* regfi_load_subkeylist_aux(REGFI_FILE* file, uint32 offset,571 uint32 max_size, bool strict,572 uint8 depth_left)572 REGFI_SUBKEY_LIST* regfi_load_subkeylist_aux(REGFI_FILE* file, uint32_t offset, 573 uint32_t max_size, bool strict, 574 uint8_t depth_left) 573 575 { 574 576 REGFI_SUBKEY_LIST* ret_val; 575 577 REGFI_SUBKEY_LIST** sublists; 576 uint32 i, num_sublists, off;577 int32 sublist_maxsize;578 uint32_t i, num_sublists, off; 579 int32_t sublist_maxsize; 578 580 579 581 if(depth_left == 0) … … 616 618 /****************************************************************************** 617 619 ******************************************************************************/ 618 REGFI_SUBKEY_LIST* regfi_parse_subkeylist(REGFI_FILE* file, uint32 offset,619 uint32 max_size, bool strict)620 REGFI_SUBKEY_LIST* regfi_parse_subkeylist(REGFI_FILE* file, uint32_t offset, 621 uint32_t max_size, bool strict) 620 622 { 621 623 REGFI_SUBKEY_LIST* ret_val; 622 uint32 i, cell_length, length, elem_size, read_len;623 uint8 * elements = NULL;624 uint8 buf[REGFI_SUBKEY_LIST_MIN_LEN];624 uint32_t i, cell_length, length, elem_size, read_len; 625 uint8_t* elements = NULL; 626 uint8_t buf[REGFI_SUBKEY_LIST_MIN_LEN]; 625 627 bool unalloc; 626 628 bool recursive_type; … … 647 649 { 648 650 recursive_type = true; 649 elem_size = sizeof(uint32 );651 elem_size = sizeof(uint32_t); 650 652 } 651 653 else if(buf[0] == 'l' && buf[1] == 'i') 652 elem_size = sizeof(uint32 );654 elem_size = sizeof(uint32_t); 653 655 else if((buf[0] == 'l') && (buf[1] == 'f' || buf[1] == 'h')) 654 656 elem_size = sizeof(REGFI_SUBKEY_LIST_ELEM); … … 676 678 677 679 length = elem_size*ret_val->num_children; 678 if(cell_length - REGFI_SUBKEY_LIST_MIN_LEN - sizeof(uint32 ) < length)680 if(cell_length - REGFI_SUBKEY_LIST_MIN_LEN - sizeof(uint32_t) < length) 679 681 { 680 682 regfi_add_message(file, REGFI_MSG_WARN, "Number of elements too large for" … … 683 685 if(strict) 684 686 goto fail; 685 length = cell_length - REGFI_SUBKEY_LIST_MIN_LEN - sizeof(uint32 );687 length = cell_length - REGFI_SUBKEY_LIST_MIN_LEN - sizeof(uint32_t); 686 688 } 687 689 … … 691 693 goto fail; 692 694 693 elements = (uint8 *)malloc(length);695 elements = (uint8_t*)malloc(length); 694 696 if(elements == NULL) 695 697 goto fail; … … 699 701 goto fail; 700 702 701 if(elem_size == sizeof(uint32 ))703 if(elem_size == sizeof(uint32_t)) 702 704 { 703 705 for (i=0; i < ret_val->num_children; i++) … … 729 731 /******************************************************************* 730 732 *******************************************************************/ 731 REGFI_SUBKEY_LIST* regfi_merge_subkeylists(uint16 num_lists,733 REGFI_SUBKEY_LIST* regfi_merge_subkeylists(uint16_t num_lists, 732 734 REGFI_SUBKEY_LIST** lists, 733 735 bool strict) 734 736 { 735 uint32 i,j,k;737 uint32_t i,j,k; 736 738 REGFI_SUBKEY_LIST* ret_val; 737 739 … … 785 787 * 786 788 ******************************************************************************/ 787 REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32 offset, uint32max_size,789 REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32_t offset, uint32_t max_size, 788 790 bool strict) 789 791 { 790 792 REGFI_SK_REC* ret_val; 791 uint8 * sec_desc_buf = NULL;792 uint32 cell_length, length;793 uint8 sk_header[REGFI_SK_MIN_LENGTH];793 uint8_t* sec_desc_buf = NULL; 794 uint32_t cell_length, length; 795 uint8_t sk_header[REGFI_SK_MIN_LENGTH]; 794 796 bool unalloc = false; 795 797 … … 855 857 } 856 858 857 sec_desc_buf = (uint8 *)malloc(ret_val->desc_size);859 sec_desc_buf = (uint8_t*)malloc(ret_val->desc_size); 858 860 if(sec_desc_buf == NULL) 859 861 goto fail; … … 889 891 890 892 891 REGFI_VALUE_LIST* regfi_parse_valuelist(REGFI_FILE* file, uint32 offset,892 uint32 num_values, bool strict)893 REGFI_VALUE_LIST* regfi_parse_valuelist(REGFI_FILE* file, uint32_t offset, 894 uint32_t num_values, bool strict) 893 895 { 894 896 REGFI_VALUE_LIST* ret_val; 895 uint32 i, cell_length, length, read_len;897 uint32_t i, cell_length, length, read_len; 896 898 bool unalloc; 897 899 … … 912 914 } 913 915 914 if((num_values * sizeof(uint32 )) > cell_length-sizeof(uint32))916 if((num_values * sizeof(uint32_t)) > cell_length-sizeof(uint32_t)) 915 917 { 916 918 regfi_add_message(file, REGFI_MSG_WARN, "Too many values found" … … 918 920 if(strict) 919 921 return NULL; 920 num_values = cell_length/sizeof(uint32 ) - sizeof(uint32);921 } 922 923 read_len = num_values*sizeof(uint32 );922 num_values = cell_length/sizeof(uint32_t) - sizeof(uint32_t); 923 } 924 925 read_len = num_values*sizeof(uint32_t); 924 926 ret_val = talloc(NULL, REGFI_VALUE_LIST); 925 927 if(ret_val == NULL) … … 935 937 936 938 length = read_len; 937 if((regfi_read(file->fd, (uint8 *)ret_val->elements, &length) != 0)939 if((regfi_read(file->fd, (uint8_t*)ret_val->elements, &length) != 0) 938 940 || length != read_len) 939 941 { … … 973 975 /****************************************************************************** 974 976 ******************************************************************************/ 975 REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32 offset,977 REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32_t offset, 976 978 REGFI_ENCODING output_encoding, bool strict) 977 979 { 978 980 REGFI_VK_REC* ret_val = NULL; 979 int32 max_size, tmp_size;981 int32_t max_size, tmp_size; 980 982 REGFI_ENCODING from_encoding; 981 983 … … 1003 1005 { 1004 1006 ret_val->valuename_raw = talloc_realloc(ret_val, ret_val->valuename_raw, 1005 uint8 , ret_val->name_length+1);1007 uint8_t, ret_val->name_length+1); 1006 1008 ret_val->valuename_raw[ret_val->name_length] = '\0'; 1007 1009 ret_val->valuename = (char*)ret_val->valuename_raw; … … 1038 1040 * If !strict, the list may contain NULLs, VK records may point to NULL. 1039 1041 ******************************************************************************/ 1040 REGFI_VALUE_LIST* regfi_load_valuelist(REGFI_FILE* file, uint32 offset,1041 uint32 num_values, uint32max_size,1042 REGFI_VALUE_LIST* regfi_load_valuelist(REGFI_FILE* file, uint32_t offset, 1043 uint32_t num_values, uint32_t max_size, 1042 1044 bool strict) 1043 1045 { 1044 uint32 usable_num_values;1045 1046 if((num_values+1) * sizeof(uint32 ) > max_size)1046 uint32_t usable_num_values; 1047 1048 if((num_values+1) * sizeof(uint32_t) > max_size) 1047 1049 { 1048 1050 regfi_add_message(file, REGFI_MSG_WARN, "Number of values indicated by" … … 1052 1054 if(strict) 1053 1055 return NULL; 1054 usable_num_values = max_size/sizeof(uint32 ) - sizeof(uint32);1056 usable_num_values = max_size/sizeof(uint32_t) - sizeof(uint32_t); 1055 1057 } 1056 1058 else … … 1065 1067 * 1066 1068 ******************************************************************************/ 1067 REGFI_NK_REC* regfi_load_key(REGFI_FILE* file, uint32 offset,1069 REGFI_NK_REC* regfi_load_key(REGFI_FILE* file, uint32_t offset, 1068 1070 REGFI_ENCODING output_encoding, bool strict) 1069 1071 { 1070 1072 REGFI_NK_REC* nk; 1071 uint32 off;1072 int32 max_size, tmp_size;1073 uint32_t off; 1074 int32_t max_size, tmp_size; 1073 1075 REGFI_ENCODING from_encoding; 1074 1076 … … 1097 1099 if(from_encoding == output_encoding) 1098 1100 { 1099 nk->keyname_raw = talloc_realloc(nk, nk->keyname_raw, uint8 , nk->name_length+1);1101 nk->keyname_raw = talloc_realloc(nk, nk->keyname_raw, uint8_t, nk->name_length+1); 1100 1102 nk->keyname_raw[nk->name_length] = '\0'; 1101 1103 nk->keyname = (char*)nk->keyname_raw; … … 1196 1198 /****************************************************************************** 1197 1199 ******************************************************************************/ 1198 const REGFI_SK_REC* regfi_load_sk(REGFI_FILE* file, uint32 offset, bool strict)1200 const REGFI_SK_REC* regfi_load_sk(REGFI_FILE* file, uint32_t offset, bool strict) 1199 1201 { 1200 1202 REGFI_SK_REC* ret_val = NULL; 1201 int32 max_size;1203 int32_t max_size; 1202 1204 void* failure_ptr = NULL; 1203 1205 … … 1240 1242 { 1241 1243 REGFI_NK_REC* nk = NULL; 1242 uint32 cell_length;1243 uint32 cur_offset = hbin->file_off+REGFI_HBIN_HEADER_SIZE;1244 uint32 hbin_end = hbin->file_off+hbin->block_size;1244 uint32_t cell_length; 1245 uint32_t cur_offset = hbin->file_off+REGFI_HBIN_HEADER_SIZE; 1246 uint32_t hbin_end = hbin->file_off+hbin->block_size; 1245 1247 bool unalloc; 1246 1248 … … 1301 1303 REGFI_FILE* rb; 1302 1304 REGFI_HBIN* hbin = NULL; 1303 uint32 hbin_off, file_length, cache_secret;1305 uint32_t hbin_off, file_length, cache_secret; 1304 1306 bool rla; 1305 1307 … … 1397 1399 REGFI_NK_REC* nk = NULL; 1398 1400 REGFI_HBIN* hbin; 1399 uint32 root_offset, i, num_hbins;1401 uint32_t root_offset, i, num_hbins; 1400 1402 1401 1403 if(!file) … … 1584 1586 REGFI_NK_REC* subkey; 1585 1587 bool found = false; 1586 uint32 old_subkey = i->cur_subkey;1588 uint32_t old_subkey = i->cur_subkey; 1587 1589 1588 1590 if(subkey_name == NULL) … … 1618 1620 bool regfi_iterator_walk_path(REGFI_ITERATOR* i, const char** path) 1619 1621 { 1620 uint32 x;1622 uint32_t x; 1621 1623 if(path == NULL) 1622 1624 return false; … … 1671 1673 REGFI_NK_REC* regfi_iterator_cur_subkey(REGFI_ITERATOR* i) 1672 1674 { 1673 uint32 nk_offset;1675 uint32_t nk_offset; 1674 1676 1675 1677 /* see if there is anything left to report */ … … 1708 1710 REGFI_VK_REC* cur; 1709 1711 bool found = false; 1710 uint32 old_value = i->cur_value;1712 uint32_t old_value = i->cur_value; 1711 1713 1712 1714 /* XXX: cur->valuename can be NULL in the registry. … … 1754 1756 { 1755 1757 REGFI_VK_REC* ret_val = NULL; 1756 uint32 voffset;1758 uint32_t voffset; 1757 1759 1758 1760 if(i->cur_key->values != NULL && i->cur_key->values->elements != NULL) … … 1791 1793 { 1792 1794 REGFI_CLASSNAME* ret_val; 1793 uint8 * raw;1795 uint8_t* raw; 1794 1796 char* interpreted; 1795 uint32 offset;1796 int32 conv_size, max_size;1797 uint16 parse_length;1797 uint32_t offset; 1798 int32_t conv_size, max_size; 1799 uint16_t parse_length; 1798 1800 1799 1801 if(key->classname_off == REGFI_OFFSET_NONE || key->classname_length == 0) … … 1935 1937 *****************************************************************************/ 1936 1938 bool regfi_interpret_data(REGFI_FILE* file, REGFI_ENCODING string_encoding, 1937 uint32 type, REGFI_DATA* data)1938 { 1939 uint8 ** tmp_array;1940 uint8 * tmp_str;1941 int32 tmp_size;1942 uint32 i, j, array_size;1939 uint32_t type, REGFI_DATA* data) 1940 { 1941 uint8_t** tmp_array; 1942 uint8_t* tmp_str; 1943 int32_t tmp_size; 1944 uint32_t i, j, array_size; 1943 1945 1944 1946 if(data == NULL) … … 1951 1953 /* REG_LINK is a symbolic link, stored as a unicode string. */ 1952 1954 case REG_LINK: 1953 tmp_str = talloc_array(NULL, uint8 , data->size);1955 tmp_str = talloc_array(NULL, uint8_t, data->size); 1954 1956 if(tmp_str == NULL) 1955 1957 { … … 1974 1976 } 1975 1977 1976 tmp_str = talloc_realloc(NULL, tmp_str, uint8 , tmp_size);1978 tmp_str = talloc_realloc(NULL, tmp_str, uint8_t, tmp_size); 1977 1979 data->interpreted.string = tmp_str; 1978 1980 data->interpreted_size = tmp_size; … … 2010 2012 } 2011 2013 data->interpreted.qword = 2012 (uint64 )IVAL(data->raw, 0) + (((uint64)IVAL(data->raw, 4))<<32);2014 (uint64_t)IVAL(data->raw, 0) + (((uint64_t)IVAL(data->raw, 4))<<32); 2013 2015 data->interpreted_size = 8; 2014 2016 break; 2015 2017 2016 2018 case REG_MULTI_SZ: 2017 tmp_str = talloc_array(NULL, uint8 , data->size);2019 tmp_str = talloc_array(NULL, uint8_t, data->size); 2018 2020 if(tmp_str == NULL) 2019 2021 { … … 2042 2044 2043 2045 array_size = tmp_size+1; 2044 tmp_array = talloc_array(NULL, uint8 *, array_size);2046 tmp_array = talloc_array(NULL, uint8_t*, array_size); 2045 2047 if(tmp_array == NULL) 2046 2048 { … … 2058 2060 } 2059 2061 tmp_array[j] = NULL; 2060 tmp_array = talloc_realloc(NULL, tmp_array, uint8 *, j+1);2062 tmp_array = talloc_realloc(NULL, tmp_array, uint8_t*, j+1); 2061 2063 data->interpreted.multiple_string = tmp_array; 2062 2064 /* XXX: how meaningful is this? should we store number of strings instead? */ … … 2107 2109 * On error, returns a negative errno code. 2108 2110 *****************************************************************************/ 2109 int32 regfi_conv_charset(const char* input_charset, const char* output_charset,2110 uint8 * input, char* output,2111 uint32 input_len, uint32output_max)2111 int32_t regfi_conv_charset(const char* input_charset, const char* output_charset, 2112 uint8_t* input, char* output, 2113 uint32_t input_len, uint32_t output_max) 2112 2114 { 2113 2115 iconv_t conv_desc; … … 2144 2146 * buffer must be at least the size of a regf header (4096 bytes). 2145 2147 *******************************************************************/ 2146 static uint32 regfi_compute_header_checksum(uint8* buffer)2147 { 2148 uint32 checksum, x;2148 static uint32_t regfi_compute_header_checksum(uint8_t* buffer) 2149 { 2150 uint32_t checksum, x; 2149 2151 int i; 2150 2152 … … 2167 2169 REGFI_FILE* regfi_parse_regf(int fd, bool strict) 2168 2170 { 2169 uint8 file_header[REGFI_REGF_SIZE];2170 uint32 length;2171 uint8_t file_header[REGFI_REGF_SIZE]; 2172 uint32_t length; 2171 2173 REGFI_FILE* ret_val; 2172 2174 … … 2243 2245 * along with it's associated cells. 2244 2246 ******************************************************************************/ 2245 REGFI_HBIN* regfi_parse_hbin(REGFI_FILE* file, uint32 offset, bool strict)2247 REGFI_HBIN* regfi_parse_hbin(REGFI_FILE* file, uint32_t offset, bool strict) 2246 2248 { 2247 2249 REGFI_HBIN *hbin; 2248 uint8 hbin_header[REGFI_HBIN_HEADER_SIZE];2249 uint32 length;2250 uint8_t hbin_header[REGFI_HBIN_HEADER_SIZE]; 2251 uint32_t length; 2250 2252 2251 2253 if(offset >= file->file_length) … … 2315 2317 /******************************************************************* 2316 2318 *******************************************************************/ 2317 REGFI_NK_REC* regfi_parse_nk(REGFI_FILE* file, uint32 offset,2318 uint32 max_size, bool strict)2319 { 2320 uint8 nk_header[REGFI_NK_MIN_LENGTH];2319 REGFI_NK_REC* regfi_parse_nk(REGFI_FILE* file, uint32_t offset, 2320 uint32_t max_size, bool strict) 2321 { 2322 uint8_t nk_header[REGFI_NK_MIN_LENGTH]; 2321 2323 REGFI_NK_REC* ret_val; 2322 uint32 length,cell_length;2324 uint32_t length,cell_length; 2323 2325 bool unalloc = false; 2324 2326 … … 2432 2434 } 2433 2435 2434 ret_val->keyname_raw = talloc_array(ret_val, uint8 , ret_val->name_length);2436 ret_val->keyname_raw = talloc_array(ret_val, uint8_t, ret_val->name_length); 2435 2437 if(ret_val->keyname_raw == NULL) 2436 2438 { … … 2441 2443 /* Don't need to seek, should be at the right offset */ 2442 2444 length = ret_val->name_length; 2443 if((regfi_read(file->fd, (uint8 *)ret_val->keyname_raw, &length) != 0)2445 if((regfi_read(file->fd, (uint8_t*)ret_val->keyname_raw, &length) != 0) 2444 2446 || length != ret_val->name_length) 2445 2447 { … … 2454 2456 2455 2457 2456 uint8 * regfi_parse_classname(REGFI_FILE* file, uint32offset,2457 uint16 * name_length, uint32max_size, bool strict)2458 { 2459 uint8 * ret_val = NULL;2460 uint32 length;2461 uint32 cell_length;2458 uint8_t* regfi_parse_classname(REGFI_FILE* file, uint32_t offset, 2459 uint16_t* name_length, uint32_t max_size, bool strict) 2460 { 2461 uint8_t* ret_val = NULL; 2462 uint32_t length; 2463 uint32_t cell_length; 2462 2464 bool unalloc = false; 2463 2465 … … 2499 2501 } 2500 2502 2501 ret_val = talloc_array(NULL, uint8 , *name_length);2503 ret_val = talloc_array(NULL, uint8_t, *name_length); 2502 2504 if(ret_val != NULL) 2503 2505 { … … 2520 2522 /****************************************************************************** 2521 2523 *******************************************************************************/ 2522 REGFI_VK_REC* regfi_parse_vk(REGFI_FILE* file, uint32 offset,2523 uint32 max_size, bool strict)2524 REGFI_VK_REC* regfi_parse_vk(REGFI_FILE* file, uint32_t offset, 2525 uint32_t max_size, bool strict) 2524 2526 { 2525 2527 REGFI_VK_REC* ret_val; 2526 uint8 vk_header[REGFI_VK_MIN_LENGTH];2527 uint32 raw_data_size, length, cell_length;2528 uint8_t vk_header[REGFI_VK_MIN_LENGTH]; 2529 uint32_t raw_data_size, length, cell_length; 2528 2530 bool unalloc = false; 2529 2531 … … 2604 2606 cell_length+=8; 2605 2607 2606 ret_val->valuename_raw = talloc_array(ret_val, uint8 , ret_val->name_length);2608 ret_val->valuename_raw = talloc_array(ret_val, uint8_t, ret_val->name_length); 2607 2609 if(ret_val->valuename_raw == NULL) 2608 2610 { … … 2612 2614 2613 2615 length = ret_val->name_length; 2614 if((regfi_read(file->fd, (uint8 *)ret_val->valuename_raw, &length) != 0)2616 if((regfi_read(file->fd, (uint8_t*)ret_val->valuename_raw, &length) != 0) 2615 2617 || length != ret_val->name_length) 2616 2618 { … … 2638 2640 * 2639 2641 ******************************************************************************/ 2640 REGFI_BUFFER regfi_load_data(REGFI_FILE* file, uint32 voffset,2641 uint32 length, bool data_in_offset,2642 REGFI_BUFFER regfi_load_data(REGFI_FILE* file, uint32_t voffset, 2643 uint32_t length, bool data_in_offset, 2642 2644 bool strict) 2643 2645 { 2644 2646 REGFI_BUFFER ret_val; 2645 uint32 cell_length, offset;2646 int32 max_size;2647 uint32_t cell_length, offset; 2648 int32_t max_size; 2647 2649 bool unalloc; 2648 2650 … … 2744 2746 * Parses the common case data records stored in a single cell. 2745 2747 ******************************************************************************/ 2746 REGFI_BUFFER regfi_parse_data(REGFI_FILE* file, uint32 offset,2747 uint32 length, bool strict)2748 REGFI_BUFFER regfi_parse_data(REGFI_FILE* file, uint32_t offset, 2749 uint32_t length, bool strict) 2748 2750 { 2749 2751 REGFI_BUFFER ret_val; 2750 uint32 read_length;2752 uint32_t read_length; 2751 2753 2752 2754 ret_val.buf = NULL; … … 2760 2762 } 2761 2763 2762 if((ret_val.buf = talloc_array(NULL, uint8 , length)) == NULL)2764 if((ret_val.buf = talloc_array(NULL, uint8_t, length)) == NULL) 2763 2765 return ret_val; 2764 2766 ret_val.len = length; … … 2783 2785 * 2784 2786 ******************************************************************************/ 2785 REGFI_BUFFER regfi_parse_little_data(REGFI_FILE* file, uint32 voffset,2786 uint32 length, bool strict)2787 REGFI_BUFFER regfi_parse_little_data(REGFI_FILE* file, uint32_t voffset, 2788 uint32_t length, bool strict) 2787 2789 { 2788 2790 REGFI_BUFFER ret_val; 2789 uint8 i;2791 uint8_t i; 2790 2792 2791 2793 ret_val.buf = NULL; … … 2800 2802 } 2801 2803 2802 if((ret_val.buf = talloc_array(NULL, uint8 , length)) == NULL)2804 if((ret_val.buf = talloc_array(NULL, uint8_t, length)) == NULL) 2803 2805 return ret_val; 2804 2806 ret_val.len = length; 2805 2807 2806 2808 for(i = 0; i < length; i++) 2807 ret_val.buf[i] = (uint8 )((voffset >> i*8) & 0xFF);2809 ret_val.buf[i] = (uint8_t)((voffset >> i*8) & 0xFF); 2808 2810 2809 2811 return ret_val; … … 2812 2814 /****************************************************************************** 2813 2815 *******************************************************************************/ 2814 REGFI_BUFFER regfi_parse_big_data_header(REGFI_FILE* file, uint32 offset,2815 uint32 max_size, bool strict)2816 REGFI_BUFFER regfi_parse_big_data_header(REGFI_FILE* file, uint32_t offset, 2817 uint32_t max_size, bool strict) 2816 2818 { 2817 2819 REGFI_BUFFER ret_val; 2818 uint32 cell_length;2820 uint32_t cell_length; 2819 2821 bool unalloc; 2820 2822 2821 2823 /* XXX: do something with unalloc? */ 2822 ret_val.buf = (uint8 *)talloc_array(NULL, uint8, REGFI_BIG_DATA_MIN_LENGTH);2824 ret_val.buf = (uint8_t*)talloc_array(NULL, uint8_t, REGFI_BIG_DATA_MIN_LENGTH); 2823 2825 if(ret_val.buf == NULL) 2824 2826 goto fail; … … 2866 2868 * 2867 2869 ******************************************************************************/ 2868 uint32 * regfi_parse_big_data_indirect(REGFI_FILE* file, uint32offset,2869 uint16 num_chunks, bool strict)2870 { 2871 uint32 * ret_val;2872 uint32 indirect_length;2873 int32 max_size;2874 uint16 i;2870 uint32_t* regfi_parse_big_data_indirect(REGFI_FILE* file, uint32_t offset, 2871 uint16_t num_chunks, bool strict) 2872 { 2873 uint32_t* ret_val; 2874 uint32_t indirect_length; 2875 int32_t max_size; 2876 uint16_t i; 2875 2877 bool unalloc; 2876 2878 … … 2878 2880 2879 2881 max_size = regfi_calc_maxsize(file, offset); 2880 if((max_size < 0) || (num_chunks*sizeof(uint32 ) + 4 > max_size))2881 return NULL; 2882 2883 ret_val = (uint32 *)talloc_array(NULL, uint32, num_chunks);2882 if((max_size < 0) || (num_chunks*sizeof(uint32_t) + 4 > max_size)) 2883 return NULL; 2884 2885 ret_val = (uint32_t*)talloc_array(NULL, uint32_t, num_chunks); 2884 2886 if(ret_val == NULL) 2885 2887 goto fail; 2886 2888 2887 if(!regfi_parse_cell(file->fd, offset, (uint8 *)ret_val,2888 num_chunks*sizeof(uint32 ),2889 if(!regfi_parse_cell(file->fd, offset, (uint8_t*)ret_val, 2890 num_chunks*sizeof(uint32_t), 2889 2891 &indirect_length, &unalloc)) 2890 2892 { … … 2898 2900 for(i=0; i<num_chunks; i++) 2899 2901 { 2900 ret_val[i] = IVAL(ret_val, i*sizeof(uint32 ));2902 ret_val[i] = IVAL(ret_val, i*sizeof(uint32_t)); 2901 2903 if((ret_val[i] & 0x00000007) != 0) 2902 2904 goto fail; … … 2924 2926 * No data in range_list elements. 2925 2927 ******************************************************************************/ 2926 range_list* regfi_parse_big_data_cells(REGFI_FILE* file, uint32 * offsets,2927 uint16 num_chunks, bool strict)2928 { 2929 uint32 cell_length, chunk_offset;2928 range_list* regfi_parse_big_data_cells(REGFI_FILE* file, uint32_t* offsets, 2929 uint16_t num_chunks, bool strict) 2930 { 2931 uint32_t cell_length, chunk_offset; 2930 2932 range_list* ret_val; 2931 uint16 i;2933 uint16_t i; 2932 2934 bool unalloc; 2933 2935 … … 2965 2967 *******************************************************************************/ 2966 2968 REGFI_BUFFER regfi_load_big_data(REGFI_FILE* file, 2967 uint32 offset, uint32data_length,2968 uint32 cell_length, range_list* used_ranges,2969 uint32_t offset, uint32_t data_length, 2970 uint32_t cell_length, range_list* used_ranges, 2969 2971 bool strict) 2970 2972 { 2971 2973 REGFI_BUFFER ret_val; 2972 uint16 num_chunks, i;2973 uint32 read_length, data_left, tmp_len, indirect_offset;2974 uint32 * indirect_ptrs = NULL;2974 uint16_t num_chunks, i; 2975 uint32_t read_length, data_left, tmp_len, indirect_offset; 2976 uint32_t* indirect_ptrs = NULL; 2975 2977 REGFI_BUFFER bd_header; 2976 2978 range_list* bd_cells = NULL; … … 3048 3050 } 3049 3051 3050 if(lseek(file->fd, cell_info->offset+sizeof(uint32 ), SEEK_SET) == -1)3052 if(lseek(file->fd, cell_info->offset+sizeof(uint32_t), SEEK_SET) == -1) 3051 3053 { 3052 3054 regfi_add_message(file, REGFI_MSG_WARN, "Could not seek to chunk while " … … 3095 3097 REGFI_HBIN* hbin; 3096 3098 const range_list_element* hbins_elem; 3097 uint32 i, num_hbins, curr_off, cell_len;3099 uint32_t i, num_hbins, curr_off, cell_len; 3098 3100 bool is_unalloc; 3099 3101 … … 3142 3144 return ret_val; 3143 3145 } 3146 3147 3148 /* From lib/time.c */ 3149 3150 /**************************************************************************** 3151 Put a 8 byte filetime from a time_t 3152 This takes real GMT as input and converts to kludge-GMT 3153 ****************************************************************************/ 3154 void regfi_unix2nt_time(REGFI_NTTIME *nt, time_t t) 3155 { 3156 double d; 3157 3158 if (t==0) 3159 { 3160 nt->low = 0; 3161 nt->high = 0; 3162 return; 3163 } 3164 3165 if (t == TIME_T_MAX) 3166 { 3167 nt->low = 0xffffffff; 3168 nt->high = 0x7fffffff; 3169 return; 3170 } 3171 3172 if (t == -1) 3173 { 3174 nt->low = 0xffffffff; 3175 nt->high = 0xffffffff; 3176 return; 3177 } 3178 3179 /* this converts GMT to kludge-GMT */ 3180 /* XXX: This was removed due to difficult dependency requirements. 3181 * So far, times appear to be correct without this adjustment, but 3182 * that may be proven wrong with adequate testing. 3183 */ 3184 /* t -= TimeDiff(t) - get_serverzone(); */ 3185 3186 d = (double)(t); 3187 d += TIME_FIXUP_CONSTANT; 3188 d *= 1.0e7; 3189 3190 nt->high = (uint32_t)(d * (1.0/(4.0*(double)(1<<30)))); 3191 nt->low = (uint32_t)(d - ((double)nt->high)*4.0*(double)(1<<30)); 3192 } 3193 3194 3195 /**************************************************************************** 3196 Interpret an 8 byte "filetime" structure to a time_t 3197 It's originally in "100ns units since jan 1st 1601" 3198 3199 An 8 byte value of 0xffffffffffffffff will be returned as (time_t)0. 3200 3201 It appears to be kludge-GMT (at least for file listings). This means 3202 its the GMT you get by taking a localtime and adding the 3203 serverzone. This is NOT the same as GMT in some cases. This routine 3204 converts this to real GMT. 3205 ****************************************************************************/ 3206 time_t regfi_nt2unix_time(const REGFI_NTTIME* nt) 3207 { 3208 double d; 3209 time_t ret; 3210 /* The next two lines are a fix needed for the 3211 broken SCO compiler. JRA. */ 3212 time_t l_time_min = TIME_T_MIN; 3213 time_t l_time_max = TIME_T_MAX; 3214 3215 if (nt->high == 0 || (nt->high == 0xffffffff && nt->low == 0xffffffff)) 3216 return(0); 3217 3218 d = ((double)nt->high)*4.0*(double)(1<<30); 3219 d += (nt->low&0xFFF00000); 3220 d *= 1.0e-7; 3221 3222 /* now adjust by 369 years to make the secs since 1970 */ 3223 d -= TIME_FIXUP_CONSTANT; 3224 3225 if (d <= l_time_min) 3226 return (l_time_min); 3227 3228 if (d >= l_time_max) 3229 return (l_time_max); 3230 3231 ret = (time_t)(d+0.5); 3232 3233 /* this takes us from kludge-GMT to real GMT */ 3234 /* XXX: This was removed due to difficult dependency requirements. 3235 * So far, times appear to be correct without this adjustment, but 3236 * that may be proven wrong with adequate testing. 3237 */ 3238 /* 3239 ret -= get_serverzone(); 3240 ret += LocTimeDiff(ret); 3241 */ 3242 3243 return(ret); 3244 } 3245 3246 /* End of stuff from lib/time.c */ -
trunk/lib/void_stack.c
r150 r168 1 /* 1 /** 2 * @file 3 * 2 4 * This is a really simple implementation of a stack which stores chunks 3 * of memory of any type. It still needs work to eliminate memory 4 * leaks. 5 * of memory of any type. 5 6 * 6 7 * Copyright (C) 2005,2007,2009 Timothy D. Morgan -
trunk/lib/winsec.c
r148 r168 1 /* 1 /** 2 * @file 2 3 * This file contains refactored Samba code used to interpret Windows 3 4 * Security Descriptors. See: -
trunk/src/common.c
r160 r168 160 160 char* tmp_ptr; 161 161 char* delim; 162 uint32 ret_val_left, i, tmp_len;162 uint32_t ret_val_left, i, tmp_len; 163 163 164 164 if(data == NULL || data->size == 0) -
trunk/src/reglookup-recover.c
r161 r168 40 40 41 41 42 char* getQuotedData(int fd, uint32 offset, uint32length)43 { 44 uint8 * buf;42 char* getQuotedData(int fd, uint32_t offset, uint32_t length) 43 { 44 uint8_t* buf; 45 45 char* quoted_buf; 46 uint32 len;46 uint32_t len; 47 47 48 48 if((lseek(fd, offset, SEEK_SET)) == -1) 49 49 return NULL; 50 50 51 buf = (uint8 *)malloc(length);51 buf = (uint8_t*)malloc(length); 52 52 if(buf == NULL) 53 53 return NULL; … … 75 75 char* quoted_raw = ""; 76 76 77 *tmp_time = nt_time_to_unix(&nk->mtime);77 *tmp_time = regfi_nt2unix_time(&nk->mtime); 78 78 tmp_time_s = gmtime(tmp_time); 79 79 strftime(mtime, sizeof(mtime), "%Y-%m-%d %H:%M:%S", tmp_time_s); … … 217 217 218 218 219 int printCell(REGFI_FILE* f, uint32 offset)219 int printCell(REGFI_FILE* f, uint32_t offset) 220 220 { 221 221 char* quoted_buf; 222 uint32 cell_length;222 uint32_t cell_length; 223 223 bool unalloc; 224 224 … … 249 249 REGFI_NK_REC* cur_ancestor; 250 250 char* ret_val; 251 uint32 virt_offset, i, stack_size, ret_val_size, ret_val_used, offset;252 int32 max_size;251 uint32_t virt_offset, i, stack_size, ret_val_size, ret_val_used, offset; 252 int32_t max_size; 253 253 REGFI_BUFFER* path_element; 254 254 … … 278 278 path_element = talloc(path_stack, REGFI_BUFFER); 279 279 if(path_element != NULL) 280 path_element->buf = (uint8 *)quote_string(cur_ancestor->keyname,280 path_element->buf = (uint8_t*)quote_string(cur_ancestor->keyname, 281 281 key_special_chars); 282 282 … … 343 343 344 344 345 bool removeRange(range_list* rl, uint32 offset, uint32length)346 { 347 int32 rm_idx;345 bool removeRange(range_list* rl, uint32_t offset, uint32_t length) 346 { 347 int32_t rm_idx; 348 348 const range_list_element* cur_elem; 349 349 … … 405 405 const range_list_element* cur_elem; 406 406 REGFI_VK_REC* vk; 407 uint32 i, j;407 uint32_t i, j; 408 408 409 409 for(i=0; i < range_list_size(unalloc_cells); i++) … … 450 450 range_list* bd_cells; 451 451 REGFI_BUFFER data; 452 uint32 i, j, offset, cell_length, length;453 int32 max_size;452 uint32_t i, j, offset, cell_length, length; 453 int32_t max_size; 454 454 bool unalloc; 455 455 … … 583 583 const range_list_element* cur_elem; 584 584 REGFI_NK_REC* key; 585 uint32 i, j;585 uint32_t i, j; 586 586 int error_code = 0; 587 587 … … 637 637 REGFI_VK_REC* vk; 638 638 const range_list_element* cur_elem; 639 uint32 i, j, num_keys, off, values_length;640 int32 max_size;639 uint32_t i, j, num_keys, off, values_length; 640 int32_t max_size; 641 641 642 642 num_keys=range_list_size(unalloc_keys); … … 663 663 * parsed structure. 664 664 */ 665 values_length = (nk->values->num_values+1)*sizeof(uint32 );665 values_length = (nk->values->num_values+1)*sizeof(uint32_t); 666 666 if(values_length != (values_length & 0xFFFFFFF8)) 667 667 values_length = (values_length & 0xFFFFFFF8) + 8; … … 727 727 const range_list_element* cur_elem; 728 728 REGFI_SK_REC* sk; 729 uint32 i, j;729 uint32_t i, j; 730 730 731 731 for(i=0; i < range_list_size(unalloc_cells); i++) … … 778 778 REGFI_NK_REC* tmp_key; 779 779 REGFI_VK_REC* tmp_value; 780 uint32 argi, arge, i, j, ret, num_unalloc_keys;780 uint32_t argi, arge, i, j, ret, num_unalloc_keys; 781 781 782 782 /* Process command line arguments */ -
trunk/src/reglookup.c
r162 r168 132 132 char* next = NULL; 133 133 char* copy; 134 uint32 ret_cur = 0;134 uint32_t ret_cur = 0; 135 135 136 136 ret_val = (char**)malloc((REGFI_MAX_DEPTH+1+1)*sizeof(char**)); … … 179 179 void freePath(char** path) 180 180 { 181 uint32 i;181 uint32_t i; 182 182 183 183 if(path == NULL) … … 196 196 const REGFI_ITER_POSITION* cur; 197 197 const REGFI_NK_REC* tmp_key; 198 uint32 buf_left = 127;199 uint32 buf_len = buf_left+1;200 uint32 name_len = 0;201 uint32 grow_amt;198 uint32_t buf_left = 127; 199 uint32_t buf_len = buf_left+1; 200 uint32_t name_len = 0; 201 uint32_t grow_amt; 202 202 char* buf; 203 203 char* new_buf; … … 245 245 if(name_len+1 > buf_left) 246 246 { 247 grow_amt = (uint32 )(buf_len/2);247 grow_amt = (uint32_t)(buf_len/2); 248 248 buf_len += name_len+1+grow_amt-buf_left; 249 249 if((new_buf = realloc(buf, buf_len)) == NULL) … … 298 298 REGFI_CLASSNAME* classname; 299 299 300 *tmp_time = nt_time_to_unix(&k->mtime);300 *tmp_time = regfi_nt2unix_time(&k->mtime); 301 301 tmp_time_s = gmtime(tmp_time); 302 302 strftime(mtime, sizeof(mtime), "%Y-%m-%d %H:%M:%S", tmp_time_s); … … 454 454 char* tmp_path_joined; 455 455 const char** tmp_path; 456 uint32 i;456 uint32_t i; 457 457 458 458 if(path == NULL) … … 557 557 REGFI_ITERATOR* iter; 558 558 int retr_path_ret; 559 uint32 argi, arge;559 uint32_t argi, arge; 560 560 561 561 /* Process command line arguments */
Note: See TracChangeset
for help on using the changeset viewer.