Changeset 168 for trunk


Ignore:
Timestamp:
03/02/10 19:08:42 (15 years ago)
Author:
tim
Message:

merged remaining smb_deps items into regfi

began formatting API comments for use with doxygen

Location:
trunk
Files:
2 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/byteorder.h

    r111 r168  
    1 /* 
     1/*
    22 * Branched from Samba project Subversion repository, version #2:
    33 *  http://websvn.samba.org/cgi-bin/viewcvs.cgi/trunk/source/include/byteorder.h
     
    2828#define _BYTEORDER_H
    2929
    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
    3337
    3438Here is a description of this file that I emailed to the samba list once:
     
    5458Ok, now to the macros themselves. I'll take a simple example, say we
    5559want 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 you
    57 want to do it with only the assumption that uint16 is _at_least_ 16
     60type called uint16_t that is in the local machines byte order, and you
     61want to do it with only the assumption that uint16_t is _at_least_ 16
    5862bits long (this last condition is very important for architectures
    5963that don't have any int types that are 2 bytes long)
     
    6569#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
    6670
    67 then to extract a uint16 value at offset 25 in a buffer you do this:
     71then to extract a uint16_t value at offset 25 in a buffer you do this:
    6872
    6973char *buffer = foo_bar();
    70 uint16 xx = SVAL(buffer,25);
     74uint16_t xx = SVAL(buffer,25);
    7175
    7276We are using the byteoder independence of the ANSI C bitshifts to do
     
    98102it also defines lots of intermediate macros, just ignore those :-)
    99103
     104@endverbatim
     105
    100106*/
    101107
     
    124130#define SSVALX(buf,pos,val) (CVAL_NC(buf,pos)=(unsigned char)((val)&0xFF),CVAL_NC(buf,pos+1)=(unsigned char)((val)>>8))
    125131#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)))
    132138
    133139#else /* CAREFUL_ALIGNMENT */
     
    136142   alignment errors */
    137143/*
    138    WARNING: This section is dependent on the length of int16 and int32
     144   WARNING: This section is dependent on the length of int16_t and int32_t
    139145   being correct
    140146*/
    141147
    142148/* 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. */
    151157
    152158/* 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))
    157163
    158164#endif /* CAREFUL_ALIGNMENT */
  • trunk/include/lru_cache.h

    r147 r168  
    1 /*
     1/**
     2 * @file
     3 *
    24 * Copyright (C) 2008-2009 Timothy D. Morgan
    35 *
  • trunk/include/range_list.h

    r148 r168  
    1 /*
     1/**
     2 * @file
     3 *
    24 * Copyright (C) 2008-2009 Timothy D. Morgan
    35 *
  • trunk/include/regfi.h

    r167 r168  
    1 /*
     1/** @file
     2 * Windows NT (and later) registry parsing library
     3 *
    24 * Branched from Samba project Subversion repository, version #6903:
    35 *   http://viewcvs.samba.org/cgi-bin/viewcvs.cgi/trunk/source/include/regfio.h?rev=6903&view=auto
    46 *
    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
    88 * Copyright (C) 2005 Gerald (Jerry) Carter
    99 *
     
    2929 * Thanks Nigel!
    3030 ***********************************************************/
     31
     32/**
     33 * @mainpage Home
     34 *
     35 * See \ref regfiTopLayer
     36 */
    3137
    3238#ifndef _REGFI_H
     
    4753#include <iconv.h>
    4854
     55#include "byteorder.h"
    4956#include "talloc.h"
    50 #include "smb_deps.h"
    5157#include "winsec.h"
    5258#include "void_stack.h"
     
    6167#define REGFI_MSG_ERROR 0x0010
    6268
    63 typedef uint8 REGFI_ENCODING;
     69typedef uint8_t REGFI_ENCODING;
    6470/* regfi library supported character encodings */
    6571#define REGFI_ENCODING_ASCII   0
     
    210216                                    | REGFI_NK_FLAG_UNKNOWN3)
    211217
     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
     225typedef struct _regfi_nttime
     226{
     227  uint32_t low;
     228  uint32_t high;
     229} REGFI_NTTIME;
     230
     231
    212232/* HBIN block */
    213233typedef struct _regfi_hbin
    214234{
    215   uint32 file_off;       /* my offset in the registry file */
    216   uint32 ref_count;      /* how many active records are pointing to this
     235  uint32_t file_off;       /* my offset in the registry file */
     236  uint32_t ref_count;      /* how many active records are pointing to this
    217237                          * block (not used currently)
    218238                          */
    219239 
    220   uint32 first_hbin_off; /* offset from first hbin block */
    221   uint32 block_size;     /* block size of this block
     240  uint32_t first_hbin_off; /* offset from first hbin block */
     241  uint32_t block_size;     /* block size of this block
    222242                          * Should be a multiple of 4096 (0x1000)
    223243                          */
    224   uint32 next_block;     /* relative offset to next block. 
     244  uint32_t next_block;     /* relative offset to next block. 
    225245                          * NOTE: This value may be unreliable!
    226246                          */
    227247
    228   uint8 magic[REGFI_HBIN_MAGIC_SIZE]; /* "hbin" */
     248  uint8_t magic[REGFI_HBIN_MAGIC_SIZE]; /* "hbin" */
    229249} REGFI_HBIN;
    230250
     
    236256   * depending on this list's type.
    237257   */
    238   uint32 offset;
    239 
    240   uint32 hash;
     258  uint32_t offset;
     259
     260  uint32_t hash;
    241261} REGFI_SUBKEY_LIST_ELEM;
    242262
     
    245265{
    246266  /* 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;
    250270 
    251271  /* Number of immediate children */
    252   uint32 num_children; 
     272  uint32_t num_children; 
    253273
    254274  /* Total number of keys referenced by this list and it's children */
    255   uint32 num_keys;     
     275  uint32_t num_keys;     
    256276
    257277  REGFI_SUBKEY_LIST_ELEM* elements;
    258   uint8 magic[REGFI_CELL_MAGIC_SIZE];
     278  uint8_t magic[REGFI_CELL_MAGIC_SIZE];
    259279
    260280  /* Set if the magic indicates this subkey list points to child subkey lists */
     
    263283
    264284
    265 typedef uint32 REGFI_VALUE_LIST_ELEM;
     285typedef uint32_t REGFI_VALUE_LIST_ELEM;
    266286typedef struct _regfi_value_list
    267287{
     
    269289   * May differ from parent key's num_values if there were parsing errors.
    270290   */
    271   uint32 num_values;
     291  uint32_t num_values;
    272292
    273293  REGFI_VALUE_LIST_ELEM* elements;
     
    281301
    282302  /* Represents raw buffer read from classname cell. */
    283   uint8* raw;
     303  uint8_t* raw;
    284304
    285305  /* Length of the raw data. May be shorter than that indicated by parent key.*/
    286   uint16 size;
     306  uint16_t size;
    287307} REGFI_CLASSNAME;
    288308
     
    290310typedef struct _regfi_data
    291311{
    292   uint32 type;
     312  uint32_t type;
    293313
    294314  /* Length of the raw data. */
    295   uint32 size;
     315  uint32_t size;
    296316
    297317  /* This is always present, representing the raw data cell contents. */
    298   uint8* raw;
     318  uint8_t* raw;
    299319
    300320  /* Represents the length of the interpreted value. Meaning is type-specific.*/
    301   uint32 interpreted_size;
     321  uint32_t interpreted_size;
    302322
    303323  /* These items represent interpreted versions of the raw attribute above.
     
    307327  union _regfi_data_interpreted
    308328  {
    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;
    318338
    319339    /* The following are treated as binary currently, but this may change in
    320340     * the future as the formats become better understood.
    321341     */
    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;
    325345  } interpreted;
    326346} REGFI_DATA;
     
    330350typedef struct
    331351{
    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) */
    334354
    335355  REGFI_DATA* data;     /* XXX: deprecated */
    336356
    337357  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 */
    341361 
    342   uint32 data_size;     /* As reported in the VK record.  May be different than
     362  uint32_t data_size;     /* As reported in the VK record.  May be different than
    343363                         * 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;
    349369  bool data_in_offset;
    350370} REGFI_VK_REC;
     
    356376typedef struct _regfi_sk_rec
    357377{
    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) */
    360380
    361381  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 */
    363383 
    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];
    370390} REGFI_SK_REC;
    371391
     
    374394typedef struct
    375395{
    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. 
    378398                         * Always in multiples of 8.
    379399                         */
     
    384404 
    385405  /* 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;
    391411  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;
    395415 
    396416  /* 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 */
    401421 
    402422  /* 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 ? */
    407427 
    408428  /* 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 */
    414434} REGFI_NK_REC;
    415435
     
    425445
    426446  /* For sanity checking (not part of the registry header) */
    427   uint32 file_length;
     447  uint32_t file_length;
    428448
    429449  /* Metadata about hbins */
     
    437457
    438458  /* Mask for error message types that will be stored. */
    439   uint16 msg_mask;
     459  uint16_t msg_mask;
    440460
    441461
    442462  /* Data parsed from file header */
    443463  /********************************/
    444   uint8  magic[REGFI_REGF_MAGIC_SIZE];/* "regf" */
     464  uint8_t  magic[REGFI_REGF_MAGIC_SIZE];/* "regf" */
    445465
    446466 /* These sequence numbers should match if
    447467  * the hive was properly synced to disk.
    448468  */
    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 */
    462482
    463483  /* 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];
    465485
    466486  WINSEC_UUID* rm_id;       /* XXX: Unverified. */
    467487  WINSEC_UUID* log_id;      /* XXX: Unverified. */
    468488  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.
    474494                             * (XOR of bytes 0x0000 - 0x01FB) */
    475495
     
    477497  WINSEC_UUID* thaw_rm_id;  /* XXX: Unverified. */
    478498  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. */
    481501
    482502  /* This seems to include random junk.  Possibly unsanitized memory left over
    483503   * from when header block was written.  For instance, chunks of nk records
    484504   * can be found, though often it's all 0s. */
    485   uint8 reserved1[REGFI_REGF_RESERVED1_SIZE];
     505  uint8_t reserved1[REGFI_REGF_RESERVED1_SIZE];
    486506
    487507  /* This is likely reserved and unusued currently.  (Should be all 0s.)
    488508   * Included here for easier access in looking for hidden data
    489509   * or doing research. */
    490   uint8 reserved2[REGFI_REGF_RESERVED2_SIZE];
     510  uint8_t reserved2[REGFI_REGF_RESERVED2_SIZE];
    491511
    492512} REGFI_FILE;
     
    499519  REGFI_NK_REC* cur_key;
    500520  REGFI_ENCODING string_encoding;
    501   uint32 cur_subkey;
    502   uint32 cur_value;
     521  uint32_t cur_subkey;
     522  uint32_t cur_value;
    503523} REGFI_ITERATOR;
    504524
     
    507527{
    508528  REGFI_NK_REC* nk;
    509   uint32 cur_subkey;
     529  uint32_t cur_subkey;
    510530  /* We could store a cur_value here as well, but didn't see
    511531   * the use in it right now.
     
    516536typedef struct _regfi_buffer
    517537{
    518   uint8* buf;
     538  uint8_t* buf;
    519539  uint32_t len;
    520540} REGFI_BUFFER;
    521541
    522542
    523 
    524 
    525543/******************************************************************************/
    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 */
    527550/******************************************************************************/
    528551
    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
    534556 *               registry hive to be opened.
    535557 *
    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
    539562 */
    540563REGFI_FILE*           regfi_open(const char* filename);
    541564
    542565
    543 /* regfi_alloc: Parses file headers of an already open registry hive file and
    544  *              allocates related structures for further parsing.
    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
    552575 */
    553576REGFI_FILE*           regfi_alloc(int fd);
    554577
    555578
    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
    564587 */
    565588int                   regfi_close(REGFI_FILE* file);
    566589
    567590
    568 /* regfi_free: Frees a hive's data structures without closing the underlying
    569  *             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
    573596 */
    574597void                  regfi_free(REGFI_FILE* file);
    575598
    576599
    577 /* regfi_get_messages: Get errors, warnings, and/or verbose information
    578  *                     relating to processing of the given registry file.
    579  *
    580  * Arguments:
    581  *   file     -- the structure for the registry file
    582  *
    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
    585608 */
    586609char*                 regfi_get_messages(REGFI_FILE* file);
    587610
    588611
    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.
    596620 *               Acceptable values are created through bitwise ORs of
    597621 *               REGFI_MSG_* values.  For instance, if only errors and
     
    606630 *               will prevent message accumulation. 
    607631 *
    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 */
     634void                  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 */
     645void                  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 */
     654void                  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
    628684 */
    629685REGFI_ITERATOR*       regfi_iterator_new(REGFI_FILE* file,
     
    631687
    632688
    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.
    635690 *
    636691 * This does not affect the underlying registry file's allocation status.
    637692 *
    638  * Arguments:
    639  *   file            -- the iterator to be freed
     693 * @param i the iterator to be freed
     694 *
     695 * @ingroup regfiTopLayer
    640696 */
    641697void                  regfi_iterator_free(REGFI_ITERATOR* i);
    642698
    643699
    644 /* regfi_iterator_down: Traverse deeper into the registry tree at the
    645  *                      current subkey.
    646  *
    647  * Arguments:
    648  *   i            -- the iterator
    649  *
    650  * Returns:
    651  *   true on success, false on failure.  Note that subkey and value indexes
    652  *   are preserved.  That is, if a regfi_iterator_up call occurs later
    653  *   (reversing the effect of this call) then the subkey and value referenced
    654  *   prior to the regfi_iterator_down call will still be referenced.  This
    655  *   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
    656712 */
    657713bool                  regfi_iterator_down(REGFI_ITERATOR* i);
    658714
    659715
    660 /* regfi_iterator_up: Traverse up to the current key's parent key.
    661  *
    662  * Arguments:
    663  *   i            -- the iterator
    664  *
    665  * Returns:
    666  *   true on success, false on failure.  Any subkey or value state
    667  *   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
    668724 */
    669725bool                  regfi_iterator_up(REGFI_ITERATOR* i);
    670726
    671727
    672 /* regfi_iterator_to_root: Traverse up to the root key of the hive.
    673  *
    674  * Arguments:
    675  *   i            -- the iterator
    676  *
    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
    679735 */
    680736bool                  regfi_iterator_to_root(REGFI_ITERATOR* i);
    681737
    682738
    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.
    692740 *
    693741 * XXX: This currently only accepts ASCII key names.  Need to look into
    694742 *      accepting other encodings.
    695743 *
    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 */
     757bool 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
    712767 */
    713768const REGFI_NK_REC*   regfi_iterator_cur_key(REGFI_ITERATOR* i);
    714769
    715770
    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
    724778 */
    725779const REGFI_SK_REC*   regfi_iterator_cur_sk(REGFI_ITERATOR* i);
    726780
    727781
    728 /* regfi_iterator_first_subkey: Sets the internal subkey index to the first
    729  *                              subkey referenced by the current key and returns
    730  *                              that key.
    731  *
    732  * Arguments:
    733  *   i            -- the iterator
    734  *
    735  * Returns:
    736  *   A newly allocated key structure for the newly referenced first subkey, or
    737  *   NULL on failure.  Failure may be due to a lack of any subkeys or other
    738  *   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
    739793 */
    740794REGFI_NK_REC*         regfi_iterator_first_subkey(REGFI_ITERATOR* i);
    741795
    742796
    743 /* regfi_iterator_cur_subkey: Returns the currently indexed subkey.
    744  *
    745  * Arguments:
    746  *   i            -- the iterator
    747  *
    748  * Returns:
    749  *   A newly allocated key structure for the currently referenced subkey,
    750  *   or NULL on failure.  Newly allocated keys must be freed with
    751  *   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
    752806 */
    753807REGFI_NK_REC*         regfi_iterator_cur_subkey(REGFI_ITERATOR* i);
    754808
    755809
    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
    767819 */
    768820REGFI_NK_REC*         regfi_iterator_next_subkey(REGFI_ITERATOR* i);
    769821
    770822
    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
    782833 */
    783834bool                  regfi_iterator_find_subkey(REGFI_ITERATOR* i,
    784835                                                 const char* subkey_name);
    785836
    786 /* regfi_iterator_first_value: Sets the internal value index to the first
    787  *                             value referenced by the current key and returns
    788  *                             that value.
    789  *
    790  * Arguments:
    791  *   i            -- the iterator
    792  *
    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 other
    796  *   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
    797848 */
    798849REGFI_VK_REC*         regfi_iterator_first_value(REGFI_ITERATOR* i);
    799850
    800851
    801 /* regfi_iterator_cur_value: Returns the currently indexed value.
    802  *
    803  * Arguments:
    804  *   i            -- the iterator
    805  *
    806  * Returns:
    807  *   A newly allocated value structure for the currently referenced value,
    808  *   or NULL on failure.  Newly allocated values must be freed with
    809  *   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
    810861 */
    811862REGFI_VK_REC*         regfi_iterator_cur_value(REGFI_ITERATOR* i);
    812863
    813864
    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
    824874 */
    825875REGFI_VK_REC*         regfi_iterator_next_value(REGFI_ITERATOR* i);
    826876
    827877
    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
    839888 */
    840889bool                  regfi_iterator_find_value(REGFI_ITERATOR* i,
    841890                                                const char* value_name);
    842891
    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
    853901 */
    854902REGFI_CLASSNAME*      regfi_iterator_fetch_classname(REGFI_ITERATOR* i,
     
    856904
    857905
    858 /* regfi_iterator_fetch_data: Retrieves data for a given value.
    859  *
    860  * Arguments:
    861  *   i            -- the iterator
    862  *   value        -- the value whose data is desired
    863  *
    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
    867915 */
    868916REGFI_DATA*           regfi_iterator_fetch_data(REGFI_ITERATOR* i,
     
    870918
    871919
    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 */
     933REGFI_NK_REC*         regfi_load_key(REGFI_FILE* file, uint32_t offset,
    876934                                     REGFI_ENCODING output_encoding,
    877935                                     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 */
     944REGFI_VK_REC*         regfi_load_value(REGFI_FILE* file, uint32_t offset,
    879945                                       REGFI_ENCODING output_encoding,
    880946                                       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 */
     955REGFI_SUBKEY_LIST*    regfi_load_subkeylist(REGFI_FILE* file, uint32_t offset,
     956                                            uint32_t num_keys, uint32_t max_size,
    883957                                            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 */
     966REGFI_VALUE_LIST*     regfi_load_valuelist(REGFI_FILE* file, uint32_t offset,
     967                                           uint32_t num_values, uint32_t max_size,
    886968                                           bool strict);
    887969
    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 */
     978REGFI_BUFFER          regfi_load_data(REGFI_FILE* file, uint32_t voffset,
     979                                      uint32_t length, bool data_in_offset,
    890980                                      bool strict);
    891981
    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 */
     989REGFI_BUFFER          regfi_load_big_data(REGFI_FILE* file, uint32_t offset,
     990                                          uint32_t data_length,uint32_t cell_length,
    894991                                          range_list* used_ranges,
    895992                                          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 */
    8961002bool                  regfi_interpret_data(REGFI_FILE* file,
    8971003                                           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 */
    8991013void                  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 */
    9001022void                  regfi_free_data(REGFI_DATA* data);
    9011023
    9021024
    9031025/* 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 */
     1033const REGFI_SK_REC*   regfi_load_sk(REGFI_FILE* file, uint32_t offset,
    9051034                                    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 */
     1043const 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
    9121053REGFI_FILE*           regfi_parse_regf(int fd, bool strict);
    913 REGFI_HBIN*           regfi_parse_hbin(REGFI_FILE* file, uint32 offset,
     1054REGFI_HBIN*           regfi_parse_hbin(REGFI_FILE* file, uint32_t offset,
    9141055                                       bool strict);
    9151056
    9161057
    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 */
     1070REGFI_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 */
     1080REGFI_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 */
     1090REGFI_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 */
     1100REGFI_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 */
    9401113range_list*           regfi_parse_unalloc_cells(REGFI_FILE* file);
    9411114
    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 */
     1122bool                  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 */
     1133uint8_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 */
     1144REGFI_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 */
     1155REGFI_BUFFER          regfi_parse_little_data(REGFI_FILE* file, uint32_t voffset,
     1156                                              uint32_t length, bool strict);
     1157
     1158
     1159/******************************************************************************/
     1160/*    Private Functions                                                       */
     1161/******************************************************************************/
    9661162REGFI_NK_REC*         regfi_rootkey(REGFI_FILE* file,
    9671163                                    REGFI_ENCODING output_encoding);
    9681164void                  regfi_subkeylist_free(REGFI_SUBKEY_LIST* list);
    969 uint32                regfi_read(int fd, uint8* buf, uint32* length);
     1165uint32_t                regfi_read(int fd, uint8_t* buf, uint32_t* length);
    9701166
    9711167const char*           regfi_type_val2str(unsigned int val);
     
    9771173char*                 regfi_get_group(WINSEC_DESC* sec_desc);
    9781174
    979 REGFI_SUBKEY_LIST*    regfi_merge_subkeylists(uint16 num_lists,
     1175REGFI_SUBKEY_LIST*    regfi_merge_subkeylists(uint16_t num_lists,
    9801176                                              REGFI_SUBKEY_LIST** lists,
    9811177                                              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,
     1178REGFI_SUBKEY_LIST*    regfi_load_subkeylist_aux(REGFI_FILE* file, uint32_t offset,
     1179                                                uint32_t max_size, bool strict,
     1180                                                uint8_t depth_left);
     1181void                  regfi_add_message(REGFI_FILE* file, uint16_t msg_type,
    9861182                                        const char* fmt, ...);
    9871183REGFI_NK_REC*         regfi_copy_nk(const REGFI_NK_REC* nk);
    9881184REGFI_VK_REC*         regfi_copy_vk(const REGFI_VK_REC* vk);
    989 int32                 regfi_calc_maxsize(REGFI_FILE* file, uint32 offset);
    990 int32                 regfi_conv_charset(const char* input_charset,
     1185int32_t               regfi_calc_maxsize(REGFI_FILE* file, uint32_t offset);
     1186int32_t               regfi_conv_charset(const char* input_charset,
    9911187                                         const char* output_charset,
    992                                          uint8* input, char* output,
    993                                          uint32 input_len, uint32 output_max);
     1188                                         uint8_t* input, char* output,
     1189                                         uint32_t input_len, uint32_t output_max);
    9941190REGFI_DATA*           regfi_buffer_to_data(REGFI_BUFFER raw_data);
    9951191
     1192/* XXX: move to base API and document */
     1193void                  regfi_unix2nt_time(REGFI_NTTIME* nt, time_t t);
     1194time_t                regfi_nt2unix_time(const REGFI_NTTIME* nt);
     1195
     1196
    9961197#endif  /* _REGFI_H */
  • trunk/include/talloc.h

    r147 r168  
    3333#include <string.h>
    3434#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
    3643
    3744/*
  • trunk/include/void_stack.h

    r150 r168  
    1 /*
     1/**
     2 * @file
     3 *
    24 * Copyright (C) 2005,2007,2009 Timothy D. Morgan
    35 *
  • trunk/include/winsec.h

    r148 r168  
    1 /*
     1/** @file
    22 * This file contains refactored Samba code used to interpret Windows
    33 * Security Descriptors. See:
     
    4141#include <unistd.h>
    4242
    43 #include "smb_deps.h"
    4443#include "talloc.h"
     44#include "byteorder.h"
    4545
    4646
     
    7272typedef struct _winsec_uuid
    7373{
    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];
    7979} WINSEC_UUID;
    8080
  • trunk/lib/Makefile

    r147 r168  
    33################################################################################
    44
    5 FILES=regfi.o smb_deps.o winsec.o void_stack.o range_list.o lru_cache.o talloc.o
     5FILES=regfi.o winsec.o void_stack.o range_list.o lru_cache.o talloc.o
    66
    77all: $(FILES)
     
    99regfi.o: regfi.c
    1010        $(CC) $(CFLAGS) $(OPTS) $(INC) -c -o $@ regfi.c
    11 
    12 smb_deps.o: smb_deps.c
    13         $(CC) $(CFLAGS) $(OPTS) $(INC) -c -o $@ smb_deps.c
    1411
    1512winsec.o: winsec.c
  • trunk/lib/lru_cache.c

    r147 r168  
    1 /*
     1/**
     2 * @file
     3 *
    24 * Copyright (C) 2008-2009 Timothy D. Morgan
    35 *
  • trunk/lib/range_list.c

    r150 r168  
    1 /*
     1/**
     2 * @file
     3 *
    24 * Copyright (C) 2008-2009 Timothy D. Morgan
    35 *
  • trunk/lib/regfi.c

    r167 r168  
    2424 */
    2525
     26/** @file */
     27
    2628#include "regfi.h"
    2729
     
    3941/******************************************************************************
    4042 ******************************************************************************/
    41 void regfi_add_message(REGFI_FILE* file, uint16 msg_type, const char* fmt, ...)
     43void regfi_add_message(REGFI_FILE* file, uint16_t msg_type, const char* fmt, ...)
    4244{
    4345  /* XXX: This function is not particularly efficient,
    4446   *      but then it is mostly used during errors.
    4547   */
    46   uint32 buf_size, buf_used;
     48  uint32_t buf_size, buf_used;
    4749  char* new_msg;
    4850  va_list args;
     
    98100
    99101
    100 void regfi_set_message_mask(REGFI_FILE* file, uint16 mask)
     102void regfi_set_message_mask(REGFI_FILE* file, uint16_t mask)
    101103{
    102104  file->msg_mask = mask;
     
    154156/* Security descriptor formatting functions  */
    155157
    156 const char* regfi_ace_type2str(uint8 type)
     158const char* regfi_ace_type2str(uint8_t type)
    157159{
    158160  static const char* map[7]
     
    174176 *   http://msdn2.microsoft.com/en-us/library/aa772242.aspx
    175177 */
    176 char* regfi_ace_flags2str(uint8 flags)
     178char* regfi_ace_flags2str(uint8_t flags)
    177179{
    178180  static const char* flag_map[32] =
     
    189191  char* ret_val = malloc(35*sizeof(char));
    190192  char* fo = ret_val;
    191   uint32 i;
    192   uint8 f;
     193  uint32_t i;
     194  uint8_t f;
    193195
    194196  if(ret_val == NULL)
     
    223225
    224226
    225 char* regfi_ace_perms2str(uint32 perms)
    226 {
    227   uint32 i, p;
     227char* regfi_ace_perms2str(uint32_t perms)
     228{
     229  uint32_t i, p;
    228230  /* This is more than is needed by a fair margin. */
    229231  char* ret_val = malloc(350*sizeof(char));
     
    304306char* regfi_sid2str(WINSEC_DOM_SID* sid)
    305307{
    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;
    309311  char* ret_val = malloc(size);
    310312 
     
    326328char* regfi_get_acl(WINSEC_ACL* acl)
    327329{
    328   uint32 i, extra, size = 0;
     330  uint32_t i, extra, size = 0;
    329331  const char* type_str;
    330332  char* flags_str;
     
    425427 * returned as 0, then EOF was encountered immediately
    426428 *****************************************************************************/
    427 uint32 regfi_read(int fd, uint8* buf, uint32* length)
    428 {
    429   uint32 rsize = 0;
    430   uint32 rret = 0;
     429uint32_t regfi_read(int fd, uint8_t* buf, uint32_t* length)
     430{
     431  uint32_t rsize = 0;
     432  uint32_t rret = 0;
    431433
    432434  do
     
    449451 *
    450452 *****************************************************************************/
    451 bool regfi_parse_cell(int fd, uint32 offset, uint8* hdr, uint32 hdr_len,
    452                       uint32* cell_length, bool* unalloc)
    453 {
    454   uint32 length;
    455   int32 raw_length;
    456   uint8 tmp[4];
     453bool 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];
    457459
    458460  if(lseek(fd, offset, SEEK_SET) == -1)
     
    493495 * The offset is a virtual file offset.
    494496 ******************************************************************************/
    495 static bool regfi_offset_in_hbin(const REGFI_HBIN* hbin, uint32 voffset)
     497static bool regfi_offset_in_hbin(const REGFI_HBIN* hbin, uint32_t voffset)
    496498{
    497499  if(!hbin)
     
    511513 * block for it.  NULL if one doesn't exist.
    512514 ******************************************************************************/
    513 const REGFI_HBIN* regfi_lookup_hbin(REGFI_FILE* file, uint32 offset)
     515const REGFI_HBIN* regfi_lookup_hbin(REGFI_FILE* file, uint32_t offset)
    514516{
    515517  return (const REGFI_HBIN*)range_list_find_data(file->hbins, offset);
     
    523525 * (Since cells can only be ~2^31 in size, this works out.)
    524526 ******************************************************************************/
    525 int32 regfi_calc_maxsize(REGFI_FILE* file, uint32 offset)
     527int32_t regfi_calc_maxsize(REGFI_FILE* file, uint32_t offset)
    526528{
    527529  const REGFI_HBIN* hbin = regfi_lookup_hbin(file, offset);
     
    535537/******************************************************************************
    536538 ******************************************************************************/
    537 REGFI_SUBKEY_LIST* regfi_load_subkeylist(REGFI_FILE* file, uint32 offset,
    538                                          uint32 num_keys, uint32 max_size,
     539REGFI_SUBKEY_LIST* regfi_load_subkeylist(REGFI_FILE* file, uint32_t offset,
     540                                         uint32_t num_keys, uint32_t max_size,
    539541                                         bool strict)
    540542{
     
    568570/******************************************************************************
    569571 ******************************************************************************/
    570 REGFI_SUBKEY_LIST* regfi_load_subkeylist_aux(REGFI_FILE* file, uint32 offset,
    571                                              uint32 max_size, bool strict,
    572                                              uint8 depth_left)
     572REGFI_SUBKEY_LIST* regfi_load_subkeylist_aux(REGFI_FILE* file, uint32_t offset,
     573                                             uint32_t max_size, bool strict,
     574                                             uint8_t depth_left)
    573575{
    574576  REGFI_SUBKEY_LIST* ret_val;
    575577  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;
    578580
    579581  if(depth_left == 0)
     
    616618/******************************************************************************
    617619 ******************************************************************************/
    618 REGFI_SUBKEY_LIST* regfi_parse_subkeylist(REGFI_FILE* file, uint32 offset,
    619                                           uint32 max_size, bool strict)
     620REGFI_SUBKEY_LIST* regfi_parse_subkeylist(REGFI_FILE* file, uint32_t offset,
     621                                          uint32_t max_size, bool strict)
    620622{
    621623  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];
    625627  bool unalloc;
    626628  bool recursive_type;
     
    647649  {
    648650    recursive_type = true;
    649     elem_size = sizeof(uint32);
     651    elem_size = sizeof(uint32_t);
    650652  }
    651653  else if(buf[0] == 'l' && buf[1] == 'i')
    652     elem_size = sizeof(uint32);
     654    elem_size = sizeof(uint32_t);
    653655  else if((buf[0] == 'l') && (buf[1] == 'f' || buf[1] == 'h'))
    654656    elem_size = sizeof(REGFI_SUBKEY_LIST_ELEM);
     
    676678
    677679  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)
    679681  {
    680682    regfi_add_message(file, REGFI_MSG_WARN, "Number of elements too large for"
     
    683685    if(strict)
    684686      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);
    686688  }
    687689
     
    691693    goto fail;
    692694
    693   elements = (uint8*)malloc(length);
     695  elements = (uint8_t*)malloc(length);
    694696  if(elements == NULL)
    695697    goto fail;
     
    699701    goto fail;
    700702
    701   if(elem_size == sizeof(uint32))
     703  if(elem_size == sizeof(uint32_t))
    702704  {
    703705    for (i=0; i < ret_val->num_children; i++)
     
    729731/*******************************************************************
    730732 *******************************************************************/
    731 REGFI_SUBKEY_LIST* regfi_merge_subkeylists(uint16 num_lists,
     733REGFI_SUBKEY_LIST* regfi_merge_subkeylists(uint16_t num_lists,
    732734                                           REGFI_SUBKEY_LIST** lists,
    733735                                           bool strict)
    734736{
    735   uint32 i,j,k;
     737  uint32_t i,j,k;
    736738  REGFI_SUBKEY_LIST* ret_val;
    737739
     
    785787 *
    786788 ******************************************************************************/
    787 REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32 offset, uint32 max_size,
     789REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32_t offset, uint32_t max_size,
    788790                             bool strict)
    789791{
    790792  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];
    794796  bool unalloc = false;
    795797
     
    855857  }
    856858
    857   sec_desc_buf = (uint8*)malloc(ret_val->desc_size);
     859  sec_desc_buf = (uint8_t*)malloc(ret_val->desc_size);
    858860  if(sec_desc_buf == NULL)
    859861    goto fail;
     
    889891
    890892
    891 REGFI_VALUE_LIST* regfi_parse_valuelist(REGFI_FILE* file, uint32 offset,
    892                                         uint32 num_values, bool strict)
     893REGFI_VALUE_LIST* regfi_parse_valuelist(REGFI_FILE* file, uint32_t offset,
     894                                        uint32_t num_values, bool strict)
    893895{
    894896  REGFI_VALUE_LIST* ret_val;
    895   uint32 i, cell_length, length, read_len;
     897  uint32_t i, cell_length, length, read_len;
    896898  bool unalloc;
    897899
     
    912914  }
    913915
    914   if((num_values * sizeof(uint32)) > cell_length-sizeof(uint32))
     916  if((num_values * sizeof(uint32_t)) > cell_length-sizeof(uint32_t))
    915917  {
    916918    regfi_add_message(file, REGFI_MSG_WARN, "Too many values found"
     
    918920    if(strict)
    919921      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);
    924926  ret_val = talloc(NULL, REGFI_VALUE_LIST);
    925927  if(ret_val == NULL)
     
    935937
    936938  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)
    938940     || length != read_len)
    939941  {
     
    973975/******************************************************************************
    974976 ******************************************************************************/
    975 REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32 offset,
     977REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32_t offset,
    976978                               REGFI_ENCODING output_encoding, bool strict)
    977979{
    978980  REGFI_VK_REC* ret_val = NULL;
    979   int32 max_size, tmp_size;
     981  int32_t max_size, tmp_size;
    980982  REGFI_ENCODING from_encoding;
    981983
     
    10031005  {
    10041006    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);
    10061008    ret_val->valuename_raw[ret_val->name_length] = '\0';
    10071009    ret_val->valuename = (char*)ret_val->valuename_raw;
     
    10381040 * If !strict, the list may contain NULLs, VK records may point to NULL.
    10391041 ******************************************************************************/
    1040 REGFI_VALUE_LIST* regfi_load_valuelist(REGFI_FILE* file, uint32 offset,
    1041                                        uint32 num_values, uint32 max_size,
     1042REGFI_VALUE_LIST* regfi_load_valuelist(REGFI_FILE* file, uint32_t offset,
     1043                                       uint32_t num_values, uint32_t max_size,
    10421044                                       bool strict)
    10431045{
    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)
    10471049  {
    10481050    regfi_add_message(file, REGFI_MSG_WARN, "Number of values indicated by"
     
    10521054    if(strict)
    10531055      return NULL;
    1054     usable_num_values = max_size/sizeof(uint32) - sizeof(uint32);
     1056    usable_num_values = max_size/sizeof(uint32_t) - sizeof(uint32_t);
    10551057  }
    10561058  else
     
    10651067 *
    10661068 ******************************************************************************/
    1067 REGFI_NK_REC* regfi_load_key(REGFI_FILE* file, uint32 offset,
     1069REGFI_NK_REC* regfi_load_key(REGFI_FILE* file, uint32_t offset,
    10681070                             REGFI_ENCODING output_encoding, bool strict)
    10691071{
    10701072  REGFI_NK_REC* nk;
    1071   uint32 off;
    1072   int32 max_size, tmp_size;
     1073  uint32_t off;
     1074  int32_t max_size, tmp_size;
    10731075  REGFI_ENCODING from_encoding;
    10741076
     
    10971099  if(from_encoding == output_encoding)
    10981100  {
    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);
    11001102    nk->keyname_raw[nk->name_length] = '\0';
    11011103    nk->keyname = (char*)nk->keyname_raw;
     
    11961198/******************************************************************************
    11971199 ******************************************************************************/
    1198 const REGFI_SK_REC* regfi_load_sk(REGFI_FILE* file, uint32 offset, bool strict)
     1200const REGFI_SK_REC* regfi_load_sk(REGFI_FILE* file, uint32_t offset, bool strict)
    11991201{
    12001202  REGFI_SK_REC* ret_val = NULL;
    1201   int32 max_size;
     1203  int32_t max_size;
    12021204  void* failure_ptr = NULL;
    12031205 
     
    12401242{
    12411243  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;
    12451247  bool unalloc;
    12461248
     
    13011303  REGFI_FILE* rb;
    13021304  REGFI_HBIN* hbin = NULL;
    1303   uint32 hbin_off, file_length, cache_secret;
     1305  uint32_t hbin_off, file_length, cache_secret;
    13041306  bool rla;
    13051307
     
    13971399  REGFI_NK_REC* nk = NULL;
    13981400  REGFI_HBIN* hbin;
    1399   uint32 root_offset, i, num_hbins;
     1401  uint32_t root_offset, i, num_hbins;
    14001402 
    14011403  if(!file)
     
    15841586  REGFI_NK_REC* subkey;
    15851587  bool found = false;
    1586   uint32 old_subkey = i->cur_subkey;
     1588  uint32_t old_subkey = i->cur_subkey;
    15871589
    15881590  if(subkey_name == NULL)
     
    16181620bool regfi_iterator_walk_path(REGFI_ITERATOR* i, const char** path)
    16191621{
    1620   uint32 x;
     1622  uint32_t x;
    16211623  if(path == NULL)
    16221624    return false;
     
    16711673REGFI_NK_REC* regfi_iterator_cur_subkey(REGFI_ITERATOR* i)
    16721674{
    1673   uint32 nk_offset;
     1675  uint32_t nk_offset;
    16741676
    16751677  /* see if there is anything left to report */
     
    17081710  REGFI_VK_REC* cur;
    17091711  bool found = false;
    1710   uint32 old_value = i->cur_value;
     1712  uint32_t old_value = i->cur_value;
    17111713
    17121714  /* XXX: cur->valuename can be NULL in the registry. 
     
    17541756{
    17551757  REGFI_VK_REC* ret_val = NULL;
    1756   uint32 voffset;
     1758  uint32_t voffset;
    17571759
    17581760  if(i->cur_key->values != NULL && i->cur_key->values->elements != NULL)
     
    17911793{
    17921794  REGFI_CLASSNAME* ret_val;
    1793   uint8* raw;
     1795  uint8_t* raw;
    17941796  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;
    17981800
    17991801  if(key->classname_off == REGFI_OFFSET_NONE || key->classname_length == 0)
     
    19351937 *****************************************************************************/
    19361938bool 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;
    19431945
    19441946  if(data == NULL)
     
    19511953  /* REG_LINK is a symbolic link, stored as a unicode string. */
    19521954  case REG_LINK:
    1953     tmp_str = talloc_array(NULL, uint8, data->size);
     1955    tmp_str = talloc_array(NULL, uint8_t, data->size);
    19541956    if(tmp_str == NULL)
    19551957    {
     
    19741976    }
    19751977
    1976     tmp_str = talloc_realloc(NULL, tmp_str, uint8, tmp_size);
     1978    tmp_str = talloc_realloc(NULL, tmp_str, uint8_t, tmp_size);
    19771979    data->interpreted.string = tmp_str;
    19781980    data->interpreted_size = tmp_size;
     
    20102012    }
    20112013    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);
    20132015    data->interpreted_size = 8;
    20142016    break;
    20152017   
    20162018  case REG_MULTI_SZ:
    2017     tmp_str = talloc_array(NULL, uint8, data->size);
     2019    tmp_str = talloc_array(NULL, uint8_t, data->size);
    20182020    if(tmp_str == NULL)
    20192021    {
     
    20422044
    20432045    array_size = tmp_size+1;
    2044     tmp_array = talloc_array(NULL, uint8*, array_size);
     2046    tmp_array = talloc_array(NULL, uint8_t*, array_size);
    20452047    if(tmp_array == NULL)
    20462048    {
     
    20582060    }
    20592061    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);
    20612063    data->interpreted.multiple_string = tmp_array;
    20622064    /* XXX: how meaningful is this?  should we store number of strings instead? */
     
    21072109 * On error, returns a negative errno code.
    21082110 *****************************************************************************/
    2109 int32 regfi_conv_charset(const char* input_charset, const char* output_charset,
    2110                          uint8* input, char* output,
    2111                          uint32 input_len, uint32 output_max)
     2111int32_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)
    21122114{
    21132115  iconv_t conv_desc;
     
    21442146 * buffer must be at least the size of a regf header (4096 bytes).
    21452147 *******************************************************************/
    2146 static uint32 regfi_compute_header_checksum(uint8* buffer)
    2147 {
    2148   uint32 checksum, x;
     2148static uint32_t regfi_compute_header_checksum(uint8_t* buffer)
     2149{
     2150  uint32_t checksum, x;
    21492151  int i;
    21502152
     
    21672169REGFI_FILE* regfi_parse_regf(int fd, bool strict)
    21682170{
    2169   uint8 file_header[REGFI_REGF_SIZE];
    2170   uint32 length;
     2171  uint8_t file_header[REGFI_REGF_SIZE];
     2172  uint32_t length;
    21712173  REGFI_FILE* ret_val;
    21722174
     
    22432245 * along with it's associated cells.
    22442246 ******************************************************************************/
    2245 REGFI_HBIN* regfi_parse_hbin(REGFI_FILE* file, uint32 offset, bool strict)
     2247REGFI_HBIN* regfi_parse_hbin(REGFI_FILE* file, uint32_t offset, bool strict)
    22462248{
    22472249  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;
    22502252 
    22512253  if(offset >= file->file_length)
     
    23152317/*******************************************************************
    23162318 *******************************************************************/
    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];
     2319REGFI_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];
    23212323  REGFI_NK_REC* ret_val;
    2322   uint32 length,cell_length;
     2324  uint32_t length,cell_length;
    23232325  bool unalloc = false;
    23242326
     
    24322434  }
    24332435
    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);
    24352437  if(ret_val->keyname_raw == NULL)
    24362438  {
     
    24412443  /* Don't need to seek, should be at the right offset */
    24422444  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)
    24442446     || length != ret_val->name_length)
    24452447  {
     
    24542456
    24552457
    2456 uint8* regfi_parse_classname(REGFI_FILE* file, uint32 offset,
    2457                              uint16* name_length, uint32 max_size, bool strict)
    2458 {
    2459   uint8* ret_val = NULL;
    2460   uint32 length;
    2461   uint32 cell_length;
     2458uint8_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;
    24622464  bool unalloc = false;
    24632465
     
    24992501    }
    25002502   
    2501     ret_val = talloc_array(NULL, uint8, *name_length);
     2503    ret_val = talloc_array(NULL, uint8_t, *name_length);
    25022504    if(ret_val != NULL)
    25032505    {
     
    25202522/******************************************************************************
    25212523*******************************************************************************/
    2522 REGFI_VK_REC* regfi_parse_vk(REGFI_FILE* file, uint32 offset,
    2523                              uint32 max_size, bool strict)
     2524REGFI_VK_REC* regfi_parse_vk(REGFI_FILE* file, uint32_t offset,
     2525                             uint32_t max_size, bool strict)
    25242526{
    25252527  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;
    25282530  bool unalloc = false;
    25292531
     
    26042606      cell_length+=8;
    26052607
    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);
    26072609    if(ret_val->valuename_raw == NULL)
    26082610    {
     
    26122614
    26132615    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)
    26152617       || length != ret_val->name_length)
    26162618    {
     
    26382640 *
    26392641 ******************************************************************************/
    2640 REGFI_BUFFER regfi_load_data(REGFI_FILE* file, uint32 voffset,
    2641                              uint32 length, bool data_in_offset,
     2642REGFI_BUFFER regfi_load_data(REGFI_FILE* file, uint32_t voffset,
     2643                             uint32_t length, bool data_in_offset,
    26422644                             bool strict)
    26432645{
    26442646  REGFI_BUFFER ret_val;
    2645   uint32 cell_length, offset;
    2646   int32 max_size;
     2647  uint32_t cell_length, offset;
     2648  int32_t max_size;
    26472649  bool unalloc;
    26482650 
     
    27442746 * Parses the common case data records stored in a single cell.
    27452747 ******************************************************************************/
    2746 REGFI_BUFFER regfi_parse_data(REGFI_FILE* file, uint32 offset,
    2747                               uint32 length, bool strict)
     2748REGFI_BUFFER regfi_parse_data(REGFI_FILE* file, uint32_t offset,
     2749                              uint32_t length, bool strict)
    27482750{
    27492751  REGFI_BUFFER ret_val;
    2750   uint32 read_length;
     2752  uint32_t read_length;
    27512753
    27522754  ret_val.buf = NULL;
     
    27602762  }
    27612763
    2762   if((ret_val.buf = talloc_array(NULL, uint8, length)) == NULL)
     2764  if((ret_val.buf = talloc_array(NULL, uint8_t, length)) == NULL)
    27632765    return ret_val;
    27642766  ret_val.len = length;
     
    27832785 *
    27842786 ******************************************************************************/
    2785 REGFI_BUFFER regfi_parse_little_data(REGFI_FILE* file, uint32 voffset,
    2786                                      uint32 length, bool strict)
     2787REGFI_BUFFER regfi_parse_little_data(REGFI_FILE* file, uint32_t voffset,
     2788                                     uint32_t length, bool strict)
    27872789{
    27882790  REGFI_BUFFER ret_val;
    2789   uint8 i;
     2791  uint8_t i;
    27902792
    27912793  ret_val.buf = NULL;
     
    28002802  }
    28012803
    2802   if((ret_val.buf = talloc_array(NULL, uint8, length)) == NULL)
     2804  if((ret_val.buf = talloc_array(NULL, uint8_t, length)) == NULL)
    28032805    return ret_val;
    28042806  ret_val.len = length;
    28052807 
    28062808  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);
    28082810
    28092811  return ret_val;
     
    28122814/******************************************************************************
    28132815*******************************************************************************/
    2814 REGFI_BUFFER regfi_parse_big_data_header(REGFI_FILE* file, uint32 offset,
    2815                                          uint32 max_size, bool strict)
     2816REGFI_BUFFER regfi_parse_big_data_header(REGFI_FILE* file, uint32_t offset,
     2817                                         uint32_t max_size, bool strict)
    28162818{
    28172819  REGFI_BUFFER ret_val;
    2818   uint32 cell_length;
     2820  uint32_t cell_length;
    28192821  bool unalloc;
    28202822
    28212823  /* 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);
    28232825  if(ret_val.buf == NULL)
    28242826    goto fail;
     
    28662868 *
    28672869 ******************************************************************************/
    2868 uint32* regfi_parse_big_data_indirect(REGFI_FILE* file, uint32 offset,
    2869                                       uint16 num_chunks, bool strict)
    2870 {
    2871   uint32* ret_val;
    2872   uint32 indirect_length;
    2873   int32 max_size;
    2874   uint16 i;
     2870uint32_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;
    28752877  bool unalloc;
    28762878
     
    28782880
    28792881  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);
    28842886  if(ret_val == NULL)
    28852887    goto fail;
    28862888
    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),
    28892891                       &indirect_length, &unalloc))
    28902892  {
     
    28982900  for(i=0; i<num_chunks; i++)
    28992901  {
    2900     ret_val[i] = IVAL(ret_val, i*sizeof(uint32));
     2902    ret_val[i] = IVAL(ret_val, i*sizeof(uint32_t));
    29012903    if((ret_val[i] & 0x00000007) != 0)
    29022904      goto fail;
     
    29242926 *  No data in range_list elements.
    29252927 ******************************************************************************/
    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;
     2928range_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;
    29302932  range_list* ret_val;
    2931   uint16 i;
     2933  uint16_t i;
    29322934  bool unalloc;
    29332935 
     
    29652967*******************************************************************************/
    29662968REGFI_BUFFER regfi_load_big_data(REGFI_FILE* file,
    2967                                  uint32 offset, uint32 data_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,
    29692971                                 bool strict)
    29702972{
    29712973  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;
    29752977  REGFI_BUFFER bd_header;
    29762978  range_list* bd_cells = NULL;
     
    30483050    }
    30493051
    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)
    30513053    {
    30523054      regfi_add_message(file, REGFI_MSG_WARN, "Could not seek to chunk while "
     
    30953097  REGFI_HBIN* hbin;
    30963098  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;
    30983100  bool is_unalloc;
    30993101
     
    31423144  return ret_val;
    31433145}
     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****************************************************************************/
     3154void 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****************************************************************************/
     3206time_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 *
    24 * 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.
    56 *
    67 * Copyright (C) 2005,2007,2009 Timothy D. Morgan
  • trunk/lib/winsec.c

    r148 r168  
    1 /*
     1/**
     2 * @file
    23 * This file contains refactored Samba code used to interpret Windows
    34 * Security Descriptors. See:
  • trunk/src/common.c

    r160 r168  
    160160  char* tmp_ptr;
    161161  char* delim;
    162   uint32 ret_val_left, i, tmp_len;
     162  uint32_t ret_val_left, i, tmp_len;
    163163
    164164  if(data == NULL || data->size == 0)
  • trunk/src/reglookup-recover.c

    r161 r168  
    4040
    4141
    42 char* getQuotedData(int fd, uint32 offset, uint32 length)
    43 {
    44   uint8* buf;
     42char* getQuotedData(int fd, uint32_t offset, uint32_t length)
     43{
     44  uint8_t* buf;
    4545  char* quoted_buf;
    46   uint32 len;
     46  uint32_t len;
    4747
    4848  if((lseek(fd, offset, SEEK_SET)) == -1)
    4949    return NULL;
    5050
    51   buf = (uint8*)malloc(length);
     51  buf = (uint8_t*)malloc(length);
    5252  if(buf == NULL)
    5353    return NULL;
     
    7575  char* quoted_raw = "";
    7676
    77   *tmp_time = nt_time_to_unix(&nk->mtime);
     77  *tmp_time = regfi_nt2unix_time(&nk->mtime);
    7878  tmp_time_s = gmtime(tmp_time);
    7979  strftime(mtime, sizeof(mtime), "%Y-%m-%d %H:%M:%S", tmp_time_s);
     
    217217
    218218
    219 int printCell(REGFI_FILE* f, uint32 offset)
     219int printCell(REGFI_FILE* f, uint32_t offset)
    220220{
    221221  char* quoted_buf;
    222   uint32 cell_length;
     222  uint32_t cell_length;
    223223  bool unalloc;
    224224
     
    249249  REGFI_NK_REC* cur_ancestor;
    250250  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;
    253253  REGFI_BUFFER* path_element;
    254254 
     
    278278        path_element = talloc(path_stack, REGFI_BUFFER);
    279279        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,
    281281                                                   key_special_chars);
    282282         
     
    343343
    344344
    345 bool removeRange(range_list* rl, uint32 offset, uint32 length)
    346 {
    347   int32 rm_idx;
     345bool removeRange(range_list* rl, uint32_t offset, uint32_t length)
     346{
     347  int32_t rm_idx;
    348348  const range_list_element* cur_elem;
    349349
     
    405405  const range_list_element* cur_elem;
    406406  REGFI_VK_REC* vk;
    407   uint32 i, j;
     407  uint32_t i, j;
    408408
    409409  for(i=0; i < range_list_size(unalloc_cells); i++)
     
    450450  range_list* bd_cells;
    451451  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;
    454454  bool unalloc;
    455455
     
    583583  const range_list_element* cur_elem;
    584584  REGFI_NK_REC* key;
    585   uint32 i, j;
     585  uint32_t i, j;
    586586  int error_code = 0;
    587587
     
    637637  REGFI_VK_REC* vk;
    638638  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;
    641641
    642642  num_keys=range_list_size(unalloc_keys);
     
    663663           * parsed structure.
    664664           */
    665           values_length = (nk->values->num_values+1)*sizeof(uint32);
     665          values_length = (nk->values->num_values+1)*sizeof(uint32_t);
    666666          if(values_length != (values_length & 0xFFFFFFF8))
    667667            values_length = (values_length & 0xFFFFFFF8) + 8;
     
    727727  const range_list_element* cur_elem;
    728728  REGFI_SK_REC* sk;
    729   uint32 i, j;
     729  uint32_t i, j;
    730730
    731731  for(i=0; i < range_list_size(unalloc_cells); i++)
     
    778778  REGFI_NK_REC* tmp_key;
    779779  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;
    781781 
    782782  /* Process command line arguments */
  • trunk/src/reglookup.c

    r162 r168  
    132132  char* next = NULL;
    133133  char* copy;
    134   uint32 ret_cur = 0;
     134  uint32_t ret_cur = 0;
    135135
    136136  ret_val = (char**)malloc((REGFI_MAX_DEPTH+1+1)*sizeof(char**));
     
    179179void freePath(char** path)
    180180{
    181   uint32 i;
     181  uint32_t i;
    182182
    183183  if(path == NULL)
     
    196196  const REGFI_ITER_POSITION* cur;
    197197  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;
    202202  char* buf;
    203203  char* new_buf;
     
    245245    if(name_len+1 > buf_left)
    246246    {
    247       grow_amt = (uint32)(buf_len/2);
     247      grow_amt = (uint32_t)(buf_len/2);
    248248      buf_len += name_len+1+grow_amt-buf_left;
    249249      if((new_buf = realloc(buf, buf_len)) == NULL)
     
    298298  REGFI_CLASSNAME* classname;
    299299
    300   *tmp_time = nt_time_to_unix(&k->mtime);
     300  *tmp_time = regfi_nt2unix_time(&k->mtime);
    301301  tmp_time_s = gmtime(tmp_time);
    302302  strftime(mtime, sizeof(mtime), "%Y-%m-%d %H:%M:%S", tmp_time_s);
     
    454454  char* tmp_path_joined;
    455455  const char** tmp_path;
    456   uint32 i;
     456  uint32_t i;
    457457 
    458458  if(path == NULL)
     
    557557  REGFI_ITERATOR* iter;
    558558  int retr_path_ret;
    559   uint32 argi, arge;
     559  uint32_t argi, arge;
    560560
    561561  /* Process command line arguments */
Note: See TracChangeset for help on using the changeset viewer.