s3-build: re-run make samba3-idl after winreg changes.
[kai/samba.git] / source3 / librpc / gen_ndr / srv_winreg.c
index 6384f65f044b73b42c1b1cd84372260716176cd5..77b0a1c5d2589e5dd9b9b3e9489d1c5dc884887f 100644 (file)
 #include "includes.h"
 #include "librpc/gen_ndr/srv_winreg.h"
 
-static BOOL api_winreg_OpenHKCR(pipes_struct *p)
+static bool api_winreg_OpenHKCR(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_OpenHKCR r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_OpenHKCR");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_OpenHKCR *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_OPENHKCR];
+
+       r = talloc(talloc_tos(), struct winreg_OpenHKCR);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_OpenHKCR(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_OpenHKCR, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.handle = talloc_zero(mem_ctx, struct policy_handle);
-       if (r.out.handle == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.result = _winreg_OpenHKCR(p, &r);
-       
-       if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_OpenHKCR, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
-       if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_OpenHKCR(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_OpenHKCR, r);
        }
-       
-       blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
-}
 
-static BOOL api_winreg_OpenHKCU(pipes_struct *p)
-{
-       struct ndr_pull *pull;
-       struct ndr_push *push;
-       NTSTATUS status;
-       DATA_BLOB blob;
-       struct winreg_OpenHKCU r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_OpenHKCU");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
-       if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+       ZERO_STRUCT(r->out);
+       r->out.handle = talloc_zero(r, struct policy_handle);
+       if (r->out.handle == NULL) {
+               talloc_free(r);
+               return false;
        }
-       
-       pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_OpenHKCU(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_OpenHKCU, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.handle = talloc_zero(mem_ctx, struct policy_handle);
-       if (r.out.handle == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.result = _winreg_OpenHKCU(p, &r);
-       
+
+       r->out.result = _winreg_OpenHKCR(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_OpenHKCU, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_OpenHKCR, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_OpenHKCU(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_OpenHKLM(pipes_struct *p)
+static bool api_winreg_OpenHKCU(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_OpenHKLM r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_OpenHKLM");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_OpenHKCU *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_OPENHKCU];
+
+       r = talloc(talloc_tos(), struct winreg_OpenHKCU);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_OpenHKLM(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_OpenHKLM, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.handle = talloc_zero(mem_ctx, struct policy_handle);
-       if (r.out.handle == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.result = _winreg_OpenHKLM(p, &r);
-       
-       if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_OpenHKLM, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
-       if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_OpenHKLM(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_OpenHKCU, r);
        }
-       
-       blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
-}
 
-static BOOL api_winreg_OpenHKPD(pipes_struct *p)
-{
-       struct ndr_pull *pull;
-       struct ndr_push *push;
-       NTSTATUS status;
-       DATA_BLOB blob;
-       struct winreg_OpenHKPD r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_OpenHKPD");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
-       if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+       ZERO_STRUCT(r->out);
+       r->out.handle = talloc_zero(r, struct policy_handle);
+       if (r->out.handle == NULL) {
+               talloc_free(r);
+               return false;
        }
-       
-       pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_OpenHKPD(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_OpenHKPD, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.handle = talloc_zero(mem_ctx, struct policy_handle);
-       if (r.out.handle == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.result = _winreg_OpenHKPD(p, &r);
-       
+
+       r->out.result = _winreg_OpenHKCU(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_OpenHKPD, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_OpenHKCU, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_OpenHKPD(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_OpenHKU(pipes_struct *p)
+static bool api_winreg_OpenHKLM(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_OpenHKU r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_OpenHKU");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_OpenHKLM *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_OPENHKLM];
+
+       r = talloc(talloc_tos(), struct winreg_OpenHKLM);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_OpenHKU(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_OpenHKU, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.handle = talloc_zero(mem_ctx, struct policy_handle);
-       if (r.out.handle == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.result = _winreg_OpenHKU(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_OpenHKLM, r);
+       }
+
+       ZERO_STRUCT(r->out);
+       r->out.handle = talloc_zero(r, struct policy_handle);
+       if (r->out.handle == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       r->out.result = _winreg_OpenHKLM(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_OpenHKU, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_OpenHKLM, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_OpenHKU(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_CloseKey(pipes_struct *p)
+static bool api_winreg_OpenHKPD(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_CloseKey r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_CloseKey");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_OpenHKPD *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_OPENHKPD];
+
+       r = talloc(talloc_tos(), struct winreg_OpenHKPD);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_CloseKey(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_CloseKey, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.handle = r.in.handle;
-       r.out.result = _winreg_CloseKey(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_OpenHKPD, r);
+       }
+
+       ZERO_STRUCT(r->out);
+       r->out.handle = talloc_zero(r, struct policy_handle);
+       if (r->out.handle == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       r->out.result = _winreg_OpenHKPD(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_CloseKey, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_OpenHKPD, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_CloseKey(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_CreateKey(pipes_struct *p)
+static bool api_winreg_OpenHKU(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_CreateKey r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_CreateKey");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_OpenHKU *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_OPENHKU];
+
+       r = talloc(talloc_tos(), struct winreg_OpenHKU);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_CreateKey(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_CreateKey, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.new_handle = talloc_zero(mem_ctx, struct policy_handle);
-       if (r.out.new_handle == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.action_taken = r.in.action_taken;
-       r.out.result = _winreg_CreateKey(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_OpenHKU, r);
+       }
+
+       ZERO_STRUCT(r->out);
+       r->out.handle = talloc_zero(r, struct policy_handle);
+       if (r->out.handle == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       r->out.result = _winreg_OpenHKU(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_CreateKey, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_OpenHKU, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_CreateKey(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_DeleteKey(pipes_struct *p)
+static bool api_winreg_CloseKey(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_DeleteKey r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_DeleteKey");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_CloseKey *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_CLOSEKEY];
+
+       r = talloc(talloc_tos(), struct winreg_CloseKey);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_DeleteKey(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_DeleteKey, &r);
-       
-       r.out.result = _winreg_DeleteKey(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_CloseKey, r);
+       }
+
+       ZERO_STRUCT(r->out);
+       r->out.handle = r->in.handle;
+       r->out.result = _winreg_CloseKey(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_DeleteKey, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_CloseKey, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_DeleteKey(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_DeleteValue(pipes_struct *p)
+static bool api_winreg_CreateKey(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_DeleteValue r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_DeleteValue");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_CreateKey *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_CREATEKEY];
+
+       r = talloc(talloc_tos(), struct winreg_CreateKey);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_DeleteValue(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_DeleteValue, &r);
-       
-       r.out.result = _winreg_DeleteValue(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_CreateKey, r);
+       }
+
+       ZERO_STRUCT(r->out);
+       r->out.new_handle = talloc_zero(r, struct policy_handle);
+       if (r->out.new_handle == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       r->out.action_taken = r->in.action_taken;
+       r->out.result = _winreg_CreateKey(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_DeleteValue, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_CreateKey, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_DeleteValue(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_EnumKey(pipes_struct *p)
+static bool api_winreg_DeleteKey(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_EnumKey r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_EnumKey");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_DeleteKey *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_DELETEKEY];
+
+       r = talloc(talloc_tos(), struct winreg_DeleteKey);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_EnumKey(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_EnumKey, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.name = r.in.name;
-       r.out.keyclass = r.in.keyclass;
-       r.out.last_changed_time = r.in.last_changed_time;
-       r.out.result = _winreg_EnumKey(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_DeleteKey, r);
+       }
+
+       r->out.result = _winreg_DeleteKey(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_EnumKey, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_DeleteKey, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_EnumKey(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_EnumValue(pipes_struct *p)
+static bool api_winreg_DeleteValue(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_EnumValue r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_EnumValue");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_DeleteValue *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_DELETEVALUE];
+
+       r = talloc(talloc_tos(), struct winreg_DeleteValue);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_EnumValue(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_EnumValue, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.name = r.in.name;
-       r.out.type = r.in.type;
-       r.out.value = r.in.value;
-       r.out.size = r.in.size;
-       r.out.length = r.in.length;
-       r.out.result = _winreg_EnumValue(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_DeleteValue, r);
+       }
+
+       r->out.result = _winreg_DeleteValue(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_EnumValue, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_DeleteValue, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_EnumValue(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_FlushKey(pipes_struct *p)
+static bool api_winreg_EnumKey(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_FlushKey r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_FlushKey");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_EnumKey *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_ENUMKEY];
+
+       r = talloc(talloc_tos(), struct winreg_EnumKey);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_FlushKey(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_FlushKey, &r);
-       
-       r.out.result = _winreg_FlushKey(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_EnumKey, r);
+       }
+
+       ZERO_STRUCT(r->out);
+       r->out.name = r->in.name;
+       r->out.keyclass = r->in.keyclass;
+       r->out.last_changed_time = r->in.last_changed_time;
+       r->out.result = _winreg_EnumKey(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_FlushKey, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_EnumKey, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_FlushKey(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_GetKeySecurity(pipes_struct *p)
+static bool api_winreg_EnumValue(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_GetKeySecurity r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_GetKeySecurity");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_EnumValue *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_ENUMVALUE];
+
+       r = talloc(talloc_tos(), struct winreg_EnumValue);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_GetKeySecurity(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_GetKeySecurity, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.sd = r.in.sd;
-       r.out.result = _winreg_GetKeySecurity(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_EnumValue, r);
+       }
+
+       ZERO_STRUCT(r->out);
+       r->out.name = r->in.name;
+       r->out.type = r->in.type;
+       r->out.value = r->in.value;
+       r->out.size = r->in.size;
+       r->out.length = r->in.length;
+       r->out.result = _winreg_EnumValue(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_GetKeySecurity, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_EnumValue, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_GetKeySecurity(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_LoadKey(pipes_struct *p)
+static bool api_winreg_FlushKey(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_LoadKey r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_LoadKey");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
-       if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+       struct winreg_FlushKey *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_FLUSHKEY];
+
+       r = talloc(talloc_tos(), struct winreg_FlushKey);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
+       if (pull == NULL) {
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_LoadKey(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_LoadKey, &r);
-       
-       r.out.result = _winreg_LoadKey(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_FlushKey, r);
+       }
+
+       r->out.result = _winreg_FlushKey(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_LoadKey, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_FlushKey, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_LoadKey(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_NotifyChangeKeyValue(pipes_struct *p)
+static bool api_winreg_GetKeySecurity(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_NotifyChangeKeyValue r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_NotifyChangeKeyValue");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_GetKeySecurity *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_GETKEYSECURITY];
+
+       r = talloc(talloc_tos(), struct winreg_GetKeySecurity);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_NotifyChangeKeyValue(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_NotifyChangeKeyValue, &r);
-       
-       r.out.result = _winreg_NotifyChangeKeyValue(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_GetKeySecurity, r);
+       }
+
+       ZERO_STRUCT(r->out);
+       r->out.sd = r->in.sd;
+       r->out.result = _winreg_GetKeySecurity(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_NotifyChangeKeyValue, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_GetKeySecurity, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_NotifyChangeKeyValue(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_OpenKey(pipes_struct *p)
+static bool api_winreg_LoadKey(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_OpenKey r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_OpenKey");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_LoadKey *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_LOADKEY];
+
+       r = talloc(talloc_tos(), struct winreg_LoadKey);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_OpenKey(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_OpenKey, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.handle = talloc_zero(mem_ctx, struct policy_handle);
-       if (r.out.handle == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.result = _winreg_OpenKey(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_LoadKey, r);
+       }
+
+       r->out.result = _winreg_LoadKey(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_OpenKey, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_LoadKey, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_OpenKey(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_QueryInfoKey(pipes_struct *p)
+static bool api_winreg_NotifyChangeKeyValue(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_QueryInfoKey r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_QueryInfoKey");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_NotifyChangeKeyValue *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_NOTIFYCHANGEKEYVALUE];
+
+       r = talloc(talloc_tos(), struct winreg_NotifyChangeKeyValue);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_QueryInfoKey(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_QueryInfoKey, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.classname = r.in.classname;
-       r.out.num_subkeys = talloc_zero(mem_ctx, uint32_t);
-       if (r.out.num_subkeys == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.max_subkeylen = talloc_zero(mem_ctx, uint32_t);
-       if (r.out.max_subkeylen == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.max_classlen = talloc_zero(mem_ctx, uint32_t);
-       if (r.out.max_classlen == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.num_values = talloc_zero(mem_ctx, uint32_t);
-       if (r.out.num_values == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.max_valnamelen = talloc_zero(mem_ctx, uint32_t);
-       if (r.out.max_valnamelen == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.max_valbufsize = talloc_zero(mem_ctx, uint32_t);
-       if (r.out.max_valbufsize == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.secdescsize = talloc_zero(mem_ctx, uint32_t);
-       if (r.out.secdescsize == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.last_changed_time = talloc_zero(mem_ctx, NTTIME);
-       if (r.out.last_changed_time == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.result = _winreg_QueryInfoKey(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_NotifyChangeKeyValue, r);
+       }
+
+       r->out.result = _winreg_NotifyChangeKeyValue(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_QueryInfoKey, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_NotifyChangeKeyValue, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_QueryInfoKey(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_QueryValue(pipes_struct *p)
+static bool api_winreg_OpenKey(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_QueryValue r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_QueryValue");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_OpenKey *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_OPENKEY];
+
+       r = talloc(talloc_tos(), struct winreg_OpenKey);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_QueryValue(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_QueryValue, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.type = r.in.type;
-       r.out.data = r.in.data;
-       r.out.data_size = r.in.data_size;
-       r.out.value_length = r.in.value_length;
-       r.out.result = _winreg_QueryValue(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_OpenKey, r);
+       }
+
+       ZERO_STRUCT(r->out);
+       r->out.handle = talloc_zero(r, struct policy_handle);
+       if (r->out.handle == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       r->out.result = _winreg_OpenKey(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_QueryValue, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_OpenKey, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_QueryValue(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_ReplaceKey(pipes_struct *p)
+static bool api_winreg_QueryInfoKey(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_ReplaceKey r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_ReplaceKey");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_QueryInfoKey *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_QUERYINFOKEY];
+
+       r = talloc(talloc_tos(), struct winreg_QueryInfoKey);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_ReplaceKey(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_ReplaceKey, &r);
-       
-       r.out.result = _winreg_ReplaceKey(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_QueryInfoKey, r);
+       }
+
+       ZERO_STRUCT(r->out);
+       r->out.classname = r->in.classname;
+       r->out.num_subkeys = talloc_zero(r, uint32_t);
+       if (r->out.num_subkeys == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       r->out.max_subkeylen = talloc_zero(r, uint32_t);
+       if (r->out.max_subkeylen == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       r->out.max_classlen = talloc_zero(r, uint32_t);
+       if (r->out.max_classlen == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       r->out.num_values = talloc_zero(r, uint32_t);
+       if (r->out.num_values == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       r->out.max_valnamelen = talloc_zero(r, uint32_t);
+       if (r->out.max_valnamelen == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       r->out.max_valbufsize = talloc_zero(r, uint32_t);
+       if (r->out.max_valbufsize == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       r->out.secdescsize = talloc_zero(r, uint32_t);
+       if (r->out.secdescsize == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       r->out.last_changed_time = talloc_zero(r, NTTIME);
+       if (r->out.last_changed_time == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       r->out.result = _winreg_QueryInfoKey(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_ReplaceKey, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_QueryInfoKey, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_ReplaceKey(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_RestoreKey(pipes_struct *p)
+static bool api_winreg_QueryValue(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_RestoreKey r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_RestoreKey");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_QueryValue *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_QUERYVALUE];
+
+       r = talloc(talloc_tos(), struct winreg_QueryValue);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_RestoreKey(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_RestoreKey, &r);
-       
-       r.out.result = _winreg_RestoreKey(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_QueryValue, r);
+       }
+
+       ZERO_STRUCT(r->out);
+       r->out.type = r->in.type;
+       r->out.data = r->in.data;
+       r->out.data_size = r->in.data_size;
+       r->out.data_length = r->in.data_length;
+       r->out.result = _winreg_QueryValue(p, r);
+
+       if (p->rng_fault_state) {
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_QueryValue, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
+       if (push == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       blob = ndr_push_blob(push);
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
+}
+
+static bool api_winreg_ReplaceKey(pipes_struct *p)
+{
+       const struct ndr_interface_call *call;
+       struct ndr_pull *pull;
+       struct ndr_push *push;
+       enum ndr_err_code ndr_err;
+       DATA_BLOB blob;
+       struct winreg_ReplaceKey *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_REPLACEKEY];
+
+       r = talloc(talloc_tos(), struct winreg_ReplaceKey);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
+       if (pull == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull->flags |= LIBNDR_FLAG_REF_ALLOC;
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_ReplaceKey, r);
+       }
+
+       r->out.result = _winreg_ReplaceKey(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_RestoreKey, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_ReplaceKey, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
+       if (push == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       blob = ndr_push_blob(push);
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
+}
+
+static bool api_winreg_RestoreKey(pipes_struct *p)
+{
+       const struct ndr_interface_call *call;
+       struct ndr_pull *pull;
+       struct ndr_push *push;
+       enum ndr_err_code ndr_err;
+       DATA_BLOB blob;
+       struct winreg_RestoreKey *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_RESTOREKEY];
+
+       r = talloc(talloc_tos(), struct winreg_RestoreKey);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
+       if (pull == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull->flags |= LIBNDR_FLAG_REF_ALLOC;
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_RestoreKey, r);
+       }
+
+       r->out.result = _winreg_RestoreKey(p, r);
+
+       if (p->rng_fault_state) {
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_RestoreKey, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
+       if (push == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       blob = ndr_push_blob(push);
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
+}
+
+static bool api_winreg_SaveKey(pipes_struct *p)
+{
+       const struct ndr_interface_call *call;
+       struct ndr_pull *pull;
+       struct ndr_push *push;
+       enum ndr_err_code ndr_err;
+       DATA_BLOB blob;
+       struct winreg_SaveKey *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_SAVEKEY];
+
+       r = talloc(talloc_tos(), struct winreg_SaveKey);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
+       if (pull == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull->flags |= LIBNDR_FLAG_REF_ALLOC;
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_SaveKey, r);
+       }
+
+       r->out.result = _winreg_SaveKey(p, r);
+
+       if (p->rng_fault_state) {
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_SaveKey, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
+       if (push == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       blob = ndr_push_blob(push);
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
+}
+
+static bool api_winreg_SetKeySecurity(pipes_struct *p)
+{
+       const struct ndr_interface_call *call;
+       struct ndr_pull *pull;
+       struct ndr_push *push;
+       enum ndr_err_code ndr_err;
+       DATA_BLOB blob;
+       struct winreg_SetKeySecurity *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_SETKEYSECURITY];
+
+       r = talloc(talloc_tos(), struct winreg_SetKeySecurity);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
+       if (pull == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull->flags |= LIBNDR_FLAG_REF_ALLOC;
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_SetKeySecurity, r);
+       }
+
+       r->out.result = _winreg_SetKeySecurity(p, r);
+
+       if (p->rng_fault_state) {
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_SetKeySecurity, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
+       if (push == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       blob = ndr_push_blob(push);
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
+}
+
+static bool api_winreg_SetValue(pipes_struct *p)
+{
+       const struct ndr_interface_call *call;
+       struct ndr_pull *pull;
+       struct ndr_push *push;
+       enum ndr_err_code ndr_err;
+       DATA_BLOB blob;
+       struct winreg_SetValue *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_SETVALUE];
+
+       r = talloc(talloc_tos(), struct winreg_SetValue);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
+       if (pull == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull->flags |= LIBNDR_FLAG_REF_ALLOC;
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_SetValue, r);
+       }
+
+       r->out.result = _winreg_SetValue(p, r);
+
+       if (p->rng_fault_state) {
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_SetValue, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
+       if (push == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       blob = ndr_push_blob(push);
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
+}
+
+static bool api_winreg_UnLoadKey(pipes_struct *p)
+{
+       const struct ndr_interface_call *call;
+       struct ndr_pull *pull;
+       struct ndr_push *push;
+       enum ndr_err_code ndr_err;
+       DATA_BLOB blob;
+       struct winreg_UnLoadKey *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_UNLOADKEY];
+
+       r = talloc(talloc_tos(), struct winreg_UnLoadKey);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
+       if (pull == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull->flags |= LIBNDR_FLAG_REF_ALLOC;
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_UnLoadKey, r);
+       }
+
+       r->out.result = _winreg_UnLoadKey(p, r);
+
+       if (p->rng_fault_state) {
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_UnLoadKey, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
+       if (push == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       blob = ndr_push_blob(push);
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
+}
+
+static bool api_winreg_InitiateSystemShutdown(pipes_struct *p)
+{
+       const struct ndr_interface_call *call;
+       struct ndr_pull *pull;
+       struct ndr_push *push;
+       enum ndr_err_code ndr_err;
+       DATA_BLOB blob;
+       struct winreg_InitiateSystemShutdown *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_INITIATESYSTEMSHUTDOWN];
+
+       r = talloc(talloc_tos(), struct winreg_InitiateSystemShutdown);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
+       if (pull == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull->flags |= LIBNDR_FLAG_REF_ALLOC;
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_InitiateSystemShutdown, r);
+       }
+
+       r->out.result = _winreg_InitiateSystemShutdown(p, r);
+
+       if (p->rng_fault_state) {
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_InitiateSystemShutdown, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_RestoreKey(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_SaveKey(pipes_struct *p)
+static bool api_winreg_AbortSystemShutdown(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_SaveKey r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_SaveKey");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_AbortSystemShutdown *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_ABORTSYSTEMSHUTDOWN];
+
+       r = talloc(talloc_tos(), struct winreg_AbortSystemShutdown);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_SaveKey(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_SaveKey, &r);
-       
-       r.out.result = _winreg_SaveKey(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_AbortSystemShutdown, r);
+       }
+
+       r->out.result = _winreg_AbortSystemShutdown(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_SaveKey, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_AbortSystemShutdown, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_SaveKey(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_SetKeySecurity(pipes_struct *p)
+static bool api_winreg_GetVersion(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_SetKeySecurity r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_SetKeySecurity");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_GetVersion *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_GETVERSION];
+
+       r = talloc(talloc_tos(), struct winreg_GetVersion);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_SetKeySecurity(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_SetKeySecurity, &r);
-       
-       r.out.result = _winreg_SetKeySecurity(p, &r);
-       
-       if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_SetKeySecurity, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
-       if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_SetKeySecurity(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_GetVersion, r);
        }
-       
-       blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
-}
 
-static BOOL api_winreg_SetValue(pipes_struct *p)
-{
-       struct ndr_pull *pull;
-       struct ndr_push *push;
-       NTSTATUS status;
-       DATA_BLOB blob;
-       struct winreg_SetValue r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_SetValue");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
-       if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+       ZERO_STRUCT(r->out);
+       r->out.version = talloc_zero(r, uint32_t);
+       if (r->out.version == NULL) {
+               talloc_free(r);
+               return false;
        }
-       
-       pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_SetValue(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_SetValue, &r);
-       
-       r.out.result = _winreg_SetValue(p, &r);
-       
+
+       r->out.result = _winreg_GetVersion(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_SetValue, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_GetVersion, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_SetValue(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_UnLoadKey(pipes_struct *p)
+static bool api_winreg_OpenHKCC(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_UnLoadKey r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_UnLoadKey");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_OpenHKCC *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_OPENHKCC];
+
+       r = talloc(talloc_tos(), struct winreg_OpenHKCC);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_UnLoadKey(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_UnLoadKey, &r);
-       
-       r.out.result = _winreg_UnLoadKey(p, &r);
-       
-       if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_UnLoadKey, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
-       if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_UnLoadKey(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_OpenHKCC, r);
        }
-       
-       blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
-}
 
-static BOOL api_winreg_InitiateSystemShutdown(pipes_struct *p)
-{
-       struct ndr_pull *pull;
-       struct ndr_push *push;
-       NTSTATUS status;
-       DATA_BLOB blob;
-       struct winreg_InitiateSystemShutdown r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_InitiateSystemShutdown");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
-       if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+       ZERO_STRUCT(r->out);
+       r->out.handle = talloc_zero(r, struct policy_handle);
+       if (r->out.handle == NULL) {
+               talloc_free(r);
+               return false;
        }
-       
-       pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_InitiateSystemShutdown(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_InitiateSystemShutdown, &r);
-       
-       r.out.result = _winreg_InitiateSystemShutdown(p, &r);
-       
+
+       r->out.result = _winreg_OpenHKCC(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_InitiateSystemShutdown, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_OpenHKCC, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_InitiateSystemShutdown(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_AbortSystemShutdown(pipes_struct *p)
+static bool api_winreg_OpenHKDD(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_AbortSystemShutdown r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_AbortSystemShutdown");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_OpenHKDD *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_OPENHKDD];
+
+       r = talloc(talloc_tos(), struct winreg_OpenHKDD);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_AbortSystemShutdown(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_AbortSystemShutdown, &r);
-       
-       r.out.result = _winreg_AbortSystemShutdown(p, &r);
-       
-       if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_AbortSystemShutdown, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
-       if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_AbortSystemShutdown(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_OpenHKDD, r);
        }
-       
-       blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
-}
 
-static BOOL api_winreg_GetVersion(pipes_struct *p)
-{
-       struct ndr_pull *pull;
-       struct ndr_push *push;
-       NTSTATUS status;
-       DATA_BLOB blob;
-       struct winreg_GetVersion r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_GetVersion");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
-       if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+       ZERO_STRUCT(r->out);
+       r->out.handle = talloc_zero(r, struct policy_handle);
+       if (r->out.handle == NULL) {
+               talloc_free(r);
+               return false;
        }
-       
-       pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_GetVersion(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_GetVersion, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.version = talloc_zero(mem_ctx, uint32_t);
-       if (r.out.version == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.result = _winreg_GetVersion(p, &r);
-       
+
+       r->out.result = _winreg_OpenHKDD(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_GetVersion, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_OpenHKDD, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_GetVersion(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_OpenHKCC(pipes_struct *p)
+static bool api_winreg_QueryMultipleValues(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_OpenHKCC r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_OpenHKCC");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_QueryMultipleValues *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_QUERYMULTIPLEVALUES];
+
+       r = talloc(talloc_tos(), struct winreg_QueryMultipleValues);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_OpenHKCC(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_OpenHKCC, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.handle = talloc_zero(mem_ctx, struct policy_handle);
-       if (r.out.handle == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.result = _winreg_OpenHKCC(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_QueryMultipleValues, r);
+       }
+
+       ZERO_STRUCT(r->out);
+       r->out.values = r->in.values;
+       r->out.buffer = r->in.buffer;
+       r->out.buffer_size = r->in.buffer_size;
+       r->out.result = _winreg_QueryMultipleValues(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_OpenHKCC, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_QueryMultipleValues, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_OpenHKCC(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_OpenHKDD(pipes_struct *p)
+static bool api_winreg_InitiateSystemShutdownEx(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_OpenHKDD r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_OpenHKDD");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_InitiateSystemShutdownEx *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_INITIATESYSTEMSHUTDOWNEX];
+
+       r = talloc(talloc_tos(), struct winreg_InitiateSystemShutdownEx);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_OpenHKDD(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_OpenHKDD, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.handle = talloc_zero(mem_ctx, struct policy_handle);
-       if (r.out.handle == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.result = _winreg_OpenHKDD(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_InitiateSystemShutdownEx, r);
+       }
+
+       r->out.result = _winreg_InitiateSystemShutdownEx(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_OpenHKDD, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_InitiateSystemShutdownEx, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_OpenHKDD(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_QueryMultipleValues(pipes_struct *p)
+static bool api_winreg_SaveKeyEx(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_QueryMultipleValues r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_QueryMultipleValues");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_SaveKeyEx *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_SAVEKEYEX];
+
+       r = talloc(talloc_tos(), struct winreg_SaveKeyEx);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_QueryMultipleValues(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_QueryMultipleValues, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.values = r.in.values;
-       r.out.buffer = r.in.buffer;
-       r.out.buffer_size = r.in.buffer_size;
-       r.out.result = _winreg_QueryMultipleValues(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_SaveKeyEx, r);
+       }
+
+       r->out.result = _winreg_SaveKeyEx(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_QueryMultipleValues, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_SaveKeyEx, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_QueryMultipleValues(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_InitiateSystemShutdownEx(pipes_struct *p)
+static bool api_winreg_OpenHKPT(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_InitiateSystemShutdownEx r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_InitiateSystemShutdownEx");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_OpenHKPT *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_OPENHKPT];
+
+       r = talloc(talloc_tos(), struct winreg_OpenHKPT);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_InitiateSystemShutdownEx(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_InitiateSystemShutdownEx, &r);
-       
-       r.out.result = _winreg_InitiateSystemShutdownEx(p, &r);
-       
-       if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_InitiateSystemShutdownEx, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
-       if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_InitiateSystemShutdownEx(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_OpenHKPT, r);
        }
-       
-       blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
-}
 
-static BOOL api_winreg_SaveKeyEx(pipes_struct *p)
-{
-       struct ndr_pull *pull;
-       struct ndr_push *push;
-       NTSTATUS status;
-       DATA_BLOB blob;
-       struct winreg_SaveKeyEx r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_SaveKeyEx");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
-       if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+       ZERO_STRUCT(r->out);
+       r->out.handle = talloc_zero(r, struct policy_handle);
+       if (r->out.handle == NULL) {
+               talloc_free(r);
+               return false;
        }
-       
-       pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_SaveKeyEx(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_SaveKeyEx, &r);
-       
-       r.out.result = _winreg_SaveKeyEx(p, &r);
-       
+
+       r->out.result = _winreg_OpenHKPT(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_SaveKeyEx, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_OpenHKPT, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_SaveKeyEx(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_OpenHKPT(pipes_struct *p)
+static bool api_winreg_OpenHKPN(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_OpenHKPT r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_OpenHKPT");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_OpenHKPN *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_OPENHKPN];
+
+       r = talloc(talloc_tos(), struct winreg_OpenHKPN);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_OpenHKPT(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_OpenHKPT, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.handle = talloc_zero(mem_ctx, struct policy_handle);
-       if (r.out.handle == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.result = _winreg_OpenHKPT(p, &r);
-       
-       if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_OpenHKPT, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
-       if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_OpenHKPT(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_OpenHKPN, r);
        }
-       
-       blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
-}
 
-static BOOL api_winreg_OpenHKPN(pipes_struct *p)
-{
-       struct ndr_pull *pull;
-       struct ndr_push *push;
-       NTSTATUS status;
-       DATA_BLOB blob;
-       struct winreg_OpenHKPN r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_OpenHKPN");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
-       if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+       ZERO_STRUCT(r->out);
+       r->out.handle = talloc_zero(r, struct policy_handle);
+       if (r->out.handle == NULL) {
+               talloc_free(r);
+               return false;
        }
-       
-       pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_OpenHKPN(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_OpenHKPN, &r);
-       
-       ZERO_STRUCT(r.out);
-       r.out.handle = talloc_zero(mem_ctx, struct policy_handle);
-       if (r.out.handle == NULL) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       r.out.result = _winreg_OpenHKPN(p, &r);
-       
+
+       r->out.result = _winreg_OpenHKPN(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_OpenHKPN, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_OpenHKPN, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_OpenHKPN(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
-static BOOL api_winreg_QueryMultipleValues2(pipes_struct *p)
+static bool api_winreg_QueryMultipleValues2(pipes_struct *p)
 {
+       const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct winreg_QueryMultipleValues2 r;
-       TALLOC_CTX *mem_ctx = talloc_init("api_winreg_QueryMultipleValues2");
-       
-       if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       pull = ndr_pull_init_blob(&blob, mem_ctx);
+       struct winreg_QueryMultipleValues2 *r;
+
+       call = &ndr_table_winreg.calls[NDR_WINREG_QUERYMULTIPLEVALUES2];
+
+       r = talloc(talloc_tos(), struct winreg_QueryMultipleValues2);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
+
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
-       status = ndr_pull_winreg_QueryMultipleValues2(pull, NDR_IN, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_IN_DEBUG(winreg_QueryMultipleValues2, &r);
-       
-       r.out.result = _winreg_QueryMultipleValues2(p, &r);
-       
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(winreg_QueryMultipleValues2, r);
+       }
+
+       r->out.result = _winreg_QueryMultipleValues2(p, r);
+
        if (p->rng_fault_state) {
-               talloc_free(mem_ctx);
-               /* Return True here, srv_pipe_hnd.c will take care */
-               return True;
-       }
-       
-       if (DEBUGLEVEL >= 10)
-               NDR_PRINT_OUT_DEBUG(winreg_QueryMultipleValues2, &r);
-       
-       push = ndr_push_init_ctx(mem_ctx);
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(winreg_QueryMultipleValues2, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
-               talloc_free(mem_ctx);
-               return False;
+               talloc_free(r);
+               return false;
        }
-       
-       status = ndr_push_winreg_QueryMultipleValues2(push, NDR_OUT, &r);
-       if (NT_STATUS_IS_ERR(status)) {
-               talloc_free(mem_ctx);
-               return False;
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
        }
-       
+
        blob = ndr_push_blob(push);
-       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
-               talloc_free(mem_ctx);
-               return False;
-       }
-       
-       talloc_free(mem_ctx);
-       
-       return True;
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
 }
 
 
@@ -2453,5 +2768,5 @@ void winreg_get_pipe_fns(struct api_struct **fns, int *n_fns)
 
 NTSTATUS rpc_winreg_init(void)
 {
-       return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "winreg", "winreg", api_winreg_cmds, sizeof(api_winreg_cmds) / sizeof(struct api_struct));
+       return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "winreg", "winreg", &ndr_table_winreg.syntax_id, api_winreg_cmds, sizeof(api_winreg_cmds) / sizeof(struct api_struct));
 }