typedef int (*sec_print_f)(SEC_DESC *sec_desc);
+static
int nt_key_iterator(REGF *regf, REG_KEY *key_tree, int bf, const char *path,
key_print_f key_print, sec_print_f sec_print,
val_print_f val_print);
+static
int nt_val_list_iterator(REGF *regf, VAL_LIST *val_list, int bf, char *path,
int terminal, val_print_f val_print)
{
return 1;
}
+static
int nt_key_list_iterator(REGF *regf, KEY_LIST *key_list, int bf,
const char *path,
key_print_f key_print, sec_print_f sec_print,
return 1;
}
+static
int nt_key_iterator(REGF *regf, REG_KEY *key_tree, int bf, const char *path,
key_print_f key_print, sec_print_f sec_print,
val_print_f val_print)
return 1;
}
+static
REG_KEY *nt_find_key_by_name(REG_KEY *tree, char *key);
/*
* Find key by name in a list ...
* Take the first component and search for that in the list
*/
+static
REG_KEY *nt_find_key_in_list_by_name(KEY_LIST *list, char *key)
{
int i;
* Find key by name in a tree ... We will assume absolute names here, but we
* need the root of the tree ...
*/
+static
REG_KEY *nt_find_key_by_name(REG_KEY *tree, char *key)
{
char *lname = NULL, *c1, *c2;
}
/* Make, delete keys */
-
+static
int nt_delete_val_key(VAL_KEY *val_key)
{
return 1;
}
+static
int nt_delete_val_list(VAL_LIST *vl)
{
int i;
return 1;
}
+static
int nt_delete_reg_key(REG_KEY *key, int delete_name);
+
+static
int nt_delete_key_list(KEY_LIST *key_list, int delete_name)
{
int i;
/*
* Find the key, and if it exists, delete it ...
*/
+static
int nt_delete_key_by_name(REGF *regf, char *name)
{
REG_KEY *key;
}
+static
int nt_delete_sid(DOM_SID *sid)
{
}
+static
int nt_delete_ace(ACE *ace)
{
}
+static
int nt_delete_acl(ACL *acl)
{
return 1;
}
+static
int nt_delete_sec_desc(SEC_DESC *sec_desc)
{
return 1;
}
+static
int nt_delete_key_sec_desc(KEY_SEC_DESC *key_sec_desc)
{
return 1;
}
+static
int nt_delete_reg_key(REG_KEY *key, int delete_name)
{
* Convert a string to a value ...
* FIXME: Error handling and convert this at command parse time ...
*/
+static
void *str_to_val(int type, char *val, int *len)
{
unsigned int *dwordp = NULL;
* An empty name will be converted to "<No Name>" before here
* Hmmm, maybe not. has_name is for that
*/
+static
VAL_KEY *nt_add_reg_value(REG_KEY *key, char *name, int type, char *value)
{
int i;
/*
* Delete a value. We return the value and let the caller deal with it.
*/
+static
VAL_KEY *nt_delete_reg_value(REG_KEY *key, char *name)
{
int i, j;
* often where we want to add values ...
*/
-/*
- * Create a 1 component key name and set its parent to parent
- */
-REG_KEY *nt_create_reg_key1(char *name, REG_KEY *parent)
-{
- REG_KEY *tmp;
-
- if (!name || !*name) return NULL; /* A key's name cannot be empty */
-
- /* There should not be more than one component */
- if (strchr(name, '\\')) return NULL;
-
- if (!(tmp = (REG_KEY *)malloc(sizeof(REG_KEY)))) return NULL;
-
- bzero(tmp, sizeof(REG_KEY));
-
- if (!(tmp->name = strdup(name))) goto error;
-
- error:
- if (tmp) free(tmp);
- return NULL;
-}
-
/*
* Convert a string of the form S-1-5-x[-y-z-r] to a SID
*/
+static
int string_to_sid(DOM_SID **sid, const char *sid_str)
{
int i = 0, auth;
/*
* Create an ACE
*/
+static
ACE *nt_create_ace(int type, int flags, unsigned int perms, const char *sid)
{
ACE *ace;
/*
* Create a default ACL
*/
+static
ACL *nt_create_default_acl(REGF *regf)
{
ACL *acl;
* Create a default security descriptor. We pull in things from env
* if need be
*/
+static
SEC_DESC *nt_create_def_sec_desc(REGF *regf)
{
SEC_DESC *tmp;
* says, but the Owner and Group SIDs can be overwridden from the command line
* and additional ACEs can be applied from the command line etc.
*/
+static
KEY_SEC_DESC *nt_inherit_security(REG_KEY *key)
{
* Create an initial security descriptor and init other structures, if needed
* We assume that the initial security stuff is empty ...
*/
+static
KEY_SEC_DESC *nt_create_init_sec(REGF *regf)
{
KEY_SEC_DESC *tsec = NULL;
/*
* Add a sub-key
*/
+static
REG_KEY *nt_add_reg_key_list(REGF *regf, REG_KEY *key, char * name, int create)
{
int i;
* This routine only adds a key from the root down.
* It calls helper functions to handle sub-key lists and sub-keys
*/
+static
REG_KEY *nt_add_reg_key(REGF *regf, char *name, int create)
{
char *lname = NULL, *c1, *c2;
{ 0, NULL },
};
+static
const char *val_to_str(unsigned int val, const VAL_STR *val_array)
{
int i = 0;
* Convert from UniCode to Ascii ... Does not take into account other lang
* Restrict by ascii_max if > 0
*/
+static
int uni_to_ascii(unsigned char *uni, unsigned char *ascii, int ascii_max,
int uni_max)
{
/*
* Convert a data value to a string for display
*/
+static
int data_to_ascii(unsigned char *datap, int len, int type, char *ascii, int ascii_max)
{
unsigned char *asciip;
}
+static
REG_KEY *nt_get_key_tree(REGF *regf, NK_HDR *nk_hdr, int size, REG_KEY *parent);
+static
int nt_set_regf_input_file(REGF *regf, char *filename)
{
return ((regf->regfile_name = strdup(filename)) != NULL);
}
+static
int nt_set_regf_output_file(REGF *regf, char *filename)
{
return ((regf->outfile_name = strdup(filename)) != NULL);
/* Create a regf structure and init it */
+static
REGF *nt_create_regf(void)
{
REGF *tmp = (REGF *)malloc(sizeof(REGF));
/* Free all the bits and pieces ... Assumes regf was malloc'd */
/* If you add stuff to REGF, add the relevant free bits here */
+static
int nt_free_regf(REGF *regf)
{
if (!regf) return 0;
/* Get the header of the registry. Return a pointer to the structure
* If the mmap'd area has not been allocated, then mmap the input file
*/
+static
REGF_HDR *nt_get_regf_hdr(REGF *regf)
{
if (!regf)
* Validate a regf header
* For now, do nothing, but we should check the checksum
*/
+static
int valid_regf_hdr(REGF_HDR *regf_hdr)
{
if (!regf_hdr) return 0;
/*
* Create a new entry in the map, and increase the size of the map if needed
*/
-
+static
SK_MAP *alloc_sk_map_entry(REGF *regf, KEY_SEC_DESC *tmp, int sk_off)
{
if (!regf->sk_map) { /* Allocate a block of 10 */
* Search for a KEY_SEC_DESC in the sk_map, but don't create one if not
* found
*/
-
+static
KEY_SEC_DESC *lookup_sec_key(SK_MAP *sk_map, int count, int sk_off)
{
int i;
/*
* Allocate a KEY_SEC_DESC if we can't find one in the map
*/
-
+static
KEY_SEC_DESC *lookup_create_sec_key(REGF *regf, SK_MAP *sk_map, int sk_off)
{
KEY_SEC_DESC *tmp = lookup_sec_key(regf->sk_map, regf->sk_count, sk_off);
* Allocate storage and duplicate a SID
* We could allocate the SID to be only the size needed, but I am too lazy.
*/
+static
DOM_SID *dup_sid(DOM_SID *sid)
{
DOM_SID *tmp = (DOM_SID *)malloc(sizeof(DOM_SID));
/*
* Allocate space for an ACE and duplicate the registry encoded one passed in
*/
+static
ACE *dup_ace(REG_ACE *ace)
{
ACE *tmp = NULL;
/*
* Allocate space for an ACL and duplicate the registry encoded one passed in
*/
+static
ACL *dup_acl(REG_ACL *acl)
{
ACL *tmp = NULL;
return tmp;
}
+static
SEC_DESC *process_sec_desc(REGF *regf, REG_SEC_DESC *sec_desc)
{
SEC_DESC *tmp = NULL;
return tmp;
}
+static
KEY_SEC_DESC *process_sk(REGF *regf, SK_HDR *sk_hdr, int sk_off, int size)
{
KEY_SEC_DESC *tmp = NULL;
/*
* Process a VK header and return a value
*/
+static
VAL_KEY *process_vk(REGF *regf, VK_HDR *vk_hdr, int size)
{
char val_name[1024];
/*
* Process a VL Header and return a list of values
*/
+static
VAL_LIST *process_vl(REGF *regf, VL_TYPE vl, int count, int size)
{
int i, vk_off;
/*
* Process an LF Header and return a list of sub-keys
*/
+static
KEY_LIST *process_lf(REGF *regf, LF_HDR *lf_hdr, int size, REG_KEY *parent)
{
int count, i, nk_off;
* This routine is passed an NK_HDR pointer and retrieves the entire tree
* from there down. It returns a REG_KEY *.
*/
+static
REG_KEY *nt_get_key_tree(REGF *regf, NK_HDR *nk_hdr, int size, REG_KEY *parent)
{
REG_KEY *tmp = NULL, *own;
return NULL;
}
+static
int nt_load_registry(REGF *regf)
{
REGF_HDR *regf_hdr;
/*
* Allocate a new hbin block, set up the header for the block etc
*/
+static
HBIN_BLK *nt_create_hbin_blk(REGF *regf, int size)
{
HBIN_BLK *tmp;
* Allocate a unit of space ... and return a pointer as function param
* and the block's offset as a side effect
*/
+static
void *nt_alloc_regf_space(REGF *regf, int size, unsigned int *off)
{
int tmp = 0;
/*
* Compute the size of a SID stored ...
*/
-
+static
unsigned int sid_size(DOM_SID *sid)
{
unsigned int size;
/*
* Compute the size of an ACE on disk from its components
*/
-
+static
unsigned int ace_size(ACE *ace)
{
unsigned int size;
/*
* Compute the size of an ACL from its components ...
*/
+static
unsigned int acl_size(ACL *acl)
{
unsigned int size;
/*
* Compute the size of the sec desc as a self-relative SD
*/
+static
unsigned int sec_desc_size(SEC_DESC *sd)
{
unsigned int size;
/*
* Store a SID at the location provided
*/
-
+static
int nt_store_SID(REGF *regf, DOM_SID *sid, unsigned char *locn)
{
int i;
}
+static
int nt_store_ace(REGF *regf, ACE *ace, unsigned char *locn)
{
int size = 0;
/*
* Store an ACL at the location provided
*/
-
+static
int nt_store_acl(REGF *regf, ACL *acl, unsigned char *locn)
{
int size = 0, i;
* that first, then the owner, then the group SID. So, we do it that way
* too.
*/
+static
unsigned int nt_store_sec_desc(REGF *regf, SEC_DESC *sd, char *locn)
{
REG_SEC_DESC *rsd = (REG_SEC_DESC *)locn;
* If it has already been stored, just get its offset from record
* otherwise, store it and record its offset
*/
-
+static
unsigned int nt_store_security(REGF *regf, KEY_SEC_DESC *sec)
{
int size = 0;
/*
* Store a VAL LIST
*/
-
+static
int nt_store_val_list(REGF *regf, VAL_LIST * values)
{
* We return the offset of the NK struct
* FIXME, FIXME, FIXME: Convert to using SIVAL and SSVAL ...
*/
+static
int nt_store_reg_key(REGF *regf, REG_KEY *key)
{
NK_HDR *nk_hdr;
* We actually create the registry header block and link it to the chain
* of output blocks.
*/
+static
REGF_HDR *nt_get_reg_header(REGF *regf)
{
HBIN_BLK *tmp = NULL;
* The lf fields are layed down after all sub-keys have been layed down, it
* seems, including the whole tree associated with each sub-key.
*/
+static
int nt_store_registry(REGF *regf)
{
REGF_HDR *reg;
char *line;
} CMD_LINE;
+static
void free_val_spec_list(VAL_SPEC_LIST *vl)
{
if (!vl) return;
/*
* Some routines to handle lines of info in the command files
*/
+static
void skip_to_eol(int fd)
{
int rc;
}
}
+static
void free_cmd(CMD *cmd)
{
if (!cmd) return;
}
+static
void free_cmd_line(CMD_LINE *cmd_line)
{
if (cmd_line) {
}
}
+static
void print_line(struct cmd_line *cl)
{
char *pl;
* Otherwise we return a cmd_line *
* Exit if other errors
*/
+static
struct cmd_line *get_cmd_line(int fd)
{
struct cmd_line *cl = (CMD_LINE *)malloc(sizeof(CMD_LINE));
* The value name can be empty. There can only be one empty name in
* a list of values. A value of - removes the value entirely.
*/
-
+static
char *dup_str(char *s, int len)
{
char *nstr;
return nstr;
}
+static
char *parse_name(char *nstr)
{
int len = 0, start = 0;
return dup_str(&nstr[start], len);
}
+static
int parse_value_type(char *tstr)
{
int len = strlen(tstr);
return 0;
}
+static
char *parse_val_str(char *vstr)
{
}
+static
char *parse_value(struct cmd_line *cl, int *vtype, char **val)
{
char *p1 = NULL, *p2 = NULL, *nstr = NULL, *tstr = NULL, *vstr = NULL;
* Assumes that there are no leading and trailing spaces
*/
+static
char *parse_key(struct cmd_line *cl, int *cmd)
{
int start = 1;
* We only check for key or val ...
*/
+static
int parse_line(struct cmd_line *cl)
{
* and compare to the correct value.
* We then seek back to the original location
*/
+static
int regedit4_file_type(int fd)
{
int cur_ofs = 0;
* Run though the data in the line and strip anything after a comment
* char.
*/
+static
void strip_comment(struct cmd_line *cl)
{
int i;
* trim leading space
*/
+static
void trim_leading_spaces(struct cmd_line *cl)
{
int i;