mirror of
https://github.com/samba-team/samba.git
synced 2025-10-25 19:33:18 +03:00
r46: Add CreateKey function (still working on it)
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
11717ae912
commit
9f13b7c60c
@@ -39,7 +39,6 @@ static void init_winreg_String(struct winreg_String *name, const char *s)
|
||||
struct winreg_Open ## u r; \
|
||||
struct winreg_OpenUnknown unknown; \
|
||||
struct policy_handle *hnd = malloc(sizeof(struct policy_handle)); \
|
||||
TALLOC_CTX *mem_ctx = talloc_init("openhive"); \
|
||||
\
|
||||
unknown.unknown0 = 0x84e0; \
|
||||
unknown.unknown1 = 0x0000; \
|
||||
@@ -47,12 +46,10 @@ static void init_winreg_String(struct winreg_String *name, const char *s)
|
||||
r.in.access_required = SEC_RIGHTS_MAXIMUM_ALLOWED; \
|
||||
r.out.handle = hnd;\
|
||||
\
|
||||
if (!NT_STATUS_IS_OK(dcerpc_winreg_Open ## u(p, mem_ctx, &r))) {\
|
||||
if (!NT_STATUS_IS_OK(dcerpc_winreg_Open ## u(p, h->mem_ctx, &r))) {\
|
||||
printf("Error executing open\n");\
|
||||
return NULL;\
|
||||
}\
|
||||
\
|
||||
talloc_destroy(mem_ctx);\
|
||||
\
|
||||
return hnd;\
|
||||
}
|
||||
@@ -83,7 +80,7 @@ struct {
|
||||
static BOOL rpc_open_registry(REG_HANDLE *h, const char *location, BOOL try_full)
|
||||
{
|
||||
BOOL res = True;
|
||||
struct rpc_data *mydata = malloc(sizeof(struct rpc_data));
|
||||
struct rpc_data *mydata = talloc(h->mem_ctx, sizeof(struct rpc_data));
|
||||
char *binding = strdup(location);
|
||||
NTSTATUS status;
|
||||
|
||||
@@ -124,7 +121,7 @@ static struct policy_handle *rpc_get_key_handle(REG_HANDLE *h, const char *path)
|
||||
char *end = strchr(path+1, '\\');
|
||||
NTSTATUS status;
|
||||
struct winreg_OpenKey r;
|
||||
struct policy_handle *key_handle = malloc(sizeof(struct policy_handle));
|
||||
struct policy_handle *key_handle = talloc(h->mem_ctx, sizeof(struct policy_handle));
|
||||
TALLOC_CTX *mem_ctx;
|
||||
|
||||
if(end) hivename = strndup(path+1, end-path-1);
|
||||
@@ -177,17 +174,16 @@ static BOOL rpc_fetch_subkeys(REG_KEY *parent, int *count, REG_KEY ***subkeys)
|
||||
struct winreg_Time tm;
|
||||
struct rpc_data *mydata = parent->handle->backend_data;
|
||||
int i;
|
||||
REG_KEY **ar = malloc(sizeof(REG_KEY *));
|
||||
REG_KEY **ar = talloc(parent->mem_ctx, sizeof(REG_KEY *));
|
||||
NTSTATUS status = NT_STATUS_OK;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
|
||||
/* List the hives */
|
||||
if(parent->backend_data == parent->handle->backend_data) {
|
||||
REG_KEY **ar = malloc(sizeof(REG_KEY *));
|
||||
for(i = 0; known_hives[i].name; i++) {
|
||||
ar[i] = reg_key_new_rel(known_hives[i].name, parent, NULL);
|
||||
(*count)++;
|
||||
ar = realloc(ar, sizeof(REG_KEY *) * ((*count)+1));
|
||||
ar = talloc_realloc(parent->mem_ctx, ar, sizeof(REG_KEY *) * ((*count)+1));
|
||||
}
|
||||
|
||||
*subkeys = ar;
|
||||
@@ -199,7 +195,6 @@ static BOOL rpc_fetch_subkeys(REG_KEY *parent, int *count, REG_KEY ***subkeys)
|
||||
|
||||
if(!parent->backend_data) return False;
|
||||
|
||||
mem_ctx = talloc_init("enumkey");
|
||||
(*count) = 0;
|
||||
r.in.handle = parent->backend_data;
|
||||
keyname.unknown = 0x0000020a;
|
||||
@@ -215,11 +210,11 @@ static BOOL rpc_fetch_subkeys(REG_KEY *parent, int *count, REG_KEY ***subkeys)
|
||||
r.in.enum_index = i;
|
||||
r.in.unknown = r.out.unknown = 0x0414;
|
||||
r.in.key_name_len = r.out.key_name_len = 0;
|
||||
status = dcerpc_winreg_EnumKey(mydata->pipe, mem_ctx, &r);
|
||||
status = dcerpc_winreg_EnumKey(mydata->pipe, parent->mem_ctx, &r);
|
||||
if(NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(r.out.result)) {
|
||||
ar[(*count)] = reg_key_new_rel(r.out.out_name->name, parent, NULL);
|
||||
(*count)++;
|
||||
ar = realloc(ar, ((*count)+1) * sizeof(REG_KEY *));
|
||||
ar = talloc_realloc(parent->mem_ctx, ar, ((*count)+1) * sizeof(REG_KEY *));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,29 +266,38 @@ static BOOL rpc_fetch_values(REG_KEY *parent, int *count, REG_VAL ***values)
|
||||
r.in.returned_len = &returned_len;
|
||||
r.out.result.v = 0;
|
||||
|
||||
mem_ctx = talloc_init("fetchvalues");
|
||||
while(1) {
|
||||
status = dcerpc_winreg_EnumValue(mydata->pipe, mem_ctx, &r);
|
||||
status = dcerpc_winreg_EnumValue(mydata->pipe, parent->mem_ctx, &r);
|
||||
if(NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(r.out.result)) {
|
||||
r.in.enum_index++;
|
||||
ar[(*count)] = reg_val_new(parent, NULL);
|
||||
ar[(*count)]->name = strdup(r.out.name->name);
|
||||
ar[(*count)]->name = talloc_strdup(ar[*count]->mem_ctx, r.out.name->name);
|
||||
ar[(*count)]->data_type = *r.out.type;
|
||||
ar[(*count)]->data_len = value.len;
|
||||
ar[(*count)]->data_blk = malloc(value.len);
|
||||
ar[(*count)]->data_blk = talloc(ar[*count]->mem_ctx, value.len);
|
||||
memcpy(ar[(*count)]->data_blk, value.buffer, value.len);
|
||||
(*count)++;
|
||||
ar = realloc(ar, ((*count)+1) * sizeof(REG_VAL *));
|
||||
ar = talloc_realloc(parent->mem_ctx, ar, ((*count)+1) * sizeof(REG_VAL *));
|
||||
} else break;
|
||||
}
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
*values = ar;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
static BOOL rpc_add_key(REG_KEY *parent, const char *name)
|
||||
{
|
||||
/* FIXME */
|
||||
return False;
|
||||
}
|
||||
|
||||
static BOOL rpc_del_key(REG_KEY *k)
|
||||
{
|
||||
/* FIXME */
|
||||
return False;
|
||||
}
|
||||
|
||||
static REG_OPS reg_backend_rpc = {
|
||||
.name = "rpc",
|
||||
.open_registry = rpc_open_registry,
|
||||
@@ -302,6 +306,8 @@ static REG_OPS reg_backend_rpc = {
|
||||
.open_key = rpc_open_key,
|
||||
.fetch_subkeys = rpc_fetch_subkeys,
|
||||
.fetch_values = rpc_fetch_values,
|
||||
.add_key = rpc_add_key,
|
||||
.del_key = rpc_del_key,
|
||||
};
|
||||
|
||||
NTSTATUS reg_rpc_init(void)
|
||||
|
||||
Reference in New Issue
Block a user