include/regfio.h

説明を見る。
00001 /*
00002  * Unix SMB/CIFS implementation.
00003  * Windows NT registry I/O library
00004  * Copyright (c) Gerald (Jerry) Carter               2005
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 /************************************************************
00022  * Most of this information was obtained from 
00023  * http://www.wednesday.demon.co.uk/dosreg.html
00024  * Thanks Nigel!
00025  ***********************************************************/
00026 
00027 
00028 #ifndef _REGFIO_H
00029 #define _REGFIO_H
00030 
00031 /* Macros */
00032  
00033 #define REGF_BLOCKSIZE          0x1000
00034 #define REGF_ALLOC_BLOCK        0x1000
00035 
00036 /* header sizes for various records */
00037 
00038 #define REGF_HDR_SIZE           4
00039 #define HBIN_HDR_SIZE           4
00040 #define HBIN_HEADER_REC_SIZE    0x24
00041 #define REC_HDR_SIZE            2
00042 
00043 #define REGF_OFFSET_NONE        0xffffffff
00044 
00045 /* Flags for the vk records */
00046 
00047 #define VK_FLAG_NAME_PRESENT    0x0001
00048 #define VK_DATA_IN_OFFSET       0x80000000
00049 
00050 /* NK record macros */
00051 
00052 #define NK_TYPE_LINKKEY         0x0010
00053 #define NK_TYPE_NORMALKEY       0x0020
00054 #define NK_TYPE_ROOTKEY         0x002c
00055 
00056 #define HBIN_STORE_REF(x, y)    { x->hbin = y; y->ref_count++ };
00057 #define HBIN_REMOVE_REF(x, y)   { x->hbin = NULL; y->ref_count-- /* if the count == 0; we can clean up */ };
00058 
00059 
00060 /* HBIN block */
00061 struct regf_hbin;
00062 typedef struct regf_hbin {
00063         struct regf_hbin *prev, *next;
00064         uint32 file_off;                /* my offset in the registry file */
00065         uint32 free_off;                /* offset to free space within the hbin record */
00066         uint32 free_size;               /* amount of data left in the block */
00067         int ref_count;                  /* how many active records are pointing to this block (not used currently) */
00068         
00069         char   header[HBIN_HDR_SIZE];   /* "hbin" */
00070         uint32 first_hbin_off;          /* offset from first hbin block */
00071         uint32 block_size;              /* block size of this blockually a multiple of 4096Kb) */
00072 
00073         prs_struct ps;                  /* data */
00074 
00075         BOOL dirty;                     /* has this hbin block been modified? */
00076 } REGF_HBIN;
00077 
00078 /* ??? List -- list of key offsets and hashed names for consistency */
00079 
00080 typedef struct {
00081         uint32 nk_off;
00082         uint8 keycheck[sizeof(uint32)];
00083         char *fullname;
00084 } REGF_HASH_REC;
00085 
00086 typedef struct {
00087         REGF_HBIN *hbin;        /* pointer to HBIN record (in memory) containing this nk record */
00088         uint32 hbin_off;        /* offset from beginning of this hbin block */
00089         uint32 rec_size;        /* ((start_offset - end_offset) & 0xfffffff8) */
00090 
00091         char header[REC_HDR_SIZE];
00092         uint16 num_keys;
00093         REGF_HASH_REC *hashes;
00094 } REGF_LF_REC;
00095 
00096 /* Key Value */
00097 
00098 typedef struct {
00099         REGF_HBIN *hbin;        /* pointer to HBIN record (in memory) containing this nk record */
00100         uint32 hbin_off;        /* offset from beginning of this hbin block */
00101         uint32 rec_size;        /* ((start_offset - end_offset) & 0xfffffff8) */
00102         uint32 rec_off;         /* offset stored in the value list */
00103         
00104         char header[REC_HDR_SIZE];
00105         char *valuename;
00106         uint32 data_size;
00107         uint32 data_off;
00108         uint8  *data;
00109         uint32 type;
00110         uint16 flag;
00111 } REGF_VK_REC;
00112 
00113 
00114 /* Key Security */
00115 struct _regf_sk_rec;
00116 
00117 typedef struct _regf_sk_rec {
00118         struct _regf_sk_rec *next, *prev;
00119         REGF_HBIN *hbin;        /* pointer to HBIN record (in memory) containing this nk record */
00120         uint32 hbin_off;        /* offset from beginning of this hbin block */
00121         uint32 rec_size;        /* ((start_offset - end_offset) & 0xfffffff8) */
00122 
00123         uint32 sk_off;          /* offset parsed from NK record used as a key
00124                                    to lookup reference to this SK record */
00125 
00126         char header[REC_HDR_SIZE];
00127         uint32 prev_sk_off;
00128         uint32 next_sk_off;
00129         uint32 ref_count;
00130         uint32 size;
00131         SEC_DESC *sec_desc;
00132 } REGF_SK_REC;
00133 
00134 /* Key Name */ 
00135 
00136 typedef struct {
00137         REGF_HBIN *hbin;        /* pointer to HBIN record (in memory) containing this nk record */
00138         uint32 hbin_off;        /* offset from beginning of this hbin block */
00139         uint32 subkey_index;    /* index to next subkey record to return */
00140         uint32 rec_size;        /* ((start_offset - end_offset) & 0xfffffff8) */
00141         
00142         /* header information */
00143         
00144         char header[REC_HDR_SIZE];
00145         uint16 key_type;
00146         NTTIME mtime;
00147         uint32 parent_off;      /* back pointer in registry hive */
00148         uint32 classname_off;   
00149         char *classname;
00150         char *keyname;
00151 
00152         /* max lengths */
00153 
00154         uint32 max_bytes_subkeyname;            /* max subkey name * 2 */
00155         uint32 max_bytes_subkeyclassname;       /* max subkey classname length (as if) */
00156         uint32 max_bytes_valuename;             /* max valuename * 2 */
00157         uint32 max_bytes_value;                 /* max value data size */
00158 
00159         /* unknowns */
00160 
00161         uint32 unk_index;                       /* nigel says run time index ? */
00162         
00163         /* children */
00164         
00165         uint32 num_subkeys;
00166         uint32 subkeys_off;     /* hash records that point to NK records */     
00167         uint32 num_values;
00168         uint32 values_off;      /* value lists which point to VK records */
00169         uint32 sk_off;          /* offset to SK record */
00170         
00171         /* link in the other records here */
00172         
00173         REGF_LF_REC subkeys;
00174         REGF_VK_REC *values;
00175         REGF_SK_REC *sec_desc;
00176         
00177 } REGF_NK_REC;
00178 
00179 /* REGF block */
00180  
00181 typedef struct {
00182         /* run time information */
00183 
00184         int fd;                         /* file descriptor */
00185         int open_flags;                 /* flags passed to the open() call */
00186         TALLOC_CTX *mem_ctx;            /* memory context for run-time file access information */
00187         REGF_HBIN *block_list;          /* list of open hbin blocks */
00188 
00189         /* file format information */
00190 
00191         char   header[REGF_HDR_SIZE];   /* "regf" */
00192         uint32 data_offset;             /* offset to record in the first (or any?) hbin block */
00193         uint32 last_block;              /* offset to last hbin block in file */
00194         uint32 checksum;                /* XOR of bytes 0x0000 - 0x01FB */
00195         NTTIME mtime;
00196         
00197         REGF_SK_REC *sec_desc_list;     /* list of security descriptors referenced by NK records */
00198 
00199         /* unknowns used to simply writing */
00200         
00201         uint32 unknown1;
00202         uint32 unknown2;
00203         uint32 unknown3;
00204         uint32 unknown4;
00205         uint32 unknown5;
00206         uint32 unknown6;
00207         
00208 } REGF_FILE;
00209 
00210 /* Function Declarations */
00211  
00212 REGF_FILE*    regfio_open( const char *filename, int flags, int mode );
00213 int           regfio_close( REGF_FILE *r );
00214 
00215 REGF_NK_REC*  regfio_rootkey( REGF_FILE *file );
00216 REGF_NK_REC*  regfio_fetch_subkey( REGF_FILE *file, REGF_NK_REC *nk );
00217 REGF_NK_REC*  regfio_write_key ( REGF_FILE *file, const char *name,
00218                                  REGVAL_CTR *values, REGSUBKEY_CTR *subkeys,
00219                                  SEC_DESC *sec_desc, REGF_NK_REC *parent );
00220 
00221 
00222 #endif  /* _REGFIO_H */
00223 

Sambaに対してSat Aug 29 21:22:55 2009に生成されました。  doxygen 1.4.7