summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/utils/regedit.c13
-rw-r--r--source3/utils/regedit_dialog.c23
-rw-r--r--source3/utils/regedit_dialog.h3
3 files changed, 27 insertions, 12 deletions
diff --git a/source3/utils/regedit.c b/source3/utils/regedit.c
index f4139d65b2..27d802b97e 100644
--- a/source3/utils/regedit.c
+++ b/source3/utils/regedit.c
@@ -132,7 +132,8 @@ static void print_help(struct regedit *regedit)
{
const char *khelp = "[n] New Key [s] New Subkey [d] Del Key "
"[LEFT] Ascend [RIGHT] Descend";
- const char *vhelp = "[n] New Value [d] Del Value [ENTER] Edit";
+ const char *vhelp = "[n] New Value [d] Del Value [ENTER] Edit "
+ "[b] Edit binary";
const char *msg = "KEYS";
const char *help = khelp;
const char *genhelp = "[TAB] Switch sections [q] Quit regedit "
@@ -335,6 +336,7 @@ static void handle_tree_input(struct regedit *regedit, int c)
static void handle_value_input(struct regedit *regedit, int c)
{
struct value_item *vitem;
+ bool binmode = false;
switch (c) {
case KEY_DOWN:
@@ -343,6 +345,10 @@ static void handle_value_input(struct regedit *regedit, int c)
case KEY_UP:
menu_driver(regedit->vl->menu, REQ_UP_ITEM);
break;
+ case 'b':
+ case 'B':
+ binmode = true;
+ /* Falthrough... */
case '\n':
case KEY_ENTER:
vitem = item_userptr(current_item(regedit->vl->menu));
@@ -350,7 +356,7 @@ static void handle_value_input(struct regedit *regedit, int c)
struct tree_node *node;
node = item_userptr(current_item(regedit->keys->menu));
dialog_edit_value(regedit, node->key, vitem->type,
- vitem);
+ vitem, binmode);
value_list_load(regedit->vl, node->key);
}
break;
@@ -363,7 +369,8 @@ static void handle_value_input(struct regedit *regedit, int c)
if (sel == DIALOG_OK) {
struct tree_node *node;
node = item_userptr(current_item(regedit->keys->menu));
- dialog_edit_value(regedit, node->key, new_type, NULL);
+ dialog_edit_value(regedit, node->key, new_type, NULL,
+ false);
value_list_load(regedit->vl, node->key);
}
break;
diff --git a/source3/utils/regedit_dialog.c b/source3/utils/regedit_dialog.c
index d05efad142..ddb6819940 100644
--- a/source3/utils/regedit_dialog.c
+++ b/source3/utils/regedit_dialog.c
@@ -593,6 +593,7 @@ struct edit_dialog {
struct hexedit *buf;
enum input_section section;
bool closing;
+ uint32_t mode;
};
static int edit_dialog_free(struct edit_dialog *edit)
@@ -694,7 +695,7 @@ static WERROR set_value(struct edit_dialog *edit, struct registry_key *key,
return WERR_FILE_EXISTS;
}
- switch (type) {
+ switch (edit->mode) {
case REG_DWORD: {
uint32_t val;
int base = 10;
@@ -857,7 +858,7 @@ static WERROR edit_init_dialog(struct edit_dialog *edit, uint32_t type)
NULL
};
- switch (type) {
+ switch (edit->mode) {
case REG_MULTI_SZ:
diaheight = EDIT_HEIGHT_MULTILINE;
winheight = EDIT_FORM_WIN_HEIGHT_MULTILINE;
@@ -894,7 +895,7 @@ static WERROR edit_init_dialog(struct edit_dialog *edit, uint32_t type)
return WERR_OK;
}
-static WERROR edit_init_form(struct edit_dialog *edit, uint32_t type,
+static WERROR edit_init_form(struct edit_dialog *edit,
const struct value_item *vitem)
{
@@ -926,7 +927,7 @@ static WERROR edit_init_form(struct edit_dialog *edit, uint32_t type,
set_field_buffer(edit->field[2], 0, "Data");
field_opts_off(edit->field[2], O_EDIT);
- if (type == REG_BINARY) {
+ if (edit->mode == REG_BINARY) {
size_t len = 8;
const void *buf = NULL;
@@ -947,7 +948,7 @@ static WERROR edit_init_form(struct edit_dialog *edit, uint32_t type,
} else {
int val_rows = EDIT_DATA_HEIGHT_ONELINE;
- if (type == REG_MULTI_SZ) {
+ if (edit->mode == REG_MULTI_SZ) {
val_rows = EDIT_DATA_HEIGHT_MULTILINE;
}
edit->field[FLD_DATA] = new_field(val_rows,
@@ -965,7 +966,7 @@ static WERROR edit_init_form(struct edit_dialog *edit, uint32_t type,
set_field_back(edit->field[FLD_DATA], A_REVERSE);
field_opts_off(edit->field[FLD_DATA],
O_BLANK | O_AUTOSKIP | O_STATIC | O_WRAP);
- if (type == REG_DWORD) {
+ if (edit->mode == REG_DWORD) {
set_field_type(edit->field[FLD_DATA], TYPE_REGEXP,
"^ *([0-9]+|0[xX][0-9a-fA-F]+) *$");
}
@@ -1042,7 +1043,8 @@ static WERROR handle_editor_input(struct edit_dialog *edit,
}
WERROR dialog_edit_value(TALLOC_CTX *ctx, struct registry_key *key,
- uint32_t type, const struct value_item *vitem)
+ uint32_t type, const struct value_item *vitem,
+ bool force_binary)
{
struct edit_dialog *edit;
WERROR rv = WERR_NOMEM;
@@ -1053,11 +1055,16 @@ WERROR dialog_edit_value(TALLOC_CTX *ctx, struct registry_key *key,
}
talloc_set_destructor(edit, edit_dialog_free);
+ edit->mode = type;
+ if (force_binary) {
+ edit->mode = REG_BINARY;
+ }
+
rv = edit_init_dialog(edit, type);
if (!W_ERROR_IS_OK(rv)) {
goto finish;
}
- rv = edit_init_form(edit, type, vitem);
+ rv = edit_init_form(edit, vitem);
if (!W_ERROR_IS_OK(rv)) {
goto finish;
}
diff --git a/source3/utils/regedit_dialog.h b/source3/utils/regedit_dialog.h
index ab171cf4d7..0a0aec87b8 100644
--- a/source3/utils/regedit_dialog.h
+++ b/source3/utils/regedit_dialog.h
@@ -68,7 +68,8 @@ struct registry_key;
struct value_item;
WERROR dialog_edit_value(TALLOC_CTX *ctx, struct registry_key *key,
- uint32_t type, const struct value_item *vitem);
+ uint32_t type, const struct value_item *vitem,
+ bool force_binary);
int dialog_select_type(TALLOC_CTX *ctx, int *type);