librpc/gen_ndr
[metze/samba/wip.git] / source3 / librpc / gen_ndr / ndr_winreg_s.c
1 /* server functions auto-generated by pidl */
2 #include "librpc/gen_ndr/ndr_winreg.h"
3
4 /* winreg - dcerpc server boilerplate generated by pidl */
5
6
7 static NTSTATUS winreg__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface, uint32_t if_version)
8 {
9 #ifdef DCESRV_INTERFACE_WINREG_BIND
10         return DCESRV_INTERFACE_WINREG_BIND(dce_call,iface);
11 #else
12         return NT_STATUS_OK;
13 #endif
14 }
15
16 static void winreg__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
17 {
18 #ifdef DCESRV_INTERFACE_WINREG_UNBIND
19         DCESRV_INTERFACE_WINREG_UNBIND(context, iface);
20 #else
21         return;
22 #endif
23 }
24
25 static NTSTATUS winreg__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
26 {
27         enum ndr_err_code ndr_err;
28         uint16_t opnum = dce_call->pkt.u.request.opnum;
29
30         dce_call->fault_code = 0;
31
32         if (opnum >= ndr_table_winreg.num_calls) {
33                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
34                 return NT_STATUS_NET_WRITE_FAULT;
35         }
36
37         *r = talloc_named(mem_ctx,
38                           ndr_table_winreg.calls[opnum].struct_size,
39                           "struct %s",
40                           ndr_table_winreg.calls[opnum].name);
41         NT_STATUS_HAVE_NO_MEMORY(*r);
42
43         /* unravel the NDR for the packet */
44         ndr_err = ndr_table_winreg.calls[opnum].ndr_pull(pull, NDR_IN, *r);
45         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
46                 dcerpc_log_packet(dce_call->conn->packet_log_dir, 
47                                   &ndr_table_winreg, opnum, NDR_IN,
48                                   &dce_call->pkt.u.request.stub_and_verifier);
49                 dce_call->fault_code = DCERPC_FAULT_NDR;
50                 return NT_STATUS_NET_WRITE_FAULT;
51         }
52
53         return NT_STATUS_OK;
54 }
55
56 static NTSTATUS winreg__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
57 {
58         uint16_t opnum = dce_call->pkt.u.request.opnum;
59
60         switch (opnum) {
61         case 0: {
62                 struct winreg_OpenHKCR *r2 = (struct winreg_OpenHKCR *)r;
63                 if (DEBUGLEVEL >= 10) {
64                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKCR, NDR_IN, r2);
65                 }
66                 r2->out.result = dcesrv_winreg_OpenHKCR(dce_call, mem_ctx, r2);
67                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
68                         DEBUG(5,("function winreg_OpenHKCR will reply async\n"));
69                 }
70                 break;
71         }
72         case 1: {
73                 struct winreg_OpenHKCU *r2 = (struct winreg_OpenHKCU *)r;
74                 if (DEBUGLEVEL >= 10) {
75                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKCU, NDR_IN, r2);
76                 }
77                 r2->out.result = dcesrv_winreg_OpenHKCU(dce_call, mem_ctx, r2);
78                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
79                         DEBUG(5,("function winreg_OpenHKCU will reply async\n"));
80                 }
81                 break;
82         }
83         case 2: {
84                 struct winreg_OpenHKLM *r2 = (struct winreg_OpenHKLM *)r;
85                 if (DEBUGLEVEL >= 10) {
86                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKLM, NDR_IN, r2);
87                 }
88                 r2->out.result = dcesrv_winreg_OpenHKLM(dce_call, mem_ctx, r2);
89                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
90                         DEBUG(5,("function winreg_OpenHKLM will reply async\n"));
91                 }
92                 break;
93         }
94         case 3: {
95                 struct winreg_OpenHKPD *r2 = (struct winreg_OpenHKPD *)r;
96                 if (DEBUGLEVEL >= 10) {
97                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKPD, NDR_IN, r2);
98                 }
99                 r2->out.result = dcesrv_winreg_OpenHKPD(dce_call, mem_ctx, r2);
100                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
101                         DEBUG(5,("function winreg_OpenHKPD will reply async\n"));
102                 }
103                 break;
104         }
105         case 4: {
106                 struct winreg_OpenHKU *r2 = (struct winreg_OpenHKU *)r;
107                 if (DEBUGLEVEL >= 10) {
108                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKU, NDR_IN, r2);
109                 }
110                 r2->out.result = dcesrv_winreg_OpenHKU(dce_call, mem_ctx, r2);
111                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
112                         DEBUG(5,("function winreg_OpenHKU will reply async\n"));
113                 }
114                 break;
115         }
116         case 5: {
117                 struct winreg_CloseKey *r2 = (struct winreg_CloseKey *)r;
118                 if (DEBUGLEVEL >= 10) {
119                         NDR_PRINT_FUNCTION_DEBUG(winreg_CloseKey, NDR_IN, r2);
120                 }
121                 r2->out.result = dcesrv_winreg_CloseKey(dce_call, mem_ctx, r2);
122                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
123                         DEBUG(5,("function winreg_CloseKey will reply async\n"));
124                 }
125                 break;
126         }
127         case 6: {
128                 struct winreg_CreateKey *r2 = (struct winreg_CreateKey *)r;
129                 if (DEBUGLEVEL >= 10) {
130                         NDR_PRINT_FUNCTION_DEBUG(winreg_CreateKey, NDR_IN, r2);
131                 }
132                 r2->out.result = dcesrv_winreg_CreateKey(dce_call, mem_ctx, r2);
133                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
134                         DEBUG(5,("function winreg_CreateKey will reply async\n"));
135                 }
136                 break;
137         }
138         case 7: {
139                 struct winreg_DeleteKey *r2 = (struct winreg_DeleteKey *)r;
140                 if (DEBUGLEVEL >= 10) {
141                         NDR_PRINT_FUNCTION_DEBUG(winreg_DeleteKey, NDR_IN, r2);
142                 }
143                 r2->out.result = dcesrv_winreg_DeleteKey(dce_call, mem_ctx, r2);
144                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
145                         DEBUG(5,("function winreg_DeleteKey will reply async\n"));
146                 }
147                 break;
148         }
149         case 8: {
150                 struct winreg_DeleteValue *r2 = (struct winreg_DeleteValue *)r;
151                 if (DEBUGLEVEL >= 10) {
152                         NDR_PRINT_FUNCTION_DEBUG(winreg_DeleteValue, NDR_IN, r2);
153                 }
154                 r2->out.result = dcesrv_winreg_DeleteValue(dce_call, mem_ctx, r2);
155                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
156                         DEBUG(5,("function winreg_DeleteValue will reply async\n"));
157                 }
158                 break;
159         }
160         case 9: {
161                 struct winreg_EnumKey *r2 = (struct winreg_EnumKey *)r;
162                 if (DEBUGLEVEL >= 10) {
163                         NDR_PRINT_FUNCTION_DEBUG(winreg_EnumKey, NDR_IN, r2);
164                 }
165                 r2->out.result = dcesrv_winreg_EnumKey(dce_call, mem_ctx, r2);
166                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
167                         DEBUG(5,("function winreg_EnumKey will reply async\n"));
168                 }
169                 break;
170         }
171         case 10: {
172                 struct winreg_EnumValue *r2 = (struct winreg_EnumValue *)r;
173                 if (DEBUGLEVEL >= 10) {
174                         NDR_PRINT_FUNCTION_DEBUG(winreg_EnumValue, NDR_IN, r2);
175                 }
176                 r2->out.result = dcesrv_winreg_EnumValue(dce_call, mem_ctx, r2);
177                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
178                         DEBUG(5,("function winreg_EnumValue will reply async\n"));
179                 }
180                 break;
181         }
182         case 11: {
183                 struct winreg_FlushKey *r2 = (struct winreg_FlushKey *)r;
184                 if (DEBUGLEVEL >= 10) {
185                         NDR_PRINT_FUNCTION_DEBUG(winreg_FlushKey, NDR_IN, r2);
186                 }
187                 r2->out.result = dcesrv_winreg_FlushKey(dce_call, mem_ctx, r2);
188                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
189                         DEBUG(5,("function winreg_FlushKey will reply async\n"));
190                 }
191                 break;
192         }
193         case 12: {
194                 struct winreg_GetKeySecurity *r2 = (struct winreg_GetKeySecurity *)r;
195                 if (DEBUGLEVEL >= 10) {
196                         NDR_PRINT_FUNCTION_DEBUG(winreg_GetKeySecurity, NDR_IN, r2);
197                 }
198                 r2->out.result = dcesrv_winreg_GetKeySecurity(dce_call, mem_ctx, r2);
199                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
200                         DEBUG(5,("function winreg_GetKeySecurity will reply async\n"));
201                 }
202                 break;
203         }
204         case 13: {
205                 struct winreg_LoadKey *r2 = (struct winreg_LoadKey *)r;
206                 if (DEBUGLEVEL >= 10) {
207                         NDR_PRINT_FUNCTION_DEBUG(winreg_LoadKey, NDR_IN, r2);
208                 }
209                 r2->out.result = dcesrv_winreg_LoadKey(dce_call, mem_ctx, r2);
210                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
211                         DEBUG(5,("function winreg_LoadKey will reply async\n"));
212                 }
213                 break;
214         }
215         case 14: {
216                 struct winreg_NotifyChangeKeyValue *r2 = (struct winreg_NotifyChangeKeyValue *)r;
217                 if (DEBUGLEVEL >= 10) {
218                         NDR_PRINT_FUNCTION_DEBUG(winreg_NotifyChangeKeyValue, NDR_IN, r2);
219                 }
220                 r2->out.result = dcesrv_winreg_NotifyChangeKeyValue(dce_call, mem_ctx, r2);
221                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
222                         DEBUG(5,("function winreg_NotifyChangeKeyValue will reply async\n"));
223                 }
224                 break;
225         }
226         case 15: {
227                 struct winreg_OpenKey *r2 = (struct winreg_OpenKey *)r;
228                 if (DEBUGLEVEL >= 10) {
229                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenKey, NDR_IN, r2);
230                 }
231                 r2->out.result = dcesrv_winreg_OpenKey(dce_call, mem_ctx, r2);
232                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
233                         DEBUG(5,("function winreg_OpenKey will reply async\n"));
234                 }
235                 break;
236         }
237         case 16: {
238                 struct winreg_QueryInfoKey *r2 = (struct winreg_QueryInfoKey *)r;
239                 if (DEBUGLEVEL >= 10) {
240                         NDR_PRINT_FUNCTION_DEBUG(winreg_QueryInfoKey, NDR_IN, r2);
241                 }
242                 r2->out.result = dcesrv_winreg_QueryInfoKey(dce_call, mem_ctx, r2);
243                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
244                         DEBUG(5,("function winreg_QueryInfoKey will reply async\n"));
245                 }
246                 break;
247         }
248         case 17: {
249                 struct winreg_QueryValue *r2 = (struct winreg_QueryValue *)r;
250                 if (DEBUGLEVEL >= 10) {
251                         NDR_PRINT_FUNCTION_DEBUG(winreg_QueryValue, NDR_IN, r2);
252                 }
253                 r2->out.result = dcesrv_winreg_QueryValue(dce_call, mem_ctx, r2);
254                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
255                         DEBUG(5,("function winreg_QueryValue will reply async\n"));
256                 }
257                 break;
258         }
259         case 18: {
260                 struct winreg_ReplaceKey *r2 = (struct winreg_ReplaceKey *)r;
261                 if (DEBUGLEVEL >= 10) {
262                         NDR_PRINT_FUNCTION_DEBUG(winreg_ReplaceKey, NDR_IN, r2);
263                 }
264                 r2->out.result = dcesrv_winreg_ReplaceKey(dce_call, mem_ctx, r2);
265                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
266                         DEBUG(5,("function winreg_ReplaceKey will reply async\n"));
267                 }
268                 break;
269         }
270         case 19: {
271                 struct winreg_RestoreKey *r2 = (struct winreg_RestoreKey *)r;
272                 if (DEBUGLEVEL >= 10) {
273                         NDR_PRINT_FUNCTION_DEBUG(winreg_RestoreKey, NDR_IN, r2);
274                 }
275                 r2->out.result = dcesrv_winreg_RestoreKey(dce_call, mem_ctx, r2);
276                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
277                         DEBUG(5,("function winreg_RestoreKey will reply async\n"));
278                 }
279                 break;
280         }
281         case 20: {
282                 struct winreg_SaveKey *r2 = (struct winreg_SaveKey *)r;
283                 if (DEBUGLEVEL >= 10) {
284                         NDR_PRINT_FUNCTION_DEBUG(winreg_SaveKey, NDR_IN, r2);
285                 }
286                 r2->out.result = dcesrv_winreg_SaveKey(dce_call, mem_ctx, r2);
287                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
288                         DEBUG(5,("function winreg_SaveKey will reply async\n"));
289                 }
290                 break;
291         }
292         case 21: {
293                 struct winreg_SetKeySecurity *r2 = (struct winreg_SetKeySecurity *)r;
294                 if (DEBUGLEVEL >= 10) {
295                         NDR_PRINT_FUNCTION_DEBUG(winreg_SetKeySecurity, NDR_IN, r2);
296                 }
297                 r2->out.result = dcesrv_winreg_SetKeySecurity(dce_call, mem_ctx, r2);
298                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
299                         DEBUG(5,("function winreg_SetKeySecurity will reply async\n"));
300                 }
301                 break;
302         }
303         case 22: {
304                 struct winreg_SetValue *r2 = (struct winreg_SetValue *)r;
305                 if (DEBUGLEVEL >= 10) {
306                         NDR_PRINT_FUNCTION_DEBUG(winreg_SetValue, NDR_IN, r2);
307                 }
308                 r2->out.result = dcesrv_winreg_SetValue(dce_call, mem_ctx, r2);
309                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
310                         DEBUG(5,("function winreg_SetValue will reply async\n"));
311                 }
312                 break;
313         }
314         case 23: {
315                 struct winreg_UnLoadKey *r2 = (struct winreg_UnLoadKey *)r;
316                 if (DEBUGLEVEL >= 10) {
317                         NDR_PRINT_FUNCTION_DEBUG(winreg_UnLoadKey, NDR_IN, r2);
318                 }
319                 r2->out.result = dcesrv_winreg_UnLoadKey(dce_call, mem_ctx, r2);
320                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
321                         DEBUG(5,("function winreg_UnLoadKey will reply async\n"));
322                 }
323                 break;
324         }
325         case 24: {
326                 struct winreg_InitiateSystemShutdown *r2 = (struct winreg_InitiateSystemShutdown *)r;
327                 if (DEBUGLEVEL >= 10) {
328                         NDR_PRINT_FUNCTION_DEBUG(winreg_InitiateSystemShutdown, NDR_IN, r2);
329                 }
330                 r2->out.result = dcesrv_winreg_InitiateSystemShutdown(dce_call, mem_ctx, r2);
331                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
332                         DEBUG(5,("function winreg_InitiateSystemShutdown will reply async\n"));
333                 }
334                 break;
335         }
336         case 25: {
337                 struct winreg_AbortSystemShutdown *r2 = (struct winreg_AbortSystemShutdown *)r;
338                 if (DEBUGLEVEL >= 10) {
339                         NDR_PRINT_FUNCTION_DEBUG(winreg_AbortSystemShutdown, NDR_IN, r2);
340                 }
341                 r2->out.result = dcesrv_winreg_AbortSystemShutdown(dce_call, mem_ctx, r2);
342                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
343                         DEBUG(5,("function winreg_AbortSystemShutdown will reply async\n"));
344                 }
345                 break;
346         }
347         case 26: {
348                 struct winreg_GetVersion *r2 = (struct winreg_GetVersion *)r;
349                 if (DEBUGLEVEL >= 10) {
350                         NDR_PRINT_FUNCTION_DEBUG(winreg_GetVersion, NDR_IN, r2);
351                 }
352                 r2->out.result = dcesrv_winreg_GetVersion(dce_call, mem_ctx, r2);
353                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
354                         DEBUG(5,("function winreg_GetVersion will reply async\n"));
355                 }
356                 break;
357         }
358         case 27: {
359                 struct winreg_OpenHKCC *r2 = (struct winreg_OpenHKCC *)r;
360                 if (DEBUGLEVEL >= 10) {
361                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKCC, NDR_IN, r2);
362                 }
363                 r2->out.result = dcesrv_winreg_OpenHKCC(dce_call, mem_ctx, r2);
364                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
365                         DEBUG(5,("function winreg_OpenHKCC will reply async\n"));
366                 }
367                 break;
368         }
369         case 28: {
370                 struct winreg_OpenHKDD *r2 = (struct winreg_OpenHKDD *)r;
371                 if (DEBUGLEVEL >= 10) {
372                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKDD, NDR_IN, r2);
373                 }
374                 r2->out.result = dcesrv_winreg_OpenHKDD(dce_call, mem_ctx, r2);
375                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
376                         DEBUG(5,("function winreg_OpenHKDD will reply async\n"));
377                 }
378                 break;
379         }
380         case 29: {
381                 struct winreg_QueryMultipleValues *r2 = (struct winreg_QueryMultipleValues *)r;
382                 if (DEBUGLEVEL >= 10) {
383                         NDR_PRINT_FUNCTION_DEBUG(winreg_QueryMultipleValues, NDR_IN, r2);
384                 }
385                 r2->out.result = dcesrv_winreg_QueryMultipleValues(dce_call, mem_ctx, r2);
386                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
387                         DEBUG(5,("function winreg_QueryMultipleValues will reply async\n"));
388                 }
389                 break;
390         }
391         case 30: {
392                 struct winreg_InitiateSystemShutdownEx *r2 = (struct winreg_InitiateSystemShutdownEx *)r;
393                 if (DEBUGLEVEL >= 10) {
394                         NDR_PRINT_FUNCTION_DEBUG(winreg_InitiateSystemShutdownEx, NDR_IN, r2);
395                 }
396                 r2->out.result = dcesrv_winreg_InitiateSystemShutdownEx(dce_call, mem_ctx, r2);
397                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
398                         DEBUG(5,("function winreg_InitiateSystemShutdownEx will reply async\n"));
399                 }
400                 break;
401         }
402         case 31: {
403                 struct winreg_SaveKeyEx *r2 = (struct winreg_SaveKeyEx *)r;
404                 if (DEBUGLEVEL >= 10) {
405                         NDR_PRINT_FUNCTION_DEBUG(winreg_SaveKeyEx, NDR_IN, r2);
406                 }
407                 r2->out.result = dcesrv_winreg_SaveKeyEx(dce_call, mem_ctx, r2);
408                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
409                         DEBUG(5,("function winreg_SaveKeyEx will reply async\n"));
410                 }
411                 break;
412         }
413         case 32: {
414                 struct winreg_OpenHKPT *r2 = (struct winreg_OpenHKPT *)r;
415                 if (DEBUGLEVEL >= 10) {
416                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKPT, NDR_IN, r2);
417                 }
418                 r2->out.result = dcesrv_winreg_OpenHKPT(dce_call, mem_ctx, r2);
419                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
420                         DEBUG(5,("function winreg_OpenHKPT will reply async\n"));
421                 }
422                 break;
423         }
424         case 33: {
425                 struct winreg_OpenHKPN *r2 = (struct winreg_OpenHKPN *)r;
426                 if (DEBUGLEVEL >= 10) {
427                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKPN, NDR_IN, r2);
428                 }
429                 r2->out.result = dcesrv_winreg_OpenHKPN(dce_call, mem_ctx, r2);
430                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
431                         DEBUG(5,("function winreg_OpenHKPN will reply async\n"));
432                 }
433                 break;
434         }
435         case 34: {
436                 struct winreg_QueryMultipleValues2 *r2 = (struct winreg_QueryMultipleValues2 *)r;
437                 if (DEBUGLEVEL >= 10) {
438                         NDR_PRINT_FUNCTION_DEBUG(winreg_QueryMultipleValues2, NDR_IN, r2);
439                 }
440                 r2->out.result = dcesrv_winreg_QueryMultipleValues2(dce_call, mem_ctx, r2);
441                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
442                         DEBUG(5,("function winreg_QueryMultipleValues2 will reply async\n"));
443                 }
444                 break;
445         }
446         case 35: {
447                 struct winreg_DeleteKeyEx *r2 = (struct winreg_DeleteKeyEx *)r;
448                 if (DEBUGLEVEL >= 10) {
449                         NDR_PRINT_FUNCTION_DEBUG(winreg_DeleteKeyEx, NDR_IN, r2);
450                 }
451                 r2->out.result = dcesrv_winreg_DeleteKeyEx(dce_call, mem_ctx, r2);
452                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
453                         DEBUG(5,("function winreg_DeleteKeyEx will reply async\n"));
454                 }
455                 break;
456         }
457
458         default:
459                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
460                 break;
461         }
462
463         if (dce_call->fault_code != 0) {
464                 dcerpc_log_packet(dce_call->conn->packet_log_dir, 
465                           &ndr_table_winreg, opnum, NDR_IN,
466                                   &dce_call->pkt.u.request.stub_and_verifier);
467                 return NT_STATUS_NET_WRITE_FAULT;
468         }
469
470         return NT_STATUS_OK;
471 }
472
473 static NTSTATUS winreg__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
474 {
475         uint16_t opnum = dce_call->pkt.u.request.opnum;
476
477         switch (opnum) {
478         case 0: {
479                 struct winreg_OpenHKCR *r2 = (struct winreg_OpenHKCR *)r;
480                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
481                         DEBUG(5,("function winreg_OpenHKCR replied async\n"));
482                 }
483                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
484                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKCR, NDR_OUT | NDR_SET_VALUES, r2);
485                 }
486                 if (dce_call->fault_code != 0) {
487                         DEBUG(2,("dcerpc_fault %s in winreg_OpenHKCR\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
488                 }
489                 break;
490         }
491         case 1: {
492                 struct winreg_OpenHKCU *r2 = (struct winreg_OpenHKCU *)r;
493                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
494                         DEBUG(5,("function winreg_OpenHKCU replied async\n"));
495                 }
496                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
497                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKCU, NDR_OUT | NDR_SET_VALUES, r2);
498                 }
499                 if (dce_call->fault_code != 0) {
500                         DEBUG(2,("dcerpc_fault %s in winreg_OpenHKCU\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
501                 }
502                 break;
503         }
504         case 2: {
505                 struct winreg_OpenHKLM *r2 = (struct winreg_OpenHKLM *)r;
506                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
507                         DEBUG(5,("function winreg_OpenHKLM replied async\n"));
508                 }
509                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
510                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKLM, NDR_OUT | NDR_SET_VALUES, r2);
511                 }
512                 if (dce_call->fault_code != 0) {
513                         DEBUG(2,("dcerpc_fault %s in winreg_OpenHKLM\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
514                 }
515                 break;
516         }
517         case 3: {
518                 struct winreg_OpenHKPD *r2 = (struct winreg_OpenHKPD *)r;
519                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
520                         DEBUG(5,("function winreg_OpenHKPD replied async\n"));
521                 }
522                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
523                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKPD, NDR_OUT | NDR_SET_VALUES, r2);
524                 }
525                 if (dce_call->fault_code != 0) {
526                         DEBUG(2,("dcerpc_fault %s in winreg_OpenHKPD\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
527                 }
528                 break;
529         }
530         case 4: {
531                 struct winreg_OpenHKU *r2 = (struct winreg_OpenHKU *)r;
532                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
533                         DEBUG(5,("function winreg_OpenHKU replied async\n"));
534                 }
535                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
536                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKU, NDR_OUT | NDR_SET_VALUES, r2);
537                 }
538                 if (dce_call->fault_code != 0) {
539                         DEBUG(2,("dcerpc_fault %s in winreg_OpenHKU\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
540                 }
541                 break;
542         }
543         case 5: {
544                 struct winreg_CloseKey *r2 = (struct winreg_CloseKey *)r;
545                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
546                         DEBUG(5,("function winreg_CloseKey replied async\n"));
547                 }
548                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
549                         NDR_PRINT_FUNCTION_DEBUG(winreg_CloseKey, NDR_OUT | NDR_SET_VALUES, r2);
550                 }
551                 if (dce_call->fault_code != 0) {
552                         DEBUG(2,("dcerpc_fault %s in winreg_CloseKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
553                 }
554                 break;
555         }
556         case 6: {
557                 struct winreg_CreateKey *r2 = (struct winreg_CreateKey *)r;
558                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
559                         DEBUG(5,("function winreg_CreateKey replied async\n"));
560                 }
561                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
562                         NDR_PRINT_FUNCTION_DEBUG(winreg_CreateKey, NDR_OUT | NDR_SET_VALUES, r2);
563                 }
564                 if (dce_call->fault_code != 0) {
565                         DEBUG(2,("dcerpc_fault %s in winreg_CreateKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
566                 }
567                 break;
568         }
569         case 7: {
570                 struct winreg_DeleteKey *r2 = (struct winreg_DeleteKey *)r;
571                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
572                         DEBUG(5,("function winreg_DeleteKey replied async\n"));
573                 }
574                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
575                         NDR_PRINT_FUNCTION_DEBUG(winreg_DeleteKey, NDR_OUT | NDR_SET_VALUES, r2);
576                 }
577                 if (dce_call->fault_code != 0) {
578                         DEBUG(2,("dcerpc_fault %s in winreg_DeleteKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
579                 }
580                 break;
581         }
582         case 8: {
583                 struct winreg_DeleteValue *r2 = (struct winreg_DeleteValue *)r;
584                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
585                         DEBUG(5,("function winreg_DeleteValue replied async\n"));
586                 }
587                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
588                         NDR_PRINT_FUNCTION_DEBUG(winreg_DeleteValue, NDR_OUT | NDR_SET_VALUES, r2);
589                 }
590                 if (dce_call->fault_code != 0) {
591                         DEBUG(2,("dcerpc_fault %s in winreg_DeleteValue\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
592                 }
593                 break;
594         }
595         case 9: {
596                 struct winreg_EnumKey *r2 = (struct winreg_EnumKey *)r;
597                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
598                         DEBUG(5,("function winreg_EnumKey replied async\n"));
599                 }
600                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
601                         NDR_PRINT_FUNCTION_DEBUG(winreg_EnumKey, NDR_OUT | NDR_SET_VALUES, r2);
602                 }
603                 if (dce_call->fault_code != 0) {
604                         DEBUG(2,("dcerpc_fault %s in winreg_EnumKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
605                 }
606                 break;
607         }
608         case 10: {
609                 struct winreg_EnumValue *r2 = (struct winreg_EnumValue *)r;
610                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
611                         DEBUG(5,("function winreg_EnumValue replied async\n"));
612                 }
613                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
614                         NDR_PRINT_FUNCTION_DEBUG(winreg_EnumValue, NDR_OUT | NDR_SET_VALUES, r2);
615                 }
616                 if (dce_call->fault_code != 0) {
617                         DEBUG(2,("dcerpc_fault %s in winreg_EnumValue\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
618                 }
619                 break;
620         }
621         case 11: {
622                 struct winreg_FlushKey *r2 = (struct winreg_FlushKey *)r;
623                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
624                         DEBUG(5,("function winreg_FlushKey replied async\n"));
625                 }
626                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
627                         NDR_PRINT_FUNCTION_DEBUG(winreg_FlushKey, NDR_OUT | NDR_SET_VALUES, r2);
628                 }
629                 if (dce_call->fault_code != 0) {
630                         DEBUG(2,("dcerpc_fault %s in winreg_FlushKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
631                 }
632                 break;
633         }
634         case 12: {
635                 struct winreg_GetKeySecurity *r2 = (struct winreg_GetKeySecurity *)r;
636                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
637                         DEBUG(5,("function winreg_GetKeySecurity replied async\n"));
638                 }
639                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
640                         NDR_PRINT_FUNCTION_DEBUG(winreg_GetKeySecurity, NDR_OUT | NDR_SET_VALUES, r2);
641                 }
642                 if (dce_call->fault_code != 0) {
643                         DEBUG(2,("dcerpc_fault %s in winreg_GetKeySecurity\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
644                 }
645                 break;
646         }
647         case 13: {
648                 struct winreg_LoadKey *r2 = (struct winreg_LoadKey *)r;
649                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
650                         DEBUG(5,("function winreg_LoadKey replied async\n"));
651                 }
652                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
653                         NDR_PRINT_FUNCTION_DEBUG(winreg_LoadKey, NDR_OUT | NDR_SET_VALUES, r2);
654                 }
655                 if (dce_call->fault_code != 0) {
656                         DEBUG(2,("dcerpc_fault %s in winreg_LoadKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
657                 }
658                 break;
659         }
660         case 14: {
661                 struct winreg_NotifyChangeKeyValue *r2 = (struct winreg_NotifyChangeKeyValue *)r;
662                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
663                         DEBUG(5,("function winreg_NotifyChangeKeyValue replied async\n"));
664                 }
665                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
666                         NDR_PRINT_FUNCTION_DEBUG(winreg_NotifyChangeKeyValue, NDR_OUT | NDR_SET_VALUES, r2);
667                 }
668                 if (dce_call->fault_code != 0) {
669                         DEBUG(2,("dcerpc_fault %s in winreg_NotifyChangeKeyValue\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
670                 }
671                 break;
672         }
673         case 15: {
674                 struct winreg_OpenKey *r2 = (struct winreg_OpenKey *)r;
675                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
676                         DEBUG(5,("function winreg_OpenKey replied async\n"));
677                 }
678                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
679                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenKey, NDR_OUT | NDR_SET_VALUES, r2);
680                 }
681                 if (dce_call->fault_code != 0) {
682                         DEBUG(2,("dcerpc_fault %s in winreg_OpenKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
683                 }
684                 break;
685         }
686         case 16: {
687                 struct winreg_QueryInfoKey *r2 = (struct winreg_QueryInfoKey *)r;
688                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
689                         DEBUG(5,("function winreg_QueryInfoKey replied async\n"));
690                 }
691                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
692                         NDR_PRINT_FUNCTION_DEBUG(winreg_QueryInfoKey, NDR_OUT | NDR_SET_VALUES, r2);
693                 }
694                 if (dce_call->fault_code != 0) {
695                         DEBUG(2,("dcerpc_fault %s in winreg_QueryInfoKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
696                 }
697                 break;
698         }
699         case 17: {
700                 struct winreg_QueryValue *r2 = (struct winreg_QueryValue *)r;
701                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
702                         DEBUG(5,("function winreg_QueryValue replied async\n"));
703                 }
704                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
705                         NDR_PRINT_FUNCTION_DEBUG(winreg_QueryValue, NDR_OUT | NDR_SET_VALUES, r2);
706                 }
707                 if (dce_call->fault_code != 0) {
708                         DEBUG(2,("dcerpc_fault %s in winreg_QueryValue\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
709                 }
710                 break;
711         }
712         case 18: {
713                 struct winreg_ReplaceKey *r2 = (struct winreg_ReplaceKey *)r;
714                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
715                         DEBUG(5,("function winreg_ReplaceKey replied async\n"));
716                 }
717                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
718                         NDR_PRINT_FUNCTION_DEBUG(winreg_ReplaceKey, NDR_OUT | NDR_SET_VALUES, r2);
719                 }
720                 if (dce_call->fault_code != 0) {
721                         DEBUG(2,("dcerpc_fault %s in winreg_ReplaceKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
722                 }
723                 break;
724         }
725         case 19: {
726                 struct winreg_RestoreKey *r2 = (struct winreg_RestoreKey *)r;
727                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
728                         DEBUG(5,("function winreg_RestoreKey replied async\n"));
729                 }
730                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
731                         NDR_PRINT_FUNCTION_DEBUG(winreg_RestoreKey, NDR_OUT | NDR_SET_VALUES, r2);
732                 }
733                 if (dce_call->fault_code != 0) {
734                         DEBUG(2,("dcerpc_fault %s in winreg_RestoreKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
735                 }
736                 break;
737         }
738         case 20: {
739                 struct winreg_SaveKey *r2 = (struct winreg_SaveKey *)r;
740                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
741                         DEBUG(5,("function winreg_SaveKey replied async\n"));
742                 }
743                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
744                         NDR_PRINT_FUNCTION_DEBUG(winreg_SaveKey, NDR_OUT | NDR_SET_VALUES, r2);
745                 }
746                 if (dce_call->fault_code != 0) {
747                         DEBUG(2,("dcerpc_fault %s in winreg_SaveKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
748                 }
749                 break;
750         }
751         case 21: {
752                 struct winreg_SetKeySecurity *r2 = (struct winreg_SetKeySecurity *)r;
753                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
754                         DEBUG(5,("function winreg_SetKeySecurity replied async\n"));
755                 }
756                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
757                         NDR_PRINT_FUNCTION_DEBUG(winreg_SetKeySecurity, NDR_OUT | NDR_SET_VALUES, r2);
758                 }
759                 if (dce_call->fault_code != 0) {
760                         DEBUG(2,("dcerpc_fault %s in winreg_SetKeySecurity\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
761                 }
762                 break;
763         }
764         case 22: {
765                 struct winreg_SetValue *r2 = (struct winreg_SetValue *)r;
766                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
767                         DEBUG(5,("function winreg_SetValue replied async\n"));
768                 }
769                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
770                         NDR_PRINT_FUNCTION_DEBUG(winreg_SetValue, NDR_OUT | NDR_SET_VALUES, r2);
771                 }
772                 if (dce_call->fault_code != 0) {
773                         DEBUG(2,("dcerpc_fault %s in winreg_SetValue\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
774                 }
775                 break;
776         }
777         case 23: {
778                 struct winreg_UnLoadKey *r2 = (struct winreg_UnLoadKey *)r;
779                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
780                         DEBUG(5,("function winreg_UnLoadKey replied async\n"));
781                 }
782                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
783                         NDR_PRINT_FUNCTION_DEBUG(winreg_UnLoadKey, NDR_OUT | NDR_SET_VALUES, r2);
784                 }
785                 if (dce_call->fault_code != 0) {
786                         DEBUG(2,("dcerpc_fault %s in winreg_UnLoadKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
787                 }
788                 break;
789         }
790         case 24: {
791                 struct winreg_InitiateSystemShutdown *r2 = (struct winreg_InitiateSystemShutdown *)r;
792                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
793                         DEBUG(5,("function winreg_InitiateSystemShutdown replied async\n"));
794                 }
795                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
796                         NDR_PRINT_FUNCTION_DEBUG(winreg_InitiateSystemShutdown, NDR_OUT | NDR_SET_VALUES, r2);
797                 }
798                 if (dce_call->fault_code != 0) {
799                         DEBUG(2,("dcerpc_fault %s in winreg_InitiateSystemShutdown\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
800                 }
801                 break;
802         }
803         case 25: {
804                 struct winreg_AbortSystemShutdown *r2 = (struct winreg_AbortSystemShutdown *)r;
805                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
806                         DEBUG(5,("function winreg_AbortSystemShutdown replied async\n"));
807                 }
808                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
809                         NDR_PRINT_FUNCTION_DEBUG(winreg_AbortSystemShutdown, NDR_OUT | NDR_SET_VALUES, r2);
810                 }
811                 if (dce_call->fault_code != 0) {
812                         DEBUG(2,("dcerpc_fault %s in winreg_AbortSystemShutdown\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
813                 }
814                 break;
815         }
816         case 26: {
817                 struct winreg_GetVersion *r2 = (struct winreg_GetVersion *)r;
818                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
819                         DEBUG(5,("function winreg_GetVersion replied async\n"));
820                 }
821                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
822                         NDR_PRINT_FUNCTION_DEBUG(winreg_GetVersion, NDR_OUT | NDR_SET_VALUES, r2);
823                 }
824                 if (dce_call->fault_code != 0) {
825                         DEBUG(2,("dcerpc_fault %s in winreg_GetVersion\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
826                 }
827                 break;
828         }
829         case 27: {
830                 struct winreg_OpenHKCC *r2 = (struct winreg_OpenHKCC *)r;
831                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
832                         DEBUG(5,("function winreg_OpenHKCC replied async\n"));
833                 }
834                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
835                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKCC, NDR_OUT | NDR_SET_VALUES, r2);
836                 }
837                 if (dce_call->fault_code != 0) {
838                         DEBUG(2,("dcerpc_fault %s in winreg_OpenHKCC\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
839                 }
840                 break;
841         }
842         case 28: {
843                 struct winreg_OpenHKDD *r2 = (struct winreg_OpenHKDD *)r;
844                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
845                         DEBUG(5,("function winreg_OpenHKDD replied async\n"));
846                 }
847                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
848                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKDD, NDR_OUT | NDR_SET_VALUES, r2);
849                 }
850                 if (dce_call->fault_code != 0) {
851                         DEBUG(2,("dcerpc_fault %s in winreg_OpenHKDD\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
852                 }
853                 break;
854         }
855         case 29: {
856                 struct winreg_QueryMultipleValues *r2 = (struct winreg_QueryMultipleValues *)r;
857                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
858                         DEBUG(5,("function winreg_QueryMultipleValues replied async\n"));
859                 }
860                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
861                         NDR_PRINT_FUNCTION_DEBUG(winreg_QueryMultipleValues, NDR_OUT | NDR_SET_VALUES, r2);
862                 }
863                 if (dce_call->fault_code != 0) {
864                         DEBUG(2,("dcerpc_fault %s in winreg_QueryMultipleValues\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
865                 }
866                 break;
867         }
868         case 30: {
869                 struct winreg_InitiateSystemShutdownEx *r2 = (struct winreg_InitiateSystemShutdownEx *)r;
870                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
871                         DEBUG(5,("function winreg_InitiateSystemShutdownEx replied async\n"));
872                 }
873                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
874                         NDR_PRINT_FUNCTION_DEBUG(winreg_InitiateSystemShutdownEx, NDR_OUT | NDR_SET_VALUES, r2);
875                 }
876                 if (dce_call->fault_code != 0) {
877                         DEBUG(2,("dcerpc_fault %s in winreg_InitiateSystemShutdownEx\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
878                 }
879                 break;
880         }
881         case 31: {
882                 struct winreg_SaveKeyEx *r2 = (struct winreg_SaveKeyEx *)r;
883                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
884                         DEBUG(5,("function winreg_SaveKeyEx replied async\n"));
885                 }
886                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
887                         NDR_PRINT_FUNCTION_DEBUG(winreg_SaveKeyEx, NDR_OUT | NDR_SET_VALUES, r2);
888                 }
889                 if (dce_call->fault_code != 0) {
890                         DEBUG(2,("dcerpc_fault %s in winreg_SaveKeyEx\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
891                 }
892                 break;
893         }
894         case 32: {
895                 struct winreg_OpenHKPT *r2 = (struct winreg_OpenHKPT *)r;
896                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
897                         DEBUG(5,("function winreg_OpenHKPT replied async\n"));
898                 }
899                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
900                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKPT, NDR_OUT | NDR_SET_VALUES, r2);
901                 }
902                 if (dce_call->fault_code != 0) {
903                         DEBUG(2,("dcerpc_fault %s in winreg_OpenHKPT\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
904                 }
905                 break;
906         }
907         case 33: {
908                 struct winreg_OpenHKPN *r2 = (struct winreg_OpenHKPN *)r;
909                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
910                         DEBUG(5,("function winreg_OpenHKPN replied async\n"));
911                 }
912                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
913                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKPN, NDR_OUT | NDR_SET_VALUES, r2);
914                 }
915                 if (dce_call->fault_code != 0) {
916                         DEBUG(2,("dcerpc_fault %s in winreg_OpenHKPN\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
917                 }
918                 break;
919         }
920         case 34: {
921                 struct winreg_QueryMultipleValues2 *r2 = (struct winreg_QueryMultipleValues2 *)r;
922                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
923                         DEBUG(5,("function winreg_QueryMultipleValues2 replied async\n"));
924                 }
925                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
926                         NDR_PRINT_FUNCTION_DEBUG(winreg_QueryMultipleValues2, NDR_OUT | NDR_SET_VALUES, r2);
927                 }
928                 if (dce_call->fault_code != 0) {
929                         DEBUG(2,("dcerpc_fault %s in winreg_QueryMultipleValues2\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
930                 }
931                 break;
932         }
933         case 35: {
934                 struct winreg_DeleteKeyEx *r2 = (struct winreg_DeleteKeyEx *)r;
935                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
936                         DEBUG(5,("function winreg_DeleteKeyEx replied async\n"));
937                 }
938                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
939                         NDR_PRINT_FUNCTION_DEBUG(winreg_DeleteKeyEx, NDR_OUT | NDR_SET_VALUES, r2);
940                 }
941                 if (dce_call->fault_code != 0) {
942                         DEBUG(2,("dcerpc_fault %s in winreg_DeleteKeyEx\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
943                 }
944                 break;
945         }
946
947         default:
948                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
949                 break;
950         }
951
952         if (dce_call->fault_code != 0) {
953                 dcerpc_log_packet(dce_call->conn->packet_log_dir,
954                           &ndr_table_winreg, opnum, NDR_IN,
955                                   &dce_call->pkt.u.request.stub_and_verifier);
956                 return NT_STATUS_NET_WRITE_FAULT;
957         }
958
959         return NT_STATUS_OK;
960 }
961
962 static NTSTATUS winreg__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
963 {
964         enum ndr_err_code ndr_err;
965         uint16_t opnum = dce_call->pkt.u.request.opnum;
966
967         ndr_err = ndr_table_winreg.calls[opnum].ndr_push(push, NDR_OUT, r);
968         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
969                 dce_call->fault_code = DCERPC_FAULT_NDR;
970                 return NT_STATUS_NET_WRITE_FAULT;
971         }
972
973         return NT_STATUS_OK;
974 }
975
976 const struct dcesrv_interface dcesrv_winreg_interface = {
977         .name           = "winreg",
978         .syntax_id  = {{0x338cd001,0x2244,0x31f1,{0xaa,0xaa},{0x90,0x00,0x38,0x00,0x10,0x03}},1.0},
979         .bind           = winreg__op_bind,
980         .unbind         = winreg__op_unbind,
981         .ndr_pull       = winreg__op_ndr_pull,
982         .dispatch       = winreg__op_dispatch,
983         .reply          = winreg__op_reply,
984         .ndr_push       = winreg__op_ndr_push
985 };
986
987
988 static NTSTATUS winreg__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
989 {
990         int i;
991
992         for (i=0;i<ndr_table_winreg.endpoints->count;i++) {
993                 NTSTATUS ret;
994                 const char *name = ndr_table_winreg.endpoints->names[i];
995
996                 ret = dcesrv_interface_register(dce_ctx, name, &dcesrv_winreg_interface, NULL);
997                 if (!NT_STATUS_IS_OK(ret)) {
998                         DEBUG(1,("winreg_op_init_server: failed to register endpoint '%s'\n",name));
999                         return ret;
1000                 }
1001         }
1002
1003         return NT_STATUS_OK;
1004 }
1005
1006 static bool winreg__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
1007 {
1008         if (dcesrv_winreg_interface.syntax_id.if_version == if_version &&
1009                 GUID_equal(&dcesrv_winreg_interface.syntax_id.uuid, uuid)) {
1010                 memcpy(iface,&dcesrv_winreg_interface, sizeof(*iface));
1011                 return true;
1012         }
1013
1014         return false;
1015 }
1016
1017 static bool winreg__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
1018 {
1019         if (strcmp(dcesrv_winreg_interface.name, name)==0) {
1020                 memcpy(iface, &dcesrv_winreg_interface, sizeof(*iface));
1021                 return true;
1022         }
1023
1024         return false;   
1025 }
1026         
1027 NTSTATUS dcerpc_server_winreg_init(void)
1028 {
1029         NTSTATUS ret;
1030         struct dcesrv_endpoint_server ep_server;
1031
1032         /* fill in our name */
1033         ep_server.name = "winreg";
1034
1035         /* fill in all the operations */
1036         ep_server.init_server = winreg__op_init_server;
1037
1038         ep_server.interface_by_uuid = winreg__op_interface_by_uuid;
1039         ep_server.interface_by_name = winreg__op_interface_by_name;
1040
1041         /* register ourselves with the DCERPC subsystem. */
1042         ret = dcerpc_register_ep_server(&ep_server);
1043
1044         if (!NT_STATUS_IS_OK(ret)) {
1045                 DEBUG(0,("Failed to register 'winreg' endpoint server!\n"));
1046                 return ret;
1047         }
1048
1049         return ret;
1050 }
1051