librpc/gen_ndr
[metze/samba/wip.git] / source3 / librpc / gen_ndr / ndr_winreg_c.c
1 /* client functions auto-generated by pidl */
2
3 #include "includes.h"
4 #include <tevent.h>
5 #include "lib/util/tevent_ntstatus.h"
6 #include "librpc/gen_ndr/ndr_winreg.h"
7 #include "librpc/gen_ndr/ndr_winreg_c.h"
8
9 /* winreg - client functions generated by pidl */
10
11 struct dcerpc_winreg_OpenHKCR_r_state {
12         TALLOC_CTX *out_mem_ctx;
13 };
14
15 static void dcerpc_winreg_OpenHKCR_r_done(struct tevent_req *subreq);
16
17 struct tevent_req *dcerpc_winreg_OpenHKCR_r_send(TALLOC_CTX *mem_ctx,
18         struct tevent_context *ev,
19         struct dcerpc_binding_handle *h,
20         struct winreg_OpenHKCR *r)
21 {
22         struct tevent_req *req;
23         struct dcerpc_winreg_OpenHKCR_r_state *state;
24         struct tevent_req *subreq;
25
26         req = tevent_req_create(mem_ctx, &state,
27                                 struct dcerpc_winreg_OpenHKCR_r_state);
28         if (req == NULL) {
29                 return NULL;
30         }
31
32         state->out_mem_ctx = talloc_new(state);
33         if (tevent_req_nomem(state->out_mem_ctx, req)) {
34                 return tevent_req_post(req, ev);
35         }
36
37         subreq = dcerpc_binding_handle_call_send(state, ev, h,
38                         NULL, &ndr_table_winreg,
39                         NDR_WINREG_OPENHKCR, state->out_mem_ctx, r);
40         if (tevent_req_nomem(subreq, req)) {
41                 return tevent_req_post(req, ev);
42         }
43         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKCR_r_done, req);
44
45         return req;
46 }
47
48 static void dcerpc_winreg_OpenHKCR_r_done(struct tevent_req *subreq)
49 {
50         struct tevent_req *req =
51                 tevent_req_callback_data(subreq,
52                 struct tevent_req);
53         NTSTATUS status;
54
55         status = dcerpc_binding_handle_call_recv(subreq);
56         if (!NT_STATUS_IS_OK(status)) {
57                 tevent_req_nterror(req, status);
58                 return;
59         }
60
61         tevent_req_done(req);
62 }
63
64 NTSTATUS dcerpc_winreg_OpenHKCR_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
65 {
66         struct dcerpc_winreg_OpenHKCR_r_state *state =
67                 tevent_req_data(req,
68                 struct dcerpc_winreg_OpenHKCR_r_state);
69         NTSTATUS status;
70
71         if (tevent_req_is_nterror(req, &status)) {
72                 tevent_req_received(req);
73                 return status;
74         }
75
76         talloc_steal(mem_ctx, state->out_mem_ctx);
77
78         tevent_req_received(req);
79         return NT_STATUS_OK;
80 }
81
82 NTSTATUS dcerpc_winreg_OpenHKCR_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_OpenHKCR *r)
83 {
84         NTSTATUS status;
85
86         status = dcerpc_binding_handle_call(h,
87                         NULL, &ndr_table_winreg,
88                         NDR_WINREG_OPENHKCR, mem_ctx, r);
89
90         return status;
91 }
92
93 NTSTATUS dcerpc_winreg_OpenHKCR_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_OpenHKCR *r)
94 {
95         NTSTATUS status;
96
97         status = dcerpc_winreg_OpenHKCR_r(p->binding_handle, mem_ctx, r);
98
99         if (NT_STATUS_IS_RPC(status)) {
100                 status = NT_STATUS_NET_WRITE_FAULT;
101         }
102
103         return status;
104 }
105
106 struct dcerpc_winreg_OpenHKCR_state {
107         struct winreg_OpenHKCR orig;
108         struct winreg_OpenHKCR tmp;
109         TALLOC_CTX *out_mem_ctx;
110 };
111
112 static void dcerpc_winreg_OpenHKCR_done(struct tevent_req *subreq);
113
114 struct tevent_req *dcerpc_winreg_OpenHKCR_send(TALLOC_CTX *mem_ctx,
115                                                struct tevent_context *ev,
116                                                struct dcerpc_binding_handle *h,
117                                                uint16_t *_system_name /* [in] [unique] */,
118                                                uint32_t _access_mask /* [in]  */,
119                                                struct policy_handle *_handle /* [out] [ref] */)
120 {
121         struct tevent_req *req;
122         struct dcerpc_winreg_OpenHKCR_state *state;
123         struct tevent_req *subreq;
124
125         req = tevent_req_create(mem_ctx, &state,
126                                 struct dcerpc_winreg_OpenHKCR_state);
127         if (req == NULL) {
128                 return NULL;
129         }
130         state->out_mem_ctx = NULL;
131
132         /* In parameters */
133         state->orig.in.system_name = _system_name;
134         state->orig.in.access_mask = _access_mask;
135
136         /* Out parameters */
137         state->orig.out.handle = _handle;
138
139         /* Result */
140         ZERO_STRUCT(state->orig.out.result);
141
142         state->out_mem_ctx = talloc_named_const(state, 0,
143                              "dcerpc_winreg_OpenHKCR_out_memory");
144         if (tevent_req_nomem(state->out_mem_ctx, req)) {
145                 return tevent_req_post(req, ev);
146         }
147
148         /* make a temporary copy, that we pass to the dispatch function */
149         state->tmp = state->orig;
150
151         subreq = dcerpc_winreg_OpenHKCR_r_send(state, ev, h, &state->tmp);
152         if (tevent_req_nomem(subreq, req)) {
153                 return tevent_req_post(req, ev);
154         }
155         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKCR_done, req);
156         return req;
157 }
158
159 static void dcerpc_winreg_OpenHKCR_done(struct tevent_req *subreq)
160 {
161         struct tevent_req *req = tevent_req_callback_data(
162                 subreq, struct tevent_req);
163         struct dcerpc_winreg_OpenHKCR_state *state = tevent_req_data(
164                 req, struct dcerpc_winreg_OpenHKCR_state);
165         NTSTATUS status;
166         TALLOC_CTX *mem_ctx;
167
168         if (state->out_mem_ctx) {
169                 mem_ctx = state->out_mem_ctx;
170         } else {
171                 mem_ctx = state;
172         }
173
174         status = dcerpc_winreg_OpenHKCR_r_recv(subreq, mem_ctx);
175         TALLOC_FREE(subreq);
176         if (!NT_STATUS_IS_OK(status)) {
177                 tevent_req_nterror(req, status);
178                 return;
179         }
180
181         /* Copy out parameters */
182         *state->orig.out.handle = *state->tmp.out.handle;
183
184         /* Copy result */
185         state->orig.out.result = state->tmp.out.result;
186
187         /* Reset temporary structure */
188         ZERO_STRUCT(state->tmp);
189
190         tevent_req_done(req);
191 }
192
193 NTSTATUS dcerpc_winreg_OpenHKCR_recv(struct tevent_req *req,
194                                      TALLOC_CTX *mem_ctx,
195                                      WERROR *result)
196 {
197         struct dcerpc_winreg_OpenHKCR_state *state = tevent_req_data(
198                 req, struct dcerpc_winreg_OpenHKCR_state);
199         NTSTATUS status;
200
201         if (tevent_req_is_nterror(req, &status)) {
202                 tevent_req_received(req);
203                 return status;
204         }
205
206         /* Steal possible out parameters to the callers context */
207         talloc_steal(mem_ctx, state->out_mem_ctx);
208
209         /* Return result */
210         *result = state->orig.out.result;
211
212         tevent_req_received(req);
213         return NT_STATUS_OK;
214 }
215
216 NTSTATUS dcerpc_winreg_OpenHKCR(struct dcerpc_binding_handle *h,
217                                 TALLOC_CTX *mem_ctx,
218                                 uint16_t *_system_name /* [in] [unique] */,
219                                 uint32_t _access_mask /* [in]  */,
220                                 struct policy_handle *_handle /* [out] [ref] */,
221                                 WERROR *result)
222 {
223         struct winreg_OpenHKCR r;
224         NTSTATUS status;
225
226         /* In parameters */
227         r.in.system_name = _system_name;
228         r.in.access_mask = _access_mask;
229
230         status = dcerpc_winreg_OpenHKCR_r(h, mem_ctx, &r);
231         if (!NT_STATUS_IS_OK(status)) {
232                 return status;
233         }
234
235         /* Return variables */
236         *_handle = *r.out.handle;
237
238         /* Return result */
239         *result = r.out.result;
240
241         return NT_STATUS_OK;
242 }
243
244 struct dcerpc_winreg_OpenHKCU_r_state {
245         TALLOC_CTX *out_mem_ctx;
246 };
247
248 static void dcerpc_winreg_OpenHKCU_r_done(struct tevent_req *subreq);
249
250 struct tevent_req *dcerpc_winreg_OpenHKCU_r_send(TALLOC_CTX *mem_ctx,
251         struct tevent_context *ev,
252         struct dcerpc_binding_handle *h,
253         struct winreg_OpenHKCU *r)
254 {
255         struct tevent_req *req;
256         struct dcerpc_winreg_OpenHKCU_r_state *state;
257         struct tevent_req *subreq;
258
259         req = tevent_req_create(mem_ctx, &state,
260                                 struct dcerpc_winreg_OpenHKCU_r_state);
261         if (req == NULL) {
262                 return NULL;
263         }
264
265         state->out_mem_ctx = talloc_new(state);
266         if (tevent_req_nomem(state->out_mem_ctx, req)) {
267                 return tevent_req_post(req, ev);
268         }
269
270         subreq = dcerpc_binding_handle_call_send(state, ev, h,
271                         NULL, &ndr_table_winreg,
272                         NDR_WINREG_OPENHKCU, state->out_mem_ctx, r);
273         if (tevent_req_nomem(subreq, req)) {
274                 return tevent_req_post(req, ev);
275         }
276         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKCU_r_done, req);
277
278         return req;
279 }
280
281 static void dcerpc_winreg_OpenHKCU_r_done(struct tevent_req *subreq)
282 {
283         struct tevent_req *req =
284                 tevent_req_callback_data(subreq,
285                 struct tevent_req);
286         NTSTATUS status;
287
288         status = dcerpc_binding_handle_call_recv(subreq);
289         if (!NT_STATUS_IS_OK(status)) {
290                 tevent_req_nterror(req, status);
291                 return;
292         }
293
294         tevent_req_done(req);
295 }
296
297 NTSTATUS dcerpc_winreg_OpenHKCU_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
298 {
299         struct dcerpc_winreg_OpenHKCU_r_state *state =
300                 tevent_req_data(req,
301                 struct dcerpc_winreg_OpenHKCU_r_state);
302         NTSTATUS status;
303
304         if (tevent_req_is_nterror(req, &status)) {
305                 tevent_req_received(req);
306                 return status;
307         }
308
309         talloc_steal(mem_ctx, state->out_mem_ctx);
310
311         tevent_req_received(req);
312         return NT_STATUS_OK;
313 }
314
315 NTSTATUS dcerpc_winreg_OpenHKCU_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_OpenHKCU *r)
316 {
317         NTSTATUS status;
318
319         status = dcerpc_binding_handle_call(h,
320                         NULL, &ndr_table_winreg,
321                         NDR_WINREG_OPENHKCU, mem_ctx, r);
322
323         return status;
324 }
325
326 NTSTATUS dcerpc_winreg_OpenHKCU_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_OpenHKCU *r)
327 {
328         NTSTATUS status;
329
330         status = dcerpc_winreg_OpenHKCU_r(p->binding_handle, mem_ctx, r);
331
332         if (NT_STATUS_IS_RPC(status)) {
333                 status = NT_STATUS_NET_WRITE_FAULT;
334         }
335
336         return status;
337 }
338
339 struct dcerpc_winreg_OpenHKCU_state {
340         struct winreg_OpenHKCU orig;
341         struct winreg_OpenHKCU tmp;
342         TALLOC_CTX *out_mem_ctx;
343 };
344
345 static void dcerpc_winreg_OpenHKCU_done(struct tevent_req *subreq);
346
347 struct tevent_req *dcerpc_winreg_OpenHKCU_send(TALLOC_CTX *mem_ctx,
348                                                struct tevent_context *ev,
349                                                struct dcerpc_binding_handle *h,
350                                                uint16_t *_system_name /* [in] [unique] */,
351                                                uint32_t _access_mask /* [in]  */,
352                                                struct policy_handle *_handle /* [out] [ref] */)
353 {
354         struct tevent_req *req;
355         struct dcerpc_winreg_OpenHKCU_state *state;
356         struct tevent_req *subreq;
357
358         req = tevent_req_create(mem_ctx, &state,
359                                 struct dcerpc_winreg_OpenHKCU_state);
360         if (req == NULL) {
361                 return NULL;
362         }
363         state->out_mem_ctx = NULL;
364
365         /* In parameters */
366         state->orig.in.system_name = _system_name;
367         state->orig.in.access_mask = _access_mask;
368
369         /* Out parameters */
370         state->orig.out.handle = _handle;
371
372         /* Result */
373         ZERO_STRUCT(state->orig.out.result);
374
375         state->out_mem_ctx = talloc_named_const(state, 0,
376                              "dcerpc_winreg_OpenHKCU_out_memory");
377         if (tevent_req_nomem(state->out_mem_ctx, req)) {
378                 return tevent_req_post(req, ev);
379         }
380
381         /* make a temporary copy, that we pass to the dispatch function */
382         state->tmp = state->orig;
383
384         subreq = dcerpc_winreg_OpenHKCU_r_send(state, ev, h, &state->tmp);
385         if (tevent_req_nomem(subreq, req)) {
386                 return tevent_req_post(req, ev);
387         }
388         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKCU_done, req);
389         return req;
390 }
391
392 static void dcerpc_winreg_OpenHKCU_done(struct tevent_req *subreq)
393 {
394         struct tevent_req *req = tevent_req_callback_data(
395                 subreq, struct tevent_req);
396         struct dcerpc_winreg_OpenHKCU_state *state = tevent_req_data(
397                 req, struct dcerpc_winreg_OpenHKCU_state);
398         NTSTATUS status;
399         TALLOC_CTX *mem_ctx;
400
401         if (state->out_mem_ctx) {
402                 mem_ctx = state->out_mem_ctx;
403         } else {
404                 mem_ctx = state;
405         }
406
407         status = dcerpc_winreg_OpenHKCU_r_recv(subreq, mem_ctx);
408         TALLOC_FREE(subreq);
409         if (!NT_STATUS_IS_OK(status)) {
410                 tevent_req_nterror(req, status);
411                 return;
412         }
413
414         /* Copy out parameters */
415         *state->orig.out.handle = *state->tmp.out.handle;
416
417         /* Copy result */
418         state->orig.out.result = state->tmp.out.result;
419
420         /* Reset temporary structure */
421         ZERO_STRUCT(state->tmp);
422
423         tevent_req_done(req);
424 }
425
426 NTSTATUS dcerpc_winreg_OpenHKCU_recv(struct tevent_req *req,
427                                      TALLOC_CTX *mem_ctx,
428                                      WERROR *result)
429 {
430         struct dcerpc_winreg_OpenHKCU_state *state = tevent_req_data(
431                 req, struct dcerpc_winreg_OpenHKCU_state);
432         NTSTATUS status;
433
434         if (tevent_req_is_nterror(req, &status)) {
435                 tevent_req_received(req);
436                 return status;
437         }
438
439         /* Steal possible out parameters to the callers context */
440         talloc_steal(mem_ctx, state->out_mem_ctx);
441
442         /* Return result */
443         *result = state->orig.out.result;
444
445         tevent_req_received(req);
446         return NT_STATUS_OK;
447 }
448
449 NTSTATUS dcerpc_winreg_OpenHKCU(struct dcerpc_binding_handle *h,
450                                 TALLOC_CTX *mem_ctx,
451                                 uint16_t *_system_name /* [in] [unique] */,
452                                 uint32_t _access_mask /* [in]  */,
453                                 struct policy_handle *_handle /* [out] [ref] */,
454                                 WERROR *result)
455 {
456         struct winreg_OpenHKCU r;
457         NTSTATUS status;
458
459         /* In parameters */
460         r.in.system_name = _system_name;
461         r.in.access_mask = _access_mask;
462
463         status = dcerpc_winreg_OpenHKCU_r(h, mem_ctx, &r);
464         if (!NT_STATUS_IS_OK(status)) {
465                 return status;
466         }
467
468         /* Return variables */
469         *_handle = *r.out.handle;
470
471         /* Return result */
472         *result = r.out.result;
473
474         return NT_STATUS_OK;
475 }
476
477 struct dcerpc_winreg_OpenHKLM_r_state {
478         TALLOC_CTX *out_mem_ctx;
479 };
480
481 static void dcerpc_winreg_OpenHKLM_r_done(struct tevent_req *subreq);
482
483 struct tevent_req *dcerpc_winreg_OpenHKLM_r_send(TALLOC_CTX *mem_ctx,
484         struct tevent_context *ev,
485         struct dcerpc_binding_handle *h,
486         struct winreg_OpenHKLM *r)
487 {
488         struct tevent_req *req;
489         struct dcerpc_winreg_OpenHKLM_r_state *state;
490         struct tevent_req *subreq;
491
492         req = tevent_req_create(mem_ctx, &state,
493                                 struct dcerpc_winreg_OpenHKLM_r_state);
494         if (req == NULL) {
495                 return NULL;
496         }
497
498         state->out_mem_ctx = talloc_new(state);
499         if (tevent_req_nomem(state->out_mem_ctx, req)) {
500                 return tevent_req_post(req, ev);
501         }
502
503         subreq = dcerpc_binding_handle_call_send(state, ev, h,
504                         NULL, &ndr_table_winreg,
505                         NDR_WINREG_OPENHKLM, state->out_mem_ctx, r);
506         if (tevent_req_nomem(subreq, req)) {
507                 return tevent_req_post(req, ev);
508         }
509         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKLM_r_done, req);
510
511         return req;
512 }
513
514 static void dcerpc_winreg_OpenHKLM_r_done(struct tevent_req *subreq)
515 {
516         struct tevent_req *req =
517                 tevent_req_callback_data(subreq,
518                 struct tevent_req);
519         NTSTATUS status;
520
521         status = dcerpc_binding_handle_call_recv(subreq);
522         if (!NT_STATUS_IS_OK(status)) {
523                 tevent_req_nterror(req, status);
524                 return;
525         }
526
527         tevent_req_done(req);
528 }
529
530 NTSTATUS dcerpc_winreg_OpenHKLM_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
531 {
532         struct dcerpc_winreg_OpenHKLM_r_state *state =
533                 tevent_req_data(req,
534                 struct dcerpc_winreg_OpenHKLM_r_state);
535         NTSTATUS status;
536
537         if (tevent_req_is_nterror(req, &status)) {
538                 tevent_req_received(req);
539                 return status;
540         }
541
542         talloc_steal(mem_ctx, state->out_mem_ctx);
543
544         tevent_req_received(req);
545         return NT_STATUS_OK;
546 }
547
548 NTSTATUS dcerpc_winreg_OpenHKLM_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_OpenHKLM *r)
549 {
550         NTSTATUS status;
551
552         status = dcerpc_binding_handle_call(h,
553                         NULL, &ndr_table_winreg,
554                         NDR_WINREG_OPENHKLM, mem_ctx, r);
555
556         return status;
557 }
558
559 NTSTATUS dcerpc_winreg_OpenHKLM_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_OpenHKLM *r)
560 {
561         NTSTATUS status;
562
563         status = dcerpc_winreg_OpenHKLM_r(p->binding_handle, mem_ctx, r);
564
565         if (NT_STATUS_IS_RPC(status)) {
566                 status = NT_STATUS_NET_WRITE_FAULT;
567         }
568
569         return status;
570 }
571
572 struct dcerpc_winreg_OpenHKLM_state {
573         struct winreg_OpenHKLM orig;
574         struct winreg_OpenHKLM tmp;
575         TALLOC_CTX *out_mem_ctx;
576 };
577
578 static void dcerpc_winreg_OpenHKLM_done(struct tevent_req *subreq);
579
580 struct tevent_req *dcerpc_winreg_OpenHKLM_send(TALLOC_CTX *mem_ctx,
581                                                struct tevent_context *ev,
582                                                struct dcerpc_binding_handle *h,
583                                                uint16_t *_system_name /* [in] [unique] */,
584                                                uint32_t _access_mask /* [in]  */,
585                                                struct policy_handle *_handle /* [out] [ref] */)
586 {
587         struct tevent_req *req;
588         struct dcerpc_winreg_OpenHKLM_state *state;
589         struct tevent_req *subreq;
590
591         req = tevent_req_create(mem_ctx, &state,
592                                 struct dcerpc_winreg_OpenHKLM_state);
593         if (req == NULL) {
594                 return NULL;
595         }
596         state->out_mem_ctx = NULL;
597
598         /* In parameters */
599         state->orig.in.system_name = _system_name;
600         state->orig.in.access_mask = _access_mask;
601
602         /* Out parameters */
603         state->orig.out.handle = _handle;
604
605         /* Result */
606         ZERO_STRUCT(state->orig.out.result);
607
608         state->out_mem_ctx = talloc_named_const(state, 0,
609                              "dcerpc_winreg_OpenHKLM_out_memory");
610         if (tevent_req_nomem(state->out_mem_ctx, req)) {
611                 return tevent_req_post(req, ev);
612         }
613
614         /* make a temporary copy, that we pass to the dispatch function */
615         state->tmp = state->orig;
616
617         subreq = dcerpc_winreg_OpenHKLM_r_send(state, ev, h, &state->tmp);
618         if (tevent_req_nomem(subreq, req)) {
619                 return tevent_req_post(req, ev);
620         }
621         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKLM_done, req);
622         return req;
623 }
624
625 static void dcerpc_winreg_OpenHKLM_done(struct tevent_req *subreq)
626 {
627         struct tevent_req *req = tevent_req_callback_data(
628                 subreq, struct tevent_req);
629         struct dcerpc_winreg_OpenHKLM_state *state = tevent_req_data(
630                 req, struct dcerpc_winreg_OpenHKLM_state);
631         NTSTATUS status;
632         TALLOC_CTX *mem_ctx;
633
634         if (state->out_mem_ctx) {
635                 mem_ctx = state->out_mem_ctx;
636         } else {
637                 mem_ctx = state;
638         }
639
640         status = dcerpc_winreg_OpenHKLM_r_recv(subreq, mem_ctx);
641         TALLOC_FREE(subreq);
642         if (!NT_STATUS_IS_OK(status)) {
643                 tevent_req_nterror(req, status);
644                 return;
645         }
646
647         /* Copy out parameters */
648         *state->orig.out.handle = *state->tmp.out.handle;
649
650         /* Copy result */
651         state->orig.out.result = state->tmp.out.result;
652
653         /* Reset temporary structure */
654         ZERO_STRUCT(state->tmp);
655
656         tevent_req_done(req);
657 }
658
659 NTSTATUS dcerpc_winreg_OpenHKLM_recv(struct tevent_req *req,
660                                      TALLOC_CTX *mem_ctx,
661                                      WERROR *result)
662 {
663         struct dcerpc_winreg_OpenHKLM_state *state = tevent_req_data(
664                 req, struct dcerpc_winreg_OpenHKLM_state);
665         NTSTATUS status;
666
667         if (tevent_req_is_nterror(req, &status)) {
668                 tevent_req_received(req);
669                 return status;
670         }
671
672         /* Steal possible out parameters to the callers context */
673         talloc_steal(mem_ctx, state->out_mem_ctx);
674
675         /* Return result */
676         *result = state->orig.out.result;
677
678         tevent_req_received(req);
679         return NT_STATUS_OK;
680 }
681
682 NTSTATUS dcerpc_winreg_OpenHKLM(struct dcerpc_binding_handle *h,
683                                 TALLOC_CTX *mem_ctx,
684                                 uint16_t *_system_name /* [in] [unique] */,
685                                 uint32_t _access_mask /* [in]  */,
686                                 struct policy_handle *_handle /* [out] [ref] */,
687                                 WERROR *result)
688 {
689         struct winreg_OpenHKLM r;
690         NTSTATUS status;
691
692         /* In parameters */
693         r.in.system_name = _system_name;
694         r.in.access_mask = _access_mask;
695
696         status = dcerpc_winreg_OpenHKLM_r(h, mem_ctx, &r);
697         if (!NT_STATUS_IS_OK(status)) {
698                 return status;
699         }
700
701         /* Return variables */
702         *_handle = *r.out.handle;
703
704         /* Return result */
705         *result = r.out.result;
706
707         return NT_STATUS_OK;
708 }
709
710 struct dcerpc_winreg_OpenHKPD_r_state {
711         TALLOC_CTX *out_mem_ctx;
712 };
713
714 static void dcerpc_winreg_OpenHKPD_r_done(struct tevent_req *subreq);
715
716 struct tevent_req *dcerpc_winreg_OpenHKPD_r_send(TALLOC_CTX *mem_ctx,
717         struct tevent_context *ev,
718         struct dcerpc_binding_handle *h,
719         struct winreg_OpenHKPD *r)
720 {
721         struct tevent_req *req;
722         struct dcerpc_winreg_OpenHKPD_r_state *state;
723         struct tevent_req *subreq;
724
725         req = tevent_req_create(mem_ctx, &state,
726                                 struct dcerpc_winreg_OpenHKPD_r_state);
727         if (req == NULL) {
728                 return NULL;
729         }
730
731         state->out_mem_ctx = talloc_new(state);
732         if (tevent_req_nomem(state->out_mem_ctx, req)) {
733                 return tevent_req_post(req, ev);
734         }
735
736         subreq = dcerpc_binding_handle_call_send(state, ev, h,
737                         NULL, &ndr_table_winreg,
738                         NDR_WINREG_OPENHKPD, state->out_mem_ctx, r);
739         if (tevent_req_nomem(subreq, req)) {
740                 return tevent_req_post(req, ev);
741         }
742         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKPD_r_done, req);
743
744         return req;
745 }
746
747 static void dcerpc_winreg_OpenHKPD_r_done(struct tevent_req *subreq)
748 {
749         struct tevent_req *req =
750                 tevent_req_callback_data(subreq,
751                 struct tevent_req);
752         NTSTATUS status;
753
754         status = dcerpc_binding_handle_call_recv(subreq);
755         if (!NT_STATUS_IS_OK(status)) {
756                 tevent_req_nterror(req, status);
757                 return;
758         }
759
760         tevent_req_done(req);
761 }
762
763 NTSTATUS dcerpc_winreg_OpenHKPD_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
764 {
765         struct dcerpc_winreg_OpenHKPD_r_state *state =
766                 tevent_req_data(req,
767                 struct dcerpc_winreg_OpenHKPD_r_state);
768         NTSTATUS status;
769
770         if (tevent_req_is_nterror(req, &status)) {
771                 tevent_req_received(req);
772                 return status;
773         }
774
775         talloc_steal(mem_ctx, state->out_mem_ctx);
776
777         tevent_req_received(req);
778         return NT_STATUS_OK;
779 }
780
781 NTSTATUS dcerpc_winreg_OpenHKPD_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_OpenHKPD *r)
782 {
783         NTSTATUS status;
784
785         status = dcerpc_binding_handle_call(h,
786                         NULL, &ndr_table_winreg,
787                         NDR_WINREG_OPENHKPD, mem_ctx, r);
788
789         return status;
790 }
791
792 NTSTATUS dcerpc_winreg_OpenHKPD_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_OpenHKPD *r)
793 {
794         NTSTATUS status;
795
796         status = dcerpc_winreg_OpenHKPD_r(p->binding_handle, mem_ctx, r);
797
798         if (NT_STATUS_IS_RPC(status)) {
799                 status = NT_STATUS_NET_WRITE_FAULT;
800         }
801
802         return status;
803 }
804
805 struct dcerpc_winreg_OpenHKPD_state {
806         struct winreg_OpenHKPD orig;
807         struct winreg_OpenHKPD tmp;
808         TALLOC_CTX *out_mem_ctx;
809 };
810
811 static void dcerpc_winreg_OpenHKPD_done(struct tevent_req *subreq);
812
813 struct tevent_req *dcerpc_winreg_OpenHKPD_send(TALLOC_CTX *mem_ctx,
814                                                struct tevent_context *ev,
815                                                struct dcerpc_binding_handle *h,
816                                                uint16_t *_system_name /* [in] [unique] */,
817                                                uint32_t _access_mask /* [in]  */,
818                                                struct policy_handle *_handle /* [out] [ref] */)
819 {
820         struct tevent_req *req;
821         struct dcerpc_winreg_OpenHKPD_state *state;
822         struct tevent_req *subreq;
823
824         req = tevent_req_create(mem_ctx, &state,
825                                 struct dcerpc_winreg_OpenHKPD_state);
826         if (req == NULL) {
827                 return NULL;
828         }
829         state->out_mem_ctx = NULL;
830
831         /* In parameters */
832         state->orig.in.system_name = _system_name;
833         state->orig.in.access_mask = _access_mask;
834
835         /* Out parameters */
836         state->orig.out.handle = _handle;
837
838         /* Result */
839         ZERO_STRUCT(state->orig.out.result);
840
841         state->out_mem_ctx = talloc_named_const(state, 0,
842                              "dcerpc_winreg_OpenHKPD_out_memory");
843         if (tevent_req_nomem(state->out_mem_ctx, req)) {
844                 return tevent_req_post(req, ev);
845         }
846
847         /* make a temporary copy, that we pass to the dispatch function */
848         state->tmp = state->orig;
849
850         subreq = dcerpc_winreg_OpenHKPD_r_send(state, ev, h, &state->tmp);
851         if (tevent_req_nomem(subreq, req)) {
852                 return tevent_req_post(req, ev);
853         }
854         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKPD_done, req);
855         return req;
856 }
857
858 static void dcerpc_winreg_OpenHKPD_done(struct tevent_req *subreq)
859 {
860         struct tevent_req *req = tevent_req_callback_data(
861                 subreq, struct tevent_req);
862         struct dcerpc_winreg_OpenHKPD_state *state = tevent_req_data(
863                 req, struct dcerpc_winreg_OpenHKPD_state);
864         NTSTATUS status;
865         TALLOC_CTX *mem_ctx;
866
867         if (state->out_mem_ctx) {
868                 mem_ctx = state->out_mem_ctx;
869         } else {
870                 mem_ctx = state;
871         }
872
873         status = dcerpc_winreg_OpenHKPD_r_recv(subreq, mem_ctx);
874         TALLOC_FREE(subreq);
875         if (!NT_STATUS_IS_OK(status)) {
876                 tevent_req_nterror(req, status);
877                 return;
878         }
879
880         /* Copy out parameters */
881         *state->orig.out.handle = *state->tmp.out.handle;
882
883         /* Copy result */
884         state->orig.out.result = state->tmp.out.result;
885
886         /* Reset temporary structure */
887         ZERO_STRUCT(state->tmp);
888
889         tevent_req_done(req);
890 }
891
892 NTSTATUS dcerpc_winreg_OpenHKPD_recv(struct tevent_req *req,
893                                      TALLOC_CTX *mem_ctx,
894                                      WERROR *result)
895 {
896         struct dcerpc_winreg_OpenHKPD_state *state = tevent_req_data(
897                 req, struct dcerpc_winreg_OpenHKPD_state);
898         NTSTATUS status;
899
900         if (tevent_req_is_nterror(req, &status)) {
901                 tevent_req_received(req);
902                 return status;
903         }
904
905         /* Steal possible out parameters to the callers context */
906         talloc_steal(mem_ctx, state->out_mem_ctx);
907
908         /* Return result */
909         *result = state->orig.out.result;
910
911         tevent_req_received(req);
912         return NT_STATUS_OK;
913 }
914
915 NTSTATUS dcerpc_winreg_OpenHKPD(struct dcerpc_binding_handle *h,
916                                 TALLOC_CTX *mem_ctx,
917                                 uint16_t *_system_name /* [in] [unique] */,
918                                 uint32_t _access_mask /* [in]  */,
919                                 struct policy_handle *_handle /* [out] [ref] */,
920                                 WERROR *result)
921 {
922         struct winreg_OpenHKPD r;
923         NTSTATUS status;
924
925         /* In parameters */
926         r.in.system_name = _system_name;
927         r.in.access_mask = _access_mask;
928
929         status = dcerpc_winreg_OpenHKPD_r(h, mem_ctx, &r);
930         if (!NT_STATUS_IS_OK(status)) {
931                 return status;
932         }
933
934         /* Return variables */
935         *_handle = *r.out.handle;
936
937         /* Return result */
938         *result = r.out.result;
939
940         return NT_STATUS_OK;
941 }
942
943 struct dcerpc_winreg_OpenHKU_r_state {
944         TALLOC_CTX *out_mem_ctx;
945 };
946
947 static void dcerpc_winreg_OpenHKU_r_done(struct tevent_req *subreq);
948
949 struct tevent_req *dcerpc_winreg_OpenHKU_r_send(TALLOC_CTX *mem_ctx,
950         struct tevent_context *ev,
951         struct dcerpc_binding_handle *h,
952         struct winreg_OpenHKU *r)
953 {
954         struct tevent_req *req;
955         struct dcerpc_winreg_OpenHKU_r_state *state;
956         struct tevent_req *subreq;
957
958         req = tevent_req_create(mem_ctx, &state,
959                                 struct dcerpc_winreg_OpenHKU_r_state);
960         if (req == NULL) {
961                 return NULL;
962         }
963
964         state->out_mem_ctx = talloc_new(state);
965         if (tevent_req_nomem(state->out_mem_ctx, req)) {
966                 return tevent_req_post(req, ev);
967         }
968
969         subreq = dcerpc_binding_handle_call_send(state, ev, h,
970                         NULL, &ndr_table_winreg,
971                         NDR_WINREG_OPENHKU, state->out_mem_ctx, r);
972         if (tevent_req_nomem(subreq, req)) {
973                 return tevent_req_post(req, ev);
974         }
975         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKU_r_done, req);
976
977         return req;
978 }
979
980 static void dcerpc_winreg_OpenHKU_r_done(struct tevent_req *subreq)
981 {
982         struct tevent_req *req =
983                 tevent_req_callback_data(subreq,
984                 struct tevent_req);
985         NTSTATUS status;
986
987         status = dcerpc_binding_handle_call_recv(subreq);
988         if (!NT_STATUS_IS_OK(status)) {
989                 tevent_req_nterror(req, status);
990                 return;
991         }
992
993         tevent_req_done(req);
994 }
995
996 NTSTATUS dcerpc_winreg_OpenHKU_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
997 {
998         struct dcerpc_winreg_OpenHKU_r_state *state =
999                 tevent_req_data(req,
1000                 struct dcerpc_winreg_OpenHKU_r_state);
1001         NTSTATUS status;
1002
1003         if (tevent_req_is_nterror(req, &status)) {
1004                 tevent_req_received(req);
1005                 return status;
1006         }
1007
1008         talloc_steal(mem_ctx, state->out_mem_ctx);
1009
1010         tevent_req_received(req);
1011         return NT_STATUS_OK;
1012 }
1013
1014 NTSTATUS dcerpc_winreg_OpenHKU_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_OpenHKU *r)
1015 {
1016         NTSTATUS status;
1017
1018         status = dcerpc_binding_handle_call(h,
1019                         NULL, &ndr_table_winreg,
1020                         NDR_WINREG_OPENHKU, mem_ctx, r);
1021
1022         return status;
1023 }
1024
1025 NTSTATUS dcerpc_winreg_OpenHKU_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_OpenHKU *r)
1026 {
1027         NTSTATUS status;
1028
1029         status = dcerpc_winreg_OpenHKU_r(p->binding_handle, mem_ctx, r);
1030
1031         if (NT_STATUS_IS_RPC(status)) {
1032                 status = NT_STATUS_NET_WRITE_FAULT;
1033         }
1034
1035         return status;
1036 }
1037
1038 struct dcerpc_winreg_OpenHKU_state {
1039         struct winreg_OpenHKU orig;
1040         struct winreg_OpenHKU tmp;
1041         TALLOC_CTX *out_mem_ctx;
1042 };
1043
1044 static void dcerpc_winreg_OpenHKU_done(struct tevent_req *subreq);
1045
1046 struct tevent_req *dcerpc_winreg_OpenHKU_send(TALLOC_CTX *mem_ctx,
1047                                               struct tevent_context *ev,
1048                                               struct dcerpc_binding_handle *h,
1049                                               uint16_t *_system_name /* [in] [unique] */,
1050                                               uint32_t _access_mask /* [in]  */,
1051                                               struct policy_handle *_handle /* [out] [ref] */)
1052 {
1053         struct tevent_req *req;
1054         struct dcerpc_winreg_OpenHKU_state *state;
1055         struct tevent_req *subreq;
1056
1057         req = tevent_req_create(mem_ctx, &state,
1058                                 struct dcerpc_winreg_OpenHKU_state);
1059         if (req == NULL) {
1060                 return NULL;
1061         }
1062         state->out_mem_ctx = NULL;
1063
1064         /* In parameters */
1065         state->orig.in.system_name = _system_name;
1066         state->orig.in.access_mask = _access_mask;
1067
1068         /* Out parameters */
1069         state->orig.out.handle = _handle;
1070
1071         /* Result */
1072         ZERO_STRUCT(state->orig.out.result);
1073
1074         state->out_mem_ctx = talloc_named_const(state, 0,
1075                              "dcerpc_winreg_OpenHKU_out_memory");
1076         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1077                 return tevent_req_post(req, ev);
1078         }
1079
1080         /* make a temporary copy, that we pass to the dispatch function */
1081         state->tmp = state->orig;
1082
1083         subreq = dcerpc_winreg_OpenHKU_r_send(state, ev, h, &state->tmp);
1084         if (tevent_req_nomem(subreq, req)) {
1085                 return tevent_req_post(req, ev);
1086         }
1087         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKU_done, req);
1088         return req;
1089 }
1090
1091 static void dcerpc_winreg_OpenHKU_done(struct tevent_req *subreq)
1092 {
1093         struct tevent_req *req = tevent_req_callback_data(
1094                 subreq, struct tevent_req);
1095         struct dcerpc_winreg_OpenHKU_state *state = tevent_req_data(
1096                 req, struct dcerpc_winreg_OpenHKU_state);
1097         NTSTATUS status;
1098         TALLOC_CTX *mem_ctx;
1099
1100         if (state->out_mem_ctx) {
1101                 mem_ctx = state->out_mem_ctx;
1102         } else {
1103                 mem_ctx = state;
1104         }
1105
1106         status = dcerpc_winreg_OpenHKU_r_recv(subreq, mem_ctx);
1107         TALLOC_FREE(subreq);
1108         if (!NT_STATUS_IS_OK(status)) {
1109                 tevent_req_nterror(req, status);
1110                 return;
1111         }
1112
1113         /* Copy out parameters */
1114         *state->orig.out.handle = *state->tmp.out.handle;
1115
1116         /* Copy result */
1117         state->orig.out.result = state->tmp.out.result;
1118
1119         /* Reset temporary structure */
1120         ZERO_STRUCT(state->tmp);
1121
1122         tevent_req_done(req);
1123 }
1124
1125 NTSTATUS dcerpc_winreg_OpenHKU_recv(struct tevent_req *req,
1126                                     TALLOC_CTX *mem_ctx,
1127                                     WERROR *result)
1128 {
1129         struct dcerpc_winreg_OpenHKU_state *state = tevent_req_data(
1130                 req, struct dcerpc_winreg_OpenHKU_state);
1131         NTSTATUS status;
1132
1133         if (tevent_req_is_nterror(req, &status)) {
1134                 tevent_req_received(req);
1135                 return status;
1136         }
1137
1138         /* Steal possible out parameters to the callers context */
1139         talloc_steal(mem_ctx, state->out_mem_ctx);
1140
1141         /* Return result */
1142         *result = state->orig.out.result;
1143
1144         tevent_req_received(req);
1145         return NT_STATUS_OK;
1146 }
1147
1148 NTSTATUS dcerpc_winreg_OpenHKU(struct dcerpc_binding_handle *h,
1149                                TALLOC_CTX *mem_ctx,
1150                                uint16_t *_system_name /* [in] [unique] */,
1151                                uint32_t _access_mask /* [in]  */,
1152                                struct policy_handle *_handle /* [out] [ref] */,
1153                                WERROR *result)
1154 {
1155         struct winreg_OpenHKU r;
1156         NTSTATUS status;
1157
1158         /* In parameters */
1159         r.in.system_name = _system_name;
1160         r.in.access_mask = _access_mask;
1161
1162         status = dcerpc_winreg_OpenHKU_r(h, mem_ctx, &r);
1163         if (!NT_STATUS_IS_OK(status)) {
1164                 return status;
1165         }
1166
1167         /* Return variables */
1168         *_handle = *r.out.handle;
1169
1170         /* Return result */
1171         *result = r.out.result;
1172
1173         return NT_STATUS_OK;
1174 }
1175
1176 struct dcerpc_winreg_CloseKey_r_state {
1177         TALLOC_CTX *out_mem_ctx;
1178 };
1179
1180 static void dcerpc_winreg_CloseKey_r_done(struct tevent_req *subreq);
1181
1182 struct tevent_req *dcerpc_winreg_CloseKey_r_send(TALLOC_CTX *mem_ctx,
1183         struct tevent_context *ev,
1184         struct dcerpc_binding_handle *h,
1185         struct winreg_CloseKey *r)
1186 {
1187         struct tevent_req *req;
1188         struct dcerpc_winreg_CloseKey_r_state *state;
1189         struct tevent_req *subreq;
1190
1191         req = tevent_req_create(mem_ctx, &state,
1192                                 struct dcerpc_winreg_CloseKey_r_state);
1193         if (req == NULL) {
1194                 return NULL;
1195         }
1196
1197         state->out_mem_ctx = talloc_new(state);
1198         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1199                 return tevent_req_post(req, ev);
1200         }
1201
1202         subreq = dcerpc_binding_handle_call_send(state, ev, h,
1203                         NULL, &ndr_table_winreg,
1204                         NDR_WINREG_CLOSEKEY, state->out_mem_ctx, r);
1205         if (tevent_req_nomem(subreq, req)) {
1206                 return tevent_req_post(req, ev);
1207         }
1208         tevent_req_set_callback(subreq, dcerpc_winreg_CloseKey_r_done, req);
1209
1210         return req;
1211 }
1212
1213 static void dcerpc_winreg_CloseKey_r_done(struct tevent_req *subreq)
1214 {
1215         struct tevent_req *req =
1216                 tevent_req_callback_data(subreq,
1217                 struct tevent_req);
1218         NTSTATUS status;
1219
1220         status = dcerpc_binding_handle_call_recv(subreq);
1221         if (!NT_STATUS_IS_OK(status)) {
1222                 tevent_req_nterror(req, status);
1223                 return;
1224         }
1225
1226         tevent_req_done(req);
1227 }
1228
1229 NTSTATUS dcerpc_winreg_CloseKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
1230 {
1231         struct dcerpc_winreg_CloseKey_r_state *state =
1232                 tevent_req_data(req,
1233                 struct dcerpc_winreg_CloseKey_r_state);
1234         NTSTATUS status;
1235
1236         if (tevent_req_is_nterror(req, &status)) {
1237                 tevent_req_received(req);
1238                 return status;
1239         }
1240
1241         talloc_steal(mem_ctx, state->out_mem_ctx);
1242
1243         tevent_req_received(req);
1244         return NT_STATUS_OK;
1245 }
1246
1247 NTSTATUS dcerpc_winreg_CloseKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_CloseKey *r)
1248 {
1249         NTSTATUS status;
1250
1251         status = dcerpc_binding_handle_call(h,
1252                         NULL, &ndr_table_winreg,
1253                         NDR_WINREG_CLOSEKEY, mem_ctx, r);
1254
1255         return status;
1256 }
1257
1258 NTSTATUS dcerpc_winreg_CloseKey_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_CloseKey *r)
1259 {
1260         NTSTATUS status;
1261
1262         status = dcerpc_winreg_CloseKey_r(p->binding_handle, mem_ctx, r);
1263
1264         if (NT_STATUS_IS_RPC(status)) {
1265                 status = NT_STATUS_NET_WRITE_FAULT;
1266         }
1267
1268         return status;
1269 }
1270
1271 struct dcerpc_winreg_CloseKey_state {
1272         struct winreg_CloseKey orig;
1273         struct winreg_CloseKey tmp;
1274         TALLOC_CTX *out_mem_ctx;
1275 };
1276
1277 static void dcerpc_winreg_CloseKey_done(struct tevent_req *subreq);
1278
1279 struct tevent_req *dcerpc_winreg_CloseKey_send(TALLOC_CTX *mem_ctx,
1280                                                struct tevent_context *ev,
1281                                                struct dcerpc_binding_handle *h,
1282                                                struct policy_handle *_handle /* [in,out] [ref] */)
1283 {
1284         struct tevent_req *req;
1285         struct dcerpc_winreg_CloseKey_state *state;
1286         struct tevent_req *subreq;
1287
1288         req = tevent_req_create(mem_ctx, &state,
1289                                 struct dcerpc_winreg_CloseKey_state);
1290         if (req == NULL) {
1291                 return NULL;
1292         }
1293         state->out_mem_ctx = NULL;
1294
1295         /* In parameters */
1296         state->orig.in.handle = _handle;
1297
1298         /* Out parameters */
1299         state->orig.out.handle = _handle;
1300
1301         /* Result */
1302         ZERO_STRUCT(state->orig.out.result);
1303
1304         state->out_mem_ctx = talloc_named_const(state, 0,
1305                              "dcerpc_winreg_CloseKey_out_memory");
1306         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1307                 return tevent_req_post(req, ev);
1308         }
1309
1310         /* make a temporary copy, that we pass to the dispatch function */
1311         state->tmp = state->orig;
1312
1313         subreq = dcerpc_winreg_CloseKey_r_send(state, ev, h, &state->tmp);
1314         if (tevent_req_nomem(subreq, req)) {
1315                 return tevent_req_post(req, ev);
1316         }
1317         tevent_req_set_callback(subreq, dcerpc_winreg_CloseKey_done, req);
1318         return req;
1319 }
1320
1321 static void dcerpc_winreg_CloseKey_done(struct tevent_req *subreq)
1322 {
1323         struct tevent_req *req = tevent_req_callback_data(
1324                 subreq, struct tevent_req);
1325         struct dcerpc_winreg_CloseKey_state *state = tevent_req_data(
1326                 req, struct dcerpc_winreg_CloseKey_state);
1327         NTSTATUS status;
1328         TALLOC_CTX *mem_ctx;
1329
1330         if (state->out_mem_ctx) {
1331                 mem_ctx = state->out_mem_ctx;
1332         } else {
1333                 mem_ctx = state;
1334         }
1335
1336         status = dcerpc_winreg_CloseKey_r_recv(subreq, mem_ctx);
1337         TALLOC_FREE(subreq);
1338         if (!NT_STATUS_IS_OK(status)) {
1339                 tevent_req_nterror(req, status);
1340                 return;
1341         }
1342
1343         /* Copy out parameters */
1344         *state->orig.out.handle = *state->tmp.out.handle;
1345
1346         /* Copy result */
1347         state->orig.out.result = state->tmp.out.result;
1348
1349         /* Reset temporary structure */
1350         ZERO_STRUCT(state->tmp);
1351
1352         tevent_req_done(req);
1353 }
1354
1355 NTSTATUS dcerpc_winreg_CloseKey_recv(struct tevent_req *req,
1356                                      TALLOC_CTX *mem_ctx,
1357                                      WERROR *result)
1358 {
1359         struct dcerpc_winreg_CloseKey_state *state = tevent_req_data(
1360                 req, struct dcerpc_winreg_CloseKey_state);
1361         NTSTATUS status;
1362
1363         if (tevent_req_is_nterror(req, &status)) {
1364                 tevent_req_received(req);
1365                 return status;
1366         }
1367
1368         /* Steal possible out parameters to the callers context */
1369         talloc_steal(mem_ctx, state->out_mem_ctx);
1370
1371         /* Return result */
1372         *result = state->orig.out.result;
1373
1374         tevent_req_received(req);
1375         return NT_STATUS_OK;
1376 }
1377
1378 NTSTATUS dcerpc_winreg_CloseKey(struct dcerpc_binding_handle *h,
1379                                 TALLOC_CTX *mem_ctx,
1380                                 struct policy_handle *_handle /* [in,out] [ref] */,
1381                                 WERROR *result)
1382 {
1383         struct winreg_CloseKey r;
1384         NTSTATUS status;
1385
1386         /* In parameters */
1387         r.in.handle = _handle;
1388
1389         status = dcerpc_winreg_CloseKey_r(h, mem_ctx, &r);
1390         if (!NT_STATUS_IS_OK(status)) {
1391                 return status;
1392         }
1393
1394         /* Return variables */
1395         *_handle = *r.out.handle;
1396
1397         /* Return result */
1398         *result = r.out.result;
1399
1400         return NT_STATUS_OK;
1401 }
1402
1403 struct dcerpc_winreg_CreateKey_r_state {
1404         TALLOC_CTX *out_mem_ctx;
1405 };
1406
1407 static void dcerpc_winreg_CreateKey_r_done(struct tevent_req *subreq);
1408
1409 struct tevent_req *dcerpc_winreg_CreateKey_r_send(TALLOC_CTX *mem_ctx,
1410         struct tevent_context *ev,
1411         struct dcerpc_binding_handle *h,
1412         struct winreg_CreateKey *r)
1413 {
1414         struct tevent_req *req;
1415         struct dcerpc_winreg_CreateKey_r_state *state;
1416         struct tevent_req *subreq;
1417
1418         req = tevent_req_create(mem_ctx, &state,
1419                                 struct dcerpc_winreg_CreateKey_r_state);
1420         if (req == NULL) {
1421                 return NULL;
1422         }
1423
1424         state->out_mem_ctx = talloc_new(state);
1425         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1426                 return tevent_req_post(req, ev);
1427         }
1428
1429         subreq = dcerpc_binding_handle_call_send(state, ev, h,
1430                         NULL, &ndr_table_winreg,
1431                         NDR_WINREG_CREATEKEY, state->out_mem_ctx, r);
1432         if (tevent_req_nomem(subreq, req)) {
1433                 return tevent_req_post(req, ev);
1434         }
1435         tevent_req_set_callback(subreq, dcerpc_winreg_CreateKey_r_done, req);
1436
1437         return req;
1438 }
1439
1440 static void dcerpc_winreg_CreateKey_r_done(struct tevent_req *subreq)
1441 {
1442         struct tevent_req *req =
1443                 tevent_req_callback_data(subreq,
1444                 struct tevent_req);
1445         NTSTATUS status;
1446
1447         status = dcerpc_binding_handle_call_recv(subreq);
1448         if (!NT_STATUS_IS_OK(status)) {
1449                 tevent_req_nterror(req, status);
1450                 return;
1451         }
1452
1453         tevent_req_done(req);
1454 }
1455
1456 NTSTATUS dcerpc_winreg_CreateKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
1457 {
1458         struct dcerpc_winreg_CreateKey_r_state *state =
1459                 tevent_req_data(req,
1460                 struct dcerpc_winreg_CreateKey_r_state);
1461         NTSTATUS status;
1462
1463         if (tevent_req_is_nterror(req, &status)) {
1464                 tevent_req_received(req);
1465                 return status;
1466         }
1467
1468         talloc_steal(mem_ctx, state->out_mem_ctx);
1469
1470         tevent_req_received(req);
1471         return NT_STATUS_OK;
1472 }
1473
1474 NTSTATUS dcerpc_winreg_CreateKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_CreateKey *r)
1475 {
1476         NTSTATUS status;
1477
1478         status = dcerpc_binding_handle_call(h,
1479                         NULL, &ndr_table_winreg,
1480                         NDR_WINREG_CREATEKEY, mem_ctx, r);
1481
1482         return status;
1483 }
1484
1485 NTSTATUS dcerpc_winreg_CreateKey_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_CreateKey *r)
1486 {
1487         NTSTATUS status;
1488
1489         status = dcerpc_winreg_CreateKey_r(p->binding_handle, mem_ctx, r);
1490
1491         if (NT_STATUS_IS_RPC(status)) {
1492                 status = NT_STATUS_NET_WRITE_FAULT;
1493         }
1494
1495         return status;
1496 }
1497
1498 struct dcerpc_winreg_CreateKey_state {
1499         struct winreg_CreateKey orig;
1500         struct winreg_CreateKey tmp;
1501         TALLOC_CTX *out_mem_ctx;
1502 };
1503
1504 static void dcerpc_winreg_CreateKey_done(struct tevent_req *subreq);
1505
1506 struct tevent_req *dcerpc_winreg_CreateKey_send(TALLOC_CTX *mem_ctx,
1507                                                 struct tevent_context *ev,
1508                                                 struct dcerpc_binding_handle *h,
1509                                                 struct policy_handle *_handle /* [in] [ref] */,
1510                                                 struct winreg_String _name /* [in]  */,
1511                                                 struct winreg_String _keyclass /* [in]  */,
1512                                                 uint32_t _options /* [in]  */,
1513                                                 uint32_t _access_mask /* [in]  */,
1514                                                 struct winreg_SecBuf *_secdesc /* [in] [unique] */,
1515                                                 struct policy_handle *_new_handle /* [out] [ref] */,
1516                                                 enum winreg_CreateAction *_action_taken /* [in,out] [unique] */)
1517 {
1518         struct tevent_req *req;
1519         struct dcerpc_winreg_CreateKey_state *state;
1520         struct tevent_req *subreq;
1521
1522         req = tevent_req_create(mem_ctx, &state,
1523                                 struct dcerpc_winreg_CreateKey_state);
1524         if (req == NULL) {
1525                 return NULL;
1526         }
1527         state->out_mem_ctx = NULL;
1528
1529         /* In parameters */
1530         state->orig.in.handle = _handle;
1531         state->orig.in.name = _name;
1532         state->orig.in.keyclass = _keyclass;
1533         state->orig.in.options = _options;
1534         state->orig.in.access_mask = _access_mask;
1535         state->orig.in.secdesc = _secdesc;
1536         state->orig.in.action_taken = _action_taken;
1537
1538         /* Out parameters */
1539         state->orig.out.new_handle = _new_handle;
1540         state->orig.out.action_taken = _action_taken;
1541
1542         /* Result */
1543         ZERO_STRUCT(state->orig.out.result);
1544
1545         state->out_mem_ctx = talloc_named_const(state, 0,
1546                              "dcerpc_winreg_CreateKey_out_memory");
1547         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1548                 return tevent_req_post(req, ev);
1549         }
1550
1551         /* make a temporary copy, that we pass to the dispatch function */
1552         state->tmp = state->orig;
1553
1554         subreq = dcerpc_winreg_CreateKey_r_send(state, ev, h, &state->tmp);
1555         if (tevent_req_nomem(subreq, req)) {
1556                 return tevent_req_post(req, ev);
1557         }
1558         tevent_req_set_callback(subreq, dcerpc_winreg_CreateKey_done, req);
1559         return req;
1560 }
1561
1562 static void dcerpc_winreg_CreateKey_done(struct tevent_req *subreq)
1563 {
1564         struct tevent_req *req = tevent_req_callback_data(
1565                 subreq, struct tevent_req);
1566         struct dcerpc_winreg_CreateKey_state *state = tevent_req_data(
1567                 req, struct dcerpc_winreg_CreateKey_state);
1568         NTSTATUS status;
1569         TALLOC_CTX *mem_ctx;
1570
1571         if (state->out_mem_ctx) {
1572                 mem_ctx = state->out_mem_ctx;
1573         } else {
1574                 mem_ctx = state;
1575         }
1576
1577         status = dcerpc_winreg_CreateKey_r_recv(subreq, mem_ctx);
1578         TALLOC_FREE(subreq);
1579         if (!NT_STATUS_IS_OK(status)) {
1580                 tevent_req_nterror(req, status);
1581                 return;
1582         }
1583
1584         /* Copy out parameters */
1585         *state->orig.out.new_handle = *state->tmp.out.new_handle;
1586         if (state->orig.out.action_taken && state->tmp.out.action_taken) {
1587                 *state->orig.out.action_taken = *state->tmp.out.action_taken;
1588         }
1589
1590         /* Copy result */
1591         state->orig.out.result = state->tmp.out.result;
1592
1593         /* Reset temporary structure */
1594         ZERO_STRUCT(state->tmp);
1595
1596         tevent_req_done(req);
1597 }
1598
1599 NTSTATUS dcerpc_winreg_CreateKey_recv(struct tevent_req *req,
1600                                       TALLOC_CTX *mem_ctx,
1601                                       WERROR *result)
1602 {
1603         struct dcerpc_winreg_CreateKey_state *state = tevent_req_data(
1604                 req, struct dcerpc_winreg_CreateKey_state);
1605         NTSTATUS status;
1606
1607         if (tevent_req_is_nterror(req, &status)) {
1608                 tevent_req_received(req);
1609                 return status;
1610         }
1611
1612         /* Steal possible out parameters to the callers context */
1613         talloc_steal(mem_ctx, state->out_mem_ctx);
1614
1615         /* Return result */
1616         *result = state->orig.out.result;
1617
1618         tevent_req_received(req);
1619         return NT_STATUS_OK;
1620 }
1621
1622 NTSTATUS dcerpc_winreg_CreateKey(struct dcerpc_binding_handle *h,
1623                                  TALLOC_CTX *mem_ctx,
1624                                  struct policy_handle *_handle /* [in] [ref] */,
1625                                  struct winreg_String _name /* [in]  */,
1626                                  struct winreg_String _keyclass /* [in]  */,
1627                                  uint32_t _options /* [in]  */,
1628                                  uint32_t _access_mask /* [in]  */,
1629                                  struct winreg_SecBuf *_secdesc /* [in] [unique] */,
1630                                  struct policy_handle *_new_handle /* [out] [ref] */,
1631                                  enum winreg_CreateAction *_action_taken /* [in,out] [unique] */,
1632                                  WERROR *result)
1633 {
1634         struct winreg_CreateKey r;
1635         NTSTATUS status;
1636
1637         /* In parameters */
1638         r.in.handle = _handle;
1639         r.in.name = _name;
1640         r.in.keyclass = _keyclass;
1641         r.in.options = _options;
1642         r.in.access_mask = _access_mask;
1643         r.in.secdesc = _secdesc;
1644         r.in.action_taken = _action_taken;
1645
1646         status = dcerpc_winreg_CreateKey_r(h, mem_ctx, &r);
1647         if (!NT_STATUS_IS_OK(status)) {
1648                 return status;
1649         }
1650
1651         /* Return variables */
1652         *_new_handle = *r.out.new_handle;
1653         if (_action_taken && r.out.action_taken) {
1654                 *_action_taken = *r.out.action_taken;
1655         }
1656
1657         /* Return result */
1658         *result = r.out.result;
1659
1660         return NT_STATUS_OK;
1661 }
1662
1663 struct dcerpc_winreg_DeleteKey_r_state {
1664         TALLOC_CTX *out_mem_ctx;
1665 };
1666
1667 static void dcerpc_winreg_DeleteKey_r_done(struct tevent_req *subreq);
1668
1669 struct tevent_req *dcerpc_winreg_DeleteKey_r_send(TALLOC_CTX *mem_ctx,
1670         struct tevent_context *ev,
1671         struct dcerpc_binding_handle *h,
1672         struct winreg_DeleteKey *r)
1673 {
1674         struct tevent_req *req;
1675         struct dcerpc_winreg_DeleteKey_r_state *state;
1676         struct tevent_req *subreq;
1677
1678         req = tevent_req_create(mem_ctx, &state,
1679                                 struct dcerpc_winreg_DeleteKey_r_state);
1680         if (req == NULL) {
1681                 return NULL;
1682         }
1683
1684         state->out_mem_ctx = NULL;
1685         subreq = dcerpc_binding_handle_call_send(state, ev, h,
1686                         NULL, &ndr_table_winreg,
1687                         NDR_WINREG_DELETEKEY, state, r);
1688         if (tevent_req_nomem(subreq, req)) {
1689                 return tevent_req_post(req, ev);
1690         }
1691         tevent_req_set_callback(subreq, dcerpc_winreg_DeleteKey_r_done, req);
1692
1693         return req;
1694 }
1695
1696 static void dcerpc_winreg_DeleteKey_r_done(struct tevent_req *subreq)
1697 {
1698         struct tevent_req *req =
1699                 tevent_req_callback_data(subreq,
1700                 struct tevent_req);
1701         NTSTATUS status;
1702
1703         status = dcerpc_binding_handle_call_recv(subreq);
1704         if (!NT_STATUS_IS_OK(status)) {
1705                 tevent_req_nterror(req, status);
1706                 return;
1707         }
1708
1709         tevent_req_done(req);
1710 }
1711
1712 NTSTATUS dcerpc_winreg_DeleteKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
1713 {
1714         struct dcerpc_winreg_DeleteKey_r_state *state =
1715                 tevent_req_data(req,
1716                 struct dcerpc_winreg_DeleteKey_r_state);
1717         NTSTATUS status;
1718
1719         if (tevent_req_is_nterror(req, &status)) {
1720                 tevent_req_received(req);
1721                 return status;
1722         }
1723
1724         talloc_steal(mem_ctx, state->out_mem_ctx);
1725
1726         tevent_req_received(req);
1727         return NT_STATUS_OK;
1728 }
1729
1730 NTSTATUS dcerpc_winreg_DeleteKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_DeleteKey *r)
1731 {
1732         NTSTATUS status;
1733
1734         status = dcerpc_binding_handle_call(h,
1735                         NULL, &ndr_table_winreg,
1736                         NDR_WINREG_DELETEKEY, mem_ctx, r);
1737
1738         return status;
1739 }
1740
1741 NTSTATUS dcerpc_winreg_DeleteKey_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_DeleteKey *r)
1742 {
1743         NTSTATUS status;
1744
1745         status = dcerpc_winreg_DeleteKey_r(p->binding_handle, mem_ctx, r);
1746
1747         if (NT_STATUS_IS_RPC(status)) {
1748                 status = NT_STATUS_NET_WRITE_FAULT;
1749         }
1750
1751         return status;
1752 }
1753
1754 struct dcerpc_winreg_DeleteKey_state {
1755         struct winreg_DeleteKey orig;
1756         struct winreg_DeleteKey tmp;
1757         TALLOC_CTX *out_mem_ctx;
1758 };
1759
1760 static void dcerpc_winreg_DeleteKey_done(struct tevent_req *subreq);
1761
1762 struct tevent_req *dcerpc_winreg_DeleteKey_send(TALLOC_CTX *mem_ctx,
1763                                                 struct tevent_context *ev,
1764                                                 struct dcerpc_binding_handle *h,
1765                                                 struct policy_handle *_handle /* [in] [ref] */,
1766                                                 struct winreg_String _key /* [in]  */)
1767 {
1768         struct tevent_req *req;
1769         struct dcerpc_winreg_DeleteKey_state *state;
1770         struct tevent_req *subreq;
1771
1772         req = tevent_req_create(mem_ctx, &state,
1773                                 struct dcerpc_winreg_DeleteKey_state);
1774         if (req == NULL) {
1775                 return NULL;
1776         }
1777         state->out_mem_ctx = NULL;
1778
1779         /* In parameters */
1780         state->orig.in.handle = _handle;
1781         state->orig.in.key = _key;
1782
1783         /* Out parameters */
1784
1785         /* Result */
1786         ZERO_STRUCT(state->orig.out.result);
1787
1788         /* make a temporary copy, that we pass to the dispatch function */
1789         state->tmp = state->orig;
1790
1791         subreq = dcerpc_winreg_DeleteKey_r_send(state, ev, h, &state->tmp);
1792         if (tevent_req_nomem(subreq, req)) {
1793                 return tevent_req_post(req, ev);
1794         }
1795         tevent_req_set_callback(subreq, dcerpc_winreg_DeleteKey_done, req);
1796         return req;
1797 }
1798
1799 static void dcerpc_winreg_DeleteKey_done(struct tevent_req *subreq)
1800 {
1801         struct tevent_req *req = tevent_req_callback_data(
1802                 subreq, struct tevent_req);
1803         struct dcerpc_winreg_DeleteKey_state *state = tevent_req_data(
1804                 req, struct dcerpc_winreg_DeleteKey_state);
1805         NTSTATUS status;
1806         TALLOC_CTX *mem_ctx;
1807
1808         if (state->out_mem_ctx) {
1809                 mem_ctx = state->out_mem_ctx;
1810         } else {
1811                 mem_ctx = state;
1812         }
1813
1814         status = dcerpc_winreg_DeleteKey_r_recv(subreq, mem_ctx);
1815         TALLOC_FREE(subreq);
1816         if (!NT_STATUS_IS_OK(status)) {
1817                 tevent_req_nterror(req, status);
1818                 return;
1819         }
1820
1821         /* Copy out parameters */
1822
1823         /* Copy result */
1824         state->orig.out.result = state->tmp.out.result;
1825
1826         /* Reset temporary structure */
1827         ZERO_STRUCT(state->tmp);
1828
1829         tevent_req_done(req);
1830 }
1831
1832 NTSTATUS dcerpc_winreg_DeleteKey_recv(struct tevent_req *req,
1833                                       TALLOC_CTX *mem_ctx,
1834                                       WERROR *result)
1835 {
1836         struct dcerpc_winreg_DeleteKey_state *state = tevent_req_data(
1837                 req, struct dcerpc_winreg_DeleteKey_state);
1838         NTSTATUS status;
1839
1840         if (tevent_req_is_nterror(req, &status)) {
1841                 tevent_req_received(req);
1842                 return status;
1843         }
1844
1845         /* Steal possible out parameters to the callers context */
1846         talloc_steal(mem_ctx, state->out_mem_ctx);
1847
1848         /* Return result */
1849         *result = state->orig.out.result;
1850
1851         tevent_req_received(req);
1852         return NT_STATUS_OK;
1853 }
1854
1855 NTSTATUS dcerpc_winreg_DeleteKey(struct dcerpc_binding_handle *h,
1856                                  TALLOC_CTX *mem_ctx,
1857                                  struct policy_handle *_handle /* [in] [ref] */,
1858                                  struct winreg_String _key /* [in]  */,
1859                                  WERROR *result)
1860 {
1861         struct winreg_DeleteKey r;
1862         NTSTATUS status;
1863
1864         /* In parameters */
1865         r.in.handle = _handle;
1866         r.in.key = _key;
1867
1868         status = dcerpc_winreg_DeleteKey_r(h, mem_ctx, &r);
1869         if (!NT_STATUS_IS_OK(status)) {
1870                 return status;
1871         }
1872
1873         /* Return variables */
1874
1875         /* Return result */
1876         *result = r.out.result;
1877
1878         return NT_STATUS_OK;
1879 }
1880
1881 struct dcerpc_winreg_DeleteValue_r_state {
1882         TALLOC_CTX *out_mem_ctx;
1883 };
1884
1885 static void dcerpc_winreg_DeleteValue_r_done(struct tevent_req *subreq);
1886
1887 struct tevent_req *dcerpc_winreg_DeleteValue_r_send(TALLOC_CTX *mem_ctx,
1888         struct tevent_context *ev,
1889         struct dcerpc_binding_handle *h,
1890         struct winreg_DeleteValue *r)
1891 {
1892         struct tevent_req *req;
1893         struct dcerpc_winreg_DeleteValue_r_state *state;
1894         struct tevent_req *subreq;
1895
1896         req = tevent_req_create(mem_ctx, &state,
1897                                 struct dcerpc_winreg_DeleteValue_r_state);
1898         if (req == NULL) {
1899                 return NULL;
1900         }
1901
1902         state->out_mem_ctx = NULL;
1903         subreq = dcerpc_binding_handle_call_send(state, ev, h,
1904                         NULL, &ndr_table_winreg,
1905                         NDR_WINREG_DELETEVALUE, state, r);
1906         if (tevent_req_nomem(subreq, req)) {
1907                 return tevent_req_post(req, ev);
1908         }
1909         tevent_req_set_callback(subreq, dcerpc_winreg_DeleteValue_r_done, req);
1910
1911         return req;
1912 }
1913
1914 static void dcerpc_winreg_DeleteValue_r_done(struct tevent_req *subreq)
1915 {
1916         struct tevent_req *req =
1917                 tevent_req_callback_data(subreq,
1918                 struct tevent_req);
1919         NTSTATUS status;
1920
1921         status = dcerpc_binding_handle_call_recv(subreq);
1922         if (!NT_STATUS_IS_OK(status)) {
1923                 tevent_req_nterror(req, status);
1924                 return;
1925         }
1926
1927         tevent_req_done(req);
1928 }
1929
1930 NTSTATUS dcerpc_winreg_DeleteValue_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
1931 {
1932         struct dcerpc_winreg_DeleteValue_r_state *state =
1933                 tevent_req_data(req,
1934                 struct dcerpc_winreg_DeleteValue_r_state);
1935         NTSTATUS status;
1936
1937         if (tevent_req_is_nterror(req, &status)) {
1938                 tevent_req_received(req);
1939                 return status;
1940         }
1941
1942         talloc_steal(mem_ctx, state->out_mem_ctx);
1943
1944         tevent_req_received(req);
1945         return NT_STATUS_OK;
1946 }
1947
1948 NTSTATUS dcerpc_winreg_DeleteValue_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_DeleteValue *r)
1949 {
1950         NTSTATUS status;
1951
1952         status = dcerpc_binding_handle_call(h,
1953                         NULL, &ndr_table_winreg,
1954                         NDR_WINREG_DELETEVALUE, mem_ctx, r);
1955
1956         return status;
1957 }
1958
1959 NTSTATUS dcerpc_winreg_DeleteValue_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_DeleteValue *r)
1960 {
1961         NTSTATUS status;
1962
1963         status = dcerpc_winreg_DeleteValue_r(p->binding_handle, mem_ctx, r);
1964
1965         if (NT_STATUS_IS_RPC(status)) {
1966                 status = NT_STATUS_NET_WRITE_FAULT;
1967         }
1968
1969         return status;
1970 }
1971
1972 struct dcerpc_winreg_DeleteValue_state {
1973         struct winreg_DeleteValue orig;
1974         struct winreg_DeleteValue tmp;
1975         TALLOC_CTX *out_mem_ctx;
1976 };
1977
1978 static void dcerpc_winreg_DeleteValue_done(struct tevent_req *subreq);
1979
1980 struct tevent_req *dcerpc_winreg_DeleteValue_send(TALLOC_CTX *mem_ctx,
1981                                                   struct tevent_context *ev,
1982                                                   struct dcerpc_binding_handle *h,
1983                                                   struct policy_handle *_handle /* [in] [ref] */,
1984                                                   struct winreg_String _value /* [in]  */)
1985 {
1986         struct tevent_req *req;
1987         struct dcerpc_winreg_DeleteValue_state *state;
1988         struct tevent_req *subreq;
1989
1990         req = tevent_req_create(mem_ctx, &state,
1991                                 struct dcerpc_winreg_DeleteValue_state);
1992         if (req == NULL) {
1993                 return NULL;
1994         }
1995         state->out_mem_ctx = NULL;
1996
1997         /* In parameters */
1998         state->orig.in.handle = _handle;
1999         state->orig.in.value = _value;
2000
2001         /* Out parameters */
2002
2003         /* Result */
2004         ZERO_STRUCT(state->orig.out.result);
2005
2006         /* make a temporary copy, that we pass to the dispatch function */
2007         state->tmp = state->orig;
2008
2009         subreq = dcerpc_winreg_DeleteValue_r_send(state, ev, h, &state->tmp);
2010         if (tevent_req_nomem(subreq, req)) {
2011                 return tevent_req_post(req, ev);
2012         }
2013         tevent_req_set_callback(subreq, dcerpc_winreg_DeleteValue_done, req);
2014         return req;
2015 }
2016
2017 static void dcerpc_winreg_DeleteValue_done(struct tevent_req *subreq)
2018 {
2019         struct tevent_req *req = tevent_req_callback_data(
2020                 subreq, struct tevent_req);
2021         struct dcerpc_winreg_DeleteValue_state *state = tevent_req_data(
2022                 req, struct dcerpc_winreg_DeleteValue_state);
2023         NTSTATUS status;
2024         TALLOC_CTX *mem_ctx;
2025
2026         if (state->out_mem_ctx) {
2027                 mem_ctx = state->out_mem_ctx;
2028         } else {
2029                 mem_ctx = state;
2030         }
2031
2032         status = dcerpc_winreg_DeleteValue_r_recv(subreq, mem_ctx);
2033         TALLOC_FREE(subreq);
2034         if (!NT_STATUS_IS_OK(status)) {
2035                 tevent_req_nterror(req, status);
2036                 return;
2037         }
2038
2039         /* Copy out parameters */
2040
2041         /* Copy result */
2042         state->orig.out.result = state->tmp.out.result;
2043
2044         /* Reset temporary structure */
2045         ZERO_STRUCT(state->tmp);
2046
2047         tevent_req_done(req);
2048 }
2049
2050 NTSTATUS dcerpc_winreg_DeleteValue_recv(struct tevent_req *req,
2051                                         TALLOC_CTX *mem_ctx,
2052                                         WERROR *result)
2053 {
2054         struct dcerpc_winreg_DeleteValue_state *state = tevent_req_data(
2055                 req, struct dcerpc_winreg_DeleteValue_state);
2056         NTSTATUS status;
2057
2058         if (tevent_req_is_nterror(req, &status)) {
2059                 tevent_req_received(req);
2060                 return status;
2061         }
2062
2063         /* Steal possible out parameters to the callers context */
2064         talloc_steal(mem_ctx, state->out_mem_ctx);
2065
2066         /* Return result */
2067         *result = state->orig.out.result;
2068
2069         tevent_req_received(req);
2070         return NT_STATUS_OK;
2071 }
2072
2073 NTSTATUS dcerpc_winreg_DeleteValue(struct dcerpc_binding_handle *h,
2074                                    TALLOC_CTX *mem_ctx,
2075                                    struct policy_handle *_handle /* [in] [ref] */,
2076                                    struct winreg_String _value /* [in]  */,
2077                                    WERROR *result)
2078 {
2079         struct winreg_DeleteValue r;
2080         NTSTATUS status;
2081
2082         /* In parameters */
2083         r.in.handle = _handle;
2084         r.in.value = _value;
2085
2086         status = dcerpc_winreg_DeleteValue_r(h, mem_ctx, &r);
2087         if (!NT_STATUS_IS_OK(status)) {
2088                 return status;
2089         }
2090
2091         /* Return variables */
2092
2093         /* Return result */
2094         *result = r.out.result;
2095
2096         return NT_STATUS_OK;
2097 }
2098
2099 struct dcerpc_winreg_EnumKey_r_state {
2100         TALLOC_CTX *out_mem_ctx;
2101 };
2102
2103 static void dcerpc_winreg_EnumKey_r_done(struct tevent_req *subreq);
2104
2105 struct tevent_req *dcerpc_winreg_EnumKey_r_send(TALLOC_CTX *mem_ctx,
2106         struct tevent_context *ev,
2107         struct dcerpc_binding_handle *h,
2108         struct winreg_EnumKey *r)
2109 {
2110         struct tevent_req *req;
2111         struct dcerpc_winreg_EnumKey_r_state *state;
2112         struct tevent_req *subreq;
2113
2114         req = tevent_req_create(mem_ctx, &state,
2115                                 struct dcerpc_winreg_EnumKey_r_state);
2116         if (req == NULL) {
2117                 return NULL;
2118         }
2119
2120         state->out_mem_ctx = talloc_new(state);
2121         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2122                 return tevent_req_post(req, ev);
2123         }
2124
2125         subreq = dcerpc_binding_handle_call_send(state, ev, h,
2126                         NULL, &ndr_table_winreg,
2127                         NDR_WINREG_ENUMKEY, state->out_mem_ctx, r);
2128         if (tevent_req_nomem(subreq, req)) {
2129                 return tevent_req_post(req, ev);
2130         }
2131         tevent_req_set_callback(subreq, dcerpc_winreg_EnumKey_r_done, req);
2132
2133         return req;
2134 }
2135
2136 static void dcerpc_winreg_EnumKey_r_done(struct tevent_req *subreq)
2137 {
2138         struct tevent_req *req =
2139                 tevent_req_callback_data(subreq,
2140                 struct tevent_req);
2141         NTSTATUS status;
2142
2143         status = dcerpc_binding_handle_call_recv(subreq);
2144         if (!NT_STATUS_IS_OK(status)) {
2145                 tevent_req_nterror(req, status);
2146                 return;
2147         }
2148
2149         tevent_req_done(req);
2150 }
2151
2152 NTSTATUS dcerpc_winreg_EnumKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
2153 {
2154         struct dcerpc_winreg_EnumKey_r_state *state =
2155                 tevent_req_data(req,
2156                 struct dcerpc_winreg_EnumKey_r_state);
2157         NTSTATUS status;
2158
2159         if (tevent_req_is_nterror(req, &status)) {
2160                 tevent_req_received(req);
2161                 return status;
2162         }
2163
2164         talloc_steal(mem_ctx, state->out_mem_ctx);
2165
2166         tevent_req_received(req);
2167         return NT_STATUS_OK;
2168 }
2169
2170 NTSTATUS dcerpc_winreg_EnumKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_EnumKey *r)
2171 {
2172         NTSTATUS status;
2173
2174         status = dcerpc_binding_handle_call(h,
2175                         NULL, &ndr_table_winreg,
2176                         NDR_WINREG_ENUMKEY, mem_ctx, r);
2177
2178         return status;
2179 }
2180
2181 NTSTATUS dcerpc_winreg_EnumKey_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_EnumKey *r)
2182 {
2183         NTSTATUS status;
2184
2185         status = dcerpc_winreg_EnumKey_r(p->binding_handle, mem_ctx, r);
2186
2187         if (NT_STATUS_IS_RPC(status)) {
2188                 status = NT_STATUS_NET_WRITE_FAULT;
2189         }
2190
2191         return status;
2192 }
2193
2194 struct dcerpc_winreg_EnumKey_state {
2195         struct winreg_EnumKey orig;
2196         struct winreg_EnumKey tmp;
2197         TALLOC_CTX *out_mem_ctx;
2198 };
2199
2200 static void dcerpc_winreg_EnumKey_done(struct tevent_req *subreq);
2201
2202 struct tevent_req *dcerpc_winreg_EnumKey_send(TALLOC_CTX *mem_ctx,
2203                                               struct tevent_context *ev,
2204                                               struct dcerpc_binding_handle *h,
2205                                               struct policy_handle *_handle /* [in] [ref] */,
2206                                               uint32_t _enum_index /* [in]  */,
2207                                               struct winreg_StringBuf *_name /* [in,out] [ref] */,
2208                                               struct winreg_StringBuf *_keyclass /* [in,out] [unique] */,
2209                                               NTTIME *_last_changed_time /* [in,out] [unique] */)
2210 {
2211         struct tevent_req *req;
2212         struct dcerpc_winreg_EnumKey_state *state;
2213         struct tevent_req *subreq;
2214
2215         req = tevent_req_create(mem_ctx, &state,
2216                                 struct dcerpc_winreg_EnumKey_state);
2217         if (req == NULL) {
2218                 return NULL;
2219         }
2220         state->out_mem_ctx = NULL;
2221
2222         /* In parameters */
2223         state->orig.in.handle = _handle;
2224         state->orig.in.enum_index = _enum_index;
2225         state->orig.in.name = _name;
2226         state->orig.in.keyclass = _keyclass;
2227         state->orig.in.last_changed_time = _last_changed_time;
2228
2229         /* Out parameters */
2230         state->orig.out.name = _name;
2231         state->orig.out.keyclass = _keyclass;
2232         state->orig.out.last_changed_time = _last_changed_time;
2233
2234         /* Result */
2235         ZERO_STRUCT(state->orig.out.result);
2236
2237         state->out_mem_ctx = talloc_named_const(state, 0,
2238                              "dcerpc_winreg_EnumKey_out_memory");
2239         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2240                 return tevent_req_post(req, ev);
2241         }
2242
2243         /* make a temporary copy, that we pass to the dispatch function */
2244         state->tmp = state->orig;
2245
2246         subreq = dcerpc_winreg_EnumKey_r_send(state, ev, h, &state->tmp);
2247         if (tevent_req_nomem(subreq, req)) {
2248                 return tevent_req_post(req, ev);
2249         }
2250         tevent_req_set_callback(subreq, dcerpc_winreg_EnumKey_done, req);
2251         return req;
2252 }
2253
2254 static void dcerpc_winreg_EnumKey_done(struct tevent_req *subreq)
2255 {
2256         struct tevent_req *req = tevent_req_callback_data(
2257                 subreq, struct tevent_req);
2258         struct dcerpc_winreg_EnumKey_state *state = tevent_req_data(
2259                 req, struct dcerpc_winreg_EnumKey_state);
2260         NTSTATUS status;
2261         TALLOC_CTX *mem_ctx;
2262
2263         if (state->out_mem_ctx) {
2264                 mem_ctx = state->out_mem_ctx;
2265         } else {
2266                 mem_ctx = state;
2267         }
2268
2269         status = dcerpc_winreg_EnumKey_r_recv(subreq, mem_ctx);
2270         TALLOC_FREE(subreq);
2271         if (!NT_STATUS_IS_OK(status)) {
2272                 tevent_req_nterror(req, status);
2273                 return;
2274         }
2275
2276         /* Copy out parameters */
2277         *state->orig.out.name = *state->tmp.out.name;
2278         if (state->orig.out.keyclass && state->tmp.out.keyclass) {
2279                 *state->orig.out.keyclass = *state->tmp.out.keyclass;
2280         }
2281         if (state->orig.out.last_changed_time && state->tmp.out.last_changed_time) {
2282                 *state->orig.out.last_changed_time = *state->tmp.out.last_changed_time;
2283         }
2284
2285         /* Copy result */
2286         state->orig.out.result = state->tmp.out.result;
2287
2288         /* Reset temporary structure */
2289         ZERO_STRUCT(state->tmp);
2290
2291         tevent_req_done(req);
2292 }
2293
2294 NTSTATUS dcerpc_winreg_EnumKey_recv(struct tevent_req *req,
2295                                     TALLOC_CTX *mem_ctx,
2296                                     WERROR *result)
2297 {
2298         struct dcerpc_winreg_EnumKey_state *state = tevent_req_data(
2299                 req, struct dcerpc_winreg_EnumKey_state);
2300         NTSTATUS status;
2301
2302         if (tevent_req_is_nterror(req, &status)) {
2303                 tevent_req_received(req);
2304                 return status;
2305         }
2306
2307         /* Steal possible out parameters to the callers context */
2308         talloc_steal(mem_ctx, state->out_mem_ctx);
2309
2310         /* Return result */
2311         *result = state->orig.out.result;
2312
2313         tevent_req_received(req);
2314         return NT_STATUS_OK;
2315 }
2316
2317 NTSTATUS dcerpc_winreg_EnumKey(struct dcerpc_binding_handle *h,
2318                                TALLOC_CTX *mem_ctx,
2319                                struct policy_handle *_handle /* [in] [ref] */,
2320                                uint32_t _enum_index /* [in]  */,
2321                                struct winreg_StringBuf *_name /* [in,out] [ref] */,
2322                                struct winreg_StringBuf *_keyclass /* [in,out] [unique] */,
2323                                NTTIME *_last_changed_time /* [in,out] [unique] */,
2324                                WERROR *result)
2325 {
2326         struct winreg_EnumKey r;
2327         NTSTATUS status;
2328
2329         /* In parameters */
2330         r.in.handle = _handle;
2331         r.in.enum_index = _enum_index;
2332         r.in.name = _name;
2333         r.in.keyclass = _keyclass;
2334         r.in.last_changed_time = _last_changed_time;
2335
2336         status = dcerpc_winreg_EnumKey_r(h, mem_ctx, &r);
2337         if (!NT_STATUS_IS_OK(status)) {
2338                 return status;
2339         }
2340
2341         /* Return variables */
2342         *_name = *r.out.name;
2343         if (_keyclass && r.out.keyclass) {
2344                 *_keyclass = *r.out.keyclass;
2345         }
2346         if (_last_changed_time && r.out.last_changed_time) {
2347                 *_last_changed_time = *r.out.last_changed_time;
2348         }
2349
2350         /* Return result */
2351         *result = r.out.result;
2352
2353         return NT_STATUS_OK;
2354 }
2355
2356 struct dcerpc_winreg_EnumValue_r_state {
2357         TALLOC_CTX *out_mem_ctx;
2358 };
2359
2360 static void dcerpc_winreg_EnumValue_r_done(struct tevent_req *subreq);
2361
2362 struct tevent_req *dcerpc_winreg_EnumValue_r_send(TALLOC_CTX *mem_ctx,
2363         struct tevent_context *ev,
2364         struct dcerpc_binding_handle *h,
2365         struct winreg_EnumValue *r)
2366 {
2367         struct tevent_req *req;
2368         struct dcerpc_winreg_EnumValue_r_state *state;
2369         struct tevent_req *subreq;
2370
2371         req = tevent_req_create(mem_ctx, &state,
2372                                 struct dcerpc_winreg_EnumValue_r_state);
2373         if (req == NULL) {
2374                 return NULL;
2375         }
2376
2377         state->out_mem_ctx = talloc_new(state);
2378         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2379                 return tevent_req_post(req, ev);
2380         }
2381
2382         subreq = dcerpc_binding_handle_call_send(state, ev, h,
2383                         NULL, &ndr_table_winreg,
2384                         NDR_WINREG_ENUMVALUE, state->out_mem_ctx, r);
2385         if (tevent_req_nomem(subreq, req)) {
2386                 return tevent_req_post(req, ev);
2387         }
2388         tevent_req_set_callback(subreq, dcerpc_winreg_EnumValue_r_done, req);
2389
2390         return req;
2391 }
2392
2393 static void dcerpc_winreg_EnumValue_r_done(struct tevent_req *subreq)
2394 {
2395         struct tevent_req *req =
2396                 tevent_req_callback_data(subreq,
2397                 struct tevent_req);
2398         NTSTATUS status;
2399
2400         status = dcerpc_binding_handle_call_recv(subreq);
2401         if (!NT_STATUS_IS_OK(status)) {
2402                 tevent_req_nterror(req, status);
2403                 return;
2404         }
2405
2406         tevent_req_done(req);
2407 }
2408
2409 NTSTATUS dcerpc_winreg_EnumValue_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
2410 {
2411         struct dcerpc_winreg_EnumValue_r_state *state =
2412                 tevent_req_data(req,
2413                 struct dcerpc_winreg_EnumValue_r_state);
2414         NTSTATUS status;
2415
2416         if (tevent_req_is_nterror(req, &status)) {
2417                 tevent_req_received(req);
2418                 return status;
2419         }
2420
2421         talloc_steal(mem_ctx, state->out_mem_ctx);
2422
2423         tevent_req_received(req);
2424         return NT_STATUS_OK;
2425 }
2426
2427 NTSTATUS dcerpc_winreg_EnumValue_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_EnumValue *r)
2428 {
2429         NTSTATUS status;
2430
2431         status = dcerpc_binding_handle_call(h,
2432                         NULL, &ndr_table_winreg,
2433                         NDR_WINREG_ENUMVALUE, mem_ctx, r);
2434
2435         return status;
2436 }
2437
2438 NTSTATUS dcerpc_winreg_EnumValue_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_EnumValue *r)
2439 {
2440         NTSTATUS status;
2441
2442         status = dcerpc_winreg_EnumValue_r(p->binding_handle, mem_ctx, r);
2443
2444         if (NT_STATUS_IS_RPC(status)) {
2445                 status = NT_STATUS_NET_WRITE_FAULT;
2446         }
2447
2448         return status;
2449 }
2450
2451 struct dcerpc_winreg_EnumValue_state {
2452         struct winreg_EnumValue orig;
2453         struct winreg_EnumValue tmp;
2454         TALLOC_CTX *out_mem_ctx;
2455 };
2456
2457 static void dcerpc_winreg_EnumValue_done(struct tevent_req *subreq);
2458
2459 struct tevent_req *dcerpc_winreg_EnumValue_send(TALLOC_CTX *mem_ctx,
2460                                                 struct tevent_context *ev,
2461                                                 struct dcerpc_binding_handle *h,
2462                                                 struct policy_handle *_handle /* [in] [ref] */,
2463                                                 uint32_t _enum_index /* [in]  */,
2464                                                 struct winreg_ValNameBuf *_name /* [in,out] [ref] */,
2465                                                 enum winreg_Type *_type /* [in,out] [unique] */,
2466                                                 uint8_t *_value /* [in,out] [unique,range(0,0x4000000),length_is(length?*length:0),size_is(size?*size:0)] */,
2467                                                 uint32_t *_size /* [in,out] [unique] */,
2468                                                 uint32_t *_length /* [in,out] [unique] */)
2469 {
2470         struct tevent_req *req;
2471         struct dcerpc_winreg_EnumValue_state *state;
2472         struct tevent_req *subreq;
2473
2474         req = tevent_req_create(mem_ctx, &state,
2475                                 struct dcerpc_winreg_EnumValue_state);
2476         if (req == NULL) {
2477                 return NULL;
2478         }
2479         state->out_mem_ctx = NULL;
2480
2481         /* In parameters */
2482         state->orig.in.handle = _handle;
2483         state->orig.in.enum_index = _enum_index;
2484         state->orig.in.name = _name;
2485         state->orig.in.type = _type;
2486         state->orig.in.value = _value;
2487         state->orig.in.size = _size;
2488         state->orig.in.length = _length;
2489
2490         /* Out parameters */
2491         state->orig.out.name = _name;
2492         state->orig.out.type = _type;
2493         state->orig.out.value = _value;
2494         state->orig.out.size = _size;
2495         state->orig.out.length = _length;
2496
2497         /* Result */
2498         ZERO_STRUCT(state->orig.out.result);
2499
2500         state->out_mem_ctx = talloc_named_const(state, 0,
2501                              "dcerpc_winreg_EnumValue_out_memory");
2502         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2503                 return tevent_req_post(req, ev);
2504         }
2505
2506         /* make a temporary copy, that we pass to the dispatch function */
2507         state->tmp = state->orig;
2508
2509         subreq = dcerpc_winreg_EnumValue_r_send(state, ev, h, &state->tmp);
2510         if (tevent_req_nomem(subreq, req)) {
2511                 return tevent_req_post(req, ev);
2512         }
2513         tevent_req_set_callback(subreq, dcerpc_winreg_EnumValue_done, req);
2514         return req;
2515 }
2516
2517 static void dcerpc_winreg_EnumValue_done(struct tevent_req *subreq)
2518 {
2519         struct tevent_req *req = tevent_req_callback_data(
2520                 subreq, struct tevent_req);
2521         struct dcerpc_winreg_EnumValue_state *state = tevent_req_data(
2522                 req, struct dcerpc_winreg_EnumValue_state);
2523         NTSTATUS status;
2524         TALLOC_CTX *mem_ctx;
2525
2526         if (state->out_mem_ctx) {
2527                 mem_ctx = state->out_mem_ctx;
2528         } else {
2529                 mem_ctx = state;
2530         }
2531
2532         status = dcerpc_winreg_EnumValue_r_recv(subreq, mem_ctx);
2533         TALLOC_FREE(subreq);
2534         if (!NT_STATUS_IS_OK(status)) {
2535                 tevent_req_nterror(req, status);
2536                 return;
2537         }
2538
2539         /* Copy out parameters */
2540         *state->orig.out.name = *state->tmp.out.name;
2541         if (state->orig.out.type && state->tmp.out.type) {
2542                 *state->orig.out.type = *state->tmp.out.type;
2543         }
2544         if (state->orig.out.value && state->tmp.out.value) {
2545                 {
2546                         size_t _copy_len_value;
2547                         if ((state->tmp.out.size?*state->tmp.out.size:0) > (state->tmp.in.size?*state->tmp.in.size:0)) {
2548                                 tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
2549                                 return;
2550                         }
2551                         if ((state->tmp.out.length?*state->tmp.out.length:0) > (state->tmp.out.size?*state->tmp.out.size:0)) {
2552                                 tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
2553                                 return;
2554                         }
2555                         _copy_len_value = state->tmp.out.length?*state->tmp.out.length:0;
2556                         memcpy(state->orig.out.value, state->tmp.out.value, _copy_len_value * sizeof(*state->orig.out.value));
2557                 }
2558         }
2559         if (state->orig.out.size && state->tmp.out.size) {
2560                 *state->orig.out.size = *state->tmp.out.size;
2561         }
2562         if (state->orig.out.length && state->tmp.out.length) {
2563                 *state->orig.out.length = *state->tmp.out.length;
2564         }
2565
2566         /* Copy result */
2567         state->orig.out.result = state->tmp.out.result;
2568
2569         /* Reset temporary structure */
2570         ZERO_STRUCT(state->tmp);
2571
2572         tevent_req_done(req);
2573 }
2574
2575 NTSTATUS dcerpc_winreg_EnumValue_recv(struct tevent_req *req,
2576                                       TALLOC_CTX *mem_ctx,
2577                                       WERROR *result)
2578 {
2579         struct dcerpc_winreg_EnumValue_state *state = tevent_req_data(
2580                 req, struct dcerpc_winreg_EnumValue_state);
2581         NTSTATUS status;
2582
2583         if (tevent_req_is_nterror(req, &status)) {
2584                 tevent_req_received(req);
2585                 return status;
2586         }
2587
2588         /* Steal possible out parameters to the callers context */
2589         talloc_steal(mem_ctx, state->out_mem_ctx);
2590
2591         /* Return result */
2592         *result = state->orig.out.result;
2593
2594         tevent_req_received(req);
2595         return NT_STATUS_OK;
2596 }
2597
2598 NTSTATUS dcerpc_winreg_EnumValue(struct dcerpc_binding_handle *h,
2599                                  TALLOC_CTX *mem_ctx,
2600                                  struct policy_handle *_handle /* [in] [ref] */,
2601                                  uint32_t _enum_index /* [in]  */,
2602                                  struct winreg_ValNameBuf *_name /* [in,out] [ref] */,
2603                                  enum winreg_Type *_type /* [in,out] [unique] */,
2604                                  uint8_t *_value /* [in,out] [unique,range(0,0x4000000),length_is(length?*length:0),size_is(size?*size:0)] */,
2605                                  uint32_t *_size /* [in,out] [unique] */,
2606                                  uint32_t *_length /* [in,out] [unique] */,
2607                                  WERROR *result)
2608 {
2609         struct winreg_EnumValue r;
2610         NTSTATUS status;
2611
2612         /* In parameters */
2613         r.in.handle = _handle;
2614         r.in.enum_index = _enum_index;
2615         r.in.name = _name;
2616         r.in.type = _type;
2617         r.in.value = _value;
2618         r.in.size = _size;
2619         r.in.length = _length;
2620
2621         status = dcerpc_winreg_EnumValue_r(h, mem_ctx, &r);
2622         if (!NT_STATUS_IS_OK(status)) {
2623                 return status;
2624         }
2625
2626         /* Return variables */
2627         *_name = *r.out.name;
2628         if (_type && r.out.type) {
2629                 *_type = *r.out.type;
2630         }
2631         if (_value && r.out.value) {
2632                 {
2633                         size_t _copy_len_value;
2634                         if ((r.out.size?*r.out.size:0) > (r.in.size?*r.in.size:0)) {
2635                                 return NT_STATUS_INVALID_NETWORK_RESPONSE;
2636                         }
2637                         if ((r.out.length?*r.out.length:0) > (r.out.size?*r.out.size:0)) {
2638                                 return NT_STATUS_INVALID_NETWORK_RESPONSE;
2639                         }
2640                         _copy_len_value = r.out.length?*r.out.length:0;
2641                         memcpy(_value, r.out.value, _copy_len_value * sizeof(*_value));
2642                 }
2643         }
2644         if (_size && r.out.size) {
2645                 *_size = *r.out.size;
2646         }
2647         if (_length && r.out.length) {
2648                 *_length = *r.out.length;
2649         }
2650
2651         /* Return result */
2652         *result = r.out.result;
2653
2654         return NT_STATUS_OK;
2655 }
2656
2657 struct dcerpc_winreg_FlushKey_r_state {
2658         TALLOC_CTX *out_mem_ctx;
2659 };
2660
2661 static void dcerpc_winreg_FlushKey_r_done(struct tevent_req *subreq);
2662
2663 struct tevent_req *dcerpc_winreg_FlushKey_r_send(TALLOC_CTX *mem_ctx,
2664         struct tevent_context *ev,
2665         struct dcerpc_binding_handle *h,
2666         struct winreg_FlushKey *r)
2667 {
2668         struct tevent_req *req;
2669         struct dcerpc_winreg_FlushKey_r_state *state;
2670         struct tevent_req *subreq;
2671
2672         req = tevent_req_create(mem_ctx, &state,
2673                                 struct dcerpc_winreg_FlushKey_r_state);
2674         if (req == NULL) {
2675                 return NULL;
2676         }
2677
2678         state->out_mem_ctx = NULL;
2679         subreq = dcerpc_binding_handle_call_send(state, ev, h,
2680                         NULL, &ndr_table_winreg,
2681                         NDR_WINREG_FLUSHKEY, state, r);
2682         if (tevent_req_nomem(subreq, req)) {
2683                 return tevent_req_post(req, ev);
2684         }
2685         tevent_req_set_callback(subreq, dcerpc_winreg_FlushKey_r_done, req);
2686
2687         return req;
2688 }
2689
2690 static void dcerpc_winreg_FlushKey_r_done(struct tevent_req *subreq)
2691 {
2692         struct tevent_req *req =
2693                 tevent_req_callback_data(subreq,
2694                 struct tevent_req);
2695         NTSTATUS status;
2696
2697         status = dcerpc_binding_handle_call_recv(subreq);
2698         if (!NT_STATUS_IS_OK(status)) {
2699                 tevent_req_nterror(req, status);
2700                 return;
2701         }
2702
2703         tevent_req_done(req);
2704 }
2705
2706 NTSTATUS dcerpc_winreg_FlushKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
2707 {
2708         struct dcerpc_winreg_FlushKey_r_state *state =
2709                 tevent_req_data(req,
2710                 struct dcerpc_winreg_FlushKey_r_state);
2711         NTSTATUS status;
2712
2713         if (tevent_req_is_nterror(req, &status)) {
2714                 tevent_req_received(req);
2715                 return status;
2716         }
2717
2718         talloc_steal(mem_ctx, state->out_mem_ctx);
2719
2720         tevent_req_received(req);
2721         return NT_STATUS_OK;
2722 }
2723
2724 NTSTATUS dcerpc_winreg_FlushKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_FlushKey *r)
2725 {
2726         NTSTATUS status;
2727
2728         status = dcerpc_binding_handle_call(h,
2729                         NULL, &ndr_table_winreg,
2730                         NDR_WINREG_FLUSHKEY, mem_ctx, r);
2731
2732         return status;
2733 }
2734
2735 NTSTATUS dcerpc_winreg_FlushKey_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_FlushKey *r)
2736 {
2737         NTSTATUS status;
2738
2739         status = dcerpc_winreg_FlushKey_r(p->binding_handle, mem_ctx, r);
2740
2741         if (NT_STATUS_IS_RPC(status)) {
2742                 status = NT_STATUS_NET_WRITE_FAULT;
2743         }
2744
2745         return status;
2746 }
2747
2748 struct dcerpc_winreg_FlushKey_state {
2749         struct winreg_FlushKey orig;
2750         struct winreg_FlushKey tmp;
2751         TALLOC_CTX *out_mem_ctx;
2752 };
2753
2754 static void dcerpc_winreg_FlushKey_done(struct tevent_req *subreq);
2755
2756 struct tevent_req *dcerpc_winreg_FlushKey_send(TALLOC_CTX *mem_ctx,
2757                                                struct tevent_context *ev,
2758                                                struct dcerpc_binding_handle *h,
2759                                                struct policy_handle *_handle /* [in] [ref] */)
2760 {
2761         struct tevent_req *req;
2762         struct dcerpc_winreg_FlushKey_state *state;
2763         struct tevent_req *subreq;
2764
2765         req = tevent_req_create(mem_ctx, &state,
2766                                 struct dcerpc_winreg_FlushKey_state);
2767         if (req == NULL) {
2768                 return NULL;
2769         }
2770         state->out_mem_ctx = NULL;
2771
2772         /* In parameters */
2773         state->orig.in.handle = _handle;
2774
2775         /* Out parameters */
2776
2777         /* Result */
2778         ZERO_STRUCT(state->orig.out.result);
2779
2780         /* make a temporary copy, that we pass to the dispatch function */
2781         state->tmp = state->orig;
2782
2783         subreq = dcerpc_winreg_FlushKey_r_send(state, ev, h, &state->tmp);
2784         if (tevent_req_nomem(subreq, req)) {
2785                 return tevent_req_post(req, ev);
2786         }
2787         tevent_req_set_callback(subreq, dcerpc_winreg_FlushKey_done, req);
2788         return req;
2789 }
2790
2791 static void dcerpc_winreg_FlushKey_done(struct tevent_req *subreq)
2792 {
2793         struct tevent_req *req = tevent_req_callback_data(
2794                 subreq, struct tevent_req);
2795         struct dcerpc_winreg_FlushKey_state *state = tevent_req_data(
2796                 req, struct dcerpc_winreg_FlushKey_state);
2797         NTSTATUS status;
2798         TALLOC_CTX *mem_ctx;
2799
2800         if (state->out_mem_ctx) {
2801                 mem_ctx = state->out_mem_ctx;
2802         } else {
2803                 mem_ctx = state;
2804         }
2805
2806         status = dcerpc_winreg_FlushKey_r_recv(subreq, mem_ctx);
2807         TALLOC_FREE(subreq);
2808         if (!NT_STATUS_IS_OK(status)) {
2809                 tevent_req_nterror(req, status);
2810                 return;
2811         }
2812
2813         /* Copy out parameters */
2814
2815         /* Copy result */
2816         state->orig.out.result = state->tmp.out.result;
2817
2818         /* Reset temporary structure */
2819         ZERO_STRUCT(state->tmp);
2820
2821         tevent_req_done(req);
2822 }
2823
2824 NTSTATUS dcerpc_winreg_FlushKey_recv(struct tevent_req *req,
2825                                      TALLOC_CTX *mem_ctx,
2826                                      WERROR *result)
2827 {
2828         struct dcerpc_winreg_FlushKey_state *state = tevent_req_data(
2829                 req, struct dcerpc_winreg_FlushKey_state);
2830         NTSTATUS status;
2831
2832         if (tevent_req_is_nterror(req, &status)) {
2833                 tevent_req_received(req);
2834                 return status;
2835         }
2836
2837         /* Steal possible out parameters to the callers context */
2838         talloc_steal(mem_ctx, state->out_mem_ctx);
2839
2840         /* Return result */
2841         *result = state->orig.out.result;
2842
2843         tevent_req_received(req);
2844         return NT_STATUS_OK;
2845 }
2846
2847 NTSTATUS dcerpc_winreg_FlushKey(struct dcerpc_binding_handle *h,
2848                                 TALLOC_CTX *mem_ctx,
2849                                 struct policy_handle *_handle /* [in] [ref] */,
2850                                 WERROR *result)
2851 {
2852         struct winreg_FlushKey r;
2853         NTSTATUS status;
2854
2855         /* In parameters */
2856         r.in.handle = _handle;
2857
2858         status = dcerpc_winreg_FlushKey_r(h, mem_ctx, &r);
2859         if (!NT_STATUS_IS_OK(status)) {
2860                 return status;
2861         }
2862
2863         /* Return variables */
2864
2865         /* Return result */
2866         *result = r.out.result;
2867
2868         return NT_STATUS_OK;
2869 }
2870
2871 struct dcerpc_winreg_GetKeySecurity_r_state {
2872         TALLOC_CTX *out_mem_ctx;
2873 };
2874
2875 static void dcerpc_winreg_GetKeySecurity_r_done(struct tevent_req *subreq);
2876
2877 struct tevent_req *dcerpc_winreg_GetKeySecurity_r_send(TALLOC_CTX *mem_ctx,
2878         struct tevent_context *ev,
2879         struct dcerpc_binding_handle *h,
2880         struct winreg_GetKeySecurity *r)
2881 {
2882         struct tevent_req *req;
2883         struct dcerpc_winreg_GetKeySecurity_r_state *state;
2884         struct tevent_req *subreq;
2885
2886         req = tevent_req_create(mem_ctx, &state,
2887                                 struct dcerpc_winreg_GetKeySecurity_r_state);
2888         if (req == NULL) {
2889                 return NULL;
2890         }
2891
2892         state->out_mem_ctx = talloc_new(state);
2893         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2894                 return tevent_req_post(req, ev);
2895         }
2896
2897         subreq = dcerpc_binding_handle_call_send(state, ev, h,
2898                         NULL, &ndr_table_winreg,
2899                         NDR_WINREG_GETKEYSECURITY, state->out_mem_ctx, r);
2900         if (tevent_req_nomem(subreq, req)) {
2901                 return tevent_req_post(req, ev);
2902         }
2903         tevent_req_set_callback(subreq, dcerpc_winreg_GetKeySecurity_r_done, req);
2904
2905         return req;
2906 }
2907
2908 static void dcerpc_winreg_GetKeySecurity_r_done(struct tevent_req *subreq)
2909 {
2910         struct tevent_req *req =
2911                 tevent_req_callback_data(subreq,
2912                 struct tevent_req);
2913         NTSTATUS status;
2914
2915         status = dcerpc_binding_handle_call_recv(subreq);
2916         if (!NT_STATUS_IS_OK(status)) {
2917                 tevent_req_nterror(req, status);
2918                 return;
2919         }
2920
2921         tevent_req_done(req);
2922 }
2923
2924 NTSTATUS dcerpc_winreg_GetKeySecurity_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
2925 {
2926         struct dcerpc_winreg_GetKeySecurity_r_state *state =
2927                 tevent_req_data(req,
2928                 struct dcerpc_winreg_GetKeySecurity_r_state);
2929         NTSTATUS status;
2930
2931         if (tevent_req_is_nterror(req, &status)) {
2932                 tevent_req_received(req);
2933                 return status;
2934         }
2935
2936         talloc_steal(mem_ctx, state->out_mem_ctx);
2937
2938         tevent_req_received(req);
2939         return NT_STATUS_OK;
2940 }
2941
2942 NTSTATUS dcerpc_winreg_GetKeySecurity_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_GetKeySecurity *r)
2943 {
2944         NTSTATUS status;
2945
2946         status = dcerpc_binding_handle_call(h,
2947                         NULL, &ndr_table_winreg,
2948                         NDR_WINREG_GETKEYSECURITY, mem_ctx, r);
2949
2950         return status;
2951 }
2952
2953 NTSTATUS dcerpc_winreg_GetKeySecurity_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_GetKeySecurity *r)
2954 {
2955         NTSTATUS status;
2956
2957         status = dcerpc_winreg_GetKeySecurity_r(p->binding_handle, mem_ctx, r);
2958
2959         if (NT_STATUS_IS_RPC(status)) {
2960                 status = NT_STATUS_NET_WRITE_FAULT;
2961         }
2962
2963         return status;
2964 }
2965
2966 struct dcerpc_winreg_GetKeySecurity_state {
2967         struct winreg_GetKeySecurity orig;
2968         struct winreg_GetKeySecurity tmp;
2969         TALLOC_CTX *out_mem_ctx;
2970 };
2971
2972 static void dcerpc_winreg_GetKeySecurity_done(struct tevent_req *subreq);
2973
2974 struct tevent_req *dcerpc_winreg_GetKeySecurity_send(TALLOC_CTX *mem_ctx,
2975                                                      struct tevent_context *ev,
2976                                                      struct dcerpc_binding_handle *h,
2977                                                      struct policy_handle *_handle /* [in] [ref] */,
2978                                                      uint32_t _sec_info /* [in]  */,
2979                                                      struct KeySecurityData *_sd /* [in,out] [ref] */)
2980 {
2981         struct tevent_req *req;
2982         struct dcerpc_winreg_GetKeySecurity_state *state;
2983         struct tevent_req *subreq;
2984
2985         req = tevent_req_create(mem_ctx, &state,
2986                                 struct dcerpc_winreg_GetKeySecurity_state);
2987         if (req == NULL) {
2988                 return NULL;
2989         }
2990         state->out_mem_ctx = NULL;
2991
2992         /* In parameters */
2993         state->orig.in.handle = _handle;
2994         state->orig.in.sec_info = _sec_info;
2995         state->orig.in.sd = _sd;
2996
2997         /* Out parameters */
2998         state->orig.out.sd = _sd;
2999
3000         /* Result */
3001         ZERO_STRUCT(state->orig.out.result);
3002
3003         state->out_mem_ctx = talloc_named_const(state, 0,
3004                              "dcerpc_winreg_GetKeySecurity_out_memory");
3005         if (tevent_req_nomem(state->out_mem_ctx, req)) {
3006                 return tevent_req_post(req, ev);
3007         }
3008
3009         /* make a temporary copy, that we pass to the dispatch function */
3010         state->tmp = state->orig;
3011
3012         subreq = dcerpc_winreg_GetKeySecurity_r_send(state, ev, h, &state->tmp);
3013         if (tevent_req_nomem(subreq, req)) {
3014                 return tevent_req_post(req, ev);
3015         }
3016         tevent_req_set_callback(subreq, dcerpc_winreg_GetKeySecurity_done, req);
3017         return req;
3018 }
3019
3020 static void dcerpc_winreg_GetKeySecurity_done(struct tevent_req *subreq)
3021 {
3022         struct tevent_req *req = tevent_req_callback_data(
3023                 subreq, struct tevent_req);
3024         struct dcerpc_winreg_GetKeySecurity_state *state = tevent_req_data(
3025                 req, struct dcerpc_winreg_GetKeySecurity_state);
3026         NTSTATUS status;
3027         TALLOC_CTX *mem_ctx;
3028
3029         if (state->out_mem_ctx) {
3030                 mem_ctx = state->out_mem_ctx;
3031         } else {
3032                 mem_ctx = state;
3033         }
3034
3035         status = dcerpc_winreg_GetKeySecurity_r_recv(subreq, mem_ctx);
3036         TALLOC_FREE(subreq);
3037         if (!NT_STATUS_IS_OK(status)) {
3038                 tevent_req_nterror(req, status);
3039                 return;
3040         }
3041
3042         /* Copy out parameters */
3043         *state->orig.out.sd = *state->tmp.out.sd;
3044
3045         /* Copy result */
3046         state->orig.out.result = state->tmp.out.result;
3047
3048         /* Reset temporary structure */
3049         ZERO_STRUCT(state->tmp);
3050
3051         tevent_req_done(req);
3052 }
3053
3054 NTSTATUS dcerpc_winreg_GetKeySecurity_recv(struct tevent_req *req,
3055                                            TALLOC_CTX *mem_ctx,
3056                                            WERROR *result)
3057 {
3058         struct dcerpc_winreg_GetKeySecurity_state *state = tevent_req_data(
3059                 req, struct dcerpc_winreg_GetKeySecurity_state);
3060         NTSTATUS status;
3061
3062         if (tevent_req_is_nterror(req, &status)) {
3063                 tevent_req_received(req);
3064                 return status;
3065         }
3066
3067         /* Steal possible out parameters to the callers context */
3068         talloc_steal(mem_ctx, state->out_mem_ctx);
3069
3070         /* Return result */
3071         *result = state->orig.out.result;
3072
3073         tevent_req_received(req);
3074         return NT_STATUS_OK;
3075 }
3076
3077 NTSTATUS dcerpc_winreg_GetKeySecurity(struct dcerpc_binding_handle *h,
3078                                       TALLOC_CTX *mem_ctx,
3079                                       struct policy_handle *_handle /* [in] [ref] */,
3080                                       uint32_t _sec_info /* [in]  */,
3081                                       struct KeySecurityData *_sd /* [in,out] [ref] */,
3082                                       WERROR *result)
3083 {
3084         struct winreg_GetKeySecurity r;
3085         NTSTATUS status;
3086
3087         /* In parameters */
3088         r.in.handle = _handle;
3089         r.in.sec_info = _sec_info;
3090         r.in.sd = _sd;
3091
3092         status = dcerpc_winreg_GetKeySecurity_r(h, mem_ctx, &r);
3093         if (!NT_STATUS_IS_OK(status)) {
3094                 return status;
3095         }
3096
3097         /* Return variables */
3098         *_sd = *r.out.sd;
3099
3100         /* Return result */
3101         *result = r.out.result;
3102
3103         return NT_STATUS_OK;
3104 }
3105
3106 struct dcerpc_winreg_LoadKey_r_state {
3107         TALLOC_CTX *out_mem_ctx;
3108 };
3109
3110 static void dcerpc_winreg_LoadKey_r_done(struct tevent_req *subreq);
3111
3112 struct tevent_req *dcerpc_winreg_LoadKey_r_send(TALLOC_CTX *mem_ctx,
3113         struct tevent_context *ev,
3114         struct dcerpc_binding_handle *h,
3115         struct winreg_LoadKey *r)
3116 {
3117         struct tevent_req *req;
3118         struct dcerpc_winreg_LoadKey_r_state *state;
3119         struct tevent_req *subreq;
3120
3121         req = tevent_req_create(mem_ctx, &state,
3122                                 struct dcerpc_winreg_LoadKey_r_state);
3123         if (req == NULL) {
3124                 return NULL;
3125         }
3126
3127         state->out_mem_ctx = NULL;
3128         subreq = dcerpc_binding_handle_call_send(state, ev, h,
3129                         NULL, &ndr_table_winreg,
3130                         NDR_WINREG_LOADKEY, state, r);
3131         if (tevent_req_nomem(subreq, req)) {
3132                 return tevent_req_post(req, ev);
3133         }
3134         tevent_req_set_callback(subreq, dcerpc_winreg_LoadKey_r_done, req);
3135
3136         return req;
3137 }
3138
3139 static void dcerpc_winreg_LoadKey_r_done(struct tevent_req *subreq)
3140 {
3141         struct tevent_req *req =
3142                 tevent_req_callback_data(subreq,
3143                 struct tevent_req);
3144         NTSTATUS status;
3145
3146         status = dcerpc_binding_handle_call_recv(subreq);
3147         if (!NT_STATUS_IS_OK(status)) {
3148                 tevent_req_nterror(req, status);
3149                 return;
3150         }
3151
3152         tevent_req_done(req);
3153 }
3154
3155 NTSTATUS dcerpc_winreg_LoadKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
3156 {
3157         struct dcerpc_winreg_LoadKey_r_state *state =
3158                 tevent_req_data(req,
3159                 struct dcerpc_winreg_LoadKey_r_state);
3160         NTSTATUS status;
3161
3162         if (tevent_req_is_nterror(req, &status)) {
3163                 tevent_req_received(req);
3164                 return status;
3165         }
3166
3167         talloc_steal(mem_ctx, state->out_mem_ctx);
3168
3169         tevent_req_received(req);
3170         return NT_STATUS_OK;
3171 }
3172
3173 NTSTATUS dcerpc_winreg_LoadKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_LoadKey *r)
3174 {
3175         NTSTATUS status;
3176
3177         status = dcerpc_binding_handle_call(h,
3178                         NULL, &ndr_table_winreg,
3179                         NDR_WINREG_LOADKEY, mem_ctx, r);
3180
3181         return status;
3182 }
3183
3184 NTSTATUS dcerpc_winreg_LoadKey_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_LoadKey *r)
3185 {
3186         NTSTATUS status;
3187
3188         status = dcerpc_winreg_LoadKey_r(p->binding_handle, mem_ctx, r);
3189
3190         if (NT_STATUS_IS_RPC(status)) {
3191                 status = NT_STATUS_NET_WRITE_FAULT;
3192         }
3193
3194         return status;
3195 }
3196
3197 struct dcerpc_winreg_LoadKey_state {
3198         struct winreg_LoadKey orig;
3199         struct winreg_LoadKey tmp;
3200         TALLOC_CTX *out_mem_ctx;
3201 };
3202
3203 static void dcerpc_winreg_LoadKey_done(struct tevent_req *subreq);
3204
3205 struct tevent_req *dcerpc_winreg_LoadKey_send(TALLOC_CTX *mem_ctx,
3206                                               struct tevent_context *ev,
3207                                               struct dcerpc_binding_handle *h,
3208                                               struct policy_handle *_handle /* [in] [ref] */,
3209                                               struct winreg_String *_keyname /* [in] [unique] */,
3210                                               struct winreg_String *_filename /* [in] [unique] */)
3211 {
3212         struct tevent_req *req;
3213         struct dcerpc_winreg_LoadKey_state *state;
3214         struct tevent_req *subreq;
3215
3216         req = tevent_req_create(mem_ctx, &state,
3217                                 struct dcerpc_winreg_LoadKey_state);
3218         if (req == NULL) {
3219                 return NULL;
3220         }
3221         state->out_mem_ctx = NULL;
3222
3223         /* In parameters */
3224         state->orig.in.handle = _handle;
3225         state->orig.in.keyname = _keyname;
3226         state->orig.in.filename = _filename;
3227
3228         /* Out parameters */
3229
3230         /* Result */
3231         ZERO_STRUCT(state->orig.out.result);
3232
3233         /* make a temporary copy, that we pass to the dispatch function */
3234         state->tmp = state->orig;
3235
3236         subreq = dcerpc_winreg_LoadKey_r_send(state, ev, h, &state->tmp);
3237         if (tevent_req_nomem(subreq, req)) {
3238                 return tevent_req_post(req, ev);
3239         }
3240         tevent_req_set_callback(subreq, dcerpc_winreg_LoadKey_done, req);
3241         return req;
3242 }
3243
3244 static void dcerpc_winreg_LoadKey_done(struct tevent_req *subreq)
3245 {
3246         struct tevent_req *req = tevent_req_callback_data(
3247                 subreq, struct tevent_req);
3248         struct dcerpc_winreg_LoadKey_state *state = tevent_req_data(
3249                 req, struct dcerpc_winreg_LoadKey_state);
3250         NTSTATUS status;
3251         TALLOC_CTX *mem_ctx;
3252
3253         if (state->out_mem_ctx) {
3254                 mem_ctx = state->out_mem_ctx;
3255         } else {
3256                 mem_ctx = state;
3257         }
3258
3259         status = dcerpc_winreg_LoadKey_r_recv(subreq, mem_ctx);
3260         TALLOC_FREE(subreq);
3261         if (!NT_STATUS_IS_OK(status)) {
3262                 tevent_req_nterror(req, status);
3263                 return;
3264         }
3265
3266         /* Copy out parameters */
3267
3268         /* Copy result */
3269         state->orig.out.result = state->tmp.out.result;
3270
3271         /* Reset temporary structure */
3272         ZERO_STRUCT(state->tmp);
3273
3274         tevent_req_done(req);
3275 }
3276
3277 NTSTATUS dcerpc_winreg_LoadKey_recv(struct tevent_req *req,
3278                                     TALLOC_CTX *mem_ctx,
3279                                     WERROR *result)
3280 {
3281         struct dcerpc_winreg_LoadKey_state *state = tevent_req_data(
3282                 req, struct dcerpc_winreg_LoadKey_state);
3283         NTSTATUS status;
3284
3285         if (tevent_req_is_nterror(req, &status)) {
3286                 tevent_req_received(req);
3287                 return status;
3288         }
3289
3290         /* Steal possible out parameters to the callers context */
3291         talloc_steal(mem_ctx, state->out_mem_ctx);
3292
3293         /* Return result */
3294         *result = state->orig.out.result;
3295
3296         tevent_req_received(req);
3297         return NT_STATUS_OK;
3298 }
3299
3300 NTSTATUS dcerpc_winreg_LoadKey(struct dcerpc_binding_handle *h,
3301                                TALLOC_CTX *mem_ctx,
3302                                struct policy_handle *_handle /* [in] [ref] */,
3303                                struct winreg_String *_keyname /* [in] [unique] */,
3304                                struct winreg_String *_filename /* [in] [unique] */,
3305                                WERROR *result)
3306 {
3307         struct winreg_LoadKey r;
3308         NTSTATUS status;
3309
3310         /* In parameters */
3311         r.in.handle = _handle;
3312         r.in.keyname = _keyname;
3313         r.in.filename = _filename;
3314
3315         status = dcerpc_winreg_LoadKey_r(h, mem_ctx, &r);
3316         if (!NT_STATUS_IS_OK(status)) {
3317                 return status;
3318         }
3319
3320         /* Return variables */
3321
3322         /* Return result */
3323         *result = r.out.result;
3324
3325         return NT_STATUS_OK;
3326 }
3327
3328 struct dcerpc_winreg_NotifyChangeKeyValue_r_state {
3329         TALLOC_CTX *out_mem_ctx;
3330 };
3331
3332 static void dcerpc_winreg_NotifyChangeKeyValue_r_done(struct tevent_req *subreq);
3333
3334 struct tevent_req *dcerpc_winreg_NotifyChangeKeyValue_r_send(TALLOC_CTX *mem_ctx,
3335         struct tevent_context *ev,
3336         struct dcerpc_binding_handle *h,
3337         struct winreg_NotifyChangeKeyValue *r)
3338 {
3339         struct tevent_req *req;
3340         struct dcerpc_winreg_NotifyChangeKeyValue_r_state *state;
3341         struct tevent_req *subreq;
3342
3343         req = tevent_req_create(mem_ctx, &state,
3344                                 struct dcerpc_winreg_NotifyChangeKeyValue_r_state);
3345         if (req == NULL) {
3346                 return NULL;
3347         }
3348
3349         state->out_mem_ctx = NULL;
3350         subreq = dcerpc_binding_handle_call_send(state, ev, h,
3351                         NULL, &ndr_table_winreg,
3352                         NDR_WINREG_NOTIFYCHANGEKEYVALUE, state, r);
3353         if (tevent_req_nomem(subreq, req)) {
3354                 return tevent_req_post(req, ev);
3355         }
3356         tevent_req_set_callback(subreq, dcerpc_winreg_NotifyChangeKeyValue_r_done, req);
3357
3358         return req;
3359 }
3360
3361 static void dcerpc_winreg_NotifyChangeKeyValue_r_done(struct tevent_req *subreq)
3362 {
3363         struct tevent_req *req =
3364                 tevent_req_callback_data(subreq,
3365                 struct tevent_req);
3366         NTSTATUS status;
3367
3368         status = dcerpc_binding_handle_call_recv(subreq);
3369         if (!NT_STATUS_IS_OK(status)) {
3370                 tevent_req_nterror(req, status);
3371                 return;
3372         }
3373
3374         tevent_req_done(req);
3375 }
3376
3377 NTSTATUS dcerpc_winreg_NotifyChangeKeyValue_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
3378 {
3379         struct dcerpc_winreg_NotifyChangeKeyValue_r_state *state =
3380                 tevent_req_data(req,
3381                 struct dcerpc_winreg_NotifyChangeKeyValue_r_state);
3382         NTSTATUS status;
3383
3384         if (tevent_req_is_nterror(req, &status)) {
3385                 tevent_req_received(req);
3386                 return status;
3387         }
3388
3389         talloc_steal(mem_ctx, state->out_mem_ctx);
3390
3391         tevent_req_received(req);
3392         return NT_STATUS_OK;
3393 }
3394
3395 NTSTATUS dcerpc_winreg_NotifyChangeKeyValue_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_NotifyChangeKeyValue *r)
3396 {
3397         NTSTATUS status;
3398
3399         status = dcerpc_binding_handle_call(h,
3400                         NULL, &ndr_table_winreg,
3401                         NDR_WINREG_NOTIFYCHANGEKEYVALUE, mem_ctx, r);
3402
3403         return status;
3404 }
3405
3406 NTSTATUS dcerpc_winreg_NotifyChangeKeyValue_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_NotifyChangeKeyValue *r)
3407 {
3408         NTSTATUS status;
3409
3410         status = dcerpc_winreg_NotifyChangeKeyValue_r(p->binding_handle, mem_ctx, r);
3411
3412         if (NT_STATUS_IS_RPC(status)) {
3413                 status = NT_STATUS_NET_WRITE_FAULT;
3414         }
3415
3416         return status;
3417 }
3418
3419 struct dcerpc_winreg_NotifyChangeKeyValue_state {
3420         struct winreg_NotifyChangeKeyValue orig;
3421         struct winreg_NotifyChangeKeyValue tmp;
3422         TALLOC_CTX *out_mem_ctx;
3423 };
3424
3425 static void dcerpc_winreg_NotifyChangeKeyValue_done(struct tevent_req *subreq);
3426
3427 struct tevent_req *dcerpc_winreg_NotifyChangeKeyValue_send(TALLOC_CTX *mem_ctx,
3428                                                            struct tevent_context *ev,
3429                                                            struct dcerpc_binding_handle *h,
3430                                                            struct policy_handle *_handle /* [in] [ref] */,
3431                                                            uint8_t _watch_subtree /* [in]  */,
3432                                                            uint32_t _notify_filter /* [in]  */,
3433                                                            uint32_t _unknown /* [in]  */,
3434                                                            struct winreg_String _string1 /* [in]  */,
3435                                                            struct winreg_String _string2 /* [in]  */,
3436                                                            uint32_t _unknown2 /* [in]  */)
3437 {
3438         struct tevent_req *req;
3439         struct dcerpc_winreg_NotifyChangeKeyValue_state *state;
3440         struct tevent_req *subreq;
3441
3442         req = tevent_req_create(mem_ctx, &state,
3443                                 struct dcerpc_winreg_NotifyChangeKeyValue_state);
3444         if (req == NULL) {
3445                 return NULL;
3446         }
3447         state->out_mem_ctx = NULL;
3448
3449         /* In parameters */
3450         state->orig.in.handle = _handle;
3451         state->orig.in.watch_subtree = _watch_subtree;
3452         state->orig.in.notify_filter = _notify_filter;
3453         state->orig.in.unknown = _unknown;
3454         state->orig.in.string1 = _string1;
3455         state->orig.in.string2 = _string2;
3456         state->orig.in.unknown2 = _unknown2;
3457
3458         /* Out parameters */
3459
3460         /* Result */
3461         ZERO_STRUCT(state->orig.out.result);
3462
3463         /* make a temporary copy, that we pass to the dispatch function */
3464         state->tmp = state->orig;
3465
3466         subreq = dcerpc_winreg_NotifyChangeKeyValue_r_send(state, ev, h, &state->tmp);
3467         if (tevent_req_nomem(subreq, req)) {
3468                 return tevent_req_post(req, ev);
3469         }
3470         tevent_req_set_callback(subreq, dcerpc_winreg_NotifyChangeKeyValue_done, req);
3471         return req;
3472 }
3473
3474 static void dcerpc_winreg_NotifyChangeKeyValue_done(struct tevent_req *subreq)
3475 {
3476         struct tevent_req *req = tevent_req_callback_data(
3477                 subreq, struct tevent_req);
3478         struct dcerpc_winreg_NotifyChangeKeyValue_state *state = tevent_req_data(
3479                 req, struct dcerpc_winreg_NotifyChangeKeyValue_state);
3480         NTSTATUS status;
3481         TALLOC_CTX *mem_ctx;
3482
3483         if (state->out_mem_ctx) {
3484                 mem_ctx = state->out_mem_ctx;
3485         } else {
3486                 mem_ctx = state;
3487         }
3488
3489         status = dcerpc_winreg_NotifyChangeKeyValue_r_recv(subreq, mem_ctx);
3490         TALLOC_FREE(subreq);
3491         if (!NT_STATUS_IS_OK(status)) {
3492                 tevent_req_nterror(req, status);
3493                 return;
3494         }
3495
3496         /* Copy out parameters */
3497
3498         /* Copy result */
3499         state->orig.out.result = state->tmp.out.result;
3500
3501         /* Reset temporary structure */
3502         ZERO_STRUCT(state->tmp);
3503
3504         tevent_req_done(req);
3505 }
3506
3507 NTSTATUS dcerpc_winreg_NotifyChangeKeyValue_recv(struct tevent_req *req,
3508                                                  TALLOC_CTX *mem_ctx,
3509                                                  WERROR *result)
3510 {
3511         struct dcerpc_winreg_NotifyChangeKeyValue_state *state = tevent_req_data(
3512                 req, struct dcerpc_winreg_NotifyChangeKeyValue_state);
3513         NTSTATUS status;
3514
3515         if (tevent_req_is_nterror(req, &status)) {
3516                 tevent_req_received(req);
3517                 return status;
3518         }
3519
3520         /* Steal possible out parameters to the callers context */
3521         talloc_steal(mem_ctx, state->out_mem_ctx);
3522
3523         /* Return result */
3524         *result = state->orig.out.result;
3525
3526         tevent_req_received(req);
3527         return NT_STATUS_OK;
3528 }
3529
3530 NTSTATUS dcerpc_winreg_NotifyChangeKeyValue(struct dcerpc_binding_handle *h,
3531                                             TALLOC_CTX *mem_ctx,
3532                                             struct policy_handle *_handle /* [in] [ref] */,
3533                                             uint8_t _watch_subtree /* [in]  */,
3534                                             uint32_t _notify_filter /* [in]  */,
3535                                             uint32_t _unknown /* [in]  */,
3536                                             struct winreg_String _string1 /* [in]  */,
3537                                             struct winreg_String _string2 /* [in]  */,
3538                                             uint32_t _unknown2 /* [in]  */,
3539                                             WERROR *result)
3540 {
3541         struct winreg_NotifyChangeKeyValue r;
3542         NTSTATUS status;
3543
3544         /* In parameters */
3545         r.in.handle = _handle;
3546         r.in.watch_subtree = _watch_subtree;
3547         r.in.notify_filter = _notify_filter;
3548         r.in.unknown = _unknown;
3549         r.in.string1 = _string1;
3550         r.in.string2 = _string2;
3551         r.in.unknown2 = _unknown2;
3552
3553         status = dcerpc_winreg_NotifyChangeKeyValue_r(h, mem_ctx, &r);
3554         if (!NT_STATUS_IS_OK(status)) {
3555                 return status;
3556         }
3557
3558         /* Return variables */
3559
3560         /* Return result */
3561         *result = r.out.result;
3562
3563         return NT_STATUS_OK;
3564 }
3565
3566 struct dcerpc_winreg_OpenKey_r_state {
3567         TALLOC_CTX *out_mem_ctx;
3568 };
3569
3570 static void dcerpc_winreg_OpenKey_r_done(struct tevent_req *subreq);
3571
3572 struct tevent_req *dcerpc_winreg_OpenKey_r_send(TALLOC_CTX *mem_ctx,
3573         struct tevent_context *ev,
3574         struct dcerpc_binding_handle *h,
3575         struct winreg_OpenKey *r)
3576 {
3577         struct tevent_req *req;
3578         struct dcerpc_winreg_OpenKey_r_state *state;
3579         struct tevent_req *subreq;
3580
3581         req = tevent_req_create(mem_ctx, &state,
3582                                 struct dcerpc_winreg_OpenKey_r_state);
3583         if (req == NULL) {
3584                 return NULL;
3585         }
3586
3587         state->out_mem_ctx = talloc_new(state);
3588         if (tevent_req_nomem(state->out_mem_ctx, req)) {
3589                 return tevent_req_post(req, ev);
3590         }
3591
3592         subreq = dcerpc_binding_handle_call_send(state, ev, h,
3593                         NULL, &ndr_table_winreg,
3594                         NDR_WINREG_OPENKEY, state->out_mem_ctx, r);
3595         if (tevent_req_nomem(subreq, req)) {
3596                 return tevent_req_post(req, ev);
3597         }
3598         tevent_req_set_callback(subreq, dcerpc_winreg_OpenKey_r_done, req);
3599
3600         return req;
3601 }
3602
3603 static void dcerpc_winreg_OpenKey_r_done(struct tevent_req *subreq)
3604 {
3605         struct tevent_req *req =
3606                 tevent_req_callback_data(subreq,
3607                 struct tevent_req);
3608         NTSTATUS status;
3609
3610         status = dcerpc_binding_handle_call_recv(subreq);
3611         if (!NT_STATUS_IS_OK(status)) {
3612                 tevent_req_nterror(req, status);
3613                 return;
3614         }
3615
3616         tevent_req_done(req);
3617 }
3618
3619 NTSTATUS dcerpc_winreg_OpenKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
3620 {
3621         struct dcerpc_winreg_OpenKey_r_state *state =
3622                 tevent_req_data(req,
3623                 struct dcerpc_winreg_OpenKey_r_state);
3624         NTSTATUS status;
3625
3626         if (tevent_req_is_nterror(req, &status)) {
3627                 tevent_req_received(req);
3628                 return status;
3629         }
3630
3631         talloc_steal(mem_ctx, state->out_mem_ctx);
3632
3633         tevent_req_received(req);
3634         return NT_STATUS_OK;
3635 }
3636
3637 NTSTATUS dcerpc_winreg_OpenKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_OpenKey *r)
3638 {
3639         NTSTATUS status;
3640
3641         status = dcerpc_binding_handle_call(h,
3642                         NULL, &ndr_table_winreg,
3643                         NDR_WINREG_OPENKEY, mem_ctx, r);
3644
3645         return status;
3646 }
3647
3648 NTSTATUS dcerpc_winreg_OpenKey_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_OpenKey *r)
3649 {
3650         NTSTATUS status;
3651
3652         status = dcerpc_winreg_OpenKey_r(p->binding_handle, mem_ctx, r);
3653
3654         if (NT_STATUS_IS_RPC(status)) {
3655                 status = NT_STATUS_NET_WRITE_FAULT;
3656         }
3657
3658         return status;
3659 }
3660
3661 struct dcerpc_winreg_OpenKey_state {
3662         struct winreg_OpenKey orig;
3663         struct winreg_OpenKey tmp;
3664         TALLOC_CTX *out_mem_ctx;
3665 };
3666
3667 static void dcerpc_winreg_OpenKey_done(struct tevent_req *subreq);
3668
3669 struct tevent_req *dcerpc_winreg_OpenKey_send(TALLOC_CTX *mem_ctx,
3670                                               struct tevent_context *ev,
3671                                               struct dcerpc_binding_handle *h,
3672                                               struct policy_handle *_parent_handle /* [in] [ref] */,
3673                                               struct winreg_String _keyname /* [in]  */,
3674                                               uint32_t _options /* [in]  */,
3675                                               uint32_t _access_mask /* [in]  */,
3676                                               struct policy_handle *_handle /* [out] [ref] */)
3677 {
3678         struct tevent_req *req;
3679         struct dcerpc_winreg_OpenKey_state *state;
3680         struct tevent_req *subreq;
3681
3682         req = tevent_req_create(mem_ctx, &state,
3683                                 struct dcerpc_winreg_OpenKey_state);
3684         if (req == NULL) {
3685                 return NULL;
3686         }
3687         state->out_mem_ctx = NULL;
3688
3689         /* In parameters */
3690         state->orig.in.parent_handle = _parent_handle;
3691         state->orig.in.keyname = _keyname;
3692         state->orig.in.options = _options;
3693         state->orig.in.access_mask = _access_mask;
3694
3695         /* Out parameters */
3696         state->orig.out.handle = _handle;
3697
3698         /* Result */
3699         ZERO_STRUCT(state->orig.out.result);
3700
3701         state->out_mem_ctx = talloc_named_const(state, 0,
3702                              "dcerpc_winreg_OpenKey_out_memory");
3703         if (tevent_req_nomem(state->out_mem_ctx, req)) {
3704                 return tevent_req_post(req, ev);
3705         }
3706
3707         /* make a temporary copy, that we pass to the dispatch function */
3708         state->tmp = state->orig;
3709
3710         subreq = dcerpc_winreg_OpenKey_r_send(state, ev, h, &state->tmp);
3711         if (tevent_req_nomem(subreq, req)) {
3712                 return tevent_req_post(req, ev);
3713         }
3714         tevent_req_set_callback(subreq, dcerpc_winreg_OpenKey_done, req);
3715         return req;
3716 }
3717
3718 static void dcerpc_winreg_OpenKey_done(struct tevent_req *subreq)
3719 {
3720         struct tevent_req *req = tevent_req_callback_data(
3721                 subreq, struct tevent_req);
3722         struct dcerpc_winreg_OpenKey_state *state = tevent_req_data(
3723                 req, struct dcerpc_winreg_OpenKey_state);
3724         NTSTATUS status;
3725         TALLOC_CTX *mem_ctx;
3726
3727         if (state->out_mem_ctx) {
3728                 mem_ctx = state->out_mem_ctx;
3729         } else {
3730                 mem_ctx = state;
3731         }
3732
3733         status = dcerpc_winreg_OpenKey_r_recv(subreq, mem_ctx);
3734         TALLOC_FREE(subreq);
3735         if (!NT_STATUS_IS_OK(status)) {
3736                 tevent_req_nterror(req, status);
3737                 return;
3738         }
3739
3740         /* Copy out parameters */
3741         *state->orig.out.handle = *state->tmp.out.handle;
3742
3743         /* Copy result */
3744         state->orig.out.result = state->tmp.out.result;
3745
3746         /* Reset temporary structure */
3747         ZERO_STRUCT(state->tmp);
3748
3749         tevent_req_done(req);
3750 }
3751
3752 NTSTATUS dcerpc_winreg_OpenKey_recv(struct tevent_req *req,
3753                                     TALLOC_CTX *mem_ctx,
3754                                     WERROR *result)
3755 {
3756         struct dcerpc_winreg_OpenKey_state *state = tevent_req_data(
3757                 req, struct dcerpc_winreg_OpenKey_state);
3758         NTSTATUS status;
3759
3760         if (tevent_req_is_nterror(req, &status)) {
3761                 tevent_req_received(req);
3762                 return status;
3763         }
3764
3765         /* Steal possible out parameters to the callers context */
3766         talloc_steal(mem_ctx, state->out_mem_ctx);
3767
3768         /* Return result */
3769         *result = state->orig.out.result;
3770
3771         tevent_req_received(req);
3772         return NT_STATUS_OK;
3773 }
3774
3775 NTSTATUS dcerpc_winreg_OpenKey(struct dcerpc_binding_handle *h,
3776                                TALLOC_CTX *mem_ctx,
3777                                struct policy_handle *_parent_handle /* [in] [ref] */,
3778                                struct winreg_String _keyname /* [in]  */,
3779                                uint32_t _options /* [in]  */,
3780                                uint32_t _access_mask /* [in]  */,
3781                                struct policy_handle *_handle /* [out] [ref] */,
3782                                WERROR *result)
3783 {
3784         struct winreg_OpenKey r;
3785         NTSTATUS status;
3786
3787         /* In parameters */
3788         r.in.parent_handle = _parent_handle;
3789         r.in.keyname = _keyname;
3790         r.in.options = _options;
3791         r.in.access_mask = _access_mask;
3792
3793         status = dcerpc_winreg_OpenKey_r(h, mem_ctx, &r);
3794         if (!NT_STATUS_IS_OK(status)) {
3795                 return status;
3796         }
3797
3798         /* Return variables */
3799         *_handle = *r.out.handle;
3800
3801         /* Return result */
3802         *result = r.out.result;
3803
3804         return NT_STATUS_OK;
3805 }
3806
3807 struct dcerpc_winreg_QueryInfoKey_r_state {
3808         TALLOC_CTX *out_mem_ctx;
3809 };
3810
3811 static void dcerpc_winreg_QueryInfoKey_r_done(struct tevent_req *subreq);
3812
3813 struct tevent_req *dcerpc_winreg_QueryInfoKey_r_send(TALLOC_CTX *mem_ctx,
3814         struct tevent_context *ev,
3815         struct dcerpc_binding_handle *h,
3816         struct winreg_QueryInfoKey *r)
3817 {
3818         struct tevent_req *req;
3819         struct dcerpc_winreg_QueryInfoKey_r_state *state;
3820         struct tevent_req *subreq;
3821
3822         req = tevent_req_create(mem_ctx, &state,
3823                                 struct dcerpc_winreg_QueryInfoKey_r_state);
3824         if (req == NULL) {
3825                 return NULL;
3826         }
3827
3828         state->out_mem_ctx = talloc_new(state);
3829         if (tevent_req_nomem(state->out_mem_ctx, req)) {
3830                 return tevent_req_post(req, ev);
3831         }
3832
3833         subreq = dcerpc_binding_handle_call_send(state, ev, h,
3834                         NULL, &ndr_table_winreg,
3835                         NDR_WINREG_QUERYINFOKEY, state->out_mem_ctx, r);
3836         if (tevent_req_nomem(subreq, req)) {
3837                 return tevent_req_post(req, ev);
3838         }
3839         tevent_req_set_callback(subreq, dcerpc_winreg_QueryInfoKey_r_done, req);
3840
3841         return req;
3842 }
3843
3844 static void dcerpc_winreg_QueryInfoKey_r_done(struct tevent_req *subreq)
3845 {
3846         struct tevent_req *req =
3847                 tevent_req_callback_data(subreq,
3848                 struct tevent_req);
3849         NTSTATUS status;
3850
3851         status = dcerpc_binding_handle_call_recv(subreq);
3852         if (!NT_STATUS_IS_OK(status)) {
3853                 tevent_req_nterror(req, status);
3854                 return;
3855         }
3856
3857         tevent_req_done(req);
3858 }
3859
3860 NTSTATUS dcerpc_winreg_QueryInfoKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
3861 {
3862         struct dcerpc_winreg_QueryInfoKey_r_state *state =
3863                 tevent_req_data(req,
3864                 struct dcerpc_winreg_QueryInfoKey_r_state);
3865         NTSTATUS status;
3866
3867         if (tevent_req_is_nterror(req, &status)) {
3868                 tevent_req_received(req);
3869                 return status;
3870         }
3871
3872         talloc_steal(mem_ctx, state->out_mem_ctx);
3873
3874         tevent_req_received(req);
3875         return NT_STATUS_OK;
3876 }
3877
3878 NTSTATUS dcerpc_winreg_QueryInfoKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_QueryInfoKey *r)
3879 {
3880         NTSTATUS status;
3881
3882         status = dcerpc_binding_handle_call(h,
3883                         NULL, &ndr_table_winreg,
3884                         NDR_WINREG_QUERYINFOKEY, mem_ctx, r);
3885
3886         return status;
3887 }
3888
3889 NTSTATUS dcerpc_winreg_QueryInfoKey_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_QueryInfoKey *r)
3890 {
3891         NTSTATUS status;
3892
3893         status = dcerpc_winreg_QueryInfoKey_r(p->binding_handle, mem_ctx, r);
3894
3895         if (NT_STATUS_IS_RPC(status)) {
3896                 status = NT_STATUS_NET_WRITE_FAULT;
3897         }
3898
3899         return status;
3900 }
3901
3902 struct dcerpc_winreg_QueryInfoKey_state {
3903         struct winreg_QueryInfoKey orig;
3904         struct winreg_QueryInfoKey tmp;
3905         TALLOC_CTX *out_mem_ctx;
3906 };
3907
3908 static void dcerpc_winreg_QueryInfoKey_done(struct tevent_req *subreq);
3909
3910 struct tevent_req *dcerpc_winreg_QueryInfoKey_send(TALLOC_CTX *mem_ctx,
3911                                                    struct tevent_context *ev,
3912                                                    struct dcerpc_binding_handle *h,
3913                                                    struct policy_handle *_handle /* [in] [ref] */,
3914                                                    struct winreg_String *_classname /* [in,out] [ref] */,
3915                                                    uint32_t *_num_subkeys /* [out] [ref] */,
3916                                                    uint32_t *_max_subkeylen /* [out] [ref] */,
3917                                                    uint32_t *_max_classlen /* [out] [ref] */,
3918                                                    uint32_t *_num_values /* [out] [ref] */,
3919                                                    uint32_t *_max_valnamelen /* [out] [ref] */,
3920                                                    uint32_t *_max_valbufsize /* [out] [ref] */,
3921                                                    uint32_t *_secdescsize /* [out] [ref] */,
3922                                                    NTTIME *_last_changed_time /* [out] [ref] */)
3923 {
3924         struct tevent_req *req;
3925         struct dcerpc_winreg_QueryInfoKey_state *state;
3926         struct tevent_req *subreq;
3927
3928         req = tevent_req_create(mem_ctx, &state,
3929                                 struct dcerpc_winreg_QueryInfoKey_state);
3930         if (req == NULL) {
3931                 return NULL;
3932         }
3933         state->out_mem_ctx = NULL;
3934
3935         /* In parameters */
3936         state->orig.in.handle = _handle;
3937         state->orig.in.classname = _classname;
3938
3939         /* Out parameters */
3940         state->orig.out.classname = _classname;
3941         state->orig.out.num_subkeys = _num_subkeys;
3942         state->orig.out.max_subkeylen = _max_subkeylen;
3943         state->orig.out.max_classlen = _max_classlen;
3944         state->orig.out.num_values = _num_values;
3945         state->orig.out.max_valnamelen = _max_valnamelen;
3946         state->orig.out.max_valbufsize = _max_valbufsize;
3947         state->orig.out.secdescsize = _secdescsize;
3948         state->orig.out.last_changed_time = _last_changed_time;
3949
3950         /* Result */
3951         ZERO_STRUCT(state->orig.out.result);
3952
3953         state->out_mem_ctx = talloc_named_const(state, 0,
3954                              "dcerpc_winreg_QueryInfoKey_out_memory");
3955         if (tevent_req_nomem(state->out_mem_ctx, req)) {
3956                 return tevent_req_post(req, ev);
3957         }
3958
3959         /* make a temporary copy, that we pass to the dispatch function */
3960         state->tmp = state->orig;
3961
3962         subreq = dcerpc_winreg_QueryInfoKey_r_send(state, ev, h, &state->tmp);
3963         if (tevent_req_nomem(subreq, req)) {
3964                 return tevent_req_post(req, ev);
3965         }
3966         tevent_req_set_callback(subreq, dcerpc_winreg_QueryInfoKey_done, req);
3967         return req;
3968 }
3969
3970 static void dcerpc_winreg_QueryInfoKey_done(struct tevent_req *subreq)
3971 {
3972         struct tevent_req *req = tevent_req_callback_data(
3973                 subreq, struct tevent_req);
3974         struct dcerpc_winreg_QueryInfoKey_state *state = tevent_req_data(
3975                 req, struct dcerpc_winreg_QueryInfoKey_state);
3976         NTSTATUS status;
3977         TALLOC_CTX *mem_ctx;
3978
3979         if (state->out_mem_ctx) {
3980                 mem_ctx = state->out_mem_ctx;
3981         } else {
3982                 mem_ctx = state;
3983         }
3984
3985         status = dcerpc_winreg_QueryInfoKey_r_recv(subreq, mem_ctx);
3986         TALLOC_FREE(subreq);
3987         if (!NT_STATUS_IS_OK(status)) {
3988                 tevent_req_nterror(req, status);
3989                 return;
3990         }
3991
3992         /* Copy out parameters */
3993         *state->orig.out.classname = *state->tmp.out.classname;
3994         *state->orig.out.num_subkeys = *state->tmp.out.num_subkeys;
3995         *state->orig.out.max_subkeylen = *state->tmp.out.max_subkeylen;
3996         *state->orig.out.max_classlen = *state->tmp.out.max_classlen;
3997         *state->orig.out.num_values = *state->tmp.out.num_values;
3998         *state->orig.out.max_valnamelen = *state->tmp.out.max_valnamelen;
3999         *state->orig.out.max_valbufsize = *state->tmp.out.max_valbufsize;
4000         *state->orig.out.secdescsize = *state->tmp.out.secdescsize;
4001         *state->orig.out.last_changed_time = *state->tmp.out.last_changed_time;
4002
4003         /* Copy result */
4004         state->orig.out.result = state->tmp.out.result;
4005
4006         /* Reset temporary structure */
4007         ZERO_STRUCT(state->tmp);
4008
4009         tevent_req_done(req);
4010 }
4011
4012 NTSTATUS dcerpc_winreg_QueryInfoKey_recv(struct tevent_req *req,
4013                                          TALLOC_CTX *mem_ctx,
4014                                          WERROR *result)
4015 {
4016         struct dcerpc_winreg_QueryInfoKey_state *state = tevent_req_data(
4017                 req, struct dcerpc_winreg_QueryInfoKey_state);
4018         NTSTATUS status;
4019
4020         if (tevent_req_is_nterror(req, &status)) {
4021                 tevent_req_received(req);
4022                 return status;
4023         }
4024
4025         /* Steal possible out parameters to the callers context */
4026         talloc_steal(mem_ctx, state->out_mem_ctx);
4027
4028         /* Return result */
4029         *result = state->orig.out.result;
4030
4031         tevent_req_received(req);
4032         return NT_STATUS_OK;
4033 }
4034
4035 NTSTATUS dcerpc_winreg_QueryInfoKey(struct dcerpc_binding_handle *h,
4036                                     TALLOC_CTX *mem_ctx,
4037                                     struct policy_handle *_handle /* [in] [ref] */,
4038                                     struct winreg_String *_classname /* [in,out] [ref] */,
4039                                     uint32_t *_num_subkeys /* [out] [ref] */,
4040                                     uint32_t *_max_subkeylen /* [out] [ref] */,
4041                                     uint32_t *_max_classlen /* [out] [ref] */,
4042                                     uint32_t *_num_values /* [out] [ref] */,
4043                                     uint32_t *_max_valnamelen /* [out] [ref] */,
4044                                     uint32_t *_max_valbufsize /* [out] [ref] */,
4045                                     uint32_t *_secdescsize /* [out] [ref] */,
4046                                     NTTIME *_last_changed_time /* [out] [ref] */,
4047                                     WERROR *result)
4048 {
4049         struct winreg_QueryInfoKey r;
4050         NTSTATUS status;
4051
4052         /* In parameters */
4053         r.in.handle = _handle;
4054         r.in.classname = _classname;
4055
4056         status = dcerpc_winreg_QueryInfoKey_r(h, mem_ctx, &r);
4057         if (!NT_STATUS_IS_OK(status)) {
4058                 return status;
4059         }
4060
4061         /* Return variables */
4062         *_classname = *r.out.classname;
4063         *_num_subkeys = *r.out.num_subkeys;
4064         *_max_subkeylen = *r.out.max_subkeylen;
4065         *_max_classlen = *r.out.max_classlen;
4066         *_num_values = *r.out.num_values;
4067         *_max_valnamelen = *r.out.max_valnamelen;
4068         *_max_valbufsize = *r.out.max_valbufsize;
4069         *_secdescsize = *r.out.secdescsize;
4070         *_last_changed_time = *r.out.last_changed_time;
4071
4072         /* Return result */
4073         *result = r.out.result;
4074
4075         return NT_STATUS_OK;
4076 }
4077
4078 struct dcerpc_winreg_QueryValue_r_state {
4079         TALLOC_CTX *out_mem_ctx;
4080 };
4081
4082 static void dcerpc_winreg_QueryValue_r_done(struct tevent_req *subreq);
4083
4084 struct tevent_req *dcerpc_winreg_QueryValue_r_send(TALLOC_CTX *mem_ctx,
4085         struct tevent_context *ev,
4086         struct dcerpc_binding_handle *h,
4087         struct winreg_QueryValue *r)
4088 {
4089         struct tevent_req *req;
4090         struct dcerpc_winreg_QueryValue_r_state *state;
4091         struct tevent_req *subreq;
4092
4093         req = tevent_req_create(mem_ctx, &state,
4094                                 struct dcerpc_winreg_QueryValue_r_state);
4095         if (req == NULL) {
4096                 return NULL;
4097         }
4098
4099         state->out_mem_ctx = talloc_new(state);
4100         if (tevent_req_nomem(state->out_mem_ctx, req)) {
4101                 return tevent_req_post(req, ev);
4102         }
4103
4104         subreq = dcerpc_binding_handle_call_send(state, ev, h,
4105                         NULL, &ndr_table_winreg,
4106                         NDR_WINREG_QUERYVALUE, state->out_mem_ctx, r);
4107         if (tevent_req_nomem(subreq, req)) {
4108                 return tevent_req_post(req, ev);
4109         }
4110         tevent_req_set_callback(subreq, dcerpc_winreg_QueryValue_r_done, req);
4111
4112         return req;
4113 }
4114
4115 static void dcerpc_winreg_QueryValue_r_done(struct tevent_req *subreq)
4116 {
4117         struct tevent_req *req =
4118                 tevent_req_callback_data(subreq,
4119                 struct tevent_req);
4120         NTSTATUS status;
4121
4122         status = dcerpc_binding_handle_call_recv(subreq);
4123         if (!NT_STATUS_IS_OK(status)) {
4124                 tevent_req_nterror(req, status);
4125                 return;
4126         }
4127
4128         tevent_req_done(req);
4129 }
4130
4131 NTSTATUS dcerpc_winreg_QueryValue_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
4132 {
4133         struct dcerpc_winreg_QueryValue_r_state *state =
4134                 tevent_req_data(req,
4135                 struct dcerpc_winreg_QueryValue_r_state);
4136         NTSTATUS status;
4137
4138         if (tevent_req_is_nterror(req, &status)) {
4139                 tevent_req_received(req);
4140                 return status;
4141         }
4142
4143         talloc_steal(mem_ctx, state->out_mem_ctx);
4144
4145         tevent_req_received(req);
4146         return NT_STATUS_OK;
4147 }
4148
4149 NTSTATUS dcerpc_winreg_QueryValue_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_QueryValue *r)
4150 {
4151         NTSTATUS status;
4152
4153         status = dcerpc_binding_handle_call(h,
4154                         NULL, &ndr_table_winreg,
4155                         NDR_WINREG_QUERYVALUE, mem_ctx, r);
4156
4157         return status;
4158 }
4159
4160 NTSTATUS dcerpc_winreg_QueryValue_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_QueryValue *r)
4161 {
4162         NTSTATUS status;
4163
4164         status = dcerpc_winreg_QueryValue_r(p->binding_handle, mem_ctx, r);
4165
4166         if (NT_STATUS_IS_RPC(status)) {
4167                 status = NT_STATUS_NET_WRITE_FAULT;
4168         }
4169
4170         return status;
4171 }
4172
4173 struct dcerpc_winreg_QueryValue_state {
4174         struct winreg_QueryValue orig;
4175         struct winreg_QueryValue tmp;
4176         TALLOC_CTX *out_mem_ctx;
4177 };
4178
4179 static void dcerpc_winreg_QueryValue_done(struct tevent_req *subreq);
4180
4181 struct tevent_req *dcerpc_winreg_QueryValue_send(TALLOC_CTX *mem_ctx,
4182                                                  struct tevent_context *ev,
4183                                                  struct dcerpc_binding_handle *h,
4184                                                  struct policy_handle *_handle /* [in] [ref] */,
4185                                                  struct winreg_String *_value_name /* [in] [ref] */,
4186                                                  enum winreg_Type *_type /* [in,out] [unique] */,
4187                                                  uint8_t *_data /* [in,out] [unique,range(0,0x4000000),length_is(data_length?*data_length:0),size_is(data_size?*data_size:0)] */,
4188                                                  uint32_t *_data_size /* [in,out] [unique] */,
4189                                                  uint32_t *_data_length /* [in,out] [unique] */)
4190 {
4191         struct tevent_req *req;
4192         struct dcerpc_winreg_QueryValue_state *state;
4193         struct tevent_req *subreq;
4194
4195         req = tevent_req_create(mem_ctx, &state,
4196                                 struct dcerpc_winreg_QueryValue_state);
4197         if (req == NULL) {
4198                 return NULL;
4199         }
4200         state->out_mem_ctx = NULL;
4201
4202         /* In parameters */
4203         state->orig.in.handle = _handle;
4204         state->orig.in.value_name = _value_name;
4205         state->orig.in.type = _type;
4206         state->orig.in.data = _data;
4207         state->orig.in.data_size = _data_size;
4208         state->orig.in.data_length = _data_length;
4209
4210         /* Out parameters */
4211         state->orig.out.type = _type;
4212         state->orig.out.data = _data;
4213         state->orig.out.data_size = _data_size;
4214         state->orig.out.data_length = _data_length;
4215
4216         /* Result */
4217         ZERO_STRUCT(state->orig.out.result);
4218
4219         state->out_mem_ctx = talloc_named_const(state, 0,
4220                              "dcerpc_winreg_QueryValue_out_memory");
4221         if (tevent_req_nomem(state->out_mem_ctx, req)) {
4222                 return tevent_req_post(req, ev);
4223         }
4224
4225         /* make a temporary copy, that we pass to the dispatch function */
4226         state->tmp = state->orig;
4227
4228         subreq = dcerpc_winreg_QueryValue_r_send(state, ev, h, &state->tmp);
4229         if (tevent_req_nomem(subreq, req)) {
4230                 return tevent_req_post(req, ev);
4231         }
4232         tevent_req_set_callback(subreq, dcerpc_winreg_QueryValue_done, req);
4233         return req;
4234 }
4235
4236 static void dcerpc_winreg_QueryValue_done(struct tevent_req *subreq)
4237 {
4238         struct tevent_req *req = tevent_req_callback_data(
4239                 subreq, struct tevent_req);
4240         struct dcerpc_winreg_QueryValue_state *state = tevent_req_data(
4241                 req, struct dcerpc_winreg_QueryValue_state);
4242         NTSTATUS status;
4243         TALLOC_CTX *mem_ctx;
4244
4245         if (state->out_mem_ctx) {
4246                 mem_ctx = state->out_mem_ctx;
4247         } else {
4248                 mem_ctx = state;
4249         }
4250
4251         status = dcerpc_winreg_QueryValue_r_recv(subreq, mem_ctx);
4252         TALLOC_FREE(subreq);
4253         if (!NT_STATUS_IS_OK(status)) {
4254                 tevent_req_nterror(req, status);
4255                 return;
4256         }
4257
4258         /* Copy out parameters */
4259         if (state->orig.out.type && state->tmp.out.type) {
4260                 *state->orig.out.type = *state->tmp.out.type;
4261         }
4262         if (state->orig.out.data && state->tmp.out.data) {
4263                 {
4264                         size_t _copy_len_data;
4265                         if ((state->tmp.out.data_size?*state->tmp.out.data_size:0) > (state->tmp.in.data_size?*state->tmp.in.data_size:0)) {
4266                                 tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
4267                                 return;
4268                         }
4269                         if ((state->tmp.out.data_length?*state->tmp.out.data_length:0) > (state->tmp.out.data_size?*state->tmp.out.data_size:0)) {
4270                                 tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
4271                                 return;
4272                         }
4273                         _copy_len_data = state->tmp.out.data_length?*state->tmp.out.data_length:0;
4274                         memcpy(state->orig.out.data, state->tmp.out.data, _copy_len_data * sizeof(*state->orig.out.data));
4275                 }
4276         }
4277         if (state->orig.out.data_size && state->tmp.out.data_size) {
4278                 *state->orig.out.data_size = *state->tmp.out.data_size;
4279         }
4280         if (state->orig.out.data_length && state->tmp.out.data_length) {
4281                 *state->orig.out.data_length = *state->tmp.out.data_length;
4282         }
4283
4284         /* Copy result */
4285         state->orig.out.result = state->tmp.out.result;
4286
4287         /* Reset temporary structure */
4288         ZERO_STRUCT(state->tmp);
4289
4290         tevent_req_done(req);
4291 }
4292
4293 NTSTATUS dcerpc_winreg_QueryValue_recv(struct tevent_req *req,
4294                                        TALLOC_CTX *mem_ctx,
4295                                        WERROR *result)
4296 {
4297         struct dcerpc_winreg_QueryValue_state *state = tevent_req_data(
4298                 req, struct dcerpc_winreg_QueryValue_state);
4299         NTSTATUS status;
4300
4301         if (tevent_req_is_nterror(req, &status)) {
4302                 tevent_req_received(req);
4303                 return status;
4304         }
4305
4306         /* Steal possible out parameters to the callers context */
4307         talloc_steal(mem_ctx, state->out_mem_ctx);
4308
4309         /* Return result */
4310         *result = state->orig.out.result;
4311
4312         tevent_req_received(req);
4313         return NT_STATUS_OK;
4314 }
4315
4316 NTSTATUS dcerpc_winreg_QueryValue(struct dcerpc_binding_handle *h,
4317                                   TALLOC_CTX *mem_ctx,
4318                                   struct policy_handle *_handle /* [in] [ref] */,
4319                                   struct winreg_String *_value_name /* [in] [ref] */,
4320                                   enum winreg_Type *_type /* [in,out] [unique] */,
4321                                   uint8_t *_data /* [in,out] [unique,range(0,0x4000000),length_is(data_length?*data_length:0),size_is(data_size?*data_size:0)] */,
4322                                   uint32_t *_data_size /* [in,out] [unique] */,
4323                                   uint32_t *_data_length /* [in,out] [unique] */,
4324                                   WERROR *result)
4325 {
4326         struct winreg_QueryValue r;
4327         NTSTATUS status;
4328
4329         /* In parameters */
4330         r.in.handle = _handle;
4331         r.in.value_name = _value_name;
4332         r.in.type = _type;
4333         r.in.data = _data;
4334         r.in.data_size = _data_size;
4335         r.in.data_length = _data_length;
4336
4337         status = dcerpc_winreg_QueryValue_r(h, mem_ctx, &r);
4338         if (!NT_STATUS_IS_OK(status)) {
4339                 return status;
4340         }
4341
4342         /* Return variables */
4343         if (_type && r.out.type) {
4344                 *_type = *r.out.type;
4345         }
4346         if (_data && r.out.data) {
4347                 {
4348                         size_t _copy_len_data;
4349                         if ((r.out.data_size?*r.out.data_size:0) > (r.in.data_size?*r.in.data_size:0)) {
4350                                 return NT_STATUS_INVALID_NETWORK_RESPONSE;
4351                         }
4352                         if ((r.out.data_length?*r.out.data_length:0) > (r.out.data_size?*r.out.data_size:0)) {
4353                                 return NT_STATUS_INVALID_NETWORK_RESPONSE;
4354                         }
4355                         _copy_len_data = r.out.data_length?*r.out.data_length:0;
4356                         memcpy(_data, r.out.data, _copy_len_data * sizeof(*_data));
4357                 }
4358         }
4359         if (_data_size && r.out.data_size) {
4360                 *_data_size = *r.out.data_size;
4361         }
4362         if (_data_length && r.out.data_length) {
4363                 *_data_length = *r.out.data_length;
4364         }
4365
4366         /* Return result */
4367         *result = r.out.result;
4368
4369         return NT_STATUS_OK;
4370 }
4371
4372 struct dcerpc_winreg_ReplaceKey_r_state {
4373         TALLOC_CTX *out_mem_ctx;
4374 };
4375
4376 static void dcerpc_winreg_ReplaceKey_r_done(struct tevent_req *subreq);
4377
4378 struct tevent_req *dcerpc_winreg_ReplaceKey_r_send(TALLOC_CTX *mem_ctx,
4379         struct tevent_context *ev,
4380         struct dcerpc_binding_handle *h,
4381         struct winreg_ReplaceKey *r)
4382 {
4383         struct tevent_req *req;
4384         struct dcerpc_winreg_ReplaceKey_r_state *state;
4385         struct tevent_req *subreq;
4386
4387         req = tevent_req_create(mem_ctx, &state,
4388                                 struct dcerpc_winreg_ReplaceKey_r_state);
4389         if (req == NULL) {
4390                 return NULL;
4391         }
4392
4393         state->out_mem_ctx = NULL;
4394         subreq = dcerpc_binding_handle_call_send(state, ev, h,
4395                         NULL, &ndr_table_winreg,
4396                         NDR_WINREG_REPLACEKEY, state, r);
4397         if (tevent_req_nomem(subreq, req)) {
4398                 return tevent_req_post(req, ev);
4399         }
4400         tevent_req_set_callback(subreq, dcerpc_winreg_ReplaceKey_r_done, req);
4401
4402         return req;
4403 }
4404
4405 static void dcerpc_winreg_ReplaceKey_r_done(struct tevent_req *subreq)
4406 {
4407         struct tevent_req *req =
4408                 tevent_req_callback_data(subreq,
4409                 struct tevent_req);
4410         NTSTATUS status;
4411
4412         status = dcerpc_binding_handle_call_recv(subreq);
4413         if (!NT_STATUS_IS_OK(status)) {
4414                 tevent_req_nterror(req, status);
4415                 return;
4416         }
4417
4418         tevent_req_done(req);
4419 }
4420
4421 NTSTATUS dcerpc_winreg_ReplaceKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
4422 {
4423         struct dcerpc_winreg_ReplaceKey_r_state *state =
4424                 tevent_req_data(req,
4425                 struct dcerpc_winreg_ReplaceKey_r_state);
4426         NTSTATUS status;
4427
4428         if (tevent_req_is_nterror(req, &status)) {
4429                 tevent_req_received(req);
4430                 return status;
4431         }
4432
4433         talloc_steal(mem_ctx, state->out_mem_ctx);
4434
4435         tevent_req_received(req);
4436         return NT_STATUS_OK;
4437 }
4438
4439 NTSTATUS dcerpc_winreg_ReplaceKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_ReplaceKey *r)
4440 {
4441         NTSTATUS status;
4442
4443         status = dcerpc_binding_handle_call(h,
4444                         NULL, &ndr_table_winreg,
4445                         NDR_WINREG_REPLACEKEY, mem_ctx, r);
4446
4447         return status;
4448 }
4449
4450 NTSTATUS dcerpc_winreg_ReplaceKey_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_ReplaceKey *r)
4451 {
4452         NTSTATUS status;
4453
4454         status = dcerpc_winreg_ReplaceKey_r(p->binding_handle, mem_ctx, r);
4455
4456         if (NT_STATUS_IS_RPC(status)) {
4457                 status = NT_STATUS_NET_WRITE_FAULT;
4458         }
4459
4460         return status;
4461 }
4462
4463 struct dcerpc_winreg_ReplaceKey_state {
4464         struct winreg_ReplaceKey orig;
4465         struct winreg_ReplaceKey tmp;
4466         TALLOC_CTX *out_mem_ctx;
4467 };
4468
4469 static void dcerpc_winreg_ReplaceKey_done(struct tevent_req *subreq);
4470
4471 struct tevent_req *dcerpc_winreg_ReplaceKey_send(TALLOC_CTX *mem_ctx,
4472                                                  struct tevent_context *ev,
4473                                                  struct dcerpc_binding_handle *h,
4474                                                  struct policy_handle *_handle /* [in] [ref] */,
4475                                                  struct winreg_String *_subkey /* [in] [ref] */,
4476                                                  struct winreg_String *_new_file /* [in] [ref] */,
4477                                                  struct winreg_String *_old_file /* [in] [ref] */)
4478 {
4479         struct tevent_req *req;
4480         struct dcerpc_winreg_ReplaceKey_state *state;
4481         struct tevent_req *subreq;
4482
4483         req = tevent_req_create(mem_ctx, &state,
4484                                 struct dcerpc_winreg_ReplaceKey_state);
4485         if (req == NULL) {
4486                 return NULL;
4487         }
4488         state->out_mem_ctx = NULL;
4489
4490         /* In parameters */
4491         state->orig.in.handle = _handle;
4492         state->orig.in.subkey = _subkey;
4493         state->orig.in.new_file = _new_file;
4494         state->orig.in.old_file = _old_file;
4495
4496         /* Out parameters */
4497
4498         /* Result */
4499         ZERO_STRUCT(state->orig.out.result);
4500
4501         /* make a temporary copy, that we pass to the dispatch function */
4502         state->tmp = state->orig;
4503
4504         subreq = dcerpc_winreg_ReplaceKey_r_send(state, ev, h, &state->tmp);
4505         if (tevent_req_nomem(subreq, req)) {
4506                 return tevent_req_post(req, ev);
4507         }
4508         tevent_req_set_callback(subreq, dcerpc_winreg_ReplaceKey_done, req);
4509         return req;
4510 }
4511
4512 static void dcerpc_winreg_ReplaceKey_done(struct tevent_req *subreq)
4513 {
4514         struct tevent_req *req = tevent_req_callback_data(
4515                 subreq, struct tevent_req);
4516         struct dcerpc_winreg_ReplaceKey_state *state = tevent_req_data(
4517                 req, struct dcerpc_winreg_ReplaceKey_state);
4518         NTSTATUS status;
4519         TALLOC_CTX *mem_ctx;
4520
4521         if (state->out_mem_ctx) {
4522                 mem_ctx = state->out_mem_ctx;
4523         } else {
4524                 mem_ctx = state;
4525         }
4526
4527         status = dcerpc_winreg_ReplaceKey_r_recv(subreq, mem_ctx);
4528         TALLOC_FREE(subreq);
4529         if (!NT_STATUS_IS_OK(status)) {
4530                 tevent_req_nterror(req, status);
4531                 return;
4532         }
4533
4534         /* Copy out parameters */
4535
4536         /* Copy result */
4537         state->orig.out.result = state->tmp.out.result;
4538
4539         /* Reset temporary structure */
4540         ZERO_STRUCT(state->tmp);
4541
4542         tevent_req_done(req);
4543 }
4544
4545 NTSTATUS dcerpc_winreg_ReplaceKey_recv(struct tevent_req *req,
4546                                        TALLOC_CTX *mem_ctx,
4547                                        WERROR *result)
4548 {
4549         struct dcerpc_winreg_ReplaceKey_state *state = tevent_req_data(
4550                 req, struct dcerpc_winreg_ReplaceKey_state);
4551         NTSTATUS status;
4552
4553         if (tevent_req_is_nterror(req, &status)) {
4554                 tevent_req_received(req);
4555                 return status;
4556         }
4557
4558         /* Steal possible out parameters to the callers context */
4559         talloc_steal(mem_ctx, state->out_mem_ctx);
4560
4561         /* Return result */
4562         *result = state->orig.out.result;
4563
4564         tevent_req_received(req);
4565         return NT_STATUS_OK;
4566 }
4567
4568 NTSTATUS dcerpc_winreg_ReplaceKey(struct dcerpc_binding_handle *h,
4569                                   TALLOC_CTX *mem_ctx,
4570                                   struct policy_handle *_handle /* [in] [ref] */,
4571                                   struct winreg_String *_subkey /* [in] [ref] */,
4572                                   struct winreg_String *_new_file /* [in] [ref] */,
4573                                   struct winreg_String *_old_file /* [in] [ref] */,
4574                                   WERROR *result)
4575 {
4576         struct winreg_ReplaceKey r;
4577         NTSTATUS status;
4578
4579         /* In parameters */
4580         r.in.handle = _handle;
4581         r.in.subkey = _subkey;
4582         r.in.new_file = _new_file;
4583         r.in.old_file = _old_file;
4584
4585         status = dcerpc_winreg_ReplaceKey_r(h, mem_ctx, &r);
4586         if (!NT_STATUS_IS_OK(status)) {
4587                 return status;
4588         }
4589
4590         /* Return variables */
4591
4592         /* Return result */
4593         *result = r.out.result;
4594
4595         return NT_STATUS_OK;
4596 }
4597
4598 struct dcerpc_winreg_RestoreKey_r_state {
4599         TALLOC_CTX *out_mem_ctx;
4600 };
4601
4602 static void dcerpc_winreg_RestoreKey_r_done(struct tevent_req *subreq);
4603
4604 struct tevent_req *dcerpc_winreg_RestoreKey_r_send(TALLOC_CTX *mem_ctx,
4605         struct tevent_context *ev,
4606         struct dcerpc_binding_handle *h,
4607         struct winreg_RestoreKey *r)
4608 {
4609         struct tevent_req *req;
4610         struct dcerpc_winreg_RestoreKey_r_state *state;
4611         struct tevent_req *subreq;
4612
4613         req = tevent_req_create(mem_ctx, &state,
4614                                 struct dcerpc_winreg_RestoreKey_r_state);
4615         if (req == NULL) {
4616                 return NULL;
4617         }
4618
4619         state->out_mem_ctx = NULL;
4620         subreq = dcerpc_binding_handle_call_send(state, ev, h,
4621                         NULL, &ndr_table_winreg,
4622                         NDR_WINREG_RESTOREKEY, state, r);
4623         if (tevent_req_nomem(subreq, req)) {
4624                 return tevent_req_post(req, ev);
4625         }
4626         tevent_req_set_callback(subreq, dcerpc_winreg_RestoreKey_r_done, req);
4627
4628         return req;
4629 }
4630
4631 static void dcerpc_winreg_RestoreKey_r_done(struct tevent_req *subreq)
4632 {
4633         struct tevent_req *req =
4634                 tevent_req_callback_data(subreq,
4635                 struct tevent_req);
4636         NTSTATUS status;
4637
4638         status = dcerpc_binding_handle_call_recv(subreq);
4639         if (!NT_STATUS_IS_OK(status)) {
4640                 tevent_req_nterror(req, status);
4641                 return;
4642         }
4643
4644         tevent_req_done(req);
4645 }
4646
4647 NTSTATUS dcerpc_winreg_RestoreKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
4648 {
4649         struct dcerpc_winreg_RestoreKey_r_state *state =
4650                 tevent_req_data(req,
4651                 struct dcerpc_winreg_RestoreKey_r_state);
4652         NTSTATUS status;
4653
4654         if (tevent_req_is_nterror(req, &status)) {
4655                 tevent_req_received(req);
4656                 return status;
4657         }
4658
4659         talloc_steal(mem_ctx, state->out_mem_ctx);
4660
4661         tevent_req_received(req);
4662         return NT_STATUS_OK;
4663 }
4664
4665 NTSTATUS dcerpc_winreg_RestoreKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_RestoreKey *r)
4666 {
4667         NTSTATUS status;
4668
4669         status = dcerpc_binding_handle_call(h,
4670                         NULL, &ndr_table_winreg,
4671                         NDR_WINREG_RESTOREKEY, mem_ctx, r);
4672
4673         return status;
4674 }
4675
4676 NTSTATUS dcerpc_winreg_RestoreKey_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_RestoreKey *r)
4677 {
4678         NTSTATUS status;
4679
4680         status = dcerpc_winreg_RestoreKey_r(p->binding_handle, mem_ctx, r);
4681
4682         if (NT_STATUS_IS_RPC(status)) {
4683                 status = NT_STATUS_NET_WRITE_FAULT;
4684         }
4685
4686         return status;
4687 }
4688
4689 struct dcerpc_winreg_RestoreKey_state {
4690         struct winreg_RestoreKey orig;
4691         struct winreg_RestoreKey tmp;
4692         TALLOC_CTX *out_mem_ctx;
4693 };
4694
4695 static void dcerpc_winreg_RestoreKey_done(struct tevent_req *subreq);
4696
4697 struct tevent_req *dcerpc_winreg_RestoreKey_send(TALLOC_CTX *mem_ctx,
4698                                                  struct tevent_context *ev,
4699                                                  struct dcerpc_binding_handle *h,
4700                                                  struct policy_handle *_handle /* [in] [ref] */,
4701                                                  struct winreg_String *_filename /* [in] [ref] */,
4702                                                  uint32_t _flags /* [in]  */)
4703 {
4704         struct tevent_req *req;
4705         struct dcerpc_winreg_RestoreKey_state *state;
4706         struct tevent_req *subreq;
4707
4708         req = tevent_req_create(mem_ctx, &state,
4709                                 struct dcerpc_winreg_RestoreKey_state);
4710         if (req == NULL) {
4711                 return NULL;
4712         }
4713         state->out_mem_ctx = NULL;
4714
4715         /* In parameters */
4716         state->orig.in.handle = _handle;
4717         state->orig.in.filename = _filename;
4718         state->orig.in.flags = _flags;
4719
4720         /* Out parameters */
4721
4722         /* Result */
4723         ZERO_STRUCT(state->orig.out.result);
4724
4725         /* make a temporary copy, that we pass to the dispatch function */
4726         state->tmp = state->orig;
4727
4728         subreq = dcerpc_winreg_RestoreKey_r_send(state, ev, h, &state->tmp);
4729         if (tevent_req_nomem(subreq, req)) {
4730                 return tevent_req_post(req, ev);
4731         }
4732         tevent_req_set_callback(subreq, dcerpc_winreg_RestoreKey_done, req);
4733         return req;
4734 }
4735
4736 static void dcerpc_winreg_RestoreKey_done(struct tevent_req *subreq)
4737 {
4738         struct tevent_req *req = tevent_req_callback_data(
4739                 subreq, struct tevent_req);
4740         struct dcerpc_winreg_RestoreKey_state *state = tevent_req_data(
4741                 req, struct dcerpc_winreg_RestoreKey_state);
4742         NTSTATUS status;
4743         TALLOC_CTX *mem_ctx;
4744
4745         if (state->out_mem_ctx) {
4746                 mem_ctx = state->out_mem_ctx;
4747         } else {
4748                 mem_ctx = state;
4749         }
4750
4751         status = dcerpc_winreg_RestoreKey_r_recv(subreq, mem_ctx);
4752         TALLOC_FREE(subreq);
4753         if (!NT_STATUS_IS_OK(status)) {
4754                 tevent_req_nterror(req, status);
4755                 return;
4756         }
4757
4758         /* Copy out parameters */
4759
4760         /* Copy result */
4761         state->orig.out.result = state->tmp.out.result;
4762
4763         /* Reset temporary structure */
4764         ZERO_STRUCT(state->tmp);
4765
4766         tevent_req_done(req);
4767 }
4768
4769 NTSTATUS dcerpc_winreg_RestoreKey_recv(struct tevent_req *req,
4770                                        TALLOC_CTX *mem_ctx,
4771                                        WERROR *result)
4772 {
4773         struct dcerpc_winreg_RestoreKey_state *state = tevent_req_data(
4774                 req, struct dcerpc_winreg_RestoreKey_state);
4775         NTSTATUS status;
4776
4777         if (tevent_req_is_nterror(req, &status)) {
4778                 tevent_req_received(req);
4779                 return status;
4780         }
4781
4782         /* Steal possible out parameters to the callers context */
4783         talloc_steal(mem_ctx, state->out_mem_ctx);
4784
4785         /* Return result */
4786         *result = state->orig.out.result;
4787
4788         tevent_req_received(req);
4789         return NT_STATUS_OK;
4790 }
4791
4792 NTSTATUS dcerpc_winreg_RestoreKey(struct dcerpc_binding_handle *h,
4793                                   TALLOC_CTX *mem_ctx,
4794                                   struct policy_handle *_handle /* [in] [ref] */,
4795                                   struct winreg_String *_filename /* [in] [ref] */,
4796                                   uint32_t _flags /* [in]  */,
4797                                   WERROR *result)
4798 {
4799         struct winreg_RestoreKey r;
4800         NTSTATUS status;
4801
4802         /* In parameters */
4803         r.in.handle = _handle;
4804         r.in.filename = _filename;
4805         r.in.flags = _flags;
4806
4807         status = dcerpc_winreg_RestoreKey_r(h, mem_ctx, &r);
4808         if (!NT_STATUS_IS_OK(status)) {
4809                 return status;
4810         }
4811
4812         /* Return variables */
4813
4814         /* Return result */
4815         *result = r.out.result;
4816
4817         return NT_STATUS_OK;
4818 }
4819
4820 struct dcerpc_winreg_SaveKey_r_state {
4821         TALLOC_CTX *out_mem_ctx;
4822 };
4823
4824 static void dcerpc_winreg_SaveKey_r_done(struct tevent_req *subreq);
4825
4826 struct tevent_req *dcerpc_winreg_SaveKey_r_send(TALLOC_CTX *mem_ctx,
4827         struct tevent_context *ev,
4828         struct dcerpc_binding_handle *h,
4829         struct winreg_SaveKey *r)
4830 {
4831         struct tevent_req *req;
4832         struct dcerpc_winreg_SaveKey_r_state *state;
4833         struct tevent_req *subreq;
4834
4835         req = tevent_req_create(mem_ctx, &state,
4836                                 struct dcerpc_winreg_SaveKey_r_state);
4837         if (req == NULL) {
4838                 return NULL;
4839         }
4840
4841         state->out_mem_ctx = NULL;
4842         subreq = dcerpc_binding_handle_call_send(state, ev, h,
4843                         NULL, &ndr_table_winreg,
4844                         NDR_WINREG_SAVEKEY, state, r);
4845         if (tevent_req_nomem(subreq, req)) {
4846                 return tevent_req_post(req, ev);
4847         }
4848         tevent_req_set_callback(subreq, dcerpc_winreg_SaveKey_r_done, req);
4849
4850         return req;
4851 }
4852
4853 static void dcerpc_winreg_SaveKey_r_done(struct tevent_req *subreq)
4854 {
4855         struct tevent_req *req =
4856                 tevent_req_callback_data(subreq,
4857                 struct tevent_req);
4858         NTSTATUS status;
4859
4860         status = dcerpc_binding_handle_call_recv(subreq);
4861         if (!NT_STATUS_IS_OK(status)) {
4862                 tevent_req_nterror(req, status);
4863                 return;
4864         }
4865
4866         tevent_req_done(req);
4867 }
4868
4869 NTSTATUS dcerpc_winreg_SaveKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
4870 {
4871         struct dcerpc_winreg_SaveKey_r_state *state =
4872                 tevent_req_data(req,
4873                 struct dcerpc_winreg_SaveKey_r_state);
4874         NTSTATUS status;
4875
4876         if (tevent_req_is_nterror(req, &status)) {
4877                 tevent_req_received(req);
4878                 return status;
4879         }
4880
4881         talloc_steal(mem_ctx, state->out_mem_ctx);
4882
4883         tevent_req_received(req);
4884         return NT_STATUS_OK;
4885 }
4886
4887 NTSTATUS dcerpc_winreg_SaveKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_SaveKey *r)
4888 {
4889         NTSTATUS status;
4890
4891         status = dcerpc_binding_handle_call(h,
4892                         NULL, &ndr_table_winreg,
4893                         NDR_WINREG_SAVEKEY, mem_ctx, r);
4894
4895         return status;
4896 }
4897
4898 NTSTATUS dcerpc_winreg_SaveKey_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_SaveKey *r)
4899 {
4900         NTSTATUS status;
4901
4902         status = dcerpc_winreg_SaveKey_r(p->binding_handle, mem_ctx, r);
4903
4904         if (NT_STATUS_IS_RPC(status)) {
4905                 status = NT_STATUS_NET_WRITE_FAULT;
4906         }
4907
4908         return status;
4909 }
4910
4911 struct dcerpc_winreg_SaveKey_state {
4912         struct winreg_SaveKey orig;
4913         struct winreg_SaveKey tmp;
4914         TALLOC_CTX *out_mem_ctx;
4915 };
4916
4917 static void dcerpc_winreg_SaveKey_done(struct tevent_req *subreq);
4918
4919 struct tevent_req *dcerpc_winreg_SaveKey_send(TALLOC_CTX *mem_ctx,
4920                                               struct tevent_context *ev,
4921                                               struct dcerpc_binding_handle *h,
4922                                               struct policy_handle *_handle /* [in] [ref] */,
4923                                               struct winreg_String *_filename /* [in] [ref] */,
4924                                               struct KeySecurityAttribute *_sec_attrib /* [in] [unique] */)
4925 {
4926         struct tevent_req *req;
4927         struct dcerpc_winreg_SaveKey_state *state;
4928         struct tevent_req *subreq;
4929
4930         req = tevent_req_create(mem_ctx, &state,
4931                                 struct dcerpc_winreg_SaveKey_state);
4932         if (req == NULL) {
4933                 return NULL;
4934         }
4935         state->out_mem_ctx = NULL;
4936
4937         /* In parameters */
4938         state->orig.in.handle = _handle;
4939         state->orig.in.filename = _filename;
4940         state->orig.in.sec_attrib = _sec_attrib;
4941
4942         /* Out parameters */
4943
4944         /* Result */
4945         ZERO_STRUCT(state->orig.out.result);
4946
4947         /* make a temporary copy, that we pass to the dispatch function */
4948         state->tmp = state->orig;
4949
4950         subreq = dcerpc_winreg_SaveKey_r_send(state, ev, h, &state->tmp);
4951         if (tevent_req_nomem(subreq, req)) {
4952                 return tevent_req_post(req, ev);
4953         }
4954         tevent_req_set_callback(subreq, dcerpc_winreg_SaveKey_done, req);
4955         return req;
4956 }
4957
4958 static void dcerpc_winreg_SaveKey_done(struct tevent_req *subreq)
4959 {
4960         struct tevent_req *req = tevent_req_callback_data(
4961                 subreq, struct tevent_req);
4962         struct dcerpc_winreg_SaveKey_state *state = tevent_req_data(
4963                 req, struct dcerpc_winreg_SaveKey_state);
4964         NTSTATUS status;
4965         TALLOC_CTX *mem_ctx;
4966
4967         if (state->out_mem_ctx) {
4968                 mem_ctx = state->out_mem_ctx;
4969         } else {
4970                 mem_ctx = state;
4971         }
4972
4973         status = dcerpc_winreg_SaveKey_r_recv(subreq, mem_ctx);
4974         TALLOC_FREE(subreq);
4975         if (!NT_STATUS_IS_OK(status)) {
4976                 tevent_req_nterror(req, status);
4977                 return;
4978         }
4979
4980         /* Copy out parameters */
4981
4982         /* Copy result */
4983         state->orig.out.result = state->tmp.out.result;
4984
4985         /* Reset temporary structure */
4986         ZERO_STRUCT(state->tmp);
4987
4988         tevent_req_done(req);
4989 }
4990
4991 NTSTATUS dcerpc_winreg_SaveKey_recv(struct tevent_req *req,
4992                                     TALLOC_CTX *mem_ctx,
4993                                     WERROR *result)
4994 {
4995         struct dcerpc_winreg_SaveKey_state *state = tevent_req_data(
4996                 req, struct dcerpc_winreg_SaveKey_state);
4997         NTSTATUS status;
4998
4999         if (tevent_req_is_nterror(req, &status)) {
5000                 tevent_req_received(req);
5001                 return status;
5002         }
5003
5004         /* Steal possible out parameters to the callers context */
5005         talloc_steal(mem_ctx, state->out_mem_ctx);
5006
5007         /* Return result */
5008         *result = state->orig.out.result;
5009
5010         tevent_req_received(req);
5011         return NT_STATUS_OK;
5012 }
5013
5014 NTSTATUS dcerpc_winreg_SaveKey(struct dcerpc_binding_handle *h,
5015                                TALLOC_CTX *mem_ctx,
5016                                struct policy_handle *_handle /* [in] [ref] */,
5017                                struct winreg_String *_filename /* [in] [ref] */,
5018                                struct KeySecurityAttribute *_sec_attrib /* [in] [unique] */,
5019                                WERROR *result)
5020 {
5021         struct winreg_SaveKey r;
5022         NTSTATUS status;
5023
5024         /* In parameters */
5025         r.in.handle = _handle;
5026         r.in.filename = _filename;
5027         r.in.sec_attrib = _sec_attrib;
5028
5029         status = dcerpc_winreg_SaveKey_r(h, mem_ctx, &r);
5030         if (!NT_STATUS_IS_OK(status)) {
5031                 return status;
5032         }
5033
5034         /* Return variables */
5035
5036         /* Return result */
5037         *result = r.out.result;
5038
5039         return NT_STATUS_OK;
5040 }
5041
5042 struct dcerpc_winreg_SetKeySecurity_r_state {
5043         TALLOC_CTX *out_mem_ctx;
5044 };
5045
5046 static void dcerpc_winreg_SetKeySecurity_r_done(struct tevent_req *subreq);
5047
5048 struct tevent_req *dcerpc_winreg_SetKeySecurity_r_send(TALLOC_CTX *mem_ctx,
5049         struct tevent_context *ev,
5050         struct dcerpc_binding_handle *h,
5051         struct winreg_SetKeySecurity *r)
5052 {
5053         struct tevent_req *req;
5054         struct dcerpc_winreg_SetKeySecurity_r_state *state;
5055         struct tevent_req *subreq;
5056
5057         req = tevent_req_create(mem_ctx, &state,
5058                                 struct dcerpc_winreg_SetKeySecurity_r_state);
5059         if (req == NULL) {
5060                 return NULL;
5061         }
5062
5063         state->out_mem_ctx = NULL;
5064         subreq = dcerpc_binding_handle_call_send(state, ev, h,
5065                         NULL, &ndr_table_winreg,
5066                         NDR_WINREG_SETKEYSECURITY, state, r);
5067         if (tevent_req_nomem(subreq, req)) {
5068                 return tevent_req_post(req, ev);
5069         }
5070         tevent_req_set_callback(subreq, dcerpc_winreg_SetKeySecurity_r_done, req);
5071
5072         return req;
5073 }
5074
5075 static void dcerpc_winreg_SetKeySecurity_r_done(struct tevent_req *subreq)
5076 {
5077         struct tevent_req *req =
5078                 tevent_req_callback_data(subreq,
5079                 struct tevent_req);
5080         NTSTATUS status;
5081
5082         status = dcerpc_binding_handle_call_recv(subreq);
5083         if (!NT_STATUS_IS_OK(status)) {
5084                 tevent_req_nterror(req, status);
5085                 return;
5086         }
5087
5088         tevent_req_done(req);
5089 }
5090
5091 NTSTATUS dcerpc_winreg_SetKeySecurity_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
5092 {
5093         struct dcerpc_winreg_SetKeySecurity_r_state *state =
5094                 tevent_req_data(req,
5095                 struct dcerpc_winreg_SetKeySecurity_r_state);
5096         NTSTATUS status;
5097
5098         if (tevent_req_is_nterror(req, &status)) {
5099                 tevent_req_received(req);
5100                 return status;
5101         }
5102
5103         talloc_steal(mem_ctx, state->out_mem_ctx);
5104
5105         tevent_req_received(req);
5106         return NT_STATUS_OK;
5107 }
5108
5109 NTSTATUS dcerpc_winreg_SetKeySecurity_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_SetKeySecurity *r)
5110 {
5111         NTSTATUS status;
5112
5113         status = dcerpc_binding_handle_call(h,
5114                         NULL, &ndr_table_winreg,
5115                         NDR_WINREG_SETKEYSECURITY, mem_ctx, r);
5116
5117         return status;
5118 }
5119
5120 NTSTATUS dcerpc_winreg_SetKeySecurity_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_SetKeySecurity *r)
5121 {
5122         NTSTATUS status;
5123
5124         status = dcerpc_winreg_SetKeySecurity_r(p->binding_handle, mem_ctx, r);
5125
5126         if (NT_STATUS_IS_RPC(status)) {
5127                 status = NT_STATUS_NET_WRITE_FAULT;
5128         }
5129
5130         return status;
5131 }
5132
5133 struct dcerpc_winreg_SetKeySecurity_state {
5134         struct winreg_SetKeySecurity orig;
5135         struct winreg_SetKeySecurity tmp;
5136         TALLOC_CTX *out_mem_ctx;
5137 };
5138
5139 static void dcerpc_winreg_SetKeySecurity_done(struct tevent_req *subreq);
5140
5141 struct tevent_req *dcerpc_winreg_SetKeySecurity_send(TALLOC_CTX *mem_ctx,
5142                                                      struct tevent_context *ev,
5143                                                      struct dcerpc_binding_handle *h,
5144                                                      struct policy_handle *_handle /* [in] [ref] */,
5145                                                      uint32_t _sec_info /* [in]  */,
5146                                                      struct KeySecurityData *_sd /* [in] [ref] */)
5147 {
5148         struct tevent_req *req;
5149         struct dcerpc_winreg_SetKeySecurity_state *state;
5150         struct tevent_req *subreq;
5151
5152         req = tevent_req_create(mem_ctx, &state,
5153                                 struct dcerpc_winreg_SetKeySecurity_state);
5154         if (req == NULL) {
5155                 return NULL;
5156         }
5157         state->out_mem_ctx = NULL;
5158
5159         /* In parameters */
5160         state->orig.in.handle = _handle;
5161         state->orig.in.sec_info = _sec_info;
5162         state->orig.in.sd = _sd;
5163
5164         /* Out parameters */
5165
5166         /* Result */
5167         ZERO_STRUCT(state->orig.out.result);
5168
5169         /* make a temporary copy, that we pass to the dispatch function */
5170         state->tmp = state->orig;
5171
5172         subreq = dcerpc_winreg_SetKeySecurity_r_send(state, ev, h, &state->tmp);
5173         if (tevent_req_nomem(subreq, req)) {
5174                 return tevent_req_post(req, ev);
5175         }
5176         tevent_req_set_callback(subreq, dcerpc_winreg_SetKeySecurity_done, req);
5177         return req;
5178 }
5179
5180 static void dcerpc_winreg_SetKeySecurity_done(struct tevent_req *subreq)
5181 {
5182         struct tevent_req *req = tevent_req_callback_data(
5183                 subreq, struct tevent_req);
5184         struct dcerpc_winreg_SetKeySecurity_state *state = tevent_req_data(
5185                 req, struct dcerpc_winreg_SetKeySecurity_state);
5186         NTSTATUS status;
5187         TALLOC_CTX *mem_ctx;
5188
5189         if (state->out_mem_ctx) {
5190                 mem_ctx = state->out_mem_ctx;
5191         } else {
5192                 mem_ctx = state;
5193         }
5194
5195         status = dcerpc_winreg_SetKeySecurity_r_recv(subreq, mem_ctx);
5196         TALLOC_FREE(subreq);
5197         if (!NT_STATUS_IS_OK(status)) {
5198                 tevent_req_nterror(req, status);
5199                 return;
5200         }
5201
5202         /* Copy out parameters */
5203
5204         /* Copy result */
5205         state->orig.out.result = state->tmp.out.result;
5206
5207         /* Reset temporary structure */
5208         ZERO_STRUCT(state->tmp);
5209
5210         tevent_req_done(req);
5211 }
5212
5213 NTSTATUS dcerpc_winreg_SetKeySecurity_recv(struct tevent_req *req,
5214                                            TALLOC_CTX *mem_ctx,
5215                                            WERROR *result)
5216 {
5217         struct dcerpc_winreg_SetKeySecurity_state *state = tevent_req_data(
5218                 req, struct dcerpc_winreg_SetKeySecurity_state);
5219         NTSTATUS status;
5220
5221         if (tevent_req_is_nterror(req, &status)) {
5222                 tevent_req_received(req);
5223                 return status;
5224         }
5225
5226         /* Steal possible out parameters to the callers context */
5227         talloc_steal(mem_ctx, state->out_mem_ctx);
5228
5229         /* Return result */
5230         *result = state->orig.out.result;
5231
5232         tevent_req_received(req);
5233         return NT_STATUS_OK;
5234 }
5235
5236 NTSTATUS dcerpc_winreg_SetKeySecurity(struct dcerpc_binding_handle *h,
5237                                       TALLOC_CTX *mem_ctx,
5238                                       struct policy_handle *_handle /* [in] [ref] */,
5239                                       uint32_t _sec_info /* [in]  */,
5240                                       struct KeySecurityData *_sd /* [in] [ref] */,
5241                                       WERROR *result)
5242 {
5243         struct winreg_SetKeySecurity r;
5244         NTSTATUS status;
5245
5246         /* In parameters */
5247         r.in.handle = _handle;
5248         r.in.sec_info = _sec_info;
5249         r.in.sd = _sd;
5250
5251         status = dcerpc_winreg_SetKeySecurity_r(h, mem_ctx, &r);
5252         if (!NT_STATUS_IS_OK(status)) {
5253                 return status;
5254         }
5255
5256         /* Return variables */
5257
5258         /* Return result */
5259         *result = r.out.result;
5260
5261         return NT_STATUS_OK;
5262 }
5263
5264 struct dcerpc_winreg_SetValue_r_state {
5265         TALLOC_CTX *out_mem_ctx;
5266 };
5267
5268 static void dcerpc_winreg_SetValue_r_done(struct tevent_req *subreq);
5269
5270 struct tevent_req *dcerpc_winreg_SetValue_r_send(TALLOC_CTX *mem_ctx,
5271         struct tevent_context *ev,
5272         struct dcerpc_binding_handle *h,
5273         struct winreg_SetValue *r)
5274 {
5275         struct tevent_req *req;
5276         struct dcerpc_winreg_SetValue_r_state *state;
5277         struct tevent_req *subreq;
5278
5279         req = tevent_req_create(mem_ctx, &state,
5280                                 struct dcerpc_winreg_SetValue_r_state);
5281         if (req == NULL) {
5282                 return NULL;
5283         }
5284
5285         state->out_mem_ctx = NULL;
5286         subreq = dcerpc_binding_handle_call_send(state, ev, h,
5287                         NULL, &ndr_table_winreg,
5288                         NDR_WINREG_SETVALUE, state, r);
5289         if (tevent_req_nomem(subreq, req)) {
5290                 return tevent_req_post(req, ev);
5291         }
5292         tevent_req_set_callback(subreq, dcerpc_winreg_SetValue_r_done, req);
5293
5294         return req;
5295 }
5296
5297 static void dcerpc_winreg_SetValue_r_done(struct tevent_req *subreq)
5298 {
5299         struct tevent_req *req =
5300                 tevent_req_callback_data(subreq,
5301                 struct tevent_req);
5302         NTSTATUS status;
5303
5304         status = dcerpc_binding_handle_call_recv(subreq);
5305         if (!NT_STATUS_IS_OK(status)) {
5306                 tevent_req_nterror(req, status);
5307                 return;
5308         }
5309
5310         tevent_req_done(req);
5311 }
5312
5313 NTSTATUS dcerpc_winreg_SetValue_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
5314 {
5315         struct dcerpc_winreg_SetValue_r_state *state =
5316                 tevent_req_data(req,
5317                 struct dcerpc_winreg_SetValue_r_state);
5318         NTSTATUS status;
5319
5320         if (tevent_req_is_nterror(req, &status)) {
5321                 tevent_req_received(req);
5322                 return status;
5323         }
5324
5325         talloc_steal(mem_ctx, state->out_mem_ctx);
5326
5327         tevent_req_received(req);
5328         return NT_STATUS_OK;
5329 }
5330
5331 NTSTATUS dcerpc_winreg_SetValue_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_SetValue *r)
5332 {
5333         NTSTATUS status;
5334
5335         status = dcerpc_binding_handle_call(h,
5336                         NULL, &ndr_table_winreg,
5337                         NDR_WINREG_SETVALUE, mem_ctx, r);
5338
5339         return status;
5340 }
5341
5342 NTSTATUS dcerpc_winreg_SetValue_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_SetValue *r)
5343 {
5344         NTSTATUS status;
5345
5346         status = dcerpc_winreg_SetValue_r(p->binding_handle, mem_ctx, r);
5347
5348         if (NT_STATUS_IS_RPC(status)) {
5349                 status = NT_STATUS_NET_WRITE_FAULT;
5350         }
5351
5352         return status;
5353 }
5354
5355 struct dcerpc_winreg_SetValue_state {
5356         struct winreg_SetValue orig;
5357         struct winreg_SetValue tmp;
5358         TALLOC_CTX *out_mem_ctx;
5359 };
5360
5361 static void dcerpc_winreg_SetValue_done(struct tevent_req *subreq);
5362
5363 struct tevent_req *dcerpc_winreg_SetValue_send(TALLOC_CTX *mem_ctx,
5364                                                struct tevent_context *ev,
5365                                                struct dcerpc_binding_handle *h,
5366                                                struct policy_handle *_handle /* [in] [ref] */,
5367                                                struct winreg_String _name /* [in]  */,
5368                                                enum winreg_Type _type /* [in]  */,
5369                                                uint8_t *_data /* [in] [ref,size_is(size)] */,
5370                                                uint32_t _size /* [in]  */)
5371 {
5372         struct tevent_req *req;
5373         struct dcerpc_winreg_SetValue_state *state;
5374         struct tevent_req *subreq;
5375
5376         req = tevent_req_create(mem_ctx, &state,
5377                                 struct dcerpc_winreg_SetValue_state);
5378         if (req == NULL) {
5379                 return NULL;
5380         }
5381         state->out_mem_ctx = NULL;
5382
5383         /* In parameters */
5384         state->orig.in.handle = _handle;
5385         state->orig.in.name = _name;
5386         state->orig.in.type = _type;
5387         state->orig.in.data = _data;
5388         state->orig.in.size = _size;
5389
5390         /* Out parameters */
5391
5392         /* Result */
5393         ZERO_STRUCT(state->orig.out.result);
5394
5395         /* make a temporary copy, that we pass to the dispatch function */
5396         state->tmp = state->orig;
5397
5398         subreq = dcerpc_winreg_SetValue_r_send(state, ev, h, &state->tmp);
5399         if (tevent_req_nomem(subreq, req)) {
5400                 return tevent_req_post(req, ev);
5401         }
5402         tevent_req_set_callback(subreq, dcerpc_winreg_SetValue_done, req);
5403         return req;
5404 }
5405
5406 static void dcerpc_winreg_SetValue_done(struct tevent_req *subreq)
5407 {
5408         struct tevent_req *req = tevent_req_callback_data(
5409                 subreq, struct tevent_req);
5410         struct dcerpc_winreg_SetValue_state *state = tevent_req_data(
5411                 req, struct dcerpc_winreg_SetValue_state);
5412         NTSTATUS status;
5413         TALLOC_CTX *mem_ctx;
5414
5415         if (state->out_mem_ctx) {
5416                 mem_ctx = state->out_mem_ctx;
5417         } else {
5418                 mem_ctx = state;
5419         }
5420
5421         status = dcerpc_winreg_SetValue_r_recv(subreq, mem_ctx);
5422         TALLOC_FREE(subreq);
5423         if (!NT_STATUS_IS_OK(status)) {
5424                 tevent_req_nterror(req, status);
5425                 return;
5426         }
5427
5428         /* Copy out parameters */
5429
5430         /* Copy result */
5431         state->orig.out.result = state->tmp.out.result;
5432
5433         /* Reset temporary structure */
5434         ZERO_STRUCT(state->tmp);
5435
5436         tevent_req_done(req);
5437 }
5438
5439 NTSTATUS dcerpc_winreg_SetValue_recv(struct tevent_req *req,
5440                                      TALLOC_CTX *mem_ctx,
5441                                      WERROR *result)
5442 {
5443         struct dcerpc_winreg_SetValue_state *state = tevent_req_data(
5444                 req, struct dcerpc_winreg_SetValue_state);
5445         NTSTATUS status;
5446
5447         if (tevent_req_is_nterror(req, &status)) {
5448                 tevent_req_received(req);
5449                 return status;
5450         }
5451
5452         /* Steal possible out parameters to the callers context */
5453         talloc_steal(mem_ctx, state->out_mem_ctx);
5454
5455         /* Return result */
5456         *result = state->orig.out.result;
5457
5458         tevent_req_received(req);
5459         return NT_STATUS_OK;
5460 }
5461
5462 NTSTATUS dcerpc_winreg_SetValue(struct dcerpc_binding_handle *h,
5463                                 TALLOC_CTX *mem_ctx,
5464                                 struct policy_handle *_handle /* [in] [ref] */,
5465                                 struct winreg_String _name /* [in]  */,
5466                                 enum winreg_Type _type /* [in]  */,
5467                                 uint8_t *_data /* [in] [ref,size_is(size)] */,
5468                                 uint32_t _size /* [in]  */,
5469                                 WERROR *result)
5470 {
5471         struct winreg_SetValue r;
5472         NTSTATUS status;
5473
5474         /* In parameters */
5475         r.in.handle = _handle;
5476         r.in.name = _name;
5477         r.in.type = _type;
5478         r.in.data = _data;
5479         r.in.size = _size;
5480
5481         status = dcerpc_winreg_SetValue_r(h, mem_ctx, &r);
5482         if (!NT_STATUS_IS_OK(status)) {
5483                 return status;
5484         }
5485
5486         /* Return variables */
5487
5488         /* Return result */
5489         *result = r.out.result;
5490
5491         return NT_STATUS_OK;
5492 }
5493
5494 struct dcerpc_winreg_UnLoadKey_r_state {
5495         TALLOC_CTX *out_mem_ctx;
5496 };
5497
5498 static void dcerpc_winreg_UnLoadKey_r_done(struct tevent_req *subreq);
5499
5500 struct tevent_req *dcerpc_winreg_UnLoadKey_r_send(TALLOC_CTX *mem_ctx,
5501         struct tevent_context *ev,
5502         struct dcerpc_binding_handle *h,
5503         struct winreg_UnLoadKey *r)
5504 {
5505         struct tevent_req *req;
5506         struct dcerpc_winreg_UnLoadKey_r_state *state;
5507         struct tevent_req *subreq;
5508
5509         req = tevent_req_create(mem_ctx, &state,
5510                                 struct dcerpc_winreg_UnLoadKey_r_state);
5511         if (req == NULL) {
5512                 return NULL;
5513         }
5514
5515         state->out_mem_ctx = NULL;
5516         subreq = dcerpc_binding_handle_call_send(state, ev, h,
5517                         NULL, &ndr_table_winreg,
5518                         NDR_WINREG_UNLOADKEY, state, r);
5519         if (tevent_req_nomem(subreq, req)) {
5520                 return tevent_req_post(req, ev);
5521         }
5522         tevent_req_set_callback(subreq, dcerpc_winreg_UnLoadKey_r_done, req);
5523
5524         return req;
5525 }
5526
5527 static void dcerpc_winreg_UnLoadKey_r_done(struct tevent_req *subreq)
5528 {
5529         struct tevent_req *req =
5530                 tevent_req_callback_data(subreq,
5531                 struct tevent_req);
5532         NTSTATUS status;
5533
5534         status = dcerpc_binding_handle_call_recv(subreq);
5535         if (!NT_STATUS_IS_OK(status)) {
5536                 tevent_req_nterror(req, status);
5537                 return;
5538         }
5539
5540         tevent_req_done(req);
5541 }
5542
5543 NTSTATUS dcerpc_winreg_UnLoadKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
5544 {
5545         struct dcerpc_winreg_UnLoadKey_r_state *state =
5546                 tevent_req_data(req,
5547                 struct dcerpc_winreg_UnLoadKey_r_state);
5548         NTSTATUS status;
5549
5550         if (tevent_req_is_nterror(req, &status)) {
5551                 tevent_req_received(req);
5552                 return status;
5553         }
5554
5555         talloc_steal(mem_ctx, state->out_mem_ctx);
5556
5557         tevent_req_received(req);
5558         return NT_STATUS_OK;
5559 }
5560
5561 NTSTATUS dcerpc_winreg_UnLoadKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_UnLoadKey *r)
5562 {
5563         NTSTATUS status;
5564
5565         status = dcerpc_binding_handle_call(h,
5566                         NULL, &ndr_table_winreg,
5567                         NDR_WINREG_UNLOADKEY, mem_ctx, r);
5568
5569         return status;
5570 }
5571
5572 NTSTATUS dcerpc_winreg_UnLoadKey_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_UnLoadKey *r)
5573 {
5574         NTSTATUS status;
5575
5576         status = dcerpc_winreg_UnLoadKey_r(p->binding_handle, mem_ctx, r);
5577
5578         if (NT_STATUS_IS_RPC(status)) {
5579                 status = NT_STATUS_NET_WRITE_FAULT;
5580         }
5581
5582         return status;
5583 }
5584
5585 struct dcerpc_winreg_UnLoadKey_state {
5586         struct winreg_UnLoadKey orig;
5587         struct winreg_UnLoadKey tmp;
5588         TALLOC_CTX *out_mem_ctx;
5589 };
5590
5591 static void dcerpc_winreg_UnLoadKey_done(struct tevent_req *subreq);
5592
5593 struct tevent_req *dcerpc_winreg_UnLoadKey_send(TALLOC_CTX *mem_ctx,
5594                                                 struct tevent_context *ev,
5595                                                 struct dcerpc_binding_handle *h,
5596                                                 struct policy_handle *_handle /* [in] [ref] */,
5597                                                 struct winreg_String *_subkey /* [in] [ref] */)
5598 {
5599         struct tevent_req *req;
5600         struct dcerpc_winreg_UnLoadKey_state *state;
5601         struct tevent_req *subreq;
5602
5603         req = tevent_req_create(mem_ctx, &state,
5604                                 struct dcerpc_winreg_UnLoadKey_state);
5605         if (req == NULL) {
5606                 return NULL;
5607         }
5608         state->out_mem_ctx = NULL;
5609
5610         /* In parameters */
5611         state->orig.in.handle = _handle;
5612         state->orig.in.subkey = _subkey;
5613
5614         /* Out parameters */
5615
5616         /* Result */
5617         ZERO_STRUCT(state->orig.out.result);
5618
5619         /* make a temporary copy, that we pass to the dispatch function */
5620         state->tmp = state->orig;
5621
5622         subreq = dcerpc_winreg_UnLoadKey_r_send(state, ev, h, &state->tmp);
5623         if (tevent_req_nomem(subreq, req)) {
5624                 return tevent_req_post(req, ev);
5625         }
5626         tevent_req_set_callback(subreq, dcerpc_winreg_UnLoadKey_done, req);
5627         return req;
5628 }
5629
5630 static void dcerpc_winreg_UnLoadKey_done(struct tevent_req *subreq)
5631 {
5632         struct tevent_req *req = tevent_req_callback_data(
5633                 subreq, struct tevent_req);
5634         struct dcerpc_winreg_UnLoadKey_state *state = tevent_req_data(
5635                 req, struct dcerpc_winreg_UnLoadKey_state);
5636         NTSTATUS status;
5637         TALLOC_CTX *mem_ctx;
5638
5639         if (state->out_mem_ctx) {
5640                 mem_ctx = state->out_mem_ctx;
5641         } else {
5642                 mem_ctx = state;
5643         }
5644
5645         status = dcerpc_winreg_UnLoadKey_r_recv(subreq, mem_ctx);
5646         TALLOC_FREE(subreq);
5647         if (!NT_STATUS_IS_OK(status)) {
5648                 tevent_req_nterror(req, status);
5649                 return;
5650         }
5651
5652         /* Copy out parameters */
5653
5654         /* Copy result */
5655         state->orig.out.result = state->tmp.out.result;
5656
5657         /* Reset temporary structure */
5658         ZERO_STRUCT(state->tmp);
5659
5660         tevent_req_done(req);
5661 }
5662
5663 NTSTATUS dcerpc_winreg_UnLoadKey_recv(struct tevent_req *req,
5664                                       TALLOC_CTX *mem_ctx,
5665                                       WERROR *result)
5666 {
5667         struct dcerpc_winreg_UnLoadKey_state *state = tevent_req_data(
5668                 req, struct dcerpc_winreg_UnLoadKey_state);
5669         NTSTATUS status;
5670
5671         if (tevent_req_is_nterror(req, &status)) {
5672                 tevent_req_received(req);
5673                 return status;
5674         }
5675
5676         /* Steal possible out parameters to the callers context */
5677         talloc_steal(mem_ctx, state->out_mem_ctx);
5678
5679         /* Return result */
5680         *result = state->orig.out.result;
5681
5682         tevent_req_received(req);
5683         return NT_STATUS_OK;
5684 }
5685
5686 NTSTATUS dcerpc_winreg_UnLoadKey(struct dcerpc_binding_handle *h,
5687                                  TALLOC_CTX *mem_ctx,
5688                                  struct policy_handle *_handle /* [in] [ref] */,
5689                                  struct winreg_String *_subkey /* [in] [ref] */,
5690                                  WERROR *result)
5691 {
5692         struct winreg_UnLoadKey r;
5693         NTSTATUS status;
5694
5695         /* In parameters */
5696         r.in.handle = _handle;
5697         r.in.subkey = _subkey;
5698
5699         status = dcerpc_winreg_UnLoadKey_r(h, mem_ctx, &r);
5700         if (!NT_STATUS_IS_OK(status)) {
5701                 return status;
5702         }
5703
5704         /* Return variables */
5705
5706         /* Return result */
5707         *result = r.out.result;
5708
5709         return NT_STATUS_OK;
5710 }
5711
5712 struct dcerpc_winreg_InitiateSystemShutdown_r_state {
5713         TALLOC_CTX *out_mem_ctx;
5714 };
5715
5716 static void dcerpc_winreg_InitiateSystemShutdown_r_done(struct tevent_req *subreq);
5717
5718 struct tevent_req *dcerpc_winreg_InitiateSystemShutdown_r_send(TALLOC_CTX *mem_ctx,
5719         struct tevent_context *ev,
5720         struct dcerpc_binding_handle *h,
5721         struct winreg_InitiateSystemShutdown *r)
5722 {
5723         struct tevent_req *req;
5724         struct dcerpc_winreg_InitiateSystemShutdown_r_state *state;
5725         struct tevent_req *subreq;
5726
5727         req = tevent_req_create(mem_ctx, &state,
5728                                 struct dcerpc_winreg_InitiateSystemShutdown_r_state);
5729         if (req == NULL) {
5730                 return NULL;
5731         }
5732
5733         state->out_mem_ctx = NULL;
5734         subreq = dcerpc_binding_handle_call_send(state, ev, h,
5735                         NULL, &ndr_table_winreg,
5736                         NDR_WINREG_INITIATESYSTEMSHUTDOWN, state, r);
5737         if (tevent_req_nomem(subreq, req)) {
5738                 return tevent_req_post(req, ev);
5739         }
5740         tevent_req_set_callback(subreq, dcerpc_winreg_InitiateSystemShutdown_r_done, req);
5741
5742         return req;
5743 }
5744
5745 static void dcerpc_winreg_InitiateSystemShutdown_r_done(struct tevent_req *subreq)
5746 {
5747         struct tevent_req *req =
5748                 tevent_req_callback_data(subreq,
5749                 struct tevent_req);
5750         NTSTATUS status;
5751
5752         status = dcerpc_binding_handle_call_recv(subreq);
5753         if (!NT_STATUS_IS_OK(status)) {
5754                 tevent_req_nterror(req, status);
5755                 return;
5756         }
5757
5758         tevent_req_done(req);
5759 }
5760
5761 NTSTATUS dcerpc_winreg_InitiateSystemShutdown_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
5762 {
5763         struct dcerpc_winreg_InitiateSystemShutdown_r_state *state =
5764                 tevent_req_data(req,
5765                 struct dcerpc_winreg_InitiateSystemShutdown_r_state);
5766         NTSTATUS status;
5767
5768         if (tevent_req_is_nterror(req, &status)) {
5769                 tevent_req_received(req);
5770                 return status;
5771         }
5772
5773         talloc_steal(mem_ctx, state->out_mem_ctx);
5774
5775         tevent_req_received(req);
5776         return NT_STATUS_OK;
5777 }
5778
5779 NTSTATUS dcerpc_winreg_InitiateSystemShutdown_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_InitiateSystemShutdown *r)
5780 {
5781         NTSTATUS status;
5782
5783         status = dcerpc_binding_handle_call(h,
5784                         NULL, &ndr_table_winreg,
5785                         NDR_WINREG_INITIATESYSTEMSHUTDOWN, mem_ctx, r);
5786
5787         return status;
5788 }
5789
5790 NTSTATUS dcerpc_winreg_InitiateSystemShutdown_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_InitiateSystemShutdown *r)
5791 {
5792         NTSTATUS status;
5793
5794         status = dcerpc_winreg_InitiateSystemShutdown_r(p->binding_handle, mem_ctx, r);
5795
5796         if (NT_STATUS_IS_RPC(status)) {
5797                 status = NT_STATUS_NET_WRITE_FAULT;
5798         }
5799
5800         return status;
5801 }
5802
5803 struct dcerpc_winreg_InitiateSystemShutdown_state {
5804         struct winreg_InitiateSystemShutdown orig;
5805         struct winreg_InitiateSystemShutdown tmp;
5806         TALLOC_CTX *out_mem_ctx;
5807 };
5808
5809 static void dcerpc_winreg_InitiateSystemShutdown_done(struct tevent_req *subreq);
5810
5811 struct tevent_req *dcerpc_winreg_InitiateSystemShutdown_send(TALLOC_CTX *mem_ctx,
5812                                                              struct tevent_context *ev,
5813                                                              struct dcerpc_binding_handle *h,
5814                                                              uint16_t *_hostname /* [in] [unique] */,
5815                                                              struct lsa_StringLarge *_message /* [in] [unique] */,
5816                                                              uint32_t _timeout /* [in]  */,
5817                                                              uint8_t _force_apps /* [in]  */,
5818                                                              uint8_t _do_reboot /* [in]  */)
5819 {
5820         struct tevent_req *req;
5821         struct dcerpc_winreg_InitiateSystemShutdown_state *state;
5822         struct tevent_req *subreq;
5823
5824         req = tevent_req_create(mem_ctx, &state,
5825                                 struct dcerpc_winreg_InitiateSystemShutdown_state);
5826         if (req == NULL) {
5827                 return NULL;
5828         }
5829         state->out_mem_ctx = NULL;
5830
5831         /* In parameters */
5832         state->orig.in.hostname = _hostname;
5833         state->orig.in.message = _message;
5834         state->orig.in.timeout = _timeout;
5835         state->orig.in.force_apps = _force_apps;
5836         state->orig.in.do_reboot = _do_reboot;
5837
5838         /* Out parameters */
5839
5840         /* Result */
5841         ZERO_STRUCT(state->orig.out.result);
5842
5843         /* make a temporary copy, that we pass to the dispatch function */
5844         state->tmp = state->orig;
5845
5846         subreq = dcerpc_winreg_InitiateSystemShutdown_r_send(state, ev, h, &state->tmp);
5847         if (tevent_req_nomem(subreq, req)) {
5848                 return tevent_req_post(req, ev);
5849         }
5850         tevent_req_set_callback(subreq, dcerpc_winreg_InitiateSystemShutdown_done, req);
5851         return req;
5852 }
5853
5854 static void dcerpc_winreg_InitiateSystemShutdown_done(struct tevent_req *subreq)
5855 {
5856         struct tevent_req *req = tevent_req_callback_data(
5857                 subreq, struct tevent_req);
5858         struct dcerpc_winreg_InitiateSystemShutdown_state *state = tevent_req_data(
5859                 req, struct dcerpc_winreg_InitiateSystemShutdown_state);
5860         NTSTATUS status;
5861         TALLOC_CTX *mem_ctx;
5862
5863         if (state->out_mem_ctx) {
5864                 mem_ctx = state->out_mem_ctx;
5865         } else {
5866                 mem_ctx = state;
5867         }
5868
5869         status = dcerpc_winreg_InitiateSystemShutdown_r_recv(subreq, mem_ctx);
5870         TALLOC_FREE(subreq);
5871         if (!NT_STATUS_IS_OK(status)) {
5872                 tevent_req_nterror(req, status);
5873                 return;
5874         }
5875
5876         /* Copy out parameters */
5877
5878         /* Copy result */
5879         state->orig.out.result = state->tmp.out.result;
5880
5881         /* Reset temporary structure */
5882         ZERO_STRUCT(state->tmp);
5883
5884         tevent_req_done(req);
5885 }
5886
5887 NTSTATUS dcerpc_winreg_InitiateSystemShutdown_recv(struct tevent_req *req,
5888                                                    TALLOC_CTX *mem_ctx,
5889                                                    WERROR *result)
5890 {
5891         struct dcerpc_winreg_InitiateSystemShutdown_state *state = tevent_req_data(
5892                 req, struct dcerpc_winreg_InitiateSystemShutdown_state);
5893         NTSTATUS status;
5894
5895         if (tevent_req_is_nterror(req, &status)) {
5896                 tevent_req_received(req);
5897                 return status;
5898         }
5899
5900         /* Steal possible out parameters to the callers context */
5901         talloc_steal(mem_ctx, state->out_mem_ctx);
5902
5903         /* Return result */
5904         *result = state->orig.out.result;
5905
5906         tevent_req_received(req);
5907         return NT_STATUS_OK;
5908 }
5909
5910 NTSTATUS dcerpc_winreg_InitiateSystemShutdown(struct dcerpc_binding_handle *h,
5911                                               TALLOC_CTX *mem_ctx,
5912                                               uint16_t *_hostname /* [in] [unique] */,
5913                                               struct lsa_StringLarge *_message /* [in] [unique] */,
5914                                               uint32_t _timeout /* [in]  */,
5915                                               uint8_t _force_apps /* [in]  */,
5916                                               uint8_t _do_reboot /* [in]  */,
5917                                               WERROR *result)
5918 {
5919         struct winreg_InitiateSystemShutdown r;
5920         NTSTATUS status;
5921
5922         /* In parameters */
5923         r.in.hostname = _hostname;
5924         r.in.message = _message;
5925         r.in.timeout = _timeout;
5926         r.in.force_apps = _force_apps;
5927         r.in.do_reboot = _do_reboot;
5928
5929         status = dcerpc_winreg_InitiateSystemShutdown_r(h, mem_ctx, &r);
5930         if (!NT_STATUS_IS_OK(status)) {
5931                 return status;
5932         }
5933
5934         /* Return variables */
5935
5936         /* Return result */
5937         *result = r.out.result;
5938
5939         return NT_STATUS_OK;
5940 }
5941
5942 struct dcerpc_winreg_AbortSystemShutdown_r_state {
5943         TALLOC_CTX *out_mem_ctx;
5944 };
5945
5946 static void dcerpc_winreg_AbortSystemShutdown_r_done(struct tevent_req *subreq);
5947
5948 struct tevent_req *dcerpc_winreg_AbortSystemShutdown_r_send(TALLOC_CTX *mem_ctx,
5949         struct tevent_context *ev,
5950         struct dcerpc_binding_handle *h,
5951         struct winreg_AbortSystemShutdown *r)
5952 {
5953         struct tevent_req *req;
5954         struct dcerpc_winreg_AbortSystemShutdown_r_state *state;
5955         struct tevent_req *subreq;
5956
5957         req = tevent_req_create(mem_ctx, &state,
5958                                 struct dcerpc_winreg_AbortSystemShutdown_r_state);
5959         if (req == NULL) {
5960                 return NULL;
5961         }
5962
5963         state->out_mem_ctx = NULL;
5964         subreq = dcerpc_binding_handle_call_send(state, ev, h,
5965                         NULL, &ndr_table_winreg,
5966                         NDR_WINREG_ABORTSYSTEMSHUTDOWN, state, r);
5967         if (tevent_req_nomem(subreq, req)) {
5968                 return tevent_req_post(req, ev);
5969         }
5970         tevent_req_set_callback(subreq, dcerpc_winreg_AbortSystemShutdown_r_done, req);
5971
5972         return req;
5973 }
5974
5975 static void dcerpc_winreg_AbortSystemShutdown_r_done(struct tevent_req *subreq)
5976 {
5977         struct tevent_req *req =
5978                 tevent_req_callback_data(subreq,
5979                 struct tevent_req);
5980         NTSTATUS status;
5981
5982         status = dcerpc_binding_handle_call_recv(subreq);
5983         if (!NT_STATUS_IS_OK(status)) {
5984                 tevent_req_nterror(req, status);
5985                 return;
5986         }
5987
5988         tevent_req_done(req);
5989 }
5990
5991 NTSTATUS dcerpc_winreg_AbortSystemShutdown_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
5992 {
5993         struct dcerpc_winreg_AbortSystemShutdown_r_state *state =
5994                 tevent_req_data(req,
5995                 struct dcerpc_winreg_AbortSystemShutdown_r_state);
5996         NTSTATUS status;
5997
5998         if (tevent_req_is_nterror(req, &status)) {
5999                 tevent_req_received(req);
6000                 return status;
6001         }
6002
6003         talloc_steal(mem_ctx, state->out_mem_ctx);
6004
6005         tevent_req_received(req);
6006         return NT_STATUS_OK;
6007 }
6008
6009 NTSTATUS dcerpc_winreg_AbortSystemShutdown_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_AbortSystemShutdown *r)
6010 {
6011         NTSTATUS status;
6012
6013         status = dcerpc_binding_handle_call(h,
6014                         NULL, &ndr_table_winreg,
6015                         NDR_WINREG_ABORTSYSTEMSHUTDOWN, mem_ctx, r);
6016
6017         return status;
6018 }
6019
6020 NTSTATUS dcerpc_winreg_AbortSystemShutdown_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_AbortSystemShutdown *r)
6021 {
6022         NTSTATUS status;
6023
6024         status = dcerpc_winreg_AbortSystemShutdown_r(p->binding_handle, mem_ctx, r);
6025
6026         if (NT_STATUS_IS_RPC(status)) {
6027                 status = NT_STATUS_NET_WRITE_FAULT;
6028         }
6029
6030         return status;
6031 }
6032
6033 struct dcerpc_winreg_AbortSystemShutdown_state {
6034         struct winreg_AbortSystemShutdown orig;
6035         struct winreg_AbortSystemShutdown tmp;
6036         TALLOC_CTX *out_mem_ctx;
6037 };
6038
6039 static void dcerpc_winreg_AbortSystemShutdown_done(struct tevent_req *subreq);
6040
6041 struct tevent_req *dcerpc_winreg_AbortSystemShutdown_send(TALLOC_CTX *mem_ctx,
6042                                                           struct tevent_context *ev,
6043                                                           struct dcerpc_binding_handle *h,
6044                                                           uint16_t *_server /* [in] [unique] */)
6045 {
6046         struct tevent_req *req;
6047         struct dcerpc_winreg_AbortSystemShutdown_state *state;
6048         struct tevent_req *subreq;
6049
6050         req = tevent_req_create(mem_ctx, &state,
6051                                 struct dcerpc_winreg_AbortSystemShutdown_state);
6052         if (req == NULL) {
6053                 return NULL;
6054         }
6055         state->out_mem_ctx = NULL;
6056
6057         /* In parameters */
6058         state->orig.in.server = _server;
6059
6060         /* Out parameters */
6061
6062         /* Result */
6063         ZERO_STRUCT(state->orig.out.result);
6064
6065         /* make a temporary copy, that we pass to the dispatch function */
6066         state->tmp = state->orig;
6067
6068         subreq = dcerpc_winreg_AbortSystemShutdown_r_send(state, ev, h, &state->tmp);
6069         if (tevent_req_nomem(subreq, req)) {
6070                 return tevent_req_post(req, ev);
6071         }
6072         tevent_req_set_callback(subreq, dcerpc_winreg_AbortSystemShutdown_done, req);
6073         return req;
6074 }
6075
6076 static void dcerpc_winreg_AbortSystemShutdown_done(struct tevent_req *subreq)
6077 {
6078         struct tevent_req *req = tevent_req_callback_data(
6079                 subreq, struct tevent_req);
6080         struct dcerpc_winreg_AbortSystemShutdown_state *state = tevent_req_data(
6081                 req, struct dcerpc_winreg_AbortSystemShutdown_state);
6082         NTSTATUS status;
6083         TALLOC_CTX *mem_ctx;
6084
6085         if (state->out_mem_ctx) {
6086                 mem_ctx = state->out_mem_ctx;
6087         } else {
6088                 mem_ctx = state;
6089         }
6090
6091         status = dcerpc_winreg_AbortSystemShutdown_r_recv(subreq, mem_ctx);
6092         TALLOC_FREE(subreq);
6093         if (!NT_STATUS_IS_OK(status)) {
6094                 tevent_req_nterror(req, status);
6095                 return;
6096         }
6097
6098         /* Copy out parameters */
6099
6100         /* Copy result */
6101         state->orig.out.result = state->tmp.out.result;
6102
6103         /* Reset temporary structure */
6104         ZERO_STRUCT(state->tmp);
6105
6106         tevent_req_done(req);
6107 }
6108
6109 NTSTATUS dcerpc_winreg_AbortSystemShutdown_recv(struct tevent_req *req,
6110                                                 TALLOC_CTX *mem_ctx,
6111                                                 WERROR *result)
6112 {
6113         struct dcerpc_winreg_AbortSystemShutdown_state *state = tevent_req_data(
6114                 req, struct dcerpc_winreg_AbortSystemShutdown_state);
6115         NTSTATUS status;
6116
6117         if (tevent_req_is_nterror(req, &status)) {
6118                 tevent_req_received(req);
6119                 return status;
6120         }
6121
6122         /* Steal possible out parameters to the callers context */
6123         talloc_steal(mem_ctx, state->out_mem_ctx);
6124
6125         /* Return result */
6126         *result = state->orig.out.result;
6127
6128         tevent_req_received(req);
6129         return NT_STATUS_OK;
6130 }
6131
6132 NTSTATUS dcerpc_winreg_AbortSystemShutdown(struct dcerpc_binding_handle *h,
6133                                            TALLOC_CTX *mem_ctx,
6134                                            uint16_t *_server /* [in] [unique] */,
6135                                            WERROR *result)
6136 {
6137         struct winreg_AbortSystemShutdown r;
6138         NTSTATUS status;
6139
6140         /* In parameters */
6141         r.in.server = _server;
6142
6143         status = dcerpc_winreg_AbortSystemShutdown_r(h, mem_ctx, &r);
6144         if (!NT_STATUS_IS_OK(status)) {
6145                 return status;
6146         }
6147
6148         /* Return variables */
6149
6150         /* Return result */
6151         *result = r.out.result;
6152
6153         return NT_STATUS_OK;
6154 }
6155
6156 struct dcerpc_winreg_GetVersion_r_state {
6157         TALLOC_CTX *out_mem_ctx;
6158 };
6159
6160 static void dcerpc_winreg_GetVersion_r_done(struct tevent_req *subreq);
6161
6162 struct tevent_req *dcerpc_winreg_GetVersion_r_send(TALLOC_CTX *mem_ctx,
6163         struct tevent_context *ev,
6164         struct dcerpc_binding_handle *h,
6165         struct winreg_GetVersion *r)
6166 {
6167         struct tevent_req *req;
6168         struct dcerpc_winreg_GetVersion_r_state *state;
6169         struct tevent_req *subreq;
6170
6171         req = tevent_req_create(mem_ctx, &state,
6172                                 struct dcerpc_winreg_GetVersion_r_state);
6173         if (req == NULL) {
6174                 return NULL;
6175         }
6176
6177         state->out_mem_ctx = talloc_new(state);
6178         if (tevent_req_nomem(state->out_mem_ctx, req)) {
6179                 return tevent_req_post(req, ev);
6180         }
6181
6182         subreq = dcerpc_binding_handle_call_send(state, ev, h,
6183                         NULL, &ndr_table_winreg,
6184                         NDR_WINREG_GETVERSION, state->out_mem_ctx, r);
6185         if (tevent_req_nomem(subreq, req)) {
6186                 return tevent_req_post(req, ev);
6187         }
6188         tevent_req_set_callback(subreq, dcerpc_winreg_GetVersion_r_done, req);
6189
6190         return req;
6191 }
6192
6193 static void dcerpc_winreg_GetVersion_r_done(struct tevent_req *subreq)
6194 {
6195         struct tevent_req *req =
6196                 tevent_req_callback_data(subreq,
6197                 struct tevent_req);
6198         NTSTATUS status;
6199
6200         status = dcerpc_binding_handle_call_recv(subreq);
6201         if (!NT_STATUS_IS_OK(status)) {
6202                 tevent_req_nterror(req, status);
6203                 return;
6204         }
6205
6206         tevent_req_done(req);
6207 }
6208
6209 NTSTATUS dcerpc_winreg_GetVersion_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
6210 {
6211         struct dcerpc_winreg_GetVersion_r_state *state =
6212                 tevent_req_data(req,
6213                 struct dcerpc_winreg_GetVersion_r_state);
6214         NTSTATUS status;
6215
6216         if (tevent_req_is_nterror(req, &status)) {
6217                 tevent_req_received(req);
6218                 return status;
6219         }
6220
6221         talloc_steal(mem_ctx, state->out_mem_ctx);
6222
6223         tevent_req_received(req);
6224         return NT_STATUS_OK;
6225 }
6226
6227 NTSTATUS dcerpc_winreg_GetVersion_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_GetVersion *r)
6228 {
6229         NTSTATUS status;
6230
6231         status = dcerpc_binding_handle_call(h,
6232                         NULL, &ndr_table_winreg,
6233                         NDR_WINREG_GETVERSION, mem_ctx, r);
6234
6235         return status;
6236 }
6237
6238 NTSTATUS dcerpc_winreg_GetVersion_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_GetVersion *r)
6239 {
6240         NTSTATUS status;
6241
6242         status = dcerpc_winreg_GetVersion_r(p->binding_handle, mem_ctx, r);
6243
6244         if (NT_STATUS_IS_RPC(status)) {
6245                 status = NT_STATUS_NET_WRITE_FAULT;
6246         }
6247
6248         return status;
6249 }
6250
6251 struct dcerpc_winreg_GetVersion_state {
6252         struct winreg_GetVersion orig;
6253         struct winreg_GetVersion tmp;
6254         TALLOC_CTX *out_mem_ctx;
6255 };
6256
6257 static void dcerpc_winreg_GetVersion_done(struct tevent_req *subreq);
6258
6259 struct tevent_req *dcerpc_winreg_GetVersion_send(TALLOC_CTX *mem_ctx,
6260                                                  struct tevent_context *ev,
6261                                                  struct dcerpc_binding_handle *h,
6262                                                  struct policy_handle *_handle /* [in] [ref] */,
6263                                                  uint32_t *_version /* [out] [ref] */)
6264 {
6265         struct tevent_req *req;
6266         struct dcerpc_winreg_GetVersion_state *state;
6267         struct tevent_req *subreq;
6268
6269         req = tevent_req_create(mem_ctx, &state,
6270                                 struct dcerpc_winreg_GetVersion_state);
6271         if (req == NULL) {
6272                 return NULL;
6273         }
6274         state->out_mem_ctx = NULL;
6275
6276         /* In parameters */
6277         state->orig.in.handle = _handle;
6278
6279         /* Out parameters */
6280         state->orig.out.version = _version;
6281
6282         /* Result */
6283         ZERO_STRUCT(state->orig.out.result);
6284
6285         state->out_mem_ctx = talloc_named_const(state, 0,
6286                              "dcerpc_winreg_GetVersion_out_memory");
6287         if (tevent_req_nomem(state->out_mem_ctx, req)) {
6288                 return tevent_req_post(req, ev);
6289         }
6290
6291         /* make a temporary copy, that we pass to the dispatch function */
6292         state->tmp = state->orig;
6293
6294         subreq = dcerpc_winreg_GetVersion_r_send(state, ev, h, &state->tmp);
6295         if (tevent_req_nomem(subreq, req)) {
6296                 return tevent_req_post(req, ev);
6297         }
6298         tevent_req_set_callback(subreq, dcerpc_winreg_GetVersion_done, req);
6299         return req;
6300 }
6301
6302 static void dcerpc_winreg_GetVersion_done(struct tevent_req *subreq)
6303 {
6304         struct tevent_req *req = tevent_req_callback_data(
6305                 subreq, struct tevent_req);
6306         struct dcerpc_winreg_GetVersion_state *state = tevent_req_data(
6307                 req, struct dcerpc_winreg_GetVersion_state);
6308         NTSTATUS status;
6309         TALLOC_CTX *mem_ctx;
6310
6311         if (state->out_mem_ctx) {
6312                 mem_ctx = state->out_mem_ctx;
6313         } else {
6314                 mem_ctx = state;
6315         }
6316
6317         status = dcerpc_winreg_GetVersion_r_recv(subreq, mem_ctx);
6318         TALLOC_FREE(subreq);
6319         if (!NT_STATUS_IS_OK(status)) {
6320                 tevent_req_nterror(req, status);
6321                 return;
6322         }
6323
6324         /* Copy out parameters */
6325         *state->orig.out.version = *state->tmp.out.version;
6326
6327         /* Copy result */
6328         state->orig.out.result = state->tmp.out.result;
6329
6330         /* Reset temporary structure */
6331         ZERO_STRUCT(state->tmp);
6332
6333         tevent_req_done(req);
6334 }
6335
6336 NTSTATUS dcerpc_winreg_GetVersion_recv(struct tevent_req *req,
6337                                        TALLOC_CTX *mem_ctx,
6338                                        WERROR *result)
6339 {
6340         struct dcerpc_winreg_GetVersion_state *state = tevent_req_data(
6341                 req, struct dcerpc_winreg_GetVersion_state);
6342         NTSTATUS status;
6343
6344         if (tevent_req_is_nterror(req, &status)) {
6345                 tevent_req_received(req);
6346                 return status;
6347         }
6348
6349         /* Steal possible out parameters to the callers context */
6350         talloc_steal(mem_ctx, state->out_mem_ctx);
6351
6352         /* Return result */
6353         *result = state->orig.out.result;
6354
6355         tevent_req_received(req);
6356         return NT_STATUS_OK;
6357 }
6358
6359 NTSTATUS dcerpc_winreg_GetVersion(struct dcerpc_binding_handle *h,
6360                                   TALLOC_CTX *mem_ctx,
6361                                   struct policy_handle *_handle /* [in] [ref] */,
6362                                   uint32_t *_version /* [out] [ref] */,
6363                                   WERROR *result)
6364 {
6365         struct winreg_GetVersion r;
6366         NTSTATUS status;
6367
6368         /* In parameters */
6369         r.in.handle = _handle;
6370
6371         status = dcerpc_winreg_GetVersion_r(h, mem_ctx, &r);
6372         if (!NT_STATUS_IS_OK(status)) {
6373                 return status;
6374         }
6375
6376         /* Return variables */
6377         *_version = *r.out.version;
6378
6379         /* Return result */
6380         *result = r.out.result;
6381
6382         return NT_STATUS_OK;
6383 }
6384
6385 struct dcerpc_winreg_OpenHKCC_r_state {
6386         TALLOC_CTX *out_mem_ctx;
6387 };
6388
6389 static void dcerpc_winreg_OpenHKCC_r_done(struct tevent_req *subreq);
6390
6391 struct tevent_req *dcerpc_winreg_OpenHKCC_r_send(TALLOC_CTX *mem_ctx,
6392         struct tevent_context *ev,
6393         struct dcerpc_binding_handle *h,
6394         struct winreg_OpenHKCC *r)
6395 {
6396         struct tevent_req *req;
6397         struct dcerpc_winreg_OpenHKCC_r_state *state;
6398         struct tevent_req *subreq;
6399
6400         req = tevent_req_create(mem_ctx, &state,
6401                                 struct dcerpc_winreg_OpenHKCC_r_state);
6402         if (req == NULL) {
6403                 return NULL;
6404         }
6405
6406         state->out_mem_ctx = talloc_new(state);
6407         if (tevent_req_nomem(state->out_mem_ctx, req)) {
6408                 return tevent_req_post(req, ev);
6409         }
6410
6411         subreq = dcerpc_binding_handle_call_send(state, ev, h,
6412                         NULL, &ndr_table_winreg,
6413                         NDR_WINREG_OPENHKCC, state->out_mem_ctx, r);
6414         if (tevent_req_nomem(subreq, req)) {
6415                 return tevent_req_post(req, ev);
6416         }
6417         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKCC_r_done, req);
6418
6419         return req;
6420 }
6421
6422 static void dcerpc_winreg_OpenHKCC_r_done(struct tevent_req *subreq)
6423 {
6424         struct tevent_req *req =
6425                 tevent_req_callback_data(subreq,
6426                 struct tevent_req);
6427         NTSTATUS status;
6428
6429         status = dcerpc_binding_handle_call_recv(subreq);
6430         if (!NT_STATUS_IS_OK(status)) {
6431                 tevent_req_nterror(req, status);
6432                 return;
6433         }
6434
6435         tevent_req_done(req);
6436 }
6437
6438 NTSTATUS dcerpc_winreg_OpenHKCC_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
6439 {
6440         struct dcerpc_winreg_OpenHKCC_r_state *state =
6441                 tevent_req_data(req,
6442                 struct dcerpc_winreg_OpenHKCC_r_state);
6443         NTSTATUS status;
6444
6445         if (tevent_req_is_nterror(req, &status)) {
6446                 tevent_req_received(req);
6447                 return status;
6448         }
6449
6450         talloc_steal(mem_ctx, state->out_mem_ctx);
6451
6452         tevent_req_received(req);
6453         return NT_STATUS_OK;
6454 }
6455
6456 NTSTATUS dcerpc_winreg_OpenHKCC_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_OpenHKCC *r)
6457 {
6458         NTSTATUS status;
6459
6460         status = dcerpc_binding_handle_call(h,
6461                         NULL, &ndr_table_winreg,
6462                         NDR_WINREG_OPENHKCC, mem_ctx, r);
6463
6464         return status;
6465 }
6466
6467 NTSTATUS dcerpc_winreg_OpenHKCC_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_OpenHKCC *r)
6468 {
6469         NTSTATUS status;
6470
6471         status = dcerpc_winreg_OpenHKCC_r(p->binding_handle, mem_ctx, r);
6472
6473         if (NT_STATUS_IS_RPC(status)) {
6474                 status = NT_STATUS_NET_WRITE_FAULT;
6475         }
6476
6477         return status;
6478 }
6479
6480 struct dcerpc_winreg_OpenHKCC_state {
6481         struct winreg_OpenHKCC orig;
6482         struct winreg_OpenHKCC tmp;
6483         TALLOC_CTX *out_mem_ctx;
6484 };
6485
6486 static void dcerpc_winreg_OpenHKCC_done(struct tevent_req *subreq);
6487
6488 struct tevent_req *dcerpc_winreg_OpenHKCC_send(TALLOC_CTX *mem_ctx,
6489                                                struct tevent_context *ev,
6490                                                struct dcerpc_binding_handle *h,
6491                                                uint16_t *_system_name /* [in] [unique] */,
6492                                                uint32_t _access_mask /* [in]  */,
6493                                                struct policy_handle *_handle /* [out] [ref] */)
6494 {
6495         struct tevent_req *req;
6496         struct dcerpc_winreg_OpenHKCC_state *state;
6497         struct tevent_req *subreq;
6498
6499         req = tevent_req_create(mem_ctx, &state,
6500                                 struct dcerpc_winreg_OpenHKCC_state);
6501         if (req == NULL) {
6502                 return NULL;
6503         }
6504         state->out_mem_ctx = NULL;
6505
6506         /* In parameters */
6507         state->orig.in.system_name = _system_name;
6508         state->orig.in.access_mask = _access_mask;
6509
6510         /* Out parameters */
6511         state->orig.out.handle = _handle;
6512
6513         /* Result */
6514         ZERO_STRUCT(state->orig.out.result);
6515
6516         state->out_mem_ctx = talloc_named_const(state, 0,
6517                              "dcerpc_winreg_OpenHKCC_out_memory");
6518         if (tevent_req_nomem(state->out_mem_ctx, req)) {
6519                 return tevent_req_post(req, ev);
6520         }
6521
6522         /* make a temporary copy, that we pass to the dispatch function */
6523         state->tmp = state->orig;
6524
6525         subreq = dcerpc_winreg_OpenHKCC_r_send(state, ev, h, &state->tmp);
6526         if (tevent_req_nomem(subreq, req)) {
6527                 return tevent_req_post(req, ev);
6528         }
6529         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKCC_done, req);
6530         return req;
6531 }
6532
6533 static void dcerpc_winreg_OpenHKCC_done(struct tevent_req *subreq)
6534 {
6535         struct tevent_req *req = tevent_req_callback_data(
6536                 subreq, struct tevent_req);
6537         struct dcerpc_winreg_OpenHKCC_state *state = tevent_req_data(
6538                 req, struct dcerpc_winreg_OpenHKCC_state);
6539         NTSTATUS status;
6540         TALLOC_CTX *mem_ctx;
6541
6542         if (state->out_mem_ctx) {
6543                 mem_ctx = state->out_mem_ctx;
6544         } else {
6545                 mem_ctx = state;
6546         }
6547
6548         status = dcerpc_winreg_OpenHKCC_r_recv(subreq, mem_ctx);
6549         TALLOC_FREE(subreq);
6550         if (!NT_STATUS_IS_OK(status)) {
6551                 tevent_req_nterror(req, status);
6552                 return;
6553         }
6554
6555         /* Copy out parameters */
6556         *state->orig.out.handle = *state->tmp.out.handle;
6557
6558         /* Copy result */
6559         state->orig.out.result = state->tmp.out.result;
6560
6561         /* Reset temporary structure */
6562         ZERO_STRUCT(state->tmp);
6563
6564         tevent_req_done(req);
6565 }
6566
6567 NTSTATUS dcerpc_winreg_OpenHKCC_recv(struct tevent_req *req,
6568                                      TALLOC_CTX *mem_ctx,
6569                                      WERROR *result)
6570 {
6571         struct dcerpc_winreg_OpenHKCC_state *state = tevent_req_data(
6572                 req, struct dcerpc_winreg_OpenHKCC_state);
6573         NTSTATUS status;
6574
6575         if (tevent_req_is_nterror(req, &status)) {
6576                 tevent_req_received(req);
6577                 return status;
6578         }
6579
6580         /* Steal possible out parameters to the callers context */
6581         talloc_steal(mem_ctx, state->out_mem_ctx);
6582
6583         /* Return result */
6584         *result = state->orig.out.result;
6585
6586         tevent_req_received(req);
6587         return NT_STATUS_OK;
6588 }
6589
6590 NTSTATUS dcerpc_winreg_OpenHKCC(struct dcerpc_binding_handle *h,
6591                                 TALLOC_CTX *mem_ctx,
6592                                 uint16_t *_system_name /* [in] [unique] */,
6593                                 uint32_t _access_mask /* [in]  */,
6594                                 struct policy_handle *_handle /* [out] [ref] */,
6595                                 WERROR *result)
6596 {
6597         struct winreg_OpenHKCC r;
6598         NTSTATUS status;
6599
6600         /* In parameters */
6601         r.in.system_name = _system_name;
6602         r.in.access_mask = _access_mask;
6603
6604         status = dcerpc_winreg_OpenHKCC_r(h, mem_ctx, &r);
6605         if (!NT_STATUS_IS_OK(status)) {
6606                 return status;
6607         }
6608
6609         /* Return variables */
6610         *_handle = *r.out.handle;
6611
6612         /* Return result */
6613         *result = r.out.result;
6614
6615         return NT_STATUS_OK;
6616 }
6617
6618 struct dcerpc_winreg_OpenHKDD_r_state {
6619         TALLOC_CTX *out_mem_ctx;
6620 };
6621
6622 static void dcerpc_winreg_OpenHKDD_r_done(struct tevent_req *subreq);
6623
6624 struct tevent_req *dcerpc_winreg_OpenHKDD_r_send(TALLOC_CTX *mem_ctx,
6625         struct tevent_context *ev,
6626         struct dcerpc_binding_handle *h,
6627         struct winreg_OpenHKDD *r)
6628 {
6629         struct tevent_req *req;
6630         struct dcerpc_winreg_OpenHKDD_r_state *state;
6631         struct tevent_req *subreq;
6632
6633         req = tevent_req_create(mem_ctx, &state,
6634                                 struct dcerpc_winreg_OpenHKDD_r_state);
6635         if (req == NULL) {
6636                 return NULL;
6637         }
6638
6639         state->out_mem_ctx = talloc_new(state);
6640         if (tevent_req_nomem(state->out_mem_ctx, req)) {
6641                 return tevent_req_post(req, ev);
6642         }
6643
6644         subreq = dcerpc_binding_handle_call_send(state, ev, h,
6645                         NULL, &ndr_table_winreg,
6646                         NDR_WINREG_OPENHKDD, state->out_mem_ctx, r);
6647         if (tevent_req_nomem(subreq, req)) {
6648                 return tevent_req_post(req, ev);
6649         }
6650         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKDD_r_done, req);
6651
6652         return req;
6653 }
6654
6655 static void dcerpc_winreg_OpenHKDD_r_done(struct tevent_req *subreq)
6656 {
6657         struct tevent_req *req =
6658                 tevent_req_callback_data(subreq,
6659                 struct tevent_req);
6660         NTSTATUS status;
6661
6662         status = dcerpc_binding_handle_call_recv(subreq);
6663         if (!NT_STATUS_IS_OK(status)) {
6664                 tevent_req_nterror(req, status);
6665                 return;
6666         }
6667
6668         tevent_req_done(req);
6669 }
6670
6671 NTSTATUS dcerpc_winreg_OpenHKDD_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
6672 {
6673         struct dcerpc_winreg_OpenHKDD_r_state *state =
6674                 tevent_req_data(req,
6675                 struct dcerpc_winreg_OpenHKDD_r_state);
6676         NTSTATUS status;
6677
6678         if (tevent_req_is_nterror(req, &status)) {
6679                 tevent_req_received(req);
6680                 return status;
6681         }
6682
6683         talloc_steal(mem_ctx, state->out_mem_ctx);
6684
6685         tevent_req_received(req);
6686         return NT_STATUS_OK;
6687 }
6688
6689 NTSTATUS dcerpc_winreg_OpenHKDD_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_OpenHKDD *r)
6690 {
6691         NTSTATUS status;
6692
6693         status = dcerpc_binding_handle_call(h,
6694                         NULL, &ndr_table_winreg,
6695                         NDR_WINREG_OPENHKDD, mem_ctx, r);
6696
6697         return status;
6698 }
6699
6700 NTSTATUS dcerpc_winreg_OpenHKDD_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_OpenHKDD *r)
6701 {
6702         NTSTATUS status;
6703
6704         status = dcerpc_winreg_OpenHKDD_r(p->binding_handle, mem_ctx, r);
6705
6706         if (NT_STATUS_IS_RPC(status)) {
6707                 status = NT_STATUS_NET_WRITE_FAULT;
6708         }
6709
6710         return status;
6711 }
6712
6713 struct dcerpc_winreg_OpenHKDD_state {
6714         struct winreg_OpenHKDD orig;
6715         struct winreg_OpenHKDD tmp;
6716         TALLOC_CTX *out_mem_ctx;
6717 };
6718
6719 static void dcerpc_winreg_OpenHKDD_done(struct tevent_req *subreq);
6720
6721 struct tevent_req *dcerpc_winreg_OpenHKDD_send(TALLOC_CTX *mem_ctx,
6722                                                struct tevent_context *ev,
6723                                                struct dcerpc_binding_handle *h,
6724                                                uint16_t *_system_name /* [in] [unique] */,
6725                                                uint32_t _access_mask /* [in]  */,
6726                                                struct policy_handle *_handle /* [out] [ref] */)
6727 {
6728         struct tevent_req *req;
6729         struct dcerpc_winreg_OpenHKDD_state *state;
6730         struct tevent_req *subreq;
6731
6732         req = tevent_req_create(mem_ctx, &state,
6733                                 struct dcerpc_winreg_OpenHKDD_state);
6734         if (req == NULL) {
6735                 return NULL;
6736         }
6737         state->out_mem_ctx = NULL;
6738
6739         /* In parameters */
6740         state->orig.in.system_name = _system_name;
6741         state->orig.in.access_mask = _access_mask;
6742
6743         /* Out parameters */
6744         state->orig.out.handle = _handle;
6745
6746         /* Result */
6747         ZERO_STRUCT(state->orig.out.result);
6748
6749         state->out_mem_ctx = talloc_named_const(state, 0,
6750                              "dcerpc_winreg_OpenHKDD_out_memory");
6751         if (tevent_req_nomem(state->out_mem_ctx, req)) {
6752                 return tevent_req_post(req, ev);
6753         }
6754
6755         /* make a temporary copy, that we pass to the dispatch function */
6756         state->tmp = state->orig;
6757
6758         subreq = dcerpc_winreg_OpenHKDD_r_send(state, ev, h, &state->tmp);
6759         if (tevent_req_nomem(subreq, req)) {
6760                 return tevent_req_post(req, ev);
6761         }
6762         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKDD_done, req);
6763         return req;
6764 }
6765
6766 static void dcerpc_winreg_OpenHKDD_done(struct tevent_req *subreq)
6767 {
6768         struct tevent_req *req = tevent_req_callback_data(
6769                 subreq, struct tevent_req);
6770         struct dcerpc_winreg_OpenHKDD_state *state = tevent_req_data(
6771                 req, struct dcerpc_winreg_OpenHKDD_state);
6772         NTSTATUS status;
6773         TALLOC_CTX *mem_ctx;
6774
6775         if (state->out_mem_ctx) {
6776                 mem_ctx = state->out_mem_ctx;
6777         } else {
6778                 mem_ctx = state;
6779         }
6780
6781         status = dcerpc_winreg_OpenHKDD_r_recv(subreq, mem_ctx);
6782         TALLOC_FREE(subreq);
6783         if (!NT_STATUS_IS_OK(status)) {
6784                 tevent_req_nterror(req, status);
6785                 return;
6786         }
6787
6788         /* Copy out parameters */
6789         *state->orig.out.handle = *state->tmp.out.handle;
6790
6791         /* Copy result */
6792         state->orig.out.result = state->tmp.out.result;
6793
6794         /* Reset temporary structure */
6795         ZERO_STRUCT(state->tmp);
6796
6797         tevent_req_done(req);
6798 }
6799
6800 NTSTATUS dcerpc_winreg_OpenHKDD_recv(struct tevent_req *req,
6801                                      TALLOC_CTX *mem_ctx,
6802                                      WERROR *result)
6803 {
6804         struct dcerpc_winreg_OpenHKDD_state *state = tevent_req_data(
6805                 req, struct dcerpc_winreg_OpenHKDD_state);
6806         NTSTATUS status;
6807
6808         if (tevent_req_is_nterror(req, &status)) {
6809                 tevent_req_received(req);
6810                 return status;
6811         }
6812
6813         /* Steal possible out parameters to the callers context */
6814         talloc_steal(mem_ctx, state->out_mem_ctx);
6815
6816         /* Return result */
6817         *result = state->orig.out.result;
6818
6819         tevent_req_received(req);
6820         return NT_STATUS_OK;
6821 }
6822
6823 NTSTATUS dcerpc_winreg_OpenHKDD(struct dcerpc_binding_handle *h,
6824                                 TALLOC_CTX *mem_ctx,
6825                                 uint16_t *_system_name /* [in] [unique] */,
6826                                 uint32_t _access_mask /* [in]  */,
6827                                 struct policy_handle *_handle /* [out] [ref] */,
6828                                 WERROR *result)
6829 {
6830         struct winreg_OpenHKDD r;
6831         NTSTATUS status;
6832
6833         /* In parameters */
6834         r.in.system_name = _system_name;
6835         r.in.access_mask = _access_mask;
6836
6837         status = dcerpc_winreg_OpenHKDD_r(h, mem_ctx, &r);
6838         if (!NT_STATUS_IS_OK(status)) {
6839                 return status;
6840         }
6841
6842         /* Return variables */
6843         *_handle = *r.out.handle;
6844
6845         /* Return result */
6846         *result = r.out.result;
6847
6848         return NT_STATUS_OK;
6849 }
6850
6851 struct dcerpc_winreg_QueryMultipleValues_r_state {
6852         TALLOC_CTX *out_mem_ctx;
6853 };
6854
6855 static void dcerpc_winreg_QueryMultipleValues_r_done(struct tevent_req *subreq);
6856
6857 struct tevent_req *dcerpc_winreg_QueryMultipleValues_r_send(TALLOC_CTX *mem_ctx,
6858         struct tevent_context *ev,
6859         struct dcerpc_binding_handle *h,
6860         struct winreg_QueryMultipleValues *r)
6861 {
6862         struct tevent_req *req;
6863         struct dcerpc_winreg_QueryMultipleValues_r_state *state;
6864         struct tevent_req *subreq;
6865
6866         req = tevent_req_create(mem_ctx, &state,
6867                                 struct dcerpc_winreg_QueryMultipleValues_r_state);
6868         if (req == NULL) {
6869                 return NULL;
6870         }
6871
6872         state->out_mem_ctx = talloc_new(state);
6873         if (tevent_req_nomem(state->out_mem_ctx, req)) {
6874                 return tevent_req_post(req, ev);
6875         }
6876
6877         subreq = dcerpc_binding_handle_call_send(state, ev, h,
6878                         NULL, &ndr_table_winreg,
6879                         NDR_WINREG_QUERYMULTIPLEVALUES, state->out_mem_ctx, r);
6880         if (tevent_req_nomem(subreq, req)) {
6881                 return tevent_req_post(req, ev);
6882         }
6883         tevent_req_set_callback(subreq, dcerpc_winreg_QueryMultipleValues_r_done, req);
6884
6885         return req;
6886 }
6887
6888 static void dcerpc_winreg_QueryMultipleValues_r_done(struct tevent_req *subreq)
6889 {
6890         struct tevent_req *req =
6891                 tevent_req_callback_data(subreq,
6892                 struct tevent_req);
6893         NTSTATUS status;
6894
6895         status = dcerpc_binding_handle_call_recv(subreq);
6896         if (!NT_STATUS_IS_OK(status)) {
6897                 tevent_req_nterror(req, status);
6898                 return;
6899         }
6900
6901         tevent_req_done(req);
6902 }
6903
6904 NTSTATUS dcerpc_winreg_QueryMultipleValues_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
6905 {
6906         struct dcerpc_winreg_QueryMultipleValues_r_state *state =
6907                 tevent_req_data(req,
6908                 struct dcerpc_winreg_QueryMultipleValues_r_state);
6909         NTSTATUS status;
6910
6911         if (tevent_req_is_nterror(req, &status)) {
6912                 tevent_req_received(req);
6913                 return status;
6914         }
6915
6916         talloc_steal(mem_ctx, state->out_mem_ctx);
6917
6918         tevent_req_received(req);
6919         return NT_STATUS_OK;
6920 }
6921
6922 NTSTATUS dcerpc_winreg_QueryMultipleValues_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_QueryMultipleValues *r)
6923 {
6924         NTSTATUS status;
6925
6926         status = dcerpc_binding_handle_call(h,
6927                         NULL, &ndr_table_winreg,
6928                         NDR_WINREG_QUERYMULTIPLEVALUES, mem_ctx, r);
6929
6930         return status;
6931 }
6932
6933 NTSTATUS dcerpc_winreg_QueryMultipleValues_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_QueryMultipleValues *r)
6934 {
6935         NTSTATUS status;
6936
6937         status = dcerpc_winreg_QueryMultipleValues_r(p->binding_handle, mem_ctx, r);
6938
6939         if (NT_STATUS_IS_RPC(status)) {
6940                 status = NT_STATUS_NET_WRITE_FAULT;
6941         }
6942
6943         return status;
6944 }
6945
6946 struct dcerpc_winreg_QueryMultipleValues_state {
6947         struct winreg_QueryMultipleValues orig;
6948         struct winreg_QueryMultipleValues tmp;
6949         TALLOC_CTX *out_mem_ctx;
6950 };
6951
6952 static void dcerpc_winreg_QueryMultipleValues_done(struct tevent_req *subreq);
6953
6954 struct tevent_req *dcerpc_winreg_QueryMultipleValues_send(TALLOC_CTX *mem_ctx,
6955                                                           struct tevent_context *ev,
6956                                                           struct dcerpc_binding_handle *h,
6957                                                           struct policy_handle *_key_handle /* [in] [ref] */,
6958                                                           struct QueryMultipleValue *_values_in /* [in] [ref,length_is(num_values),size_is(num_values)] */,
6959                                                           struct QueryMultipleValue *_values_out /* [out] [ref,length_is(num_values),size_is(num_values)] */,
6960                                                           uint32_t _num_values /* [in]  */,
6961                                                           uint8_t *_buffer /* [in,out] [unique,length_is(*buffer_size),size_is(*buffer_size)] */,
6962                                                           uint32_t *_buffer_size /* [in,out] [ref] */)
6963 {
6964         struct tevent_req *req;
6965         struct dcerpc_winreg_QueryMultipleValues_state *state;
6966         struct tevent_req *subreq;
6967
6968         req = tevent_req_create(mem_ctx, &state,
6969                                 struct dcerpc_winreg_QueryMultipleValues_state);
6970         if (req == NULL) {
6971                 return NULL;
6972         }
6973         state->out_mem_ctx = NULL;
6974
6975         /* In parameters */
6976         state->orig.in.key_handle = _key_handle;
6977         state->orig.in.values_in = _values_in;
6978         state->orig.in.num_values = _num_values;
6979         state->orig.in.buffer = _buffer;
6980         state->orig.in.buffer_size = _buffer_size;
6981
6982         /* Out parameters */
6983         state->orig.out.values_out = _values_out;
6984         state->orig.out.buffer = _buffer;
6985         state->orig.out.buffer_size = _buffer_size;
6986
6987         /* Result */
6988         ZERO_STRUCT(state->orig.out.result);
6989
6990         state->out_mem_ctx = talloc_named_const(state, 0,
6991                              "dcerpc_winreg_QueryMultipleValues_out_memory");
6992         if (tevent_req_nomem(state->out_mem_ctx, req)) {
6993                 return tevent_req_post(req, ev);
6994         }
6995
6996         /* make a temporary copy, that we pass to the dispatch function */
6997         state->tmp = state->orig;
6998
6999         subreq = dcerpc_winreg_QueryMultipleValues_r_send(state, ev, h, &state->tmp);
7000         if (tevent_req_nomem(subreq, req)) {
7001                 return tevent_req_post(req, ev);
7002         }
7003         tevent_req_set_callback(subreq, dcerpc_winreg_QueryMultipleValues_done, req);
7004         return req;
7005 }
7006
7007 static void dcerpc_winreg_QueryMultipleValues_done(struct tevent_req *subreq)
7008 {
7009         struct tevent_req *req = tevent_req_callback_data(
7010                 subreq, struct tevent_req);
7011         struct dcerpc_winreg_QueryMultipleValues_state *state = tevent_req_data(
7012                 req, struct dcerpc_winreg_QueryMultipleValues_state);
7013         NTSTATUS status;
7014         TALLOC_CTX *mem_ctx;
7015
7016         if (state->out_mem_ctx) {
7017                 mem_ctx = state->out_mem_ctx;
7018         } else {
7019                 mem_ctx = state;
7020         }
7021
7022         status = dcerpc_winreg_QueryMultipleValues_r_recv(subreq, mem_ctx);
7023         TALLOC_FREE(subreq);
7024         if (!NT_STATUS_IS_OK(status)) {
7025                 tevent_req_nterror(req, status);
7026                 return;
7027         }
7028
7029         /* Copy out parameters */
7030         {
7031                 size_t _copy_len_values_out;
7032                 _copy_len_values_out = state->tmp.in.num_values;
7033                 memcpy(state->orig.out.values_out, state->tmp.out.values_out, _copy_len_values_out * sizeof(*state->orig.out.values_out));
7034         }
7035         if (state->orig.out.buffer && state->tmp.out.buffer) {
7036                 {
7037                         size_t _copy_len_buffer;
7038                         if ((*state->tmp.out.buffer_size) > (*state->tmp.in.buffer_size)) {
7039                                 tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
7040                                 return;
7041                         }
7042                         _copy_len_buffer = *state->tmp.out.buffer_size;
7043                         memcpy(state->orig.out.buffer, state->tmp.out.buffer, _copy_len_buffer * sizeof(*state->orig.out.buffer));
7044                 }
7045         }
7046         *state->orig.out.buffer_size = *state->tmp.out.buffer_size;
7047
7048         /* Copy result */
7049         state->orig.out.result = state->tmp.out.result;
7050
7051         /* Reset temporary structure */
7052         ZERO_STRUCT(state->tmp);
7053
7054         tevent_req_done(req);
7055 }
7056
7057 NTSTATUS dcerpc_winreg_QueryMultipleValues_recv(struct tevent_req *req,
7058                                                 TALLOC_CTX *mem_ctx,
7059                                                 WERROR *result)
7060 {
7061         struct dcerpc_winreg_QueryMultipleValues_state *state = tevent_req_data(
7062                 req, struct dcerpc_winreg_QueryMultipleValues_state);
7063         NTSTATUS status;
7064
7065         if (tevent_req_is_nterror(req, &status)) {
7066                 tevent_req_received(req);
7067                 return status;
7068         }
7069
7070         /* Steal possible out parameters to the callers context */
7071         talloc_steal(mem_ctx, state->out_mem_ctx);
7072
7073         /* Return result */
7074         *result = state->orig.out.result;
7075
7076         tevent_req_received(req);
7077         return NT_STATUS_OK;
7078 }
7079
7080 NTSTATUS dcerpc_winreg_QueryMultipleValues(struct dcerpc_binding_handle *h,
7081                                            TALLOC_CTX *mem_ctx,
7082                                            struct policy_handle *_key_handle /* [in] [ref] */,
7083                                            struct QueryMultipleValue *_values_in /* [in] [ref,length_is(num_values),size_is(num_values)] */,
7084                                            struct QueryMultipleValue *_values_out /* [out] [ref,length_is(num_values),size_is(num_values)] */,
7085                                            uint32_t _num_values /* [in]  */,
7086                                            uint8_t *_buffer /* [in,out] [unique,length_is(*buffer_size),size_is(*buffer_size)] */,
7087                                            uint32_t *_buffer_size /* [in,out] [ref] */,
7088                                            WERROR *result)
7089 {
7090         struct winreg_QueryMultipleValues r;
7091         NTSTATUS status;
7092
7093         /* In parameters */
7094         r.in.key_handle = _key_handle;
7095         r.in.values_in = _values_in;
7096         r.in.num_values = _num_values;
7097         r.in.buffer = _buffer;
7098         r.in.buffer_size = _buffer_size;
7099
7100         status = dcerpc_winreg_QueryMultipleValues_r(h, mem_ctx, &r);
7101         if (!NT_STATUS_IS_OK(status)) {
7102                 return status;
7103         }
7104
7105         /* Return variables */
7106         {
7107                 size_t _copy_len_values_out;
7108                 _copy_len_values_out = r.in.num_values;
7109                 memcpy(_values_out, r.out.values_out, _copy_len_values_out * sizeof(*_values_out));
7110         }
7111         if (_buffer && r.out.buffer) {
7112                 {
7113                         size_t _copy_len_buffer;
7114                         if ((*r.out.buffer_size) > (*r.in.buffer_size)) {
7115                                 return NT_STATUS_INVALID_NETWORK_RESPONSE;
7116                         }
7117                         _copy_len_buffer = *r.out.buffer_size;
7118                         memcpy(_buffer, r.out.buffer, _copy_len_buffer * sizeof(*_buffer));
7119                 }
7120         }
7121         *_buffer_size = *r.out.buffer_size;
7122
7123         /* Return result */
7124         *result = r.out.result;
7125
7126         return NT_STATUS_OK;
7127 }
7128
7129 struct dcerpc_winreg_InitiateSystemShutdownEx_r_state {
7130         TALLOC_CTX *out_mem_ctx;
7131 };
7132
7133 static void dcerpc_winreg_InitiateSystemShutdownEx_r_done(struct tevent_req *subreq);
7134
7135 struct tevent_req *dcerpc_winreg_InitiateSystemShutdownEx_r_send(TALLOC_CTX *mem_ctx,
7136         struct tevent_context *ev,
7137         struct dcerpc_binding_handle *h,
7138         struct winreg_InitiateSystemShutdownEx *r)
7139 {
7140         struct tevent_req *req;
7141         struct dcerpc_winreg_InitiateSystemShutdownEx_r_state *state;
7142         struct tevent_req *subreq;
7143
7144         req = tevent_req_create(mem_ctx, &state,
7145                                 struct dcerpc_winreg_InitiateSystemShutdownEx_r_state);
7146         if (req == NULL) {
7147                 return NULL;
7148         }
7149
7150         state->out_mem_ctx = NULL;
7151         subreq = dcerpc_binding_handle_call_send(state, ev, h,
7152                         NULL, &ndr_table_winreg,
7153                         NDR_WINREG_INITIATESYSTEMSHUTDOWNEX, state, r);
7154         if (tevent_req_nomem(subreq, req)) {
7155                 return tevent_req_post(req, ev);
7156         }
7157         tevent_req_set_callback(subreq, dcerpc_winreg_InitiateSystemShutdownEx_r_done, req);
7158
7159         return req;
7160 }
7161
7162 static void dcerpc_winreg_InitiateSystemShutdownEx_r_done(struct tevent_req *subreq)
7163 {
7164         struct tevent_req *req =
7165                 tevent_req_callback_data(subreq,
7166                 struct tevent_req);
7167         NTSTATUS status;
7168
7169         status = dcerpc_binding_handle_call_recv(subreq);
7170         if (!NT_STATUS_IS_OK(status)) {
7171                 tevent_req_nterror(req, status);
7172                 return;
7173         }
7174
7175         tevent_req_done(req);
7176 }
7177
7178 NTSTATUS dcerpc_winreg_InitiateSystemShutdownEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
7179 {
7180         struct dcerpc_winreg_InitiateSystemShutdownEx_r_state *state =
7181                 tevent_req_data(req,
7182                 struct dcerpc_winreg_InitiateSystemShutdownEx_r_state);
7183         NTSTATUS status;
7184
7185         if (tevent_req_is_nterror(req, &status)) {
7186                 tevent_req_received(req);
7187                 return status;
7188         }
7189
7190         talloc_steal(mem_ctx, state->out_mem_ctx);
7191
7192         tevent_req_received(req);
7193         return NT_STATUS_OK;
7194 }
7195
7196 NTSTATUS dcerpc_winreg_InitiateSystemShutdownEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_InitiateSystemShutdownEx *r)
7197 {
7198         NTSTATUS status;
7199
7200         status = dcerpc_binding_handle_call(h,
7201                         NULL, &ndr_table_winreg,
7202                         NDR_WINREG_INITIATESYSTEMSHUTDOWNEX, mem_ctx, r);
7203
7204         return status;
7205 }
7206
7207 NTSTATUS dcerpc_winreg_InitiateSystemShutdownEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_InitiateSystemShutdownEx *r)
7208 {
7209         NTSTATUS status;
7210
7211         status = dcerpc_winreg_InitiateSystemShutdownEx_r(p->binding_handle, mem_ctx, r);
7212
7213         if (NT_STATUS_IS_RPC(status)) {
7214                 status = NT_STATUS_NET_WRITE_FAULT;
7215         }
7216
7217         return status;
7218 }
7219
7220 struct dcerpc_winreg_InitiateSystemShutdownEx_state {
7221         struct winreg_InitiateSystemShutdownEx orig;
7222         struct winreg_InitiateSystemShutdownEx tmp;
7223         TALLOC_CTX *out_mem_ctx;
7224 };
7225
7226 static void dcerpc_winreg_InitiateSystemShutdownEx_done(struct tevent_req *subreq);
7227
7228 struct tevent_req *dcerpc_winreg_InitiateSystemShutdownEx_send(TALLOC_CTX *mem_ctx,
7229                                                                struct tevent_context *ev,
7230                                                                struct dcerpc_binding_handle *h,
7231                                                                uint16_t *_hostname /* [in] [unique] */,
7232                                                                struct lsa_StringLarge *_message /* [in] [unique] */,
7233                                                                uint32_t _timeout /* [in]  */,
7234                                                                uint8_t _force_apps /* [in]  */,
7235                                                                uint8_t _do_reboot /* [in]  */,
7236                                                                uint32_t _reason /* [in]  */)
7237 {
7238         struct tevent_req *req;
7239         struct dcerpc_winreg_InitiateSystemShutdownEx_state *state;
7240         struct tevent_req *subreq;
7241
7242         req = tevent_req_create(mem_ctx, &state,
7243                                 struct dcerpc_winreg_InitiateSystemShutdownEx_state);
7244         if (req == NULL) {
7245                 return NULL;
7246         }
7247         state->out_mem_ctx = NULL;
7248
7249         /* In parameters */
7250         state->orig.in.hostname = _hostname;
7251         state->orig.in.message = _message;
7252         state->orig.in.timeout = _timeout;
7253         state->orig.in.force_apps = _force_apps;
7254         state->orig.in.do_reboot = _do_reboot;
7255         state->orig.in.reason = _reason;
7256
7257         /* Out parameters */
7258
7259         /* Result */
7260         ZERO_STRUCT(state->orig.out.result);
7261
7262         /* make a temporary copy, that we pass to the dispatch function */
7263         state->tmp = state->orig;
7264
7265         subreq = dcerpc_winreg_InitiateSystemShutdownEx_r_send(state, ev, h, &state->tmp);
7266         if (tevent_req_nomem(subreq, req)) {
7267                 return tevent_req_post(req, ev);
7268         }
7269         tevent_req_set_callback(subreq, dcerpc_winreg_InitiateSystemShutdownEx_done, req);
7270         return req;
7271 }
7272
7273 static void dcerpc_winreg_InitiateSystemShutdownEx_done(struct tevent_req *subreq)
7274 {
7275         struct tevent_req *req = tevent_req_callback_data(
7276                 subreq, struct tevent_req);
7277         struct dcerpc_winreg_InitiateSystemShutdownEx_state *state = tevent_req_data(
7278                 req, struct dcerpc_winreg_InitiateSystemShutdownEx_state);
7279         NTSTATUS status;
7280         TALLOC_CTX *mem_ctx;
7281
7282         if (state->out_mem_ctx) {
7283                 mem_ctx = state->out_mem_ctx;
7284         } else {
7285                 mem_ctx = state;
7286         }
7287
7288         status = dcerpc_winreg_InitiateSystemShutdownEx_r_recv(subreq, mem_ctx);
7289         TALLOC_FREE(subreq);
7290         if (!NT_STATUS_IS_OK(status)) {
7291                 tevent_req_nterror(req, status);
7292                 return;
7293         }
7294
7295         /* Copy out parameters */
7296
7297         /* Copy result */
7298         state->orig.out.result = state->tmp.out.result;
7299
7300         /* Reset temporary structure */
7301         ZERO_STRUCT(state->tmp);
7302
7303         tevent_req_done(req);
7304 }
7305
7306 NTSTATUS dcerpc_winreg_InitiateSystemShutdownEx_recv(struct tevent_req *req,
7307                                                      TALLOC_CTX *mem_ctx,
7308                                                      WERROR *result)
7309 {
7310         struct dcerpc_winreg_InitiateSystemShutdownEx_state *state = tevent_req_data(
7311                 req, struct dcerpc_winreg_InitiateSystemShutdownEx_state);
7312         NTSTATUS status;
7313
7314         if (tevent_req_is_nterror(req, &status)) {
7315                 tevent_req_received(req);
7316                 return status;
7317         }
7318
7319         /* Steal possible out parameters to the callers context */
7320         talloc_steal(mem_ctx, state->out_mem_ctx);
7321
7322         /* Return result */
7323         *result = state->orig.out.result;
7324
7325         tevent_req_received(req);
7326         return NT_STATUS_OK;
7327 }
7328
7329 NTSTATUS dcerpc_winreg_InitiateSystemShutdownEx(struct dcerpc_binding_handle *h,
7330                                                 TALLOC_CTX *mem_ctx,
7331                                                 uint16_t *_hostname /* [in] [unique] */,
7332                                                 struct lsa_StringLarge *_message /* [in] [unique] */,
7333                                                 uint32_t _timeout /* [in]  */,
7334                                                 uint8_t _force_apps /* [in]  */,
7335                                                 uint8_t _do_reboot /* [in]  */,
7336                                                 uint32_t _reason /* [in]  */,
7337                                                 WERROR *result)
7338 {
7339         struct winreg_InitiateSystemShutdownEx r;
7340         NTSTATUS status;
7341
7342         /* In parameters */
7343         r.in.hostname = _hostname;
7344         r.in.message = _message;
7345         r.in.timeout = _timeout;
7346         r.in.force_apps = _force_apps;
7347         r.in.do_reboot = _do_reboot;
7348         r.in.reason = _reason;
7349
7350         status = dcerpc_winreg_InitiateSystemShutdownEx_r(h, mem_ctx, &r);
7351         if (!NT_STATUS_IS_OK(status)) {
7352                 return status;
7353         }
7354
7355         /* Return variables */
7356
7357         /* Return result */
7358         *result = r.out.result;
7359
7360         return NT_STATUS_OK;
7361 }
7362
7363 struct dcerpc_winreg_SaveKeyEx_r_state {
7364         TALLOC_CTX *out_mem_ctx;
7365 };
7366
7367 static void dcerpc_winreg_SaveKeyEx_r_done(struct tevent_req *subreq);
7368
7369 struct tevent_req *dcerpc_winreg_SaveKeyEx_r_send(TALLOC_CTX *mem_ctx,
7370         struct tevent_context *ev,
7371         struct dcerpc_binding_handle *h,
7372         struct winreg_SaveKeyEx *r)
7373 {
7374         struct tevent_req *req;
7375         struct dcerpc_winreg_SaveKeyEx_r_state *state;
7376         struct tevent_req *subreq;
7377
7378         req = tevent_req_create(mem_ctx, &state,
7379                                 struct dcerpc_winreg_SaveKeyEx_r_state);
7380         if (req == NULL) {
7381                 return NULL;
7382         }
7383
7384         state->out_mem_ctx = NULL;
7385         subreq = dcerpc_binding_handle_call_send(state, ev, h,
7386                         NULL, &ndr_table_winreg,
7387                         NDR_WINREG_SAVEKEYEX, state, r);
7388         if (tevent_req_nomem(subreq, req)) {
7389                 return tevent_req_post(req, ev);
7390         }
7391         tevent_req_set_callback(subreq, dcerpc_winreg_SaveKeyEx_r_done, req);
7392
7393         return req;
7394 }
7395
7396 static void dcerpc_winreg_SaveKeyEx_r_done(struct tevent_req *subreq)
7397 {
7398         struct tevent_req *req =
7399                 tevent_req_callback_data(subreq,
7400                 struct tevent_req);
7401         NTSTATUS status;
7402
7403         status = dcerpc_binding_handle_call_recv(subreq);
7404         if (!NT_STATUS_IS_OK(status)) {
7405                 tevent_req_nterror(req, status);
7406                 return;
7407         }
7408
7409         tevent_req_done(req);
7410 }
7411
7412 NTSTATUS dcerpc_winreg_SaveKeyEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
7413 {
7414         struct dcerpc_winreg_SaveKeyEx_r_state *state =
7415                 tevent_req_data(req,
7416                 struct dcerpc_winreg_SaveKeyEx_r_state);
7417         NTSTATUS status;
7418
7419         if (tevent_req_is_nterror(req, &status)) {
7420                 tevent_req_received(req);
7421                 return status;
7422         }
7423
7424         talloc_steal(mem_ctx, state->out_mem_ctx);
7425
7426         tevent_req_received(req);
7427         return NT_STATUS_OK;
7428 }
7429
7430 NTSTATUS dcerpc_winreg_SaveKeyEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_SaveKeyEx *r)
7431 {
7432         NTSTATUS status;
7433
7434         status = dcerpc_binding_handle_call(h,
7435                         NULL, &ndr_table_winreg,
7436                         NDR_WINREG_SAVEKEYEX, mem_ctx, r);
7437
7438         return status;
7439 }
7440
7441 NTSTATUS dcerpc_winreg_SaveKeyEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_SaveKeyEx *r)
7442 {
7443         NTSTATUS status;
7444
7445         status = dcerpc_winreg_SaveKeyEx_r(p->binding_handle, mem_ctx, r);
7446
7447         if (NT_STATUS_IS_RPC(status)) {
7448                 status = NT_STATUS_NET_WRITE_FAULT;
7449         }
7450
7451         return status;
7452 }
7453
7454 struct dcerpc_winreg_SaveKeyEx_state {
7455         struct winreg_SaveKeyEx orig;
7456         struct winreg_SaveKeyEx tmp;
7457         TALLOC_CTX *out_mem_ctx;
7458 };
7459
7460 static void dcerpc_winreg_SaveKeyEx_done(struct tevent_req *subreq);
7461
7462 struct tevent_req *dcerpc_winreg_SaveKeyEx_send(TALLOC_CTX *mem_ctx,
7463                                                 struct tevent_context *ev,
7464                                                 struct dcerpc_binding_handle *h,
7465                                                 struct policy_handle *_handle /* [in] [ref] */,
7466                                                 struct winreg_String *_filename /* [in] [ref] */,
7467                                                 struct KeySecurityAttribute *_sec_attrib /* [in] [unique] */,
7468                                                 uint32_t _flags /* [in]  */)
7469 {
7470         struct tevent_req *req;
7471         struct dcerpc_winreg_SaveKeyEx_state *state;
7472         struct tevent_req *subreq;
7473
7474         req = tevent_req_create(mem_ctx, &state,
7475                                 struct dcerpc_winreg_SaveKeyEx_state);
7476         if (req == NULL) {
7477                 return NULL;
7478         }
7479         state->out_mem_ctx = NULL;
7480
7481         /* In parameters */
7482         state->orig.in.handle = _handle;
7483         state->orig.in.filename = _filename;
7484         state->orig.in.sec_attrib = _sec_attrib;
7485         state->orig.in.flags = _flags;
7486
7487         /* Out parameters */
7488
7489         /* Result */
7490         ZERO_STRUCT(state->orig.out.result);
7491
7492         /* make a temporary copy, that we pass to the dispatch function */
7493         state->tmp = state->orig;
7494
7495         subreq = dcerpc_winreg_SaveKeyEx_r_send(state, ev, h, &state->tmp);
7496         if (tevent_req_nomem(subreq, req)) {
7497                 return tevent_req_post(req, ev);
7498         }
7499         tevent_req_set_callback(subreq, dcerpc_winreg_SaveKeyEx_done, req);
7500         return req;
7501 }
7502
7503 static void dcerpc_winreg_SaveKeyEx_done(struct tevent_req *subreq)
7504 {
7505         struct tevent_req *req = tevent_req_callback_data(
7506                 subreq, struct tevent_req);
7507         struct dcerpc_winreg_SaveKeyEx_state *state = tevent_req_data(
7508                 req, struct dcerpc_winreg_SaveKeyEx_state);
7509         NTSTATUS status;
7510         TALLOC_CTX *mem_ctx;
7511
7512         if (state->out_mem_ctx) {
7513                 mem_ctx = state->out_mem_ctx;
7514         } else {
7515                 mem_ctx = state;
7516         }
7517
7518         status = dcerpc_winreg_SaveKeyEx_r_recv(subreq, mem_ctx);
7519         TALLOC_FREE(subreq);
7520         if (!NT_STATUS_IS_OK(status)) {
7521                 tevent_req_nterror(req, status);
7522                 return;
7523         }
7524
7525         /* Copy out parameters */
7526
7527         /* Copy result */
7528         state->orig.out.result = state->tmp.out.result;
7529
7530         /* Reset temporary structure */
7531         ZERO_STRUCT(state->tmp);
7532
7533         tevent_req_done(req);
7534 }
7535
7536 NTSTATUS dcerpc_winreg_SaveKeyEx_recv(struct tevent_req *req,
7537                                       TALLOC_CTX *mem_ctx,
7538                                       WERROR *result)
7539 {
7540         struct dcerpc_winreg_SaveKeyEx_state *state = tevent_req_data(
7541                 req, struct dcerpc_winreg_SaveKeyEx_state);
7542         NTSTATUS status;
7543
7544         if (tevent_req_is_nterror(req, &status)) {
7545                 tevent_req_received(req);
7546                 return status;
7547         }
7548
7549         /* Steal possible out parameters to the callers context */
7550         talloc_steal(mem_ctx, state->out_mem_ctx);
7551
7552         /* Return result */
7553         *result = state->orig.out.result;
7554
7555         tevent_req_received(req);
7556         return NT_STATUS_OK;
7557 }
7558
7559 NTSTATUS dcerpc_winreg_SaveKeyEx(struct dcerpc_binding_handle *h,
7560                                  TALLOC_CTX *mem_ctx,
7561                                  struct policy_handle *_handle /* [in] [ref] */,
7562                                  struct winreg_String *_filename /* [in] [ref] */,
7563                                  struct KeySecurityAttribute *_sec_attrib /* [in] [unique] */,
7564                                  uint32_t _flags /* [in]  */,
7565                                  WERROR *result)
7566 {
7567         struct winreg_SaveKeyEx r;
7568         NTSTATUS status;
7569
7570         /* In parameters */
7571         r.in.handle = _handle;
7572         r.in.filename = _filename;
7573         r.in.sec_attrib = _sec_attrib;
7574         r.in.flags = _flags;
7575
7576         status = dcerpc_winreg_SaveKeyEx_r(h, mem_ctx, &r);
7577         if (!NT_STATUS_IS_OK(status)) {
7578                 return status;
7579         }
7580
7581         /* Return variables */
7582
7583         /* Return result */
7584         *result = r.out.result;
7585
7586         return NT_STATUS_OK;
7587 }
7588
7589 struct dcerpc_winreg_OpenHKPT_r_state {
7590         TALLOC_CTX *out_mem_ctx;
7591 };
7592
7593 static void dcerpc_winreg_OpenHKPT_r_done(struct tevent_req *subreq);
7594
7595 struct tevent_req *dcerpc_winreg_OpenHKPT_r_send(TALLOC_CTX *mem_ctx,
7596         struct tevent_context *ev,
7597         struct dcerpc_binding_handle *h,
7598         struct winreg_OpenHKPT *r)
7599 {
7600         struct tevent_req *req;
7601         struct dcerpc_winreg_OpenHKPT_r_state *state;
7602         struct tevent_req *subreq;
7603
7604         req = tevent_req_create(mem_ctx, &state,
7605                                 struct dcerpc_winreg_OpenHKPT_r_state);
7606         if (req == NULL) {
7607                 return NULL;
7608         }
7609
7610         state->out_mem_ctx = talloc_new(state);
7611         if (tevent_req_nomem(state->out_mem_ctx, req)) {
7612                 return tevent_req_post(req, ev);
7613         }
7614
7615         subreq = dcerpc_binding_handle_call_send(state, ev, h,
7616                         NULL, &ndr_table_winreg,
7617                         NDR_WINREG_OPENHKPT, state->out_mem_ctx, r);
7618         if (tevent_req_nomem(subreq, req)) {
7619                 return tevent_req_post(req, ev);
7620         }
7621         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKPT_r_done, req);
7622
7623         return req;
7624 }
7625
7626 static void dcerpc_winreg_OpenHKPT_r_done(struct tevent_req *subreq)
7627 {
7628         struct tevent_req *req =
7629                 tevent_req_callback_data(subreq,
7630                 struct tevent_req);
7631         NTSTATUS status;
7632
7633         status = dcerpc_binding_handle_call_recv(subreq);
7634         if (!NT_STATUS_IS_OK(status)) {
7635                 tevent_req_nterror(req, status);
7636                 return;
7637         }
7638
7639         tevent_req_done(req);
7640 }
7641
7642 NTSTATUS dcerpc_winreg_OpenHKPT_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
7643 {
7644         struct dcerpc_winreg_OpenHKPT_r_state *state =
7645                 tevent_req_data(req,
7646                 struct dcerpc_winreg_OpenHKPT_r_state);
7647         NTSTATUS status;
7648
7649         if (tevent_req_is_nterror(req, &status)) {
7650                 tevent_req_received(req);
7651                 return status;
7652         }
7653
7654         talloc_steal(mem_ctx, state->out_mem_ctx);
7655
7656         tevent_req_received(req);
7657         return NT_STATUS_OK;
7658 }
7659
7660 NTSTATUS dcerpc_winreg_OpenHKPT_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_OpenHKPT *r)
7661 {
7662         NTSTATUS status;
7663
7664         status = dcerpc_binding_handle_call(h,
7665                         NULL, &ndr_table_winreg,
7666                         NDR_WINREG_OPENHKPT, mem_ctx, r);
7667
7668         return status;
7669 }
7670
7671 NTSTATUS dcerpc_winreg_OpenHKPT_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_OpenHKPT *r)
7672 {
7673         NTSTATUS status;
7674
7675         status = dcerpc_winreg_OpenHKPT_r(p->binding_handle, mem_ctx, r);
7676
7677         if (NT_STATUS_IS_RPC(status)) {
7678                 status = NT_STATUS_NET_WRITE_FAULT;
7679         }
7680
7681         return status;
7682 }
7683
7684 struct dcerpc_winreg_OpenHKPT_state {
7685         struct winreg_OpenHKPT orig;
7686         struct winreg_OpenHKPT tmp;
7687         TALLOC_CTX *out_mem_ctx;
7688 };
7689
7690 static void dcerpc_winreg_OpenHKPT_done(struct tevent_req *subreq);
7691
7692 struct tevent_req *dcerpc_winreg_OpenHKPT_send(TALLOC_CTX *mem_ctx,
7693                                                struct tevent_context *ev,
7694                                                struct dcerpc_binding_handle *h,
7695                                                uint16_t *_system_name /* [in] [unique] */,
7696                                                uint32_t _access_mask /* [in]  */,
7697                                                struct policy_handle *_handle /* [out] [ref] */)
7698 {
7699         struct tevent_req *req;
7700         struct dcerpc_winreg_OpenHKPT_state *state;
7701         struct tevent_req *subreq;
7702
7703         req = tevent_req_create(mem_ctx, &state,
7704                                 struct dcerpc_winreg_OpenHKPT_state);
7705         if (req == NULL) {
7706                 return NULL;
7707         }
7708         state->out_mem_ctx = NULL;
7709
7710         /* In parameters */
7711         state->orig.in.system_name = _system_name;
7712         state->orig.in.access_mask = _access_mask;
7713
7714         /* Out parameters */
7715         state->orig.out.handle = _handle;
7716
7717         /* Result */
7718         ZERO_STRUCT(state->orig.out.result);
7719
7720         state->out_mem_ctx = talloc_named_const(state, 0,
7721                              "dcerpc_winreg_OpenHKPT_out_memory");
7722         if (tevent_req_nomem(state->out_mem_ctx, req)) {
7723                 return tevent_req_post(req, ev);
7724         }
7725
7726         /* make a temporary copy, that we pass to the dispatch function */
7727         state->tmp = state->orig;
7728
7729         subreq = dcerpc_winreg_OpenHKPT_r_send(state, ev, h, &state->tmp);
7730         if (tevent_req_nomem(subreq, req)) {
7731                 return tevent_req_post(req, ev);
7732         }
7733         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKPT_done, req);
7734         return req;
7735 }
7736
7737 static void dcerpc_winreg_OpenHKPT_done(struct tevent_req *subreq)
7738 {
7739         struct tevent_req *req = tevent_req_callback_data(
7740                 subreq, struct tevent_req);
7741         struct dcerpc_winreg_OpenHKPT_state *state = tevent_req_data(
7742                 req, struct dcerpc_winreg_OpenHKPT_state);
7743         NTSTATUS status;
7744         TALLOC_CTX *mem_ctx;
7745
7746         if (state->out_mem_ctx) {
7747                 mem_ctx = state->out_mem_ctx;
7748         } else {
7749                 mem_ctx = state;
7750         }
7751
7752         status = dcerpc_winreg_OpenHKPT_r_recv(subreq, mem_ctx);
7753         TALLOC_FREE(subreq);
7754         if (!NT_STATUS_IS_OK(status)) {
7755                 tevent_req_nterror(req, status);
7756                 return;
7757         }
7758
7759         /* Copy out parameters */
7760         *state->orig.out.handle = *state->tmp.out.handle;
7761
7762         /* Copy result */
7763         state->orig.out.result = state->tmp.out.result;
7764
7765         /* Reset temporary structure */
7766         ZERO_STRUCT(state->tmp);
7767
7768         tevent_req_done(req);
7769 }
7770
7771 NTSTATUS dcerpc_winreg_OpenHKPT_recv(struct tevent_req *req,
7772                                      TALLOC_CTX *mem_ctx,
7773                                      WERROR *result)
7774 {
7775         struct dcerpc_winreg_OpenHKPT_state *state = tevent_req_data(
7776                 req, struct dcerpc_winreg_OpenHKPT_state);
7777         NTSTATUS status;
7778
7779         if (tevent_req_is_nterror(req, &status)) {
7780                 tevent_req_received(req);
7781                 return status;
7782         }
7783
7784         /* Steal possible out parameters to the callers context */
7785         talloc_steal(mem_ctx, state->out_mem_ctx);
7786
7787         /* Return result */
7788         *result = state->orig.out.result;
7789
7790         tevent_req_received(req);
7791         return NT_STATUS_OK;
7792 }
7793
7794 NTSTATUS dcerpc_winreg_OpenHKPT(struct dcerpc_binding_handle *h,
7795                                 TALLOC_CTX *mem_ctx,
7796                                 uint16_t *_system_name /* [in] [unique] */,
7797                                 uint32_t _access_mask /* [in]  */,
7798                                 struct policy_handle *_handle /* [out] [ref] */,
7799                                 WERROR *result)
7800 {
7801         struct winreg_OpenHKPT r;
7802         NTSTATUS status;
7803
7804         /* In parameters */
7805         r.in.system_name = _system_name;
7806         r.in.access_mask = _access_mask;
7807
7808         status = dcerpc_winreg_OpenHKPT_r(h, mem_ctx, &r);
7809         if (!NT_STATUS_IS_OK(status)) {
7810                 return status;
7811         }
7812
7813         /* Return variables */
7814         *_handle = *r.out.handle;
7815
7816         /* Return result */
7817         *result = r.out.result;
7818
7819         return NT_STATUS_OK;
7820 }
7821
7822 struct dcerpc_winreg_OpenHKPN_r_state {
7823         TALLOC_CTX *out_mem_ctx;
7824 };
7825
7826 static void dcerpc_winreg_OpenHKPN_r_done(struct tevent_req *subreq);
7827
7828 struct tevent_req *dcerpc_winreg_OpenHKPN_r_send(TALLOC_CTX *mem_ctx,
7829         struct tevent_context *ev,
7830         struct dcerpc_binding_handle *h,
7831         struct winreg_OpenHKPN *r)
7832 {
7833         struct tevent_req *req;
7834         struct dcerpc_winreg_OpenHKPN_r_state *state;
7835         struct tevent_req *subreq;
7836
7837         req = tevent_req_create(mem_ctx, &state,
7838                                 struct dcerpc_winreg_OpenHKPN_r_state);
7839         if (req == NULL) {
7840                 return NULL;
7841         }
7842
7843         state->out_mem_ctx = talloc_new(state);
7844         if (tevent_req_nomem(state->out_mem_ctx, req)) {
7845                 return tevent_req_post(req, ev);
7846         }
7847
7848         subreq = dcerpc_binding_handle_call_send(state, ev, h,
7849                         NULL, &ndr_table_winreg,
7850                         NDR_WINREG_OPENHKPN, state->out_mem_ctx, r);
7851         if (tevent_req_nomem(subreq, req)) {
7852                 return tevent_req_post(req, ev);
7853         }
7854         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKPN_r_done, req);
7855
7856         return req;
7857 }
7858
7859 static void dcerpc_winreg_OpenHKPN_r_done(struct tevent_req *subreq)
7860 {
7861         struct tevent_req *req =
7862                 tevent_req_callback_data(subreq,
7863                 struct tevent_req);
7864         NTSTATUS status;
7865
7866         status = dcerpc_binding_handle_call_recv(subreq);
7867         if (!NT_STATUS_IS_OK(status)) {
7868                 tevent_req_nterror(req, status);
7869                 return;
7870         }
7871
7872         tevent_req_done(req);
7873 }
7874
7875 NTSTATUS dcerpc_winreg_OpenHKPN_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
7876 {
7877         struct dcerpc_winreg_OpenHKPN_r_state *state =
7878                 tevent_req_data(req,
7879                 struct dcerpc_winreg_OpenHKPN_r_state);
7880         NTSTATUS status;
7881
7882         if (tevent_req_is_nterror(req, &status)) {
7883                 tevent_req_received(req);
7884                 return status;
7885         }
7886
7887         talloc_steal(mem_ctx, state->out_mem_ctx);
7888
7889         tevent_req_received(req);
7890         return NT_STATUS_OK;
7891 }
7892
7893 NTSTATUS dcerpc_winreg_OpenHKPN_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_OpenHKPN *r)
7894 {
7895         NTSTATUS status;
7896
7897         status = dcerpc_binding_handle_call(h,
7898                         NULL, &ndr_table_winreg,
7899                         NDR_WINREG_OPENHKPN, mem_ctx, r);
7900
7901         return status;
7902 }
7903
7904 NTSTATUS dcerpc_winreg_OpenHKPN_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_OpenHKPN *r)
7905 {
7906         NTSTATUS status;
7907
7908         status = dcerpc_winreg_OpenHKPN_r(p->binding_handle, mem_ctx, r);
7909
7910         if (NT_STATUS_IS_RPC(status)) {
7911                 status = NT_STATUS_NET_WRITE_FAULT;
7912         }
7913
7914         return status;
7915 }
7916
7917 struct dcerpc_winreg_OpenHKPN_state {
7918         struct winreg_OpenHKPN orig;
7919         struct winreg_OpenHKPN tmp;
7920         TALLOC_CTX *out_mem_ctx;
7921 };
7922
7923 static void dcerpc_winreg_OpenHKPN_done(struct tevent_req *subreq);
7924
7925 struct tevent_req *dcerpc_winreg_OpenHKPN_send(TALLOC_CTX *mem_ctx,
7926                                                struct tevent_context *ev,
7927                                                struct dcerpc_binding_handle *h,
7928                                                uint16_t *_system_name /* [in] [unique] */,
7929                                                uint32_t _access_mask /* [in]  */,
7930                                                struct policy_handle *_handle /* [out] [ref] */)
7931 {
7932         struct tevent_req *req;
7933         struct dcerpc_winreg_OpenHKPN_state *state;
7934         struct tevent_req *subreq;
7935
7936         req = tevent_req_create(mem_ctx, &state,
7937                                 struct dcerpc_winreg_OpenHKPN_state);
7938         if (req == NULL) {
7939                 return NULL;
7940         }
7941         state->out_mem_ctx = NULL;
7942
7943         /* In parameters */
7944         state->orig.in.system_name = _system_name;
7945         state->orig.in.access_mask = _access_mask;
7946
7947         /* Out parameters */
7948         state->orig.out.handle = _handle;
7949
7950         /* Result */
7951         ZERO_STRUCT(state->orig.out.result);
7952
7953         state->out_mem_ctx = talloc_named_const(state, 0,
7954                              "dcerpc_winreg_OpenHKPN_out_memory");
7955         if (tevent_req_nomem(state->out_mem_ctx, req)) {
7956                 return tevent_req_post(req, ev);
7957         }
7958
7959         /* make a temporary copy, that we pass to the dispatch function */
7960         state->tmp = state->orig;
7961
7962         subreq = dcerpc_winreg_OpenHKPN_r_send(state, ev, h, &state->tmp);
7963         if (tevent_req_nomem(subreq, req)) {
7964                 return tevent_req_post(req, ev);
7965         }
7966         tevent_req_set_callback(subreq, dcerpc_winreg_OpenHKPN_done, req);
7967         return req;
7968 }
7969
7970 static void dcerpc_winreg_OpenHKPN_done(struct tevent_req *subreq)
7971 {
7972         struct tevent_req *req = tevent_req_callback_data(
7973                 subreq, struct tevent_req);
7974         struct dcerpc_winreg_OpenHKPN_state *state = tevent_req_data(
7975                 req, struct dcerpc_winreg_OpenHKPN_state);
7976         NTSTATUS status;
7977         TALLOC_CTX *mem_ctx;
7978
7979         if (state->out_mem_ctx) {
7980                 mem_ctx = state->out_mem_ctx;
7981         } else {
7982                 mem_ctx = state;
7983         }
7984
7985         status = dcerpc_winreg_OpenHKPN_r_recv(subreq, mem_ctx);
7986         TALLOC_FREE(subreq);
7987         if (!NT_STATUS_IS_OK(status)) {
7988                 tevent_req_nterror(req, status);
7989                 return;
7990         }
7991
7992         /* Copy out parameters */
7993         *state->orig.out.handle = *state->tmp.out.handle;
7994
7995         /* Copy result */
7996         state->orig.out.result = state->tmp.out.result;
7997
7998         /* Reset temporary structure */
7999         ZERO_STRUCT(state->tmp);
8000
8001         tevent_req_done(req);
8002 }
8003
8004 NTSTATUS dcerpc_winreg_OpenHKPN_recv(struct tevent_req *req,
8005                                      TALLOC_CTX *mem_ctx,
8006                                      WERROR *result)
8007 {
8008         struct dcerpc_winreg_OpenHKPN_state *state = tevent_req_data(
8009                 req, struct dcerpc_winreg_OpenHKPN_state);
8010         NTSTATUS status;
8011
8012         if (tevent_req_is_nterror(req, &status)) {
8013                 tevent_req_received(req);
8014                 return status;
8015         }
8016
8017         /* Steal possible out parameters to the callers context */
8018         talloc_steal(mem_ctx, state->out_mem_ctx);
8019
8020         /* Return result */
8021         *result = state->orig.out.result;
8022
8023         tevent_req_received(req);
8024         return NT_STATUS_OK;
8025 }
8026
8027 NTSTATUS dcerpc_winreg_OpenHKPN(struct dcerpc_binding_handle *h,
8028                                 TALLOC_CTX *mem_ctx,
8029                                 uint16_t *_system_name /* [in] [unique] */,
8030                                 uint32_t _access_mask /* [in]  */,
8031                                 struct policy_handle *_handle /* [out] [ref] */,
8032                                 WERROR *result)
8033 {
8034         struct winreg_OpenHKPN r;
8035         NTSTATUS status;
8036
8037         /* In parameters */
8038         r.in.system_name = _system_name;
8039         r.in.access_mask = _access_mask;
8040
8041         status = dcerpc_winreg_OpenHKPN_r(h, mem_ctx, &r);
8042         if (!NT_STATUS_IS_OK(status)) {
8043                 return status;
8044         }
8045
8046         /* Return variables */
8047         *_handle = *r.out.handle;
8048
8049         /* Return result */
8050         *result = r.out.result;
8051
8052         return NT_STATUS_OK;
8053 }
8054
8055 struct dcerpc_winreg_QueryMultipleValues2_r_state {
8056         TALLOC_CTX *out_mem_ctx;
8057 };
8058
8059 static void dcerpc_winreg_QueryMultipleValues2_r_done(struct tevent_req *subreq);
8060
8061 struct tevent_req *dcerpc_winreg_QueryMultipleValues2_r_send(TALLOC_CTX *mem_ctx,
8062         struct tevent_context *ev,
8063         struct dcerpc_binding_handle *h,
8064         struct winreg_QueryMultipleValues2 *r)
8065 {
8066         struct tevent_req *req;
8067         struct dcerpc_winreg_QueryMultipleValues2_r_state *state;
8068         struct tevent_req *subreq;
8069
8070         req = tevent_req_create(mem_ctx, &state,
8071                                 struct dcerpc_winreg_QueryMultipleValues2_r_state);
8072         if (req == NULL) {
8073                 return NULL;
8074         }
8075
8076         state->out_mem_ctx = talloc_new(state);
8077         if (tevent_req_nomem(state->out_mem_ctx, req)) {
8078                 return tevent_req_post(req, ev);
8079         }
8080
8081         subreq = dcerpc_binding_handle_call_send(state, ev, h,
8082                         NULL, &ndr_table_winreg,
8083                         NDR_WINREG_QUERYMULTIPLEVALUES2, state->out_mem_ctx, r);
8084         if (tevent_req_nomem(subreq, req)) {
8085                 return tevent_req_post(req, ev);
8086         }
8087         tevent_req_set_callback(subreq, dcerpc_winreg_QueryMultipleValues2_r_done, req);
8088
8089         return req;
8090 }
8091
8092 static void dcerpc_winreg_QueryMultipleValues2_r_done(struct tevent_req *subreq)
8093 {
8094         struct tevent_req *req =
8095                 tevent_req_callback_data(subreq,
8096                 struct tevent_req);
8097         NTSTATUS status;
8098
8099         status = dcerpc_binding_handle_call_recv(subreq);
8100         if (!NT_STATUS_IS_OK(status)) {
8101                 tevent_req_nterror(req, status);
8102                 return;
8103         }
8104
8105         tevent_req_done(req);
8106 }
8107
8108 NTSTATUS dcerpc_winreg_QueryMultipleValues2_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
8109 {
8110         struct dcerpc_winreg_QueryMultipleValues2_r_state *state =
8111                 tevent_req_data(req,
8112                 struct dcerpc_winreg_QueryMultipleValues2_r_state);
8113         NTSTATUS status;
8114
8115         if (tevent_req_is_nterror(req, &status)) {
8116                 tevent_req_received(req);
8117                 return status;
8118         }
8119
8120         talloc_steal(mem_ctx, state->out_mem_ctx);
8121
8122         tevent_req_received(req);
8123         return NT_STATUS_OK;
8124 }
8125
8126 NTSTATUS dcerpc_winreg_QueryMultipleValues2_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_QueryMultipleValues2 *r)
8127 {
8128         NTSTATUS status;
8129
8130         status = dcerpc_binding_handle_call(h,
8131                         NULL, &ndr_table_winreg,
8132                         NDR_WINREG_QUERYMULTIPLEVALUES2, mem_ctx, r);
8133
8134         return status;
8135 }
8136
8137 NTSTATUS dcerpc_winreg_QueryMultipleValues2_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_QueryMultipleValues2 *r)
8138 {
8139         NTSTATUS status;
8140
8141         status = dcerpc_winreg_QueryMultipleValues2_r(p->binding_handle, mem_ctx, r);
8142
8143         if (NT_STATUS_IS_RPC(status)) {
8144                 status = NT_STATUS_NET_WRITE_FAULT;
8145         }
8146
8147         return status;
8148 }
8149
8150 struct dcerpc_winreg_QueryMultipleValues2_state {
8151         struct winreg_QueryMultipleValues2 orig;
8152         struct winreg_QueryMultipleValues2 tmp;
8153         TALLOC_CTX *out_mem_ctx;
8154 };
8155
8156 static void dcerpc_winreg_QueryMultipleValues2_done(struct tevent_req *subreq);
8157
8158 struct tevent_req *dcerpc_winreg_QueryMultipleValues2_send(TALLOC_CTX *mem_ctx,
8159                                                            struct tevent_context *ev,
8160                                                            struct dcerpc_binding_handle *h,
8161                                                            struct policy_handle *_key_handle /* [in] [ref] */,
8162                                                            struct QueryMultipleValue *_values_in /* [in] [ref,length_is(num_values),size_is(num_values)] */,
8163                                                            struct QueryMultipleValue *_values_out /* [out] [ref,length_is(num_values),size_is(num_values)] */,
8164                                                            uint32_t _num_values /* [in]  */,
8165                                                            uint8_t *_buffer /* [in,out] [unique,length_is(*offered),size_is(*offered)] */,
8166                                                            uint32_t *_offered /* [in] [ref] */,
8167                                                            uint32_t *_needed /* [out] [ref] */)
8168 {
8169         struct tevent_req *req;
8170         struct dcerpc_winreg_QueryMultipleValues2_state *state;
8171         struct tevent_req *subreq;
8172
8173         req = tevent_req_create(mem_ctx, &state,
8174                                 struct dcerpc_winreg_QueryMultipleValues2_state);
8175         if (req == NULL) {
8176                 return NULL;
8177         }
8178         state->out_mem_ctx = NULL;
8179
8180         /* In parameters */
8181         state->orig.in.key_handle = _key_handle;
8182         state->orig.in.values_in = _values_in;
8183         state->orig.in.num_values = _num_values;
8184         state->orig.in.buffer = _buffer;
8185         state->orig.in.offered = _offered;
8186
8187         /* Out parameters */
8188         state->orig.out.values_out = _values_out;
8189         state->orig.out.buffer = _buffer;
8190         state->orig.out.needed = _needed;
8191
8192         /* Result */
8193         ZERO_STRUCT(state->orig.out.result);
8194
8195         state->out_mem_ctx = talloc_named_const(state, 0,
8196                              "dcerpc_winreg_QueryMultipleValues2_out_memory");
8197         if (tevent_req_nomem(state->out_mem_ctx, req)) {
8198                 return tevent_req_post(req, ev);
8199         }
8200
8201         /* make a temporary copy, that we pass to the dispatch function */
8202         state->tmp = state->orig;
8203
8204         subreq = dcerpc_winreg_QueryMultipleValues2_r_send(state, ev, h, &state->tmp);
8205         if (tevent_req_nomem(subreq, req)) {
8206                 return tevent_req_post(req, ev);
8207         }
8208         tevent_req_set_callback(subreq, dcerpc_winreg_QueryMultipleValues2_done, req);
8209         return req;
8210 }
8211
8212 static void dcerpc_winreg_QueryMultipleValues2_done(struct tevent_req *subreq)
8213 {
8214         struct tevent_req *req = tevent_req_callback_data(
8215                 subreq, struct tevent_req);
8216         struct dcerpc_winreg_QueryMultipleValues2_state *state = tevent_req_data(
8217                 req, struct dcerpc_winreg_QueryMultipleValues2_state);
8218         NTSTATUS status;
8219         TALLOC_CTX *mem_ctx;
8220
8221         if (state->out_mem_ctx) {
8222                 mem_ctx = state->out_mem_ctx;
8223         } else {
8224                 mem_ctx = state;
8225         }
8226
8227         status = dcerpc_winreg_QueryMultipleValues2_r_recv(subreq, mem_ctx);
8228         TALLOC_FREE(subreq);
8229         if (!NT_STATUS_IS_OK(status)) {
8230                 tevent_req_nterror(req, status);
8231                 return;
8232         }
8233
8234         /* Copy out parameters */
8235         {
8236                 size_t _copy_len_values_out;
8237                 _copy_len_values_out = state->tmp.in.num_values;
8238                 memcpy(state->orig.out.values_out, state->tmp.out.values_out, _copy_len_values_out * sizeof(*state->orig.out.values_out));
8239         }
8240         if (state->orig.out.buffer && state->tmp.out.buffer) {
8241                 {
8242                         size_t _copy_len_buffer;
8243                         _copy_len_buffer = *state->tmp.in.offered;
8244                         memcpy(state->orig.out.buffer, state->tmp.out.buffer, _copy_len_buffer * sizeof(*state->orig.out.buffer));
8245                 }
8246         }
8247         *state->orig.out.needed = *state->tmp.out.needed;
8248
8249         /* Copy result */
8250         state->orig.out.result = state->tmp.out.result;
8251
8252         /* Reset temporary structure */
8253         ZERO_STRUCT(state->tmp);
8254
8255         tevent_req_done(req);
8256 }
8257
8258 NTSTATUS dcerpc_winreg_QueryMultipleValues2_recv(struct tevent_req *req,
8259                                                  TALLOC_CTX *mem_ctx,
8260                                                  WERROR *result)
8261 {
8262         struct dcerpc_winreg_QueryMultipleValues2_state *state = tevent_req_data(
8263                 req, struct dcerpc_winreg_QueryMultipleValues2_state);
8264         NTSTATUS status;
8265
8266         if (tevent_req_is_nterror(req, &status)) {
8267                 tevent_req_received(req);
8268                 return status;
8269         }
8270
8271         /* Steal possible out parameters to the callers context */
8272         talloc_steal(mem_ctx, state->out_mem_ctx);
8273
8274         /* Return result */
8275         *result = state->orig.out.result;
8276
8277         tevent_req_received(req);
8278         return NT_STATUS_OK;
8279 }
8280
8281 NTSTATUS dcerpc_winreg_QueryMultipleValues2(struct dcerpc_binding_handle *h,
8282                                             TALLOC_CTX *mem_ctx,
8283                                             struct policy_handle *_key_handle /* [in] [ref] */,
8284                                             struct QueryMultipleValue *_values_in /* [in] [ref,length_is(num_values),size_is(num_values)] */,
8285                                             struct QueryMultipleValue *_values_out /* [out] [ref,length_is(num_values),size_is(num_values)] */,
8286                                             uint32_t _num_values /* [in]  */,
8287                                             uint8_t *_buffer /* [in,out] [unique,length_is(*offered),size_is(*offered)] */,
8288                                             uint32_t *_offered /* [in] [ref] */,
8289                                             uint32_t *_needed /* [out] [ref] */,
8290                                             WERROR *result)
8291 {
8292         struct winreg_QueryMultipleValues2 r;
8293         NTSTATUS status;
8294
8295         /* In parameters */
8296         r.in.key_handle = _key_handle;
8297         r.in.values_in = _values_in;
8298         r.in.num_values = _num_values;
8299         r.in.buffer = _buffer;
8300         r.in.offered = _offered;
8301
8302         status = dcerpc_winreg_QueryMultipleValues2_r(h, mem_ctx, &r);
8303         if (!NT_STATUS_IS_OK(status)) {
8304                 return status;
8305         }
8306
8307         /* Return variables */
8308         {
8309                 size_t _copy_len_values_out;
8310                 _copy_len_values_out = r.in.num_values;
8311                 memcpy(_values_out, r.out.values_out, _copy_len_values_out * sizeof(*_values_out));
8312         }
8313         if (_buffer && r.out.buffer) {
8314                 {
8315                         size_t _copy_len_buffer;
8316                         _copy_len_buffer = *r.in.offered;
8317                         memcpy(_buffer, r.out.buffer, _copy_len_buffer * sizeof(*_buffer));
8318                 }
8319         }
8320         *_needed = *r.out.needed;
8321
8322         /* Return result */
8323         *result = r.out.result;
8324
8325         return NT_STATUS_OK;
8326 }
8327
8328 struct dcerpc_winreg_DeleteKeyEx_r_state {
8329         TALLOC_CTX *out_mem_ctx;
8330 };
8331
8332 static void dcerpc_winreg_DeleteKeyEx_r_done(struct tevent_req *subreq);
8333
8334 struct tevent_req *dcerpc_winreg_DeleteKeyEx_r_send(TALLOC_CTX *mem_ctx,
8335         struct tevent_context *ev,
8336         struct dcerpc_binding_handle *h,
8337         struct winreg_DeleteKeyEx *r)
8338 {
8339         struct tevent_req *req;
8340         struct dcerpc_winreg_DeleteKeyEx_r_state *state;
8341         struct tevent_req *subreq;
8342
8343         req = tevent_req_create(mem_ctx, &state,
8344                                 struct dcerpc_winreg_DeleteKeyEx_r_state);
8345         if (req == NULL) {
8346                 return NULL;
8347         }
8348
8349         state->out_mem_ctx = NULL;
8350         subreq = dcerpc_binding_handle_call_send(state, ev, h,
8351                         NULL, &ndr_table_winreg,
8352                         NDR_WINREG_DELETEKEYEX, state, r);
8353         if (tevent_req_nomem(subreq, req)) {
8354                 return tevent_req_post(req, ev);
8355         }
8356         tevent_req_set_callback(subreq, dcerpc_winreg_DeleteKeyEx_r_done, req);
8357
8358         return req;
8359 }
8360
8361 static void dcerpc_winreg_DeleteKeyEx_r_done(struct tevent_req *subreq)
8362 {
8363         struct tevent_req *req =
8364                 tevent_req_callback_data(subreq,
8365                 struct tevent_req);
8366         NTSTATUS status;
8367
8368         status = dcerpc_binding_handle_call_recv(subreq);
8369         if (!NT_STATUS_IS_OK(status)) {
8370                 tevent_req_nterror(req, status);
8371                 return;
8372         }
8373
8374         tevent_req_done(req);
8375 }
8376
8377 NTSTATUS dcerpc_winreg_DeleteKeyEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
8378 {
8379         struct dcerpc_winreg_DeleteKeyEx_r_state *state =
8380                 tevent_req_data(req,
8381                 struct dcerpc_winreg_DeleteKeyEx_r_state);
8382         NTSTATUS status;
8383
8384         if (tevent_req_is_nterror(req, &status)) {
8385                 tevent_req_received(req);
8386                 return status;
8387         }
8388
8389         talloc_steal(mem_ctx, state->out_mem_ctx);
8390
8391         tevent_req_received(req);
8392         return NT_STATUS_OK;
8393 }
8394
8395 NTSTATUS dcerpc_winreg_DeleteKeyEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct winreg_DeleteKeyEx *r)
8396 {
8397         NTSTATUS status;
8398
8399         status = dcerpc_binding_handle_call(h,
8400                         NULL, &ndr_table_winreg,
8401                         NDR_WINREG_DELETEKEYEX, mem_ctx, r);
8402
8403         return status;
8404 }
8405
8406 NTSTATUS dcerpc_winreg_DeleteKeyEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_DeleteKeyEx *r)
8407 {
8408         NTSTATUS status;
8409
8410         status = dcerpc_winreg_DeleteKeyEx_r(p->binding_handle, mem_ctx, r);
8411
8412         if (NT_STATUS_IS_RPC(status)) {
8413                 status = NT_STATUS_NET_WRITE_FAULT;
8414         }
8415
8416         return status;
8417 }
8418
8419 struct dcerpc_winreg_DeleteKeyEx_state {
8420         struct winreg_DeleteKeyEx orig;
8421         struct winreg_DeleteKeyEx tmp;
8422         TALLOC_CTX *out_mem_ctx;
8423 };
8424
8425 static void dcerpc_winreg_DeleteKeyEx_done(struct tevent_req *subreq);
8426
8427 struct tevent_req *dcerpc_winreg_DeleteKeyEx_send(TALLOC_CTX *mem_ctx,
8428                                                   struct tevent_context *ev,
8429                                                   struct dcerpc_binding_handle *h,
8430                                                   struct policy_handle *_handle /* [in] [ref] */,
8431                                                   struct winreg_String *_key /* [in] [ref] */,
8432                                                   uint32_t _access_mask /* [in]  */,
8433                                                   uint32_t _reserved /* [in]  */)
8434 {
8435         struct tevent_req *req;
8436         struct dcerpc_winreg_DeleteKeyEx_state *state;
8437         struct tevent_req *subreq;
8438
8439         req = tevent_req_create(mem_ctx, &state,
8440                                 struct dcerpc_winreg_DeleteKeyEx_state);
8441         if (req == NULL) {
8442                 return NULL;
8443         }
8444         state->out_mem_ctx = NULL;
8445
8446         /* In parameters */
8447         state->orig.in.handle = _handle;
8448         state->orig.in.key = _key;
8449         state->orig.in.access_mask = _access_mask;
8450         state->orig.in.reserved = _reserved;
8451
8452         /* Out parameters */
8453
8454         /* Result */
8455         ZERO_STRUCT(state->orig.out.result);
8456
8457         /* make a temporary copy, that we pass to the dispatch function */
8458         state->tmp = state->orig;
8459
8460         subreq = dcerpc_winreg_DeleteKeyEx_r_send(state, ev, h, &state->tmp);
8461         if (tevent_req_nomem(subreq, req)) {
8462                 return tevent_req_post(req, ev);
8463         }
8464         tevent_req_set_callback(subreq, dcerpc_winreg_DeleteKeyEx_done, req);
8465         return req;
8466 }
8467
8468 static void dcerpc_winreg_DeleteKeyEx_done(struct tevent_req *subreq)
8469 {
8470         struct tevent_req *req = tevent_req_callback_data(
8471                 subreq, struct tevent_req);
8472         struct dcerpc_winreg_DeleteKeyEx_state *state = tevent_req_data(
8473                 req, struct dcerpc_winreg_DeleteKeyEx_state);
8474         NTSTATUS status;
8475         TALLOC_CTX *mem_ctx;
8476
8477         if (state->out_mem_ctx) {
8478                 mem_ctx = state->out_mem_ctx;
8479         } else {
8480                 mem_ctx = state;
8481         }
8482
8483         status = dcerpc_winreg_DeleteKeyEx_r_recv(subreq, mem_ctx);
8484         TALLOC_FREE(subreq);
8485         if (!NT_STATUS_IS_OK(status)) {
8486                 tevent_req_nterror(req, status);
8487                 return;
8488         }
8489
8490         /* Copy out parameters */
8491
8492         /* Copy result */
8493         state->orig.out.result = state->tmp.out.result;
8494
8495         /* Reset temporary structure */
8496         ZERO_STRUCT(state->tmp);
8497
8498         tevent_req_done(req);
8499 }
8500
8501 NTSTATUS dcerpc_winreg_DeleteKeyEx_recv(struct tevent_req *req,
8502                                         TALLOC_CTX *mem_ctx,
8503                                         WERROR *result)
8504 {
8505         struct dcerpc_winreg_DeleteKeyEx_state *state = tevent_req_data(
8506                 req, struct dcerpc_winreg_DeleteKeyEx_state);
8507         NTSTATUS status;
8508
8509         if (tevent_req_is_nterror(req, &status)) {
8510                 tevent_req_received(req);
8511                 return status;
8512         }
8513
8514         /* Steal possible out parameters to the callers context */
8515         talloc_steal(mem_ctx, state->out_mem_ctx);
8516
8517         /* Return result */
8518         *result = state->orig.out.result;
8519
8520         tevent_req_received(req);
8521         return NT_STATUS_OK;
8522 }
8523
8524 NTSTATUS dcerpc_winreg_DeleteKeyEx(struct dcerpc_binding_handle *h,
8525                                    TALLOC_CTX *mem_ctx,
8526                                    struct policy_handle *_handle /* [in] [ref] */,
8527                                    struct winreg_String *_key /* [in] [ref] */,
8528                                    uint32_t _access_mask /* [in]  */,
8529                                    uint32_t _reserved /* [in]  */,
8530                                    WERROR *result)
8531 {
8532         struct winreg_DeleteKeyEx r;
8533         NTSTATUS status;
8534
8535         /* In parameters */
8536         r.in.handle = _handle;
8537         r.in.key = _key;
8538         r.in.access_mask = _access_mask;
8539         r.in.reserved = _reserved;
8540
8541         status = dcerpc_winreg_DeleteKeyEx_r(h, mem_ctx, &r);
8542         if (!NT_STATUS_IS_OK(status)) {
8543                 return status;
8544         }
8545
8546         /* Return variables */
8547
8548         /* Return result */
8549         *result = r.out.result;
8550
8551         return NT_STATUS_OK;
8552 }
8553